| |
| |
| |
| |
| |
| |
|
|
| (function ($, require) { |
| var exports = require('piwik/UI'); |
|
|
| |
| |
| |
| var Notification = function () { |
| this.notificationId = null; |
| }; |
|
|
| |
| |
| |
| Notification.prototype.show = function (message, options) { |
| options = checkOptions(options); |
| options.noclear = !! options.noclear; |
| this.notificationId = window.CoreHome.NotificationsStore.show($.extend({ message: message }, options)); |
| }; |
|
|
| |
| |
| |
| Notification.prototype.remove = function (notificationId) { |
| window.CoreHome.NotificationsStore.remove(notificationId); |
| }; |
|
|
| |
| |
| |
| Notification.prototype.scrollToNotification = function () { |
| if (this.notificationId) { |
| window.CoreHome.NotificationsStore.scrollToNotification(this.notificationId); |
| } |
| }; |
|
|
| |
| |
| |
| Notification.prototype.toast = function (message, options) { |
| options = checkOptions(options); |
| options.noclear = !! options.noclear; |
| window.CoreHome.NotificationsStore.toast($.extend({ message: message }, options)); |
| }; |
|
|
| exports.Notification = Notification; |
|
|
| function checkOptions(options) { |
| if (options && !$.isPlainObject(options)) { |
| throw new Error('Options has the wrong format, cannot display notification'); |
| } else if (!options) { |
| options = {}; |
| } |
| return options; |
| } |
|
|
| })(jQuery, require); |
|
|