1(function($) { 2 "use strict" 3 if(typeof stm_listings != 'undefined' && stm_listings.listings.length > 0) { 4 stm_listings.listings.forEach(function(list, index){ 5 // Save New Row 6 $(document).on('click', 7 '.stm_vehicles_add_new .listing_categories_add_new .stm_vehicles_listing_option_meta ' + 8 '.stm_vehicles_listing_row_actions a[href="#add_new_'+list.slug+'"]', function () { 9 var $stmForm = $(this).closest('form'); 10 var $stmtable = $(this).closest('.stm_vehicles_add_new'); 11 12 $.ajax({ 13 url: ajaxurl, 14 type: 'POST', 15 dataType: 'json', 16 data: $stmForm.serialize() + '&action=stm_'+list.slug+'_add_new_option', 17 context: this, 18 beforeSend: function () { 19 $('.listing_categories_add_new .stm_response_message').text(); 20 $('.listing_categories_add_new .stm_response_message').slideUp(); 21 $stmtable.addClass('loading'); 22 }, 23 success: function (data) { 24 $stmtable.removeClass('loading'); 25 if (data.message) { 26 $('.listing_categories_add_new .stm_response_message').text(data.message); 27 $('.listing_categories_add_new .stm_response_message').slideDown(); 28 } 29 if (data.option) { 30 stm_post_type_append_option(list, data.option); 31 } 32 } 33 }); 34 }); 35 36 // Delete Row 37 $(document).on('click', '.stm_vehicles_listing_row_actions a[href="#delete_'+list.slug+'"]', function(e) { 38 39 var numberTr = $(this).closest('tr').attr('data-tr'); 40 var $stmOptions = $(this).closest('.stm_vehicles_listing_option_meta'); 41 42 var confirm_delete = confirm('Are you sure?'); 43 if(!confirm_delete){ 44 e.preventDefault(); 45 return; 46 } 47 48 $.ajax({ 49 url: ajaxurl, 50 type: 'POST', 51 dataType: 'json', 52 data: 'number=' + numberTr + '&action=stm_'+list.slug+'_delete_option_row', 53 context: this, 54 beforeSend: function () { 55 $stmOptions.addClass('loading'); 56 }, 57 success: function (data) { 58 $stmOptions.removeClass('loading'); 59 stmVehiclesListingDeleteOption(numberTr); 60 } 61 }); 62 }); 63 64 // Save Row 65 $(document).on('click', '.stm_vehicles_listing_row_actions a[href="#save_'+list.slug+'"]', function() { 66 var $stmForm = $(this).closest('form'); 67 var $stmOptions = $(this).closest('.stm_vehicles_listing_option_meta'); 68 69 $.ajax({ 70 url: ajaxurl, 71 type: 'POST', 72 dataType: 'json', 73 data: $stmForm.serialize() + '&action=stm_'+list.slug+'_save_option_row', 74 context: this, 75 beforeSend: function () { 76 $stmOptions.addClass('loading'); 77 }, 78 success: function (data) { 79 $stmOptions.removeClass('loading'); 80 } 81 }); 82 }); 83 84 var stmSortableSelectorM = $(".stm_vehicles_listing_categories .stm_vehicles_listing_content table."+list.slug+"_categories_edit tbody"); 85 86 $(stmSortableSelectorM).sortable({ 87 items: ".stm_listings_settings_head" 88 }); 89 $(stmSortableSelectorM).disableSelection(); 90 91 $(stmSortableSelectorM).sortable({ 92 stop: function (event, ui) { 93 94 var newOrder = $(this).sortable("toArray", {attribute: 'data-tr'}); 95 96 $('.'+list.slug+'_categories_edit .stm_listings_settings_tr').each(function(){ 97 var currentNum = $(this).attr('data-tr'); 98 99 $(this).detach().insertAfter($('.stm_listings_settings_head[data-tr="' + currentNum + '"]')); 100 101 }); 102 103 $.ajax({ 104 url: ajaxurl, 105 type: 'POST', 106 dataType: 'json', 107 data: 'order=' + newOrder.join(',') + '&action=stm_'+list.slug+'_save_option_order', 108 context: this, 109 beforeSend: function () { 110 $('.stm_vehicles_listing_categories .stm_vehicles_listing_content').addClass('loading'); 111 }, 112 success: function (data) { 113 $('.stm_vehicles_listing_categories .stm_vehicles_listing_content').removeClass('loading'); 114 stmVehiclesListingSortOptions(list); 115 }, 116 error: function (jqXHR, exception) { 117 var msg = ''; 118 if (jqXHR.status === 0) { 119 msg = 'Not connect.\n Verify Network.'; 120 } else if (jqXHR.status === 404) { 121 msg = 'Requested page not found. [404]'; 122 } else if (jqXHR.status === 500) { 123 msg = 'Internal Server Error [500].'; 124 } else if (exception === 'parsererror') { 125 msg = 'Requested JSON parse failed.'; 126 } else if (exception === 'timeout') { 127 msg = 'Time out error.'; 128 } else if (exception === 'abort') { 129 msg = 'Ajax request aborted.'; 130 } else { 131 msg = 'Uncaught Error.\n' + jqXHR.responseText; 132 } 133 console.warn(msg); 134 } 135 }); 136 } 137 }).disableSelection(); 138 }); 139 } 140
141 function stmVehiclesListingSortOptions(list) { 142 var number = 0; 143 $('.stm_listings_settings_head').each(function(){ 144 $(this).attr('data-tr', number); 145 number ++; 146 }); 147 148 number = 0; 149 150 $('.'+list.slug+'_categories_edit .stm_listings_settings_tr').each(function(){ 151 $(this).attr('data-tr', number); 152 $(this).find('input[name="stm_vehicle_listing_row_position"]').val(number); 153 number ++; 154 }); 155 } 156 157 function stmVehiclesListingDeleteOption(number) { 158 159 $('.stm_listings_settings_head[data-tr="' + number + '"], ' + 160 '.stm_listings_settings_tr[data-tr="' + number + '"]').remove(); 161 } 162 163 function stm_post_type_append_option(list, option) { 164 var trHead = '<tr class="stm_listings_settings_head" data-tr="' + option.key + '">' + 165 '<td class="highlited">' + option.name + '</td> ' + 166 '<td>' + option.plural + '</td> ' + 167 '<td>' + option.slug + '</td> ' + 168 '<td>' + option.numeric + '</td> ' + 169 '<td class="manage"><i class="fas fa-list-ul" data-url="' + option.link + '"></i></td> ' + 170 '<td><i class="fas fa-pencil-alt"></i></td> ' + 171 '</tr>'; 172 173 var tableHead = '.'+list.slug+'_categories_edit tbody'; 174 var $tableHead = $(tableHead); 175 176 $tableHead.append(trHead); 177 var $newTrSettings = $('.listing_categories_add_new tr').clone(); 178 $newTrSettings.appendTo(tableHead); 179 $newTrSettings.attr('data-tr', option.key); 180 $newTrSettings.find('.stm_vehicles_listing_option_meta').hide(); 181 182 $('.listing_categories_add_new form').trigger('reset'); 183 184 $newTrSettings.find('.stm_response_message').text(); 185 $newTrSettings.find('.stm_response_message').hide(); 186 } 187 188 if(typeof STMListings != 'undefined') { 189 STMListings.Filter.prototype.performAjax = function (url) { 190 let type = $('form[data-trigger="filter"]').find('input[name="posttype"]').val(); 191 $.ajax({ 192 url: url, 193 dataType: 'json', 194 context: this, 195 data: 'ajax_action=' + this.ajax_action + '&posttype='+type, 196 beforeSend: this.ajaxBefore, 197 success: this.ajaxSuccess, 198 complete: this.ajaxComplete 199 }); 200 201 STMListings.Filter.prototype.ajax_action = STMListings.Filter.prototype.ajax_action + '&posttype=' + type; 202 }; 203 } 204 205 $('.multilisting-search-tabs-wrap .nav-item').on('click', function(e){ 206 $('.multilisting-search-tabs-wrap .nav-item .nav-link').removeClass('active'); 207 208 if($(this).find('.nav-link:first').hasClass('active')) { 209 $(this).find('.nav-link:first').removeClass('active'); 210 } else { 211 $(this).find('.nav-link:first').addClass('active'); 212 } 213 }); 214 215}(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.