diff --git a/app/assets/images/default-favicon.ico b/app/assets/images/default-favicon.ico index d20ae8eed..cab552a23 100644 Binary files a/app/assets/images/default-favicon.ico and b/app/assets/images/default-favicon.ico differ diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico index db5a23d75..ac54b34b9 100644 Binary files a/app/assets/images/favicon.ico and b/app/assets/images/favicon.ico differ diff --git a/app/assets/javascripts/external/jquery.faviconNotify.js b/app/assets/javascripts/external/jquery.faviconNotify.js index e0c370b9d..984bd2dd0 100644 --- a/app/assets/javascripts/external/jquery.faviconNotify.js +++ b/app/assets/javascripts/external/jquery.faviconNotify.js @@ -1,226 +1,53 @@ /** - * jQuery Favicon Notify - * - * Updates the favicon to notify the user of changes. In the original tests I - * had an embedded font collection to allow any charachers - I decided that the - * ~130Kb and added complexity was overkill. As such it now uses a manual glyph - * set meaning that only numerical notifications are possible. - * - * Dual licensed under the MIT and GPL licenses: - * - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * @author David King - * @copyright Copyright (c) 2011 + - * @url oodavid.com - */ +* jQuery Favicon Notify +* +* Updates the favicon with a number to notify the user of changes. +* +* iconUrl: Url of favicon image or icon +* count: Integer count to place above favicon +* +* $.faviconNotify(iconUrl, count) +*/ (function($){ - var canvas; - var bg = '#000000'; - var fg = '#FFFFFF'; - var pos = 'br'; - $.faviconNotify = function(icon, num, myPos, myBg, myFg){ - // Default the positions - myPos = myPos || pos; - myFg = myFg || fg; - myBg = myBg || bg; - // Create a canvas if we need one - canvas = canvas || $('')[0]; - if(canvas.getContext){ - // Load the icon - $('').load(function(e){ - // Load the icon into the canvas - canvas.height = canvas.width = 16; - var ctx = canvas.getContext('2d'); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.drawImage(this, 0, 0); - // We gots num? - if(num !== undefined){ - num = parseFloat(num, 10); - // Convert the num into a glyphs array - var myGlyphs = []; - if(num > 99){ - myGlyphs.push(glyphs['LOTS']); - } else { - num = num.toString().split(''); - $.each(num, function(k,v){ - myGlyphs.push(glyphs[v]); - }); - } - if(num>0) { - // Merge the glyphs together - var combined = []; - var glyphHeight = myGlyphs[0].length; - $.each(myGlyphs, function(k,v){ - for(y=0; y').attr('href', canvas.toDataURL('image/png'))); - }).attr('src', icon) - } - }; - var glyphs = { - '0': [ - ' --- ', - ' -@@@- ', - '-@---@-', - '-@- -@-', - '-@- -@-', - '-@- -@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '1': [ - ' - ', - ' -@- ', - '-@@- ', - ' -@- ', - ' -@- ', - ' -@- ', - ' -@- ', - '-@@@-', - ' --- ' ], - '2': [ - ' --- ', - ' -@@@- ', - '-@---@-', - ' - --@-', - ' -@@- ', - ' -@-- ', - '-@---- ', - '-@@@@@-', - ' ----- ' ], - '3': [ - ' --- ', - ' -@@@- ', - '-@---@-', - ' - --@-', - ' -@@- ', - ' - --@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '4': [ - ' -- ', - ' -@@-', - ' -@-@-', - ' -@--@-', - '-@---@-', - '-@@@@@-', - ' ----@-', - ' -@-', - ' - ' ], - '5': [ - ' ----- ', - '-@@@@@-', - '-@---- ', - '-@--- ', - '-@@@@- ', - ' ----@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '6': [ - ' --- ', - ' -@@@- ', - '-@---@-', - '-@---- ', - '-@@@@- ', - '-@---@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '7': [ - ' ----- ', - '-@@@@@-', - ' ----@-', - ' -@- ', - ' -@- ', - ' -@- ', - ' -@- ', - ' -@- ', - ' - ' ], - '8': [ - ' --- ', - ' -@@@- ', - '-@---@-', - '-@---@-', - ' -@@@- ', - '-@---@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '9': [ - ' --- ', - ' -@@@- ', - '-@---@-', - '-@---@-', - ' -@@@@-', - ' ----@-', - '-@---@-', - ' -@@@- ', - ' --- ' ], - '!': [ - ' - ', - '-@-', - '-@-', - '-@-', - '-@-', - '-@-', - ' - ', - '-@-', - ' - ' ], - '.': [ - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' - ', - '-@-', - ' - ' ], - 'LOTS': [ - ' - -- --- -- ', - '-@- -@@-@@@--@@-', - '-@--@--@-@--@- ', - '-@--@--@-@--@- ', - '-@--@--@-@- -@- ', - '-@--@--@-@- -@-', - '-@--@--@-@----@-', - '-@@@-@@--@-@@@- ', - ' --- -- - --- ' - ] - }; + $.faviconNotify = function(iconUrl, count){ + var canvas = canvas || $('')[0], + img = $('')[0], + multiplier, fontSize, context, xOffset, yOffset; + + if (canvas.getContext) { + if (count < 1) { count = '' } + else if (count < 10) { count = ' ' + count } + else if (count > 99) { count = '99' } + + img.onload = function () { + canvas.height = canvas.width = this.width; + multiplier = (this.width / 16); + + fontSize = multiplier * 11; + xOffset = multiplier; + yOffset = multiplier * 11; + + context = canvas.getContext('2d'); + context.drawImage(this, 0, 0); + context.font = 'bold ' + fontSize + 'px "helvetica", sans-serif'; + + context.fillStyle = '#FFF'; + context.fillText(count, xOffset, yOffset); + context.fillText(count, xOffset + 2, yOffset); + context.fillText(count, xOffset, yOffset + 2); + context.fillText(count, xOffset + 2, yOffset + 2); + + context.fillStyle = '#000'; + context.fillText(count, xOffset + 1, yOffset + 1); + + $('link[rel$=icon]').remove(); + $('head').append( + $('').attr( + 'href', canvas.toDataURL('image/png') + ) + ); + }; + img.src = iconUrl; + } + }; })(jQuery);