]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_FormWidget.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dijit.form._FormWidget"]){
9 dojo
._hasResource
["dijit.form._FormWidget"]=true;
10 dojo
.provide("dijit.form._FormWidget");
11 dojo
.require("dojo.window");
12 dojo
.require("dijit._Widget");
13 dojo
.require("dijit._Templated");
14 dojo
.require("dijit._CssStateMixin");
15 dojo
.declare("dijit.form._FormWidget",[dijit
._Widget
,dijit
._Templated
,dijit
._CssStateMixin
],{name
:"",alt
:"",value
:"",type
:"text",tabIndex
:"0",disabled
:false,intermediateChanges
:false,scrollOnFocus
:true,attributeMap
:dojo
.delegate(dijit
._Widget
.prototype.attributeMap
,{value
:"focusNode",id
:"focusNode",tabIndex
:"focusNode",alt
:"focusNode",title
:"focusNode"}),postMixInProperties:function(){
16 this.nameAttrSetting
=this.name
?("name=\""+this.name
.replace(/'/g,""")+"\""):"";
17 this.inherited(arguments);
18 },postCreate:function(){
19 this.inherited(arguments);
20 this.connect(this.domNode,"onmousedown","_onMouseDown");
21 },_setDisabledAttr:function(_1){
23 dojo.attr(this.focusNode,"disabled",_1);
25 dojo.attr(this.valueNode,"disabled",_1);
27 dijit.setWaiState(this.focusNode,"disabled",_1);
31 var _2="tabIndex" in this.attributeMap?this.attributeMap.tabIndex:"focusNode";
32 dojo.forEach(dojo.isArray(_2)?_2:[_2],function(_3){
34 if(dojo.isWebKit||dijit.hasDefaultTabStop(_4)){
35 _4.setAttribute("tabIndex","-1");
37 _4.removeAttribute("tabIndex");
41 this.focusNode.setAttribute("tabIndex",this.tabIndex);
43 },setDisabled:function(_5){
44 dojo.deprecated("setDisabled("+_5+") is deprecated. Use set('disabled
',"+_5+") instead.","","2.0");
45 this.set("disabled",_5);
46 },_onFocus:function(e){
47 if(this.scrollOnFocus){
48 dojo.window.scrollIntoView(this.domNode);
50 this.inherited(arguments);
51 },isFocusable:function(){
52 return !this.disabled&&!this.readOnly&&this.focusNode&&(dojo.style(this.domNode,"display")!="none");
54 dijit.focus(this.focusNode);
55 },compare:function(_6,_7){
56 if(typeof _6=="number"&&typeof _7=="number"){
57 return (isNaN(_6)&&isNaN(_7))?0:_6-_7;
69 },onChange:function(_8){
70 },_onChangeActive:false,_handleOnChange:function(_9,_a){
72 if(this._lastValueReported==undefined&&(_a===null||!this._onChangeActive)){
73 this._resetValue=this._lastValueReported=_9;
75 if((this.intermediateChanges||_a||_a===undefined)&&((typeof _9!=typeof this._lastValueReported)||this.compare(_9,this._lastValueReported)!=0)){
76 this._lastValueReported=_9;
77 if(this._onChangeActive){
78 if(this._onChangeHandle){
79 clearTimeout(this._onChangeHandle);
81 this._onChangeHandle=setTimeout(dojo.hitch(this,function(){
82 this._onChangeHandle=null;
88 this.inherited(arguments);
89 this._onChangeActive=true;
91 if(this._onChangeHandle){
92 clearTimeout(this._onChangeHandle);
93 this.onChange(this._lastValueReported);
95 this.inherited(arguments);
96 },setValue:function(_b){
97 dojo.deprecated("dijit.form._FormWidget:setValue("+_b+") is deprecated. Use set('value
',"+_b+") instead.","","2.0");
99 },getValue:function(){
100 dojo.deprecated(this.declaredClass+"::getValue() is deprecated. Use get('value
') instead.","","2.0");
101 return this.get("value");
102 },_onMouseDown:function(e){
103 if(!e.ctrlKey&&this.isFocusable()){
104 var _c=this.connect(dojo.body(),"onmouseup",function(){
105 if(this.isFocusable()){
112 dojo.declare("dijit.form._FormValueWidget",dijit.form._FormWidget,{readOnly:false,attributeMap:dojo.delegate(dijit.form._FormWidget.prototype.attributeMap,{value:"",readOnly:"focusNode"}),_setReadOnlyAttr:function(_d){
114 dojo.attr(this.focusNode,"readOnly",_d);
115 dijit.setWaiState(this.focusNode,"readonly",_d);
116 },postCreate:function(){
117 this.inherited(arguments);
119 this.connect(this.focusNode||this.domNode,"onkeydown",this._onKeyDown);
121 if(this._resetValue===undefined){
122 this._resetValue=this.value;
124 },_setValueAttr:function(_e,_f){
126 this._handleOnChange(_e,_f);
127 },_getValueAttr:function(){
128 return this._lastValue;
130 this._setValueAttr(this._lastValueReported,false);
132 this._hasBeenBlurred=false;
133 this._setValueAttr(this._resetValue,true);
134 },_onKeyDown:function(e){
135 if(e.keyCode==dojo.keys.ESCAPE&&!(e.ctrlKey||e.altKey||e.metaKey)){
139 te=document.createEventObject();
140 te.keyCode=dojo.keys.ESCAPE;
141 te.shiftKey=e.shiftKey;
142 e.srcElement.fireEvent("onkeypress",te);
145 },_layoutHackIE7:function(){
147 var _10=this.domNode;
148 var _11=_10.parentNode;
149 var _12=_10.firstChild||_10;
150 var _13=_12.style.filter;
152 while(_11&&_11.clientHeight==0){
154 var _15=_14.connect(_11,"onscroll",function(e){
156 _12.style.filter=(new Date()).getMilliseconds();
157 setTimeout(function(){
158 _12.style.filter=_13;