From 4ce59c2f82b0a75f3e164faab5a0b2b0dc9df3a8 Mon Sep 17 00:00:00 2001 From: Marco Rinck Date: Tue, 19 Nov 2013 22:27:33 +0100 Subject: [PATCH 001/169] updated doc --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 095036a..d9589ec 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ present, you only have to provide keys as messages, angular-translate will trans * updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE) * new option: only display unique messages, which is the new default, disable to allow same message more than once (BREAKING CHANGE) -* new option: allow html tags in messages, default is off you need to +* new option: allow html tags in messages, default is off, allows to use HTML tags in messages **0.3.1** - 1st Oct 2013 @@ -33,16 +33,6 @@ present, you only have to provide keys as messages, angular-translate will trans * adding css animations support via ngAnimate (for angularJS >= 1.2) * ability to configure server message keys -**0.2.0** - 22nd Sept 2013 - -* reworking, bugfixing and documenting handling of server sent messages/notifications -* externalizing css styles of growl class -* provide minified versions of js and css files in build folder - -**0.1.3** - 20th Sept 2013 - -* introducing ttl config option, fixes #2 - ##Installation You can install angular-growl with bower: From 50e046899481bc80c4500facf167362b7bff1e5b Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:04:15 +0100 Subject: [PATCH 002/169] Do not require an old angular version but anything >=1.2.0 --- bower.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index d91288b..f5c72d8 100644 --- a/bower.json +++ b/bower.json @@ -22,9 +22,9 @@ ".gitignore" ], "dependencies": { - "angular": "1.2.1" + "angular": ">=1.2.1" }, "devDependencies": { - "angular-mocks": "1.2.1" + "angular-mocks": ">=1.2.1" } -} \ No newline at end of file +} From 0350362662966e96275d60f952dd5a0f94346ec1 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:12:23 +0100 Subject: [PATCH 003/169] Remove ngSanitize dependency by using --- README.md | 6 +-- bower.json | 2 +- build/angular-growl.js | 8 ++-- build/angular-growl.min.css | 4 +- build/angular-growl.min.js | 6 +-- demo/demo.html | 92 ++++++++++++++++--------------------- package.json | 3 +- src/growlDirective.js | 3 +- 8 files changed, 55 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 095036a..1bca525 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ Alternatively you can download the files in the [build folder](build/) manually - @@ -169,11 +168,8 @@ app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { Turn this on to be able to display html tags in messages, default behaviour is to NOT display HTML. -For this to work, you have to declare a dependency to "ngSanitize" (and load the extra javascript) in your own application -module! - ````javascript -var app = angular.module('myApp', ['angular-growl', 'ngSanitize']); +var app = angular.module('myApp', ['angular-growl']); app.config(['growlProvider', function(growlProvider) { growlProvider.globalEnableHtml(true); diff --git a/bower.json b/bower.json index f5c72d8..45163cf 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "author": "Marco Rinck", + "author": ["Marco Rinck", "Jan Stevens"], "name": "angular-growl", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "version": "0.4.0", diff --git a/build/angular-growl.js b/build/angular-growl.js index e461296..286f5b0 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,12 +1,13 @@ /** - * angular-growl - v0.4.0 - 2013-11-19 + * angular-growl - v0.4.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2013 Marco Rinck; Licensed MIT + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ angular.module('angular-growl', []); angular.module('angular-growl').directive('growl', [ '$rootScope', - function ($rootScope) { + '$sce', + function ($rootScope, $sce) { 'use strict'; return { restrict: 'A', @@ -21,6 +22,7 @@ angular.module('angular-growl').directive('growl', [ var onlyUnique = growl.onlyUnique(); $scope.messages = []; function addMessage(message) { + message.text = $sce.trustAsHtml(message.text); $scope.messages.push(message); if (message.ttl && message.ttl !== -1) { $timeout(function () { diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index e1ed842..0b97226 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,7 +1,7 @@ /** - * angular-growl - v0.4.0 - 2013-11-19 + * angular-growl - v0.4.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2013 Marco Rinck; Licensed MIT + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ .growl{position:fixed;top:10px;right:10px;float:right;width:250px}.growl-item.ng-enter,.growl-item.ng-leave{-webkit-transition:.5s linear all;-moz-transition:.5s linear all;-o-transition:.5s linear all;transition:.5s linear all}.growl-item.ng-enter,.growl-item.ng-leave.ng-leave-active{opacity:0}.growl-item.ng-leave,.growl-item.ng-enter.ng-enter-active{opacity:1} \ No newline at end of file diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 83798c5..78e961d 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** - * angular-growl - v0.4.0 - 2013-11-19 + * angular-growl - v0.4.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2013 Marco Rinck; Licensed MIT + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope",function(a){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(b,c,d){function e(a){b.messages.push(a),a.ttl&&-1!==a.ttl&&c(function(){b.deleteMessage(a)},a.ttl)}var f=d.onlyUnique();b.messages=[],a.$on("growlMessage",function(a,c){var d;f?(angular.forEach(b.messages,function(a){c.text===a.text&&c.severity===a.severity&&(d=!0)}),d||e(c)):e(c)}),b.deleteMessage=function(a){var c=b.messages.indexOf(a);c>-1&&b.messages.splice(c,1)},b.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,g){function h(a){p&&(a.text=p(a.text)),c.$broadcast("growlMessage",a)}function i(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a,enableHtml:g.enableHtml||b},h(f)}function j(a,b){i(a,b,"warn")}function k(a,b){i(a,b,"error")}function l(a,b){i(a,b,"info")}function m(a,b){i(a,b,"success")}function n(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}i(c[d],void 0,f)}}function o(){return f}var p;try{p=g("translate")}catch(q){}return{addWarnMessage:j,addErrorMessage:k,addInfoMessage:l,addSuccessMessage:m,addServerMessages:n,onlyUnique:o}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,g){function h(a){p&&(a.text=p(a.text)),c.$broadcast("growlMessage",a)}function i(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a,enableHtml:g.enableHtml||b},h(f)}function j(a,b){i(a,b,"warn")}function k(a,b){i(a,b,"error")}function l(a,b){i(a,b,"info")}function m(a,b){i(a,b,"success")}function n(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}i(c[d],void 0,f)}}function o(){return f}var p;try{p=g("translate")}catch(q){}return{addWarnMessage:j,addErrorMessage:k,addInfoMessage:l,addSuccessMessage:m,addServerMessages:n,onlyUnique:o}}]}); \ No newline at end of file diff --git a/demo/demo.html b/demo/demo.html index ba84da0..5f49841 100644 --- a/demo/demo.html +++ b/demo/demo.html @@ -1,79 +1,65 @@ - + angular-growl demo - - - - - - -
-

angular-growl Demo site

- -
-
+ + +
+

angular-growl Demo site

