From 06fa31a2c1a3a4f899402d116e1c8214f98d7cf0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 6 Jul 2016 14:13:52 -0400 Subject: [PATCH 1/5] Added license property to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 5a26e98..8876c09 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.6.5", "description": "Add notification bubbles in the favicon", "author": "Tom Moor (http://tommoor.com)", + "license": "MIT", "main" : "./tinycon.js", "repository" : { "type": "git", From 75baba2b33f97e98da1ff9778438b114cea033bc Mon Sep 17 00:00:00 2001 From: Phil Harnish Date: Fri, 12 Sep 2014 08:51:55 -0700 Subject: [PATCH 2/5] Chrome browsers with nonstandard zoom report fractional devicePixelRatio. Fractional pixel values cause drawing artifacts with text. Tested on a retina display (rounds up to 2) and a standard display (stays at 1). --- tinycon.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tinycon.js b/tinycon.js index 19d2245..85a9a63 100644 --- a/tinycon.js +++ b/tinycon.js @@ -14,7 +14,8 @@ var faviconImage = null; var canvas = null; var options = {}; - var r = window.devicePixelRatio || 1; + // Chrome browsers with nonstandard zoom report fractional devicePixelRatio. + var r = Math.ceil(window.devicePixelRatio) || 1; var size = 16 * r; var defaults = { width: 7, @@ -192,16 +193,16 @@ // bubble context.beginPath(); - context.moveTo(left + radius, top); + context.moveTo(left + radius, top); context.quadraticCurveTo(left, top, left, top + radius); context.lineTo(left, bottom - radius); - context.quadraticCurveTo(left, bottom, left + radius, bottom); - context.lineTo(right - radius, bottom); - context.quadraticCurveTo(right, bottom, right, bottom - radius); - context.lineTo(right, top + radius); - context.quadraticCurveTo(right, top, right - radius, top); - context.closePath(); - context.fill(); + context.quadraticCurveTo(left, bottom, left + radius, bottom); + context.lineTo(right - radius, bottom); + context.quadraticCurveTo(right, bottom, right, bottom - radius); + context.lineTo(right, top + radius); + context.quadraticCurveTo(right, top, right - radius, top); + context.closePath(); + context.fill(); // bottom shadow context.beginPath(); From 38ab833ff6eef5b8f0cce61dedc2bbe39182f3de Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 13 Aug 2016 15:38:39 -0700 Subject: [PATCH 3/5] Added minified file and README note --- README.md | 5 +++++ tinycon.min.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e78ddcf..bd23897 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,11 @@ Currently the library degrades to title update: * Safari 5 +## Development + +To produce the minified file run `grunt uglify` + + ## License / Credits Tinycon is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with Tinycon. diff --git a/tinycon.min.js b/tinycon.min.js index dc796a3..b39f400 100644 --- a/tinycon.min.js +++ b/tinycon.min.js @@ -5,4 +5,4 @@ * @license MIT Licensed * @version 0.6.4 */ -!function(){var a={},b=null,c=null,d=null,e=null,f={},g=window.devicePixelRatio||1,h=16*g,i={width:7,height:9,font:10*g+"px arial",color:"#ffffff",background:"#F03D25",fallback:!0,crossOrigin:!0,abbreviate:!0},j=function(){var a=navigator.userAgent.toLowerCase();return function(b){return-1!==a.indexOf(b)}}(),k={ie:j("trident"),chrome:j("chrome"),webkit:j("chrome")||j("safari"),safari:j("safari")&&!j("chrome"),mozilla:j("mozilla")&&!j("chrome")&&!j("safari")},l=function(){for(var a=document.getElementsByTagName("link"),b=0,c=a.length;c>b;b++)if((a[b].getAttribute("rel")||"").match(/\bicon\b/i))return a[b];return!1},m=function(){for(var a=document.getElementsByTagName("link"),b=document.getElementsByTagName("head")[0],c=0,d=a.length;d>c;c++){var e="undefined"!=typeof a[c];e&&(a[c].getAttribute("rel")||"").match(/\bicon\b/i)&&b.removeChild(a[c])}},n=function(){if(!c||!b){var a=l();b=a?a.getAttribute("href"):"/favicon.ico",c||(c=b)}return b},o=function(){return e||(e=document.createElement("canvas"),e.width=h,e.height=h),e},p=function(a){if(a){m();var b=document.createElement("link");b.type="image/x-icon",b.rel="icon",b.href=a,document.getElementsByTagName("head")[0].appendChild(b)}},q=function(a,b){if(!o().getContext||k.ie||k.safari||"force"===f.fallback)return r(a);var c=o().getContext("2d"),b=b||"#000000",e=n();d=document.createElement("img"),d.onload=function(){c.clearRect(0,0,h,h),c.drawImage(d,0,0,d.width,d.height,0,0,h,h),(a+"").length>0&&s(c,a,b),t()},!e.match(/^data/)&&f.crossOrigin&&(d.crossOrigin="anonymous"),d.src=e},r=function(a){if(f.fallback){var b=document.title;"("===b[0]&&(b=b.slice(b.indexOf(" "))),(a+"").length>0?document.title="("+a+") "+b:document.title=b}},s=function(a,b,c){"number"==typeof b&&b>99&&f.abbreviate&&(b=u(b));var d=(b+"").length-1,e=f.width*g+6*g*d,i=f.height*g,j=h-i,l=h-e-g,m=16*g,n=16*g,o=2*g;a.font=(k.webkit?"bold ":"")+f.font,a.fillStyle=f.background,a.strokeStyle=f.background,a.lineWidth=g,a.beginPath(),a.moveTo(l+o,j),a.quadraticCurveTo(l,j,l,j+o),a.lineTo(l,m-o),a.quadraticCurveTo(l,m,l+o,m),a.lineTo(n-o,m),a.quadraticCurveTo(n,m,n,m-o),a.lineTo(n,j+o),a.quadraticCurveTo(n,j,n-o,j),a.closePath(),a.fill(),a.beginPath(),a.strokeStyle="rgba(0,0,0,0.3)",a.moveTo(l+o/2,m),a.lineTo(n-o/2,m),a.stroke(),a.fillStyle=f.color,a.textAlign="right",a.textBaseline="top",a.fillText(b,2===g?29:15,k.mozilla?7*g:6*g)},t=function(){o().getContext&&p(o().toDataURL())},u=function(a){for(var b=[["G",1e9],["M",1e6],["k",1e3]],c=0;c=b[c][1]){a=v(a/b[c][1])+b[c][0];break}return a},v=function(a,b){var c=new Number(a);return c.toFixed(b)};a.setOptions=function(a){f={},a.colour&&(a.color=a.colour);for(var b in i)f[b]=a.hasOwnProperty(b)?a[b]:i[b];return this},a.setImage=function(a){return b=a,t(),this},a.setBubble=function(a,b){return a=a||"",q(a,b),this},a.reset=function(){b=c,p(c)},a.setOptions(i),"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module?module.exports=a:window.Tinycon=a}(); \ No newline at end of file +!function(){var a={},b=null,c=null,d=null,e=null,f={},g=Math.ceil(window.devicePixelRatio)||1,h=16*g,i={width:7,height:9,font:10*g+"px arial",color:"#ffffff",background:"#F03D25",fallback:!0,crossOrigin:!0,abbreviate:!0},j=function(){var a=navigator.userAgent.toLowerCase();return function(b){return-1!==a.indexOf(b)}}(),k={ie:j("trident"),chrome:j("chrome"),webkit:j("chrome")||j("safari"),safari:j("safari")&&!j("chrome"),mozilla:j("mozilla")&&!j("chrome")&&!j("safari")},l=function(){for(var a=document.getElementsByTagName("link"),b=0,c=a.length;c>b;b++)if((a[b].getAttribute("rel")||"").match(/\bicon\b/i))return a[b];return!1},m=function(){for(var a=document.getElementsByTagName("link"),b=document.getElementsByTagName("head")[0],c=0,d=a.length;d>c;c++){var e="undefined"!=typeof a[c];e&&(a[c].getAttribute("rel")||"").match(/\bicon\b/i)&&b.removeChild(a[c])}},n=function(){if(!c||!b){var a=l();b=a?a.getAttribute("href"):"/favicon.ico",c||(c=b)}return b},o=function(){return e||(e=document.createElement("canvas"),e.width=h,e.height=h),e},p=function(a){if(a){m();var b=document.createElement("link");b.type="image/x-icon",b.rel="icon",b.href=a,document.getElementsByTagName("head")[0].appendChild(b)}},q=function(a,b){if(!o().getContext||k.ie||k.safari||"force"===f.fallback)return r(a);var c=o().getContext("2d"),b=b||"#000000",e=n();d=document.createElement("img"),d.onload=function(){c.clearRect(0,0,h,h),c.drawImage(d,0,0,d.width,d.height,0,0,h,h),(a+"").length>0&&s(c,a,b),t()},!e.match(/^data/)&&f.crossOrigin&&(d.crossOrigin="anonymous"),d.src=e},r=function(a){if(f.fallback){var b=document.title;"("===b[0]&&(b=b.slice(b.indexOf(" "))),(a+"").length>0?document.title="("+a+") "+b:document.title=b}},s=function(a,b,c){"number"==typeof b&&b>99&&f.abbreviate&&(b=u(b));var d=(b+"").length-1,e=f.width*g+6*g*d,i=f.height*g,j=h-i,l=h-e-g,m=16*g,n=16*g,o=2*g;a.font=(k.webkit?"bold ":"")+f.font,a.fillStyle=f.background,a.strokeStyle=f.background,a.lineWidth=g,a.beginPath(),a.moveTo(l+o,j),a.quadraticCurveTo(l,j,l,j+o),a.lineTo(l,m-o),a.quadraticCurveTo(l,m,l+o,m),a.lineTo(n-o,m),a.quadraticCurveTo(n,m,n,m-o),a.lineTo(n,j+o),a.quadraticCurveTo(n,j,n-o,j),a.closePath(),a.fill(),a.beginPath(),a.strokeStyle="rgba(0,0,0,0.3)",a.moveTo(l+o/2,m),a.lineTo(n-o/2,m),a.stroke(),a.fillStyle=f.color,a.textAlign="right",a.textBaseline="top",a.fillText(b,2===g?29:15,k.mozilla?7*g:6*g)},t=function(){o().getContext&&p(o().toDataURL())},u=function(a){for(var b=[["G",1e9],["M",1e6],["k",1e3]],c=0;c=b[c][1]){a=v(a/b[c][1])+b[c][0];break}return a},v=function(a,b){var c=new Number(a);return c.toFixed(b)};a.setOptions=function(a){f={},a.colour&&(a.color=a.colour);for(var b in i)f[b]=a.hasOwnProperty(b)?a[b]:i[b];return this},a.setImage=function(a){return b=a,t(),this},a.setBubble=function(a,b){return a=a||"",q(a,b),this},a.reset=function(){b=c,p(c)},a.setOptions(i),"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module?module.exports=a:window.Tinycon=a}(); \ No newline at end of file From cdb71d792b2438a167a014e20093c92c3cfa94ce Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 13 Aug 2016 15:38:44 -0700 Subject: [PATCH 4/5] 0.6.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8876c09..01e9844 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tinycon", - "version": "0.6.5", + "version": "0.6.6", "description": "Add notification bubbles in the favicon", "author": "Tom Moor (http://tommoor.com)", "license": "MIT", From 83e7ef5765f1b29e1abeee6262f9b5b3f9242c24 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 13 Aug 2016 15:42:43 -0700 Subject: [PATCH 5/5] Removed version note from comment, its in the package.json --- tinycon.js | 1 - tinycon.min.js | 1 - 2 files changed, 2 deletions(-) diff --git a/tinycon.js b/tinycon.js index 85a9a63..a694923 100644 --- a/tinycon.js +++ b/tinycon.js @@ -3,7 +3,6 @@ * Tom Moor, http://tommoor.com * Copyright (c) 2015 Tom Moor * @license MIT Licensed - * @version 0.6.4 */ (function(){ diff --git a/tinycon.min.js b/tinycon.min.js index b39f400..1e533d8 100644 --- a/tinycon.min.js +++ b/tinycon.min.js @@ -3,6 +3,5 @@ * Tom Moor, http://tommoor.com * Copyright (c) 2015 Tom Moor * @license MIT Licensed - * @version 0.6.4 */ !function(){var a={},b=null,c=null,d=null,e=null,f={},g=Math.ceil(window.devicePixelRatio)||1,h=16*g,i={width:7,height:9,font:10*g+"px arial",color:"#ffffff",background:"#F03D25",fallback:!0,crossOrigin:!0,abbreviate:!0},j=function(){var a=navigator.userAgent.toLowerCase();return function(b){return-1!==a.indexOf(b)}}(),k={ie:j("trident"),chrome:j("chrome"),webkit:j("chrome")||j("safari"),safari:j("safari")&&!j("chrome"),mozilla:j("mozilla")&&!j("chrome")&&!j("safari")},l=function(){for(var a=document.getElementsByTagName("link"),b=0,c=a.length;c>b;b++)if((a[b].getAttribute("rel")||"").match(/\bicon\b/i))return a[b];return!1},m=function(){for(var a=document.getElementsByTagName("link"),b=document.getElementsByTagName("head")[0],c=0,d=a.length;d>c;c++){var e="undefined"!=typeof a[c];e&&(a[c].getAttribute("rel")||"").match(/\bicon\b/i)&&b.removeChild(a[c])}},n=function(){if(!c||!b){var a=l();b=a?a.getAttribute("href"):"/favicon.ico",c||(c=b)}return b},o=function(){return e||(e=document.createElement("canvas"),e.width=h,e.height=h),e},p=function(a){if(a){m();var b=document.createElement("link");b.type="image/x-icon",b.rel="icon",b.href=a,document.getElementsByTagName("head")[0].appendChild(b)}},q=function(a,b){if(!o().getContext||k.ie||k.safari||"force"===f.fallback)return r(a);var c=o().getContext("2d"),b=b||"#000000",e=n();d=document.createElement("img"),d.onload=function(){c.clearRect(0,0,h,h),c.drawImage(d,0,0,d.width,d.height,0,0,h,h),(a+"").length>0&&s(c,a,b),t()},!e.match(/^data/)&&f.crossOrigin&&(d.crossOrigin="anonymous"),d.src=e},r=function(a){if(f.fallback){var b=document.title;"("===b[0]&&(b=b.slice(b.indexOf(" "))),(a+"").length>0?document.title="("+a+") "+b:document.title=b}},s=function(a,b,c){"number"==typeof b&&b>99&&f.abbreviate&&(b=u(b));var d=(b+"").length-1,e=f.width*g+6*g*d,i=f.height*g,j=h-i,l=h-e-g,m=16*g,n=16*g,o=2*g;a.font=(k.webkit?"bold ":"")+f.font,a.fillStyle=f.background,a.strokeStyle=f.background,a.lineWidth=g,a.beginPath(),a.moveTo(l+o,j),a.quadraticCurveTo(l,j,l,j+o),a.lineTo(l,m-o),a.quadraticCurveTo(l,m,l+o,m),a.lineTo(n-o,m),a.quadraticCurveTo(n,m,n,m-o),a.lineTo(n,j+o),a.quadraticCurveTo(n,j,n-o,j),a.closePath(),a.fill(),a.beginPath(),a.strokeStyle="rgba(0,0,0,0.3)",a.moveTo(l+o/2,m),a.lineTo(n-o/2,m),a.stroke(),a.fillStyle=f.color,a.textAlign="right",a.textBaseline="top",a.fillText(b,2===g?29:15,k.mozilla?7*g:6*g)},t=function(){o().getContext&&p(o().toDataURL())},u=function(a){for(var b=[["G",1e9],["M",1e6],["k",1e3]],c=0;c=b[c][1]){a=v(a/b[c][1])+b[c][0];break}return a},v=function(a,b){var c=new Number(a);return c.toFixed(b)};a.setOptions=function(a){f={},a.colour&&(a.color=a.colour);for(var b in i)f[b]=a.hasOwnProperty(b)?a[b]:i[b];return this},a.setImage=function(a){return b=a,t(),this},a.setBubble=function(a,b){return a=a||"",q(a,b),this},a.reset=function(){b=c,p(c)},a.setOptions(i),"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module?module.exports=a:window.Tinycon=a}(); \ No newline at end of file