Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switching to native for loops because they're orders of magnitude fas…

…ter.
  • Loading branch information...
commit d0589acb9bcb8479967ee4994830d729e3651388 1 parent 610ba8a
@doctyper authored
Showing with 461 additions and 324 deletions.
  1. +36 −33 dist/flexie.min.js
  2. +425 −291 src/flexie.js
View
69 dist/flexie.min.js
@@ -1,33 +1,36 @@
-var Flexie=function(x,E){function F(a){if(a)a=a.replace(va,w).replace(wa,w);return a}function h(a,d){var c,b=0,e=a?a.length:P;if(e===P)for(c in a){if(a.hasOwnProperty(c))if(d.call(a[c],c,a[c])===I)break}else for(c=a[0];b<e&&d.call(c,b,c)!==I;c=a[++b]);}function xa(){var a;h(X,function(d,c){if(x[d]&&!a)if(a=eval(c.s.replace("*",d))){Y=d;return false}});return a}function Z(a,d){a="on"+a;var c=x[a];x[a]=typeof x[a]!=="function"?d:function(){c&&c();d()}}function $(a){var d=a.nodeName.toLowerCase();if(a.id)d+=
-"#"+a.id;else if(a.FLX_DOM_ID)d+="["+aa+"='"+a.FLX_DOM_ID+"']";return d}function T(a){if(!a.FLX_DOM_ID){U+=1;a.FLX_DOM_ID=U;a.setAttribute(aa,a.FLX_DOM_ID)}}function ya(a){var d=[],c,b,e,f,g,i;a=a.replace(za,w);a=a.replace(/\s?(\{|\:|\})\s?/g,Q);a=a.split(ba);h(a,function(k,l){if(l){c=[l,ba].join(w);if((b=/(\@media[^\{]+\{)?(.*)\{(.*)\}/.exec(c))&&b[3]){e=b[2];f=b[3].split(";");i=[];h(f,function(n,o){g=o.split(":");g.length&&g[1]&&i.push({property:g[0],value:g[1]})});e&&i.length&&d.push({selector:e,
-properties:i})}}});return d}function Aa(a){var d,c,b,e,f,g=/\s?,\s?/,i,k,l={},n={};i=function(o,p,m,j){var q={selector:F(o),properties:[]};h(p.properties,function(r,u){q.properties.push({property:F(u.property),value:F(u.value)})});if(m&&j)q[m]=j;return q};k=function(o,p,m,j){var q=m&&j?l[o]:n[o],r;if(q){h(p.properties,function(u,A){h(q.properties,function(J,B){if(A.property===B.property){r=J;return false}});if(r)q.properties[r]=A;else q.properties.push(A)});if(m&&j)q[m]=j}else if(m&&j)l[o]=i(o,p,
-m,j);else n[o]=i(o,p,t,t)};h(a,function(o,p){d=F(p.selector).replace(g,",").split(g);h(d,function(m,j){j=F(j);c=p.properties;h(c,function(q,r){b=F(r.property);e=F(r.value);if(b){f=b.replace("box-",w);switch(f){case "display":e==="box"&&k(j,p,t,t);break;case "orient":case "align":case "direction":case "pack":k(j,p,t,t);break;case "flex":case "flex-group":case "ordinal-group":k(j,p,f,e)}}})})});h(n,function(o,p){y.push(p)});h(l,function(o,p){ca.push(p)});return{boxes:y,children:ca}}function da(a,d,
-c){var b,e,f=[];h(c,function(g,i){if(i.selector){b=d(i.selector);b=b[0]?b:[b];b[0]&&h(b,function(k,l){if(l.nodeName!==P)switch(l.nodeName.toLowerCase()){case "script":case "style":case "link":break;default:if(l.parentNode===a){T(l);e={};h(i,function(n){e[n]=i[n]});e.match=l;f.push(e)}}})}else{T(i);f.push({match:i,selector:$(i)})}});return f}function Ba(a){h(a,function(d,c){a[d]=c||Ca[d]});return a}function Da(a){var d,c,b,e,f,g,i,k,l,n,o,p,m,j,q={},r,u,A,J="["+R+"]";if(a){h(a.boxes,function(B,C){C.selector=
-F(C.selector);d=C.selector;c=C.properties;g=i=k=l=n=t;h(c,function(Ea,G){b=F(G.property);e=F(G.value);if(b){f=b.replace("box-",w);switch(f){case "display":if(e==="box")g=e;break;case "orient":i=e;break;case "align":k=e;break;case "direction":l=e;break;case "pack":n=e}}});o=K;p=o(C.selector);p=p[0]?p:[p];h(p,function(Ea,G){if(G.nodeType){T(G);m=da(G,o,a.children);A=d+" "+J;j={target:G,selector:d,properties:c,children:m,display:g,orient:i,align:k,direction:l,pack:n,nested:A};if(r=q[G.FLX_DOM_ID])h(j,
-function(L,N){switch(L){case "selector":if(N&&!RegExp(N).test(r[L]))r[L]+=", "+N;break;case "children":h(j[L],function(Wa,ea){u=I;h(r[L],function(Xa,Fa){if(ea.match.FLX_DOM_ID===Fa.match.FLX_DOM_ID)u=s});u||r[L].push(ea)});break;default:if(N)r[L]=N}});else{q[G.FLX_DOM_ID]=Ba(j);q[G.FLX_DOM_ID].target.setAttribute(R,s)}}})});fa=K(J);y={};h(fa,function(B,C){y[C.FLX_DOM_ID]=q[C.FLX_DOM_ID]});h(y,function(B,C){C.display==="box"&&new z.box(C)})}}function ga(a,d,c){c=c.replace(c.charAt(0),c.charAt(0).toUpperCase());
-var b=a["offset"+c]||0;b&&h(d,function(e,f){f=parseFloat(a.currentStyle[f]);isNaN(f)||(b-=f)});return b}function ha(a,d){var c,b,e=a.currentStyle&&a.currentStyle[d],f=a.style;if(!ia.test(e)&&Ga.test(e)){c=f.left;b=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;f.left=e||0;e=f.pixelLeft+"px";f.left=c||0;a.runtimeStyle.left=b}return e}function v(a,d,c){if(a!==P){if(x.getComputedStyle)a=x.getComputedStyle(a,t)[d];else if(Ha.test(d)){var b=a&&a.currentStyle?a.currentStyle[d]:0;if(!ia.test(b)){if(b===
-"auto"||b==="medium"){switch(d){case "width":b=[ja,ka,la,ma];b=ga(a,b,d);break;case "height":b=[V,na,oa,pa];b=ga(a,b,d);break;default:b=ha(a,d)}a=b}else a=ha(a,d);b=a}a=b}else a=a.currentStyle[d];if(c){a=parseInt(a,10);if(isNaN(a))a=0}return a}}function Ia(a){return a.innerWidth||a.clientWidth}function Ja(a){return a.innerHeight||a.clientHeight}function W(a,d,c,b){var e=[];h(Ka,function(f,g){e.push((b?g:w)+d+":"+(!b?g:w)+c)});a.style.cssText+=e.join(";");return a}function D(a,d,c){h(a&&a[0]?a:[a],
-function(b,e){if(e&&e.style)e.style[d]=c?c+"px":w})}function La(a){var d,c;a=a.replace(Ma,function(b,e){return"%"+e}).replace(/\s|\>|\+|\~/g,"%").split(/%/g);d={_id:100,_class:10,_tag:1};c=0;h(a,function(b,e){if(/#/.test(e))c+=d._id;else if(/\.|\[|\:/.test(e))c+=d._class;else if(/[a-zA-Z]+/.test(e))c+=d._tag});return c}function Na(a,d,c){var b=[],e,f=(c?"ordinal":"flex")+"Specificity";h(a,function(g,i){if(!c&&i.flex||c&&i["ordinal-group"]){i[f]=i[f]||La(i.selector);e=I;h(b,function(k,l){if(l.match===
-i.match){if(l[f]<i[f])b[k]=i;e=s;return I}});e||b.push(i)}});return b}function S(a,d,c){var b={},e=[],f=0,g;a=Na(a,d,c);h(d,function(i,k){h(a,function(l,n){if(c){g=n["ordinal-group"]||"1";if(n.match===k){n.match.setAttribute("data-ordinal-group",g);b[g]=b[g]||[];b[g].push(n)}}else{g=n.flex||"0";if(n.match===k&&(!n[g]||n[g]&&parseInt(n[g],10)<=1)){f+=parseInt(g,10);b[g]=b[g]||[];b[g].push(n)}}});if(c&&!k.getAttribute("data-ordinal-group")){g="1";k.setAttribute("data-ordinal-group",g);b[g]=b[g]||[];
-b[g].push({match:k})}});h(b,function(i){e.push(i)});e.sort(function(i,k){return k-i});return{keys:e,groups:b,total:f}}function Oa(){if(!qa){var a,d,c,b,e=E.body,f=E.documentElement,g;Z("resize",function(){g&&window.clearTimeout(g);g=window.setTimeout(function(){c=x.innerWidth||f.innerWidth||f.clientWidth||e.clientWidth;b=x.innerHeight||f.innerHeight||f.clientHeight||e.clientHeight;if(a!==c||d!==b){z.updateInstance(t,t);a=c;d=b}},250)});qa=s}}function ra(a){var d,c;h(a,function(b,e){d=e.style.width;
-c=e.style.height;e.style.cssText=w;e.style.width=d;e.style.height=c})}function O(a,d){var c=[],b,e,f;e=0;for(f=d.length;e<f;e++)if(b=d[e])switch(b.nodeName.toLowerCase()){case "script":case "style":case "link":break;default:if(b.nodeType===1)c.push(b);else if(b.nodeType===3&&(b.isElementContentWhitespace||Pa.test(b.data))){a.removeChild(b);e--}}return c}function sa(a){var d=0;a=a.parentNode;for(var c;a.FLX_DOM_ID;){c=y[a.FLX_DOM_ID];c=S(c.children,O(a,a.childNodes),t);d+=c.total;c=s;a=a.parentNode}return{nested:c,
-flex:d}}function Qa(a,d){var c=a.parentNode,b;if(c.FLX_DOM_ID){c=y[c.FLX_DOM_ID];h(c.properties,function(e,f){if(RegExp(d).test(f.property)){b=s;return I}})}return b}function Ra(a){a.flexMatrix&&h(a.children,function(d,c){c.flex=a.flexMatrix[d]});a.ordinalMatrix&&h(a.children,function(d,c){c["ordinal-group"]=a.ordinalMatrix[d]});return a}function Sa(a,d){var c=a.target;if(!c.FLX_DOM_ID)c.FLX_DOM_ID=c.FLX_DOM_ID||++U;if(!a.nodes)a.nodes=O(c,c.childNodes);if(!a.selector){a.selector=$(c);c.setAttribute(R,
-s)}if(!a.properties)a.properties=[];if(!a.children)a.children=da(c,K,O(c,c.childNodes));if(!a.nested)a.nested=a.selector+" ["+R+"]";a.target=c;a._instance=d;return a}var z={},U=0,aa="data-flexie-id",R="data-flexie-parent",H,Y,X={NW:{s:"*.Dom.select"},DOMAssistant:{s:"*.$",m:"*.DOMReady"},Prototype:{s:"$$",m:"document.observe",p:"dom:loaded",c:"document"},YAHOO:{s:"*.util.Selector.query",m:"*.util.Event.onDOMReady",c:"*.util.Event"},MooTools:{s:"$$",m:"window.addEvent",p:"domready"},Sizzle:{s:"*"},
-jQuery:{s:"*",m:"*(document).ready"},dojo:{s:"*.query",m:"*.addOnLoad"}},K,ia=/^-?\d+(?:px)?$/i,Ga=/^-?\d/,Ha=/width|height|margin|padding|border/,Ta=/(msie) ([\w.]+)/,za=/\t|\n|\r/g,Ua=/^max\-([a-z]+)/,Va=/^https?:\/\//i,va=/^\s\s*/,wa=/\s\s*$/,Pa=/^\s*$/,Ma=/\s?(\#|\.|\[|\:(\:)?[^first\-(line|letter)|before|after]+)/g,w="",ta=" ",Q="$1",ka="paddingRight",na="paddingBottom",ja="paddingLeft",V="paddingTop",ma="borderRightWidth",pa="borderBottomWidth",la="borderLeftWidth",oa="borderTopWidth",ba="}",
-Ka=" -o- -moz- -ms- -webkit- -khtml- ".split(ta),Ca={orient:"horizontal",align:"stretch",direction:"inherit",pack:"start"},y=[],ca=[],fa,qa,s=true,I=false,t=null,P,M={IE:function(){var a,d=Ta.exec(x.navigator.userAgent.toLowerCase());if(d)a=parseInt(d[2],10);return a}()},ua;ua=function(){function a(m){return m.replace(k,function(j,q,r){j=r.split(",");h(j,function(u,A){A.replace(l,Q).replace(n,Q).replace(p,Q).replace(o,ta)});return q+j.join(",")})}function d(){if(x.XMLHttpRequest)return new x.XMLHttpRequest;
-try{return new x.ActiveXObject("Microsoft.XMLHTTP")}catch(m){return t}}function c(m){var j=d();j.open("GET",m,I);j.send();return j.status===200?j.responseText:w}function b(m,j){if(m){if(Va.test(m))return j.substring(0,j.indexOf("/",8))===m.substring(0,m.indexOf("/",8))?m:t;if(m.charAt(0)==="/")return j.substring(0,j.indexOf("/",8))+m;var q=j.split("?")[0];if(m.charAt(0)!=="?"&&q.charAt(q.length-1)!=="/")q=q.substring(0,q.lastIndexOf("/")+1);return q+m}}function e(m){if(m)return c(m).replace(f,w).replace(g,
-function(j,q,r,u,A,J){j=e(b(r||A,m));return J?"@media "+J+" {"+j+"}":j}).replace(i,function(j,q,r,u){r=r||w;return q?j:" url("+r+b(u,m,true)+r+") "});return w}var f=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g,g=/@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g,i=/(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g,k=/((?:^|(?:\s*})+)(?:\s*@media[^{]+{)?)\s*([^\{]*?[\[:][^{]+)/g,l=/([(\[+~])\s+/g,n=/\s+([)\]+~])/g,o=/\s+/g,p=/^\s*((?:[\S\s]*\S)?)\s*$/;return function(){var m,
-j,q;j=E.getElementsByTagName("BASE");var r=j.length>0?j[0].href:E.location.href,u;j=0;for(q=E.styleSheets.length;j<q;j++)if((m=E.styleSheets[j])&&m.href!==t)if(m=b(m.href,r)){u=a(e(m));u=ya(u);u=Aa(u)}Da(u)}}();z.box=function(a){return this.renderModel(a)};z.box.prototype={properties:{boxModel:function(a,d,c){var b,e;a.style.display="block";if(M.IE===8)a.style.overflow="hidden";if(!c.cleared){selectors=c.selector.split(/\s?,\s?/);b=E.styleSheets;b=b[b.length-1];e="padding-top:"+(v(a,V,t)||"0.1px;");
-h(selectors,function(f,g){if(b.addRule)if(M.IE<8){a.style.zoom="1";if(M.IE===6)b.addRule(g.replace(/\>|\+|\~/g,""),e+"zoom:1;",0);else M.IE===7&&b.addRule(g,e+"display:inline-block;",0)}else{b.addRule(g,e,0);b.addRule(g+":before","content: '.';display: block;height: 0;overflow: hidden",0);b.addRule(g+":after","content: '.';display: block;height: 0;overflow: hidden;clear:both;",0)}else if(b.insertRule){b.insertRule(g+"{"+e+"}",0);b.insertRule(g+":after{content: '.';display: block;height: 0;overflow: hidden;clear:both;}",
-0)}});c.cleared=s}},boxDirection:function(a,d,c){var b;if(c.direction==="reverse"&&!c.reversed||c.direction==="normal"&&c.reversed){d=d.reverse();h(d,function(e,f){a.appendChild(f)});d=K(c.nested);h(d,function(e,f){if((b=y[f.FLX_DOM_ID])&&b.direction==="inherit")b.direction=c.direction});c.reversed=!c.reversed}},boxOrient:function(a,d,c){var b;a={pos:"marginLeft",opp:"marginRight",dim:"width",out:"offsetWidth",func:Ia,pad:[ja,ka,la,ma]};b={pos:"marginTop",opp:"marginBottom",dim:"height",out:"offsetHeight",
-func:Ja,pad:[V,na,oa,pa]};H||h(d,function(e,f){f.style[M.IE>=9?"cssFloat":"styleFloat"]="left";if(c.orient==="vertical"||c.orient==="block-axis")f.style.clear="left";if(M.IE===6)f.style.display="inline"});switch(c.orient){case "vertical":case "block-axis":this.props=b;this.anti=a;break;default:this.props=a;this.anti=b}},boxOrdinalGroup:function(a,d,c){var b,e;if(d.length){b=function(f){f=f.keys;h(c.reversed?f:f.reverse(),function(g,i){h(d,function(k,l){i===l.getAttribute("data-ordinal-group")&&a.appendChild(l)})})};
-e=S(c.children,d,s);e.keys.length>1&&b(e)}},boxFlex:function(a,d,c){var b=this,e,f,g,i;if(d.length){e=function(k){var l=k.groups,n;h(k.keys,function(o,p){h(l[p],function(m,j){n=t;h(j.properties,function(q,r){if(Ua.test(r.property))n=parseFloat(r.value)});if(!n||j.match[b.props.out]>n)D(j.match,b.props.pos,t)})})};f=function(k){var l=0,n;h(d,function(o,p){l+=v(p,b.props.dim,s);h(b.props.pad,function(m,j){l+=v(p,j,s)});l+=v(p,b.props.pos,s);l+=v(p,b.props.opp,s)});n=a[b.props.out]-l;h(b.props.pad,function(o,
-p){n-=v(a,p,s)});return{whitespace:n,ration:n/k.total}};g=function(k,l){var n=k.groups,o,p,m=l.ration,j,q,r;h(k.keys,function(u,A){j=m*A;h(n[A],function(J,B){if(B.match){o=B.match.getAttribute("data-flex");p=B.match.getAttribute("data-specificity");if(!o||p<=B.flexSpecificity){B.match.setAttribute("data-flex",A);B.match.setAttribute("data-specificity",B.flexSpecificity);q=v(B.match,b.props.dim,s);r=Math.max(0,q+j);D(B.match,b.props.dim,r)}}})})};i=S(c.children,d,t);if(i.total){c.hasFlex=s;e(i);c=
-f(i);g(i,c)}}},boxAlign:function(a,d,c){var b=this,e,f,g=sa(a);if(!H&&!g.flex&&(c.orient==="vertical"||c.orient==="block-axis")){Qa(a,b.anti.dim)||D(a,b.anti.dim,t);D(d,b.anti.dim,t)}e=a[b.anti.out];h(b.anti.pad,function(i,k){e-=v(a,k,s)});switch(c.align){case "start":break;case "end":h(d,function(i,k){f=e-k[b.anti.out];f-=v(k,b.anti.opp,s);D(k,b.anti.pos,f)});break;case "center":h(d,function(i,k){f=(e-k[b.anti.out])/2;D(k,b.anti.pos,f)});break;default:h(d,function(i,k){switch(k.nodeName.toLowerCase()){case "button":case "input":case "select":break;
-default:var l=0;h(b.anti.pad,function(n,o){l+=v(k,o,s);l+=v(a,o,s)});k.style[b.anti.dim]="100%";f=k[b.anti.out]-l;D(k,b.anti.dim,t);f=e;f-=v(k,b.anti.pos,s);h(b.anti.pad,function(n,o){f-=v(k,o,s)});f-=v(k,b.anti.opp,s);f=Math.max(0,f);D(k,b.anti.dim,f)}})}},boxPack:function(a,d,c){var b=this,e=0,f=0,g=0,i,k,l;l=d.length-1;h(d,function(n,o){e+=o[b.props.out];e+=v(o,b.props.pos,s);e+=v(o,b.props.opp,s)});f=v(d[0],b.props.pos,s);i=a[b.props.out]-e;h(b.props.pad,function(n,o){i-=v(a,o,s)});if(i<0)i=Math.max(0,
-i);switch(c.pack){case "end":D(d[0],b.props.pos,g+f+i);break;case "center":if(g)g/=2;D(d[0],b.props.pos,g+f+Math.floor(i/2));break;case "justify":c=Math.floor((g+i)/l);l=c*l-i;for(g=d.length-1;g;){f=d[g];k=c;if(l){k++;l++}k=v(f,b.props.pos,s)+k;D(f,b.props.pos,k);g--}}a.style.overflow=""}},setup:function(a,d,c){var b=this,e,f;if(!(!a||!d||!c))if(H&&H.partialSupport){e=S(c.children,d,t);f=sa(a);d=O(a,a.childNodes);b.properties.boxOrient.call(b,a,d,c);if(!e.total||!K(c.nested).length){if(c.align===
-"stretch"&&!H.boxAlignStretch&&(!f.nested||!f.flex))b.properties.boxAlign.call(b,a,d,c);c.pack==="justify"&&!H.boxPackJustify&&!e.total&&b.properties.boxPack.call(b,a,d,c)}}else H||h(b.properties,function(g,i){i.call(b,a,O(a,a.childNodes),c)})},trackDOM:function(a){Oa(this,a)},updateModel:function(a){var d=a.target,c=a.nodes;ra(c);if(a.flexMatrix||a.ordinalMatrix)a=Ra(a);this.setup(d,c,a);this.bubbleUp(d,a)},renderModel:function(a){var d=this,c=a.target,b=c.childNodes;if(!c.length&&!b)return false;
-a=Sa(a,this);d.updateModel(a);x.setTimeout(function(){d.trackDOM(a)},0);return d},bubbleUp:function(a,d){for(var c,b=d.target.parentNode;b;){if(c=y[b.FLX_DOM_ID]){ra(c.nodes);this.setup(c.target,c.nodes,c)}b=b.parentNode}}};z.updateInstance=function(a,d){var c;if(a)if(c=y[a.FLX_DOM_ID])c._instance.updateModel(c);else c=new z.box(d);else h(y,function(b,e){e._instance.updateModel(e)})};z.getInstance=function(a){return y[a.FLX_DOM_ID]};z.destroyInstance=function(a){var d;d=function(c){c.target.FLX_DOM_ID=
-t;c.target.style.cssText=w;h(c.children,function(b,e){e.match.style.cssText=w})};if(a)(a=y[a.FLX_DOM_ID])&&d(a);else{h(y,function(c,b){d(b)});y=[]}};z.flexboxSupport=function(){var a={},d,c=E.createElement("flxbox"),b;c.style.width=c.style.height="100px";c.innerHTML='<b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b><b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b><b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b>';
-W(c,"display","box",t);W(c,"box-align","stretch",s);W(c,"box-pack","justify",s);E.body.appendChild(c);d=c.firstChild.offsetHeight;h({boxAlignStretch:function(){return d===100},boxPackJustify:function(){var e=0;h(c.childNodes,function(f,g){e+=g.offsetLeft});return e===135}},function(e,f){b=f();if(!b)a.partialSupport=s;a[e]=b});E.body.removeChild(c);return~c.style.display.indexOf("box")?a:I};z.init=function(){z.flexboxSupported=H=z.flexboxSupport();if((!H||H.partialSupport)&&K)ua()};z.version="1.0.3";
-(function(a){Y||(K=xa());var d,c,b;h(X,function(e,f){if(x[e]&&!d&&f.m){d=eval(f.m.replace("*",e));c=f.c?eval(f.c.replace("*",e)):x;b=[];if(d&&c){f.p&&b.push(f.p);b.push(a);d.apply(c,b);return false}}});d||Z("load",a)})(z.init);return z}(this,document);
+var Flexie=function(H,R){function O(a){if(a)a=a.replace(Ha,E).replace(Ia,E);return a}function ia(a,d){a="on"+a;var c=H[a];H[a]=typeof H[a]!=="function"?d:function(){c&&c();d()}}function ja(a){var d=a.nodeName.toLowerCase();if(a.id)d+="#"+a.id;else if(a.FLX_DOM_ID)d+="["+ka+"='"+a.FLX_DOM_ID+"']";return d}function ca(a){if(!a.FLX_DOM_ID){da+=1;a.FLX_DOM_ID=da;a.setAttribute(ka,a.FLX_DOM_ID)}}function Ja(a){var d,c,b,e,f=/\s?,\s?/,g,h,k,i={},n={},r,p,j,l,m,o,y,v;g=function(s,w,q,A){var z,C,I;s={selector:O(s),
+properties:[]};z=0;for(C=w.properties.length;z<C;z++){I=w.properties[z];s.properties.push({property:O(I.property),value:O(I.value)})}if(q&&A)s[q]=A;return s};h=function(s,w,q,A){var z=q&&A?i[s]:n[s],C,I,P,L,t;if(z){C=0;for(I=w.properties.length;C<I;C++){P=w.properties[C];L=0;for(t=z.properties.length;L<t;L++){s=z.properties[L];if(P.property===s.property)return false}z.properties.push(P)}if(q&&A)z[q]=A}else if(q&&A)i[s]=g(s,w,q,A);else n[s]=g(s,w,x,x)};r=0;for(p=a.length;r<p;r++){j=a[r];d=O(j.selector).replace(f,
+",").split(f);l=0;for(m=d.length;l<m;l++){o=O(d[l]);c=j.properties;y=0;for(v=c.length;y<v;y++){e=c[y];b=O(e.property);e=O(e.value);if(b){b=b.replace("box-",E);switch(b){case "display":e==="box"&&h(o,j,x,x);break;case "orient":case "align":case "direction":case "pack":h(o,j,x,x);break;case "flex":case "flex-group":case "ordinal-group":h(o,j,b,e)}}}}}for(k in n)n.hasOwnProperty(k)&&B.push(n[k]);for(k in i)i.hasOwnProperty(k)&&la.push(i[k]);return{boxes:B,children:la}}function ma(a,d,c){var b,e,f=[],
+g,h,k,i,n,r,p;g=0;for(h=c.length;g<h;g++){k=c[g];if(k.selector){b=d(k.selector);b=b[0]?b:[b];if(b[0]){i=0;for(n=b.length;i<n;i++){r=b[i];if(r.nodeName!==na)switch(r.nodeName.toLowerCase()){case "script":case "style":case "link":break;default:if(r.parentNode===a){ca(r);e={};for(p in k)if(k.hasOwnProperty(p))e[p]=k[p];e.match=r;f.push(e)}}}}}else{ca(k);f.push({match:k,selector:ja(k)})}}return f}function oa(a,d,c){c=c.replace(c.charAt(0),c.charAt(0).toUpperCase());c=a["offset"+c]||0;var b,e,f;if(c){b=
+0;for(e=d.length;b<e;b++){f=parseFloat(a.currentStyle[d[b]]);isNaN(f)||(c-=f)}}return c}function pa(a,d){var c,b,e=a.currentStyle&&a.currentStyle[d],f=a.style;if(!qa.test(e)&&Ka.test(e)){c=f.left;b=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;f.left=e||0;e=f.pixelLeft+"px";f.left=c||0;a.runtimeStyle.left=b}return e}function D(a,d,c){if(a!==na){if(H.getComputedStyle)a=H.getComputedStyle(a,x)[d];else if(La.test(d)){var b=a&&a.currentStyle?a.currentStyle[d]:0;if(!qa.test(b)){if(b==="auto"||
+b==="medium"){switch(d){case "width":b=[ra,sa,ta,ua];b=oa(a,b,d);break;case "height":b=[ea,va,wa,xa];b=oa(a,b,d);break;default:b=pa(a,d)}a=b}else a=pa(a,d);b=a}a=b}else a=a.currentStyle[d];if(c){a=parseInt(a,10);if(isNaN(a))a=0}return a}}function Ma(a){return a.innerWidth||a.clientWidth}function Na(a){return a.innerHeight||a.clientHeight}function fa(a,d,c,b){var e=[],f,g,h;f=0;for(g=ya.length;f<g;f++){h=ya[f];e.push((b?h:E)+d+":"+(!b?h:E)+c)}a.style.cssText+=e.join(";");return a}function M(a,d,c){var b=
+a&&a[0]?a:[a],e,f;e=0;for(f=b.length;e<f;e++)if((a=b[e])&&a.style)a.style[d]=c?c+"px":E}function Oa(a){var d,c,b,e,f;a=a.replace(Pa,function(g,h){return"%"+h}).replace(/\s|\>|\+|\~/g,"%").split(/%/g);d={_id:100,_class:10,_tag:1};b=c=0;for(e=a.length;b<e;b++){f=a[b];if(/#/.test(f))c+=d._id;else if(/\.|\[|\:/.test(f))c+=d._class;else if(/[a-zA-Z]+/.test(f))c+=d._tag}return c}function Qa(a,d,c){d=[];var b,e=(c?"ordinal":"flex")+"Specificity",f,g,h,k,i,n;f=0;for(g=a.length;f<g;f++){h=a[f];if(!c&&h.flex||
+c&&h["ordinal-group"]){h[e]=h[e]||Oa(h.selector);b=U;k=0;for(i=d.length;k<i;k++){n=d[k];if(n.match===h.match){if(n[e]<h[e])d[g]=h;return U}}b||d.push(h)}}return d}function Z(a,d,c){var b={},e=[],f=0,g,h,k,i,n,r,p,j;a=Qa(a,d,c);h=0;for(k=d.length;h<k;h++){i=d[h];n=0;for(r=a.length;n<r;n++){p=a[n];if(c){g=p["ordinal-group"]||"1";if(p.match===i){p.match.setAttribute("data-ordinal-group",g);b[g]=b[g]||[];b[g].push(p)}}else{g=p.flex||"0";if(p.match===i&&(!p[g]||p[g]&&parseInt(p[g],10)<=1)){f+=parseInt(g,
+10);b[g]=b[g]||[];b[g].push(p)}}}if(c&&!i.getAttribute("data-ordinal-group")){g="1";i.setAttribute("data-ordinal-group",g);b[g]=b[g]||[];b[g].push({match:i})}}for(j in b)b.hasOwnProperty(j)&&e.push(j);e.sort(function(l,m){return m-l});return{keys:e,groups:b,total:f}}function Ra(){if(!za){var a,d,c,b,e=R.body,f=R.documentElement,g;ia("resize",function(){g&&window.clearTimeout(g);g=window.setTimeout(function(){c=H.innerWidth||f.innerWidth||f.clientWidth||e.clientWidth;b=H.innerHeight||f.innerHeight||
+f.clientHeight||e.clientHeight;if(a!==c||d!==b){J.updateInstance(x,x);a=c;d=b}},250)});za=u}}function Aa(a){var d,c,b,e,f;d=0;for(c=a.length;d<c;d++){b=a[d];e=b.style.width;f=b.style.height;b.style.cssText=E;b.style.width=e;b.style.height=f}}function Y(a,d){var c=[],b,e,f;e=0;for(f=d.length;e<f;e++)if(b=d[e])switch(b.nodeName.toLowerCase()){case "script":case "style":case "link":break;default:if(b.nodeType===1)c.push(b);else if(b.nodeType===3&&(b.isElementContentWhitespace||Sa.test(b.data))){a.removeChild(b);
+e--}}return c}function Ba(a){var d=0;a=a.parentNode;for(var c;a.FLX_DOM_ID;){c=B[a.FLX_DOM_ID];c=Z(c.children,Y(a,a.childNodes),x);d+=c.total;c=u;a=a.parentNode}return{nested:c,flex:d}}function Ta(a,d){var c=a.target;if(!c.FLX_DOM_ID)c.FLX_DOM_ID=c.FLX_DOM_ID||++da;if(!a.nodes)a.nodes=Y(c,c.childNodes);if(!a.selector){a.selector=ja(c);c.setAttribute($,u)}if(!a.properties)a.properties=[];if(!a.children)a.children=ma(c,T,Y(c,c.childNodes));if(!a.nested)a.nested=a.selector+" ["+$+"]";a.target=c;a._instance=
+d;return a}var J={},da=0,ka="data-flexie-id",$="data-flexie-parent",Q,Ca,V={NW:{s:"*.Dom.select"},DOMAssistant:{s:"*.$",m:"*.DOMReady"},Prototype:{s:"$$",m:"document.observe",p:"dom:loaded",c:"document"},YAHOO:{s:"*.util.Selector.query",m:"*.util.Event.onDOMReady",c:"*.util.Event"},MooTools:{s:"$$",m:"window.addEvent",p:"domready"},Sizzle:{s:"*"},jQuery:{s:"*",m:"*(document).ready"},dojo:{s:"*.query",m:"*.addOnLoad"}},T,qa=/^-?\d+(?:px)?$/i,Ka=/^-?\d/,La=/width|height|margin|padding|border/,Ua=/(msie) ([\w.]+)/,
+Va=/\t|\n|\r/g,Wa=/^max\-([a-z]+)/,Xa=/^https?:\/\//i,Ha=/^\s\s*/,Ia=/\s\s*$/,Sa=/^\s*$/,Pa=/\s?(\#|\.|\[|\:(\:)?[^first\-(line|letter)|before|after]+)/g,E="",Da=" ",aa="$1",sa="paddingRight",va="paddingBottom",ra="paddingLeft",ea="paddingTop",ua="borderRightWidth",xa="borderBottomWidth",ta="borderLeftWidth",wa="borderTopWidth",ya=" -o- -moz- -ms- -webkit- -khtml- ".split(Da),Ya={orient:"horizontal",align:"stretch",direction:"inherit",pack:"start"},B=[],la=[],ga,za,u=true,U=false,x=null,na,W={IE:function(){var a,
+d=Ua.exec(H.navigator.userAgent.toLowerCase());if(d)a=parseInt(d[2],10);return a}()},Ea;Ea=function(){function a(j){return j.replace(k,function(l,m,o){var y,v;l=o.split(",");o=0;for(y=l.length;o<y;o++){v=l[o];v.replace(i,aa).replace(n,aa).replace(p,aa).replace(r,Da)}return m+l.join(",")})}function d(){if(H.XMLHttpRequest)return new H.XMLHttpRequest;try{return new H.ActiveXObject("Microsoft.XMLHTTP")}catch(j){return x}}function c(j){var l=d();l.open("GET",j,U);l.send();l=l.status===200?l.responseText:
+E;if(j===window.location.href){j=l;l=/<style[^<>]*>([^<>]*)<\/style[\s]?>/img;for(var m=l.exec(j),o=[];m;){(m=m[1])&&o.push(m);m=l.exec(j)}l=o.join("\n\n")}return l}function b(j,l){if(j){if(Xa.test(j))return l.substring(0,l.indexOf("/",8))===j.substring(0,j.indexOf("/",8))?j:x;if(j.charAt(0)==="/")return l.substring(0,l.indexOf("/",8))+j;var m=l.split("?")[0];if(j.charAt(0)!=="?"&&m.charAt(m.length-1)!=="/")m=m.substring(0,m.lastIndexOf("/")+1);return m+j}}function e(j){if(j)return c(j).replace(f,
+E).replace(g,function(l,m,o,y,v,s){l=e(b(o||v,j));return s?"@media "+s+" {"+l+"}":l}).replace(h,function(l,m,o,y){o=o||E;return m?l:" url("+o+b(y,j,true)+o+") "});return E}var f=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g,g=/@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g,h=/(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g,k=/((?:^|(?:\s*\})+)(?:\s*@media[^\{]+\{)?)\s*([^\{]*?[\[:][^{]+)/g,i=/([(\[+~])\s+/g,n=/\s+([)\]+~])/g,r=/\s+/g,p=/^\s*((?:[\S\s]*\S)?)\s*$/;
+return function(){var j,l=[],m,o;m=R.getElementsByTagName("BASE");var y=m.length>0?m[0].href:R.location.href,v=R.styleSheets,s,w;m=0;for(o=v.length;m<o;m++){j=v[m];j!=x&&l.push(j)}l.push(window.location);m=0;for(o=l.length;m<o;m++)if(j=l[m]){if(j=b(j.href,y))s=a(e(j));if(s){w=s;j=[];v=void 0;var q=void 0,A=void 0;q=void 0;A=void 0;var z=void 0,C=void 0,I=void 0,P=void 0;z=void 0;w=w.replace(Va,E);w=w.replace(/\s?(\{|\:|\})\s?/g,aa);v=w.split("}");for(I in v)if(v.hasOwnProperty(I))if(w=v[I]){q=[w,
+"}"].join(E);if((A=/(\@media[^\{]+\{)?(.*)\{(.*)\}/.exec(q))&&A[3]){q=A[2];A=A[3].split(";");C=[];for(P in A)if(A.hasOwnProperty(P)){z=A[P];z=z.split(":");z.length&&z[1]&&C.push({property:z[0],value:z[1]})}q&&C.length&&j.push({selector:q,properties:C})}}w=j;w=Ja(w)}}l=w;var L,t,F,G;I={};var N;P="["+$+"]";var K,X,S,ha,ba,Fa,Ga;if(l){q=0;for(A=l.boxes.length;q<A;q++){F=l.boxes[q];F.selector=O(F.selector);s=F.selector;m=F.properties;o=y=w=j=v=x;C=0;for(z=m.length;C<z;C++){G=m[C];L=O(G.property);t=O(G.value);
+if(L){L=L.replace("box-",E);switch(L){case "display":if(t==="box")o=t;break;case "orient":y=t;break;case "align":w=t;break;case "direction":j=t;break;case "pack":v=t}}}L=T;F=L(F.selector);F=F[0]?F:[F];C=0;for(z=F.length;C<z;C++){t=F[C];if(t.nodeType){ca(t);G=ma(t,L,l.children);N=s+" "+P;G={target:t,selector:s,properties:m,children:G,display:o,orient:y,align:w,direction:j,pack:v,nested:N};if(N=I[t.FLX_DOM_ID])for(K in G){if(G.hasOwnProperty(K)){t=G[K];switch(K){case "selector":if(t&&!RegExp(t).test(N[K]))N[K]+=
+", "+t;break;case "children":X=0;for(S=G[K].length;X<S;X++){ha=G[K][X];t=U;ba=0;for(Fa=N[K].length;ba<Fa;ba++){Ga=N[K][ba];if(ha.match.FLX_DOM_ID===Ga.match.FLX_DOM_ID)t=u}t||N[K].push(ha)}break;default:if(t)N[K]=t}}}else{N=I;X=t.FLX_DOM_ID;S=void 0;for(S in G)if(G.hasOwnProperty(S))G[S]=G[S]||Ya[S];N[X]=G;I[t.FLX_DOM_ID].target.setAttribute($,u)}}}}ga=T(P);B={};q=0;for(A=ga.length;q<A;q++){t=ga[q];B[t.FLX_DOM_ID]=I[t.FLX_DOM_ID]}for(K in B)if(B.hasOwnProperty(K)){F=B[K];F.display==="box"&&new J.box(F)}}}}();
+J.box=function(a){return this.renderModel(a)};J.box.prototype={properties:{boxModel:function(a,d,c){var b,e,f,g,h;a.style.display="block";if(W.IE===8)a.style.overflow="hidden";if(!c.cleared){d=c.selector.split(/\s?,\s?/);b=R.styleSheets;b=b[b.length-1];e="padding-top:"+(D(a,ea,x)||"0.1px;");f=0;for(g=d.length;f<g;f++){h=d[f];if(b.addRule)if(W.IE<8){a.style.zoom="1";if(W.IE===6)b.addRule(h.replace(/\>|\+|\~/g,""),e+"zoom:1;",0);else W.IE===7&&b.addRule(h,e+"display:inline-block;",0)}else{b.addRule(h,
+e,0);b.addRule(h+":before","content: '.';display: block;height: 0;overflow: hidden",0);b.addRule(h+":after","content: '.';display: block;height: 0;overflow: hidden;clear:both;",0)}else if(b.insertRule){b.insertRule(h+"{"+e+"}",0);b.insertRule(h+":after{content: '.';display: block;height: 0;overflow: hidden;clear:both;}",0)}}c.cleared=u}},boxDirection:function(a,d,c){var b,e,f;if(c.direction==="reverse"&&!c.reversed||c.direction==="normal"&&c.reversed){d=d.reverse();b=0;for(e=d.length;b<e;b++){f=d[b];
+a.appendChild(f)}a=T(c.nested);b=0;for(e=a.length;b<e;b++){d=a[b];if((d=B[d.FLX_DOM_ID])&&d.direction==="inherit")d.direction=c.direction}c.reversed=!c.reversed}},boxOrient:function(a,d,c){var b,e,f,g;a={pos:"marginLeft",opp:"marginRight",dim:"width",out:"offsetWidth",func:Ma,pad:[ra,sa,ta,ua]};b={pos:"marginTop",opp:"marginBottom",dim:"height",out:"offsetHeight",func:Na,pad:[ea,va,wa,xa]};if(!Q){e=0;for(f=d.length;e<f;e++){g=d[e];g.style[W.IE>=9?"cssFloat":"styleFloat"]="left";if(c.orient==="vertical"||
+c.orient==="block-axis")g.style.clear="left";if(W.IE===6)g.style.display="inline"}}switch(c.orient){case "vertical":case "block-axis":this.props=b;this.anti=a;break;default:this.props=a;this.anti=b}},boxOrdinalGroup:function(a,d,c){var b,e;if(d.length){b=function(f){f=f.keys;f=c.reversed?f:f.reverse();var g,h,k,i,n,r;g=0;for(h=f.length;g<h;g++){k=f[g];i=0;for(n=d.length;i<n;i++){r=d[i];k===r.getAttribute("data-ordinal-group")&&a.appendChild(r)}}};e=Z(c.children,d,u);e.keys.length>1&&b(e)}},boxFlex:function(a,
+d,c){var b=this,e,f,g,h;if(d.length){e=function(k){var i=k.groups;k=k.keys;var n,r,p,j,l,m,o,y,v,s;r=0;for(p=k.length;r<p;r++){j=k[r];l=0;for(m=i[j].length;l<m;l++){o=i[j][l];n=x;y=0;for(v=o.properties.length;y<v;y++){s=o.properties[y];if(Wa.test(s.property))n=parseFloat(s.value)}if(!n||o.match[b.props.out]>n)M(o.match,b.props.pos,x)}}};f=function(k){var i=0,n,r,p,j,l,m;n=0;for(r=d.length;n<r;n++){p=d[n];i+=D(p,b.props.dim,u);j=0;for(l=b.props.pad.length;j<l;j++){m=b.props.pad[j];i+=D(p,m,u)}i+=D(p,
+b.props.pos,u);i+=D(p,b.props.opp,u)}i=a[b.props.out]-i;n=0;for(r=b.props.pad.length;n<r;n++){m=b.props.pad[n];i-=D(a,m,u)}return{whitespace:i,ration:i/k.total}};g=function(k,i){var n=k.groups,r=k.keys,p,j,l=i.ration,m,o,y,v,s,w,q;o=0;for(y=r.length;o<y;o++){v=r[o];m=l*v;s=0;for(w=n[v].length;s<w;s++){q=n[v][s];if(q.match){p=q.match.getAttribute("data-flex");j=q.match.getAttribute("data-specificity");if(!p||j<=q.flexSpecificity){q.match.setAttribute("data-flex",v);q.match.setAttribute("data-specificity",
+q.flexSpecificity);p=D(q.match,b.props.dim,u);p=Math.max(0,p+m);M(q.match,b.props.dim,p)}}}}};h=Z(c.children,d,x);if(h.total){c.hasFlex=u;e(h);c=f(h);g(h,c)}}},boxAlign:function(a,d,c){var b,e;b=Ba(a);var f,g,h,k,i;if(!Q&&!b.flex&&(c.orient==="vertical"||c.orient==="block-axis")){a:{b=this.anti.dim;f=a.parentNode;if(f.FLX_DOM_ID){f=B[f.FLX_DOM_ID];g=0;for(h=f.properties.length;g<h;g++){k=f.properties[g];if(RegExp(b).test(k.property)){b=U;break a}}}b=void 0}b||M(a,this.anti.dim,x);M(d,this.anti.dim,
+x)}b=a[this.anti.out];f=0;for(g=this.anti.pad.length;f<g;f++){h=this.anti.pad[f];b-=D(a,h,u)}switch(c.align){case "start":break;case "end":f=0;for(g=d.length;f<g;f++){i=d[f];e=b-i[this.anti.out];e-=D(i,this.anti.opp,u);M(i,this.anti.pos,e)}break;case "center":f=0;for(g=d.length;f<g;f++){i=d[f];e=(b-i[this.anti.out])/2;M(i,this.anti.pos,e)}break;default:f=0;for(g=d.length;f<g;f++){i=d[f];switch(i.nodeName.toLowerCase()){case "button":case "input":case "select":break;default:c=e=0;for(k=this.anti.pad.length;c<
+k;c++){h=this.anti.pad[c];e+=D(i,h,u);e+=D(a,h,u)}i.style[this.anti.dim]="100%";M(i,this.anti.dim,x);e=b;e-=D(i,this.anti.pos,u);c=0;for(k=this.anti.pad.length;c<k;c++){h=this.anti.pad[c];e-=D(i,h,u)}e-=D(i,this.anti.opp,u);e=Math.max(0,e);M(i,this.anti.dim,e)}}}},boxPack:function(a,d,c){var b=0,e=0,f=0,g;g=d.length-1;var h,k,i;h=0;for(k=d.length;h<k;h++){e=d[h];b+=e[this.props.out];b+=D(e,this.props.pos,u);b+=D(e,this.props.opp,u)}e=D(d[0],this.props.pos,u);b=a[this.props.out]-b;h=0;for(k=this.props.pad.length;h<
+k;h++){i=this.props.pad[h];b-=D(a,i,u)}if(b<0)b=Math.max(0,b);switch(c.pack){case "end":M(d[0],this.props.pos,f+e+b);break;case "center":if(f)f/=2;M(d[0],this.props.pos,f+e+Math.floor(b/2));break;case "justify":c=Math.floor((f+b)/g);g=c*g-b;for(h=d.length-1;h;){e=d[h];f=c;if(g){f++;g++}f=D(e,this.props.pos,u)+f;M(e,this.props.pos,f);h--}}a.style.overflow=""}},setup:function(a,d,c){var b,e;if(!(!a||!d||!c))if(Q&&Q.partialSupport){b=Z(c.children,d,x);e=Ba(a);d=Y(a,a.childNodes);this.properties.boxOrient.call(this,
+a,d,c);if(!b.total||!T(c.nested).length){if(c.align==="stretch"&&!Q.boxAlignStretch&&(!e.nested||!e.flex))this.properties.boxAlign.call(this,a,d,c);c.pack==="justify"&&!Q.boxPackJustify&&!b.total&&this.properties.boxPack.call(this,a,d,c)}}else if(!Q)for(b in this.properties)if(this.properties.hasOwnProperty(b)){d=this.properties[b];d.call(this,a,Y(a,a.childNodes),c)}},trackDOM:function(a){Ra(this,a)},updateModel:function(a){var d=a.target,c=a.nodes;Aa(c);if(a.flexMatrix||a.ordinalMatrix){var b,e,
+f;if(a.flexMatrix){b=0;for(e=a.children.length;b<e;b++){f=a.children[b];f.flex=a.flexMatrix[b]}}if(a.ordinalMatrix){b=0;for(e=a.children.length;b<e;b++){f=a.children[b];f["ordinal-group"]=a.ordinalMatrix[b]}}}this.setup(d,c,a);this.bubbleUp(d,a)},renderModel:function(a){var d=this,c=a.target,b=c.childNodes;if(!c.length&&!b)return false;a=Ta(a,this);d.updateModel(a);H.setTimeout(function(){d.trackDOM(a)},0);return d},bubbleUp:function(a,d){for(var c,b=d.target.parentNode;b;){if(c=B[b.FLX_DOM_ID]){Aa(c.nodes);
+this.setup(c.target,c.nodes,c)}b=b.parentNode}}};J.updateInstance=function(a,d){var c,b;if(a)if(c=B[a.FLX_DOM_ID])c._instance.updateModel(c);else new J.box(d);else for(b in B)if(B.hasOwnProperty(b)){c=B[b];c._instance.updateModel(c)}};J.getInstance=function(a){return B[a.FLX_DOM_ID]};J.destroyInstance=function(a){var d,c,b,e,f;d=function(g){g.target.FLX_DOM_ID=x;g.target.style.cssText=E;c=0;for(b=g.children.length;c<b;c++){e=g.children[c];e.match.style.cssText=E}};if(a)(a=B[a.FLX_DOM_ID])&&d(a);else{for(f in B)B.hasOwnProperty(f)&&
+d(B[f]);B=[]}};J.flexboxSupport=function(){var a={},d,c=R.createElement("flxbox"),b,e,f;c.style.width=c.style.height="100px";c.innerHTML='<b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b><b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b><b style="margin: 0; padding: 0; display:block; width: 10px; height:50px"></b>';fa(c,"display","box",x);fa(c,"box-align","stretch",u);fa(c,"box-pack","justify",u);R.body.appendChild(c);d=c.firstChild.offsetHeight;
+b={boxAlignStretch:function(){return d===100},boxPackJustify:function(){var g=0,h,k;h=0;for(k=c.childNodes.length;h<k;h++)g+=c.childNodes[h].offsetLeft;return g===135}};for(f in b)if(b.hasOwnProperty(f)){e=b[f];e=e();if(!e)a.partialSupport=u;a[f]=e}R.body.removeChild(c);return~c.style.display.indexOf("box")?a:U};J.init=function(){J.flexboxSupported=Q=J.flexboxSupport();if((!Q||Q.partialSupport)&&T)Ea()};J.version="1.0.3";(function(a){if(!Ca){var d,c,b;for(c in V)if(V.hasOwnProperty(c)){b=V[c];if(H[c]&&
+!d)if(d=eval(b.s.replace("*",c))){Ca=c;break}}T=d}var e,f;for(f in V)if(V.hasOwnProperty(f)){b=V[f];if(H[f]&&!e&&b.m){e=eval(b.m.replace("*",f));d=b.c?eval(b.c.replace("*",f)):H;c=[];if(e&&d){b.p&&c.push(b.p);c.push(a);e.apply(d,c);break}}}e||ia("load",a)})(J.init);return J}(this,document);
View
716 src/flexie.js
@@ -183,28 +183,6 @@ var Flexie = (function (win, doc) {
return string;
}
- // Via jQuery 1.4.3
- // http://github.com/jquery/jquery/blob/master/src/core.js#L593
- function forEach(object, callback) {
- var name, i = 0, value,
- length = object ? object.length : UNDEFINED,
- isObj = length === UNDEFINED;
-
- if (isObj) {
- for (name in object) {
- if (object.hasOwnProperty(name)) {
- if (callback.call(object[name], name, object[name]) === FALSE) {
- break;
- }
- }
- }
- } else {
- for (value = object[0]; i < length && callback.call(value, i, value) !== FALSE; value = object[++i]) {
- continue;
- }
- }
- }
-
// --[ determineSelectorMethod() ]--------------------------------------
// walks through the engines object testing for an suitable
// selector engine.
@@ -212,18 +190,23 @@ var Flexie = (function (win, doc) {
// Moving outside Selectivizr scope because detection is needed before running selectivizrEngine
function determineSelectorMethod() {
// compatiable selector engines in order of CSS3 support
- var engines = ENGINES, method;
+ var engines = ENGINES, method,
+ engine, obj;
- forEach(engines, function (engine, obj) {
- if (win[engine] && !method) {
- method = eval(obj.s.replace("*", engine));
-
- if (method) {
- ENGINE = engine;
- return false;
+ for (engine in engines) {
+ if (engines.hasOwnProperty(engine)) {
+ obj = engines[engine];
+
+ if (win[engine] && !method) {
+ method = eval(obj.s.replace("*", engine));
+
+ if (method) {
+ ENGINE = engine;
+ break;
+ }
}
}
- });
+ }
return method;
}
@@ -252,24 +235,29 @@ var Flexie = (function (win, doc) {
// compatiable selector engines in order of CSS3 support
var engines = ENGINES,
- method, caller, args;
+ method, caller, args,
+ engine, obj;
- forEach(engines, function (engine, obj) {
- if (win[engine] && !method && obj.m) {
- method = eval(obj.m.replace("*", engine));
- caller = obj.c ? eval(obj.c.replace("*", engine)) : win;
- args = [];
-
- if (method && caller) {
- if (obj.p) {
- args.push(obj.p);
+ for (engine in engines) {
+ if (engines.hasOwnProperty(engine)) {
+ obj = engines[engine];
+
+ if (win[engine] && !method && obj.m) {
+ method = eval(obj.m.replace("*", engine));
+ caller = obj.c ? eval(obj.c.replace("*", engine)) : win;
+ args = [];
+
+ if (method && caller) {
+ if (obj.p) {
+ args.push(obj.p);
+ }
+ args.push(handler);
+ method.apply(caller, args);
+ break;
}
- args.push(handler);
- method.apply(caller, args);
- return false;
}
}
- });
+ }
if (!method) {
addEvent("load", handler);
@@ -299,7 +287,8 @@ var Flexie = (function (win, doc) {
function buildSelectorTree(text) {
var rules = [], ruletext, rule,
- match, selector, proptext, splitprop, properties;
+ match, selector, proptext, splitprop, properties,
+ i, j, x;
// Tabs, Returns
text = text.replace(WHITESPACE_CHARACTERS, EMPTY_STRING);
@@ -308,38 +297,45 @@ var Flexie = (function (win, doc) {
text = text.replace(/\s?(\{|\:|\})\s?/g, PLACEHOLDER_STRING);
ruletext = text.split(END_MUSTACHE);
-
- forEach(ruletext, function (i, text) {
- if (text) {
- rule = [text, END_MUSTACHE].join(EMPTY_STRING);
-
- match = (/(\@media[^\{]+\{)?(.*)\{(.*)\}/).exec(rule);
-
- if (match && match[3]) {
- selector = match[2];
- proptext = match[3].split(";");
- properties = [];
+
+ for (i in ruletext) {
+ if (ruletext.hasOwnProperty(i)) {
+ text = ruletext[i];
+
+ if (text) {
+ rule = [text, END_MUSTACHE].join(EMPTY_STRING);
+
+ match = (/(\@media[^\{]+\{)?(.*)\{(.*)\}/).exec(rule);
- forEach(proptext, function (i, x) {
- splitprop = x.split(":");
+ if (match && match[3]) {
+ selector = match[2];
+ proptext = match[3].split(";");
+ properties = [];
- if (splitprop.length && splitprop[1]) {
- properties.push({
- property : splitprop[0],
- value : splitprop[1]
+ for (j in proptext) {
+ if (proptext.hasOwnProperty(j)) {
+ x = proptext[j];
+ splitprop = x.split(":");
+
+ if (splitprop.length && splitprop[1]) {
+ properties.push({
+ property : splitprop[0],
+ value : splitprop[1]
+ });
+ }
+ }
+ }
+
+ if (selector && properties.length) {
+ rules.push({
+ selector : selector,
+ properties : properties
});
}
- });
-
- if (selector && properties.length) {
- rules.push({
- selector : selector,
- properties : properties
- });
}
}
}
- });
+ }
return rules;
}
@@ -348,21 +344,26 @@ var Flexie = (function (win, doc) {
var selectors, properties,
property, value, shortProp,
selectorSplit = /\s?,\s?/,
- createUniqueObject, addRules,
- uniqueChildren = {}, uniqueBoxes = {};
+ createUniqueObject, addRules, key,
+ uniqueChildren = {}, uniqueBoxes = {},
+ i, j, rule, k, l, selector, m, n, prop;
createUniqueObject = function (selector, rules, prop, value) {
- var unique = {
+ var unique, i, j, rule;
+
+ unique = {
selector : trim(selector),
properties : []
};
- forEach(rules.properties, function (i, prop) {
+ for (i = 0, j = rules.properties.length; i < j; i++) {
+ rule = rules.properties[i];
+
unique.properties.push({
- property : trim(prop.property),
- value : trim(prop.value)
+ property : trim(rule.property),
+ value : trim(rule.value)
});
- });
+ }
if (prop && value) {
unique[prop] = value;
@@ -373,23 +374,27 @@ var Flexie = (function (win, doc) {
addRules = function (selector, rules, prop, value) {
var box = (prop && value) ? uniqueChildren[selector] : uniqueBoxes[selector],
- exists;
+ exists, x, i, j, rule, k, l;
if (box) {
- forEach(rules.properties, function (i, rule) {
- forEach(box.properties, function (j, x) {
+ for (i = 0, j = rules.properties.length; i < j; i++) {
+ rule = rules.properties[i];
+
+ for (k = 0, l = box.properties.length; k < l; k++) {
+ x = box.properties[k];
+
if (rule.property === x.property) {
- exists = j;
+ exists = k;
return false;
}
- });
+ }
if (exists) {
box.properties[exists] = rule;
} else {
box.properties.push(rule);
}
- });
+ }
if (prop && value) {
box[prop] = value;
@@ -402,15 +407,18 @@ var Flexie = (function (win, doc) {
}
}
};
-
- forEach(rules, function (i, rule) {
+
+ for (i = 0, j = rules.length; i < j; i++) {
+ rule = rules[i];
+
selectors = trim(rule.selector).replace(selectorSplit, ",").split(selectorSplit);
-
- forEach(selectors, function (i, selector) {
- selector = trim(selector);
+
+ for (k = 0, l = selectors.length; k < l; k++) {
+ selector = trim(selectors[k]);
properties = rule.properties;
- forEach(properties, function (i, prop) {
+ for (m = 0, n = properties.length; m < n; m++) {
+ prop = properties[m];
property = trim(prop.property);
value = trim(prop.value);
@@ -438,17 +446,21 @@ var Flexie = (function (win, doc) {
break;
}
}
- });
- });
- });
-
- forEach(uniqueBoxes, function (key, box) {
- FLEX_BOXES.push(box);
- });
-
- forEach(uniqueChildren, function (key, child) {
- POSSIBLE_FLEX_CHILDREN.push(child);
- });
+ }
+ }
+ }
+
+ for (key in uniqueBoxes) {
+ if (uniqueBoxes.hasOwnProperty(key)) {
+ FLEX_BOXES.push(uniqueBoxes[key]);
+ }
+ }
+
+ for (key in uniqueChildren) {
+ if (uniqueChildren.hasOwnProperty(key)) {
+ POSSIBLE_FLEX_CHILDREN.push(uniqueChildren[key]);
+ }
+ }
return {
boxes : FLEX_BOXES,
@@ -457,15 +469,23 @@ var Flexie = (function (win, doc) {
}
function matchFlexChildren(parent, lib, possibleChildren) {
- var caller, unique, matches = [];
-
- forEach(possibleChildren, function (i, child) {
+ var caller, unique, matches = [],
+ i, j, child,
+ k, l, node,
+ key;
+
+ for (i = 0, j = possibleChildren.length; i < j; i++) {
+ child = possibleChildren[i];
+
if (child.selector) {
caller = lib(child.selector);
caller = caller[0] ? caller : [caller];
if (caller[0]) {
- forEach(caller, function (i, node) {
+
+ for (k = 0, l = caller.length; k < l; k++) {
+ node = caller[k];
+
if (node.nodeName !== UNDEFINED) {
switch (node.nodeName.toLowerCase()) {
case "script" :
@@ -480,9 +500,11 @@ var Flexie = (function (win, doc) {
unique = {};
- forEach(child, function (key) {
- unique[key] = child[key];
- });
+ for (key in child) {
+ if (child.hasOwnProperty(key)) {
+ unique[key] = child[key];
+ }
+ }
unique.match = node;
matches.push(unique);
@@ -490,7 +512,7 @@ var Flexie = (function (win, doc) {
break;
}
}
- });
+ }
}
} else {
// Flag each unique node with FLX_DOM_ID
@@ -501,33 +523,40 @@ var Flexie = (function (win, doc) {
selector : buildSelector(child)
});
}
- });
+ }
return matches;
}
function getParams(params) {
- forEach(params, function (key, value) {
- params[key] = value || DEFAULTS[key];
- });
+ var key;
+
+ for (key in params) {
+ if (params.hasOwnProperty(key)) {
+ params[key] = params[key] || DEFAULTS[key];
+ }
+ }
return params;
}
function buildFlexieCall(flexers) {
var selector, properties, property, value, shortProp,
- display, orient, align, direction, pack,
- lib, caller, children,
- box, params, flexboxes = {},
- match, childMatch, nestedFlexboxes,
- flexieParentSelector = "[" + FLX_PARENT_ATTR + "]";
+ display, orient, align, direction, pack,
+ lib, caller, children,
+ box, params, flexboxes = {},
+ match, childMatch, nestedFlexboxes,
+ flexieParentSelector = "[" + FLX_PARENT_ATTR + "]",
+ i, j, flex, k, l, prop,
+ target, key, m, n, child, o, p, existing;
// No boxflex? No dice.
if (!flexers) {
return;
}
-
- forEach(flexers.boxes, function (i, flex) {
+
+ for (i = 0, j = flexers.boxes.length; i < j; i++) {
+ flex = flexers.boxes[i];
flex.selector = trim(flex.selector);
selector = flex.selector;
@@ -535,8 +564,9 @@ var Flexie = (function (win, doc) {
display = orient = align = direction = pack = NULL;
- forEach(properties, function (i, prop) {
-
+ for (k = 0, l = properties.length; k < l; k++) {
+ prop = properties[k];
+
property = trim(prop.property);
value = trim(prop.value);
@@ -567,7 +597,7 @@ var Flexie = (function (win, doc) {
break;
}
}
- });
+ }
// Determine library
lib = LIBRARY;
@@ -578,7 +608,9 @@ var Flexie = (function (win, doc) {
// In an array?
caller = caller[0] ? caller : [caller];
- forEach(caller, function (i, target) {
+ for (k = 0, l = caller.length; k < l; k++) {
+ target = caller[k];
+
// If is DOM object
if (target.nodeType) {
// Flag each unique node with FLX_DOM_ID
@@ -607,73 +639,88 @@ var Flexie = (function (win, doc) {
match = flexboxes[target.FLX_DOM_ID];
if (match) {
- forEach(params, function (key, value) {
- switch (key) {
- case "selector" :
- if (value && !(new RegExp(value).test(match[key]))) {
- match[key] += ", " + value;
- }
- break;
-
- case "children" :
- forEach(params[key], function (k, child) {
- childMatch = FALSE;
-
- forEach(match[key], function (key, existing) {
- if (child.match.FLX_DOM_ID === existing.match.FLX_DOM_ID) {
- childMatch = TRUE;
+ for (key in params) {
+ if (params.hasOwnProperty(key)) {
+ value = params[key];
+
+ switch (key) {
+ case "selector" :
+ if (value && !(new RegExp(value).test(match[key]))) {
+ match[key] += ", " + value;
+ }
+ break;
+
+ case "children" :
+ for (m = 0, n = params[key].length; m < n; m++) {
+ child = params[key][m];
+ childMatch = FALSE;
+
+ for (o = 0, p = match[key].length; o < p; o++) {
+ existing = match[key][o];
+
+ if (child.match.FLX_DOM_ID === existing.match.FLX_DOM_ID) {
+ childMatch = TRUE;
+ }
}
- });
+
+ if (!childMatch) {
+ match[key].push(child);
+ }
+ }
+ break;
- if (!childMatch) {
- match[key].push(child);
+ default :
+ if (value) {
+ match[key] = value;
}
- });
- break;
-
- default :
- if (value) {
- match[key] = value;
+ break;
}
- break;
}
- });
+ }
} else {
flexboxes[target.FLX_DOM_ID] = getParams(params);
flexboxes[target.FLX_DOM_ID].target.setAttribute(FLX_PARENT_ATTR, TRUE);
}
}
- });
- });
+ }
+ }
DOM_ORDERED = LIBRARY(flexieParentSelector);
FLEX_BOXES = {};
- forEach(DOM_ORDERED, function (i, target) {
+ for (i = 0, j = DOM_ORDERED.length; i < j; i++) {
+ target = DOM_ORDERED[i];
+
FLEX_BOXES[target.FLX_DOM_ID] = flexboxes[target.FLX_DOM_ID];
- });
+ }
// Loop through each match, initialize constructor
- forEach(FLEX_BOXES, function (key, flex) {
- // One final check to ensure each flexbox has a display property
- if (flex.display === "box") {
- // Constructor
- box = new FLX.box(flex);
+ for (key in FLEX_BOXES) {
+ if (FLEX_BOXES.hasOwnProperty(key)) {
+ flex = FLEX_BOXES[key];
+
+ // One final check to ensure each flexbox has a display property
+ if (flex.display === "box") {
+ // Constructor
+ box = new FLX.box(flex);
+ }
}
- });
+ }
}
function calcPx(element, props, dir) {
var dim = dir.replace(dir.charAt(0), dir.charAt(0).toUpperCase()),
- value = element["offset" + dim] || 0;
+ value = element["offset" + dim] || 0,
+ i, j, prop;
if (value) {
- forEach(props, function (i, prop) {
- prop = parseFloat(element.currentStyle[prop]);
+ for (i = 0, j = props.length; i < j; i++) {
+ prop = parseFloat(element.currentStyle[props[i]]);
+
if (!isNaN(prop)) {
value -= prop;
}
- });
+ }
}
return value;
@@ -777,28 +824,34 @@ var Flexie = (function (win, doc) {
}
function appendProperty(target, prop, value, prefixName) {
- var cssText = [];
-
- forEach(PREFIXES, function (i, prefix) {
+ var cssText = [],
+ i, j, prefix;
+
+ for (i = 0, j = PREFIXES.length; i < j; i++) {
+ prefix = PREFIXES[i];
cssText.push((prefixName ? prefix : EMPTY_STRING) + prop + ":" + (!prefixName ? prefix : EMPTY_STRING) + value);
- });
+ }
target.style.cssText += cssText.join(";");
return target;
}
function appendPixelValue(target, prop, value) {
- var targets = target && target[0] ? target : [target];
+ var targets = target && target[0] ? target : [target],
+ i, j;
- forEach(targets, function (i, target) {
+ for (i = 0, j = targets.length; i < j; i++) {
+ target = targets[i];
+
if (target && target.style) {
target.style[prop] = (value ? (value + "px") : EMPTY_STRING);
}
- });
+ }
}
function calculateSpecificity (selector) {
- var selectorGrid, matrix, total;
+ var selectorGrid, matrix, total,
+ i, j, chunk;
selectorGrid = selector.replace(CSS_SELECTOR, function (e, f) {
return "%" + f;
@@ -814,7 +867,9 @@ var Flexie = (function (win, doc) {
total = 0;
// Add each selector value to total.
- forEach(selectorGrid, function (i, chunk) {
+ for (i = 0, j = selectorGrid.length; i < j; i++) {
+ chunk = selectorGrid[i];
+
if ((/#/).test(chunk)) {
total += matrix._id;
} else if ((/\.|\[|\:/).test(chunk)) {
@@ -822,22 +877,27 @@ var Flexie = (function (win, doc) {
} else if ((/[a-zA-Z]+/).test(chunk)) {
total += matrix._tag;
}
- });
+ }
return total;
}
function filterDuplicates (matches, children, type) {
var filteredMatches = [], exists,
- spec = (type ? "ordinal" : "flex") + "Specificity";
+ spec = (type ? "ordinal" : "flex") + "Specificity",
+ i, j, x, k, l, f;
- forEach(matches, function (i, x) {
+ for (i = 0, j = matches.length; i < j; i++) {
+ x = matches[i];
+
if ((!type && x.flex) || (type && x["ordinal-group"])) {
x[spec] = x[spec] || calculateSpecificity(x.selector);
exists = FALSE;
- forEach(filteredMatches, function (j, f) {
+ for (k = 0, l = filteredMatches.length; k < l; k++) {
+ f = filteredMatches[k];
+
if (f.match === x.match) {
if (f[spec] < x[spec]) {
filteredMatches[j] = x;
@@ -846,27 +906,32 @@ var Flexie = (function (win, doc) {
exists = TRUE;
return FALSE;
}
- });
+ }
if (!exists) {
filteredMatches.push(x);
}
}
- });
+ }
return filteredMatches;
}
function createMatchMatrix(matches, children, type) {
var groups = {}, keys = [], totalRatio = 0,
- group, order = "ordinal-group",
- BoxOrdinalAttr = "data-" + order;
+ group, order = "ordinal-group",
+ BoxOrdinalAttr = "data-" + order,
+ i, j, kid, k, l, x, key;
// Filter dupes
matches = filterDuplicates(matches, children, type);
- forEach(children, function (i, kid) {
- forEach(matches, function (j, x) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
+ for (k = 0, l = matches.length; k < l; k++) {
+ x = matches[k];
+
if (type) {
// If no value declared, it's the default.
group = x[order] || "1";
@@ -888,7 +953,7 @@ var Flexie = (function (win, doc) {
groups[group].push(x);
}
}
- });
+ }
if (type && !kid.getAttribute(BoxOrdinalAttr)) {
group = "1";
@@ -899,11 +964,13 @@ var Flexie = (function (win, doc) {
match : kid
});
}
- });
+ }
- forEach(groups, function (key) {
- keys.push(key);
- });
+ for (key in groups) {
+ if (groups.hasOwnProperty(key)) {
+ keys.push(key);
+ }
+ }
keys.sort(function (a, b) {
return b - a;
@@ -949,9 +1016,11 @@ var Flexie = (function (win, doc) {
}
function cleanPositioningProperties (children) {
- var w, h;
+ var i, j, kid, w, h;
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
w = kid.style.width;
h = kid.style.height;
@@ -959,7 +1028,7 @@ var Flexie = (function (win, doc) {
kid.style.width = w;
kid.style.height = h;
- });
+ }
}
function sanitizeChildren (target, nodes) {
@@ -1015,34 +1084,39 @@ var Flexie = (function (win, doc) {
function dimensionValues (target, prop) {
var parent = target.parentNode,
- obj,
- dimension;
+ obj, dimension, i, j, rule;
if (parent.FLX_DOM_ID) {
obj = FLEX_BOXES[parent.FLX_DOM_ID];
- forEach(obj.properties, function (i, rule) {
+ for (i = 0, j = obj.properties.length; i < j; i++) {
+ rule = obj.properties[i];
+
if ((new RegExp(prop)).test(rule.property)) {
dimension = TRUE;
return FALSE;
}
- });
+ }
}
return dimension;
}
function updateChildValues (params) {
+ var i, j, x;
+
if (params.flexMatrix) {
- forEach(params.children, function (i, x) {
+ for (i = 0, j = params.children.length; i < j; i++) {
+ x = params.children[i];
x.flex = params.flexMatrix[i];
- });
+ }
}
if (params.ordinalMatrix) {
- forEach(params.children, function (i, x) {
+ for (i = 0, j = params.children.length; i < j; i++) {
+ x = params.children[i];
x["ordinal-group"] = params.ordinalMatrix[i];
- });
+ }
}
return params;
@@ -1117,13 +1191,15 @@ var Flexie = (function (win, doc) {
// creates one or more patches for each matched selector.
function patchStyleSheet(cssText) {
return cssText.replace(RE_SELECTOR_GROUP, function (m, prefix, selectorText) {
- var selectorGroups, selector;
+ var selectorGroups, selector,
+ i, j, group;
selectorGroups = selectorText.split(",");
- forEach(selectorGroups, function (i, group) {
+ for (i = 0, j = selectorGroups.length; i < j; i++) {
+ group = selectorGroups[i];
selector = normalizeSelectorWhitespace(group) + SPACE_STRING;
- });
+ }
return prefix + selectorGroups.join(",");
});
@@ -1279,7 +1355,8 @@ var Flexie = (function (win, doc) {
FLX.box.prototype = {
properties : {
boxModel : function (target, children, params) {
- var selectors, stylesheet, paddingFix, generatedRules;
+ var selectors, stylesheet, paddingFix, generatedRules,
+ i, j, selector;
target.style.display = "block";
@@ -1302,7 +1379,9 @@ var Flexie = (function (win, doc) {
"overflow: hidden"
].join(";");
- forEach(selectors, function (i, selector) {
+ for (i = 0, j = selectors.length; i < j; i++) {
+ selector = selectors[i];
+
if (stylesheet.addRule) {
if (BROWSER.IE < 8) {
target.style.zoom = "1";
@@ -1321,40 +1400,45 @@ var Flexie = (function (win, doc) {
stylesheet.insertRule(selector + "{" + paddingFix + "}", 0);
stylesheet.insertRule(selector + ":after{" + generatedRules + ";clear:both;}", 0);
}
- });
+ }
params.cleared = TRUE;
}
},
boxDirection : function (target, children, params) {
- var nestedSelector, nested;
+ var nestedSelector, nested,
+ i, j, kid, node;
if ((params.direction === "reverse" && !params.reversed) || (params.direction === "normal" && params.reversed)) {
children = children.reverse();
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
target.appendChild(kid);
- });
+ }
// box-direction is inheritable.
// We need to see if there are any nested flexbox elements
nestedSelector = LIBRARY(params.nested);
- forEach(nestedSelector, function (i, node) {
+ for (i = 0, j = nestedSelector.length; i < j; i++) {
+ node = nestedSelector[i];
+
nested = FLEX_BOXES[node.FLX_DOM_ID];
if (nested && nested.direction === INHERIT) {
nested.direction = params.direction;
}
- });
+ }
params.reversed = !params.reversed;
}
},
boxOrient : function (target, children, params) {
- var self = this, wide, high;
+ var self = this, wide, high,
+ i, j, kid;
wide = {
pos : "marginLeft",
@@ -1375,7 +1459,9 @@ var Flexie = (function (win, doc) {
};
if (!SUPPORT) {
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
kid.style[(BROWSER.IE >= 9) ? "cssFloat" : "styleFloat"] = LEFT;
if (params.orient === VERTICAL || params.orient === BLOCK_AXIS) {
@@ -1385,7 +1471,7 @@ var Flexie = (function (win, doc) {
if (BROWSER.IE === 6) {
kid.style.display = "inline";
}
- });
+ }
}
switch (params.orient) {
@@ -1411,15 +1497,21 @@ var Flexie = (function (win, doc) {
}
organizeChildren = function (matrix) {
- var keys = matrix.keys;
-
- forEach(params.reversed ? keys : keys.reverse(), function (i, key) {
- forEach(children, function (i, kid) {
+ var keys = matrix.keys,
+ iterator = params.reversed ? keys : keys.reverse(),
+ i, j, key, k, l, kid;
+
+ for (i = 0, j = iterator.length; i < j; i++) {
+ key = iterator[i];
+
+ for (k = 0, l = children.length; k < l; k++) {
+ kid = children[k];
+
if (key === kid.getAttribute("data-ordinal-group")) {
target.appendChild(kid);
}
- });
- });
+ }
+ }
};
matrix = createMatchMatrix(params.children, children, TRUE);
@@ -1446,47 +1538,60 @@ var Flexie = (function (win, doc) {
testForRestrictiveProperties = function (matrix) {
var flexers = matrix.groups,
keys = matrix.keys,
- max;
+ max, i, j, key,
+ k, l, x, m, n, rule;
- forEach(keys, function (i, key) {
- forEach(flexers[key], function (i, x) {
+ for (i = 0, j = keys.length; i < j; i++) {
+ key = keys[i];
+
+ for (k = 0, l = flexers[key].length; k < l; k++) {
+ x = flexers[key][k];
max = NULL;
- forEach(x.properties, function (i, rule) {
+ for (m = 0, n = x.properties.length; m < n; m++) {
+ rule = x.properties[m];
+
if ((RESTRICTIVE_PROPERTIES).test(rule.property)) {
max = parseFloat(rule.value);
}
- });
+ }
if (!max || x.match[self.props.out] > max) {
appendPixelValue(x.match, self.props.pos, NULL);
}
- });
- });
+ }
+ }
};
findTotalWhitespace = function (matrix) {
var groupDimension = 0,
whitespace,
- ration;
+ ration,
+ i, j, kid,
+ k, l, pad;
+
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
- forEach(children, function (i, kid) {
groupDimension += getComputedStyle(kid, self.props.dim, TRUE);
- forEach(self.props.pad, function (i, pad) {
+ for (k = 0, l = self.props.pad.length; k < l; k++) {
+ pad = self.props.pad[k];
+
groupDimension += getComputedStyle(kid, pad, TRUE);
- });
+ }
groupDimension += getComputedStyle(kid, self.props.pos, TRUE);
groupDimension += getComputedStyle(kid, self.props.opp, TRUE);
- });
+ }
whitespace = target[self.props.out] - groupDimension;
- forEach(self.props.pad, function (i, pad) {
+ for (i = 0, j = self.props.pad.length; i < j; i++) {
+ pad = self.props.pad[i];
whitespace -= getComputedStyle(target, pad, TRUE);
- });
+ }
ration = (whitespace / matrix.total);
@@ -1499,17 +1604,18 @@ var Flexie = (function (win, doc) {
distributeRatio = function (matrix, whitespace) {
var flexers = matrix.groups,
keys = matrix.keys,
- flex,
- specificity,
+ flex, specificity,
ration = whitespace.ration,
- widthRation,
- trueDim,
- newDimension;
+ widthRation, trueDim, newDimension,
+ i, j, key, k, l, x;
- forEach(keys, function (i, key) {
+ for (i = 0, j = keys.length; i < j; i++) {
+ key = keys[i];
widthRation = (ration * key);
- forEach(flexers[key], function (i, x) {
+ for (k = 0, l = flexers[key].length; k < l; k++) {
+ x = flexers[key][k];
+
if (x.match) {
flex = x.match.getAttribute("data-flex");
specificity = x.match.getAttribute("data-specificity");
@@ -1523,8 +1629,8 @@ var Flexie = (function (win, doc) {
appendPixelValue(x.match, self.props.dim, newDimension);
}
}
- });
- });
+ }
+ }
};
matrix = createMatchMatrix(params.children, children, NULL);
@@ -1544,7 +1650,8 @@ var Flexie = (function (win, doc) {
var self = this,
targetDimension,
kidDimension,
- flexCheck = parentFlex(target);
+ flexCheck = parentFlex(target),
+ i, j, pad, k, l, kid;
if (!SUPPORT && !flexCheck.flex && (params.orient === VERTICAL || params.orient === BLOCK_AXIS)) {
if (!dimensionValues(target, self.anti.dim)) {
@@ -1555,31 +1662,39 @@ var Flexie = (function (win, doc) {
// Remove padding / border from target dimension
targetDimension = target[self.anti.out];
- forEach(self.anti.pad, function (i, pad) {
+
+ for (i = 0, j = self.anti.pad.length; i < j; i++) {
+ pad = self.anti.pad[i];
targetDimension -= getComputedStyle(target, pad, TRUE);
- });
+ }
switch (params.align) {
case "start" :
break;
case "end" :
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
kidDimension = targetDimension - kid[self.anti.out];
kidDimension -= getComputedStyle(kid, self.anti.opp, TRUE);
appendPixelValue(kid, self.anti.pos, kidDimension);
- });
+ }
break;
case "center" :
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
kidDimension = (targetDimension - kid[self.anti.out]) / 2;
appendPixelValue(kid, self.anti.pos, kidDimension);
- });
+ }
break;
default :
- forEach(children, function (i, kid) {
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
+
switch (kid.nodeName.toLowerCase()) {
case "button" :
case "input" :
@@ -1589,10 +1704,12 @@ var Flexie = (function (win, doc) {
default :
var subtract = 0;
- forEach(self.anti.pad, function (i, pad) {
+ for (k = 0, l = self.anti.pad.length; k < l; k++) {
+ pad = self.anti.pad[k];
+
subtract += getComputedStyle(kid, pad, TRUE);
subtract += getComputedStyle(target, pad, TRUE);
- });
+ }
kid.style[self.anti.dim] = "100%";
kidDimension = kid[self.anti.out] - subtract;
@@ -1601,9 +1718,11 @@ var Flexie = (function (win, doc) {
kidDimension = targetDimension;
kidDimension -= getComputedStyle(kid, self.anti.pos, TRUE);
- forEach(self.anti.pad, function (i, pad) {
+ for (k = 0, l = self.anti.pad.length; k < l; k++) {
+ pad = self.anti.pad[k];
+
kidDimension -= getComputedStyle(kid, pad, TRUE);
- });
+ }
kidDimension -= getComputedStyle(kid, self.anti.opp, TRUE);
kidDimension = Math.max(0, kidDimension);
@@ -1611,7 +1730,7 @@ var Flexie = (function (win, doc) {
appendPixelValue(kid, self.anti.dim, kidDimension);
break;
}
- });
+ }
break;
}
},
@@ -1626,21 +1745,24 @@ var Flexie = (function (win, doc) {
currentDimension,
remainder,
length = children.length - 1,
- kid;
+ kid, i, j, value, pad;
+
+ for (i = 0, j = children.length; i < j; i++) {
+ kid = children[i];
- forEach(children, function (i, kid) {
groupDimension += kid[self.props.out];
groupDimension += getComputedStyle(kid, self.props.pos, TRUE);
groupDimension += getComputedStyle(kid, self.props.opp, TRUE);
- });
+ }
firstComputedMargin = getComputedStyle(children[0], self.props.pos, TRUE);
totalDimension = target[self.props.out] - groupDimension;
// Remove padding / border from target dimension
- forEach(self.props.pad, function (i, pad) {
+ for (i = 0, j = self.props.pad.length; i < j; i++) {
+ pad = self.props.pad[i];
totalDimension -= getComputedStyle(target, pad, TRUE);
- });
+ }
// If totalDimension is less than 0, we have a problem...
if (totalDimension < 0) {
@@ -1664,8 +1786,7 @@ var Flexie = (function (win, doc) {
fractionedDimension = Math.floor((targetPadding + totalDimension) / length);
remainder = (fractionedDimension * length) - totalDimension;
- var i = children.length - 1,
- value;
+ i = children.length - 1;
while (i) {
kid = children[i];
@@ -1690,7 +1811,8 @@ var Flexie = (function (win, doc) {
},
setup : function (target, children, params) {
- var self = this, matrix, flexCheck;
+ var self = this, matrix, flexCheck,
+ key, func;
if (!target || !children || !params) {
return;
@@ -1713,9 +1835,12 @@ var Flexie = (function (win, doc) {
}
}
} else if (!SUPPORT) {
- forEach(self.properties, function (key, func) {
- func.call(self, target, sanitizeChildren(target, target.childNodes), params);
- });
+ for (key in self.properties) {
+ if (self.properties.hasOwnProperty(key)) {
+ func = self.properties[key];
+ func.call(self, target, sanitizeChildren(target, target.childNodes), params);
+ }
+ }
}
},
@@ -1781,7 +1906,7 @@ var Flexie = (function (win, doc) {
};
FLX.updateInstance = function (target, params) {
- var box;
+ var box, key;
if (target) {
box = FLEX_BOXES[target.FLX_DOM_ID];
@@ -1792,9 +1917,12 @@ var Flexie = (function (win, doc) {
box = new FLX.box(params);
}
} else {
- forEach(FLEX_BOXES, function (i, box) {
- box._instance.updateModel(box);
- });
+ for (key in FLEX_BOXES) {
+ if (FLEX_BOXES.hasOwnProperty(key)) {
+ box = FLEX_BOXES[key];
+ box._instance.updateModel(box);
+ }
+ }
}
};
@@ -1803,16 +1931,16 @@ var Flexie = (function (win, doc) {
};
FLX.destroyInstance = function (target) {
- var box,
- destroy;
+ var box, destroy, i, j, x, key;
destroy = function (box) {
box.target.FLX_DOM_ID = NULL;
box.target.style.cssText = EMPTY_STRING;
- forEach(box.children, function (i, x) {
+ for (i = 0, j = box.children.length; i < j; i++) {
+ x = box.children[i];
x.match.style.cssText = EMPTY_STRING;
- });
+ }
};
if (target) {
@@ -1822,9 +1950,11 @@ var Flexie = (function (win, doc) {
destroy(box);
}
} else {
- forEach(FLEX_BOXES, function (i, box) {
- destroy(box);
- });
+ for (key in FLEX_BOXES) {
+ if (FLEX_BOXES.hasOwnProperty(key)) {
+ destroy(FLEX_BOXES[key]);
+ }
+ }
FLEX_BOXES = [];
}
@@ -1836,8 +1966,7 @@ var Flexie = (function (win, doc) {
childHeight,
dummy = doc.createElement("flxbox"),
child = '<b style="margin: 0; padding: 0; display:block; width: 10px; height:' + (height / 2) + 'px"></b>',
- tests,
- result;
+ tests, result, key, value;
dummy.style.width = dummy.style.height = height + "px";
dummy.innerHTML = (child + child + child);
@@ -1855,25 +1984,30 @@ var Flexie = (function (win, doc) {
},
boxPackJustify : function () {
- var totalOffset = 0;
+ var totalOffset = 0,
+ i, j;
- forEach(dummy.childNodes, function (i, child) {
- totalOffset += child.offsetLeft;
- });
+ for (i = 0, j = dummy.childNodes.length; i < j; i++) {
+ totalOffset += dummy.childNodes[i].offsetLeft;
+ }
return (totalOffset === 135);
}
};
- forEach(tests, function (key, value) {
- result = value();
-
- if (!result) {
- partialSupportGrid.partialSupport = TRUE;
+ for (key in tests) {
+ if (tests.hasOwnProperty(key)) {
+ value = tests[key];
+
+ result = value();
+
+ if (!result) {
+ partialSupportGrid.partialSupport = TRUE;
+ }
+
+ partialSupportGrid[key] = result;
}
-
- partialSupportGrid[key] = result;
- });
+ }
doc.body.removeChild(dummy);
return ~ (dummy.style.display).indexOf("box") ? partialSupportGrid : FALSE;
Please sign in to comment.
Something went wrong with that request. Please try again.