1jQuery( '#legacy_date_shipped' ).datepicker({ 2 dateFormat: 'yy-mm-dd' 3}); 4 5jQuery(document).on("click", "#ast-show-tracking-form", function(e){ 6 e.preventDefault(); 7 var self = jQuery(this); 8 9 self.closest('div').find('form#ast-add-shipping-tracking-form').slideDown( 300, function() { 10 jQuery(this).removeClass('dokan-hide'); 11 }); 12}); 13 14jQuery(document).on("click", "#ast-dokan-cancel-tracking-note", function(e){ 15 e.preventDefault(); 16 var self = jQuery(this); 17 18 self.closest('form#ast-add-shipping-tracking-form').slideUp( 300, function() { 19 jQuery(this).addClass('dokan-hide'); 20 }); 21}); 22 23jQuery(document).on("click", "#ast-add-tracking-details", function(){ 24 25 var form = jQuery('#ast-add-shipping-tracking-form'); 26 var error; 27 var tracking_provider = jQuery("#ast-add-shipping-tracking-form #tracking_provider"); 28 var tracking_number = jQuery("#ast-add-shipping-tracking-form #tracking_number"); 29 var date_shipped = jQuery("#ast-add-shipping-tracking-form #legacy_date_shipped"); 30 31 if( tracking_provider.val() === '' ){ 32 //jQuery("#tracking_provider").siblings('.select2-container').find('.select2-selection').css('border-color','red'); 33 showerror(tracking_provider); 34 error = true; 35 } else{ 36 //jQuery("#tracking_provider").siblings('.select2-container').find('.select2-selection').css('border-color','#ddd'); 37 hideerror(tracking_provider); 38 } 39 40 if( tracking_number.val() === '' ){ 41 showerror(tracking_number); 42 error = true; 43 } else{ 44 hideerror(tracking_number); 45 } 46 47 if( date_shipped.val() === '' ){ 48 showerror(date_shipped); 49 error = true; 50 } else{ 51 hideerror(date_shipped); 52 } 53 54 if(jQuery('#ast-add-shipping-tracking-form .enable_tracking_per_item').prop("checked") == true){ 55 if(jQuery("tr").hasClass("ASTProduct_row")){ 56 var qty = false; 57 jQuery(".ASTProduct_row").each(function(index){ 58 var ASTProduct_qty = jQuery(this).find('input[type="number"]').val(); 59 if(ASTProduct_qty > 0){ 60 qty = true; 61 return false; 62 } 63 }); 64 } 65 } 66 67 if(qty == false){ 68 jQuery('.qty_validation').show(); 69 return false; 70 } else{ 71 jQuery('.qty_validation').hide(); 72 } 73 74 if(error == true){ 75 return false; 76 } 77 78 jQuery("#ast-add-shipping-tracking-form").block({ 79 message: null, 80 overlayCSS: { 81 background: "#fff", 82 opacity: .6 83 } 84 }); 85 jQuery.ajax({ 86 url: dokan.ajaxurl, 87 data: form.serialize(), 88 type: 'POST', 89 success: function(response) { 90 jQuery( '#ast-add-shipping-tracking-form' ).unblock(); 91 location.reload(); 92 }, 93 error: function(response) { 94 console.log(response); 95 } 96 }); 97 return false; 98}); 99 100jQuery(document).on("click", ".ast-dokan-delete-tracking", function(){ 101 var tracking_id = jQuery( this ).attr( 'rel' ); 102 103 jQuery( '#tracking-item-' + tracking_id ).block({ 104 message: null, 105 overlayCSS: { 106 background: '#fff', 107 opacity: 0.6 108 } 109 }); 110 111 var data = { 112 action: 'ast_dokan_delete_item', 113 order_id: jQuery( '#order_id' ).val(), 114 tracking_id: tracking_id, 115 security: jQuery( '#ast_dona_delete_tracking_nonce' ).val() 116 }; 117 118 jQuery.ajax({ 119 url: dokan.ajaxurl, 120 data: data, 121 type: 'POST', 122 success: function(response) { 123 jQuery( '#tracking-item-' + tracking_id ).unblock(); 124 if ( response != '-1' ) { 125 jQuery( '#tracking-item-' + tracking_id ).remove(); 126 } 127 location.reload(); 128 }, 129 error: function(response) { 130 console.log(response); 131 } 132 }); 133 134 return false; 135}); 136 137jQuery(document).ready(function() { 138 jQuery('#tracking_provider').select2({ 139 matcher: modelMatcher 140 }); 141}); 142 143function showerror(element){ 144 element.css("border","1px solid red"); 145} 146function hideerror(element){ 147 element.css("border","1px solid #ddd"); 148} 149 150function modelMatcher (params, data) { 151 data.parentText = data.parentText || ""; 152 153 // Always return the object if there is nothing to compare 154 if (jQuery.trim(params.term) === '') { 155 return data; 156 } 157 158 // Do a recursive check for options with children 159 if (data.children && data.children.length > 0) { 160 // Clone the data object if there are children 161 // This is required as we modify the object to remove any non-matches 162 var match = jQuery.extend(true, {}, data); 163 164 // Check each child of the option 165 for (var c = data.children.length - 1; c >= 0; c--) { 166 var child = data.children[c]; 167 child.parentText += data.parentText + " " + data.text; 168 169 var matches = modelMatcher(params, child); 170 171 // If there wasn't a match, remove the object in the array 172 if (matches == null) { 173 match.children.splice(c, 1); 174 } 175 } 176 177 // If any children matched, return the new object 178 if (match.children.length > 0) { 179 return match; 180 } 181 182 // If there were no matching children, check just the plain object 183 return modelMatcher(params, match); 184 } 185 186 // If the typed-in term matches the text of this term, or the text from any 187 // parent term, then it's a match. 188 var original = (data.parentText + ' ' + data.text).toUpperCase(); 189 var term = params.term.toUpperCase(); 190 191 192 // Check if the text contains the term 193 if (original.indexOf(term) > -1) { 194 return data; 195 } 196 197 // If it doesn't contain the term, don't return anything 198 return null; 199}
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.