You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.0 KiB
JavaScript
82 lines
3.0 KiB
JavaScript
define("dijit/form/MappedTextBox", [
|
|
"dojo/_base/declare", // declare
|
|
"dojo/dom-construct", // domConstruct.place
|
|
"./ValidationTextBox"
|
|
], function(declare, domConstruct, ValidationTextBox){
|
|
|
|
// module:
|
|
// dijit/form/MappedTextBox
|
|
|
|
return declare("dijit.form.MappedTextBox", ValidationTextBox, {
|
|
// summary:
|
|
// A dijit/form/ValidationTextBox subclass which provides a base class for widgets that have
|
|
// a visible formatted display value, and a serializable
|
|
// value in a hidden input field which is actually sent to the server.
|
|
// description:
|
|
// The visible display may
|
|
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
|
|
// input field which uses the `name` attribute declared by the original widget. That value sent
|
|
// to the server is defined by the dijit/form/MappedTextBox.serialize() method and is typically
|
|
// locale-neutral.
|
|
// tags:
|
|
// protected
|
|
|
|
postMixInProperties: function(){
|
|
this.inherited(arguments);
|
|
|
|
// we want the name attribute to go to the hidden <input>, not the displayed <input>,
|
|
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
|
|
this.nameAttrSetting = "";
|
|
},
|
|
|
|
// Override default behavior to assign name to focusNode
|
|
_setNameAttr: null,
|
|
|
|
serialize: function(val /*=====, options =====*/){
|
|
// summary:
|
|
// Overridable function used to convert the get('value') result to a canonical
|
|
// (non-localized) string. For example, will print dates in ISO format, and
|
|
// numbers the same way as they are represented in javascript.
|
|
// val: anything
|
|
// options: Object?
|
|
// tags:
|
|
// protected extension
|
|
return val.toString ? val.toString() : ""; // String
|
|
},
|
|
|
|
toString: function(){
|
|
// summary:
|
|
// Returns widget as a printable string using the widget's value
|
|
// tags:
|
|
// protected
|
|
var val = this.filter(this.get('value')); // call filter in case value is nonstring and filter has been customized
|
|
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
|
|
},
|
|
|
|
validate: function(){
|
|
// Overrides `dijit/form/TextBox.validate`
|
|
this.valueNode.value = this.toString();
|
|
return this.inherited(arguments);
|
|
},
|
|
|
|
buildRendering: function(){
|
|
// Overrides `dijit/_TemplatedMixin/buildRendering`
|
|
|
|
this.inherited(arguments);
|
|
|
|
// Create a hidden <input> node with the serialized value used for submit
|
|
// (as opposed to the displayed value).
|
|
// Passing in name as markup rather than calling domConstruct.create() with an attrs argument
|
|
// to make query(input[name=...]) work on IE. (see #8660)
|
|
this.valueNode = domConstruct.place("<input type='hidden'" + (this.name ? ' name="' + this.name.replace(/"/g, """) + '"' : "") + "/>", this.textbox, "after");
|
|
},
|
|
|
|
reset: function(){
|
|
// Overrides `dijit/form/ValidationTextBox.reset` to
|
|
// reset the hidden textbox value to ''
|
|
this.valueNode.value = '';
|
|
this.inherited(arguments);
|
|
}
|
|
});
|
|
});
|