From c6a4204132f06855b39d9eeb8c97a2325e2e1949 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Thu, 20 Nov 2014 11:53:13 +0100 Subject: [PATCH] Updated the build files, added the readme --- README.md | 13 +++++++++++++ bower.json | 2 +- build/angular-growl.css | 2 +- build/angular-growl.js | 12 ++++++++---- build/angular-growl.min.css | 2 +- build/angular-growl.min.js | 4 ++-- package.json | 2 +- src/growlFactory.js | 2 +- 8 files changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7b681e3..c41760f 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,19 @@ Live demo's can be found on the following codepen collection: ## [Codepen Collection](http://codepen.io/collection/Jhcpi/) ##Changelog +**0.8.0** - TBE TODO +* Code clean up +* Testing +* Latest angular support +* [Finding a solution for this issue](https://github.com/JanStevens/angular-growl-2/issues/54) + +**0.7.2** - 20 Nov 2014 +* Possibility to toggle the translation of messages (@schoes) [pull #55](https://github.com/JanStevens/angular-growl-2/pull/55) +* Check if the response is undefined (Offline Connections) (@brunoporto) [pull #50](https://github.com/JanStevens/angular-growl-2/pull/50) +* Prevent NPEs when working with server-side messages (@madhead) [pull #45](https://github.com/JanStevens/angular-growl-2/pull/45) +* Added a general method for setting the Growl type based on a server response (@madhead) [pull #41](https://github.com/JanStevens/angular-growl-2/pull/41) +* Split Growl directive in a growl factory added a way to programatically close messages and a setText to update the message text (@chasemgray) [pull #38](https://github.com/JanStevens/angular-growl-2/pull/38) + **0.7.0** - 10 Aug 2014 * Added new documentation website with examples instead of this readme. * Growl Containers are now responsive for mobile devices (@tlvince) [pull #17](https://github.com/JanStevens/angular-growl-2/pull/17) diff --git a/bower.json b/bower.json index 1f20d29..05d0e8e 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.7.1", + "version": "0.7.2", "homepage": "http://janstevens.github.io/angular-growl-2", "repository": { "type": "git", diff --git a/build/angular-growl.css b/build/angular-growl.css index 87ab0c1..c2c81d9 100644 --- a/build/angular-growl.css +++ b/build/angular-growl.css @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.7.1 - 2014-10-06 + * angular-growl-v2 - v0.7.2 - 2014-11-20 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ diff --git a/build/angular-growl.js b/build/angular-growl.js index 94f6e11..e995911 100644 --- a/build/angular-growl.js +++ b/build/angular-growl.js @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.7.1 - 2014-10-06 + * angular-growl-v2 - v0.7.2 - 2014-11-20 * http://janstevens.github.io/angular-growl-2 * Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT */ @@ -92,7 +92,7 @@ angular.module('angular-growl').provider('growl', function () { error: null, warning: null, info: null - }, _messagesKey = 'messages', _messageTextKey = 'text', _messageTitleKey = 'title', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _messageVariableKey = 'variables', _referenceId = 0, _inline = false, _position = 'top-right', _disableCloseButton = false, _disableIcons = false, _reverseOrder = false, _disableCountDown = false; + }, _messagesKey = 'messages', _messageTextKey = 'text', _messageTitleKey = 'title', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _messageVariableKey = 'variables', _referenceId = 0, _inline = false, _position = 'top-right', _disableCloseButton = false, _disableIcons = false, _reverseOrder = false, _disableCountDown = false, _translateMessages = true; this.globalTimeToLive = function (ttl) { if (typeof ttl === 'object') { for (var k in ttl) { @@ -108,6 +108,9 @@ angular.module('angular-growl').provider('growl', function () { } } }; + this.globalTranslateMessages = function (translateMessages) { + _translateMessages = translateMessages; + }; this.globalDisableCloseButton = function (disableCloseButton) { _disableCloseButton = disableCloseButton; }; @@ -149,7 +152,7 @@ angular.module('angular-growl').provider('growl', function () { 'growl', function ($q, growl) { function checkResponse(response) { - if (response.data[_messagesKey] && response.data[_messagesKey].length > 0) { + if (response !== undefined && response.data[_messagesKey] && response.data[_messagesKey].length > 0) { growl.addServerMessages(response.data[_messagesKey]); } } @@ -181,7 +184,7 @@ angular.module('angular-growl').provider('growl', function () { } catch (e) { } function broadcastMessage(message) { - if (translate) { + if (translate && message.translateMessage) { message.text = translate(message.text, message.variables); } else { var polation = $interpolate(message.text); @@ -206,6 +209,7 @@ angular.module('angular-growl').provider('growl', function () { disableCountDown: _config.disableCountDown === undefined ? _disableCountDown : _config.disableCountDown, position: _config.position || _position, referenceId: _config.referenceId || _referenceId, + translateMessage: _config.translateMessage === undefined ? _translateMessages : _config.translateMessage, destroy: function () { growlMessages.deleteMessage(message); }, diff --git a/build/angular-growl.min.css b/build/angular-growl.min.css index 2c67ec7..86c5a5e 100644 --- a/build/angular-growl.min.css +++ b/build/angular-growl.min.css @@ -1,5 +1,5 @@ /** - * angular-growl-v2 - v0.7.1 - 2014-10-06 + * angular-growl-v2 - v0.7.2 - 2014-11-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 c0e3d5e..a01d4d2 100644 --- a/build/angular-growl.min.js +++ b/build/angular-growl.min.js @@ -1,6 +1,6 @@ /** - * angular-growl-v2 - v0.7.1 - 2014-10-06 + * angular-growl-v2 - v0.7.2 - 2014-11-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",[function(){"use strict";return{restrict:"A",templateUrl:"templates/growl/growl.html",replace:!1,scope:{reference:"@",inline:"@",limitMessages:"="},controller:["$scope","$timeout","growl","growlMessages",function(a,b,c,d){a.referenceId=a.reference||0,d.initDirective(a.referenceId,a.limitMessages),a.growlMessages=d,a.inlineMessage=a.inline||c.inlineMessages(),a.$watch("limitMessages",function(b){var c=d.directives[a.referenceId];angular.isUndefined(b)||angular.isUndefined(c)||(c.limitMessages=b)}),a.stopTimeoutClose=function(a){a.clickToClose||(angular.forEach(a.promises,function(a){b.cancel(a)}),a.close?d.deleteMessage(a):a.close=!0)},a.alertClasses=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":"warning"===a.severity,icon:a.disableIcons===!1,"alert-dismissable":!a.disableCloseButton}},a.showCountDown=function(a){return!a.disableCountDown&&a.ttl>0},a.wrapperClasses=function(){var b={};return b["growl-fixed"]=!a.inlineMessage,b[c.position()]=!0,b},a.computeTitle=function(a){var b={success:"Success",error:"Error",info:"Information",warn:"Warning"};return b[a.severity]}}]}}]),angular.module("angular-growl").run(["$templateCache",function(a){"use strict";void 0===a.get("templates/growl/growl.html")&&a.put("templates/growl/growl.html",'

