Debian Codegraph @

dijit/form/MappedTextBox.js

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