diff --git a/README.md b/README.md index 097d939..bc18ff8 100755 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ The `notify` function can either be passed a string or an object. When passing * `scope` - Optional. A valid Angular scope object. The scope of the template will be created by calling `$new()` on this scope. * `position` - Optional. `center`, `left` and `right` are the only acceptable values. * `container` - Optional. Element that contains each notification. Defaults to `document.body`. +* `parentalPosition` - Optional. Boolean for whether or not the notification should be positioned absolutely from it container intead of CSS position:fixed. Requires the parent to have position:relative. This function will return an object with a `close()` method and a `message` property. diff --git a/angular-notify.css b/angular-notify.css index ec993f9..54e86ca 100755 --- a/angular-notify.css +++ b/angular-notify.css @@ -34,6 +34,14 @@ right:15px; } +.cg-notify-message-parental-position{ + position: absolute; +} + +.cg-notify-notification-parent{ + position: relative; +} + .cg-notify-message a { font-weight:bold; color:inherit; diff --git a/angular-notify.html b/angular-notify.html index 3c00178..74fb4ba 100755 --- a/angular-notify.html +++ b/angular-notify.html @@ -1,7 +1,8 @@
diff --git a/angular-notify.js b/angular-notify.js index 7fbdf6e..5c28502 100755 --- a/angular-notify.js +++ b/angular-notify.js @@ -8,7 +8,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' var position = 'center'; var container = document.body; var maximumOpen = 0; - + var parentalPosition = false; var messageElements = []; var openNotificationsScope = []; @@ -21,12 +21,14 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' args.duration = args.duration ? args.duration : defaultDuration; args.templateUrl = args.templateUrl ? args.templateUrl : defaultTemplateUrl; args.container = args.container ? args.container : container; + args.parentalPosition = args.parentalPosition ? args.parentalPosition : parentalPosition; args.classes = args.classes ? args.classes : ''; var scope = args.scope ? args.scope.$new() : $rootScope.$new(); scope.$position = args.position ? args.position : position; scope.$message = args.message; scope.$classes = args.classes; + scope.$parentalPosition = args.parentalPosition; scope.$messageTemplate = args.messageTemplate; if (maximumOpen > 0) { @@ -65,6 +67,10 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' } } + if (args.parentalPosition === true){ + angular.element(args.container).addClass('cg-notify-notification-parent'); + } + angular.element(args.container).append(templateElement); messageElements.push(templateElement); @@ -142,6 +148,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' position = !angular.isUndefined(args.position) ? args.position : position; container = args.container ? args.container : container; maximumOpen = args.maximumOpen ? args.maximumOpen : maximumOpen; + parentalPosition = args.parentalPosition ? args.parentalPosition : parentalPosition; }; notify.closeAll = function(){