Commit c3cb63b6 authored by XhmikosR's avatar XhmikosR
Browse files

Update holder.js to v2.3.1.

Fix #12653.
parent 8f7170ab
Showing with 234 additions and 86 deletions
+234 -86
/*! /*!
Holder - 2.2 - client side image placeholders Holder - 2.3.1 - client side image placeholders
(c) 2012-2013 Ivan Malopinsky / http://imsky.co (c) 2012-2014 Ivan Malopinsky / http://imsky.co
Provided under the MIT License. Provided under the MIT License.
Commercial use requires attribution. Commercial use requires attribution.
*/ */
var Holder=Holder||{};!function(a,b){function c(a,b){var c="complete",d="readystatechange",e=!1,f=e,g=!0,h=a.document,i=h.documentElement,j=h.addEventListener?"addEventListener":"attachEvent",k=h.addEventListener?"removeEventListener":"detachEvent",l=h.addEventListener?"":"on",m=function(g){(g.type!=d||h.readyState==c)&&(("load"==g.type?a:h)[k](l+g.type,m,e),!f&&(f=!0)&&b.call(a,null))},n=function(){try{i.doScroll("left")}catch(a){return void setTimeout(n,50)}m("poll")};if(h.readyState==c)b.call(a,"lazy");else{if(h.createEventObject&&i.doScroll){try{g=!a.frameElement}catch(o){}g&&n()}h[j](l+"DOMContentLoaded",m,e),h[j](l+d,m,e),a[j](l+"load",m,e)}}function d(a){a=a.match(/^(\W)?(.*)/);var b=document["getElement"+(a[1]?"#"==a[1]?"ById":"sByClassName":"sByTagName")](a[2]),c=[];return null!==b&&(c=b.length?b:0===b.length?b:[b]),c}function e(a,b){var c={};for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);return c}function f(a,b,c){b=parseInt(b,10),a=parseInt(a,10);var d=Math.max(b,a),e=Math.min(b,a),f=1/12,g=Math.min(.75*e,.75*d*f);return{height:Math.round(Math.max(c.size,g))}}function g(a){var b=a.ctx,c=a.dimensions,d=a.template,e=a.ratio,g=a.holder,h="literal"==g.textmode,i="exact"==g.textmode,j=f(c.width,c.height,d),k=j.height,l=c.width*e,m=c.height*e,n=d.font?d.font:"sans-serif";o.width=l,o.height=m,b.textAlign="center",b.textBaseline="middle",b.fillStyle=d.background,b.fillRect(0,0,l,m),b.fillStyle=d.foreground,b.font="bold "+k+"px "+n;var p=d.text?d.text:Math.floor(c.width)+"x"+Math.floor(c.height);if(h){var c=g.dimensions;p=c.width+"x"+c.height}else if(i&&g.exact_dimensions){var c=g.exact_dimensions;p=Math.floor(c.width)+"x"+Math.floor(c.height)}var q=b.measureText(p).width;return q/l>=.75&&(k=Math.floor(.75*k*(l/q))),b.font="bold "+k*e+"px "+n,b.fillText(p,l/2,m/2,l),o.toDataURL("image/png")}function h(a,b,c,d){var f=c.dimensions,h=c.theme,i=c.text?decodeURIComponent(c.text):c.text,j=f.width+"x"+f.height;h=i?e(h,{text:i}):h,h=c.font?e(h,{font:c.font}):h,b.setAttribute("data-src",d),c.theme=h,b.holder_data=c,"image"==a?(b.setAttribute("alt",i?i:h.text?h.text+" ["+j+"]":j),(n||!c.auto)&&(b.style.width=f.width+"px",b.style.height=f.height+"px"),n?b.style.backgroundColor=h.background:(b.setAttribute("src",g({ctx:s,dimensions:f,template:h,ratio:t,holder:c})),c.textmode&&"exact"==c.textmode&&(r.push(b),k(b)))):"background"==a?n||(b.style.backgroundImage="url("+g({ctx:s,dimensions:f,template:h,ratio:t,holder:c})+")",b.style.backgroundSize=f.width+"px "+f.height+"px"):"fluid"==a&&(b.setAttribute("alt",i?i:h.text?h.text+" ["+j+"]":j),b.style.height="%"==f.height.slice(-1)?f.height:f.height+"px",b.style.width="%"==f.width.slice(-1)?f.width:f.width+"px",("inline"==b.style.display||""===b.style.display||"none"==b.style.display)&&(b.style.display="block"),n?b.style.backgroundColor=h.background:(r.push(b),k(b)))}function i(a,b){var c={height:a.clientHeight,width:a.clientWidth};if(!c.height&&!c.width){if(a.hasAttribute("data-holder-invisible"))throw new Error("Holder: placeholder is not visible");return a.setAttribute("data-holder-invisible",!0),setTimeout(function(){b.call(this,a)},1),null}return a.removeAttribute("data-holder-invisible"),c}function k(a){var b;b=null==a.nodeType?r:[a];for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];if(d.holder_data){var e=d.holder_data,f=i(d,k);f&&(e.fluid&&d.setAttribute("src",g({ctx:s,dimensions:f,template:e.theme,ratio:t,holder:e})),e.textmode&&"exact"==e.textmode&&(e.exact_dimensions=f,d.setAttribute("src",g({ctx:s,dimensions:e.dimensions,template:e.theme,ratio:t,holder:e}))))}}}function l(b,c){var d={theme:e(u.themes.gray,{})},f=!1;for(sl=b.length,j=0;sl>j;j++){var g=b[j];a.flags.dimensions.match(g)?(f=!0,d.dimensions=a.flags.dimensions.output(g)):a.flags.fluid.match(g)?(f=!0,d.dimensions=a.flags.fluid.output(g),d.fluid=!0):a.flags.textmode.match(g)?d.textmode=a.flags.textmode.output(g):a.flags.colors.match(g)?d.theme=a.flags.colors.output(g):c.themes[g]?c.themes.hasOwnProperty(g)&&(d.theme=e(c.themes[g],{})):a.flags.font.match(g)?d.font=a.flags.font.output(g):a.flags.auto.match(g)?d.auto=!0:a.flags.text.match(g)&&(d.text=a.flags.text.output(g))}return f?d:!1}var m=!1,n=!1,o=document.createElement("canvas"),p=1,q=1,r=[];if(o.getContext)if(o.toDataURL("image/png").indexOf("data:image/png")<0)n=!0;else var s=o.getContext("2d");else n=!0;n||(p=window.devicePixelRatio||1,q=s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1);var t=p/q,u={domain:"holder.js",images:"img",bgnodes:".holderjs",themes:{gray:{background:"#eee",foreground:"#aaa",size:12},social:{background:"#3a5a97",foreground:"#fff",size:12},industrial:{background:"#434A52",foreground:"#C2F200",size:12},sky:{background:"#0D8FDB",foreground:"#fff",size:12},vine:{background:"#39DBAC",foreground:"#1E292C",size:12},lava:{background:"#F8591A",foreground:"#1C2846",size:12}},stylesheet:""};a.flags={dimensions:{regex:/^(\d+)x(\d+)$/,output:function(a){var b=this.regex.exec(a);return{width:+b[1],height:+b[2]}}},fluid:{regex:/^([0-9%]+)x([0-9%]+)$/,output:function(a){var b=this.regex.exec(a);return{width:b[1],height:b[2]}}},colors:{regex:/#([0-9a-f]{3,})\:#([0-9a-f]{3,})/i,output:function(a){var b=this.regex.exec(a);return{size:u.themes.gray.size,foreground:"#"+b[2],background:"#"+b[1]}}},text:{regex:/text\:(.*)/,output:function(a){return this.regex.exec(a)[1]}},font:{regex:/font\:(.*)/,output:function(a){return this.regex.exec(a)[1]}},auto:{regex:/^auto$/},textmode:{regex:/textmode\:(.*)/,output:function(a){return this.regex.exec(a)[1]}}},document.getElementsByClassName||(document.getElementsByClassName=function(a){var b,c,d,e=document,f=[];if(e.querySelectorAll)return e.querySelectorAll("."+a);if(e.evaluate)for(c=".//*[contains(concat(' ', @class, ' '), ' "+a+" ')]",b=e.evaluate(c,e,null,0,null);d=b.iterateNext();)f.push(d);else for(b=e.getElementsByTagName("*"),c=new RegExp("(^|\\s)"+a+"(\\s|$)"),d=0;d<b.length;d++)c.test(b[d].className)&&f.push(b[d]);return f}),window.getComputedStyle||(window.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"==b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this}),Object.prototype.hasOwnProperty||(Object.prototype.hasOwnProperty=function(a){var b=this.__proto__||this.constructor.prototype;return a in this&&(!(a in b)||b[a]!==this[a])});for(var v in a.flags)a.flags.hasOwnProperty(v)&&(a.flags[v].match=function(a){return a.match(this.regex)});a.add_theme=function(b,c){return null!=b&&null!=c&&(u.themes[b]=c),a},a.add_image=function(b,c){var e=d(c);if(e.length)for(var f=0,g=e.length;g>f;f++){var h=document.createElement("img");h.setAttribute("data-src",b),e[f].appendChild(h)}return a},a.run=function(b){m=!0;var c=e(u,b),f=[],g=[],i=[];for("string"==typeof c.images?g=d(c.images):window.NodeList&&c.images instanceof window.NodeList?g=c.images:window.Node&&c.images instanceof window.Node&&(g=[c.images]),"string"==typeof c.bgnodes?i=d(c.bgnodes):window.NodeList&&c.elements instanceof window.NodeList?i=c.bgnodes:window.Node&&c.bgnodes instanceof window.Node&&(i=[c.bgnodes]),o=0,n=g.length;n>o;o++)f.push(g[o]);var j=document.getElementById("holderjs-style");j||(j=document.createElement("style"),j.setAttribute("id","holderjs-style"),j.type="text/css",document.getElementsByTagName("head")[0].appendChild(j)),c.nocss||(j.styleSheet?j.styleSheet.cssText+=c.stylesheet:j.appendChild(document.createTextNode(c.stylesheet)));for(var k=new RegExp(c.domain+'/(.*?)"?\\)'),n=i.length,o=0;n>o;o++){var p=window.getComputedStyle(i[o],null).getPropertyValue("background-image"),q=p.match(k),r=i[o].getAttribute("data-background-src");if(q){var s=l(q[1].split("/"),c);s&&h("background",i[o],s,p)}else if(null!=r){var s=l(r.substr(r.lastIndexOf(c.domain)+c.domain.length+1).split("/"),c);s&&h("background",i[o],s,p)}}for(n=f.length,o=0;n>o;o++){var t,v;v=t=p=null;try{v=f[o].getAttribute("src"),attr_datasrc=f[o].getAttribute("data-src")}catch(w){}if(null==attr_datasrc&&v&&v.indexOf(c.domain)>=0?p=v:attr_datasrc&&attr_datasrc.indexOf(c.domain)>=0&&(p=attr_datasrc),p){var s=l(p.substr(p.lastIndexOf(c.domain)+c.domain.length+1).split("/"),c);s&&(s.fluid?h("fluid",f[o],s,p):h("image",f[o],s,p))}}return a},c(b,function(){window.addEventListener?(window.addEventListener("resize",k,!1),window.addEventListener("orientationchange",k,!1)):window.attachEvent("onresize",k),m||a.run()}),"function"==typeof define&&define.amd&&define([],function(){return a})}(Holder,window),/*! var Holder=Holder||{};!function(a,b){function c(a,b,c){b=parseInt(b,10),a=parseInt(a,10);var d=Math.max(b,a),e=Math.min(b,a),f=1/12,g=Math.min(.75*e,.75*d*f);return{height:Math.round(Math.max(c.size,g))}}function d(a){var b=[];for(p in a)a.hasOwnProperty(p)&&b.push(p+":"+a[p]);return b.join(";")}function e(a){var b=a.ctx,d=a.dimensions,e=a.template,f=a.ratio,g=a.holder,h="literal"==g.textmode,i="exact"==g.textmode,j=c(d.width,d.height,e),k=j.height,l=d.width*f,m=d.height*f,n=e.font?e.font:"Arial,Helvetica,sans-serif";canvas.width=l,canvas.height=m,b.textAlign="center",b.textBaseline="middle",b.fillStyle=e.background,b.fillRect(0,0,l,m),b.fillStyle=e.foreground,b.font="bold "+k+"px "+n;var o=e.text?e.text:Math.floor(d.width)+"x"+Math.floor(d.height);if(h){var d=g.dimensions;o=d.width+"x"+d.height}else if(i&&g.exact_dimensions){var d=g.exact_dimensions;o=Math.floor(d.width)+"x"+Math.floor(d.height)}var p=b.measureText(o).width;return p/l>=.75&&(k=Math.floor(.75*k*(l/p))),b.font="bold "+k*f+"px "+n,b.fillText(o,l/2,m/2,l),canvas.toDataURL("image/png")}function f(a){var b=a.dimensions,d=a.template,e=a.holder,f="literal"==e.textmode,g="exact"==e.textmode,h=c(b.width,b.height,d),i=h.height,j=b.width,k=b.height,l=d.font?d.font:"Arial,Helvetica,sans-serif",m=d.text?d.text:Math.floor(b.width)+"x"+Math.floor(b.height);if(f){var b=e.dimensions;m=b.width+"x"+b.height}else if(g&&e.exact_dimensions){var b=e.exact_dimensions;m=Math.floor(b.width)+"x"+Math.floor(b.height)}var n=z({text:m,width:j,height:k,text_height:i,font:l,template:d});return"data:image/svg+xml;base64,"+btoa(n)}function g(a){return r.use_canvas&&!r.use_svg?e(a):f(a)}function h(a,b,c,d){var e=c.dimensions,f=c.theme,h=c.text?decodeURIComponent(c.text):c.text,i=e.width+"x"+e.height;f=h?o(f,{text:h}):f,f=c.font?o(f,{font:c.font}):f,b.setAttribute("data-src",d),c.theme=f,b.holder_data=c,"image"==a?(b.setAttribute("alt",h?h:f.text?f.text+" ["+i+"]":i),(r.use_fallback||!c.auto)&&(b.style.width=e.width+"px",b.style.height=e.height+"px"),r.use_fallback?b.style.backgroundColor=f.background:(b.setAttribute("src",g({ctx:w,dimensions:e,template:f,ratio:x,holder:c})),c.textmode&&"exact"==c.textmode&&(v.push(b),k(b)))):"background"==a?r.use_fallback||(b.style.backgroundImage="url("+g({ctx:w,dimensions:e,template:f,ratio:x,holder:c})+")",b.style.backgroundSize=e.width+"px "+e.height+"px"):"fluid"==a&&(b.setAttribute("alt",h?h:f.text?f.text+" ["+i+"]":i),"%"==e.height.slice(-1)?b.style.height=e.height:null!=c.auto&&c.auto||(b.style.height=e.height+"px"),"%"==e.width.slice(-1)?b.style.width=e.width:null!=c.auto&&c.auto||(b.style.width=e.width+"px"),("inline"==b.style.display||""===b.style.display||"none"==b.style.display)&&(b.style.display="block"),j(b),r.use_fallback?b.style.backgroundColor=f.background:(v.push(b),k(b)))}function i(a,b){var c={height:a.clientHeight,width:a.clientWidth};return c.height||c.width?(a.removeAttribute("data-holder-invisible"),c):(a.setAttribute("data-holder-invisible",!0),void b.call(this,a))}function j(b){if(b.holder_data){var c=i(b,a.invisible_error_fn(j));if(c){var d=b.holder_data;d.initial_dimensions=c,d.fluid_data={fluid_height:"%"==d.dimensions.height.slice(-1),fluid_width:"%"==d.dimensions.width.slice(-1),mode:null},d.fluid_data.fluid_width&&!d.fluid_data.fluid_height?(d.fluid_data.mode="width",d.fluid_data.ratio=d.initial_dimensions.width/parseFloat(d.dimensions.height)):!d.fluid_data.fluid_width&&d.fluid_data.fluid_height&&(d.fluid_data.mode="height",d.fluid_data.ratio=parseFloat(d.dimensions.width)/d.initial_dimensions.height)}}}function k(b){var c;c=null==b.nodeType?v:[b];for(var d in c)if(c.hasOwnProperty(d)){var e=c[d];if(e.holder_data){var f=e.holder_data,h=i(e,a.invisible_error_fn(k));if(h){if(f.fluid){if(f.auto)switch(f.fluid_data.mode){case"width":h.height=h.width/f.fluid_data.ratio;break;case"height":h.width=h.height*f.fluid_data.ratio}e.setAttribute("src",g({ctx:w,dimensions:h,template:f.theme,ratio:x,holder:f}))}f.textmode&&"exact"==f.textmode&&(f.exact_dimensions=h,e.setAttribute("src",g({ctx:w,dimensions:f.dimensions,template:f.theme,ratio:x,holder:f})))}}}}function l(b,c){for(var d={theme:o(y.themes.gray,{})},e=!1,f=b.length,g=0;f>g;g++){var h=b[g];a.flags.dimensions.match(h)?(e=!0,d.dimensions=a.flags.dimensions.output(h)):a.flags.fluid.match(h)?(e=!0,d.dimensions=a.flags.fluid.output(h),d.fluid=!0):a.flags.textmode.match(h)?d.textmode=a.flags.textmode.output(h):a.flags.colors.match(h)?d.theme=a.flags.colors.output(h):c.themes[h]?c.themes.hasOwnProperty(h)&&(d.theme=o(c.themes[h],{})):a.flags.font.match(h)?d.font=a.flags.font.output(h):a.flags.auto.match(h)?d.auto=!0:a.flags.text.match(h)&&(d.text=a.flags.text.output(h))}return e?d:!1}function m(a,b){var c="complete",d="readystatechange",e=!1,f=e,g=!0,h=a.document,i=h.documentElement,j=h.addEventListener?"addEventListener":"attachEvent",k=h.addEventListener?"removeEventListener":"detachEvent",l=h.addEventListener?"":"on",m=function(g){(g.type!=d||h.readyState==c)&&(("load"==g.type?a:h)[k](l+g.type,m,e),!f&&(f=!0)&&b.call(a,null))},n=function(){try{i.doScroll("left")}catch(a){return void setTimeout(n,50)}m("poll")};if(h.readyState==c)b.call(a,"lazy");else{if(h.createEventObject&&i.doScroll){try{g=!a.frameElement}catch(o){}g&&n()}h[j](l+"DOMContentLoaded",m,e),h[j](l+d,m,e),a[j](l+"load",m,e)}}function n(a,b){var a=a.match(/^(\W)?(.*)/),b=b||document,c=b["getElement"+(a[1]?"#"==a[1]?"ById":"sByClassName":"sByTagName")],d=c.call(b,a[2]),e=[];return null!==d&&(e=d.length||0===d.length?d:[d]),e}function o(a,b){var c={};for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);return c}var q={use_svg:!1,use_canvas:!1,use_fallback:!1},r={},s=!1;canvas=document.createElement("canvas");var t=1,u=1,v=[];if(canvas.getContext)if(canvas.toDataURL("image/png").indexOf("data:image/png")<0)q.use_fallback=!0;else var w=canvas.getContext("2d");else q.use_fallback=!0;document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect&&(q.use_svg=!0,q.use_canvas=!1),q.use_fallback||(t=window.devicePixelRatio||1,u=w.webkitBackingStorePixelRatio||w.mozBackingStorePixelRatio||w.msBackingStorePixelRatio||w.oBackingStorePixelRatio||w.backingStorePixelRatio||1);var x=t/u,y={domain:"holder.js",images:"img",bgnodes:".holderjs",themes:{gray:{background:"#eee",foreground:"#aaa",size:12},social:{background:"#3a5a97",foreground:"#fff",size:12},industrial:{background:"#434A52",foreground:"#C2F200",size:12},sky:{background:"#0D8FDB",foreground:"#fff",size:12},vine:{background:"#39DBAC",foreground:"#1E292C",size:12},lava:{background:"#F8591A",foreground:"#1C2846",size:12}},stylesheet:""};a.flags={dimensions:{regex:/^(\d+)x(\d+)$/,output:function(a){var b=this.regex.exec(a);return{width:+b[1],height:+b[2]}}},fluid:{regex:/^([0-9%]+)x([0-9%]+)$/,output:function(a){var b=this.regex.exec(a);return{width:b[1],height:b[2]}}},colors:{regex:/#([0-9a-f]{3,})\:#([0-9a-f]{3,})/i,output:function(a){var b=this.regex.exec(a);return{size:y.themes.gray.size,foreground:"#"+b[2],background:"#"+b[1]}}},text:{regex:/text\:(.*)/,output:function(a){return this.regex.exec(a)[1]}},font:{regex:/font\:(.*)/,output:function(a){return this.regex.exec(a)[1]}},auto:{regex:/^auto$/},textmode:{regex:/textmode\:(.*)/,output:function(a){return this.regex.exec(a)[1]}}};var z=function(){if(window.XMLSerializer){var a=new XMLSerializer,b="http://www.w3.org/2000/svg",c=document.createElementNS(b,"svg");c.webkitMatchesSelector&&c.setAttribute("xmlns","http://www.w3.org/2000/svg");var e=document.createElementNS(b,"rect"),f=document.createElementNS(b,"text"),g=document.createTextNode(null);return f.setAttribute("text-anchor","middle"),f.appendChild(g),c.appendChild(e),c.appendChild(f),function(b){return c.setAttribute("width",b.width),c.setAttribute("height",b.height),e.setAttribute("width",b.width),e.setAttribute("height",b.height),e.setAttribute("fill",b.template.background),f.setAttribute("x",b.width/2),f.setAttribute("y",b.height/2),g.nodeValue=b.text,f.setAttribute("style",d({fill:b.template.foreground,"font-weight":"bold","font-size":b.text_height+"px","font-family":b.font,"dominant-baseline":"central"})),a.serializeToString(c)}}}();for(var A in a.flags)a.flags.hasOwnProperty(A)&&(a.flags[A].match=function(a){return a.match(this.regex)});a.invisible_error_fn=function(){return function(a){if(a.hasAttribute("data-holder-invisible"))throw new Error("Holder: invisible placeholder")}},a.add_theme=function(b,c){return null!=b&&null!=c&&(y.themes[b]=c),a},a.add_image=function(b,c){var d=n(c);if(d.length)for(var e=0,f=d.length;f>e;e++){var g=document.createElement("img");g.setAttribute("data-src",b),d[e].appendChild(g)}return a},a.run=function(b){r=o({},q),s=!0;var c=o(y,b),d=[],e=[],f=[];for(null!=c.use_canvas&&c.use_canvas&&(r.use_canvas=!0,r.use_svg=!1),"string"==typeof c.images?e=n(c.images):window.NodeList&&c.images instanceof window.NodeList?e=c.images:window.Node&&c.images instanceof window.Node?e=[c.images]:window.HTMLCollection&&c.images instanceof window.HTMLCollection&&(e=c.images),"string"==typeof c.bgnodes?f=n(c.bgnodes):window.NodeList&&c.elements instanceof window.NodeList?f=c.bgnodes:window.Node&&c.bgnodes instanceof window.Node&&(f=[c.bgnodes]),k=0,j=e.length;j>k;k++)d.push(e[k]);var g=document.getElementById("holderjs-style");g||(g=document.createElement("style"),g.setAttribute("id","holderjs-style"),g.type="text/css",document.getElementsByTagName("head")[0].appendChild(g)),c.nocss||(g.styleSheet?g.styleSheet.cssText+=c.stylesheet:g.appendChild(document.createTextNode(c.stylesheet)));for(var i=new RegExp(c.domain+'/(.*?)"?\\)'),j=f.length,k=0;j>k;k++){var m=window.getComputedStyle(f[k],null).getPropertyValue("background-image"),p=m.match(i),t=f[k].getAttribute("data-background-src");if(p){var u=l(p[1].split("/"),c);u&&h("background",f[k],u,m)}else if(null!=t){var u=l(t.substr(t.lastIndexOf(c.domain)+c.domain.length+1).split("/"),c);u&&h("background",f[k],u,m)}}for(j=d.length,k=0;j>k;k++){var v,w;w=v=m=null;try{w=d[k].getAttribute("src"),attr_datasrc=d[k].getAttribute("data-src")}catch(x){}if(null==attr_datasrc&&w&&w.indexOf(c.domain)>=0?m=w:attr_datasrc&&attr_datasrc.indexOf(c.domain)>=0&&(m=attr_datasrc),m){var u=l(m.substr(m.lastIndexOf(c.domain)+c.domain.length+1).split("/"),c);u&&(u.fluid?h("fluid",d[k],u,m):h("image",d[k],u,m))}}return a},m(b,function(){window.addEventListener?(window.addEventListener("resize",k,!1),window.addEventListener("orientationchange",k,!1)):window.attachEvent("onresize",k),s||a.run({})}),"function"==typeof define&&define.amd&&define([],function(){return a}),function(){function a(a){this.message=a}var b="undefined"!=typeof exports?exports:this,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a.prototype=Error(),a.prototype.name="InvalidCharacterError",b.btoa||(b.btoa=function(b){for(var d,e,f=0,g=c,h="";b.charAt(0|f)||(g="=",f%1);h+=g.charAt(63&d>>8-8*(f%1))){if(e=b.charCodeAt(f+=.75),e>255)throw new a("'btoa' failed");d=d<<8|e}return h}),b.atob||(b.atob=function(b){if(b=b.replace(/=+$/,""),1==b.length%4)throw new a("'atob' failed");for(var d,e,f=0,g=0,h="";e=b.charAt(g++);~e&&(d=f%4?64*d+e:e,f++%4)?h+=String.fromCharCode(255&d>>(6&-2*f)):0)e=c.indexOf(e);return h})}(),document.getElementsByClassName||(document.getElementsByClassName=function(a){var b,c,d,e=document,f=[];if(e.querySelectorAll)return e.querySelectorAll("."+a);if(e.evaluate)for(c=".//*[contains(concat(' ', @class, ' '), ' "+a+" ')]",b=e.evaluate(c,e,null,0,null);d=b.iterateNext();)f.push(d);else for(b=e.getElementsByTagName("*"),c=new RegExp("(^|\\s)"+a+"(\\s|$)"),d=0;d<b.length;d++)c.test(b[d].className)&&f.push(b[d]);return f}),window.getComputedStyle||(window.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"==b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this}),Object.prototype.hasOwnProperty||(Object.prototype.hasOwnProperty=function(a){var b=this.__proto__||this.constructor.prototype;return a in this&&(!(a in b)||b[a]!==this[a])})}(Holder,window),/*!
* JavaScript for Bootstrap's docs (http://getbootstrap.com) * JavaScript for Bootstrap's docs (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc. * Copyright 2011-2014 Twitter, Inc.
* Licensed under the Creative Commons Attribution 3.0 Unported License. For * Licensed under the Creative Commons Attribution 3.0 Unported License. For
......
/*! /*!
Holder - 2.2 - client side image placeholders Holder - 2.3.1 - client side image placeholders
(c) 2012-2013 Ivan Malopinsky / http://imsky.co (c) 2012-2014 Ivan Malopinsky / http://imsky.co
Provided under the MIT License. Provided under the MIT License.
Commercial use requires attribution. Commercial use requires attribution.
*/ */
var Holder = Holder || {}; var Holder = Holder || {};
(function (app, win) { (function (app, win) {
var system_config = {
var preempted = false, use_svg: false,
fallback = false, use_canvas: false,
use_fallback: false
};
var instance_config = {};
var preempted = false;
canvas = document.createElement('canvas'); canvas = document.createElement('canvas');
var dpr = 1, bsr = 1; var dpr = 1, bsr = 1;
var resizable_images = []; var resizable_images = [];
if (!canvas.getContext) { if (!canvas.getContext) {
fallback = true; system_config.use_fallback = true;
} else { } else {
if (canvas.toDataURL("image/png") if (canvas.toDataURL("image/png")
.indexOf("data:image/png") < 0) { .indexOf("data:image/png") < 0) {
//Android doesn't support data URI //Android doesn't support data URI
fallback = true; system_config.use_fallback = true;
} else { } else {
var ctx = canvas.getContext("2d"); var ctx = canvas.getContext("2d");
} }
} }
if(!fallback){ if(!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect){
system_config.use_svg = true;
system_config.use_canvas = false;
}
if(!system_config.use_fallback){
dpr = window.devicePixelRatio || 1, dpr = window.devicePixelRatio || 1,
bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1; bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
} }
...@@ -129,46 +137,6 @@ app.flags = { ...@@ -129,46 +137,6 @@ app.flags = {
} }
} }
//getElementsByClassName polyfill
document.getElementsByClassName||(document.getElementsByClassName=function(e){var t=document,n,r,i,s=[];if(t.querySelectorAll)return t.querySelectorAll("."+e);if(t.evaluate){r=".//*[contains(concat(' ', @class, ' '), ' "+e+" ')]",n=t.evaluate(r,t,null,0,null);while(i=n.iterateNext())s.push(i)}else{n=t.getElementsByTagName("*"),r=new RegExp("(^|\\s)"+e+"(\\s|$)");for(i=0;i<n.length;i++)r.test(n[i].className)&&s.push(n[i])}return s})
//getComputedStyle polyfill
window.getComputedStyle||(window.getComputedStyle=function(e){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this})
//http://javascript.nwbox.com/ContentLoaded by Diego Perini with modifications
function contentLoaded(n,t){var l="complete",s="readystatechange",u=!1,h=u,c=!0,i=n.document,a=i.documentElement,e=i.addEventListener?"addEventListener":"attachEvent",v=i.addEventListener?"removeEventListener":"detachEvent",f=i.addEventListener?"":"on",r=function(e){(e.type!=s||i.readyState==l)&&((e.type=="load"?n:i)[v](f+e.type,r,u),!h&&(h=!0)&&t.call(n,null))},o=function(){try{a.doScroll("left")}catch(n){setTimeout(o,50);return}r("poll")};if(i.readyState==l)t.call(n,"lazy");else{if(i.createEventObject&&a.doScroll){try{c=!n.frameElement}catch(y){}c&&o()}i[e](f+"DOMContentLoaded",r,u),i[e](f+s,r,u),n[e](f+"load",r,u)}}
//https://gist.github.com/991057 by Jed Schmidt with modifications
function selector(a){
a=a.match(/^(\W)?(.*)/);var b=document["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2]);
var ret=[]; b!==null&&(b.length?ret=b:b.length===0?ret=b:ret=[b]); return ret;
}
//shallow object property extend
function extend(a,b){
var c={};
for(var i in a){
if(a.hasOwnProperty(i)){
c[i]=a[i];
}
}
for(var i in b){
if(b.hasOwnProperty(i)){
c[i]=b[i];
}
}
return c
}
//hasOwnProperty polyfill
if (!Object.prototype.hasOwnProperty)
/*jshint -W001, -W103 */
Object.prototype.hasOwnProperty = function(prop) {
var proto = this.__proto__ || this.constructor.prototype;
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]);
}
/*jshint +W001, +W103 */
function text_size(width, height, template) { function text_size(width, height, template) {
height = parseInt(height, 10); height = parseInt(height, 10);
width = parseInt(width, 10); width = parseInt(width, 10);
...@@ -181,20 +149,68 @@ function text_size(width, height, template) { ...@@ -181,20 +149,68 @@ function text_size(width, height, template) {
} }
} }
function draw(args) { var svg_el = (function(){
var ctx = args.ctx; //Prevent IE <9 from initializing SVG renderer
var dimensions = args.dimensions; if(!window.XMLSerializer) return;
var template = args.template; var serializer = new XMLSerializer();
var ratio = args.ratio; var svg_ns = "http://www.w3.org/2000/svg"
var holder = args.holder; var svg = document.createElementNS(svg_ns, "svg");
var literal = holder.textmode == "literal"; //IE throws an exception if this is set and Chrome requires it to be set
var exact = holder.textmode == "exact"; if(svg.webkitMatchesSelector){
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
}
var bg_el = document.createElementNS(svg_ns, "rect")
var text_el = document.createElementNS(svg_ns, "text")
var textnode_el = document.createTextNode(null)
text_el.setAttribute("text-anchor", "middle")
text_el.appendChild(textnode_el)
svg.appendChild(bg_el)
svg.appendChild(text_el)
return function(props){
svg.setAttribute("width",props.width);
svg.setAttribute("height", props.height);
bg_el.setAttribute("width", props.width);
bg_el.setAttribute("height", props.height);
bg_el.setAttribute("fill", props.template.background);
text_el.setAttribute("x", props.width/2)
text_el.setAttribute("y", props.height/2)
textnode_el.nodeValue=props.text
text_el.setAttribute("style", css_properties({
"fill": props.template.foreground,
"font-weight": "bold",
"font-size": props.text_height+"px",
"font-family":props.font,
"dominant-baseline":"central"
}))
return serializer.serializeToString(svg)
}
})()
function css_properties(props){
var ret = [];
for(p in props){
if(props.hasOwnProperty(p)){
ret.push(p+":"+props[p])
}
}
return ret.join(";")
}
function draw_canvas(args) {
var ctx = args.ctx,
dimensions = args.dimensions,
template = args.template,
ratio = args.ratio,
holder = args.holder,
literal = holder.textmode == "literal",
exact = holder.textmode == "exact";
var ts = text_size(dimensions.width, dimensions.height, template); var ts = text_size(dimensions.width, dimensions.height, template);
var text_height = ts.height; var text_height = ts.height;
var width = dimensions.width * ratio, var width = dimensions.width * ratio,
height = dimensions.height * ratio; height = dimensions.height * ratio;
var font = template.font ? template.font : "sans-serif"; var font = template.font ? template.font : "Arial,Helvetica,sans-serif";
canvas.width = width; canvas.width = width;
canvas.height = height; canvas.height = height;
ctx.textAlign = "center"; ctx.textAlign = "center";
...@@ -222,8 +238,50 @@ function draw(args) { ...@@ -222,8 +238,50 @@ function draw(args) {
return canvas.toDataURL("image/png"); return canvas.toDataURL("image/png");
} }
function render(mode, el, holder, src) { function draw_svg(args){
var dimensions = args.dimensions,
template = args.template,
holder = args.holder,
literal = holder.textmode == "literal",
exact = holder.textmode == "exact";
var ts = text_size(dimensions.width, dimensions.height, template);
var text_height = ts.height;
var width = dimensions.width,
height = dimensions.height;
var font = template.font ? template.font : "Arial,Helvetica,sans-serif";
var text = template.text ? template.text : (Math.floor(dimensions.width) + "x" + Math.floor(dimensions.height));
if (literal) {
var dimensions = holder.dimensions;
text = dimensions.width + "x" + dimensions.height;
}
else if(exact && holder.exact_dimensions){
var dimensions = holder.exact_dimensions;
text = (Math.floor(dimensions.width) + "x" + Math.floor(dimensions.height));
}
var string = svg_el({
text: text,
width:width,
height:height,
text_height:text_height,
font:font,
template:template
})
return "data:image/svg+xml;base64,"+btoa(string);
}
function draw(args) {
if(instance_config.use_canvas && !instance_config.use_svg){
return draw_canvas(args);
}
else{
return draw_svg(args);
}
}
function render(mode, el, holder, src) {
var dimensions = holder.dimensions, var dimensions = holder.dimensions,
theme = holder.theme, theme = holder.theme,
text = holder.text ? decodeURIComponent(holder.text) : holder.text; text = holder.text ? decodeURIComponent(holder.text) : holder.text;
...@@ -240,11 +298,11 @@ function render(mode, el, holder, src) { ...@@ -240,11 +298,11 @@ function render(mode, el, holder, src) {
if (mode == "image") { if (mode == "image") {
el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption); el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption);
if (fallback || !holder.auto) { if (instance_config.use_fallback || !holder.auto) {
el.style.width = dimensions.width + "px"; el.style.width = dimensions.width + "px";
el.style.height = dimensions.height + "px"; el.style.height = dimensions.height + "px";
} }
if (fallback) { if (instance_config.use_fallback) {
el.style.backgroundColor = theme.background; el.style.backgroundColor = theme.background;
} else { } else {
el.setAttribute("src", draw({ctx: ctx, dimensions: dimensions, template: theme, ratio:ratio, holder: holder})); el.setAttribute("src", draw({ctx: ctx, dimensions: dimensions, template: theme, ratio:ratio, holder: holder}));
...@@ -256,7 +314,7 @@ function render(mode, el, holder, src) { ...@@ -256,7 +314,7 @@ function render(mode, el, holder, src) {
} }
} else if (mode == "background") { } else if (mode == "background") {
if (!fallback) { if (!instance_config.use_fallback) {
el.style.backgroundImage = "url(" + draw({ctx:ctx, dimensions: dimensions, template: theme, ratio: ratio, holder: holder}) + ")"; el.style.backgroundImage = "url(" + draw({ctx:ctx, dimensions: dimensions, template: theme, ratio: ratio, holder: holder}) + ")";
el.style.backgroundSize = dimensions.width + "px " + dimensions.height + "px"; el.style.backgroundSize = dimensions.width + "px " + dimensions.height + "px";
} }
...@@ -264,18 +322,21 @@ function render(mode, el, holder, src) { ...@@ -264,18 +322,21 @@ function render(mode, el, holder, src) {
el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption); el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption);
if (dimensions.height.slice(-1) == "%") { if (dimensions.height.slice(-1) == "%") {
el.style.height = dimensions.height el.style.height = dimensions.height
} else { } else if(holder.auto == null || !holder.auto){
el.style.height = dimensions.height + "px" el.style.height = dimensions.height + "px"
} }
if (dimensions.width.slice(-1) == "%") { if (dimensions.width.slice(-1) == "%") {
el.style.width = dimensions.width el.style.width = dimensions.width
} else { } else if(holder.auto == null || !holder.auto){
el.style.width = dimensions.width + "px" el.style.width = dimensions.width + "px"
} }
if (el.style.display == "inline" || el.style.display === "" || el.style.display == "none") { if (el.style.display == "inline" || el.style.display === "" || el.style.display == "none") {
el.style.display = "block"; el.style.display = "block";
} }
if (fallback) {
set_initial_dimensions(el)
if (instance_config.use_fallback) {
el.style.backgroundColor = theme.background; el.style.backgroundColor = theme.background;
} else { } else {
resizable_images.push(el); resizable_images.push(el);
...@@ -290,19 +351,36 @@ function dimension_check(el, callback) { ...@@ -290,19 +351,36 @@ function dimension_check(el, callback) {
width: el.clientWidth width: el.clientWidth
}; };
if (!dimensions.height && !dimensions.width) { if (!dimensions.height && !dimensions.width) {
if (el.hasAttribute("data-holder-invisible")) { el.setAttribute("data-holder-invisible", true)
throw new Error("Holder: placeholder is not visible"); callback.call(this, el)
} else { }
el.setAttribute("data-holder-invisible", true) else{
setTimeout(function () {
callback.call(this, el)
}, 1)
return null;
}
} else {
el.removeAttribute("data-holder-invisible") el.removeAttribute("data-holder-invisible")
return dimensions;
}
}
function set_initial_dimensions(el){
if(el.holder_data){
var dimensions = dimension_check(el, app.invisible_error_fn( set_initial_dimensions))
if(dimensions){
var holder = el.holder_data;
holder.initial_dimensions = dimensions;
holder.fluid_data = {
fluid_height: holder.dimensions.height.slice(-1) == "%",
fluid_width: holder.dimensions.width.slice(-1) == "%",
mode: null
}
if(holder.fluid_data.fluid_width && !holder.fluid_data.fluid_height){
holder.fluid_data.mode = "width"
holder.fluid_data.ratio = holder.initial_dimensions.width / parseFloat(holder.dimensions.height)
}
else if(!holder.fluid_data.fluid_width && holder.fluid_data.fluid_height){
holder.fluid_data.mode = "height";
holder.fluid_data.ratio = parseFloat(holder.dimensions.width) / holder.initial_dimensions.height
}
}
} }
return dimensions;
} }
function resizable_update(element) { function resizable_update(element) {
...@@ -319,9 +397,19 @@ function resizable_update(element) { ...@@ -319,9 +397,19 @@ function resizable_update(element) {
var el = images[i] var el = images[i]
if (el.holder_data) { if (el.holder_data) {
var holder = el.holder_data; var holder = el.holder_data;
var dimensions = dimension_check(el, resizable_update) var dimensions = dimension_check(el, app.invisible_error_fn( resizable_update))
if(dimensions){ if(dimensions){
if(holder.fluid){ if(holder.fluid){
if(holder.auto){
switch(holder.fluid_data.mode){
case "width":
dimensions.height = dimensions.width / holder.fluid_data.ratio;
break;
case "height":
dimensions.width = dimensions.height * holder.fluid_data.ratio;
break;
}
}
el.setAttribute("src", draw({ el.setAttribute("src", draw({
ctx: ctx, ctx: ctx,
dimensions: dimensions, dimensions: dimensions,
...@@ -350,7 +438,7 @@ function parse_flags(flags, options) { ...@@ -350,7 +438,7 @@ function parse_flags(flags, options) {
theme: extend(settings.themes.gray, {}) theme: extend(settings.themes.gray, {})
}; };
var render = false; var render = false;
for (sl = flags.length, j = 0; j < sl; j++) { for (var fl = flags.length, j = 0; j < fl; j++) {
var flag = flags[j]; var flag = flags[j];
if (app.flags.dimensions.match(flag)) { if (app.flags.dimensions.match(flag)) {
render = true; render = true;
...@@ -385,10 +473,20 @@ for (var flag in app.flags) { ...@@ -385,10 +473,20 @@ for (var flag in app.flags) {
return val.match(this.regex) return val.match(this.regex)
} }
} }
app.invisible_error_fn = function(fn){
return function(el){
if(el.hasAttribute("data-holder-invisible")){
throw new Error("Holder: invisible placeholder")
}
}
}
app.add_theme = function (name, theme) { app.add_theme = function (name, theme) {
name != null && theme != null && (settings.themes[name] = theme); name != null && theme != null && (settings.themes[name] = theme);
return app; return app;
}; };
app.add_image = function (src, el) { app.add_image = function (src, el) {
var node = selector(el); var node = selector(el);
if (node.length) { if (node.length) {
...@@ -400,21 +498,31 @@ app.add_image = function (src, el) { ...@@ -400,21 +498,31 @@ app.add_image = function (src, el) {
} }
return app; return app;
}; };
app.run = function (o) { app.run = function (o) {
instance_config = extend({}, system_config)
preempted = true; preempted = true;
var options = extend(settings, o), var options = extend(settings, o),
images = [], images = [],
imageNodes = [], imageNodes = [],
bgnodes = []; bgnodes = [];
if(options.use_canvas != null && options.use_canvas){
instance_config.use_canvas = true;
instance_config.use_svg = false;
}
if (typeof (options.images) == "string") { if (typeof (options.images) == "string") {
imageNodes = selector(options.images); imageNodes = selector(options.images);
} else if (window.NodeList && options.images instanceof window.NodeList) { } else if (window.NodeList && options.images instanceof window.NodeList) {
imageNodes = options.images; imageNodes = options.images;
} else if (window.Node && options.images instanceof window.Node) { } else if (window.Node && options.images instanceof window.Node) {
imageNodes = [options.images]; imageNodes = [options.images];
} else if(window.HTMLCollection && options.images instanceof window.HTMLCollection){
imageNodes = options.images
} }
if (typeof (options.bgnodes) == "string") { if (typeof (options.bgnodes) == "string") {
bgnodes = selector(options.bgnodes); bgnodes = selector(options.bgnodes);
} else if (window.NodeList && options.elements instanceof window.NodeList) { } else if (window.NodeList && options.elements instanceof window.NodeList) {
...@@ -469,8 +577,7 @@ app.run = function (o) { ...@@ -469,8 +577,7 @@ app.run = function (o) {
src = attr_datasrc; src = attr_datasrc;
} }
if (src) { if (src) {
var holder = parse_flags(src.substr(src.lastIndexOf(options.domain) + options.domain.length + 1) var holder = parse_flags(src.substr(src.lastIndexOf(options.domain) + options.domain.length + 1).split("/"), options);
.split("/"), options);
if (holder) { if (holder) {
if (holder.fluid) { if (holder.fluid) {
render("fluid", images[i], holder, src) render("fluid", images[i], holder, src)
...@@ -482,6 +589,7 @@ app.run = function (o) { ...@@ -482,6 +589,7 @@ app.run = function (o) {
} }
return app; return app;
}; };
contentLoaded(win, function () { contentLoaded(win, function () {
if (window.addEventListener) { if (window.addEventListener) {
window.addEventListener("resize", resizable_update, false); window.addEventListener("resize", resizable_update, false);
...@@ -489,7 +597,7 @@ contentLoaded(win, function () { ...@@ -489,7 +597,7 @@ contentLoaded(win, function () {
} else { } else {
window.attachEvent("onresize", resizable_update) window.attachEvent("onresize", resizable_update)
} }
preempted || app.run(); preempted || app.run({});
}); });
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
define([], function () { define([], function () {
...@@ -497,4 +605,44 @@ if (typeof define === "function" && define.amd) { ...@@ -497,4 +605,44 @@ if (typeof define === "function" && define.amd) {
}); });
} }
//github.com/davidchambers/Base64.js
(function(){function t(t){this.message=t}var e="undefined"!=typeof exports?exports:this,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=Error(),t.prototype.name="InvalidCharacterError",e.btoa||(e.btoa=function(e){for(var o,n,a=0,i=r,c="";e.charAt(0|a)||(i="=",a%1);c+=i.charAt(63&o>>8-8*(a%1))){if(n=e.charCodeAt(a+=.75),n>255)throw new t("'btoa' failed");o=o<<8|n}return c}),e.atob||(e.atob=function(e){if(e=e.replace(/=+$/,""),1==e.length%4)throw new t("'atob' failed");for(var o,n,a=0,i=0,c="";n=e.charAt(i++);~n&&(o=a%4?64*o+n:n,a++%4)?c+=String.fromCharCode(255&o>>(6&-2*a)):0)n=r.indexOf(n);return c})})();
//getElementsByClassName polyfill
document.getElementsByClassName||(document.getElementsByClassName=function(e){var t=document,n,r,i,s=[];if(t.querySelectorAll)return t.querySelectorAll("."+e);if(t.evaluate){r=".//*[contains(concat(' ', @class, ' '), ' "+e+" ')]",n=t.evaluate(r,t,null,0,null);while(i=n.iterateNext())s.push(i)}else{n=t.getElementsByTagName("*"),r=new RegExp("(^|\\s)"+e+"(\\s|$)");for(i=0;i<n.length;i++)r.test(n[i].className)&&s.push(n[i])}return s})
//getComputedStyle polyfill
window.getComputedStyle||(window.getComputedStyle=function(e){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this})
//http://javascript.nwbox.com/ContentLoaded by Diego Perini with modifications
function contentLoaded(n,t){var l="complete",s="readystatechange",u=!1,h=u,c=!0,i=n.document,a=i.documentElement,e=i.addEventListener?"addEventListener":"attachEvent",v=i.addEventListener?"removeEventListener":"detachEvent",f=i.addEventListener?"":"on",r=function(e){(e.type!=s||i.readyState==l)&&((e.type=="load"?n:i)[v](f+e.type,r,u),!h&&(h=!0)&&t.call(n,null))},o=function(){try{a.doScroll("left")}catch(n){setTimeout(o,50);return}r("poll")};if(i.readyState==l)t.call(n,"lazy");else{if(i.createEventObject&&a.doScroll){try{c=!n.frameElement}catch(y){}c&&o()}i[e](f+"DOMContentLoaded",r,u),i[e](f+s,r,u),n[e](f+"load",r,u)}}
//https://gist.github.com/991057 by Jed Schmidt with modifications
function selector(a,b){var a=a.match(/^(\W)?(.*)/),b=b||document,c=b["getElement"+(a[1]?"#"==a[1]?"ById":"sByClassName":"sByTagName")],d=c.call(b,a[2]),e=[];return null!==d&&(e=d.length||0===d.length?d:[d]),e}
//shallow object property extend
function extend(a,b){
var c={};
for(var i in a){
if(a.hasOwnProperty(i)){
c[i]=a[i];
}
}
for(var i in b){
if(b.hasOwnProperty(i)){
c[i]=b[i];
}
}
return c
}
//hasOwnProperty polyfill
if (!Object.prototype.hasOwnProperty)
/*jshint -W001, -W103 */
Object.prototype.hasOwnProperty = function(prop) {
var proto = this.__proto__ || this.constructor.prototype;
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]);
}
/*jshint +W001, +W103 */
})(Holder, window); })(Holder, window);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment