Skip to content

Commit

Permalink
Update to support angular 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxandxss committed May 11, 2015
1 parent 74d4fc8 commit 84186d2
Show file tree
Hide file tree
Showing 9 changed files with 7,786 additions and 4,630 deletions.
3 changes: 2 additions & 1 deletion dist/angular-toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
newToast.scope.init();
});
} else {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
var sibling = container[0].lastChild ? angular.element(container[0].lastChild) : null;
$animate.enter(newToast.el, container, sibling).then(function() {
newToast.scope.init();
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-toastr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 54 additions & 53 deletions dist/angular-toastr.tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
newToast.scope.init();
});
} else {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
var sibling = container[0].lastChild ? angular.element(container[0].lastChild) : null;
$animate.enter(newToast.el, container, sibling).then(function() {
newToast.scope.init();
});
}
Expand Down Expand Up @@ -294,6 +295,58 @@
});
}());

(function() {
'use strict';

angular.module('toastr')
.directive('progressBar', progressBar);

progressBar.$inject = ['toastrConfig'];

function progressBar(toastrConfig) {
return {
replace: true,
require: '^toast',
templateUrl: function() {
return toastrConfig.templates.progressbar;
},
link: linkFunction
};

function linkFunction(scope, element, attrs, toastCtrl) {
var intervalId, currentTimeOut, hideTime;

toastCtrl.progressBar = scope;

scope.start = function(duration) {
if (intervalId) {
clearInterval(intervalId);
}

currentTimeOut = parseFloat(duration);
hideTime = new Date().getTime() + currentTimeOut;
intervalId = setInterval(updateProgress, 10);
};

scope.stop = function() {
if (intervalId) {
clearInterval(intervalId);
}
};

function updateProgress() {
var percentage = ((hideTime - (new Date().getTime())) / currentTimeOut) * 100;
element.css('width', percentage + '%');
}

scope.$on('$destroy', function() {
// Failsafe stop
clearInterval(intervalId);
});
}
}
}());

(function() {
'use strict';

Expand Down Expand Up @@ -406,57 +459,5 @@
}
}());

(function() {
'use strict';

angular.module('toastr')
.directive('progressBar', progressBar);

progressBar.$inject = ['toastrConfig'];

function progressBar(toastrConfig) {
return {
replace: true,
require: '^toast',
templateUrl: function() {
return toastrConfig.templates.progressbar;
},
link: linkFunction
};

function linkFunction(scope, element, attrs, toastCtrl) {
var intervalId, currentTimeOut, hideTime;

toastCtrl.progressBar = scope;

scope.start = function(duration) {
if (intervalId) {
clearInterval(intervalId);
}

currentTimeOut = parseFloat(duration);
hideTime = new Date().getTime() + currentTimeOut;
intervalId = setInterval(updateProgress, 10);
};

scope.stop = function() {
if (intervalId) {
clearInterval(intervalId);
}
};

function updateProgress() {
var percentage = ((hideTime - (new Date().getTime())) / currentTimeOut) * 100;
element.css('width', percentage + '%');
}

scope.$on('$destroy', function() {
// Failsafe stop
clearInterval(intervalId);
});
}
}
}());

angular.module("toastr").run(["$templateCache", function($templateCache) {$templateCache.put("directives/progressbar/progressbar.html","<div class=\"toast-progress\"></div>\n");
$templateCache.put("directives/toast/toast.html","<div class=\"{{toastClass}} {{toastType}}\" ng-click=\"tapToast()\">\n <div ng-switch on=\"allowHtml\">\n <div ng-switch-default ng-if=\"title\" class=\"{{titleClass}}\">{{title}}</div>\n <div ng-switch-default class=\"{{messageClass}}\">{{message}}</div>\n <div ng-switch-when=\"true\" ng-if=\"title\" class=\"{{titleClass}}\" ng-bind-html=\"title\"></div>\n <div ng-switch-when=\"true\" class=\"{{messageClass}}\" ng-bind-html=\"message\"></div>\n </div>\n <progress-bar ng-if=\"progressBar\"></progress-bar>\n</div>\n");}]);
Loading

0 comments on commit 84186d2

Please # to comment.