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