/* BeeLine Reader JavaScript Library -- Version 1.0.5 Copyright 2015, Andrew Cantino and Nicholas Lum, all rights reserved. */ (function(){var e=[].slice;window.BeelineUtils={colorIsDark:function(e){var t,o,r,n,i;return i=parseInt(e.substring(1),16),n=255&i>>16,o=255&i>>8,t=255&i>>0,r=.2126*n+.7152*o+.0722*t,80>r},attachElement:function(e,t){var o;return null==t&&(t=document),o=t.getElementsByTagName("head")[0],o?o.appendChild(e):t.body.appendChild(e)},loadScript:function(e,t){var o;return null==t&&(t={}),o=document.createElement("SCRIPT"),o.setAttribute("type","text/javascript"),o.setAttribute("src",e+(t.reload?"?r="+Math.random():"")),this.attachElement(o),null!=t.loads&&null!=t.then?this.whenTrue(function(){return null!=window[t.loads]},t.then):void 0},loadCSS:function(e,t){var o,r;return null==t&&(t={}),o=t.document||document,t.id&&o.getElementById(t.id)?void 0:(r=o.createElement("LINK"),r.setAttribute("rel","stylesheet"),r.setAttribute("href",e),null!=t.id&&r.setAttribute("id",t.id),r.setAttribute("type","text/css"),r.setAttribute("media",t.media||"all"),this.attachElement(r,o))},removeCSS:function(e){var t,o,r,n,i;for(n=document.querySelectorAll("link[href='"+e+"']"),i=[],o=0,r=n.length;r>o;o++)t=n[o],i.push(t.parentNode.removeChild(t));return i},afterRender:function(e){var t,o=this;return t=function(){var t;try{return e.call(o)}catch(r){return t=r,BeelineUtils.log("Exception in afterRender",t,null!=t?t.stack:void 0)}},window.setTimeout(t,1)},log:function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],"undefined"!=typeof console?"function"==typeof console.log?console.log.apply(console,["BeeLine Reader: "].concat(e.call(t))):void 0:void 0},reload:function(e){return null==e&&(e=null),e&&e.preventDefault(),window.location.reload()},alert:function(e){return alert(e)},url:function(){var e;return null!=(e=window.location)?e.href:void 0},urlMatches:function(e){var t,o;return null!=(t=window.location)?null!=(o=t.href)?o.match(e):void 0:void 0},redirect:function(e,t){var o,r;null==t&&(t={}),r="";for(o in t)""!==r&&(r+="&"),r+=o+"="+encodeURIComponent(t[o]);return window.location.href=e+(r?"?"+r:"")},domain:function(){var e,t;return null!=(e=window.location)?null!=(t=e.origin)?t.replace(/^https?:\/\//i,""):void 0:void 0},offset:function(e){var t,o,r;if(o=r=0,e.offsetParent)if(null!=window.WebKitCSSMatrix){for(;;)if(t=new WebKitCSSMatrix(window.getComputedStyle(e).webkitTransform),o+=e.offsetLeft+t.m41,r+=e.offsetTop+t.m42,!(e=e.offsetParent))break}else for(;;)if(o+=e.offsetLeft,r+=e.offsetTop,!(e=e.offsetParent))break;return[o,r]},outsideOfViewport:function(e,t){var o,r,n,i,s;return null==t&&(t=0),s=this.offset(e),r=s[0],i=s[1],o=i+e.offsetHeight,n=r+e.offsetWidth,owindow.pageXOffset+window.innerWidth*(t+1)||i>window.pageYOffset+window.innerHeight*(t+1)},whenTrue:function(e,t){var o;return o=function(){return e()?t():(BeelineUtils.log("Condition hasn't matched, trying again in a moment..."),setTimeout(o,50))},o()},not:function(e){return function(){return!e()}},presentSliceOf:function(e){var t,o,r;o={};for(t in e)r=e[t],null!=r&&""!==r&&(o[t]=r);return o},evalOrReturn:function(){var t,o,r;return o=arguments[0],r=arguments[1],t=3<=arguments.length?e.call(arguments,2):[],"function"==typeof r?r.apply(o,t):r},installCustomCSS:function(e,t,o){var r;if(!(document.getElementsByClassName(t).length>0))return(r=document.getElementById(e))&&r.parentNode.removeChild(r),r=document.createElement("style"),r.setAttribute("type","text/css"),r.setAttribute("id",e),r.setAttribute("class",t),/trident/i.test(navigator.userAgent)?r.sheet.cssText=o:/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?r.styleSheet.cssText=o:null!=r.innerText?r.innerText=o:r.innerHTML=o,document.getElementsByTagName("head")[0].appendChild(r)},sendGaTrack:function(e,t,o){var r,n,i,s,l,a,u,c,h;return i=function(e,t){return e+Math.floor(Math.random()*(t-e))},l=1e9,a=i(l,9999999999),r=i(1e7,99999999),u=i(l,2147483647),n=(new Date).getTime(),s=window.location,c=new Image,h="//www.google-analytics.com/__utm.gif?utmwv=1.3&utmn="+a+"&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn="+t+"&utmr="+s+"&utmp="+o+"&utmac="+e+"&utmcc=__utma%3D"+r+"."+u+"."+n+"."+n+"."+n+".2%3B%2B__utmb%3D"+r+"%3B%2B__utmc%3D"+r+"%3B%2B__utmz%3D"+r+"."+n+".2.2.utmccn%3D(referral)%7Cutmcsr%3D"+s.host+"%7Cutmcct%3D"+s.pathname+"%7Cutmcmd%3Dreferral%3B%2B__utmv%3D"+r+".-%3B",c.src=h}}}).call(this),/* Copyright 2015, Andrew Cantino and Nicholas Lum, all rights reserved. */ function(){var e=function(e,t){return function(){return e.apply(t,arguments)}},t=[].slice,o=[].indexOf||function(e){for(var t=0,o=this.length;o>t;t++)if(t in this&&this[t]===e)return t;return-1};window.BeeLineReader=function(){function r(t,o){var r;if(null==o&&(o={}),this._resizeHandler=e(this._resizeHandler,this),this.recolor=e(this.recolor,this),this.uncolor=e(this.uncolor,this),this.color=e(this.color,this),!t||t&&t.jquery)throw"A raw DOM Node is required when creating a BeeLineReader instance. If you are providing a jQuery node, you should call get(0) on it to extract the DOM node.";this.node=t,this.options=o,this.listeners={},this.reflowNeeded=!0,this.colorCache={},this.tohexCache={},this.coloring=!1,this.colored=!1,this.abortCount=0,this.workInterval=o.workInterval||this.WORK_INTERVAL,(r=this.options).skipTags||(r.skipTags=this.DEFAULT_SKIP_TAGS),this.browserIsCompatible()&&(this.options.handleResize&&this._setupResizeHandler(),this.options.colorImmediately&&BeelineUtils.afterRender(this.color))}return r.prototype.BEELINE_INDICATOR_CLASS="beeline-node",r.SKIP_COLOR_ATTRIBUTE="data-beeline-skip",r.prototype.DEFAULT_SKIP_TAGS=["svg","h1","h2","h3","h4","h5","style","script"],r.prototype.NUM_COLORS=4,r.prototype.SPACE_REGEX=/^\s+$/,r.prototype.MIN_COLOR_WIDTH=100,r.prototype.WRAPPER_TYPE="beelinespan",r.prototype.BASE_CLASS_PATTERN=/^(beeline-colored-area|beeline-theme-\w+)$/g,r.THEMES={bright:["#000000","#0000FF","#000000","#FF0500","#FBFBFB"],dark:["#000000","#00057F","#000000","#970000","#FBFBFB"],blues:["#000000","#0000FF","#000000","#840DD2","#FBFBFB"],gray:["#000000","#666666","#000000","#666666","#FBFBFB"],night_gray:["#FBFBFB","#666666","#FBFBFB","#666666","#000000"],night_blues:["#FBFBFB","#56AAFF","#FBFBFB","#9E8DFC","#000000"],custom:["#000000","#0000FF","#000000","#FF0500","#FBFBFB"]},r.DEFAULT_THEME="bright",r.THEME_ORDER=["bright","dark","blues","gray","night_gray","night_blues"],r.prototype.COLOR_BLOCK_LENGTH=2e3,r.prototype.WORK_INTERVAL=20,r.prototype.color=function(e){var o,n=this;return this.browserIsCompatible()?(o=function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],n.trigger.apply(n,["afterColor"].concat(t.call(o))),e?e.apply(null,o):void 0},this.trigger("beforeColor"),"custom"===this.getTheme()?this._color(this.node,this.options.customColor1||r.THEMES.custom[0],this.options.customColor2||r.THEMES.custom[1],this.options.customColor3||r.THEMES.custom[2],this.options.customColor4||r.THEMES.custom[3],this.options.customBackground||r.THEMES.custom[4],o):this._color.apply(this,[this.node].concat(t.call(r.THEMES[this.getTheme()]),[o]))):"function"==typeof e?e():void 0},r.prototype.getTheme=function(){return this.options.theme&&r.THEMES[this.options.theme]&&this.options.theme||r.DEFAULT_THEME},r.prototype.setCustom=function(e,t,o,r,n){return this.options.theme="custom",this.options.customColor1=e,this.options.customColor2=t,this.options.customColor3=o,this.options.customColor4=r,this.options.customBackground=n},r.prototype.setOptions=function(e){var t,o,r;r=[];for(t in e)o=e[t],r.push(this.options[t]=o);return r},r.prototype.uncolor=function(){return this.trigger("beforeUncolor"),this._unwrap(this.node),this.options.skipBackgroundColor||this._revertBackground(this.node),this._removeClasses(this.node,this.BASE_CLASS_PATTERN),this.colored=!1,this.reflowNeeded=!0},r.prototype.recolor=function(e){return this.browserIsCompatible()?(this.trigger("beforeRecolor"),this.reflowNeeded=!0,this.color(e)):"function"==typeof e?e():void 0},r.prototype.cleanup=function(){return this.alreadySetupResizeHandler&&window.removeEventListener("resize",this._resizeHandler,!1),this.trigger("afterCleanup")},r.prototype.bind=function(e,t,o){var r;return(r=this.listeners)[e]||(r[e]=[]),this.listeners[e].push([t,o||this])},r.prototype.trigger=function(){var e,o,r,n,i,s,l,a,u;for(n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],l=this.listeners[n]||[],u=[],i=0,s=l.length;s>i;i++)a=l[i],r=a[0],o=a[1],u.push(r.apply(o,e));return u},r.prototype.browserIsCompatible=function(){var e;return e=this._getInternetExplorerVersion(),-1===e||e>=9},r.prototype._getInternetExplorerVersion=function(){var e,t,o;return t=-1,"Microsoft Internet Explorer"===navigator.appName&&(o=navigator.userAgent,e=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"),null!==e.exec(o)&&(t=parseFloat(RegExp.$1))),t},r.prototype._setupResizeHandler=function(){return this.alreadySetupResizeHandler?void 0:(this.alreadySetupResizeHandler=!0,window.addEventListener("resize",this._resizeHandler,!1))},r.prototype._resizeHandler=function(){var e=this;return this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(function(){return e.resizeTimer=null,e.colored?(BeelineUtils.log("re-coloring after resize"),e.recolor()):void 0},500)},r.prototype._addClasses=function(e,o){return e.className=t.call(e.className.split(/\s+/)).concat([o]).join(" ")},r.prototype._removeClasses=function(e,t){var o,r;return r=e.className.split(/\s+/),e.className=function(){var e,n,i;for(i=[],e=0,n=r.length;n>e;e++)o=r[e],o.match(t)||i.push(o);return i}().join(" ")},r.prototype._installCustomStyles=function(e){var t,o;return t=""+function(){var e,t,r,n;for(r=this.options.skipTags,n=[],e=0,t=r.length;t>e;e++)o=r[e],n.push(".beeline-colored-area "+o+", ");return n}.call(this).join(" ")+"\n.beeline-colored-area a,\n.beeline-colored-area a:hover,\n.beeline-colored-area a:active,\n.beeline-colored-area a:visited {\n color: "+e+";\n}",BeelineUtils.installCustomCSS("beeline-custom-styles","beeline-custom-styles-"+e.replace("#",""),t.replace(/[\n\r]/g,""))},r.prototype._color=function(e,t,o,r,n,i,s){var l=this;return this.abortCount++,BeelineUtils.whenTrue(function(){return!l.coloring},function(){var a,u,c;return a=function(){return l.reflowNeeded=!1,l.colored=!0,l.coloring=!1,s?s():void 0},e.hasChildNodes()?(l.coloring=!0,l.abortCount--,l.options.skipBackgroundColor||(e.style.backgroundColor&&!e.originalBackgroundColor&&(e.originalBackgroundColor=e.style.backgroundColor),e.style.backgroundColor=i),l._installCustomStyles(t),l._removeClasses(e,l.BASE_CLASS_PATTERN),l._addClasses(e,"beeline-colored-area beeline-theme-"+l.getTheme()),c=[],u={reflowNeeded:l.reflowNeeded,xlast:null,ylast:null,xfirst:null,line:[],thisColor:0,colorOne:t,colorTwo:o,colorThree:r,colorFour:n,reflowNeeded:l.reflowNeeded,rtl:"rtl"===(window.getComputedStyle(e,null).direction||"").toLowerCase(),colorPairs:[]},u.xmin===u.xmax&&(u.xmax+=1),l._wrapAndColor(e,c,u),l._workOff(c,{abortable:!0,after:function(e){return e?(l.trigger("coloringAborted"),BeelineUtils.log("aborted coloring"),a()):(l._colorLine(u,!0),l._workOff(c,{after:a}))}})):s?s({error:"This node has no children"}):void 0})},r.prototype._wrapAndColor=function(e,t,n){var i,s,l,a=this;if(1===e.nodeType){if(e=e.firstChild){for(l=[];;){if(i=e.nextSibling,1===e.nodeType&&(s=e.nodeName.toLowerCase(),o.call(this.options.skipTags,s)>=0||"true"===e.getAttribute(r.SKIP_COLOR_ATTRIBUTE))||(e.className===this.BEELINE_INDICATOR_CLASS?this._colorNode(t,e,n):this._wrapAndColor(e,t,n)),!(e=i))break;l.push(void 0)}return l}}else if(3===e.nodeType){if(this.options.viewportOnly&&BeelineUtils.outsideOfViewport(e.parentNode,this.options.viewportMarginMultiple||0))return;return t.push(function(){var o,r,i,s,l,u,c,h,d;if(l=e.length,h=e.parentNode,u=e.nodeValue,h&&l&&!a.SPACE_REGEX.test(u)){for(o="",r=d=0;l>=0?l>d:d>l;r=l>=0?++d:--d)c=u.charAt(r)," "===c||"\n"===c||" "===c||"\r"===c?o+=c:(o&&(s=document.createTextNode(o),i=document.createElement(a.WRAPPER_TYPE),i.className=a.BEELINE_INDICATOR_CLASS,i.appendChild(s),h.insertBefore(i,e),a._colorNode(t,i,n)),o=c);return o&&(s=document.createTextNode(o),i=document.createElement(a.WRAPPER_TYPE),i.className=a.BEELINE_INDICATOR_CLASS,i.appendChild(s),h.insertBefore(i,e),a._colorNode(t,i,n)),h.removeChild(e)}})}},r.prototype._colorNode=function(e,t,o){var r=this;return e.push(function(){var e,n,i,s;return o.reflowNeeded?(n=t.getBoundingClientRect(),t.cachedBeeLineXRect=n):n=t.cachedBeeLineXRect||t.getBoundingClientRect(),i=n.left,s=n.top,i>=0||r.options.colorOffScreen?(null===o.xlast&&(o.xfirst=i,o.xlast=i,o.ylast=s),e=o.rtl?i-o.xlast>3:i-o.xlast<-3||s-o.ylast<-50,e&&(r._colorLine(o),o.xfirst=i),o.xlast=i,o.ylast=s,o.line.push([t,i])):void 0})},r.prototype._colorLine=function(e,t){var o,r,n,i,s,l,a,u,c;if(null==t&&(t=!1),e.line.length){for(e.thisColor<2?(s=e.colorOne,i=e.colorTwo):(s=e.colorThree,i=e.colorFour),n=e.line[e.line.length-1][1],u=e.line,l=0,a=u.length;a>l;l++)c=u[l],o=c[0],r=c[1],e.rtl?e.colorPairs.push([o,this._getColor(e.thisColor,r,e.xfirst,n,i,s)]):e.colorPairs.push([o,this._getColor(e.thisColor,r,e.xfirst,n,s,i)]);return this._partialColor(e,t),e.thisColor+=1,e.thisColor%=this.NUM_COLORS,e.line=[]}},r.prototype._partialColor=function(e,t){var o,r,n,i,s,l;if(t||e.colorPairs.length>this.COLOR_BLOCK_LENGTH){for(s=e.colorPairs,n=0,i=s.length;i>n;n++)l=s[n],o=l[0],r=l[1],o.style.setProperty("color",r,"important");return e.colorPairs=[]}},r.prototype._getColor=function(e,t,o,r,n,i){var s,l,a,u,c,h,d,p,f,g,m,C,_,y,v,w,T,E,B,b,S,A,x;switch(this.colorCache[n+i]?(x=this.colorCache[n+i],u=x[0],f=x[1],a=x[2],p=x[3],l=x[4],d=x[5]):(u=this._hexToR(i),f=this._hexToR(n),a=this._hexToG(i),p=this._hexToG(n),l=this._hexToB(i),d=this._hexToB(n),this.colorCache[n+i]=[u,f,a,p,l,d]),A=S=b=0,s=3.1415/(r-o),g=u-f,h=a-p,c=l-d,m=C=B=w=E=T=_=v=v=0,e){case 0:m=t-o,C=s*m,B=C-3.1415,v=Math.cos(B),v+=1,v/=2,E=g*v,E+=f,T=h*v,T+=p,_=c*v,_+=d,A=Math.round(E),S=Math.round(T),b=Math.round(_);break;case 1:m=t-o,C=s*m,w=C,y=Math.cos(w),y+=1,y/=2,E=g*y,E+=f,T=h*y,T+=p,_=c*y,_+=d,A=Math.round(E),S=Math.round(T),b=Math.round(_);break;case 2:m=t-o,C=s*m,B=C-3.1415,v=Math.cos(B),v+=1,v/=2,E=g*v,E+=f,T=h*v,T+=p,_=c*v,_+=d,A=Math.round(E),S=Math.round(T),b=Math.round(_);break;case 3:m=t-o,C=s*m,w=C,y=Math.cos(w),y+=1,y/=2,E=g*y,E+=f,T=h*y,T+=p,_=c*y,_+=d,A=Math.round(E),S=Math.round(T),b=Math.round(_);break;default:A=127,S=127,b=127}return this._rgbToHex(A,S,b)},r.prototype._rgbToHex=function(e,t,o){return"#"+this._toHex(e)+this._toHex(t)+this._toHex(o)},r.prototype._toHex=function(e){var t;if(!(t=this.tohexCache[e])){if(e=parseInt(e,10),isNaN(e))return"00";e=Math.max(0,Math.min(e,255)),t="0123456789ABCDEF".charAt((e-e%16)/16)+"0123456789ABCDEF".charAt(e%16),this.tohexCache[e]=t}return t},r.prototype._hexToR=function(e){return parseInt(this._cutHex(e).substring(0,2),16)},r.prototype._hexToG=function(e){return parseInt(this._cutHex(e).substring(2,4),16)},r.prototype._hexToB=function(e){return parseInt(this._cutHex(e).substring(4,6),16)},r.prototype._cutHex=function(e){return"#"===e.charAt(0)?e.substring(1,7):e},r.prototype._time=function(e,t){var o,r;return r=(new Date).getTime(),t(),o=(new Date).getTime(),BeelineUtils.log(""+e+" took "+(o-r)+"ms")},r.prototype._revertBackground=function(e){return e.style.backgroundColor=e.originalBackgroundColor||""},r.prototype._unwrap=function(e){var t,o,r,n,i,s,l,a,u,c;for(t=[],n=[],u=e.getElementsByClassName(this.BEELINE_INDICATOR_CLASS),i=0,l=u.length;l>i;i++)o=u[i],0===t.length||o===t[t.length-1].nextSibling?t.push(o):(n.push(t),t=[o]);for(t.length>0&&n.push(t),c=[],s=0,a=n.length;a>s;s++)r=n[s],c.push(this._mergeContents(r));return c},r.prototype._mergeContents=function(e){var t,o,r,n,i,s,l,a,u,c;for(o=e[0].parentNode,r="",n=0,s=e.length;s>n;n++)t=e[n],null!==(null!=(a=t.firstChild)?a.nodeValue:void 0)&&(r+=t.firstChild.nodeValue);for(o.replaceChild(document.createTextNode(r),e[0]),u=e.slice(1,e.length),c=[],i=0,l=u.length;l>i;i++)t=u[i],c.push(o.removeChild(t));return c},r.prototype._workOff=function(e,t){var o,r,n=this;for(null==t&&(t={}),r=(new Date).getTime();(new Date).getTime()-r0&&t.abortable&&this.abortCount>0){if(t.after)return t.after(!0)}else{if(e.length>0)return BeelineUtils.afterRender(function(){return n._workOff(e,t)});if(t.after)return t.after()}},r}()}.call(this);