+
+
+ +
- -
- - - - -
- - - - - - +
+ + + +
-
- -
- +
+ +
+
- -
- - - \ No newline at end of file + + diff --git a/package.json b/package.json index 3951be2..de1bf9e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "url": "https://github.com/marcorinck/angular-growl" }, "author": { - "name": "Marco Rinck" + "name": "Marco Rinck", + "name": "Jan Stevens" }, "license": "MIT", "devDependencies": { diff --git a/src/growlDirective.js b/src/growlDirective.js index edad549..84bb424 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -1,4 +1,4 @@ -angular.module("angular-growl").directive("growl", ["$rootScope", function ($rootScope) { +angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", function ($rootScope, $sce) { "use strict"; return { @@ -20,6 +20,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", function ($roo $scope.messages = []; function addMessage(message) { + message.text = $sce.trustAsHtml(message.text); $scope.messages.push(message); if (message.ttl && message.ttl !== -1) { From 51f28743c69ff8b2cd365f33ad7e356fd2c6eaa1 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:14:51 +0100 Subject: [PATCH 004/169] Force notifcations to appear in foreground --- src/growl.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/growl.css b/src/growl.css index 76bda49..9fab114 100644 --- a/src/growl.css +++ b/src/growl.css @@ -4,6 +4,7 @@ right: 10px; float: right; width: 250px; + z-index: 9999; } .growl-item.ng-enter, @@ -22,4 +23,4 @@ .growl-item.ng-enter.ng-enter-active { opacity:1; -} \ No newline at end of file +} From b8377ac9fc9ea96d6fbe946de3d60d407b202a41 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:18:04 +0100 Subject: [PATCH 005/169] Changed commands to be bit shorter --- build/angular-growl.js | 16 ++++++++-------- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 2 +- demo/demo.js | 12 +++++++----- src/growlFactory.js | 16 ++++++++-------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index 286f5b0..1271e38 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -133,16 +133,16 @@ angular.module('angular-growl').provider('growl', function () { }; broadcastMessage(message); } - function addWarnMessage(text, config) { + function warning(text, config) { sendMessage(text, config, 'warn'); } - function addErrorMessage(text, config) { + function error(text, config) { sendMessage(text, config, 'error'); } - function addInfoMessage(text, config) { + function info(text, config) { sendMessage(text, config, 'info'); } - function addSuccessMessage(text, config) { + function success(text, config) { sendMessage(text, config, 'success'); } function addServerMessages(messages) { @@ -173,10 +173,10 @@ angular.module('angular-growl').provider('growl', function () { return _onlyUniqueMessages; } return { - addWarnMessage: addWarnMessage, - addErrorMessage: addErrorMessage, - addInfoMessage: addInfoMessage, - addSuccessMessage: addSuccessMessage, + warning: warning, + error: error, + info: info, + success: success, addServerMessages: addServerMessages, onlyUnique: onlyUnique }; diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 0b97226..f9bf5f0 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -4,4 +4,4 @@ * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -.growl{position:fixed;top:10px;right:10px;float:right;width:250px}.growl-item.ng-enter,.growl-item.ng-leave{-webkit-transition:.5s linear all;-moz-transition:.5s linear all;-o-transition:.5s linear all;transition:.5s linear all}.growl-item.ng-enter,.growl-item.ng-leave.ng-leave-active{opacity:0}.growl-item.ng-leave,.growl-item.ng-enter.ng-enter-active{opacity:1} \ No newline at end of file +.growl{position:fixed;top:10px;right:10px;float:right;width:250px;z-index:9999}.growl-item.ng-enter,.growl-item.ng-leave{-webkit-transition:.5s linear all;-moz-transition:.5s linear all;-o-transition:.5s linear all;transition:.5s linear all}.growl-item.ng-enter,.growl-item.ng-leave.ng-leave-active{opacity:0}.growl-item.ng-leave,.growl-item.ng-enter.ng-enter-active{opacity:1} \ No newline at end of file diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 78e961d..f52f7fd 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -3,4 +3,4 @@ * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,g){function h(a){p&&(a.text=p(a.text)),c.$broadcast("growlMessage",a)}function i(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a,enableHtml:g.enableHtml||b},h(f)}function j(a,b){i(a,b,"warn")}function k(a,b){i(a,b,"error")}function l(a,b){i(a,b,"info")}function m(a,b){i(a,b,"success")}function n(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}i(c[d],void 0,f)}}function o(){return f}var p;try{p=g("translate")}catch(q){}return{addWarnMessage:j,addErrorMessage:k,addInfoMessage:l,addSuccessMessage:m,addServerMessages:n,onlyUnique:o}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,g){function h(a){p&&(a.text=p(a.text)),c.$broadcast("growlMessage",a)}function i(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a,enableHtml:g.enableHtml||b},h(f)}function j(a,b){i(a,b,"warn")}function k(a,b){i(a,b,"error")}function l(a,b){i(a,b,"info")}function m(a,b){i(a,b,"success")}function n(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}i(c[d],void 0,f)}}function o(){return f}var p;try{p=g("translate")}catch(q){}return{warning:j,error:k,info:l,success:m,addServerMessages:n,onlyUnique:o}}]}); \ No newline at end of file diff --git a/demo/demo.js b/demo/demo.js index 8af3ea6..d4fce66 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -1,3 +1,5 @@ +'use strict'; + var app = angular.module("demo", ["angular-growl", "ngAnimate", "ngMockE2E"]); app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvider) { @@ -35,19 +37,19 @@ app.controller("demoCtrl", function demoCtrl($scope, growl, $http) { } if ($scope.alertType === "success") { - growl.addSuccessMessage($scope.message, config); + growl.success($scope.message, config); } if ($scope.alertType === "warn") { - growl.addWarnMessage($scope.message, config); + growl.warning($scope.message, config); } if ($scope.alertType === "info") { - growl.addInfoMessage($scope.message, config); + growl.info($scope.message, config); } if ($scope.alertType === "error") { - growl.addErrorMessage($scope.message, config); + growl.error($scope.message, config); } }; @@ -56,4 +58,4 @@ app.controller("demoCtrl", function demoCtrl($scope, growl, $http) { console.log(data); }); }; -}); \ No newline at end of file +}); diff --git a/src/growlFactory.js b/src/growlFactory.js index d3e5329..40a0efa 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -120,7 +120,7 @@ angular.module("angular-growl").provider("growl", function() { * @param {string} text * @param {{ttl: number}} config */ - function addWarnMessage(text, config) { + function warning(text, config) { sendMessage(text, config, "warn"); } @@ -130,7 +130,7 @@ angular.module("angular-growl").provider("growl", function() { * @param {string} text * @param {{ttl: number}} config */ - function addErrorMessage(text, config) { + function error(text, config) { sendMessage(text, config, "error"); } @@ -140,7 +140,7 @@ angular.module("angular-growl").provider("growl", function() { * @param {string} text * @param {{ttl: number}} config */ - function addInfoMessage(text, config) { + function info(text, config) { sendMessage(text, config, "info"); } @@ -150,7 +150,7 @@ angular.module("angular-growl").provider("growl", function() { * @param {string} text * @param {{ttl: number}} config */ - function addSuccessMessage(text, config) { + function success(text, config) { sendMessage(text, config, "success"); } @@ -190,10 +190,10 @@ angular.module("angular-growl").provider("growl", function() { } return { - addWarnMessage: addWarnMessage, - addErrorMessage: addErrorMessage, - addInfoMessage: addInfoMessage, - addSuccessMessage: addSuccessMessage, + warning: warning, + error: error, + info: info, + success: success, addServerMessages: addServerMessages, onlyUnique: onlyUnique }; From adacd6cded49bb2813ac9bdd37b049335a06e514 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:19:56 +0100 Subject: [PATCH 006/169] Added uppercase of grunt file --- demo/demo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/demo.js b/demo/demo.js index d4fce66..6fa8da7 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; var app = angular.module("demo", ["angular-growl", "ngAnimate", "ngMockE2E"]); From 8e7df3896c2a55ebc94027eba6e72bb5520d3dea Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:20:27 +0100 Subject: [PATCH 007/169] bower.json should not ignore itself --- bower.json | 1 - 1 file changed, 1 deletion(-) diff --git a/bower.json b/bower.json index 45163cf..502d015 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,6 @@ "package.json", "gruntfile.js", "karma.conf.js", - "bower.json", "demo", ".gitignore" ], From 22d6992278efe41dec8e3ae9a245ebf105073ceb Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:21:48 +0100 Subject: [PATCH 008/169] Updated bower version, made sure that the css is also included in main --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 502d015..2f12d2f 100644 --- a/bower.json +++ b/bower.json @@ -2,14 +2,14 @@ "author": ["Marco Rinck", "Jan Stevens"], "name": "angular-growl", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", - "version": "0.4.0", + "version": "0.4.1", "homepage": "https://github.com/marcorinck/angular-growl", "repository": { "type": "git", "url": "https://github.com/marcorinck/angular-growl" }, "license": "MIT", - "main": "./build/angular-growl.js", + "main": ["./build/angular-growl.js", "./build/angular-growl.min.css"], "ignore": [ "src", "test", From 48f9ba6711f1566e79d3c43fbec35216afa79d1c Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:30:22 +0100 Subject: [PATCH 009/169] Updated readme and bower.json to show the version change --- README.md | 49 ++++++++++++++++++++----------------- bower.json | 2 +- build/angular-growl.js | 2 +- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 2 +- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 1bca525..d434392 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ present, you only have to provide keys as messages, angular-translate will trans ##Changelog +**0.5.0** - 18 Mar 2014 +* Manually merged some pull requests from the original branch +* Fixed bower.json file to include itself and the css file +* [BREAK] changed the function names to add growl notifications to be a shorter (success, info, warning, error VS addSuccessMessage, addInfoMessage...) + **0.4.0** - 19th Nov 2013 * updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE) @@ -85,10 +90,10 @@ Just let angular inject the growl Factory into your code and call the 4 function ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addWarnMessage("This adds a warn message"); - growl.addInfoMessage("This adds a info message"); - growl.addSuccessMessage("This adds a success message"); - growl.addErrorMessage("This adds a error message"); + growl.warning("This adds a warn message"); + growl.info("This adds a info message"); + growl.success("This adds a success message"); + growl.error("This adds a error message"); } }]); ```` @@ -107,9 +112,7 @@ app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { ##Configuration -###Only unique messages - -* Default: true +###Only unique messages [default: true] Accept only unique messages as a new message. If a message is already displayed (text and severity are the same) then this message will not be added to the displayed message list. Set to false, to always display all messages regardless if they @@ -123,12 +126,9 @@ app.config(['growlProvider', function(growlProvider) { }]); ```` -###Automatic closing of notifications (timeout, ttl) +###Automatic closing of notifications (timeout, ttl) [default: none] -* Default: none (all messages need to be closed manually by the user.) - -However, you can configure a global timeout (TTL) after which notifications should be automatically closed. To do -this, you have to configure this during config phase of angular bootstrap like this: +However, you can configure a global timeout (TTL) after which notifications should be automatically closed. To do this, you have to configure this during config phase of angular bootstrap like this: ````javascript var app = angular.module('myApp', ['angular-growl']); @@ -145,7 +145,7 @@ You can override TTL generally for every single message if you want: ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addWarnMessage("Override global ttl setting", {ttl: 10000}); + growl.warning("Override global ttl setting", {ttl: 10000}); } }]); ```` @@ -157,16 +157,14 @@ If you have set a global TTL, you can disable automatic closing of single notifi ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addWarnMessage("this will not be closed automatically even when a global ttl is set", {ttl: -1}); + growl.warning("this will not be closed automatically even when a global ttl is set", {ttl: -1}); } }]); ```` -###Allow HTML in messages - -* Default: false +###Allow HTML in messages [default: false] -Turn this on to be able to display html tags in messages, default behaviour is to NOT display HTML. +Turn this on to be able to display html tags in messages, default behaviour is to NOT display HTML. It uses `$sce` service from angular to mark the html as trusted. ````javascript var app = angular.module('myApp', ['angular-growl']); @@ -181,16 +179,14 @@ You can override the global option and allow HTML tags in single messages too: ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addWarnMessage("This is a HTML message", {enableHtml: true}); + growl.warning("This is a HTML message", {enableHtml: true}); } }]); ```` ###Animations -Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing -them. All you have to do is load the angular-animate.js provided by angularJS and add **ngAnimate** to your applications -dependency list: +Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing them. All you have to do is load the angular-animate.js provided by angularJS and add **ngAnimate** to your applications dependency list: ````html @@ -269,3 +265,12 @@ app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvi ```` Server messages will be created with default TTL. + +# License +Copyright (C) 2014 Marco Rinck + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bower.json b/bower.json index 2f12d2f..c2a957f 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "author": ["Marco Rinck", "Jan Stevens"], "name": "angular-growl", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", - "version": "0.4.1", + "version": "0.5.0", "homepage": "https://github.com/marcorinck/angular-growl", "repository": { "type": "git", diff --git a/build/angular-growl.js b/build/angular-growl.js index 1271e38..5826ac1 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,5 +1,5 @@ /** - * angular-growl - v0.4.0 - 2014-03-18 + * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index f9bf5f0..5280b6e 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,5 +1,5 @@ /** - * angular-growl - v0.4.0 - 2014-03-18 + * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index f52f7fd..c616c66 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,5 +1,5 @@ /** - * angular-growl - v0.4.0 - 2014-03-18 + * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ From 04002cdb29b9a00750ae29c9ad86e7c3bf4273b2 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:40:50 +0100 Subject: [PATCH 010/169] Added a option to hide the close button on the messages --- README.md | 21 +++++++++++++++++++++ src/growlDirective.js | 2 +- src/growlFactory.js | 15 +++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d434392..289a2f2 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,27 @@ app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { }]); ```` +###Disable close button on messages [default: false] +Turn this on to hide the close button on messages, default behaviour is to display the close button. + +```javascript +var app = angular.module('myApp', ['angular-growl']); + +app.config(['growlProvider', function(growlProvider) { + growlProvider.globalDisableCloseButton(true); +}]); +``` + +You can override the global option and hide the close button in single messages too: + + ````javascript + app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { + $scope.addSpecialWarnMessage = function() { + growl.addWarnMessage("This is a message without a close button", {disableCloseButton: true}); + } + }]); + ```` + ###Animations Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing them. All you have to do is load the angular-animate.js provided by angularJS and add **ngAnimate** to your applications dependency list: diff --git a/src/growlDirective.js b/src/growlDirective.js index 84bb424..69de25b 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -5,7 +5,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", functi restrict: 'A', template: '
' + '
' + - ' ' + + ' ' + '
' + '
' + '
' + diff --git a/src/growlFactory.js b/src/growlFactory.js index 40a0efa..078fe79 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -6,7 +6,8 @@ angular.module("angular-growl").provider("growl", function() { _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', - _onlyUniqueMessages = true; + _onlyUniqueMessages = true, + _disableCloseButton = false; /** * set a global timeout (time to live) after which messages will be automatically closed @@ -26,6 +27,15 @@ angular.module("angular-growl").provider("growl", function() { _enableHtml = enableHtml; }; + /** + * set whether the close button should be displayed (default) or hidden + * + * @param {bool} disableCloseButton true to hide close button on all messages + */ + this.globalDisableCloseButton = function (disableCloseButton) { + _disableCloseButton = disableCloseButton; + }; + /** * sets the key in $http response the serverMessagesInterecptor is looking for server-sent messages, value of key * needs to be an array of objects @@ -108,7 +118,8 @@ angular.module("angular-growl").provider("growl", function() { text: text, severity: severity, ttl: _config.ttl || _ttl, - enableHtml: _config.enableHtml || _enableHtml + enableHtml: _config.enableHtml || _enableHtml, + disableCloseButton: _config.disableCloseButton || _disableCloseButton }; broadcastMessage(message); From be41db15a128dafc51cb42e9eb15cf711551d0b2 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:41:30 +0100 Subject: [PATCH 011/169] Added the build files --- bower.json | 2 +- build/angular-growl.js | 12 ++++++++---- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index c2a957f..e7bb2c3 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "author": ["Marco Rinck", "Jan Stevens"], + "author": "Marco Rinck", "name": "angular-growl", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "version": "0.5.0", diff --git a/build/angular-growl.js b/build/angular-growl.js index 5826ac1..874d798 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,7 +1,7 @@ /** * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT + * Copyright (c) 2014 Marco Rinck; Licensed MIT */ angular.module('angular-growl', []); angular.module('angular-growl').directive('growl', [ @@ -11,7 +11,7 @@ angular.module('angular-growl').directive('growl', [ 'use strict'; return { restrict: 'A', - template: '
' + '\t
' + '\t\t' + '
' + '
' + '
' + '
' + '\t
' + '
', + template: '
' + '\t
' + '\t\t' + '
' + '
' + '
' + '
' + '\t
' + '
', replace: false, scope: true, controller: [ @@ -67,13 +67,16 @@ angular.module('angular-growl').directive('growl', [ ]); angular.module('angular-growl').provider('growl', function () { 'use strict'; - var _ttl = null, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true; + var _ttl = null, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _disableCloseButton = false; this.globalTimeToLive = function (ttl) { _ttl = ttl; }; this.globalEnableHtml = function (enableHtml) { _enableHtml = enableHtml; }; + this.globalDisableCloseButton = function (disableCloseButton) { + _disableCloseButton = disableCloseButton; + }; this.messagesKey = function (messagesKey) { _messagesKey = messagesKey; }; @@ -129,7 +132,8 @@ angular.module('angular-growl').provider('growl', function () { text: text, severity: severity, ttl: _config.ttl || _ttl, - enableHtml: _config.enableHtml || _enableHtml + enableHtml: _config.enableHtml || _enableHtml, + disableCloseButton: _config.disableCloseButton || _disableCloseButton }; broadcastMessage(message); } diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 5280b6e..b586211 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,7 +1,7 @@ /** * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT + * Copyright (c) 2014 Marco Rinck; Licensed MIT */ .growl{position:fixed;top:10px;right:10px;float:right;width:250px;z-index:9999}.growl-item.ng-enter,.growl-item.ng-leave{-webkit-transition:.5s linear all;-moz-transition:.5s linear all;-o-transition:.5s linear all;transition:.5s linear all}.growl-item.ng-enter,.growl-item.ng-leave.ng-leave-active{opacity:0}.growl-item.ng-leave,.growl-item.ng-enter.ng-enter-active{opacity:1} \ No newline at end of file diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index c616c66..b8fb6d4 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** * angular-growl - v0.5.0 - 2014-03-18 * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT + * Copyright (c) 2014 Marco Rinck; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,g){function h(a){p&&(a.text=p(a.text)),c.$broadcast("growlMessage",a)}function i(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a,enableHtml:g.enableHtml||b},h(f)}function j(a,b){i(a,b,"warn")}function k(a,b){i(a,b,"error")}function l(a,b){i(a,b,"info")}function m(a,b){i(a,b,"success")}function n(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}i(c[d],void 0,f)}}function o(){return f}var p;try{p=g("translate")}catch(q){}return{warning:j,error:k,info:l,success:m,addServerMessages:n,onlyUnique:o}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file From 54cb2be82cd78225b44e2638be211e8a2152d91a Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:44:29 +0100 Subject: [PATCH 012/169] Added a list of contributers in the readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 289a2f2..0f3bd7e 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ You can override the global option and hide the close button in single messages } }]); ```` - + ###Animations Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing them. All you have to do is load the angular-animate.js provided by angularJS and add **ngAnimate** to your applications dependency list: @@ -287,6 +287,15 @@ app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvi Server messages will be created with default TTL. +#Thanks +Thanks Marco Rinck for the original code, the following people have contributed to this project: + +* [orangeskins](https://github.com/orangeskins) +* [adamalbrecht](https://github.com/adamalbrecht) +* [m0ppers](https://github.com/m0ppers) +* [lbehnke](https://github.com/lbehnke) +* [rorymadden](https://github.com/rorymadden) + # License Copyright (C) 2014 Marco Rinck From fb0befcee6ef8966776034724fbcd5d3918b95c2 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:47:08 +0100 Subject: [PATCH 013/169] Added Default severity of sever messages if non is provided --- src/growlFactory.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/growlFactory.js b/src/growlFactory.js index 078fe79..fb49e61 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -176,20 +176,25 @@ angular.module("angular-growl").provider("growl", function() { for (i = 0; i < length; i++) { message = messages[i]; - if (message[_messageTextKey] && message[_messageSeverityKey]) { - switch (message[_messageSeverityKey]) { - case "warn": - severity = "warn"; - break; - case "success": - severity = "success"; - break; - case "info": - severity = "info"; - break; - case "error": - severity = "error"; - break; + if (message[_messageTextKey]) { + if(message[_messageSeverityKey]) { + switch (message[_messageSeverityKey]) { + case "warn": + severity = "warn"; + break; + case "success": + severity = "success"; + break; + case "info": + severity = "info"; + break; + case "error": + severity = "error"; + break; + } else { + // default the severity to error if no severity is provided + severity = 'error'; + } } sendMessage(message[_messageTextKey], undefined, severity); } From 0e0b6e52b873d3464daface1ae676804804c9d29 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:48:38 +0100 Subject: [PATCH 014/169] Added build files and fixed bracket missplacement --- build/angular-growl.js | 30 +++++++++++++++++------------- build/angular-growl.min.js | 2 +- src/growlFactory.js | 4 ++-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index 874d798..d99e0a5 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -154,20 +154,24 @@ angular.module('angular-growl').provider('growl', function () { length = messages.length; for (i = 0; i < length; i++) { message = messages[i]; - if (message[_messageTextKey] && message[_messageSeverityKey]) { - switch (message[_messageSeverityKey]) { - case 'warn': - severity = 'warn'; - break; - case 'success': - severity = 'success'; - break; - case 'info': - severity = 'info'; - break; - case 'error': + if (message[_messageTextKey]) { + if (message[_messageSeverityKey]) { + switch (message[_messageSeverityKey]) { + case 'warn': + severity = 'warn'; + break; + case 'success': + severity = 'success'; + break; + case 'info': + severity = 'info'; + break; + case 'error': + severity = 'error'; + break; + } + } else { severity = 'error'; - break; } sendMessage(message[_messageTextKey], undefined, severity); } diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index b8fb6d4..cf8878f 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -3,4 +3,4 @@ * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]&&c[e]){switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file diff --git a/src/growlFactory.js b/src/growlFactory.js index fb49e61..dd50cb5 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -191,10 +191,10 @@ angular.module("angular-growl").provider("growl", function() { case "error": severity = "error"; break; - } else { + } + } else { // default the severity to error if no severity is provided severity = 'error'; - } } sendMessage(message[_messageTextKey], undefined, severity); } From 7647ca6e6c3a7daaf45e2191aa46de95070d4d6e Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 17:51:38 +0100 Subject: [PATCH 015/169] Fixed inconsistencies in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f3bd7e..abd667e 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,8 @@ only the key: ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addSuccessMessage("SAVE_SUCCESS_MESSAGE"); - growl.addErrorMessage("VALIDATION_ERROR"); + growl.success("SAVE_SUCCESS_MESSAGE"); + growl.error("VALIDATION_ERROR"); } }]); ```` @@ -200,7 +200,7 @@ You can override the global option and hide the close button in single messages ````javascript app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) { $scope.addSpecialWarnMessage = function() { - growl.addWarnMessage("This is a message without a close button", {disableCloseButton: true}); + growl.warning("This is a message without a close button", {disableCloseButton: true}); } }]); ```` From 2302d6bd2e178a540f152765f91157279af118ae Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 18:06:59 +0100 Subject: [PATCH 016/169] Only use sce when we have html messages enabled --- build/angular-growl.js | 4 +++- build/angular-growl.min.js | 2 +- src/growlDirective.js | 4 +++- src/growlFactory.js | 12 ++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index d99e0a5..27b7022 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -22,7 +22,9 @@ angular.module('angular-growl').directive('growl', [ var onlyUnique = growl.onlyUnique(); $scope.messages = []; function addMessage(message) { - message.text = $sce.trustAsHtml(message.text); + if (message.enableHtml) { + message.text = $sce.trustAsHtml(message.text); + } $scope.messages.push(message); if (message.ttl && message.ttl !== -1) { $timeout(function () { diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index cf8878f..53a1046 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -3,4 +3,4 @@ * https://github.com/marcorinck/angular-growl * Copyright (c) 2014 Marco Rinck; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.text=b.trustAsHtml(a.text),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file diff --git a/src/growlDirective.js b/src/growlDirective.js index 69de25b..595adb0 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -20,7 +20,9 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", functi $scope.messages = []; function addMessage(message) { - message.text = $sce.trustAsHtml(message.text); + if(message.enableHtml) { + message.text = $sce.trustAsHtml(message.text); + } $scope.messages.push(message); if (message.ttl && message.ttl !== -1) { diff --git a/src/growlFactory.js b/src/growlFactory.js index dd50cb5..f108b03 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -2,12 +2,12 @@ angular.module("angular-growl").provider("growl", function() { "use strict"; var _ttl = null, - _enableHtml = false, - _messagesKey = 'messages', - _messageTextKey = 'text', - _messageSeverityKey = 'severity', - _onlyUniqueMessages = true, - _disableCloseButton = false; + _enableHtml = false, + _messagesKey = 'messages', + _messageTextKey = 'text', + _messageSeverityKey = 'severity', + _onlyUniqueMessages = true, + _disableCloseButton = false; /** * set a global timeout (time to live) after which messages will be automatically closed From 5977acbeb39d0db3fbba7a131467ec5650423225 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 20:36:05 +0100 Subject: [PATCH 017/169] Re ordered the readme --- README.md | 97 +++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index abd667e..c388250 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,5 @@ -#angular-growl - -> growl like notifications for angularJS projects, using bootstrap alert classes - -##Features - -![Standard bootstrap 2.x styles](doc/screenshot.jpg) - -* growl like notifications like in MacOS X -* using standard bootstrap classes (alert, alert-info, alert-error, alert-success) -* global or per message configuration of a timeout when message will be automatically closed -* automatic translation of messages if [angular-translate](https://github.com/PascalPrecht/angular-translate) filter is -present, you only have to provide keys as messages, angular-translate will translate them -* pre-defined $http-Interceptor to automatically handle $http responses for server-sent messages -* automatic CSS animations when adding/closing notifications (only when using >= angularJS 1.2) -* < 1 kB after GZIP - -##Changelog - -**0.5.0** - 18 Mar 2014 -* Manually merged some pull requests from the original branch -* Fixed bower.json file to include itself and the css file -* [BREAK] changed the function names to add growl notifications to be a shorter (success, info, warning, error VS addSuccessMessage, addInfoMessage...) - -**0.4.0** - 19th Nov 2013 - -* updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE) -* new option: only display unique messages, which is the new default, disable to allow same message more than once (BREAKING CHANGE) -* new option: allow html tags in messages, default is off you need to - -**0.3.1** - 1st Oct 2013 - -* bugfix: translating of messages works again -* change: also set alert css classes introduced by bootstrap 3 - -**0.3.0** - 26th Sept 2013 - -* adding css animations support via ngAnimate (for angularJS >= 1.2) -* ability to configure server message keys - -**0.2.0** - 22nd Sept 2013 - -* reworking, bugfixing and documenting handling of server sent messages/notifications -* externalizing css styles of growl class -* provide minified versions of js and css files in build folder - -**0.1.3** - 20th Sept 2013 - -* introducing ttl config option, fixes #2 +#angular-growl-2 +Growl like notifications for angularJS projects, using bootstrap alert classes, originally developed by Marco Rinck ##Installation @@ -83,6 +36,19 @@ Finally, you have to include the directive somewhere in your HTML like this: ```` +##Features + +![Standard bootstrap 2.x styles](doc/screenshot.jpg) + +* growl like notifications like in MacOS X +* using standard bootstrap classes (alert, alert-info, alert-error, alert-success) +* global or per message configuration of a timeout when message will be automatically closed +* automatic translation of messages if [angular-translate](https://github.com/PascalPrecht/angular-translate) filter is +present, you only have to provide keys as messages, angular-translate will translate them +* pre-defined $http-Interceptor to automatically handle $http responses for server-sent messages +* automatic CSS animations when adding/closing notifications (only when using >= angularJS 1.2) +* < 1 kB after GZIP + ##Usage Just let angular inject the growl Factory into your code and call the 4 functions that the factory provides accordingly: @@ -287,6 +253,39 @@ app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvi Server messages will be created with default TTL. +##Changelog + +**0.5.0** - 18 Mar 2014 +* Manually merged some pull requests from the original branch +* Fixed bower.json file to include itself and the css file +* [BREAK] changed the function names to add growl notifications to be a shorter (success, info, warning, error VS addSuccessMessage, addInfoMessage...) + +**0.4.0** - 19th Nov 2013 + +* updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE) +* new option: only display unique messages, which is the new default, disable to allow same message more than once (BREAKING CHANGE) +* new option: allow html tags in messages, default is off you need to + +**0.3.1** - 1st Oct 2013 + +* bugfix: translating of messages works again +* change: also set alert css classes introduced by bootstrap 3 + +**0.3.0** - 26th Sept 2013 + +* adding css animations support via ngAnimate (for angularJS >= 1.2) +* ability to configure server message keys + +**0.2.0** - 22nd Sept 2013 + +* reworking, bugfixing and documenting handling of server sent messages/notifications +* externalizing css styles of growl class +* provide minified versions of js and css files in build folder + +**0.1.3** - 20th Sept 2013 + +* introducing ttl config option, fixes #2 + #Thanks Thanks Marco Rinck for the original code, the following people have contributed to this project: From ace92e21167f5773a9a967b218c3b4770e52d721 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 20:42:29 +0100 Subject: [PATCH 018/169] Ready for bower deploment --- README.md | 31 ++++++++++++++++--------------- bower.json | 11 +++++++---- build/angular-growl.js | 6 +++--- build/angular-growl.min.css | 6 +++--- build/angular-growl.min.js | 6 +++--- package.json | 4 ++-- 6 files changed, 34 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index c388250..4a0b4bb 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,25 @@ #angular-growl-2 Growl like notifications for angularJS projects, using bootstrap alert classes, originally developed by Marco Rinck +##Features + +![Standard bootstrap 2.x styles](doc/screenshot.jpg) + +* growl like notifications like in MacOS X +* using standard bootstrap classes (alert, alert-info, alert-error, alert-success) +* global or per message configuration of a timeout when message will be automatically closed +* automatic translation of messages if [angular-translate](https://github.com/PascalPrecht/angular-translate) filter is +present, you only have to provide keys as messages, angular-translate will translate them +* pre-defined $http-Interceptor to automatically handle $http responses for server-sent messages +* automatic CSS animations when adding/closing notifications (only when using >= angularJS 1.2) +* < 1 kB after GZIP +* Allows for HTML content inside the alert + ##Installation -You can install angular-growl with bower: +You can install angular-growl-2 with bower: -> bower install angular-growl +> bower install angular-growl-2 Alternatively you can download the files in the [build folder](build/) manually and include them in your project. @@ -36,19 +50,6 @@ Finally, you have to include the directive somewhere in your HTML like this: ```` -##Features - -![Standard bootstrap 2.x styles](doc/screenshot.jpg) - -* growl like notifications like in MacOS X -* using standard bootstrap classes (alert, alert-info, alert-error, alert-success) -* global or per message configuration of a timeout when message will be automatically closed -* automatic translation of messages if [angular-translate](https://github.com/PascalPrecht/angular-translate) filter is -present, you only have to provide keys as messages, angular-translate will translate them -* pre-defined $http-Interceptor to automatically handle $http responses for server-sent messages -* automatic CSS animations when adding/closing notifications (only when using >= angularJS 1.2) -* < 1 kB after GZIP - ##Usage Just let angular inject the growl Factory into your code and call the 4 functions that the factory provides accordingly: diff --git a/bower.json b/bower.json index e7bb2c3..066e919 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,15 @@ { - "author": "Marco Rinck", - "name": "angular-growl", + "author": [ + "Marco Rinck", + "Jan Stevens" + ], + "name": "angular-growl-2", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "version": "0.5.0", - "homepage": "https://github.com/marcorinck/angular-growl", + "homepage": "http://janstevens.github.io/angular-growl-2", "repository": { "type": "git", - "url": "https://github.com/marcorinck/angular-growl" + "url": "https://github.com/JanStevens/angular-growl-2" }, "license": "MIT", "main": ["./build/angular-growl.js", "./build/angular-growl.min.css"], diff --git a/build/angular-growl.js b/build/angular-growl.js index 27b7022..0d37f0a 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,7 +1,7 @@ /** - * angular-growl - v0.5.0 - 2014-03-18 - * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck; Licensed MIT + * angular-growl-2 - v0.5.0 - 2014-03-18 + * http://janstevens.github.io/angular-growl-2 + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ angular.module('angular-growl', []); angular.module('angular-growl').directive('growl', [ diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index b586211..24e5a8d 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,7 +1,7 @@ /** - * angular-growl - v0.5.0 - 2014-03-18 - * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck; Licensed MIT + * angular-growl-2 - v0.5.0 - 2014-03-18 + * http://janstevens.github.io/angular-growl-2 + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ .growl{position:fixed;top:10px;right:10px;float:right;width:250px;z-index:9999}.growl-item.ng-enter,.growl-item.ng-leave{-webkit-transition:.5s linear all;-moz-transition:.5s linear all;-o-transition:.5s linear all;transition:.5s linear all}.growl-item.ng-enter,.growl-item.ng-leave.ng-leave-active{opacity:0}.growl-item.ng-leave,.growl-item.ng-enter.ng-enter-active{opacity:1} \ No newline at end of file diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 53a1046..1cebc51 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** - * angular-growl - v0.5.0 - 2014-03-18 - * https://github.com/marcorinck/angular-growl - * Copyright (c) 2014 Marco Rinck; Licensed MIT + * angular-growl-2 - v0.5.0 - 2014-03-18 + * http://janstevens.github.io/angular-growl-2 + * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:!0,controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[],a.$on("growlMessage",function(a,b){var d;g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b)}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){g=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,h){function i(a){q&&(a.text=q(a.text)),c.$broadcast("growlMessage",a)}function j(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||g},i(f)}function k(a,b){j(a,b,"warn")}function l(a,b){j(a,b,"error")}function m(a,b){j(a,b,"info")}function n(a,b){j(a,b,"success")}function o(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";j(c[d],void 0,f)}}function p(){return f}var q;try{q=h("translate")}catch(r){}return{warning:k,error:l,info:m,success:n,addServerMessages:o,onlyUnique:p}}]}); \ No newline at end of file diff --git a/package.json b/package.json index de1bf9e..5882ca9 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "angular-growl", - "version": "0.4.0", + "version": "0.5.0", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "repository": { "type": "git", - "url": "https://github.com/marcorinck/angular-growl" + "url": "https://github.com/JanStevens/angular-growl-2" }, "author": { "name": "Marco Rinck", From c4309940ead3651d7bd2dd7f93dd521984aa9689 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 18 Mar 2014 20:53:28 +0100 Subject: [PATCH 019/169] Fixed everything for release --- README.md | 4 ++-- bower.json | 2 +- build/angular-growl.js | 2 +- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 2 +- package.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4a0b4bb..c04a418 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ present, you only have to provide keys as messages, angular-translate will trans ##Installation -You can install angular-growl-2 with bower: +You can install angular-growl-v2 with bower: -> bower install angular-growl-2 +> bower install angular-growl-v2 Alternatively you can download the files in the [build folder](build/) manually and include them in your project. diff --git a/bower.json b/bower.json index 066e919..37a78ec 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "Marco Rinck", "Jan Stevens" ], - "name": "angular-growl-2", + "name": "angular-growl-v2", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "version": "0.5.0", "homepage": "http://janstevens.github.io/angular-growl-2", diff --git a/build/angular-growl.js b/build/angular-growl.js index 0d37f0a..558aa0c 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,5 +1,5 @@ /** - * angular-growl-2 - v0.5.0 - 2014-03-18 + * angular-growl-v2 - v0.5.0 - 2014-03-18 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 24e5a8d..bbe1c35 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,5 +1,5 @@ /** - * angular-growl-2 - v0.5.0 - 2014-03-18 + * angular-growl-v2 - v0.5.0 - 2014-03-18 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 1cebc51..a8f8d70 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,5 +1,5 @@ /** - * angular-growl-2 - v0.5.0 - 2014-03-18 + * angular-growl-v2 - v0.5.0 - 2014-03-18 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/package.json b/package.json index 5882ca9..1440867 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "angular-growl", + "name": "angular-growl-v2", "version": "0.5.0", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "repository": { From f91c200b8121b614e88b3b619b9b752ae1e624fa Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Wed, 19 Mar 2014 12:47:05 +0100 Subject: [PATCH 020/169] Added inline notifications and reference ids --- README.md | 48 ++++ bower.json | 2 +- build/angular-growl.js | 43 ++-- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 4 +- demo/demo.html | 11 +- demo/demo.js | 98 +++++---- package.json | 2 +- src/growlDirective.js | 136 ++++++------ src/growlFactory.js | 427 +++++++++++++++++++----------------- 10 files changed, 436 insertions(+), 337 deletions(-) diff --git a/README.md b/README.md index c04a418..878aebf 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ present, you only have to provide keys as messages, angular-translate will trans * automatic CSS animations when adding/closing notifications (only when using >= angularJS 1.2) * < 1 kB after GZIP * Allows for HTML content inside the alert +* Possible to use multiple growl directives that show their notification inline ##Installation @@ -172,6 +173,47 @@ You can override the global option and hide the close button in single messages }]); ```` +###Inline Messages [default: false] +Turn this on globally or on the directive to allow inline messages instead of the growl like messages. The default behaviour is to show growl like messages. + +```javascript +var app = angular.module('myApp', ['angular-growl']); + +app.config(['growlProvider', function(growlProvider) { + growlProvider.globalInlineMessages(true); +}); +``` + +You can override the global option by specifing a display method on the directive, you can also use this in combination with reference id option: + +```html +
+
+
+ diff --git a/demo/demo.js b/demo/demo.js index 6fa8da7..00e9eff 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -3,59 +3,61 @@ var app = angular.module("demo", ["angular-growl", "ngAnimate", "ngMockE2E"]); app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvider) { - growlProvider.globalTimeToLive(2000); - growlProvider.messagesKey("my-messages"); - growlProvider.messageTextKey("messagetext"); - growlProvider.messageSeverityKey("severity-level"); - growlProvider.onlyUniqueMessages(true); - $httpProvider.responseInterceptors.push(growlProvider.serverMessagesInterceptor); - - + growlProvider.globalTimeToLive(2000); + growlProvider.messagesKey("my-messages"); + growlProvider.messageTextKey("messagetext"); + growlProvider.messageSeverityKey("severity-level"); + growlProvider.onlyUniqueMessages(true); + $httpProvider.responseInterceptors.push(growlProvider.serverMessagesInterceptor); }]); app.run(function($httpBackend) { - //mocking backend to simulate handling server messages - $httpBackend.when('GET', '/mockbackend').respond({ - someData: "fhsdfshfshdfs", - "my-messages": [ - {"messagetext":"this is a server message", "severity-level": "warn"}, - {"messagetext":"this is another server message", "severity-level": "info"}, - {"messagetext":"and another", "severity-level": "error"} - ] - }); + //mocking backend to simulate handling server messages + $httpBackend.when('GET', '/mockbackend').respond({ + someData: "fhsdfshfshdfs", + "my-messages": [ + {"messagetext":"this is a server message", "severity-level": "warn"}, + {"messagetext":"this is another server message", "severity-level": "info"}, + {"messagetext":"and another", "severity-level": "error"} + ] + }); }); app.controller("demoCtrl", function demoCtrl($scope, growl, $http) { - $scope.createMessage = function () { - var config = {}; - if ($scope.timeout) { - config.ttl = $scope.timeout; - } - if ($scope.enableHtml) { - config.enableHtml = $scope.enableHtml; - } - - if ($scope.alertType === "success") { - growl.success($scope.message, config); - } - - if ($scope.alertType === "warn") { - growl.warning($scope.message, config); - } - - if ($scope.alertType === "info") { - growl.info($scope.message, config); - } - - if ($scope.alertType === "error") { - growl.error($scope.message, config); - } - }; - - $scope.simulateServerMessages= function() { - $http.get("/mockbackend").then(function(data) { - console.log(data); - }); - }; + $scope.createMessage = function () { + var config = {}; + if ($scope.timeout) { + config.ttl = $scope.timeout; + } + if ($scope.enableHtml) { + config.enableHtml = $scope.enableHtml; + } + + if ($scope.alertType === "success") { + growl.success($scope.message, config); + } + + if ($scope.alertType === "warn") { + growl.warning($scope.message, config); + } + + if ($scope.alertType === "info") { + growl.info($scope.message, config); + } + + if ($scope.alertType === "error") { + growl.error($scope.message, config); + } + }; + + $scope.inlineMessage = function(id) { + growl.success("Inline Message!", {referenceId: id}); + } + + $scope.simulateServerMessages= function() { + $http.get("/mockbackend").then(function(data) { + console.log(data); + }); + }; }); diff --git a/package.json b/package.json index 1440867..78f1b71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-growl-v2", - "version": "0.5.0", + "version": "0.5.2", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "repository": { "type": "git", diff --git a/src/growlDirective.js b/src/growlDirective.js index 595adb0..6bc96b4 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -1,70 +1,80 @@ -angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", function ($rootScope, $sce) { - "use strict"; +angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", + function($rootScope, $sce) { + "use strict"; - return { - restrict: 'A', - template: '
' + - '
' + - ' ' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
', - replace: false, - scope: true, - controller: ['$scope', '$timeout', 'growl', function ($scope, $timeout, growl) { - var onlyUnique = growl.onlyUnique(); + return { + restrict: 'A', + template: '
' + + '
' + + ' ' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
', + replace: false, + scope: { + reference: '@', + inline: '@' + }, + controller: ['$scope', '$timeout', 'growl', + function($scope, $timeout, growl) { + var onlyUnique = growl.onlyUnique(); + $scope.messages = []; + var referenceId = $scope.reference || 0; + $scope.inline = $scope.inline || growl.inlineMessages(); - $scope.messages = []; + function addMessage(message) { + if (message.enableHtml) { + message.text = $sce.trustAsHtml(message.text); + } + $scope.messages.push(message); - function addMessage(message) { - if(message.enableHtml) { - message.text = $sce.trustAsHtml(message.text); - } - $scope.messages.push(message); + if (message.ttl && message.ttl !== -1) { + $timeout(function() { + $scope.deleteMessage(message); + }, message.ttl); + } + } + $rootScope.$on("growlMessage", function(event, message) { + var found; + if (parseInt(referenceId, 10) === parseInt(message.referenceId, 10)) { + if (onlyUnique) { + angular.forEach($scope.messages, function(msg) { + if (message.text === msg.text && message.severity === msg.severity) { + found = true; + } + }); - if (message.ttl && message.ttl !== -1) { - $timeout(function () { - $scope.deleteMessage(message); - }, message.ttl); - } - } - $rootScope.$on("growlMessage", function (event, message) { - var found; - if (onlyUnique) { - angular.forEach($scope.messages, function(msg) { - if (message.text === msg.text && message.severity === msg.severity) { - found = true; - } - }); + if (!found) { + addMessage(message); + } + } else { + addMessage(message); + } + } + }); - if (!found) { - addMessage(message); - } - } else { - addMessage(message); - } - }); + $scope.deleteMessage = function(message) { + var index = $scope.messages.indexOf(message); + if (index > -1) { + $scope.messages.splice(index, 1); + } - $scope.deleteMessage = function (message) { - var index = $scope.messages.indexOf(message); - if (index > -1) { - $scope.messages.splice(index, 1); - } + }; - }; - - $scope.computeClasses = function (message) { - return { - 'alert-success': message.severity === "success", - 'alert-error': message.severity === "error", //bootstrap 2.3 - 'alert-danger': message.severity === "error", //bootstrap 3 - 'alert-info': message.severity === "info", - 'alert-warning': message.severity === "warn" //bootstrap 3, no effect in bs 2.3 - }; - }; - }] - }; -}]); + $scope.computeClasses = function(message) { + return { + 'alert-success': message.severity === "success", + 'alert-error': message.severity === "error", //bootstrap 2.3 + 'alert-danger': message.severity === "error", //bootstrap 3 + 'alert-info': message.severity === "info", + 'alert-warning': message.severity === "warn" //bootstrap 3, no effect in bs 2.3 + }; + }; + } + ] + }; + } +]); diff --git a/src/growlFactory.js b/src/growlFactory.js index f108b03..c180d93 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -1,33 +1,35 @@ angular.module("angular-growl").provider("growl", function() { - "use strict"; + "use strict"; - var _ttl = null, + var _ttl = null, _enableHtml = false, - _messagesKey = 'messages', - _messageTextKey = 'text', - _messageSeverityKey = 'severity', - _onlyUniqueMessages = true, - _disableCloseButton = false; - - /** - * set a global timeout (time to live) after which messages will be automatically closed - * - * @param ttl in seconds - */ - this.globalTimeToLive = function(ttl) { - _ttl = ttl; - }; - - /** - * set whether HTML in message content should be escaped (default) or binded as-is - * - * @param {bool} enableHtml true to make all messages not escapes - */ - this.globalEnableHtml = function(enableHtml) { - _enableHtml = enableHtml; - }; - - /** + _messagesKey = 'messages', + _messageTextKey = 'text', + _messageSeverityKey = 'severity', + _onlyUniqueMessages = true, + _referenceId = 0, + _inline = false, + _disableCloseButton = false; + + /** + * set a global timeout (time to live) after which messages will be automatically closed + * + * @param ttl in seconds + */ + this.globalTimeToLive = function(ttl) { + _ttl = ttl; + }; + + /** + * set whether HTML in message content should be escaped (default) or binded as-is + * + * @param {bool} enableHtml true to make all messages not escapes + */ + this.globalEnableHtml = function(enableHtml) { + _enableHtml = enableHtml; + }; + + /** * set whether the close button should be displayed (default) or hidden * * @param {bool} disableCloseButton true to hide close button on all messages @@ -36,182 +38,197 @@ angular.module("angular-growl").provider("growl", function() { _disableCloseButton = disableCloseButton; }; - /** - * sets the key in $http response the serverMessagesInterecptor is looking for server-sent messages, value of key - * needs to be an array of objects - * - * @param {string} messagesKey default: messages - */ - this.messagesKey = function(messagesKey) { - _messagesKey = messagesKey; - }; - - /** - * sets the key in server sent messages the serverMessagesInterecptor is looking for text of message - * - * @param {string} messageTextKey default: text - */ - this.messageTextKey = function(messageTextKey) { - _messageTextKey = messageTextKey; - }; - - /** - * sets the key in server sent messages the serverMessagesInterecptor is looking for severity of message - * - * @param {string} messageSeverityKey default: severity - */ - this.messageSeverityKey = function(messageSeverityKey) { - _messageSeverityKey = messageSeverityKey; - }; - - this.onlyUniqueMessages = function(onlyUniqueMessages) { - _onlyUniqueMessages = onlyUniqueMessages; - }; - - /** - * $http interceptor that can be added to array of $http interceptors during config phase of application - * via $httpProvider.responseInterceptors.push(...) - * - */ - this.serverMessagesInterceptor = ['$q', 'growl', function ($q, growl) { - function checkResponse(response) { - if (response.data[_messagesKey] && response.data[_messagesKey].length > 0) { - growl.addServerMessages(response.data[_messagesKey]); - } - } - - function success(response) { - checkResponse(response); - return response; - } - - function error(response) { - checkResponse(response); - return $q.reject(response); - } - - return function (promise) { - return promise.then(success, error); - }; - }]; - - this.$get = ["$rootScope", "$filter", function ($rootScope, $filter) { - var translate; - - try { - translate = $filter("translate"); - } catch (e) { - // - } - - function broadcastMessage(message) { - if (translate) { - message.text = translate(message.text); - } - $rootScope.$broadcast("growlMessage", message); - } - - function sendMessage(text, config, severity) { - var _config = config || {}, message; - - message = { - text: text, - severity: severity, - ttl: _config.ttl || _ttl, - enableHtml: _config.enableHtml || _enableHtml, - disableCloseButton: _config.disableCloseButton || _disableCloseButton - }; - - broadcastMessage(message); - } - - /** - * add one warn message with bootstrap class: alert - * - * @param {string} text - * @param {{ttl: number}} config - */ - function warning(text, config) { - sendMessage(text, config, "warn"); - } - - /** - * add one error message with bootstrap classes: alert, alert-error - * - * @param {string} text - * @param {{ttl: number}} config - */ - function error(text, config) { - sendMessage(text, config, "error"); - } - - /** - * add one info message with bootstrap classes: alert, alert-info - * - * @param {string} text - * @param {{ttl: number}} config - */ - function info(text, config) { - sendMessage(text, config, "info"); - } - - /** - * add one success message with bootstrap classes: alert, alert-success - * - * @param {string} text - * @param {{ttl: number}} config - */ - function success(text, config) { - sendMessage(text, config, "success"); - } - - /** - * add a indefinite number of messages that a backend server may have sent as a validation result - * - * @param {Array.} messages - */ - function addServerMessages(messages) { - var i, message, severity, length; - length = messages.length; - for (i = 0; i < length; i++) { - message = messages[i]; - - if (message[_messageTextKey]) { - if(message[_messageSeverityKey]) { - switch (message[_messageSeverityKey]) { - case "warn": - severity = "warn"; - break; - case "success": - severity = "success"; - break; - case "info": - severity = "info"; - break; - case "error": - severity = "error"; - break; - } - } else { - // default the severity to error if no severity is provided - severity = 'error'; - } - sendMessage(message[_messageTextKey], undefined, severity); - } - } - } - - function onlyUnique() { - return _onlyUniqueMessages; - } - - return { - warning: warning, - error: error, - info: info, - success: success, - addServerMessages: addServerMessages, - onlyUnique: onlyUnique - }; - }]; + /** + * set wheter the notficiation is displayed inline our in growl like fasion + * + * @param {bool} inline true to show only inline notifications + */ + this.globalInlineMessages = function(inline) { + _inline = inline; + }; + + /** + * sets the key in $http response the serverMessagesInterecptor is looking for server-sent messages, value of key + * needs to be an array of objects + * + * @param {string} messagesKey default: messages + */ + this.messagesKey = function(messagesKey) { + _messagesKey = messagesKey; + }; + + /** + * sets the key in server sent messages the serverMessagesInterecptor is looking for text of message + * + * @param {string} messageTextKey default: text + */ + this.messageTextKey = function(messageTextKey) { + _messageTextKey = messageTextKey; + }; + + /** + * sets the key in server sent messages the serverMessagesInterecptor is looking for severity of message + * + * @param {string} messageSeverityKey default: severity + */ + this.messageSeverityKey = function(messageSeverityKey) { + _messageSeverityKey = messageSeverityKey; + }; + + this.onlyUniqueMessages = function(onlyUniqueMessages) { + _onlyUniqueMessages = onlyUniqueMessages; + }; + + /** + * $http interceptor that can be added to array of $http interceptors during config phase of application + * via $httpProvider.responseInterceptors.push(...) + * + */ + this.serverMessagesInterceptor = ['$q', 'growl', function ($q, growl) { + function checkResponse(response) { + if (response.data[_messagesKey] && response.data[_messagesKey].length > 0) { + growl.addServerMessages(response.data[_messagesKey]); + } + } + + function success(response) { + checkResponse(response); + return response; + } + + function error(response) { + checkResponse(response); + return $q.reject(response); + } + + return function (promise) { + return promise.then(success, error); + }; + }]; + + this.$get = ["$rootScope", "$filter", function ($rootScope, $filter) { + var translate; + + try { + translate = $filter("translate"); + } catch (e) { + // + } + + function broadcastMessage(message) { + if (translate) { + message.text = translate(message.text); + } + $rootScope.$broadcast("growlMessage", message); + } + + function sendMessage(text, config, severity) { + var _config = config || {}, message; + + message = { + text: text, + severity: severity, + ttl: _config.ttl || _ttl, + enableHtml: _config.enableHtml || _enableHtml, + disableCloseButton: _config.disableCloseButton || _disableCloseButton, + referenceId: _config.referenceId || _referenceId + }; + + broadcastMessage(message); + } + + /** + * add one warn message with bootstrap class: alert + * + * @param {string} text + * @param {{ttl: number}} config + */ + function warning(text, config) { + sendMessage(text, config, "warn"); + } + + /** + * add one error message with bootstrap classes: alert, alert-error + * + * @param {string} text + * @param {{ttl: number}} config + */ + function error(text, config) { + sendMessage(text, config, "error"); + } + + /** + * add one info message with bootstrap classes: alert, alert-info + * + * @param {string} text + * @param {{ttl: number}} config + */ + function info(text, config) { + sendMessage(text, config, "info"); + } + + /** + * add one success message with bootstrap classes: alert, alert-success + * + * @param {string} text + * @param {{ttl: number}} config + */ + function success(text, config) { + sendMessage(text, config, "success"); + } + + /** + * add a indefinite number of messages that a backend server may have sent as a validation result + * + * @param {Array.} messages + */ + function addServerMessages(messages) { + var i, message, severity, length; + length = messages.length; + for (i = 0; i < length; i++) { + message = messages[i]; + + if (message[_messageTextKey]) { + if(message[_messageSeverityKey]) { + switch (message[_messageSeverityKey]) { + case "warn": + severity = "warn"; + break; + case "success": + severity = "success"; + break; + case "info": + severity = "info"; + break; + case "error": + severity = "error"; + break; + } + } else { + // default the severity to error if no severity is provided + severity = 'error'; + } + sendMessage(message[_messageTextKey], undefined, severity); + } + } + } + + function onlyUnique() { + return _onlyUniqueMessages; + } + + function inlineMessages() { + return _inline; + } + + return { + warning: warning, + error: error, + info: info, + success: success, + addServerMessages: addServerMessages, + onlyUnique: onlyUnique, + inlineMessages: inlineMessages, + }; + }]; }); From 127e5ad49b49ffc855c903a800b8e8a749687523 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Wed, 19 Mar 2014 13:06:21 +0100 Subject: [PATCH 021/169] Fixed bug where global config was not propagating correctly --- build/angular-growl.js | 4 ++-- build/angular-growl.min.js | 2 +- src/growlDirective.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index d7f8de1..1593822 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -11,7 +11,7 @@ angular.module('angular-growl').directive('growl', [ 'use strict'; return { restrict: 'A', - template: '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
' + '
', + template: '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
' + '
', replace: false, scope: { reference: '@', @@ -25,7 +25,7 @@ angular.module('angular-growl').directive('growl', [ var onlyUnique = growl.onlyUnique(); $scope.messages = []; var referenceId = $scope.reference || 0; - $scope.inline = $scope.inline || growl.inlineMessages(); + $scope.inlineMessage = $scope.inline || growl.inlineMessages(); function addMessage(message) { if (message.enableHtml) { message.text = $sce.trustAsHtml(message.text); diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 7b418a1..ec3f259 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -3,4 +3,4 @@ * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inline=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=0,h=!1,i=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){i=a},this.globalInlineMessages=function(a){h=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,j){function k(a){t&&(a.text=t(a.text)),c.$broadcast("growlMessage",a)}function l(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||i,referenceId:h.referenceId||g},k(f)}function m(a,b){l(a,b,"warn")}function n(a,b){l(a,b,"error")}function o(a,b){l(a,b,"info")}function p(a,b){l(a,b,"success")}function q(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";l(c[d],void 0,f)}}function r(){return f}function s(){return h}var t;try{t=j("translate")}catch(u){}return{warning:m,error:n,info:o,success:p,addServerMessages:q,onlyUnique:r,inlineMessages:s}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inlineMessage=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=0,h=!1,i=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){i=a},this.globalInlineMessages=function(a){h=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,j){function k(a){t&&(a.text=t(a.text)),c.$broadcast("growlMessage",a)}function l(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||i,referenceId:h.referenceId||g},k(f)}function m(a,b){l(a,b,"warn")}function n(a,b){l(a,b,"error")}function o(a,b){l(a,b,"info")}function p(a,b){l(a,b,"success")}function q(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";l(c[d],void 0,f)}}function r(){return f}function s(){return h}var t;try{t=j("translate")}catch(u){}return{warning:m,error:n,info:o,success:p,addServerMessages:q,onlyUnique:r,inlineMessages:s}}]}); \ No newline at end of file diff --git a/src/growlDirective.js b/src/growlDirective.js index 6bc96b4..e37ee34 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -4,7 +4,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", return { restrict: 'A', - template: '
' + + template: '
' + '
' + ' ' + '
' + @@ -23,7 +23,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", var onlyUnique = growl.onlyUnique(); $scope.messages = []; var referenceId = $scope.reference || 0; - $scope.inline = $scope.inline || growl.inlineMessages(); + $scope.inlineMessage = $scope.inline || growl.inlineMessages(); function addMessage(message) { if (message.enableHtml) { From ab4ce572953f01f41bb610c9745f0c2abe2189cd Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Wed, 19 Mar 2014 13:12:33 +0100 Subject: [PATCH 022/169] Bumped bower version --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 2a3f109..7b2d85d 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ ], "name": "angular-growl-v2", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", - "version": "0.5.2", + "version": "0.5.3", "homepage": "http://janstevens.github.io/angular-growl-2", "repository": { "type": "git", diff --git a/package.json b/package.json index 78f1b71..39c4d5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-growl-v2", - "version": "0.5.2", + "version": "0.5.3", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "repository": { "type": "git", From 302c6bd04498cd5ef23f880555390eeeba81da1a Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Wed, 19 Mar 2014 13:15:25 +0100 Subject: [PATCH 023/169] Updated readme for 0.5.3 release --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 878aebf..f55c812 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,8 @@ app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvi Server messages will be created with default TTL. ##Changelog +**0.5.3** - 19 Mar 2014 +* Fixed bug where globalInlineMessage option would not work globally **0.5.2** - 19 Mar 2014 * Added an option to show notifications inline instead of growl like behaviour (very handy for forms) From bc4cfd78a0c22323cf82ecb349b8f29e9b12b045 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Thu, 20 Mar 2014 10:02:16 +0100 Subject: [PATCH 024/169] Close #1 globalTTL will now accept a hash or integer --- build/angular-growl.js | 25 +++++++++++++++++++++---- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 4 ++-- src/growlFactory.js | 18 +++++++++++++++--- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index 1593822..844cc80 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.5.2 - 2014-03-19 + * angular-growl-v2 - v0.5.3 - 2014-03-20 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ @@ -76,9 +76,26 @@ angular.module('angular-growl').directive('growl', [ ]); angular.module('angular-growl').provider('growl', function () { 'use strict'; - var _ttl = null, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _referenceId = 0, _inline = false, _disableCloseButton = false; + var _ttl = { + success: null, + error: null, + warning: null, + info: null + }, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _referenceId = 0, _inline = false, _disableCloseButton = false; this.globalTimeToLive = function (ttl) { - _ttl = ttl; + if (typeof ttl === 'object') { + for (var k in ttl) { + if (ttl.hasOwnProperty(k)) { + _ttl[k] = ttl[k]; + } + } + } else { + for (var severity in _ttl) { + if (_ttl.hasOwnProperty(severity)) { + _ttl[severity] = ttl; + } + } + } }; this.globalEnableHtml = function (enableHtml) { _enableHtml = enableHtml; @@ -143,7 +160,7 @@ angular.module('angular-growl').provider('growl', function () { message = { text: text, severity: severity, - ttl: _config.ttl || _ttl, + ttl: _config.ttl || _ttl[severity], enableHtml: _config.enableHtml || _enableHtml, disableCloseButton: _config.disableCloseButton || _disableCloseButton, referenceId: _config.referenceId || _referenceId diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 358e749..7ea0413 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.5.2 - 2014-03-19 + * angular-growl-v2 - v0.5.3 - 2014-03-20 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index ec3f259..5d7dd0e 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** - * angular-growl-v2 - v0.5.2 - 2014-03-19 + * angular-growl-v2 - v0.5.3 - 2014-03-20 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inlineMessage=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b=!1,c="messages",d="text",e="severity",f=!0,g=0,h=!1,i=!1;this.globalTimeToLive=function(b){a=b},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){i=a},this.globalInlineMessages=function(a){h=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,j){function k(a){t&&(a.text=t(a.text)),c.$broadcast("growlMessage",a)}function l(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a,enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||i,referenceId:h.referenceId||g},k(f)}function m(a,b){l(a,b,"warn")}function n(a,b){l(a,b,"error")}function o(a,b){l(a,b,"info")}function p(a,b){l(a,b,"success")}function q(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";l(c[d],void 0,f)}}function r(){return f}function s(){return h}var t;try{t=j("translate")}catch(u){}return{warning:m,error:n,info:o,success:p,addServerMessages:q,onlyUnique:r,inlineMessages:s}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inlineMessage=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a={success:null,error:null,warning:null,info:null},b=!1,c="messages",d="text",e="severity",f=!0,g=0,h=!1,i=!1;this.globalTimeToLive=function(b){if("object"==typeof b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);else for(var d in a)a.hasOwnProperty(d)&&(a[d]=b)},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){i=a},this.globalInlineMessages=function(a){h=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,j){function k(a){t&&(a.text=t(a.text)),c.$broadcast("growlMessage",a)}function l(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a[e],enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||i,referenceId:h.referenceId||g},k(f)}function m(a,b){l(a,b,"warn")}function n(a,b){l(a,b,"error")}function o(a,b){l(a,b,"info")}function p(a,b){l(a,b,"success")}function q(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";l(c[d],void 0,f)}}function r(){return f}function s(){return h}var t;try{t=j("translate")}catch(u){}return{warning:m,error:n,info:o,success:p,addServerMessages:q,onlyUnique:r,inlineMessages:s}}]}); \ No newline at end of file diff --git a/src/growlFactory.js b/src/growlFactory.js index c180d93..6c7265d 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -1,7 +1,7 @@ angular.module("angular-growl").provider("growl", function() { "use strict"; - var _ttl = null, + var _ttl = {success: null, error: null, warning: null, info: null}, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', @@ -17,7 +17,19 @@ angular.module("angular-growl").provider("growl", function() { * @param ttl in seconds */ this.globalTimeToLive = function(ttl) { - _ttl = ttl; + if(typeof ttl === 'object') { + for(var k in ttl) { + if(ttl.hasOwnProperty(k)) { + _ttl[k] = ttl[k]; + } + } + } else { + for(var severity in _ttl) { + if(_ttl.hasOwnProperty(severity)) { + _ttl[severity] = ttl; + } + } + } }; /** @@ -128,7 +140,7 @@ angular.module("angular-growl").provider("growl", function() { message = { text: text, severity: severity, - ttl: _config.ttl || _ttl, + ttl: _config.ttl || _ttl[severity], enableHtml: _config.enableHtml || _enableHtml, disableCloseButton: _config.disableCloseButton || _disableCloseButton, referenceId: _config.referenceId || _referenceId From 27dbe8116f00a69d84ee024cd885fc8121bc5a37 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Thu, 3 Apr 2014 23:41:17 +0200 Subject: [PATCH 025/169] Merge Inject variables in growl server messages #19 from original repo --- build/angular-growl.js | 14 ++++++++++---- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 4 ++-- src/growlFactory.js | 17 +++++++++++++++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/build/angular-growl.js b/build/angular-growl.js index 844cc80..a82e755 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.5.3 - 2014-03-20 + * angular-growl-v2 - v0.5.3 - 2014-04-03 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ @@ -81,7 +81,7 @@ angular.module('angular-growl').provider('growl', function () { error: null, warning: null, info: null - }, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _referenceId = 0, _inline = false, _disableCloseButton = false; + }, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _messageVariableKey = 'variables', _referenceId = 0, _inline = false, _disableCloseButton = false; this.globalTimeToLive = function (ttl) { if (typeof ttl === 'object') { for (var k in ttl) { @@ -103,6 +103,9 @@ angular.module('angular-growl').provider('growl', function () { this.globalDisableCloseButton = function (disableCloseButton) { _disableCloseButton = disableCloseButton; }; + this.messageVariableKey = function (messageVariableKey) { + _messageVariableKey = messageVariableKey; + }; this.globalInlineMessages = function (inline) { _inline = inline; }; @@ -151,7 +154,7 @@ angular.module('angular-growl').provider('growl', function () { } function broadcastMessage(message) { if (translate) { - message.text = translate(message.text); + message.text = translate(message.text, message.variables); } $rootScope.$broadcast('growlMessage', message); } @@ -162,6 +165,7 @@ angular.module('angular-growl').provider('growl', function () { severity: severity, ttl: _config.ttl || _ttl[severity], enableHtml: _config.enableHtml || _enableHtml, + variables: _config.variables || {}, disableCloseButton: _config.disableCloseButton || _disableCloseButton, referenceId: _config.referenceId || _referenceId }; @@ -203,7 +207,9 @@ angular.module('angular-growl').provider('growl', function () { } else { severity = 'error'; } - sendMessage(message[_messageTextKey], undefined, severity); + var config = {}; + config.variables = message[_messageVariableKey] || {}; + sendMessage(message[_messageTextKey], config, severity); } } } diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 7ea0413..9be6b68 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.5.3 - 2014-03-20 + * angular-growl-v2 - v0.5.3 - 2014-04-03 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.min.js b/build/angular-growl.min.js index 5d7dd0e..2a1d545 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** - * angular-growl-v2 - v0.5.3 - 2014-03-20 + * angular-growl-v2 - v0.5.3 - 2014-04-03 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ -angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inlineMessage=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a={success:null,error:null,warning:null,info:null},b=!1,c="messages",d="text",e="severity",f=!0,g=0,h=!1,i=!1;this.globalTimeToLive=function(b){if("object"==typeof b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);else for(var d in a)a.hasOwnProperty(d)&&(a[d]=b)},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){i=a},this.globalInlineMessages=function(a){h=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,j){function k(a){t&&(a.text=t(a.text)),c.$broadcast("growlMessage",a)}function l(c,d,e){var f,h=d||{};f={text:c,severity:e,ttl:h.ttl||a[e],enableHtml:h.enableHtml||b,disableCloseButton:h.disableCloseButton||i,referenceId:h.referenceId||g},k(f)}function m(a,b){l(a,b,"warn")}function n(a,b){l(a,b,"error")}function o(a,b){l(a,b,"info")}function p(a,b){l(a,b,"success")}function q(a){var b,c,f,g;for(g=a.length,b=0;g>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";l(c[d],void 0,f)}}function r(){return f}function s(){return h}var t;try{t=j("translate")}catch(u){}return{warning:m,error:n,info:o,success:p,addServerMessages:q,onlyUnique:r,inlineMessages:s}}]}); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope","$sce",function(a,b){"use strict";return{restrict:"A",template:'
',replace:!1,scope:{reference:"@",inline:"@"},controller:["$scope","$timeout","growl",function(c,d,e){function f(a){a.enableHtml&&(a.text=b.trustAsHtml(a.text)),c.messages.push(a),a.ttl&&-1!==a.ttl&&d(function(){c.deleteMessage(a)},a.ttl)}var g=e.onlyUnique();c.messages=[];var h=c.reference||0;c.inlineMessage=c.inline||e.inlineMessages(),a.$on("growlMessage",function(a,b){var d;parseInt(h,10)===parseInt(b.referenceId,10)&&(g?(angular.forEach(c.messages,function(a){b.text===a.text&&b.severity===a.severity&&(d=!0)}),d||f(b)):f(b))}),c.deleteMessage=function(a){var b=c.messages.indexOf(a);b>-1&&c.messages.splice(b,1)},c.computeClasses=function(a){return{"alert-success":"success"===a.severity,"alert-error":"error"===a.severity,"alert-danger":"error"===a.severity,"alert-info":"info"===a.severity,"alert-warning":"warn"===a.severity}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a={success:null,error:null,warning:null,info:null},b=!1,c="messages",d="text",e="severity",f=!0,g="variables",h=0,i=!1,j=!1;this.globalTimeToLive=function(b){if("object"==typeof b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);else for(var d in a)a.hasOwnProperty(d)&&(a[d]=b)},this.globalEnableHtml=function(a){b=a},this.globalDisableCloseButton=function(a){j=a},this.messageVariableKey=function(a){g=a},this.globalInlineMessages=function(a){i=a},this.messagesKey=function(a){c=a},this.messageTextKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,b){function d(a){a.data[c]&&a.data[c].length>0&&b.addServerMessages(a.data[c])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(c,k){function l(a){u&&(a.text=u(a.text,a.variables)),c.$broadcast("growlMessage",a)}function m(c,d,e){var f,g=d||{};f={text:c,severity:e,ttl:g.ttl||a[e],enableHtml:g.enableHtml||b,variables:g.variables||{},disableCloseButton:g.disableCloseButton||j,referenceId:g.referenceId||h},l(f)}function n(a,b){m(a,b,"warn")}function o(a,b){m(a,b,"error")}function p(a,b){m(a,b,"info")}function q(a,b){m(a,b,"success")}function r(a){var b,c,f,h;for(h=a.length,b=0;h>b;b++)if(c=a[b],c[d]){if(c[e])switch(c[e]){case"warn":f="warn";break;case"success":f="success";break;case"info":f="info";break;case"error":f="error"}else f="error";var i={};i.variables=c[g]||{},m(c[d],i,f)}}function s(){return f}function t(){return i}var u;try{u=k("translate")}catch(v){}return{warning:n,error:o,info:p,success:q,addServerMessages:r,onlyUnique:s,inlineMessages:t}}]}); \ No newline at end of file diff --git a/src/growlFactory.js b/src/growlFactory.js index 6c7265d..8e2564e 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -7,6 +7,7 @@ angular.module("angular-growl").provider("growl", function() { _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, + _messageVariableKey = 'variables', _referenceId = 0, _inline = false, _disableCloseButton = false; @@ -50,6 +51,15 @@ angular.module("angular-growl").provider("growl", function() { _disableCloseButton = disableCloseButton; }; + /** + * sets the key in server sent messages the serverMessagesInterecptor is looking for variables to inject in the message + * + * @param {string} messageVariableKey default: variables + */ + this.messageVariableKey = function (messageVariableKey) { + _messageVariableKey = messageVariableKey; + }; + /** * set wheter the notficiation is displayed inline our in growl like fasion * @@ -129,7 +139,7 @@ angular.module("angular-growl").provider("growl", function() { function broadcastMessage(message) { if (translate) { - message.text = translate(message.text); + message.text = translate(message.text, message.variables); } $rootScope.$broadcast("growlMessage", message); } @@ -142,6 +152,7 @@ angular.module("angular-growl").provider("growl", function() { severity: severity, ttl: _config.ttl || _ttl[severity], enableHtml: _config.enableHtml || _enableHtml, + variables: _config.variables || {}, disableCloseButton: _config.disableCloseButton || _disableCloseButton, referenceId: _config.referenceId || _referenceId }; @@ -220,7 +231,9 @@ angular.module("angular-growl").provider("growl", function() { // default the severity to error if no severity is provided severity = 'error'; } - sendMessage(message[_messageTextKey], undefined, severity); + var config = {}; + config.variables = message[_messageVariableKey] || {}; + sendMessage(message[_messageTextKey], config, severity); } } } From d1482ac8e26a7fd8dc9d9c73176a1aa994a45a00 Mon Sep 17 00:00:00 2001 From: Paul Oprea Date: Fri, 4 Apr 2014 13:48:58 +0100 Subject: [PATCH 026/169] Option to set position on screen from predefined values --- src/growl.css | 9 ++++++--- src/growlDirective.js | 12 ++++++++++-- src/growlFactory.js | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/growl.css b/src/growl.css index 9fab114..2d44bb2 100644 --- a/src/growl.css +++ b/src/growl.css @@ -1,12 +1,15 @@ .growl { position: fixed; - top: 10px; - right: 10px; float: right; width: 250px; z-index: 9999; } - +.top-right {top: 10px; right: 15px;} +.bottom-right {bottom: 10px; right: 15px;} +.top-left {top: 10px; left: 15px;} +.bottom-left {bottom: 10px; left: 15px;} +.top-center {top: 10px; left: 50%; margin-left: -150px;} +.bottom-center { bottom: 10px; left: 50%; margin-left: -150px;} .growl-item.ng-enter, .growl-item.ng-leave { -webkit-transition:0.5s linear all; diff --git a/src/growlDirective.js b/src/growlDirective.js index e37ee34..baacfae 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -4,7 +4,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", return { restrict: 'A', - template: '
' + + template: '
' + '
' + ' ' + '
' + @@ -24,7 +24,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", $scope.messages = []; var referenceId = $scope.reference || 0; $scope.inlineMessage = $scope.inline || growl.inlineMessages(); - + $scope.position = growl.Position(); function addMessage(message) { if (message.enableHtml) { message.text = $sce.trustAsHtml(message.text); @@ -73,6 +73,14 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", 'alert-warning': message.severity === "warn" //bootstrap 3, no effect in bs 2.3 }; }; + + $scope.computeContainerClasses = function(){ + var ret = { + 'growl': !this.inlineMessage, + }; + ret[this.position] = true; + return ret + } } ] }; diff --git a/src/growlFactory.js b/src/growlFactory.js index 8e2564e..0264753 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -10,6 +10,7 @@ angular.module("angular-growl").provider("growl", function() { _messageVariableKey = 'variables', _referenceId = 0, _inline = false, + _position = 'top-right', _disableCloseButton = false; /** @@ -69,6 +70,14 @@ angular.module("angular-growl").provider("growl", function() { _inline = inline; }; + /** + * set position + * + * @param {string} messageVariableKey default: top-right + */ + this.globalPosition = function(position) { + _position = position; + }; /** * sets the key in $http response the serverMessagesInterecptor is looking for server-sent messages, value of key * needs to be an array of objects @@ -245,7 +254,10 @@ angular.module("angular-growl").provider("growl", function() { function inlineMessages() { return _inline; } - + + function Position(){ + return _position + } return { warning: warning, error: error, @@ -254,6 +266,7 @@ angular.module("angular-growl").provider("growl", function() { addServerMessages: addServerMessages, onlyUnique: onlyUnique, inlineMessages: inlineMessages, + Position: Position, }; }]; }); From 25675958b6d2fda183c834f1300e379bcd9db03f Mon Sep 17 00:00:00 2001 From: Paul Oprea Date: Fri, 4 Apr 2014 14:02:56 +0100 Subject: [PATCH 027/169] Documented position --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index f55c812..58a6bab 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,16 @@ You can override the global option and hide the close button in single messages } }]); ```` +###Position [default:top-right] +Instruct where the messages while appear relative to the screen +Options: top-left, top-right, bottom-left, bottom-right, top-center, bottom-center +````javascript +var app = angular.module('myApp', ['angular-growl']); + +app.config(['growlProvider', function(growlProvider) { + growlProvider.globalPosition('bottom-center'); +}); +```` ###Inline Messages [default: false] Turn this on globally or on the directive to allow inline messages instead of the growl like messages. The default behaviour is to show growl like messages. From 4ed3d3c1dbc47b5529b898257efb3598e513ba79 Mon Sep 17 00:00:00 2001 From: Paul Oprea Date: Fri, 4 Apr 2014 14:05:43 +0100 Subject: [PATCH 028/169] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58a6bab..e3defde 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,8 @@ You can override the global option and hide the close button in single messages ```` ###Position [default:top-right] Instruct where the messages while appear relative to the screen -Options: top-left, top-right, bottom-left, bottom-right, top-center, bottom-center +>Options: top-left, top-right, bottom-left, bottom-right, top-center, bottom-center + ````javascript var app = angular.module('myApp', ['angular-growl']); From a95b879a6e6bed5d2c7c4782335a73f7efcb89c4 Mon Sep 17 00:00:00 2001 From: Paul Oprea Date: Fri, 4 Apr 2014 16:28:30 +0100 Subject: [PATCH 029/169] Scaffold for title --- src/growl.css | 10 ++++++++++ src/growlDirective.js | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/growl.css b/src/growl.css index 2d44bb2..2e8c6b5 100644 --- a/src/growl.css +++ b/src/growl.css @@ -4,6 +4,16 @@ width: 250px; z-index: 9999; } +.growl h4 { + font-size: 13px; + color: #333; + margin-bottom: .5em; + + -webkit-text-shadow: 0 0 1px #FFF; + -moz-text-shadow: 0 0 1px #FFF; + -o-text-shadow: 0 0 1px #FFF; + text-shadow: 0 0 1px #FFF; +} .top-right {top: 10px; right: 15px;} .bottom-right {bottom: 10px; right: 15px;} .top-left {top: 10px; left: 15px;} diff --git a/src/growlDirective.js b/src/growlDirective.js index baacfae..8c6cd07 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -8,6 +8,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", '
' + ' ' + '
' + + '

' + '
' + '
' + '
' + @@ -80,6 +81,16 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", }; ret[this.position] = true; return ret + }; + + $scope.computeTitle = function(message){ + var ret = { + 'success': 'Success', + 'error': 'Error', + 'info': 'Information', + 'warn': 'Warning' + } + return ret[message.severity]; } } ] From cec9a92e743a68fc754cb816cd8c8eb3a12d676c Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 15 Apr 2014 19:47:01 +0200 Subject: [PATCH 030/169] Fixes #6 and #7 added directive template to the cache --- demo/demo.html | 12 +++++------ demo/demo.js | 2 +- src/growlDirective.js | 47 +++++++++++++++++++++++++------------------ src/growlFactory.js | 12 ++++++----- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/demo/demo.html b/demo/demo.html index d53ecca..11cff41 100644 --- a/demo/demo.html +++ b/demo/demo.html @@ -2,13 +2,11 @@ angular-growl demo - - - - - - - + + + + + diff --git a/demo/demo.js b/demo/demo.js index 00e9eff..f9ad6f4 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -53,7 +53,7 @@ app.controller("demoCtrl", function demoCtrl($scope, growl, $http) { $scope.inlineMessage = function(id) { growl.success("Inline Message!", {referenceId: id}); - } + }; $scope.simulateServerMessages= function() { $http.get("/mockbackend").then(function(data) { diff --git a/src/growlDirective.js b/src/growlDirective.js index 8c6cd07..fbf862c 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -4,16 +4,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", return { restrict: 'A', - template: '
' + - '
' + - ' ' + - '
' + - '

' + - '
' + - '
' + - '
' + - '
' + - '
', + templateUrl: 'templates/growl/growl.html', replace: false, scope: { reference: '@', @@ -25,7 +16,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", $scope.messages = []; var referenceId = $scope.reference || 0; $scope.inlineMessage = $scope.inline || growl.inlineMessages(); - $scope.position = growl.Position(); + function addMessage(message) { if (message.enableHtml) { message.text = $sce.trustAsHtml(message.text); @@ -38,6 +29,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", }, message.ttl); } } + $rootScope.$on("growlMessage", function(event, message) { var found; if (parseInt(referenceId, 10) === parseInt(message.referenceId, 10)) { @@ -65,7 +57,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", }; - $scope.computeClasses = function(message) { + $scope.messageClasses = function(message) { return { 'alert-success': message.severity === "success", 'alert-error': message.severity === "error", //bootstrap 2.3 @@ -75,12 +67,11 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", }; }; - $scope.computeContainerClasses = function(){ - var ret = { - 'growl': !this.inlineMessage, - }; - ret[this.position] = true; - return ret + $scope.wrapperClasses = function(){ + var classes = {}; + classes['growl'] = !$scope.inlineMessage; + classes[growl.position()] = true; + return classes; }; $scope.computeTitle = function(message){ @@ -89,11 +80,27 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", 'error': 'Error', 'info': 'Information', 'warn': 'Warning' - } + }; return ret[message.severity]; - } + }; } ] }; } ]); + +angular.module("angular-growl").run(['$templateCache', function($templateCache) { + "use strict"; + $templateCache.put("templates/growl/growl.html", + '
' + + '
' + + '' + + '
' + + '

' + + '
' + + '
' + + '
' + + '
' + + '
' + ); +}]); diff --git a/src/growlFactory.js b/src/growlFactory.js index 0264753..00a1787 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -160,9 +160,10 @@ angular.module("angular-growl").provider("growl", function() { text: text, severity: severity, ttl: _config.ttl || _ttl[severity], - enableHtml: _config.enableHtml || _enableHtml, + enableHtml: _config.enableHtml === undefined ? _enableHtml : _config.enableHtml, variables: _config.variables || {}, disableCloseButton: _config.disableCloseButton || _disableCloseButton, + position: _config.position || _position, referenceId: _config.referenceId || _referenceId }; @@ -254,10 +255,11 @@ angular.module("angular-growl").provider("growl", function() { function inlineMessages() { return _inline; } - - function Position(){ - return _position + + function position() { + return _position; } + return { warning: warning, error: error, @@ -266,7 +268,7 @@ angular.module("angular-growl").provider("growl", function() { addServerMessages: addServerMessages, onlyUnique: onlyUnique, inlineMessages: inlineMessages, - Position: Position, + position: position, }; }]; }); From 272ab9d55a8db22c07a5b1cbcb7eda2a80804a37 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 15 Apr 2014 19:50:10 +0200 Subject: [PATCH 031/169] Removed support for EnableHtml, default we always parse with , not living in the stone age --- src/growlDirective.js | 8 ++------ src/growlFactory.js | 11 ----------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/growlDirective.js b/src/growlDirective.js index fbf862c..bb21b4d 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -18,9 +18,7 @@ angular.module("angular-growl").directive("growl", ["$rootScope", "$sce", $scope.inlineMessage = $scope.inline || growl.inlineMessages(); function addMessage(message) { - if (message.enableHtml) { - message.text = $sce.trustAsHtml(message.text); - } + message.text = $sce.trustAsHtml(message.text); $scope.messages.push(message); if (message.ttl && message.ttl !== -1) { @@ -95,10 +93,8 @@ angular.module("angular-growl").run(['$templateCache', function($templateCache) '
' + '
' + '' + - '
' + '

' + - '
' + - '
' + + '
' + '
' + '
' + '
' diff --git a/src/growlFactory.js b/src/growlFactory.js index 00a1787..601d452 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -2,7 +2,6 @@ angular.module("angular-growl").provider("growl", function() { "use strict"; var _ttl = {success: null, error: null, warning: null, info: null}, - _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', @@ -34,15 +33,6 @@ angular.module("angular-growl").provider("growl", function() { } }; - /** - * set whether HTML in message content should be escaped (default) or binded as-is - * - * @param {bool} enableHtml true to make all messages not escapes - */ - this.globalEnableHtml = function(enableHtml) { - _enableHtml = enableHtml; - }; - /** * set whether the close button should be displayed (default) or hidden * @@ -160,7 +150,6 @@ angular.module("angular-growl").provider("growl", function() { text: text, severity: severity, ttl: _config.ttl || _ttl[severity], - enableHtml: _config.enableHtml === undefined ? _enableHtml : _config.enableHtml, variables: _config.variables || {}, disableCloseButton: _config.disableCloseButton || _disableCloseButton, position: _config.position || _position, From 768666566bc278cf681ec2104063c87ecabc74fe Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 15 Apr 2014 19:55:34 +0200 Subject: [PATCH 032/169] Fixed spacing of css --- src/growl.css | 71 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/growl.css b/src/growl.css index 2e8c6b5..1e1af8b 100644 --- a/src/growl.css +++ b/src/growl.css @@ -1,39 +1,58 @@ .growl { - position: fixed; - float: right; - width: 250px; - z-index: 9999; + position: fixed; + float: right; + width: 250px; + z-index: 9999; } .growl h4 { - font-size: 13px; - color: #333; - margin-bottom: .5em; - - -webkit-text-shadow: 0 0 1px #FFF; - -moz-text-shadow: 0 0 1px #FFF; - -o-text-shadow: 0 0 1px #FFF; - text-shadow: 0 0 1px #FFF; -} -.top-right {top: 10px; right: 15px;} -.bottom-right {bottom: 10px; right: 15px;} -.top-left {top: 10px; left: 15px;} -.bottom-left {bottom: 10px; left: 15px;} -.top-center {top: 10px; left: 50%; margin-left: -150px;} -.bottom-center { bottom: 10px; left: 50%; margin-left: -150px;} + font-size: 13px; + color: #333; + margin-bottom: .5em; + + -webkit-text-shadow: 0 0 1px #FFF; + -moz-text-shadow: 0 0 1px #FFF; + -o-text-shadow: 0 0 1px #FFF; + text-shadow: 0 0 1px #FFF; +} +.top-right { + top: 10px; + right: 15px; +} +.bottom-right { + bottom: 10px; + right: 15px; +} +.top-left { + top: 10px; + left: 15px; +} +.bottom-left { + bottom: 10px; + left: 15px; +} +.top-center { + top: 10px; + left: 50%; + margin-left: -150px; +} +.bottom-center { + bottom: 10px; + left: 50%; + margin-left: -150px; +} .growl-item.ng-enter, .growl-item.ng-leave { - -webkit-transition:0.5s linear all; - -moz-transition:0.5s linear all; - -o-transition:0.5s linear all; - transition:0.5s linear all; + -webkit-transition:0.5s linear all; + -moz-transition:0.5s linear all; + -o-transition:0.5s linear all; + transition:0.5s linear all; } .growl-item.ng-enter, .growl-item.ng-leave.ng-leave-active { - opacity:0; + opacity:0; } .growl-item.ng-leave, .growl-item.ng-enter.ng-enter-active { - opacity:1; - + opacity:1; } From dd4d7df5798fbfd157f4f1319d0fa50b3305a603 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Tue, 15 Apr 2014 21:27:56 +0200 Subject: [PATCH 033/169] Cleaned up our templated and added extra classes for custom templating, also added default colorized icons --- demo/demo.html | 4 ---- demo/demo.js | 1 + src/growl.css | 45 ++++++++++++++++++++++++++++++++----------- src/growlDirective.js | 13 ++++++------- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/demo/demo.html b/demo/demo.html index 11cff41..3866738 100644 --- a/demo/demo.html +++ b/demo/demo.html @@ -40,10 +40,6 @@ error
-