summaryrefslogtreecommitdiffstats
path: root/js/yui3/model-sync-local
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2014-09-03 05:46:38 +0200
committerDylan William Hardison <dylan@hardison.net>2014-09-03 05:48:52 +0200
commitbd23fbfeccd49a406f6a8d99a21371ad7ade07ba (patch)
tree4f7fe26cad167380d7d17ce4616173a90e684acf /js/yui3/model-sync-local
parent14be79f77292305fbd5a9508ca6142e97498abb5 (diff)
downloadbugzilla-bd23fbfeccd49a406f6a8d99a21371ad7ade07ba.tar.gz
bugzilla-bd23fbfeccd49a406f6a8d99a21371ad7ade07ba.tar.xz
Bug 913647: Deploy YUI 3.17.2 for BMO
r=glob
Diffstat (limited to 'js/yui3/model-sync-local')
-rw-r--r--js/yui3/model-sync-local/model-sync-local-min.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/js/yui3/model-sync-local/model-sync-local-min.js b/js/yui3/model-sync-local/model-sync-local-min.js
new file mode 100644
index 000000000..3c8fc773e
--- /dev/null
+++ b/js/yui3/model-sync-local/model-sync-local-min.js
@@ -0,0 +1,8 @@
+/*
+YUI 3.17.2 (build 9c3c78e)
+Copyright 2014 Yahoo! Inc. All rights reserved.
+Licensed under the BSD License.
+http://yuilibrary.com/license/
+*/
+
+YUI.add("model-sync-local",function(e,t){function n(){}n._NON_ATTRS_CFG=["root"],n._hasLocalStorage=function(){var t=e.config.win.localStorage,n=e.guid();try{return t.setItem(n,n),t.removeItem(n),!0}catch(r){return!1}}(),n._data=n._data||{},n._store=n._store||{},n.prototype={root:"",storage:null,initializer:function(t){var r,i;t||(t={}),"root"in t&&(this.root=t.root||""),!this.root&&this.model&&this.model.prototype.root&&(this.root=this.model.prototype.root),n._hasLocalStorage&&(this.storage=e.config.win.localStorage,r=this.storage.getItem(this.root)),r?(n._store[this.root]=r.split("|")||[],e.Array.each(n._store[this.root],function(t){n._data[t]=e.JSON.parse(this.storage.getItem(t))},this)):n._store[this.root]||(n._store[this.root]=[])},sync:function(e,t,n){t||(t={});var r,i;try{switch(e){case"read":this._isYUIModelList?r=this._index(t):r=this._show(t);break;case"create":r=this._create(t);break;case"update":r=this._update(t);break;case"delete":r=this._destroy(t)}}catch(s){i=s.message}r?n(null,r):i?n(i):n("Data not found in LocalStorage")},generateID:function(t){return e.guid(t+"_")},_index:function(){var t=n._store[this.root],r=e.Array.map(t,function(e){return n._data[e]});return r},_show:function(){return n._data[this.get("id")]||null},_create:function(){var t=this.toJSON();return t.id=this.generateID(this.root),n._data[t.id]=t,this.storage&&this.storage.setItem(t.id,e.JSON.stringify(t)),n._store[this.root].push(t.id),this._save(),t},_update:function(){var t=this.toJSON(),r=this.get("id");return n._data[r]=t,this.storage&&this.storage.setItem(r,t),e.Array.indexOf(n._store[this.root],r)===-1&&n._store[this.root].push(r),this._save(),t},_destroy:function(){var t=this.get("id"),r=this.storage;if(!n._data[t])return;return delete n._data[t],r&&r.removeItem(t),n._store[this.root]=e.Array.filter(n._store[this.root],function(e){return e.id!=t}),this._save(),this.toJSON()},_save:function(){n._hasLocalStorage&&this.storage&&this.storage.setItem(this.root,n._store[this.root].join("|"))}},e.namespace("ModelSync").Local=n},"3.17.2",{requires:["model","json-stringify"]});