diff --git a/README.md b/README.md index efba7e7..0dd6dca 100755 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Documentation can be found at http://www.simplestatemanager.com ##Release Log +###2.2.6 - June 23, 2014 +* Fixed issue where you can apply multiple readies. ###2.2.5 - June 12, 2014 * Fixed issue where it didnt work when you zoom the browser diff --git a/bower.json b/bower.json index a2f5c7e..23fa1d6 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "SimpleStateManager", - "version": "2.2.5", + "version": "2.2.6", "main": "src/ssm.js", "ignore": [ "**/.*", diff --git a/dist/ssm.min.js b/dist/ssm.min.js index 8c3bb9e..ce4f4ef 100755 --- a/dist/ssm.min.js +++ b/dist/ssm.min.js @@ -1,2 +1,2 @@ -/*! SimpleStateManager | license: MIT | version: 2.2.5 | build date: 2014-06-12 */ -!function(a,b){"use strict";var c={},d=[],e=0,f=[],g=10,h=null,i=[],j=function(){return"function"==typeof a.matchMedia&&"undefined"!=typeof a.matchMedia("(width: 100px)").addListener?!0:!1}(),k=function(){clearTimeout(h),h=setTimeout(l,g)},l=function(){e=o(),m(e)},m=function(a){for(var b=d.length,e=i.length,g=[],h=[],j=[],k=!0,l=c,m=0;b>m;m++){k=!0,l.state=d[m],l.browserWidth=a;for(var n=0;e>n;n++)if("undefined"!=typeof l.state[i[n].name]&&(l.callback=i[n].test,l.callback()===!1)){k=!1;break}k?s(f,d[m])?h=h.concat(d[m].onResize):(f.push(d[m]),j=j.concat(d[m].onEnter)):s(f,d[m])&&(g=g.concat(d[m].onLeave),f=t(f,d[m]))}u(g),u(j),u(h)};c.browserResize=m,c.getBrowserWidth=function(){return e},c.addState=function(a){var b={id:n(),minWidth:0,maxWidth:999999,onEnter:[],onLeave:[],onResize:[]};return a=p(b,a),"function"==typeof a.onEnter&&(a.onEnter=[a.onEnter]),"function"==typeof a.onLeave&&(a.onLeave=[a.onLeave]),"function"==typeof a.onResize&&(a.onResize=[a.onResize]),d.push(a),d=q(d,"minWidth"),this},c.updateState=function(a,b){for(var c=d.length-1;c>=0;c--)d[c].id===a&&(d[c]=p(d[c],b));return this},c.removeState=function(a){for(var b=d.length-1;b>=0;b--)d[b].id===a&&d.splice(b,1);return this},c.removeStates=function(a){for(var b=a.length-1;b>=0;b--)c.removeState(a[b]);return this},c.removeAllStates=function(){return d=f=[],this},c.addStates=function(a){for(var b=a.length-1;b>=0;b--)c.addState(a[b]);return this},c.getStates=function(a){var b=null,c=[];if("undefined"==typeof a)return d;b=a.length;for(var e=0;b>e;e++)c.push(r(a[e]));return c},c.addConfigOption=function(a){var b={name:"",test:null};a=p(b,a),""!==a.name&&null!==a.test&&i.push(a)},c.getConfigOption=function(a){if("string"!=typeof a)return i;for(var b=i.length-1;b>=0;b--)if(i[b].name===a)return i[b]},c.removeConfigOption=function(a){for(var b=i.length-1;b>=0;b--)i[b].name===a&&i.splice(b,1)},c.isActive=function(a){for(var b=0;bc;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a},o=function(){var c=0;return j?a.matchMedia("(width:"+a.innerWidth+"px)").matches?c=a.innerWidth:a.matchMedia("(width:"+a.innerWidth+"px)").matches?c=a.outerWidth:a.matchMedia("(width:"+b.body.clientWidth+"px)").matches&&(c=b.body.clientWidth):"number"==typeof b.body.clientWidth?c=b.body.clientWidth:"number"==typeof a.innerWidth?c=a.innerWidth:b.documentElement&&b.documentElement.clientWidth&&(c=b.documentElement.clientWidth),c},p=function(a,b){var c={};for(var d in a)c[d]=a[d];for(var e in b)c[e]=b[e];return c},q=function(a,b){return a.sort(function(a,c){var d=a[b],e=c[b];return e>d?-1:d>e?1:0})},r=function(a){for(var b=d.length-1;b>=0;b--)if(d[b].id===a)return d[b]},s=function(a,b){for(var c=0;cd;d++)a[d]===b&&a.splice(d,1);return a},u=function(a){for(var b=a.length,c=0;b>c;c++)a[c]()};c.addConfigOption({name:"minWidth",test:function(){return"number"==typeof this.state.minWidth&&this.state.minWidth<=this.browserWidth?!0:!1}}),c.addConfigOption({name:"maxWidth",test:function(){return"number"==typeof this.state.maxWidth&&this.state.maxWidth>=this.browserWidth?!0:!1}}),a.ssm=c,"function"==typeof a.define&&a.define.amd&&a.define("ssm",[],function(){return a.ssm})}(window,document); \ No newline at end of file +/*! SimpleStateManager | license: MIT | version: 2.2.6 | build date: 2014-06-23 */ +!function(a,b){"use strict";var c=!1,d={},e=[],f=0,g=[],h=10,i=null,j=[],k=function(){return"function"==typeof a.matchMedia&&"undefined"!=typeof a.matchMedia("(width: 100px)").addListener?!0:!1}(),l=function(){clearTimeout(i),i=setTimeout(m,h)},m=function(){f=p(),n(f)},n=function(a){for(var b=e.length,c=j.length,f=[],h=[],i=[],k=!0,l=d,m=0;b>m;m++){k=!0,l.state=e[m],l.browserWidth=a;for(var n=0;c>n;n++)if("undefined"!=typeof l.state[j[n].name]&&(l.callback=j[n].test,l.callback()===!1)){k=!1;break}k?t(g,e[m])?h=h.concat(e[m].onResize):(g.push(e[m]),i=i.concat(e[m].onEnter)):t(g,e[m])&&(f=f.concat(e[m].onLeave),g=u(g,e[m]))}v(f),v(i),v(h)};d.browserResize=n,d.getBrowserWidth=function(){return f},d.addState=function(a){var b={id:o(),minWidth:0,maxWidth:999999,onEnter:[],onLeave:[],onResize:[]};return a=q(b,a),"function"==typeof a.onEnter&&(a.onEnter=[a.onEnter]),"function"==typeof a.onLeave&&(a.onLeave=[a.onLeave]),"function"==typeof a.onResize&&(a.onResize=[a.onResize]),e.push(a),e=r(e,"minWidth"),this},d.updateState=function(a,b){for(var c=e.length-1;c>=0;c--)e[c].id===a&&(e[c]=q(e[c],b));return this},d.removeState=function(a){for(var b=e.length-1;b>=0;b--)e[b].id===a&&e.splice(b,1);return this},d.removeStates=function(a){for(var b=a.length-1;b>=0;b--)d.removeState(a[b]);return this},d.removeAllStates=function(){return e=g=[],this},d.addStates=function(a){for(var b=a.length-1;b>=0;b--)d.addState(a[b]);return this},d.getStates=function(a){var b=null,c=[];if("undefined"==typeof a)return e;b=a.length;for(var d=0;b>d;d++)c.push(s(a[d]));return c},d.addConfigOption=function(a){var b={name:"",test:null};a=q(b,a),""!==a.name&&null!==a.test&&j.push(a)},d.getConfigOption=function(a){if("string"!=typeof a)return j;for(var b=j.length-1;b>=0;b--)if(j[b].name===a)return j[b]},d.removeConfigOption=function(a){for(var b=j.length-1;b>=0;b--)j[b].name===a&&j.splice(b,1)},d.isActive=function(a){for(var b=0;bc;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a},p=function(){var c=0;return k?a.matchMedia("(width:"+a.innerWidth+"px)").matches?c=a.innerWidth:a.matchMedia("(width:"+a.innerWidth+"px)").matches?c=a.outerWidth:a.matchMedia("(width:"+b.body.clientWidth+"px)").matches&&(c=b.body.clientWidth):"number"==typeof b.body.clientWidth?c=b.body.clientWidth:"number"==typeof a.innerWidth?c=a.innerWidth:b.documentElement&&b.documentElement.clientWidth&&(c=b.documentElement.clientWidth),c},q=function(a,b){var c={};for(var d in a)c[d]=a[d];for(var e in b)c[e]=b[e];return c},r=function(a,b){return a.sort(function(a,c){var d=a[b],e=c[b];return e>d?-1:d>e?1:0})},s=function(a){for(var b=e.length-1;b>=0;b--)if(e[b].id===a)return e[b]},t=function(a,b){for(var c=0;cd;d++)a[d]===b&&a.splice(d,1);return a},v=function(a){for(var b=a.length,c=0;b>c;c++)a[c]()};d.addConfigOption({name:"minWidth",test:function(){return"number"==typeof this.state.minWidth&&this.state.minWidth<=this.browserWidth?!0:!1}}),d.addConfigOption({name:"maxWidth",test:function(){return"number"==typeof this.state.maxWidth&&this.state.maxWidth>=this.browserWidth?!0:!1}}),a.ssm=d,"function"==typeof a.define&&a.define.amd&&a.define("ssm",[],function(){return a.ssm})}(window,document); \ No newline at end of file diff --git a/index.html b/index.html index 2e2bf41..75ecdf4 100755 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
-

