summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/angular-ui-notification/src
diff options
context:
space:
mode:
Diffstat (limited to 'afb-client/bower_components/angular-ui-notification/src')
-rw-r--r--afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.html4
-rw-r--r--afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.js172
-rw-r--r--afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.less55
3 files changed, 231 insertions, 0 deletions
diff --git a/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.html b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.html
new file mode 100644
index 0000000..5f628fc
--- /dev/null
+++ b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.html
@@ -0,0 +1,4 @@
+<div class="ui-notification">
+ <h3 ng-show="title" ng-bind-html="title"></h3>
+ <div class="message" ng-bind-html="message"></div>
+</div> \ No newline at end of file
diff --git a/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.js b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.js
new file mode 100644
index 0000000..e94fa2c
--- /dev/null
+++ b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.js
@@ -0,0 +1,172 @@
+angular.module('ui-notification',[]);
+
+angular.module('ui-notification').provider('Notification', function() {
+
+ this.options = {
+ delay: 5000,
+ startTop: 10,
+ startRight: 10,
+ verticalSpacing: 10,
+ horizontalSpacing: 10,
+ positionX: 'right',
+ positionY: 'top',
+ replaceMessage: false,
+ templateUrl: 'angular-ui-notification.html'
+ };
+
+ this.setOptions = function(options) {
+ if (!angular.isObject(options)) throw new Error("Options should be an object!");
+ this.options = angular.extend({}, this.options, options);
+ };
+
+ this.$get = function($timeout, $http, $compile, $templateCache, $rootScope, $injector, $sce, $q, $window) {
+ var options = this.options;
+
+ var startTop = options.startTop;
+ var startRight = options.startRight;
+ var verticalSpacing = options.verticalSpacing;
+ var horizontalSpacing = options.horizontalSpacing;
+ var delay = options.delay;
+
+ var messageElements = [];
+ var isResizeBound = false;
+
+ var notify = function(args, t){
+ var deferred = $q.defer();
+
+ if (typeof args !== 'object') {
+ args = {message:args};
+ }
+
+ args.scope = args.scope ? args.scope : $rootScope;
+ args.template = args.templateUrl ? args.templateUrl : options.templateUrl;
+ args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
+ args.type = t ? t : '';
+ args.positionY = args.positionY ? args.positionY : options.positionY;
+ args.positionX = args.positionX ? args.positionX : options.positionX;
+ args.replaceMessage = args.replaceMessage ? args.replaceMessage : options.replaceMessage;
+
+ $http.get(args.template,{cache: $templateCache}).success(function(template) {
+
+ var scope = args.scope.$new();
+ scope.message = $sce.trustAsHtml(args.message);
+ scope.title = $sce.trustAsHtml(args.title);
+ scope.t = args.type.substr(0,1);
+ scope.delay = args.delay;
+
+ var reposite = function() {
+ var j = 0;
+ var k = 0;
+ var lastTop = startTop;
+ var lastRight = startRight;
+ var lastPosition = [];
+ for(var i = messageElements.length - 1; i >= 0; i --) {
+ var element = messageElements[i];
+ if (args.replaceMessage && i < messageElements.length - 1) {
+ element.addClass('killed');
+ continue;
+ }
+ var elHeight = parseInt(element[0].offsetHeight);
+ var elWidth = parseInt(element[0].offsetWidth);
+ var position = lastPosition[element._positionY+element._positionX];
+
+ if ((top + elHeight) > window.innerHeight) {
+ position = startTop;
+ k ++;
+ j = 0;
+ }
+
+ var top = (lastTop = position ? (j === 0 ? position : position + verticalSpacing) : startTop);
+ var right = lastRight + (k * (horizontalSpacing + elWidth));
+
+ element.css(element._positionY, top + 'px');
+ if (element._positionX == 'center') {
+ element.css('left', parseInt(window.innerWidth / 2 - elWidth / 2) + 'px');
+ } else {
+ element.css(element._positionX, right + 'px');
+ }
+
+ lastPosition[element._positionY+element._positionX] = top + elHeight;
+
+ j ++;
+ }
+ };
+
+ var templateElement = $compile(template)(scope);
+ templateElement._positionY = args.positionY;
+ templateElement._positionX = args.positionX;
+ templateElement.addClass(args.type);
+ templateElement.bind('webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd click', function(e){
+ e = e.originalEvent || e;
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 1)){
+ templateElement.remove();
+ messageElements.splice(messageElements.indexOf(templateElement), 1);
+ reposite();
+ }
+ });
+ if (angular.isNumber(args.delay)) {
+ $timeout(function() {
+ templateElement.addClass('killed');
+ }, args.delay);
+ }
+
+ angular.element(document.getElementsByTagName('body')).append(templateElement);
+ var offset = -(parseInt(templateElement[0].offsetHeight) + 50);
+ templateElement.css(templateElement._positionY, offset + "px");
+ messageElements.push(templateElement);
+
+ scope._templateElement = templateElement;
+
+ scope.kill = function(isHard) {
+ if (isHard) {
+ messageElements.splice(messageElements.indexOf(scope._templateElement), 1);
+ scope._templateElement.remove();
+ $timeout(reposite);
+ } else {
+ scope._templateElement.addClass('killed');
+ }
+ };
+
+ $timeout(reposite);
+
+ if (!isResizeBound) {
+ angular.element($window).bind('resize', function(e) {
+ $timeout(reposite);
+ });
+ isResizeBound = true;
+ }
+
+ deferred.resolve(scope);
+
+ }).error(function(data){
+ throw new Error('Template ('+args.template+') could not be loaded. ' + data);
+ });
+
+ return deferred.promise;
+ };
+
+ notify.primary = function(args) {
+ return this(args, 'primary');
+ };
+ notify.error = function(args) {
+ return this(args, 'error');
+ };
+ notify.success = function(args) {
+ return this(args, 'success');
+ };
+ notify.info = function(args) {
+ return this(args, 'info');
+ };
+ notify.warning = function(args) {
+ return this(args, 'warning');
+ };
+
+ notify.clearAll = function() {
+ angular.forEach(messageElements, function(element) {
+ element.addClass('killed');
+ });
+ };
+
+ return notify;
+ };
+});
diff --git a/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.less b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.less
new file mode 100644
index 0000000..5b66b01
--- /dev/null
+++ b/afb-client/bower_components/angular-ui-notification/src/angular-ui-notification.less
@@ -0,0 +1,55 @@
+@import "../bower_components/bootstrap/less/variables.less";
+@import "../bower_components/bootstrap/less/mixins.less";
+
+
+.ui-notification {
+ position: fixed;
+ z-index: 9999;
+ box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3);
+ cursor: pointer;
+ width: 300px;
+ color: @btn-primary-color;
+ background: @brand-primary;
+ .transition(all ease 0.5s);
+ &.killed {
+ opacity: 0;
+ .transition(opacity ease 1s);
+ }
+ & > h3 {
+ display: block;
+ margin: 10px 10px 0 10px;
+ padding: 0 0 5px 0;
+ text-align: left;
+ font-size: @font-size-base;
+ font-weight: bold;
+ border-bottom: 1px solid fadeout(@btn-primary-color, 70%);
+ }
+ & a {
+ color: @btn-primary-color;
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+ & > .message {
+ margin: 10px 10px 10px 10px;
+ }
+ &.warning {
+ color: @btn-warning-color;
+ background: @brand-warning;
+ }
+ &.error {
+ color: @btn-danger-color;
+ background: @brand-danger;
+ }
+ &.success {
+ color: @btn-success-color;
+ background: @brand-success;
+ }
+ &.info {
+ color: @btn-info-color;
+ background: @brand-info;
+ }
+ &:hover {
+ opacity: 0.7;
+ }
+} \ No newline at end of file