All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.static.js.jquery.noty.js Maven / Gradle / Ivy

/**
* noty - jQuery Notification Plugin v1.2.1
* Contributors: https://github.com/needim/noty/graphs/contributors
*
* Examples and Documentation - http://needim.github.com/noty/
*
* Licensed under the MIT licenses:
* http://www.opensource.org/licenses/mit-license.php
*
**/
(function($) {
	$.noty = function(options, customContainer) {

		var base = {};
		var $noty = null;
		var isCustom = false;

		base.init = function(options) {
			base.options = $.extend({}, $.noty.defaultOptions, options);
			base.options.type = base.options.cssPrefix+base.options.type;
			base.options.id = base.options.type+'_'+new Date().getTime();
			base.options.layout = base.options.cssPrefix+'layout_'+base.options.layout;

			if (base.options.custom.container) customContainer = base.options.custom.container;
			isCustom = ($.type(customContainer) === 'object') ? true : false;

			return base.addQueue();
		};

		// Push notification to queue
		base.addQueue = function() {
			var isGrowl = ($.inArray(base.options.layout, $.noty.growls) == -1) ? false : true;
	  	if (!isGrowl) (base.options.force) ? $.noty.queue.unshift({options: base.options}) : $.noty.queue.push({options: base.options});
	  	return base.render(isGrowl);
		};

		// Render the noty
		base.render = function(isGrowl) {

			// Layout spesific container settings
			var container = (isCustom) ? customContainer.addClass(base.options.theme+' '+base.options.layout+' noty_custom_container') : $('body');
	  	if (isGrowl) {
	  		if ($('ul.noty_cont.' + base.options.layout).length == 0)
	  			container.prepend($('
    ').addClass('noty_cont ' + base.options.layout)); container = $('ul.noty_cont.' + base.options.layout); } else { if ($.noty.available) { var fromQueue = $.noty.queue.shift(); // Get noty from queue if ($.type(fromQueue) === 'object') { $.noty.available = false; base.options = fromQueue.options; } else { $.noty.available = true; // Queue is over return base.options.id; } } else { return base.options.id; } } base.container = container; // Generating noty bar base.bar = $('
    ').attr('id', base.options.id).addClass(base.options.theme+' '+base.options.layout+' '+base.options.type); $noty = base.bar; $noty.append(base.options.template).find('.noty_text').html(base.options.text); $noty.data('noty_options', base.options); // Close button display (base.options.closeButton) ? $noty.addClass('noty_closable').find('.noty_close').show() : $noty.find('.noty_close').remove(); // Bind close event to button $noty.find('.noty_close').bind('click', function() { $noty.trigger('noty.close'); }); // If we have a button we must disable closeOnSelfClick and closeOnSelfOver option if (base.options.buttons) base.options.closeOnSelfClick = base.options.closeOnSelfOver = false; // Close on self click if (base.options.closeOnSelfClick) $noty.bind('click', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer'); // Close on self mouseover if (base.options.closeOnSelfOver) $noty.bind('mouseover', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer'); // Set buttons if available if (base.options.buttons) { $buttons = $('
    ').addClass('noty_buttons'); $noty.find('.noty_message').append($buttons); $.each(base.options.buttons, function(i, button) { bclass = (button.type) ? button.type : 'gray'; $button = $('




© 2015 - 2024 Weber Informatics LLC | Privacy Policy