diff --git a/.gitignore b/.gitignore index 28f1ba7..ea29b8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.DS_Store \ No newline at end of file +.DS_Store +bower_components/ diff --git a/README.md b/README.md index 25c74aa..0960a1b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## AngularJS Notifications -Current Version: v0.2 +Current Version: v0.3 ### Dependencies @@ -9,10 +9,7 @@ Current Version: v0.2 ### Installation -After you've downloaded this repository, include both the CSS and JavaScript -files and then declare the notifications module as a dependency of your app -module, eg: - + bower install angular-notifications-extended angular.module('myApp', ['notifications']) Once you've finished that business you should be able to use the notifications @@ -59,7 +56,7 @@ desktop notifications by specifying an image to display in the notification. ### HTML5 Notifications If you want to use HTML5 notifications with the same API then you can call -`$notification.enableHtml5Mode()`. +`$notification.enableHtml5Mode()`. **Note:** You will need permissions in order to use HTML5 notifications so for this reason you should call `enableHtml5Mode` in a click event listener or @@ -71,4 +68,3 @@ something. - @pablocaselas : https://github.com/DerekRies/angular-notifications/issues/7 - @deltapsilon : https://github.com/DerekRies/angular-notifications/pull/5 - @michaelwoods : https://github.com/valaky/angular-notifications/commit/2f05f7832f2af9e74b1fe68d55fe04aeabff52c7 - diff --git a/bower.json b/bower.json index 895f3c6..0141af5 100644 --- a/bower.json +++ b/bower.json @@ -2,8 +2,8 @@ "author": { "name": "https://github.com/amcdnl" }, - "name": "angular-notifications", - "version": "0.2.0", + "name": "angular-notifications-extended", + "version": "0.3.0", "main": "notification.js", "ignore": [ "**/.*", @@ -11,6 +11,10 @@ "components" ], "dependencies": { - "angular": "~1.1.3" + "angular": "~1.2" + }, + "repository": { + "type": "git", + "url": "git://github.com/Swimlane/angular-notifications.git" } -} \ No newline at end of file +} diff --git a/dist/notification.css b/dist/notification.css new file mode 100644 index 0000000..cbf43e5 --- /dev/null +++ b/dist/notification.css @@ -0,0 +1,30 @@ +.ng-notification-container { + position: absolute; + z-index: 10000; +} +.ng-notification-container.bottom { + bottom: 20px; +} +.ng-notification-container.right { + right: 20px; +} +.ng-notification-container.left { + left: 20px; +} +.ng-notification-container.top { + top: 35px; +} +.ng-notification-container.center { + left: 50%; + margin-left: -175px; +} +.ng-notification-container .ng-notification-wrapper { + width: 350px; + position: relative; + margin: 5px 0; +} +.ng-notification-container .ng-notification { + clear: both; + max-height: 90px; + overflow: hidden; +} diff --git a/dist/notification.min.js b/dist/notification.min.js new file mode 100644 index 0000000..8e35b79 --- /dev/null +++ b/dist/notification.min.js @@ -0,0 +1 @@ +!function(a){"use strict";"function"==typeof define&&define.amd?define(["angular"],a):a("object"==typeof exports?require("angular"):angular)}(function(a){var b=a.module("notifications",[]);return b.provider("$notification",function(){function b(a,c){function d(a,c,d,f,g){if("webkit"==e.html5Mode)if(0===window.webkitNotifications.checkPermission()){a||(a="favicon.ico");var h=window.webkitNotifications.createNotification(a,c,d);"function"==typeof f&&(h.ondisplay=f),"function"==typeof g&&(h.onclose=g),h.show()}else e.html5Mode=!1;else if("moz"==e.html5Mode){a||(a="favicon.ico");try{b=window.Notification||window.mozNotification;var h=new b(c,{body:d,dir:"auto",lang:"",tag:"test",icon:a})}catch(i){e.html5Mode=!1}}}var e=c,f=JSON.parse(localStorage.getItem("$notifications"))||[],g=[];return{disableHtml5Mode:function(){e.html5Mode=!1},disableType:function(a){e[a].enabled=!1},enableHtml5Mode:function(){e.html5Mode=this.requestHtml5ModePermissions()},enableType:function(a){e[a].enabled=!0},getSettings:function(){return e},toggleType:function(a){e[a].enabled=!e[a].enabled},toggleHtml5Mode:function(){e.html5Mode=!e.html5Mode},requestHtml5ModePermissions:function(){return window.webkitNotifications?0===window.webkitNotifications.checkPermission()?!0:(window.webkitNotifications.requestPermission(function(){0===window.webkitNotifications.checkPermission()?e.html5Mode="webkit":e.html5Mode=!1}),!1):window.Notification||window.mozNotification?(b=window.Notification||window.mozNotification,void b.requestPermission(function(a){"granted"==a?e.html5Mode="moz":e.html5Mode=!1})):!1},getAll:function(){return f},getQueue:function(){return g},info:function(a,b,c,d){return this.notify("info","info",a,b,c,d)},error:function(a,b,c,d){return this.notify("error","error",a,b,c,d)},success:function(a,b,c,d){return this.notify("success","success",a,b,c,d)},warning:function(a,b,c,d){return this.notify("warning","warning",a,b,c,d)},notify:function(a,b,c,d,e,f){return this.makeNotification(a,!1,b,c,d,e,f)},makeNotification:function(b,c,h,i,j,k,l){var m={type:b,image:c,icon:h,title:i,content:j,timestamp:+new Date,userData:k,duration:l,"class":e[b]["class"]};return f.push(m),void 0===l&&(l=e[b].duration),e.html5Mode?d(c,i,j,function(){},function(){}):(g.push(m),l&&a(function(){g.splice(g.indexOf(m),1)},l)),this.save(),m},save:function(){e.localStorage&&localStorage.setItem("$notifications",JSON.stringify(f))},restore:function(){},clear:function(){a(function(){g.splice(0,g.length)}),f=[],this.save()}}}var c={info:{duration:5e3,enabled:!0,"class":"info"},warning:{duration:5e3,enabled:!0,"class":"warning"},error:{duration:5e3,enabled:!0,"class":"danger"},success:{duration:5e3,enabled:!0,"class":"success"},progress:{duration:0,enabled:!0,"class":""},custom:{duration:35e3,enabled:!0,"class":""},details:!0,localStorage:!1,html5Mode:!1,templateName:"ng-notification-template"};this.setSettings=function(b){a.extend(c,b)},this.$get=["$timeout","$templateCache",function(a,d){return d.get("ng-notification-template")||d.put("ng-notification-template",'
'),new b(a,c)}]}),b.directive("notifications",["$notification","$compile","$templateCache",function(a,b,c){function d(a,b,c){var d=c.notifications;d=d.split(" "),b.addClass("ng-notification-container");for(var e=0;e