//Author : @arboshiki /** * Generates random string of n length. * String contains only letters and numbers * * @param {int} n * @returns {String} */ Math.randomString = function (n) { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < n; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; }; var Lobibox = Lobibox || {}; (function () { var LobiboxNotify = function (type, options) { //------------------------------------------------------------------------------ //----------------PROTOTYPE VARIABLES------------------------------------------- //------------------------------------------------------------------------------ this.$type = null; this.$options = null; this.$el = null; //------------------------------------------------------------------------------ //-----------------PRIVATE VARIABLES-------------------------------------------- //------------------------------------------------------------------------------ var me = this; //------------------------------------------------------------------------------ //-----------------PRIVATE FUNCTIONS-------------------------------------------- //------------------------------------------------------------------------------ var _processInput = function (options) { if (options.size === 'mini' || options.size === 'large') { options = $.extend({}, Lobibox.notify.OPTIONS[options.size], options); } options = $.extend({}, Lobibox.notify.OPTIONS[me.$type], Lobibox.notify.DEFAULTS, options); if (options.size !== 'mini' && options.title === true) { options.title = Lobibox.notify.OPTIONS[me.$type].title; } else if (options.size === 'mini' && options.title === true) { options.title = false; } if (options.icon === true) { options.icon = Lobibox.notify.OPTIONS.icons[options.iconSource][me.$type]; } if (options.sound === true) { options.sound = Lobibox.notify.OPTIONS[me.$type].sound; } if (options.sound) { options.sound = options.soundPath + options.sound + options.soundExt; } return options; }; var _appendInWrapper = function ($el, $wrapper) { if (me.$options.size === 'normal') { if ($wrapper.hasClass('bottom')) { $wrapper.prepend($el); } else { $wrapper.append($el); } } else if (me.$options.size === 'mini') { if ($wrapper.hasClass('bottom')) { $wrapper.prepend($el); } else { $wrapper.append($el); } } else if (me.$options.size === 'large') { var tabPane = _createTabPane().append($el); var $li = _createTabControl(tabPane.attr('id')); $wrapper.find('.lb-notify-wrapper').append(tabPane); $wrapper.find('.lb-notify-tabs').append($li); _activateTab($li); $li.find('>a').click(function () { _activateTab($li); }); } }; var _activateTab = function ($li) { $li.closest('.lb-notify-tabs').find('>li').removeClass('active'); $li.addClass('active'); var $current = $($li.find('>a').attr('href')); $current.closest('.lb-notify-wrapper').find('>.lb-tab-pane').removeClass('active'); $current.addClass('active') }; var _createTabControl = function (tabPaneId) { var $li = $('
', { 'class': Lobibox.notify.OPTIONS[me.$type]['class'] }); $('', { 'href': '#' + tabPaneId }).append('') .appendTo($li); return $li; }; var _createTabPane = function () { return $('', { 'class': 'lb-tab-pane', 'id': Math.randomString(10) }) }; var _createNotifyWrapper = function () { var selector = (me.$options.size === 'large' ? '.lobibox-notify-wrapper-large' : '.lobibox-notify-wrapper') + "." + me.$options.position.replace(/\s/gi, '.'), $wrapper; //var classes = me.$options.position.split(" "); $wrapper = $(selector); if ($wrapper.length === 0) { $wrapper = $('') .addClass(selector.replace(/\./g, ' ').trim()) .appendTo($('body')); if (me.$options.size === 'large') { $wrapper.append($('.lobibox-notify-msg
pauseDelayOnHover: true, // When you mouse over on notification delay (if it is enabled) will be paused.
onClickUrl: null, // The url which will be opened when notification is clicked
showAfterPrevious: false, // Set this to true if you want notification not to be shown until previous notification is closed. This is useful for notification queues
continueDelayOnInactiveTab: true, // Continue delay when browser tab is inactive
// Events
onClick: null
};
//This variable is necessary.
Lobibox.notify.OPTIONS = {
'class': 'animated-fast',
large: {
width: 500,
messageHeight: 96
},
mini: {
'class': 'notify-mini',
messageHeight: 32
},
default: {
'class': 'lobibox-notify-default',
'title': 'Default',
sound: false
},
success: {
'class': 'lobibox-notify-success',
'title': 'Success',
sound: 'sound2'
},
error: {
'class': 'lobibox-notify-error',
'title': 'Error',
sound: 'sound4'
},
warning: {
'class': 'lobibox-notify-warning',
'title': 'Warning',
sound: 'sound5'
},
info: {
'class': 'lobibox-notify-info',
'title': 'Information',
sound: 'sound6'
},
icons: {
bootstrap: {
success: 'glyphicon glyphicon-ok-sign',
error: 'glyphicon glyphicon-remove-sign',
warning: 'glyphicon glyphicon-exclamation-sign',
info: 'glyphicon glyphicon-info-sign'
},
fontAwesome: {
success: 'fa fa-check-circle',
error: 'fa fa-times-circle',
warning: 'fa fa-exclamation-circle',
info: 'fa fa-info-circle'
}
}
};
})();