Starting to add Timeline notifications.

This commit is contained in:
Gunther Brunner
2014-05-12 17:47:19 +09:00
parent 7f94b0beef
commit e4e5109533
14 changed files with 253 additions and 37 deletions

View File

@@ -0,0 +1,41 @@
module.exports = function timelineMessageDirective(Timelines, $sce, $interpolate) {
var defaults = {
message: '',
type: 'info',
ttl: 5000
}
return {
restrict: 'AE',
replace: true,
template: '',
transclude: true,
link: function (scope, iElem, iAttrs, ctrls, transcludeFn) {
var options = angular.extend({}, defaults, scope.$eval(iAttrs.timelineMessage))
transcludeFn(function (elem, scope) {
var e,
html,
interpolateFn,
safeHtml;
// Create temporary wrapper element so we can grab the inner html
e = angular.element(document.createElement('div'))
e.append(elem)
html = e.html()
// Interpolate expressions in current scope
interpolateFn = $interpolate(html)
html = interpolateFn(scope)
// Tell Angular the HTML can be trusted so it can be used in ng-bind-html
safeHtml = $sce.trustAsHtml(html)
// Add notification
Timelines.add(safeHtml, options.type, options.ttl)
})
}
}
}