Simple State Manager 2.2.5

+

Simple State Manager 2.2.6

Simple State Manager (SSM for short) is a javascript state manager for responsive websites. It is built to be light weight, has no dependencies (except javascript of course) and aims to be really easy to simply drop into your project ready to use.

Download @@ -321,6 +321,11 @@

Browser Support

Release Log

SimpleStateManager follows Semantic Versioning 2.0.0

+

2.2.6 - June 23, 2014

+
    +
  • Fixed issue where you can apply multiple readies
  • +
+

2.2.5 - June 12, 2014

  • Fixed issue where it didnt work when you zoom the browser
  • diff --git a/package.json b/package.json index f9082ca..26c4aff 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "SimpleStateManager", "description": "SimpleStateManager ==================", - "version": "2.2.5", + "version": "2.2.6", "main": "src/ssm.js", "scripts": { "test": "grunt travis --verbose" diff --git a/src/ssm.js b/src/ssm.js index 32ef21b..8eb5481 100755 --- a/src/ssm.js +++ b/src/ssm.js @@ -3,7 +3,8 @@ ;(function (window, document, undefined) { "use strict"; - var ssm = {}, + var isReady = false, + ssm = {}, states = [], browserWidth = 0, currentStates = [], @@ -254,11 +255,15 @@ //Update browser width browserWidth = getWidth(); - //Attach event for resizing - if (window.attachEvent) { - window.attachEvent("onresize", browserResizeDebounce); - } else if (window.addEventListener) { - window.addEventListener("resize", browserResizeDebounce, true); + if(isReady === false){ + //Attach event for resizing + if (window.attachEvent) { + window.attachEvent("onresize", browserResizeDebounce); + } else if (window.addEventListener) { + window.addEventListener("resize", browserResizeDebounce, true); + } + + isReady = true; } browserResize(browserWidth);