(function ($, Drupal, drupalSettings) { 'use strict'; Drupal.typnotif = { }; var index = 1; var shopping = false; var sale = false; var path = drupalSettings.path.baseUrl; //var path = 'https://www.yellowpages.co.th/'; var currentPath = drupalSettings.path.currentPath; Drupal.typnotif.createListView = function(result, type){ let html = ''; if(type === 'shopping'){ html = ""; } else if (type === 'sale') { html = ""; } return html; }; Drupal.typnotif.requestNotification = function(actDel){ $.getJSON(path+'api/notification/check', function(result){ // var displayValue = ""; // if (window.isElitePack === true) { // displayValue = result['_shopping'].length; // } else { // displayValue = result['_shopping'].length + "(" + result['_shopping_count'] + ")"; // } // $('#span-shopping-notification').html(displayValue); // $('#span-shopping-notification-mobile').html(displayValue); // $('#span-shopping-notification-mobile-block').html(displayValue); if (result && result['_shopping'] && result['_shopping'].length > 0) { var displayValue = ""; if (window.isElitePack === true) { displayValue = result['_shopping'].length; } else { displayValue = result['_shopping'].length + "(" + result['_shopping_count'] + ")"; } $('#span-shopping-notification, #span-shopping-notification-mobile') .html(displayValue) .css('display', 'inline-flex'); } else { $('#span-shopping-notification, #span-shopping-notification-mobile').hide(); } }); }; Drupal.typnotif.requestNotification(false); /*Document on click*/ $("#shopping-cart-notification").click(function(){ /*if(shopping === true){ $("#span-shopping-notification").fadeOut("slow"); }*/ }); $(document).on("mouseenter", ".shopping-cart-item", function() { $(this).find(".shopping-tool").show(); }); $(document).on("mouseleave", ".shopping-cart-item", function() { $(this).find(".shopping-tool").hide(); }); $(document).on("click", ".btn-shopping-tool-delete", function(event) { var _id = $(this).data('id'); var el = $(this); $.post(path + currentPath +'api/rfq/document/delete' , { _id: _id }).done(function( response ) { if(response.hasOwnProperty("status") && response.status === true){ el.closest('.shopping-cart-item').remove(); Drupal.typnotif.requestNotification(true); } }); return false; }); $(document).on("click", ".btn-submit-rfq", function(event) { setInterval(function(){ Drupal.typnotif.requestNotification(false); }, 2000); }); $('a[data-toggle="popover"]').popover(); })(jQuery, Drupal, drupalSettings);