gutenberg
3 years ago
gutenbergComponents
3 years ago
autoupdate_banner.js
3 years ago
banner_main.js
3 years ago
circle-progress.js
3 years ago
datatables.min.js
4 years ago
jquery.multi-select.js
4 years ago
jquery.tagsinput.min.js
4 years ago
referral_program.js
3 years ago
sidebar-plugin.js
3 years ago
speed.js
3 years ago
two_admin.js
1 year ago
two_admin_bar.js
4 years ago
two_bf_countdown.js
3 years ago
two_deactivate_plugin.js
3 years ago
two_elementor_editor.js
2 years ago
two_preview.js
3 years ago
two_update_white_label.js
1 year ago
two_white_label.js
2 years ago
two_elementor_editor.js
66 lines
| 1 | const elementorConfigsToRecreateCCSS = [ |
| 2 | 'background_image', |
| 3 | '_background_image', |
| 4 | 'background_color', |
| 5 | '_background_color', |
| 6 | ]; |
| 7 | jQuery(document).on('click', '#elementor-panel-saver-button-publish',function(){ |
| 8 | let page_id = ''; |
| 9 | if ( typeof ElementorConfig !== "undefined" ) { |
| 10 | page_id = ElementorConfig.initial_document.id; |
| 11 | } |
| 12 | if ( getLocalStorageWithExpiry('regenerateCCSSFor_' + page_id ) === "1" ) { |
| 13 | jQuery.ajax({ |
| 14 | type: "POST", |
| 15 | url: two_elementor_vars.ajax_url, |
| 16 | dataType: 'json', |
| 17 | data: { |
| 18 | action: "two_elementor_regenerate_ccss", |
| 19 | page_id: page_id, |
| 20 | //devide all types by comma ',' |
| 21 | allowed_post_types: 'page', |
| 22 | nonce: two_elementor_vars.nonce, |
| 23 | } |
| 24 | }).success(function () { |
| 25 | localStorage.removeItem('regenerateCCSSFor_' + page_id ); |
| 26 | }); |
| 27 | } |
| 28 | }); |
| 29 | jQuery(window).on('elementor:init', function () { |
| 30 | elementor.channels.editor.on('change', function (t) { |
| 31 | let regenerateCCSS = getLocalStorageWithExpiry('regenerateCCSSFor_' + t.options.container.document.id); |
| 32 | if (regenerateCCSS !== "1" ) { |
| 33 | elementorConfigsToRecreateCCSS.forEach(function (setting) { |
| 34 | if (typeof t.options.container.oldValues[setting] !== "undefined") { |
| 35 | setLocalStorageWithExpiry('regenerateCCSSFor_' + t.options.container.document.id, "1", 86400); |
| 36 | return false; |
| 37 | } |
| 38 | }); |
| 39 | } |
| 40 | }); |
| 41 | }); |
| 42 | |
| 43 | function setLocalStorageWithExpiry(key, value, ttl) { |
| 44 | const now = new Date(); |
| 45 | |
| 46 | const item = { |
| 47 | value: value, |
| 48 | expiry: now.getTime() + ttl, |
| 49 | } |
| 50 | localStorage.setItem(key, JSON.stringify(item)); |
| 51 | } |
| 52 | |
| 53 | function getLocalStorageWithExpiry(key) { |
| 54 | const itemStr = localStorage.getItem(key); |
| 55 | if (!itemStr) { |
| 56 | return null; |
| 57 | } |
| 58 | const item = JSON.parse(itemStr); |
| 59 | const now = new Date(); |
| 60 | if (now.getTime() > item.expiry) { |
| 61 | localStorage.removeItem(key); |
| 62 | return null; |
| 63 | } |
| 64 | return item.value; |
| 65 | } |
| 66 |