1"use strict"; 2 3function _typeof(obj) { 4 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 5 _typeof = function _typeof(obj) { 6 return typeof obj; 7 }; 8 } else { 9 _typeof = function _typeof(obj) { 10 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 11 }; 12 } 13 return _typeof(obj); 14} 15 16window.wfch = function ($) { 17 return { 18 "ajax": function ajax(cls, is_form, cb) { 19 var self = this; 20 var element = null; 21 var handler = {}; 22 var prefix = "wfch_"; 23 this.action = null; 24 25 this.data = function (form_data) { 26 var formEl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 27 return form_data; 28 }; 29 30 this.before_send = function (formEl) { 31 }; 32 33 this.async = function (bool) { 34 return bool; 35 }; 36 37 this.method = function (method) { 38 return method; 39 }; 40 41 this.success = function (rsp, fieldset, loader, jqxhr, status) { 42 }; 43 44 this.complete = function (rsp, fieldset, loader, jqxhr, status) { 45 }; 46 47 this.error = function (rsp, fieldset, loader, jqxhr, status) { 48 }; 49 50 this.action = function (action) { 51 return action; 52 }; 53 54 function reset_form(action, fieldset, loader, rsp, jqxhr, status) { 55 if (fieldset.length > 0) { 56 fieldset.prop('disabled', false); 57 } 58 59 loader.remove(); 60 var loader2; 61 loader2 = $("#offer_settings_btn_bottom .wfch_save_funnel_offer_products_ajax_loader "); 62 loader2.removeClass('ajax_loader_show'); 63 64 if (self.hasOwnProperty(action) === true && typeof self[action] === 'function') { 65 self[action](rsp, fieldset, loader, jqxhr, status); 66 } 67 } 68 69 function form_post(action) { 70 var formEl = element; 71 var ajax_loader = null; 72 var ajax_loader2 = null; 73 var form_data = new FormData(formEl); 74 form_data.append('action', action); 75 form_data.append('wfch_nonce', wfch_secure.nonce); 76 var form_method = $(formEl).attr('method'); 77 var method = form_method !== "undefined" && form_method !== "" ? form_method : 'POST'; 78 79 if ($(formEl).find("." + action + "_ajax_loader").length === 0) { 80 $(formEl).find(".wfch_form_submit").prepend("<span class='" + action + "_ajax_loader spinner" + "'></span>"); 81 ajax_loader = $(formEl).find("." + action + "_ajax_loader"); 82 } else { 83 ajax_loader = $(formEl).find("." + action + "_ajax_loader"); 84 } 85 86 ajax_loader2 = $("#offer_settings_btn_bottom .wfch_save_funnel_offer_products_ajax_loader "); 87 ajax_loader.addClass('ajax_loader_show'); 88 ajax_loader2.addClass('ajax_loader_show'); 89 var fieldset = $(formEl).find("fieldset"); 90 91 if (fieldset.length > 0) { 92 fieldset.prop('disabled', true); 93 } 94 95 self.before_send(formEl, action); 96 var data = self.data(form_data, formEl); 97 var request = { 98 url: ajaxurl, 99 async: self.async(true), 100 method: self.method('POST'), 101 data: data, 102 processData: false, 103 contentType: false, 104 // contentType: self.content_type(false), 105 success: function success(rsp, jqxhr, status) { 106 if (_typeof(rsp) === 'object' && rsp.hasOwnProperty('nonce')) { 107 wfch_secure.nonce = rsp.nonce; 108 delete rsp.nonce; 109 } 110
111 reset_form(action + "_ajax_success", fieldset, ajax_loader, rsp, jqxhr, status); 112 self.success(rsp, jqxhr, status, fieldset, ajax_loader); 113 }, 114 complete: function complete(rsp, jqxhr, status) { 115 reset_form(action + "_ajax_complete", fieldset, ajax_loader, rsp, jqxhr, status); 116 self.complete(rsp, jqxhr, status, fieldset, ajax_loader); 117 }, 118 error: function error(rsp, jqxhr, status) { 119 reset_form(action + "_ajax_error", fieldset, ajax_loader, rsp, jqxhr, status); 120 self.error(rsp, jqxhr, status, fieldset, ajax_loader); 121 } 122 }; 123 124 if (handler.hasOwnProperty(action)) { 125 clearTimeout(handler[action]); 126 } else { 127 handler[action] = null; 128 } 129 130 handler[action] = setTimeout(function (request) { 131 $.ajax(request); 132 }, 200, request); 133 } 134 135 function send_json(action) { 136 var formEl = element; 137 var data = self.data({}, formEl); 138 139 if (_typeof(data) === 'object') { 140 data.action = action; 141 } else { 142 data = { 143 'action': action 144 }; 145 } 146 147 self.before_send(formEl, action); 148 data.wfch_nonce = wfch_secure.nonce; 149 var request = { 150 url: ajaxurl, 151 async: self.async(true), 152 method: self.method('POST'), 153 data: data, 154 success: function success(rsp, jqxhr, status) { 155 if (_typeof(rsp) === 'object' && rsp.hasOwnProperty('nonce')) { 156 wfch_secure.nonce = rsp.nonce; 157 delete rsp.nonce; 158 } 159 160 self.success(rsp, jqxhr, status, element); 161 }, 162 complete: function complete(rsp, jqxhr, status) { 163 self.complete(rsp, jqxhr, status, element); 164 }, 165 error: function error(rsp, jqxhr, status) { 166 self.error(rsp, jqxhr, status, element); 167 } 168 }; 169 170 if (handler.hasOwnProperty(action)) { 171 clearTimeout(handler[action]); 172 } else { 173 handler[action] = null; 174 } 175 176 handler[action] = setTimeout(function (request) { 177 $.ajax(request); 178 }, 200, request); 179 } 180 181 this.ajax = function (action, data) { 182 if (_typeof(data) === 'object') { 183 data.action = action; 184 } else { 185 data = { 186 'action': action 187 }; 188 } 189 190 data.action = prefix + action; 191 self.before_send(document.body, action); 192 data.wfch_nonce = wfch_secure.nonce; 193 194 wfch.hooks.doAction('wfch_before_ajax_running', action, data); 195 var request = { 196 url: ajaxurl, 197 async: self.async(true), 198 method: self.method('POST'), 199 data: data, 200 success: function success(rsp, jqxhr, status) { 201 if (_typeof(rsp) === 'object' && rsp.hasOwnProperty('nonce')) { 202 wfch_secure.nonce = rsp.nonce; 203 delete rsp.nonce; 204 } 205 206 wfch.hooks.doAction('wfch_success_notification', rsp, action); 207 self.success(rsp, jqxhr, status, action); 208 209 }, 210 complete: function complete(rsp, jqxhr, status) { 211 212 wfch.hooks.doAction('wfch_complete_notification', rsp, action); 213 self.complete(rsp, jqxhr, status, action); 214 215 }, 216 error: function error(rsp, jqxhr, status) { 217 wfch.hooks.doAction('wfch_error_notification', action, jqxhr, status); 218 self.error(rsp, jqxhr, status, action); 219 220 } 221 }; 222 223 if (handler.hasOwnProperty(action)) { 224 clearTimeout(handler[action]); 225 } else { 226 handler[action] = null; 227 } 228 229 handler[action] = setTimeout(function (request) { 230 $.ajax(request); 231 }, 200, request); 232 }; 233 234 function form_init(cls) { 235 if ($(cls).length > 0) { 236 $(cls).on("submit", function (e) { 237 e.preventDefault(); 238 var action = $(this).data('wfoaction'); 239 240 if (action !== 'undefined') { 241 action = prefix + action; 242 action = action.trim(); 243 element = this; 244 self.action = action; 245 form_post(action); 246 } 247 }); 248 249 if (typeof cb === 'function') { 250 cb(self); 251 } 252 } 253 } 254 255 function click_init(cls) { 256 if ($(cls).length > 0) { 257 $(cls).on("click", function (e) { 258 console.log(e); 259 e.preventDefault(); 260 var action = $(this).data('wfoaction'); 261 262 if (action !== 'undefined') { 263 action = prefix + action; 264 action = action.trim(); 265 element = this; 266 self.action = action; 267 send_json(action); 268 } 269 }); 270 271 if (typeof cb === 'function') { 272 cb(self); 273 } 274 } 275 } 276 277 if (is_form === true) { 278 form_init(cls, cb); 279 return this; 280 } 281 282 if (is_form === false) { 283 click_init(cls, cb); 284 return this; 285 } 286 287 return this; 288 }, 289 "hooks": { 290 hooks: { 291 action: {}, 292 filter: {} 293 }, 294 addAction: function addAction(action, callable, priority, tag) { 295 this.addHook('action', action, callable, priority, tag); 296 }, 297 addFilter: function addFilter(action, callable, priority, tag) { 298 this.addHook('filter', action, callable, priority, tag); 299 }, 300 doAction: function doAction(action) { 301 this.doHook('action', action, arguments); 302 }, 303 applyFilters: function applyFilters(action) { 304 return this.doHook('filter', action, arguments); 305 }, 306 removeAction: function removeAction(action, tag) { 307 this.removeHook('action', action, tag); 308 }, 309 removeFilter: function removeFilter(action, priority, tag) { 310 this.removeHook('filter', action, priority, tag); 311 }, 312 addHook: function addHook(hookType, action, callable, priority, tag) { 313 if (undefined == this.hooks[hookType][action]) { 314 this.hooks[hookType][action] = []; 315 } 316 317 var hooks = this.hooks[hookType][action]; 318 319 if (undefined == tag) { 320 tag = action + '_' + hooks.length; 321 } 322 323 if (priority == undefined) { 324 priority = 10; 325 } 326 327 this.hooks[hookType][action].push({ 328 tag: tag, 329 callable: callable, 330 priority: priority 331 }); 332 }, 333 doHook: function doHook(hookType, action, args) { 334 // splice args from object into array and remove first index which is the hook name 335 args = Array.prototype.slice.call(args, 1); 336 337 if (undefined != this.hooks[hookType][action]) { 338 var hooks = this.hooks[hookType][action], 339 hook; //sort by priority 340 341 hooks.sort(function (a, b) { 342 return a.priority - b.priority; 343 }); 344 345 for (var i = 0; i < hooks.length; i++) { 346 hook = hooks[i].callable; 347 348 if (typeof hook != 'function') {
349 hook = window[hook]; 350 } 351 352 if ('action' == hookType) { 353 hook.apply(null, args); 354 } else { 355 args[0] = hook.apply(null, args); 356 } 357 } 358 } 359 360 if ('filter' == hookType) { 361 return args[0]; 362 } 363 }, 364 removeHook: function removeHook(hookType, action, priority, tag) { 365 if (undefined != this.hooks[hookType][action]) { 366 var hooks = this.hooks[hookType][action]; 367 368 for (var i = hooks.length - 1; i >= 0; i--) { 369 if ((undefined == tag || tag == hooks[i].tag) && (undefined == priority || priority == hooks[i].priority)) { 370 hooks.splice(i, 1); 371 } 372 } 373 } 374 } 375 }, 376 "tools": { 377 /** 378 * get keys length of object and array 379 * @param obj 380 * @returns {number} 381 */ 382 ol: function ol(obj) { 383 var c = 0; 384 385 if (obj != null && _typeof(obj) === "object") { 386 c = Object.keys(obj).length; 387 } 388 389 return c; 390 }, 391 isEmpty: function isEmpty(obj) { 392 for (var key in obj) { 393 if (obj.hasOwnProperty(key)) { 394 return false; 395 } 396 } 397 398 return true; 399 }, 400 401 /** 402 * Check property exist in object or Array 403 * @param obj 404 * @param key 405 * @returns {boolean} 406 */ 407 hp: function hp(obj, key) { 408 var c = false; 409 410 if (_typeof(obj) === "object" && key !== undefined) { 411 c = obj.hasOwnProperty(key); 412 } 413 414 return c; 415 }, 416 417 /** 418 * Convert destroy refresh and reconvert into in json without refrence 419 * @param obj 420 * @returns {*} 421 */ 422 jsp: function jsp(obj) { 423 if (_typeof(obj) === 'object') { 424 var doc = JSON.stringify(obj); 425 doc = JSON.parse(doc); 426 return doc; 427 } else { 428 return obj; 429 } 430 }, 431 432 /** 433 * get object keys array 434 * @param obj 435 * @returns Array 436 */ 437 kys: function kys(obj) { 438 if (_typeof(obj) === 'object' && obj != null && this.ol(obj) > 0) { 439 return Object.keys(obj); 440 } 441 442 return []; 443 }, 444 ucfirst: function ucfirst(string) { 445 return string.replace(/^\w/, function (c) { 446 return c.toUpperCase(); 447 }); 448 }, 449 stripHTML: function stripHTML(dirtyString) { 450 var dirty = $("<div>" + dirtyString + "</div>"); 451 return dirty.text(); 452 }, 453 string_to_bool: function string_to_bool() { 454 var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 455 456 if ('' === content || 'false' == content) { 457 return false; 458 } 459 460 return typeof content === "boolean" ? content : 'yes' === content || 1 === content || 'true' === content || '1' === content; 461 }, 462 is_object: function is_object(options) { 463 if (options == null) { 464 return false; 465 } 466 467 if (_typeof(options) === 'object') { 468 return true; 469 } 470 471 return false; 472 }, 473 is_bool: function is_bool(mixed_var) { 474 mixed_var = wfch.tools.string_to_bool(mixed_var); 475 return typeof mixed_var === 'boolean'; 476 } 477 }, 478 "swal": function swal(property) { 479 return wfch_swal($.extend({ 480 title: '', 481 text: "", 482 type: 'warning',
483 showCancelButton: true, 484 confirmButtonColor: '#0073aa', 485 cancelButtonColor: '#e33b3b', 486 confirmButtonText: '' 487 }, property)); 488 }, 489 "model": { 490 'add_product': function add_product() { 491 var modal_add_add_product = $("#modal-add-product"); 492 493 if (modal_add_add_product.length > 0) { 494 modal_add_add_product.iziModal({ 495 title: 'Add Product', 496 headerColor: '#6dbe45', 497 background: '#efefef', 498 borderBottom: false, 499 width: 600, 500 overlayColor: 'rgba(0, 0, 0, 0.6)', 501 transitionIn: 'fadeInDown', 502 transitionOut: 'fadeOutDown', 503 navigateArrows: "false", 504 onOpening: function onOpening(modal) { 505 modal.startLoading(); 506 }, 507 onOpened: function onOpened(modal) { 508 modal.stopLoading(); // product_search_setting(modal); 509 }, 510 onClosed: function onClosed(modal) {// console.log('onClosed'); 511 } 512 }); 513 } 514 } 515 }, 516 'sortable': function sortable(ui_class, _start, _stop, hover) { 517 var item_class = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '.wfch_item_drag'; 518 var non_drag_class = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '.ui-state-disabled'; 519 var placeholder = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ''; 520 var sortable = $(ui_class); 521 if (sortable.length === 0) return; 522 sortable.off('sortable'); 523 var options = { 524 connectWith: ui_class, 525 start: function start(event, ui) { 526 _start(event, ui); 527 }, 528 stop: function stop(event, ui) { 529 _stop(event, ui); 530 }, 531 over: function over(event, ui) { 532 hover('in', event, ui); 533 }, 534 out: function out(event, ui) { 535 hover('out', event, ui); 536 } 537 }; 538 var drag_item_class = '.wfch_item_drag'; 539 // console.log(sortable); 540 // if (sortable.find('.ui-sortable-handle').length > 0) { 541 // console.log('yyyy'); 542 // options.handle = ".ui-sortable-handle"; 543 // } 544 545 546 if (item_class !== '') { 547 drag_item_class = item_class; 548 } 549 550 if (non_drag_class !== '') { 551 drag_item_class += ':not(' + non_drag_class + ')'; 552 } 553 554 options.items = drag_item_class; 555 556 if ('' !== placeholder) { 557 options.placeholder = placeholder; 558 } 559 560 sortable.sortable(options); 561 sortable.disableSelection(); 562 }, 563 'addClass': function addClass(el, cl) { 564 $(el).addClass(cl); 565 }, 566 'removeClass': function removeClass(el, cl) { 567 $(el).removeClass(cl); 568 }, 569 show_spinner: function show_spinner() { 570 var spinner = $('.wfch_spinner.spinner'); 571 572 if (spinner.length > 0) { 573 spinner.css("visibility", "visible"); 574 } 575 }, 576 hide_spinner: function hide_spinner() { 577 var spinner = $('.wfch_spinner.spinner'); 578 579 if (spinner.length > 0) { 580 spinner.css("visibility", "hidden"); 581 } 582 }, 583 show_data_save_model: function show_data_save_model() { 584 var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 585 586 if ('' !== title) { 587 wfch.show_saved_model.iziModal('setTitle', title); 588 wfch.show_saved_model.iziModal('open'); 589 } 590 } 591 }; 592}(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.