]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/store/JsonRest.js
lib: Upgrade Dojo and Dijit from 1.8.3 to 1.12.1
[tt-rss.git] / lib / dojo / store / JsonRest.js
index dc00d973fba85936bcb07a7697fe1bba580d368c..58feb858e1ba8200ae703ef6b1703396ff0f0738 100644 (file)
@@ -1,8 +1,8 @@
 /*
-       Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+       Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
        Available via Academic Free License >= 2.1 OR the modified BSD license.
        see: http://dojotoolkit.org/license for details
 */
 
 //>>built
-define("dojo/store/JsonRest",["../_base/xhr","../json","../_base/declare","./util/QueryResults"],function(_1,_2,_3,_4){return _3("dojo.store.JsonRest",null,{constructor:function(_5){_3.safeMixin(this,_5);},target:"",idProperty:"id",get:function(id,_6){var _7=_6||{};_7.Accept=this.accepts;return _1("GET",{url:this.target+id,handleAs:"json",headers:_7});},accepts:"application/javascript, application/json",getIdentity:function(_8){return _8[this.idProperty];},put:function(_9,_a){_a=_a||{};var id=("id" in _a)?_a.id:this.getIdentity(_9);var _b=typeof id!="undefined";return _1(_b&&!_a.incremental?"PUT":"POST",{url:_b?this.target+id:this.target,postData:_2.stringify(_9),handleAs:"json",headers:{"Content-Type":"application/json",Accept:this.accepts,"If-Match":_a.overwrite===true?"*":null,"If-None-Match":_a.overwrite===false?"*":null}});},add:function(_c,_d){_d=_d||{};_d.overwrite=false;return this.put(_c,_d);},remove:function(id){return _1("DELETE",{url:this.target+id});},query:function(_e,_f){var _10={Accept:this.accepts};_f=_f||{};if(_f.start>=0||_f.count>=0){_10.Range="items="+(_f.start||"0")+"-"+(("count" in _f&&_f.count!=Infinity)?(_f.count+(_f.start||0)-1):"");}if(_e&&typeof _e=="object"){_e=_1.objectToQuery(_e);_e=_e?"?"+_e:"";}if(_f&&_f.sort){var _11=this.sortParam;_e+=(_e?"&":"?")+(_11?_11+"=":"sort(");for(var i=0;i<_f.sort.length;i++){var _12=_f.sort[i];_e+=(i>0?",":"")+(_12.descending?"-":"+")+encodeURIComponent(_12.attribute);}if(!_11){_e+=")";}}var _13=_1("GET",{url:this.target+(_e||""),handleAs:"json",headers:_10});_13.total=_13.then(function(){var _14=_13.ioArgs.xhr.getResponseHeader("Content-Range");return _14&&(_14=_14.match(/\/(.*)/))&&+_14[1];});return _4(_13);}});});
\ No newline at end of file
+define("dojo/store/JsonRest",["../_base/xhr","../_base/lang","../json","../_base/declare","./util/QueryResults"],function(_1,_2,_3,_4,_5){var _6=null;return _4("dojo.store.JsonRest",_6,{constructor:function(_7){this.headers={};_4.safeMixin(this,_7);},headers:{},target:"",idProperty:"id",ascendingPrefix:"+",descendingPrefix:"-",_getTarget:function(id){var _8=this.target;if(typeof id!="undefined"){if((_8.charAt(_8.length-1)=="/")||(_8.charAt(_8.length-1)=="=")){_8+=id;}else{_8+="/"+id;}}return _8;},get:function(id,_9){_9=_9||{};var _a=_2.mixin({Accept:this.accepts},this.headers,_9.headers||_9);return _1("GET",{url:this._getTarget(id),handleAs:"json",headers:_a});},accepts:"application/javascript, application/json",getIdentity:function(_b){return _b[this.idProperty];},put:function(_c,_d){_d=_d||{};var id=("id" in _d)?_d.id:this.getIdentity(_c);var _e=typeof id!="undefined";return _1(_e&&!_d.incremental?"PUT":"POST",{url:this._getTarget(id),postData:_3.stringify(_c),handleAs:"json",headers:_2.mixin({"Content-Type":"application/json",Accept:this.accepts,"If-Match":_d.overwrite===true?"*":null,"If-None-Match":_d.overwrite===false?"*":null},this.headers,_d.headers)});},add:function(_f,_10){_10=_10||{};_10.overwrite=false;return this.put(_f,_10);},remove:function(id,_11){_11=_11||{};return _1("DELETE",{url:this._getTarget(id),headers:_2.mixin({},this.headers,_11.headers)});},query:function(_12,_13){_13=_13||{};var _14=_2.mixin({Accept:this.accepts},this.headers,_13.headers);var _15=this.target.indexOf("?")>-1;_12=_12||"";if(_12&&typeof _12=="object"){_12=_1.objectToQuery(_12);_12=_12?(_15?"&":"?")+_12:"";}if(_13.start>=0||_13.count>=0){_14["X-Range"]="items="+(_13.start||"0")+"-"+(("count" in _13&&_13.count!=Infinity)?(_13.count+(_13.start||0)-1):"");if(this.rangeParam){_12+=(_12||_15?"&":"?")+this.rangeParam+"="+_14["X-Range"];_15=true;}else{_14.Range=_14["X-Range"];}}if(_13&&_13.sort){var _16=this.sortParam;_12+=(_12||_15?"&":"?")+(_16?_16+"=":"sort(");for(var i=0;i<_13.sort.length;i++){var _17=_13.sort[i];_12+=(i>0?",":"")+(_17.descending?this.descendingPrefix:this.ascendingPrefix)+encodeURIComponent(_17.attribute);}if(!_16){_12+=")";}}var _18=_1("GET",{url:this.target+(_12||""),handleAs:"json",headers:_14});_18.total=_18.then(function(){var _19=_18.ioArgs.xhr.getResponseHeader("Content-Range");if(!_19){_19=_18.ioArgs.xhr.getResponseHeader("X-Content-Range");}return _19&&(_19=_19.match(/\/(.*)/))&&+_19[1];});return _5(_18);}});});
\ No newline at end of file