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/package.json b/package.json index ea7cfd8..6ef563c 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "tinycon", - "version": "0.6.5", + "version": "0.6.6", "description": "Add notification bubbles in the favicon", "author": "Tom Moor (http://tommoor.com)", - "main": "./tinycon.js", - "repository": { + "license": "MIT", + "main" : "./tinycon.js", + "repository" : { "type": "git", "url": "git://github.com/tommoor/tinycon.git" }, diff --git a/tinycon.js b/tinycon.js index 7a7e7a1..9345293 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(){ @@ -14,6 +13,7 @@ var faviconImage = null; var canvas = null; var options = {}; + // Chrome browsers with nonstandard zoom report fractional devicePixelRatio. var r = Math.ceil(window.devicePixelRatio) || 1; var size = 16 * r; var defaults = { diff --git a/tinycon.min.js b/tinycon.min.js index 1951952..1e533d8 100644 --- a/tinycon.min.js +++ b/tinycon.min.js @@ -1 +1,7 @@ -!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,shape:"square",rad:null},j=function(){var a=navigator.userAgent.toLowerCase();return function(b){return a.indexOf(b)!==-1}}(),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;b0&&s(c,a,b),v()},!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=w(b));var d=(b+"").length-1,e=f.height*g,i=f.width*g+6*g*d,j={len:d,width:i,height:e,top:h-e,left:h-i-g,bottom:16*g,right:16*g,cornerRad:2*g,rad:f.rad||Math.floor(i/2)};a.font=f.font,a.fillStyle=f.background,a.strokeStyle=f.background,"disc"===f.shape?t(a,b,c,j):u(a,b,c,j)},t=function(a,b,c,d){var e=h-d.rad,g=h-d.rad;a.beginPath(),a.arc(g,e,d.rad,0,2*Math.PI),a.fill(),a.fillStyle=f.color,a.textAlign="center",a.textBaseline="middle",a.fillText(b,g,e,2*d.rad-4)},u=function(a,b,c,d){a.beginPath(),a.moveTo(d.left+d.cornerRad,d.top),a.quadraticCurveTo(d.left,d.top,d.left,d.top+d.cornerRad),a.lineTo(d.left,d.bottom-d.cornerRad),a.quadraticCurveTo(d.left,d.bottom,d.left+d.cornerRad,d.bottom),a.lineTo(d.right-d.cornerRad,d.bottom),a.quadraticCurveTo(d.right,d.bottom,d.right,d.bottom-d.cornerRad),a.lineTo(d.right,top+d.cornerRad),a.quadraticCurveTo(d.right,d.top,d.right-d.cornerRad,d.top),a.closePath(),a.fill(),a.beginPath(),a.strokeStyle="rgba(0,0,0,0.3)",a.moveTo(d.left+d.cornerRad/2,d.bottom),a.lineTo(d.right-d.cornerRad/2,d.bottom),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)},v=function(){o().getContext&&p(o().toDataURL())},w=function(a){for(var b=[["G",1e9],["M",1e6],["k",1e3]],c=0;c=b[c][1]){a=x(a/b[c][1])+b[c][0];break}return a},x=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,v(),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 +/*! + * Tinycon - A small library for manipulating the Favicon + * Tom Moor, http://tommoor.com + * Copyright (c) 2015 Tom Moor + * @license MIT Licensed + */ +!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