xdlocalstorage
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -83,2 +83,6 @@ /** | ||
function isDomReady() { | ||
return (document.readyState === 'complete'); | ||
} | ||
return { | ||
@@ -95,8 +99,20 @@ //callback is optional for cases you use the api before window load. | ||
wasInit = true; | ||
if (document.readyState === 'complete') { | ||
if (isDomReady()) { | ||
init(customOptions); | ||
} else { | ||
window.onload = function () { | ||
init(customOptions); | ||
}; | ||
if (document.addEventListener) { | ||
// All browsers expect IE < 9 | ||
document.addEventListener('readystatechange', function () { | ||
if (isDomReady()) { | ||
init(customOptions); | ||
} | ||
}); | ||
} else { | ||
// IE < 9 | ||
document.attachEvent('readystatechange', function () { | ||
if (isDomReady()) { | ||
init(customOptions); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -103,0 +119,0 @@ }, |
{ | ||
"name": "xdLocalStorage", | ||
"version": "2.0.3", | ||
"version": "2.0.5", | ||
"homepage": "https://github.com/ofirdagan/cross-domain-local-storage", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,1 +0,1 @@ | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),window.xdLocalStorage=window.xdLocalStorage||function(){function a(a){j[a.id]&&(j[a.id](a),delete j[a.id])}function b(b){var c;try{c=JSON.parse(b.data)}catch(a){}c&&c.namespace===g&&("iframe-ready"===c.id?(l=!0,h.initCallback()):a(c))}function c(a,b,c,d){i++,j[i]=d;var e={namespace:g,id:i,action:a,key:b,value:c};f.contentWindow.postMessage(JSON.stringify(e),"*")}function d(a){h=XdUtils.extend(a,h);var c=document.createElement("div");window.addEventListener?window.addEventListener("message",b,!1):window.attachEvent("onmessage",b),c.innerHTML='<iframe id="'+h.iframeId+'" src='+h.iframeUrl+' style="display: none;"></iframe>',document.body.appendChild(c),f=document.getElementById(h.iframeId)}function e(){return k?!!l||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call xdLocalStorage.init() before using it."),!1)}var f,g="cross-domain-local-message",h={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}},i=-1,j={},k=!1,l=!0;return{init:function(a){if(!a.iframeUrl)throw"You must specify iframeUrl";return k?void console.log("xdLocalStorage was already initialized!"):(k=!0,void("complete"===document.readyState?d(a):window.onload=function(){d(a)}))},setItem:function(a,b,d){e()&&c("set",a,b,d)},getItem:function(a,b){e()&&c("get",a,null,b)},removeItem:function(a,b){e()&&c("remove",a,null,b)},key:function(a,b){e()&&c("key",a,null,b)},getSize:function(a){e()&&c("size",null,null,a)},getLength:function(a){e()&&c("length",null,null,a)},clear:function(a){e()&&c("clear",null,null,a)},wasInit:function(){return k}}}(),angular.module("xdLocalStorage",[]).service("xdLocalStorage",["$q","$rootScope",function(a,b){function c(){if(!xdLocalStorage.wasInit())throw"You must init xdLocalStorage in app config before use";return f.promise}function d(d){var e=Array.prototype.slice.call(arguments,1);return c().then(function(){var c=a.defer();return xdLocalStorage[d].apply(this,e.concat(function(){var a=arguments[0];b.$apply(function(){c.resolve(a)})})),c.promise})}var e=!1,f=a.defer(),g=b.$watch(function(){return e},function(){f.resolve(!0),g()});return{init:function(c){var d=a.defer();return c.initCallback=function(){b.$apply(function(){e=!0,d.resolve()})},xdLocalStorage.init(c),d.promise},setItem:function(a,b){return d("setItem",a,b)},getItem:function(a){return d("getItem",a)},removeItem:function(a){return d("removeItem",a)},key:function(a){return d("key",a)},clear:function(){return d("clear")}}}]); | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),window.xdLocalStorage=window.xdLocalStorage||function(){function a(a){k[a.id]&&(k[a.id](a),delete k[a.id])}function b(b){var c;try{c=JSON.parse(b.data)}catch(a){}c&&c.namespace===h&&("iframe-ready"===c.id?(m=!0,i.initCallback()):a(c))}function c(a,b,c,d){j++,k[j]=d;var e={namespace:h,id:j,action:a,key:b,value:c};g.contentWindow.postMessage(JSON.stringify(e),"*")}function d(a){i=XdUtils.extend(a,i);var c=document.createElement("div");window.addEventListener?window.addEventListener("message",b,!1):window.attachEvent("onmessage",b),c.innerHTML='<iframe id="'+i.iframeId+'" src='+i.iframeUrl+' style="display: none;"></iframe>',document.body.appendChild(c),g=document.getElementById(i.iframeId)}function e(){return l?!!m||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call xdLocalStorage.init() before using it."),!1)}function f(){return"complete"===document.readyState}var g,h="cross-domain-local-message",i={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}},j=-1,k={},l=!1,m=!0;return{init:function(a){if(!a.iframeUrl)throw"You must specify iframeUrl";if(l)return void console.log("xdLocalStorage was already initialized!");l=!0,f()?d(a):document.addEventListener?document.addEventListener("readystatechange",function(){f()&&d(a)}):document.attachEvent("readystatechange",function(){f()&&d(a)})},setItem:function(a,b,d){e()&&c("set",a,b,d)},getItem:function(a,b){e()&&c("get",a,null,b)},removeItem:function(a,b){e()&&c("remove",a,null,b)},key:function(a,b){e()&&c("key",a,null,b)},getSize:function(a){e()&&c("size",null,null,a)},getLength:function(a){e()&&c("length",null,null,a)},clear:function(a){e()&&c("clear",null,null,a)},wasInit:function(){return l}}}(),angular.module("xdLocalStorage",[]).service("xdLocalStorage",["$q","$rootScope",function(a,b){function c(){if(!xdLocalStorage.wasInit())throw"You must init xdLocalStorage in app config before use";return f.promise}function d(d){var e=Array.prototype.slice.call(arguments,1);return c().then(function(){var c=a.defer();return xdLocalStorage[d].apply(this,e.concat(function(){var a=arguments[0];b.$apply(function(){c.resolve(a)})})),c.promise})}var e=!1,f=a.defer(),g=b.$watch(function(){return e},function(){f.resolve(!0),g()});return{init:function(c){var d=a.defer();return c.initCallback=function(){b.$apply(function(){e=!0,d.resolve()})},xdLocalStorage.init(c),d.promise},setItem:function(a,b){return d("setItem",a,b)},getItem:function(a){return d("getItem",a)},removeItem:function(a){return d("removeItem",a)},key:function(a){return d("key",a)},clear:function(){return d("clear")}}}]); |
@@ -1,1 +0,1 @@ | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),window.xdLocalStorage=window.xdLocalStorage||function(){function a(a){j[a.id]&&(j[a.id](a),delete j[a.id])}function b(b){var c;try{c=JSON.parse(b.data)}catch(a){}c&&c.namespace===g&&("iframe-ready"===c.id?(l=!0,h.initCallback()):a(c))}function c(a,b,c,d){i++,j[i]=d;var e={namespace:g,id:i,action:a,key:b,value:c};f.contentWindow.postMessage(JSON.stringify(e),"*")}function d(a){h=XdUtils.extend(a,h);var c=document.createElement("div");window.addEventListener?window.addEventListener("message",b,!1):window.attachEvent("onmessage",b),c.innerHTML='<iframe id="'+h.iframeId+'" src='+h.iframeUrl+' style="display: none;"></iframe>',document.body.appendChild(c),f=document.getElementById(h.iframeId)}function e(){return k?!!l||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call xdLocalStorage.init() before using it."),!1)}var f,g="cross-domain-local-message",h={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}},i=-1,j={},k=!1,l=!0;return{init:function(a){if(!a.iframeUrl)throw"You must specify iframeUrl";return k?void console.log("xdLocalStorage was already initialized!"):(k=!0,void("complete"===document.readyState?d(a):window.onload=function(){d(a)}))},setItem:function(a,b,d){e()&&c("set",a,b,d)},getItem:function(a,b){e()&&c("get",a,null,b)},removeItem:function(a,b){e()&&c("remove",a,null,b)},key:function(a,b){e()&&c("key",a,null,b)},getSize:function(a){e()&&c("size",null,null,a)},getLength:function(a){e()&&c("length",null,null,a)},clear:function(a){e()&&c("clear",null,null,a)},wasInit:function(){return k}}}(); | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),window.xdLocalStorage=window.xdLocalStorage||function(){function a(a){k[a.id]&&(k[a.id](a),delete k[a.id])}function b(b){var c;try{c=JSON.parse(b.data)}catch(a){}c&&c.namespace===h&&("iframe-ready"===c.id?(m=!0,i.initCallback()):a(c))}function c(a,b,c,d){j++,k[j]=d;var e={namespace:h,id:j,action:a,key:b,value:c};g.contentWindow.postMessage(JSON.stringify(e),"*")}function d(a){i=XdUtils.extend(a,i);var c=document.createElement("div");window.addEventListener?window.addEventListener("message",b,!1):window.attachEvent("onmessage",b),c.innerHTML='<iframe id="'+i.iframeId+'" src='+i.iframeUrl+' style="display: none;"></iframe>',document.body.appendChild(c),g=document.getElementById(i.iframeId)}function e(){return l?!!m||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call xdLocalStorage.init() before using it."),!1)}function f(){return"complete"===document.readyState}var g,h="cross-domain-local-message",i={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}},j=-1,k={},l=!1,m=!0;return{init:function(a){if(!a.iframeUrl)throw"You must specify iframeUrl";if(l)return void console.log("xdLocalStorage was already initialized!");l=!0,f()?d(a):document.addEventListener?document.addEventListener("readystatechange",function(){f()&&d(a)}):document.attachEvent("readystatechange",function(){f()&&d(a)})},setItem:function(a,b,d){e()&&c("set",a,b,d)},getItem:function(a,b){e()&&c("get",a,null,b)},removeItem:function(a,b){e()&&c("remove",a,null,b)},key:function(a,b){e()&&c("key",a,null,b)},getSize:function(a){e()&&c("size",null,null,a)},getLength:function(a){e()&&c("length",null,null,a)},clear:function(a){e()&&c("clear",null,null,a)},wasInit:function(){return l}}}(); |
@@ -1,1 +0,1 @@ | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),function(){function a(a,b){var c=XdUtils.extend(b,l);c.id=a,parent.postMessage(JSON.stringify(c),"*")}function b(b,c){var d=localStorage.getItem(c),e={key:c,value:d};a(b,e)}function c(b,c,d){localStorage.setItem(c,d);var e=localStorage.getItem(c),f={success:e===d};a(b,f)}function d(b,c){localStorage.removeItem(c),a(b,{})}function e(b,c){var d=localStorage.key(c);a(b,{key:d})}function f(b){var c=JSON.stringify(localStorage).length;a(b,{size:c})}function g(b){var c=localStorage.length;a(b,{length:c})}function h(b){localStorage.clear(),a(b,{})}function i(a){var i;try{i=JSON.parse(a.data)}catch(a){}i&&i.namespace===k&&("set"===i.action?c(i.id,i.key,i.value):"get"===i.action?b(i.id,i.key):"remove"===i.action?d(i.id,i.key):"key"===i.action?e(i.id,i.key):"size"===i.action?f(i.id):"length"===i.action?g(i.id):"clear"===i.action&&h(i.id))}function j(){var a={namespace:k,id:"iframe-ready"};parent.postMessage(JSON.stringify(a),"*")}var k="cross-domain-local-message",l={namespace:k};window.addEventListener?window.addEventListener("message",i,!1):window.attachEvent("onmessage",i),j()}(); | ||
"use strict";window.XdUtils=window.XdUtils||function(){function a(a,b){var c,d=b||{};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}return{extend:a}}(),function(){function a(a,b){var c=XdUtils.extend(b,l);c.id=a,parent.postMessage(JSON.stringify(c),"*")}function b(b,c){a(b,{key:c,value:localStorage.getItem(c)})}function c(b,c,d){localStorage.setItem(c,d),a(b,{success:localStorage.getItem(c)===d})}function d(b,c){localStorage.removeItem(c),a(b,{})}function e(b,c){a(b,{key:localStorage.key(c)})}function f(b){a(b,{size:JSON.stringify(localStorage).length})}function g(b){a(b,{length:localStorage.length})}function h(b){localStorage.clear(),a(b,{})}function i(a){var i;try{i=JSON.parse(a.data)}catch(a){}i&&i.namespace===k&&("set"===i.action?c(i.id,i.key,i.value):"get"===i.action?b(i.id,i.key):"remove"===i.action?d(i.id,i.key):"key"===i.action?e(i.id,i.key):"size"===i.action?f(i.id):"length"===i.action?g(i.id):"clear"===i.action&&h(i.id))}function j(){var a={namespace:k,id:"iframe-ready"};parent.postMessage(JSON.stringify(a),"*")}var k="cross-domain-local-message",l={namespace:k};window.addEventListener?window.addEventListener("message",i,!1):window.attachEvent("onmessage",i),j()}(); |
@@ -418,3 +418,3 @@ // Generated on 2014-04-17 using generator-webapp 0.4.9 | ||
'htmlmin', | ||
/* 'karma:unit' */ | ||
'karma:unit' | ||
]); | ||
@@ -421,0 +421,0 @@ |
{ | ||
"name": "xdlocalstorage", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"main": "dist/scripts/xdLocalStorage.min.js", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
@@ -32,5 +32,7 @@ Cross Domain Local Storage | ||
Download latest release from [here](https://github.com/ofirdagan/cross-domain-local-storage/releases) or use bower (recommended) | ||
Download latest release from [here](https://github.com/ofirdagan/cross-domain-local-storage/releases) or use bower/npm (recommended) | ||
```sh | ||
bower install xdLocalStorage --save | ||
or | ||
npm install --save xdlocalstorage | ||
``` | ||
@@ -37,0 +39,0 @@ |
195295
24
950
142