tt-rss/lib/dijit/form/_FormSelectWidget.js

2 lines
9.1 KiB
JavaScript
Raw Normal View History

2012-08-14 16:59:10 +02:00
//>>built
define("dijit/form/_FormSelectWidget",["dojo/_base/array","dojo/_base/Deferred","dojo/aspect","dojo/data/util/sorter","dojo/_base/declare","dojo/dom","dojo/dom-class","dojo/_base/kernel","dojo/_base/lang","dojo/query","dojo/when","dojo/store/util/QueryResults","./_FormValueWidget"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d){var _e=_5("dijit.form._FormSelectWidget",_d,{multiple:false,options:null,store:null,_setStoreAttr:function(_f){if(this._created){this._deprecatedSetStore(_f);}},query:null,_setQueryAttr:function(_10){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{query:_10});}},queryOptions:null,_setQueryOptionsAttr:function(_11){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{queryOptions:_11});}},labelAttr:"",onFetch:null,sortByLabel:true,loadChildrenOnOpen:false,onLoadDeferred:null,getOptions:function(_12){var _13=this.options||[];if(_12==null){return _13;}if(_9.isArrayLike(_12)){return _1.map(_12,"return this.getOptions(item);",this);}if(_9.isString(_12)){_12={value:_12};}if(_9.isObject(_12)){if(!_1.some(_13,function(_14,idx){for(var a in _12){if(!(a in _14)||_14[a]!=_12[a]){return false;}}_12=idx;return true;})){_12=-1;}}if(_12>=0&&_12<_13.length){return _13[_12];}return null;},addOption:function(_15){_1.forEach(_9.isArrayLike(_15)?_15:[_15],function(i){if(i&&_9.isObject(i)){this.options.push(i);}},this);this._loadChildren();},removeOption:function(_16){var _17=this.getOptions(_9.isArrayLike(_16)?_16:[_16]);_1.forEach(_17,function(_18){if(_18){this.options=_1.filter(this.options,function(_19){return (_19.value!==_18.value||_19.label!==_18.label);});this._removeOptionItem(_18);}},this);this._loadChildren();},updateOption:function(_1a){_1.forEach(_9.isArrayLike(_1a)?_1a:[_1a],function(i){var _1b=this.getOptions({value:i.value}),k;if(_1b){for(k in i){_1b[k]=i[k];}}},this);this._loadChildren();},setStore:function(_1c,_1d,_1e){_8.deprecated(this.declaredClass+"::setStore(store, selectedValue, fetchArgs) is deprecated. Use set('query', fetchArgs.query), set('queryOptions', fetchArgs.queryOptions), set('store', store), or set('value', selectedValue) instead.","","2.0");this._deprecatedSetStore(_1c,_1d,_1e);},_deprecatedSetStore:function(_1f,_20,_21){var _22=this.store;_21=_21||{};if(_22!==_1f){var h;while((h=this._notifyConnections.pop())){h.remove();}if(!_1f.get){_9.mixin(_1f,{_oldAPI:true,get:function(id){var _23=new _2();this.fetchItemByIdentity({identity:id,onItem:function(_24){_23.resolve(_24);},onError:function(_25){_23.reject(_25);}});return _23.promise;},query:function(_26,_27){var _28=new _2(function(){if(_29.abort){_29.abort();}});_28.total=new _2();var _29=this.fetch(_9.mixin({query:_26,onBegin:function(_2a){_28.total.resolve(_2a);},onComplete:function(_2b){_28.resolve(_2b);},onError:function(_2c){_28.reject(_2c);}},_27));return new _c(_28);}});if(_1f.getFeatures()["dojo.data.api.Notification"]){this._notifyConnections=[_3.after(_1f,"onNew",_9.hitch(this,"_onNewItem"),true),_3.after(_1f,"onDelete",_9.hitch(this,"_onDeleteItem"),true),_3.after(_1f,"onSet",_9.hitch(this,"_onSetItem"),true)];}}this._set("store",_1f);}if(this.options&&this.options.length){this.removeOption(this.options);}if(this._queryRes&&this._queryRes.close){this._queryRes.close();}if(this._observeHandle&&this._observeHandle.remove){this._observeHandle.remove();this._observeHandle=null;}if(_21.query){this._set("query",_21.query);}if(_21.queryOptions){this._set("queryOptions",_21.queryOptions);}if(_1f&&_1f.query){this._loadingStore=true;this.onLoadDeferred=new _2();this._queryRes=_1f.query(this.query,this.queryOptions);_b(this._queryRes,_9.hitch(this,function(_2d){if(this.sortByLabel&&!_21.sort&&_2d.length){if(_1f.getValue){_2d.sort(_4.createSortFunction([{attribute:_1f.getLabelAttributes(_2d[0])[0]}],_1f));}else{var _2e=this.labelAttr;_2d.sort(function(a,b){return a[_2e]>b[_2e]?1:b[_2e]>a[_2e]?-1:0;});}}if(_21.onFetch){_2d=_21.onFetch.call(this,_2d,_21);}_1.forEach(_2d,function(i){this._addOptionForItem(i);},this);if(this._queryRes.observe){this._observeHandle=this._queryRes.observe(_