ttrss/lib/dojo/data/ItemFileReadStore.js

8 lines
13 KiB
JavaScript
Raw Normal View History

/*
2011-11-08 16:40:44 +00:00
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
2012-08-14 14:59:10 +00:00
//>>built
define("dojo/data/ItemFileReadStore",["../_base/kernel","../_base/lang","../_base/declare","../_base/array","../_base/xhr","../Evented","../_base/window","./util/filter","./util/simpleFetch","../date/stamp"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a){var _b=_3("dojo.data.ItemFileReadStore",[_6],{constructor:function(_c){this._arrayOfAllItems=[];this._arrayOfTopLevelItems=[];this._loadFinished=false;this._jsonFileUrl=_c.url;this._ccUrl=_c.url;this.url=_c.url;this._jsonData=_c.data;this.data=null;this._datatypeMap=_c.typeMap||{};if(!this._datatypeMap["Date"]){this._datatypeMap["Date"]={type:Date,deserialize:function(_d){return _a.fromISOString(_d);}};}this._features={"dojo.data.api.Read":true,"dojo.data.api.Identity":true};this._itemsByIdentity=null;this._storeRefPropName="_S";this._itemNumPropName="_0";this._rootItemPropName="_RI";this._reverseRefMap="_RRM";this._loadInProgress=false;this._queuedFetches=[];if(_c.urlPreventCache!==undefined){this.urlPreventCache=_c.urlPreventCache?true:false;}if(_c.hierarchical!==undefined){this.hierarchical=_c.hierarchical?true:false;}if(_c.clearOnClose){this.clearOnClose=true;}if("failOk" in _c){this.failOk=_c.failOk?true:false;}},url:"",_ccUrl:"",data:null,typeMap:null,clearOnClose:false,urlPreventCache:false,failOk:false,hierarchical:true,_assertIsItem:function(_e){if(!this.isItem(_e)){throw new Error("dojo.data.ItemFileReadStore: Invalid item argument.");}},_assertIsAttribute:function(_f){if(typeof _f!=="string"){throw new Error("dojo.data.ItemFileReadStore: Invalid attribute argument.");}},getValue:function(_10,_11,_12){var _13=this.getValues(_10,_11);return (_13.length>0)?_13[0]:_12;},getValues:function(_14,_15){this._assertIsItem(_14);this._assertIsAttribute(_15);return (_14[_15]||[]).slice(0);},getAttributes:function(_16){this._assertIsItem(_16);var _17=[];for(var key in _16){if((key!==this._storeRefPropName)&&(key!==this._itemNumPropName)&&(key!==this._rootItemPropName)&&(key!==this._reverseRefMap)){_17.push(key);}}return _17;},hasAttribute:function(_18,_19){this._assertIsItem(_18);this._assertIsAttribute(_19);return (_19 in _18);},containsValue:function(_1a,_1b,_1c){var _1d=undefined;if(typeof _1c==="string"){_1d=_8.patternToRegExp(_1c,false);}return this._containsValue(_1a,_1b,_1c,_1d);},_containsValue:function(_1e,_1f,_20,_21){return _4.some(this.getValues(_1e,_1f),function(_22){if(_22!==null&&!_2.isObject(_22)&&_21){if(_22.toString().match(_21)){return true;}}else{if(_20===_22){return true;}}});},isItem:function(_23){if(_23&&_23[this._storeRefPropName]===this){if(this._arrayOfAllItems[_23[this._itemNumPropName]]===_23){return true;}}return false;},isItemLoaded:function(_24){return this.isItem(_24);},loadItem:function(_25){this._assertIsItem(_25.item);},getFeatures:function(){return this._features;},getLabel:function(_26){if(this._labelAttr&&this.isItem(_26)){return this.getValue(_26,this._labelAttr);}return undefined;},getLabelAttributes:function(_27){if(this._labelAttr){return [this._labelAttr];}return null;},_fetchItems:function(_28,_29,_2a){var _2b=this,_2c=function(_2d,_2e){var _2f=[],i,key;if(_2d.query){var _30,_31=_2d.queryOptions?_2d.queryOptions.ignoreCase:false;var _32={};for(key in _2d.query){_30=_2d.query[key];if(typeof _30==="string"){_32[key]=_8.patternToRegExp(_30,_31);}else{if(_30 instanceof RegExp){_32[key]=_30;}}}for(i=0;i<_2e.length;++i){var _33=true;var _34=_2e[i];if(_34===null){_33=false;}else{for(key in _2d.query){_30=_2d.query[key];if(!_2b._containsValue(_34,key,_30,_32[key])){_33=false;}}}if(_33){_2f.push(_34);}}_29(_2f,_2d);}else{for(i=0;i<_2e.length;++i){var _35=_2e[i];if(_35!==null){_2f.push(_35);}}_29(_2f,_2d);}};if(this._loadFinished){_2c(_28,this._getItemsArray(_28.queryOptions));}else{if(this._jsonFileUrl!==this._ccUrl){_1.deprecated("dojo.data.ItemFileReadStore: ","To change the url, set the url property of the store,"+" not _jsonFileUrl. _jsonFileUrl support will be removed in 2.0");this._ccUrl=this._jsonFileUrl;this.url=this._jsonFileUrl;}else{if(this.url!==this._ccUrl){this._jsonFileUrl=this.url;this._ccUrl=this.url;}}if(this.data!=null){this.