1(function($) { 2 'use strict'; 3 /** 4 * All of the code for your common JavaScript source 5 * should reside in this file. 6 * 7 * Note: It has been assumed you will write jQuery code here, so the 8 * $ function reference has been prepared for usage within the scope 9 * of this function. 10 * 11 * This enables you to define handlers, for when the DOM is ready: 12 * 13 * $(function() { 14 * 15 * }); 16 * 17 * When the window is loaded: 18 * 19 * $( window ).load(function() { 20 * 21 * }); 22 * 23 * ...and/or other possibilities. 24 * 25 * Ideally, it is not considered best practise to attach more than a 26 * single DOM-ready or window-load handler for a particular page. 27 * Although scripts in the WordPress core, Plugins and Themes may be 28 * practising this, we should strive to set a better example in our own work. 29 */ 30 jQuery(document).ready(function() { 31 // create zip of bulk products. 32 $(document).on("click", "#pgfw-create-zip-bulk", function() { 33 var self = this; 34 var cur_html = $(self).html(); 35 $(self).html('<img src="' + wpg_common_param.loader + '" style="width:20px;height:20px;display:inline;">'); 36 wpg_ajax_for_zip_or_pdf('pdf_bulk_download_zip'); 37 $(self).html(cur_html); 38 }); 39 // create pdf in continuation of bulk. 40 $(document).on('click', '#pgfw-create-pdf-bulk', function() { 41 var self = this; 42 var cur_html = $(self).html(); 43 $(self).html('<img src="' + wpg_common_param.loader + '" style="width:20px;height:20px;display:inline;">'); 44 wpg_ajax_for_zip_or_pdf('pdf_bulk_download_continuation'); 45 $(self).html(cur_html); 46 }); 47 // ajax to create pdf for bulk and download it. 48 function wpg_ajax_for_zip_or_pdf(name) { 49 $.ajax({ 50 url: wpg_common_param.ajaxurl, 51 method: 'post', 52 data: { 53 action: 'wps_wpg_ajax_for_zip_or_pdf', 54 nonce: wpg_common_param.nonce, 55 name: name, 56 status: 'yes', 57 }, 58 success: function(msg) { 59 60 $('#pgfw-download-zip-parent').html('<a href="' + msg + '" download id="pgfw-download-zip"></a>'); 61 $('#pgfw-download-zip')[0].click(); 62 $('#pgfw-download-zip-parent').html(''); 63 } 64 }); 65 } 66 // delete products from the bulk list ajax. 67 $(document).on('click', '.pgfw-delete-this-products-bulk', function(e) { 68 e.preventDefault(); 69 var self = this; 70 var cur_html = $(self).html(); 71 $(self).html('<img src="' + wpg_common_param.loader + '" style="width:10px;height:10px;display:inline;">'); 72 var product_id = $(this).data('product-id'); 73 $.ajax({ 74 url: wpg_common_param.ajaxurl, 75 method: 'post', 76 data: { 77 action: 'wpg_delete_product_from_cookies', 78 product_id: product_id, 79 nonce: wpg_common_param.nonce, 80 }, 81 success: function(msg) { 82 $(self).html(cur_html); 83 $('.wps_pgw-button_content').html(msg); 84 var cur_count = $('.wps_pgfw-display-value').text(); 85 cur_count = parseInt(cur_count) - 1; 86 $('.wps_pgfw-display-value').text(cur_count); 87 if (cur_count <= 0) { 88 $('.wps_pgw-button_wrapper').hide(); 89 } 90 location.reload(); 91 }, 92 error: function() { 93 $(self).html(cur_html); 94 } 95 }); 96 }); 97 // user email submittion from modal on creating bulk PDF. 98 $(document).on('click', '#pgfw-submit-email-user-bulk', function(e) { 99 e.preventDefault(); 100 var email = $('#pgfw-user-email-input-bulk').val(); 101 var use_account_email = $('#pgfw-user-email-from-account-bulk').is(':checked'); 102 var pdf_continuation_email = $('#pgfw-bulk-email-continuation-pdf').is(':checked'); 103 var pdf_zip_email = $('#pgfw-bulk-email-zip-pdf').is(':checked'); 104 $('#pgfw-user-email-submittion-message-bulk').html(wpg_common_param.processing_html); 105 $.ajax({ 106 url: wpg_common_param.ajaxurl, 107 method: 'post', 108 data: { 109 action: 'wps_wpg_ajax_for_zip_or_pdf',
110 nonce: wpg_common_param.nonce, 111 name: (pdf_continuation_email) ? 'pdf_bulk_download_continuation' : 'pdf_bulk_download_zip', 112 mode: 'email', 113 email: (use_account_email) ? 'use_account_email' : email, 114 }, 115 success: function(msg) { 116 $('#pgfw-user-email-submittion-message-bulk').html(msg); 117 setTimeout(function() { location.reload(); }, 5000); 118 }, 119 error: function() { 120 $('#pgfw-user-email-submittion-message-bulk').html(wpg_common_param.email_submit_error); 121 } 122 }); 123 }); 124 // add product to bulk ajax. 125 $('#pgfw-bulk-product-add').on('click', function(e) { 126 e.preventDefault(); 127 var self = this; 128 var cur_html = $(self).html(); 129 $(self).html('<img src="' + wpg_common_param.loader + '" style="width:20px;height:20px;display:inline;">'); 130 var product_id = $(self).data('product-id'); 131 $.ajax({ 132 url: wpg_common_param.ajaxurl, 133 method: 'post', 134 cache: false, 135 crossDomain: true, 136 xhrFields: { 137 withCredentials: true 138 }, 139 data: { 140 action: 'wpg_bulk_add_products_ajax', 141 product_id: product_id, 142 nonce: wpg_common_param.nonce, 143 }, 144 success: function(msg) { 145 $(self).html(cur_html); 146 if (msg <= 1) { 147 location.reload(); 148 } 149 $('.wps_pgfw-display-value').text(msg); 150 }, 151 error: function() { 152 $(self).html(cur_html); 153 } 154 }); 155 }); 156 // bulk display of products chart ajax. 157 $('.wps_pgw-button').on('click', function(e) { 158 e.preventDefault(); 159 var self = this; 160 var cur_html = $(self).html(); 161 $(self).html('<img src="' + wpg_common_param.loader + '" style="width:20px;height:20px;display:inline;">'); 162 $.ajax({ 163 url: wpg_common_param.ajaxurl, 164 method: 'post', 165 data: { 166 action: 'wpg_build_html_from_cookies', 167 nonce: wpg_common_param.nonce, 168 }, 169 success: function(msg) { 170 $('.wps_pgw-button_content').html(msg); 171 $(self).html(cur_html); 172 }, 173 error: function() { 174 $(self).html(cur_html); 175 } 176 }); 177 }); 178 }); 179})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.