]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/MappedTextBox.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dijit / form / MappedTextBox.js.uncompressed.js
1 define("dijit/form/MappedTextBox", [
2 "dojo/_base/declare", // declare
3 "dojo/dom-construct", // domConstruct.place
4 "./ValidationTextBox"
5 ], function(declare, domConstruct, ValidationTextBox){
6
7 // module:
8 // dijit/form/MappedTextBox
9
10 return declare("dijit.form.MappedTextBox", ValidationTextBox, {
11 // summary:
12 // A dijit/form/ValidationTextBox subclass which provides a base class for widgets that have
13 // a visible formatted display value, and a serializable
14 // value in a hidden input field which is actually sent to the server.
15 // description:
16 // The visible display may
17 // be locale-dependent and interactive. The value sent to the server is stored in a hidden
18 // input field which uses the `name` attribute declared by the original widget. That value sent
19 // to the server is defined by the dijit/form/MappedTextBox.serialize() method and is typically
20 // locale-neutral.
21 // tags:
22 // protected
23
24 postMixInProperties: function(){
25 this.inherited(arguments);
26
27 // we want the name attribute to go to the hidden <input>, not the displayed <input>,
28 // so override _FormWidget.postMixInProperties() setting of nameAttrSetting
29 this.nameAttrSetting = "";
30 },
31
32 // Override default behavior to assign name to focusNode
33 _setNameAttr: null,
34
35 serialize: function(val /*=====, options =====*/){
36 // summary:
37 // Overridable function used to convert the get('value') result to a canonical
38 // (non-localized) string. For example, will print dates in ISO format, and
39 // numbers the same way as they are represented in javascript.
40 // val: anything
41 // options: Object?
42 // tags:
43 // protected extension
44 return val.toString ? val.toString() : ""; // String
45 },
46
47 toString: function(){
48 // summary:
49 // Returns widget as a printable string using the widget's value
50 // tags:
51 // protected
52 var val = this.filter(this.get('value')); // call filter in case value is nonstring and filter has been customized
53 return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
54 },
55
56 validate: function(){
57 // Overrides `dijit/form/TextBox.validate`
58 this.valueNode.value = this.toString();
59 return this.inherited(arguments);
60 },
61
62 buildRendering: function(){
63 // Overrides `dijit/_TemplatedMixin/buildRendering`
64
65 this.inherited(arguments);
66
67 // Create a hidden <input> node with the serialized value used for submit
68 // (as opposed to the displayed value).
69 // Passing in name as markup rather than calling domConstruct.create() with an attrs argument
70 // to make query(input[name=...]) work on IE. (see #8660)
71 this.valueNode = domConstruct.place("<input type='hidden'" + (this.name ? ' name="' + this.name.replace(/"/g, "&quot;") + '"' : "") + "/>", this.textbox, "after");
72 },
73
74 reset: function(){
75 // Overrides `dijit/form/ValidationTextBox.reset` to
76 // reset the hidden textbox value to ''
77 this.valueNode.value = '';
78 this.inherited(arguments);
79 }
80 });
81 });