')}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a={success:null,error:null,warning:null,info:null},b="messages",c="text",d="title",e="severity",f=!0,g="variables",h=0,i=!1,j="top-right",k=!1,l=!1,m=!1,n=!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.globalDisableCloseButton=function(a){k=a},this.globalDisableIcons=function(a){l=a},this.globalReversedOrder=function(a){m=a},this.globalDisableCountDown=function(a){n=a},this.messageVariableKey=function(a){g=a},this.globalInlineMessages=function(a){i=a},this.globalPosition=function(a){j=a},this.messagesKey=function(a){b=a},this.messageTextKey=function(a){c=a},this.messageTitleKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,c){function d(a){a.data[b]&&a.data[b].length>0&&c.addServerMessages(a.data[b])}return{response:function(a){return d(a),a},responseError:function(b){return d(b),a.reject(b)}}}],this.$get=["$rootScope","$interpolate","$sce","$filter","$timeout","growlMessages",function(b,o,p,q,r,s){function t(a){if(F)a.text=F(a.text,a.variables);else{var c=o(a.text);a.text=c(a.variables)}var d=s.addMessage(a);return b.$broadcast("growlMessage",a),r(function(){},0),d}function u(b,c,d){var e,f=c||{};return e={text:b,title:f.title,severity:d,ttl:f.ttl||a[d],variables:f.variables||{},disableCloseButton:void 0===f.disableCloseButton?k:f.disableCloseButton,disableIcons:void 0===f.disableIcons?l:f.disableIcons,disableCountDown:void 0===f.disableCountDown?n:f.disableCountDown,position:f.position||j,referenceId:f.referenceId||h,destroy:function(){s.deleteMessage(e)},setText:function(a){e.text=p.trustAsHtml(String(a))},onclose:f.onclose,onopen:f.onopen},t(e)}function v(a,b){return u(a,b,"warning")}function w(a,b){return u(a,b,"error")}function x(a,b){return u(a,b,"info")}function y(a,b){return u(a,b,"success")}function z(a,b,c){c=(c||"error").toLowerCase(),u(a,b,c)}function A(a){if(a&&a.length){var b,f,h,i;for(i=a.length,b=0;i>b;b++)if(f=a[b],f[c]){h=(f[e]||"error").toLowerCase();var j={};j.variables=f[g]||{},j.title=f[d],u(f[c],j,h)}}}function B(){return f}function C(){return m}function D(){return i}function E(){return j}var F;s.onlyUnique=f,s.reverseOrder=m;try{F=q("translate")}catch(G){}return{warning:v,error:w,info:x,success:y,general:z,addServerMessages:A,onlyUnique:B,reverseOrder:C,inlineMessages:D,position:E}}]}),angular.module("angular-growl").service("growlMessages",["$sce","$timeout",function(a,b){"use strict";this.directives={},this.initDirective=function(a,b){this.directives[a]={messages:[],limitMessages:b}},this.addMessage=function(c){var d,e,f=this.directives[c.referenceId],g=f.messages;if(!this.onlyUnique||(angular.forEach(g,function(b){e=a.getTrustedHtml(b.text),c.text===e&&c.severity===b.severity&&b.title===b.title&&(d=!0)}),!d)){if(c.text=a.trustAsHtml(String(c.text)),c.ttl&&-1!==c.ttl&&(c.countdown=c.ttl/1e3,c.promises=[],c.close=!1,c.countdownFunction=function(){c.countdown>1?(c.countdown--,c.promises.push(b(c.countdownFunction,1e3))):c.countdown--}),angular.isDefined(f.limitMessages)){var h=g.length-(f.limitMessages-1);h>0&&g.splice(f.limitMessages-1,h)}return this.reverseOrder?g.unshift(c):g.push(c),"function"==typeof c.onopen&&c.onopen(),c.ttl&&-1!==c.ttl&&(c.promises.push(b(angular.bind(this,function(){this.deleteMessage(c)}),c.ttl)),c.promises.push(b(c.countdownFunction,1e3))),c}},this.deleteMessage=function(a){var b=this.directives[a.referenceId].messages,c=b.indexOf(a);c>-1&&(b[c].close=!0,b.splice(c,1)),"function"==typeof a.onclose&&a.onclose()}}]); \ No newline at end of file +angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",[function(){"use strict";return{restrict:"A",templateUrl:"templates/growl/growl.html",replace:!1,scope:{reference:"@",inline:"@",limitMessages:"="},controller:["$scope","$timeout","growl","growlMessages",function(a,b,c,d){a.referenceId=a.reference||0,d.initDirective(a.referenceId,a.limitMessages),a.growlMessages=d,a.inlineMessage=a.inline||c.inlineMessages(),a.$watch("limitMessages",function(b){var c=d.directives[a.referenceId];angular.isUndefined(b)||angular.isUndefined(c)||(c.limitMessages=b)}),a.stopTimeoutClose=function(a){a.clickToClose||(angular.forEach(a.promises,function(a){b.cancel(a)}),a.close?d.deleteMessage(a):a.close=!0)},a.alertClasses=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":"warning"===a.severity,icon:a.disableIcons===!1,"alert-dismissable":!a.disableCloseButton}},a.showCountDown=function(a){return!a.disableCountDown&&a.ttl>0},a.wrapperClasses=function(){var b={};return b["growl-fixed"]=!a.inlineMessage,b[c.position()]=!0,b},a.computeTitle=function(a){var b={success:"Success",error:"Error",info:"Information",warn:"Warning"};return b[a.severity]}}]}}]),angular.module("angular-growl").run(["$templateCache",function(a){"use strict";void 0===a.get("templates/growl/growl.html")&&a.put("templates/growl/growl.html",'

