1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-19 19:11:29 +00:00

update dojo to 1.7.3

This commit is contained in:
Andrew Dolgov
2012-08-14 18:59:10 +04:00
parent d04f8c826f
commit 1354d17270
1616 changed files with 135064 additions and 97680 deletions

View File

@@ -4,139 +4,5 @@
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojo.store.DataStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojo.store.DataStore"] = true;
dojo.provide("dojo.store.DataStore");
dojo.require("dojo.store.util.QueryResults");
dojo.declare("dojo.store.DataStore", null, {
target: "",
constructor: function(options){
// summary:
// This is an adapter for using Dojo Data stores with an object store consumer.
// You can provide a Dojo data store and use this adapter to interact with it through
// the Dojo object store API
// options: Object?
// This provides any configuration information that will be mixed into the store,
// including a reference to the Dojo data store under the property "store".
dojo.mixin(this, options);
},
_objectConverter: function(callback){
var store = this.store;
return function(item){
var object = {};
var attributes = store.getAttributes(item);
for(var i = 0; i < attributes.length; i++){
object[attributes[i]] = store.getValue(item, attributes[i]);
}
return callback(object);
};
},
get: function(id, options){
// summary:
// Retrieves an object by it's identity. This will trigger a fetchItemByIdentity
// id: Object?
// The identity to use to lookup the object
var returnedObject, returnedError;
var deferred = new dojo.Deferred();
this.store.fetchItemByIdentity({
identity: id,
onItem: this._objectConverter(function(object){
deferred.resolve(returnedObject = object);
}),
onError: function(error){
deferred.reject(returnedError = error);
}
});
if(returnedObject){
// if it was returned synchronously
return returnedObject;
}
if(returnedError){
throw returnedError;
}
return deferred.promise;
},
put: function(object, options){
// summary:
// Stores an object by its identity.
// object: Object
// The object to store.
// options: Object?
// Additional metadata for storing the data. Includes a reference to an id
// that the object may be stored with (i.e. { id: "foo" }).
var id = options && typeof options.id != "undefined" || this.getIdentity(object);
var store = this.store;
if(typeof id == "undefined"){
store.newItem(object);
}else{
store.fetchItemByIdentity({
identity: id,
onItem: function(item){
if(item){
for(var i in object){
if(store.getValue(item, i) != object[i]){
store.setValue(item, i, object[i]);
}
}
}else{
store.newItem(object);
}
}
});
}
},
remove: function(id){
// summary:
// Deletes an object by its identity.
// id: Object
// The identity to use to delete the object
var store = this.store;
this.store.fetchItemByIdentity({
identity: id,
onItem: function(item){
store.deleteItem(item);
}
});
},
query: function(query, options){
// summary:
// Queries the store for objects.
// query: Object
// The query to use for retrieving objects from the store
// options: Object?
// Optional options object as used by the underlying dojo.data Store.
// returns: dojo.store.util.QueryResults
// A query results object that can be used to iterate over results.
var returnedObject, returnedError;
var deferred = new dojo.Deferred();
deferred.total = new dojo.Deferred();
var converter = this._objectConverter(function(object){return object;});
this.store.fetch(dojo.mixin({
query: query,
onBegin: function(count){
deferred.total.resolve(count);
},
onComplete: function(results){
deferred.resolve(dojo.map(results, converter));
},
onError: function(error){
deferred.reject(error);
}
}, options));
return dojo.store.util.QueryResults(deferred);
},
getIdentity: function(object){
// summary:
// Fetch the identity for the given object.
// object: Object
// The data object to get the identity from.
// returns: Number
// The id of the given object.
return object[this.idProperty || this.store.getIdentityAttributes()[0]];
}
});
}
//>>built
define("dojo/store/DataStore",["../_base/lang","../_base/declare","../_base/Deferred","../_base/array","./util/QueryResults"],function(_1,_2,_3,_4,_5){return _2("dojo.store.DataStore",null,{target:"",constructor:function(_6){_1.mixin(this,_6);if(!"idProperty" in _6){var _7;try{_7=this.store.getIdentityAttributes();}catch(e){}this.idProperty=(!_7||!idAttributes[0])||this.idProperty;}var _8=this.store.getFeatures();if(!_8["dojo.data.api.Read"]){this.get=null;}if(!_8["dojo.data.api.Identity"]){this.getIdentity=null;}if(!_8["dojo.data.api.Write"]){this.put=this.add=null;}},idProperty:"id",store:null,_objectConverter:function(_9){var _a=this.store;var _b=this.idProperty;return function(_c){var _d={};var _e=_a.getAttributes(_c);for(var i=0;i<_e.length;i++){_d[_e[i]]=_a.getValue(_c,_e[i]);}if(!(_b in _d)){_d[_b]=_a.getIdentity(_c);}return _9(_d);};},get:function(id,_f){var _10,_11;var _12=new _3();this.store.fetchItemByIdentity({identity:id,onItem:this._objectConverter(function(_13){_12.resolve(_10=_13);}),onError:function(_14){_12.reject(_11=_14);}});if(_10){return _10;}if(_11){throw _11;}return _12.promise;},put:function(_15,_16){var id=_16&&typeof _16.id!="undefined"||this.getIdentity(_15);var _17=this.store;var _18=this.idProperty;if(typeof id=="undefined"){_17.newItem(_15);}else{_17.fetchItemByIdentity({identity:id,onItem:function(_19){if(_19){for(var i in _15){if(i!=_18&&_17.getValue(_19,i)!=_15[i]){_17.setValue(_19,i,_15[i]);}}}else{_17.newItem(_15);}}});}},remove:function(id){var _1a=this.store;this.store.fetchItemByIdentity({identity:id,onItem:function(_1b){_1a.deleteItem(_1b);}});},query:function(_1c,_1d){var _1e;var _1f=new _3(function(){_1e.abort&&_1e.abort();});_1f.total=new _3();var _20=this._objectConverter(function(_21){return _21;});_1e=this.store.fetch(_1.mixin({query:_1c,onBegin:function(_22){_1f.total.resolve(_22);},onComplete:function(_23){_1f.resolve(_4.map(_23,_20));},onError:function(_24){_1f.reject(_24);}},_1d));return _5(_1f);},getIdentity:function(_25){return _25[this.idProperty];}});});