From 8fdc5327e9cdde345a47a68710b5d98b71442adc Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 12 Feb 2014 15:10:22 +0100 Subject: [PATCH] refactor(grunt and caching): cache icon fonts, spritesmith and use icons from spritesmith for coins notification --- Gruntfile.js | 15 ++++------ public/css/alerts.styl | 33 +++------------------- public/js/controllers/notificationCtrl.js | 1 - public/js/services/notificationServices.js | 11 +++----- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ea26d68449..9186a9e800 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -56,7 +56,8 @@ module.exports = function(grunt) { build: { files: [ {expand: true, cwd: 'public/', src: 'favicon.ico', dest: 'build/'}, - {expand: true, cwd: 'public/', src: 'bower_components/habitrpg-shared/dist/spritesmith-*.png', dest: 'build/'} + {expand: true, cwd: 'public/', src: 'bower_components/habitrpg-shared/dist/spritesmith.png', dest: 'build/'}, + {expand: true, cwd: 'public/', src: 'bower_components/bootstrap/dist/fonts/*', dest: 'build/'} ] } }, @@ -69,18 +70,14 @@ module.exports = function(grunt) { }, src: [ 'build/*.js', 'build/*.css', 'build/favicon.ico', - 'build/bower_components/bootstrap/docs/assets/css/*.css', - 'build/bower_components/habitrpg-shared/dist/*.css' + 'build/bower_components/habitrpg-shared/dist/*.png', + 'build/bower_components/bootstrap/dist/fonts/*' ], - dest: 'make-sure-i-do-not-exist' + dest: 'build/*.css' } }, - nodemon: { - dev: { - ignoredFiles: ['public/*', 'Gruntfile.js', 'CHANGELOG.md', 'views/*', 'build/*', '.idea*', '.git*', '*.log'] - } - }, + nodemon: { dev: {} }, watch: { dev: { diff --git a/public/css/alerts.styl b/public/css/alerts.styl index 1520f695f8..40a7b8910b 100644 --- a/public/css/alerts.styl +++ b/public/css/alerts.styl @@ -33,6 +33,10 @@ alert-sm-mixin() .alert alert-sm-mixin() + .notification-icon + transform: scale(0.8) + + // variables gpColor = #FBEFC0 @@ -95,35 +99,6 @@ borderDarken = 20% border-color: darken(dropColor,borderDarken) color: dropText -// alert icons - -.icon-gold - background: url("/bower_components/habitrpg-shared/img/coin_single_gold.png") no-repeat - background-position: center center - background-size: 18px - width: 14px - height: 14px - display: inline-block - vertical-align: middle - -.icon-silver - background: url("/bower_components/habitrpg-shared/img/coin_single_silver.png") no-repeat - background-position: center center - background-size: 18px - width: 14px - height: 14px - display: inline-block - vertical-align: middle - -.icon-death - background: url("/bower_components/habitrpg-shared/img/sprites/dead.png") no-repeat - background-position: center center - background-size: 14px - width: 14px - height: 14px - display: inline-block - vertical-align: middle - .undo-button z-index: 3000 position:absolute diff --git a/public/js/controllers/notificationCtrl.js b/public/js/controllers/notificationCtrl.js index 8633c16fc5..1650a36f25 100644 --- a/public/js/controllers/notificationCtrl.js +++ b/public/js/controllers/notificationCtrl.js @@ -94,7 +94,6 @@ habitrpg.controller('NotificationCtrl', $rootScope.$watch('user.items.' + watched, function(before, after){ if (after == before) return; if (+after < +before) { - Notification.death(); //don't want to day "lost a head" if (watched === 'head') watched = 'helm'; Notification.text('Lost GP, 1 LVL, ' + watched); diff --git a/public/js/services/notificationServices.js b/public/js/services/notificationServices.js index 02f92bbc83..21cb09a306 100644 --- a/public/js/services/notificationServices.js +++ b/public/js/services/notificationServices.js @@ -10,7 +10,7 @@ angular.module("notificationServices", []) top_offset: 20, align: 'right', //('left', 'right', or 'center') width: 250, //(integer, or 'auto') - delay: (type=='error') ? 0 : 7000, + delay: (type=='error') ? 0 : 0, allow_dismiss: true, stackup_spacing: 10 // spacing between consecutive stacecked growls. }); @@ -25,11 +25,11 @@ angular.module("notificationServices", []) gold = Math.floor(absolute); silver = Math.floor((absolute - gold) * 100); if (gold && silver > 0) { - return "" + gold + " " + silver + " "; + return "" + gold + " " + silver + " "; } else if (gold > 0) { - return "" + gold + " "; + return "" + gold + " "; } else if (silver > 0) { - return "" + silver + " "; + return "" + silver + " "; } }; @@ -60,9 +60,6 @@ angular.module("notificationServices", []) lvl: function(){ growl(' ' + window.env.t('levelUp'), 'lvl'); }, - death: function(){ - growl(" " + window.env.t('respawn'), "death"); - }, error: function(error){ growl("  " + error, "danger"); },