')}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a={success:null,error:null,warning:null,info:null},b="messages",c="text",d="title",e="severity",f=!0,g="variables",h=0,i=!1,j="top-right",k=!1,l=!1,m=!1,n=!1,o=!0;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.globalTranslateMessages=function(a){o=a},this.globalDisableCloseButton=function(a){k=a},this.globalDisableIcons=function(a){l=a},this.globalReversedOrder=function(a){m=a},this.globalDisableCountDown=function(a){n=a},this.messageVariableKey=function(a){g=a},this.globalInlineMessages=function(a){i=a},this.globalPosition=function(a){j=a},this.messagesKey=function(a){b=a},this.messageTextKey=function(a){c=a},this.messageTitleKey=function(a){d=a},this.messageSeverityKey=function(a){e=a},this.onlyUniqueMessages=function(a){f=a},this.serverMessagesInterceptor=["$q","growl",function(a,c){function d(a){void 0!==a&&a.data[b]&&a.data[b].length>0&&c.addServerMessages(a.data[b])}return{response:function(a){return d(a),a},responseError:function(b){return d(b),a.reject(b)}}}],this.$get=["$rootScope","$interpolate","$sce","$filter","$timeout","growlMessages",function(b,p,q,r,s,t){function u(a){if(G&&a.translateMessage)a.text=G(a.text,a.variables);else{var c=p(a.text);a.text=c(a.variables)}var d=t.addMessage(a);return b.$broadcast("growlMessage",a),s(function(){},0),d}function v(b,c,d){var e,f=c||{};return e={text:b,title:f.title,severity:d,ttl:f.ttl||a[d],variables:f.variables||{},disableCloseButton:void 0===f.disableCloseButton?k:f.disableCloseButton,disableIcons:void 0===f.disableIcons?l:f.disableIcons,disableCountDown:void 0===f.disableCountDown?n:f.disableCountDown,position:f.position||j,referenceId:f.referenceId||h,translateMessage:void 0===f.translateMessage?o:f.translateMessage,destroy:function(){t.deleteMessage(e)},setText:function(a){e.text=q.trustAsHtml(String(a))},onclose:f.onclose,onopen:f.onopen},u(e)}function w(a,b){return v(a,b,"warning")}function x(a,b){return v(a,b,"error")}function y(a,b){return v(a,b,"info")}function z(a,b){return v(a,b,"success")}function A(a,b,c){c=(c||"error").toLowerCase(),v(a,b,c)}function B(a){if(a&&a.length){var b,f,h,i;for(i=a.length,b=0;i>b;b++)if(f=a[b],f[c]){h=(f[e]||"error").toLowerCase();var j={};j.variables=f[g]||{},j.title=f[d],v(f[c],j,h)}}}function C(){return f}function D(){return m}function E(){return i}function F(){return j}var G;t.onlyUnique=f,t.reverseOrder=m;try{G=r("translate")}catch(H){}return{warning:w,error:x,info:y,success:z,general:A,addServerMessages:B,onlyUnique:C,reverseOrder:D,inlineMessages:E,position:F}}]}),angular.module("angular-growl").service("growlMessages",["$sce","$timeout",function(a,b){"use strict";this.directives={},this.initDirective=function(a,b){this.directives[a]={messages:[],limitMessages:b}},this.addMessage=function(c){var d,e,f=this.directives[c.referenceId],g=f.messages;if(!this.onlyUnique||(angular.forEach(g,function(b){e=a.getTrustedHtml(b.text),c.text===e&&c.severity===b.severity&&b.title===b.title&&(d=!0)}),!d)){if(c.text=a.trustAsHtml(String(c.text)),c.ttl&&-1!==c.ttl&&(c.countdown=c.ttl/1e3,c.promises=[],c.close=!1,c.countdownFunction=function(){c.countdown>1?(c.countdown--,c.promises.push(b(c.countdownFunction,1e3))):c.countdown--}),angular.isDefined(f.limitMessages)){var h=g.length-(f.limitMessages-1);h>0&&g.splice(f.limitMessages-1,h)}return this.reverseOrder?g.unshift(c):g.push(c),"function"==typeof c.onopen&&c.onopen(),c.ttl&&-1!==c.ttl&&(c.promises.push(b(angular.bind(this,function(){this.deleteMessage(c)}),c.ttl)),c.promises.push(b(c.countdownFunction,1e3))),c}},this.deleteMessage=function(a){var b=this.directives[a.referenceId].messages,c=b.indexOf(a);c>-1&&(b[c].close=!0,b.splice(c,1)),"function"==typeof a.onclose&&a.onclose()}}]); \ No newline at end of file diff --git a/package.json b/package.json index 9b264da..5f08620 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-growl-v2", - "version": "0.7.1", + "version": "0.7.2", "description": "growl like notifications for angularJS projects, using bootstrap alert classes", "repository": { "type": "git", diff --git a/src/growlFactory.js b/src/growlFactory.js index 9ec5699..b2962f0 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -157,7 +157,7 @@ angular.module("angular-growl").provider("growl", function() { */ this.serverMessagesInterceptor = ['$q', 'growl', function ($q, growl) { function checkResponse(response) { - if (response!=undefined && response.data[_messagesKey] && response.data[_messagesKey].length > 0) { + if (response !== undefined && response.data[_messagesKey] && response.data[_messagesKey].length > 0) { growl.addServerMessages(response.data[_messagesKey]); } }