Created
October 23, 2014 09:37
-
-
Save alpavlove/e43bb539488a1ecd97e4 to your computer and use it in GitHub Desktop.
notification_service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global $, angular, _ */ | |
(function () { | |
'use strict'; | |
/** | |
* | |
* @description: Сервис нотификации | |
* | |
* @example: | |
* NotificationService.show({text: 'Все у вас ОК!', type: 'success'}); | |
* NotificationService.show({text: 'Что-то пошло не так.!', type: 'error'}); | |
* NotificationService.show({text: 'Одумайтесь!', type: 'alert'}); | |
*/ | |
/* @ngInject */ | |
function NotificationService () { | |
var defaultOptions, callNoty, publicAPI; | |
defaultOptions = { | |
layout: 'bottomLeft', | |
theme: 'CaseProTheme', | |
maxVisible: 5, | |
type: 'success', | |
text: 'Что-то прошло успешно.' | |
}; | |
callNoty = function (options) { | |
return noty(options || defaultOptions); | |
}; | |
publicAPI = { | |
/** | |
* @description Отображаем уведомления | |
* @param {string} text Сообщение для вывода в уведомлении | |
* @param {string} type Тип уведомления. Поддерживаются следующие типы: 'success', 'error', 'alert' | |
*/ | |
show: function (text, type) { | |
callNoty({text: text || defaultOptions.text, type: type || defaultOptions.type, layout: defaultOptions.layout, theme: defaultOptions.theme, maxVisible: defaultOptions.maxVisible}); | |
}, | |
/** | |
* @description Закрываем все уведомления | |
*/ | |
closeAll: function () { | |
return $.noty.closeAll(); | |
}, | |
/** | |
* @description Очищаем очередь уведомлений | |
*/ | |
clearQueue: function () { | |
return $.noty.clearQueue(); | |
} | |
}; | |
return publicAPI; | |
} | |
angular | |
.module('app') | |
.service('NotificationService', NotificationService); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment