PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.7
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / assets / js / modules / inactive-tab-message / inactive-tab-message.js

inactive-tab-message.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.7, at assets/js/modules/inactive-tab-message/inactive-tab-message.js

40 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Merchant Inactive Tab Message.
3 *
4 */
5
6 'use strict';
7
8 var merchant = merchant || {};
9 merchant.modules = merchant.modules || {};
10 (function ($) {
11 merchant.modules.inactiveTabMessage = {
12 init: function init() {
13 var setting = merchant.setting;
14 var _ref = setting || {},
15 noItemsMessage = _ref.inactive_tab_message,
16 hasItemsMessage = _ref.inactive_tab_abandoned_message;
17 var _ref2 = setting || {},
18 cartCount = _ref2.inactive_tab_cart_count;
19 $(document.body).on('added_to_cart removed_from_cart updated_wc_div', function (event, data) {
20 if (data && data['.merchant_cart_count'] !== undefined) {
21 cartCount = data['.merchant_cart_count'];
22 } else {
23 // Cart page
24 cartCount = $('.woocommerce-cart-form tr.cart_item').length;
25 }
26 });
27 var defaultTitle = document.title;
28 document.addEventListener('visibilitychange', function () {
29 var modifiedTitle = cartCount ? hasItemsMessage : noItemsMessage;
30 if (!modifiedTitle) {
31 return;
32 }
33
34 // Change the title.
35 document.title = document.hidden ? modifiedTitle.replaceAll(''', "'") : defaultTitle;
36 });
37 }
38 };
39 merchant.modules.inactiveTabMessage.init();
40 })(jQuery);