From da40fa9cfa92a2793053cda3122ae0fab4126635 Mon Sep 17 00:00:00 2001 From: Ahmad Azimi Date: Thu, 28 May 2015 09:59:57 +0430 Subject: [PATCH 1/2] Add var keyword for FontDetect and generate minified version. --- lib/fontdetect.js | 2 +- lib/fontdetect.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fontdetect.js b/lib/fontdetect.js index 3d4acc6..fe1bb24 100644 --- a/lib/fontdetect.js +++ b/lib/fontdetect.js @@ -23,7 +23,7 @@ * @copyright 2014 Jennifer Simonds * @license MIT License http://opensource.org/licenses/MIT */ -FontDetect = function() +var FontDetect = function() { // The private parts var _isInitialized = false; diff --git a/lib/fontdetect.min.js b/lib/fontdetect.min.js index 6800e71..98f5e47 100644 --- a/lib/fontdetect.min.js +++ b/lib/fontdetect.min.js @@ -1 +1 @@ -FontDetect=function(){function e(){if(!n){n=!0;var e=document.body,t=document.body.firstChild,i=document.createElement("div");i.id="fontdetectHelper",r=document.createElement("span"),r.innerText="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",i.appendChild(r),e.insertBefore(i,t),i.style.position="absolute",i.style.visibility="hidden",i.style.top="-200px",i.style.left="-100000px",i.style.width="100000px",i.style.height="200px",i.style.fontSize="100px"}}function t(e,t){return e instanceof Element?window.getComputedStyle(e).getPropertyValue(t):window.jQuery?$(e).css(t):""}var n=!1,i=["serif","sans-serif","monospace","cursive","fantasy"],r=null;return{onFontLoaded:function(t,i,r,o){if(t){var s=o&&o.msInterval?o.msInterval:100,a=o&&o.msTimeout?o.msTimeout:2e3;if(i||r){if(n||e(),this.isFontLoaded(t))return void(i&&i(t));var l=this,f=(new Date).getTime(),d=setInterval(function(){if(l.isFontLoaded(t))return clearInterval(d),void i(t);var e=(new Date).getTime();e-f>a&&(clearInterval(d),r&&r(t))},s)}}},isFontLoaded:function(t){var o=0,s=0;n||e();for(var a=0;a0&&o!=s)return!1;s=o}return!0},whichFont:function(e){for(var n=t(e,"font-family"),r=n.split(","),o=r.shift();o;){o=o.replace(/^\s*['"]?\s*([^'"]*)\s*['"]?\s*$/,"$1");for(var s=0;sg){clearInterval(j);if(d){d(b)}}}},f)},isFontLoaded:function(a){var b=0;var c=0;if(!k){_init()}for(var d=0;d0&&b!=c){return false}c=b}return true},whichFont:function(a){var b=_getCss(a,'font-family');var c=b.split(',');var d=c.shift();while(d){d=d.replace(/^\s*['"]?\s*([^'"]*)\s*['"]?\s*$/,'$1');for(var e=0;e Date: Mon, 1 Jun 2015 23:03:27 +0430 Subject: [PATCH 2/2] Minified version reverted. --- lib/fontdetect.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 lib/fontdetect.min.js diff --git a/lib/fontdetect.min.js b/lib/fontdetect.min.js old mode 100644 new mode 100755 index 98f5e47..160b540 --- a/lib/fontdetect.min.js +++ b/lib/fontdetect.min.js @@ -1 +1 @@ -var FontDetect=function(){var k=false;var l=['serif','sans-serif','monospace','cursive','fantasy'];var m=null;var n='en';var o={'en':'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','fa':'ابپتجچحخدذرزسشصضططعغفقکگلمنوهی'};function _init(){if(k){return}k=true;var a=document.body;var b=document.body.firstChild;var c=document.createElement('div');c.id='fontdetectHelper';m=document.createElement('span');m.innerText=o[n];c.appendChild(m);a.insertBefore(c,b);c.style.position='absolute';c.style.visibility='hidden';c.style.top='-200px';c.style.left='-100000px';c.style.width='100000px';c.style.height='200px';c.style.fontSize='100px'}function _getCss(a,b){if(a instanceof Element){return window.getComputedStyle(a).getPropertyValue(b)}else if(window.jQuery){return $(a).css(b)}else{return''}}return{onFontLoaded:function(b,c,d,e){if(!b){return}var f=(e&&e.msInterval)?e.msInterval:100;var g=(e&&e.msTimeout)?e.msTimeout:2000;n=(e&&e.eLang&&e.eLang in o)?e.eLang:'en';if(!c&&!d){return}if(!k){_init()}if(this.isFontLoaded(b)){if(c){c(b)}return}var h=this;var i=new Date().getTime();var j=setInterval(function(){if(h.isFontLoaded(b)){clearInterval(j);c(b);return}else{var a=new Date().getTime();if((a-i)>g){clearInterval(j);if(d){d(b)}}}},f)},isFontLoaded:function(a){var b=0;var c=0;if(!k){_init()}for(var d=0;d0&&b!=c){return false}c=b}return true},whichFont:function(a){var b=_getCss(a,'font-family');var c=b.split(',');var d=c.shift();while(d){d=d.replace(/^\s*['"]?\s*([^'"]*)\s*['"]?\s*$/,'$1');for(var e=0;ea&&(clearInterval(d),r&&r(t))},s)}}},isFontLoaded:function(t){var o=0,s=0;n||e();for(var a=0;a0&&o!=s)return!1;s=o}return!0},whichFont:function(e){for(var n=t(e,"font-family"),r=n.split(","),o=r.shift();o;){o=o.replace(/^\s*['"]?\s*([^'"]*)\s*['"]?\s*$/,"$1");for(var s=0;s