//>>built require({cache:{ 'url:dijit/form/templates/TextBox.html':"
\n"}}); define("dijit/form/TextBox", [ "dojo/_base/declare", // declare "dojo/dom-construct", // domConstruct.create "dojo/dom-style", // domStyle.getComputedStyle "dojo/_base/kernel", // kernel.deprecated "dojo/_base/lang", // lang.hitch "dojo/_base/sniff", // has("ie") has("mozilla") "dojo/_base/window", // win.doc.selection.createRange "./_FormValueWidget", "./_TextBoxMixin", "dojo/text!./templates/TextBox.html", ".." // to export dijit._setSelectionRange, remove in 2.0 ], function(declare, domConstruct, domStyle, kernel, lang, has, win, _FormValueWidget, _TextBoxMixin, template, dijit){ /*===== var _FormValueWidget = dijit.form._FormValueWidget; var _TextBoxMixin = dijit.form._TextBoxMixin; =====*/ // module: // dijit/form/TextBox // summary: // A base class for textbox form inputs var TextBox = declare(/*====="dijit.form.TextBox", =====*/ [_FormValueWidget, _TextBoxMixin], { // summary: // A base class for textbox form inputs templateString: template, _singleNodeTemplate: '', _buttonInputDisabled: has("ie") ? "disabled" : "", // allows IE to disallow focus, but Firefox cannot be disabled for mousedown events baseClass: "dijitTextBox", postMixInProperties: function(){ var type = this.type.toLowerCase(); if(this.templateString && this.templateString.toLowerCase() == "input" || ((type == "hidden" || type == "file") && this.templateString == this.constructor.prototype.templateString)){ this.templateString = this._singleNodeTemplate; } this.inherited(arguments); }, _onInput: function(e){ this.inherited(arguments); if(this.intermediateChanges){ // _TextBoxMixin uses onInput var _this = this; // the setTimeout allows the key to post to the widget input box setTimeout(function(){ _this._handleOnChange(_this.get('value'), false); }, 0); } }, _setPlaceHolderAttr: function(v){ this._set("placeHolder", v); if(!this._phspan){ this._attachPoints.push('_phspan'); // dijitInputField class gives placeHolder same padding as the input field // parent node already has dijitInputField class but it doesn't affect this // since it's position: absolute. this._phspan = domConstruct.create('span',{className:'dijitPlaceHolder dijitInputField'},this.textbox,'after'); } this._phspan.innerHTML=""; this._phspan.appendChild(document.createTextNode(v)); this._updatePlaceHolder(); }, _updatePlaceHolder: function(){ if(this._phspan){ this._phspan.style.display=(this.placeHolder&&!this.focused&&!this.textbox.value)?"":"none"; } }, _setValueAttr: function(value, /*Boolean?*/ priorityChange, /*String?*/ formattedValue){ this.inherited(arguments); this._updatePlaceHolder(); }, getDisplayedValue: function(){ // summary: // Deprecated. Use get('displayedValue') instead. // tags: // deprecated kernel.deprecated(this.declaredClass+"::getDisplayedValue() is deprecated. Use set('displayedValue') instead.", "", "2.0"); return this.get('displayedValue'); }, setDisplayedValue: function(/*String*/ value){ // summary: // Deprecated. Use set('displayedValue', ...) instead. // tags: // deprecated kernel.deprecated(this.declaredClass+"::setDisplayedValue() is deprecated. Use set('displayedValue', ...) instead.", "", "2.0"); this.set('displayedValue', value); }, _onBlur: function(e){ if(this.disabled){ return; } this.inherited(arguments); this._updatePlaceHolder(); }, _onFocus: function(/*String*/ by){ if(this.disabled || this.readOnly){ return; } this.inherited(arguments); this._updatePlaceHolder(); } }); if(has("ie")){ TextBox = declare(/*===== "dijit.form.TextBox.IEMixin", =====*/ TextBox, { declaredClass: "dijit.form.TextBox", // for user code referencing declaredClass _isTextSelected: function(){ var range = win.doc.selection.createRange(); var parent = range.parentElement(); return parent == this.textbox && range.text.length == 0; }, postCreate: function(){ this.inherited(arguments); // IE INPUT tag fontFamily has to be set directly using STYLE // the setTimeout gives IE a chance to render the TextBox and to deal with font inheritance setTimeout(lang.hitch(this, function(){ try{ var s = domStyle.getComputedStyle(this.domNode); // can throw an exception if widget is immediately destroyed if(s){ var ff = s.fontFamily; if(ff){ var inputs = this.domNode.getElementsByTagName("INPUT"); if(inputs){ for(var i=0; i < inputs.length; i++){ inputs[i].style.fontFamily = ff; } } } } }catch(e){/*when used in a Dialog, and this is called before the dialog is shown, s.fontFamily would trigger "Invalid Argument" error.*/} }), 0); } }); // Overrides definition of _setSelectionRange from _TextBoxMixin (TODO: move to _TextBoxMixin.js?) dijit._setSelectionRange = _TextBoxMixin._setSelectionRange = function(/*DomNode*/ element, /*Number?*/ start, /*Number?*/ stop){ if(element.createTextRange){ var r = element.createTextRange(); r.collapse(true); r.moveStart("character", -99999); // move to 0 r.moveStart("character", start); // delta from 0 is the correct position r.moveEnd("character", stop-start); r.select(); } } }else if(has("mozilla")){ TextBox = declare(/*===== "dijit.form.TextBox.MozMixin", =====*/TextBox, { declaredClass: "dijit.form.TextBox", // for user code referencing declaredClass _onBlur: function(e){ this.inherited(arguments); if(this.selectOnClick){ // clear selection so that the next mouse click doesn't reselect this.textbox.selectionStart = this.textbox.selectionEnd = undefined; } } }); }else{ TextBox.prototype.declaredClass = "dijit.form.TextBox"; } lang.setObject("dijit.form.TextBox", TextBox); // don't do direct assignment, it confuses API doc parser return TextBox; });