Skip to content

Commit 84186d2

Browse files
committed
Update to support angular 1.4
1 parent 74d4fc8 commit 84186d2

File tree

9 files changed

+7786
-4630
lines changed

9 files changed

+7786
-4630
lines changed

dist/angular-toastr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
newToast.scope.init();
165165
});
166166
} else {
167-
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
167+
var sibling = container[0].lastChild ? angular.element(container[0].lastChild) : null;
168+
$animate.enter(newToast.el, container, sibling).then(function() {
168169
newToast.scope.init();
169170
});
170171
}

dist/angular-toastr.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-toastr.tpls.js

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
newToast.scope.init();
165165
});
166166
} else {
167-
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
167+
var sibling = container[0].lastChild ? angular.element(container[0].lastChild) : null;
168+
$animate.enter(newToast.el, container, sibling).then(function() {
168169
newToast.scope.init();
169170
});
170171
}
@@ -294,6 +295,58 @@
294295
});
295296
}());
296297

298+
(function() {
299+
'use strict';
300+
301+
angular.module('toastr')
302+
.directive('progressBar', progressBar);
303+
304+
progressBar.$inject = ['toastrConfig'];
305+
306+
function progressBar(toastrConfig) {
307+
return {
308+
replace: true,
309+
require: '^toast',
310+
templateUrl: function() {
311+
return toastrConfig.templates.progressbar;
312+
},
313+
link: linkFunction
314+
};
315+
316+
function linkFunction(scope, element, attrs, toastCtrl) {
317+
var intervalId, currentTimeOut, hideTime;
318+
319+
toastCtrl.progressBar = scope;
320+
321+
scope.start = function(duration) {
322+
if (intervalId) {
323+
clearInterval(intervalId);
324+
}
325+
326+
currentTimeOut = parseFloat(duration);
327+
hideTime = new Date().getTime() + currentTimeOut;
328+
intervalId = setInterval(updateProgress, 10);
329+
};
330+
331+
scope.stop = function() {
332+
if (intervalId) {
333+
clearInterval(intervalId);
334+
}
335+
};
336+
337+
function updateProgress() {
338+
var percentage = ((hideTime - (new Date().getTime())) / currentTimeOut) * 100;
339+
element.css('width', percentage + '%');
340+
}
341+
342+
scope.$on('$destroy', function() {
343+
// Failsafe stop
344+
clearInterval(intervalId);
345+
});
346+
}
347+
}
348+
}());
349+
297350
(function() {
298351
'use strict';
299352

@@ -406,57 +459,5 @@
406459
}
407460
}());
408461

409-
(function() {
410-
'use strict';
411-
412-
angular.module('toastr')
413-
.directive('progressBar', progressBar);
414-
415-
progressBar.$inject = ['toastrConfig'];
416-
417-
function progressBar(toastrConfig) {
418-
return {
419-
replace: true,
420-
require: '^toast',
421-
templateUrl: function() {
422-
return toastrConfig.templates.progressbar;
423-
},
424-
link: linkFunction
425-
};
426-
427-
function linkFunction(scope, element, attrs, toastCtrl) {
428-
var intervalId, currentTimeOut, hideTime;
429-
430-
toastCtrl.progressBar = scope;
431-
432-
scope.start = function(duration) {
433-
if (intervalId) {
434-
clearInterval(intervalId);
435-
}
436-
437-
currentTimeOut = parseFloat(duration);
438-
hideTime = new Date().getTime() + currentTimeOut;
439-
intervalId = setInterval(updateProgress, 10);
440-
};
441-
442-
scope.stop = function() {
443-
if (intervalId) {
444-
clearInterval(intervalId);
445-
}
446-
};
447-
448-
function updateProgress() {
449-
var percentage = ((hideTime - (new Date().getTime())) / currentTimeOut) * 100;
450-
element.css('width', percentage + '%');
451-
}
452-
453-
scope.$on('$destroy', function() {
454-
// Failsafe stop
455-
clearInterval(intervalId);
456-
});
457-
}
458-
}
459-
}());
460-
461462
angular.module("toastr").run(["$templateCache", function($templateCache) {$templateCache.put("directives/progressbar/progressbar.html","<div class=\"toast-progress\"></div>\n");
462463
$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");}]);

0 commit comments

Comments
 (0)