Sha256: 386015f4b0c2129bcfbb67c012b59a0ff170dd13ef9a48453885f91cd35113fa

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

// toast
	var toastTimeout;

	$('[data-toggle="toast"]').tooltip({
		animation: false,
		container: '.toast',
		html: true,
		placement: 'bottom',
		template: '<div class="tooltip"><div class="toast-inner tooltip-inner"></div></div>',
		trigger: 'manual'
	});

// toast dismiss
	$(document).on('click', '[data-dismiss="toast"]', function(e) {
		e.preventDefault();
		toastHide(0);
	});

	toastHide = function (timer, toast) {
		clearTimeout(toastTimeout);

		toastTimeout = setTimeout(function() {
			$('.toast').removeClass('toast-show');

			if ($('.fbtn-container').length) {
				$('.fbtn-container').css('margin-bottom', '');
			};

			$('.toast-inner').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
				$('.toast-toggled').tooltip('hide').removeClass('toast-toggled');

				if (toast !== null && toast !== undefined) {
					toast.tooltip('show').addClass('toast-toggled');
				} else {
					$('.toast').remove();
				}
			});
		}, timer);
	}

// toast hover
	$(document).on('mouseenter', '.toast', function() {
		clearTimeout(toastTimeout);
	});

	$(document).on('mouseleave', '.toast', function() {
		toastHide(6000);
	});

// toast show
	$(document).on('click', '[data-toggle="toast"]', function() {
		var $this = $(this);

		if (!$('.toast').length) {
			$('body').append('<div class="toast"></div>');
		};

		if (!$this.hasClass('toast-toggled')) {
			if ($('.toast').hasClass('toast-show')) {
				toastHide(0, $this);
			} else {
				$this.tooltip('show').addClass('toast-toggled');
			}
		};
	});

	$(document).on('shown.bs.tooltip', '[data-toggle="toast"]', function() {
		var $this = $(this);

		$('.toast').addClass('toast-show');

		if ($(window).width() < 768 && $('.fbtn-container').length) {
			$('.fbtn-container').css('margin-bottom', $('.toast').outerHeight());
		};

		$('.toast-inner').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
			toastHide(6000);
		});
	});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
material-sass-0.0.4 app/assets/javascripts/material/toast.js
material-sass-0.0.3 app/assets/javascripts/material/toast.js