12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- // 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);
- });
- function toastHide(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);
- });
- });
|