YITH WooCommerce Ajax Search - Version 1.1.2

Version Description

  • Fixed: Prevent undefined title index if the widget is called by the the_widget func
  • Updated: Autocomplete js library
  • Updated: Plugin Core Framework
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

README.txt CHANGED
@@ -3,13 +3,13 @@
3
  Contributors: yithemes
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
- Tested up to: 3.8.1
7
- Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  YITH WooCommerce Ajax Search allows your users to search products in real time.
12
- WooCommerce 2.1.x Compatible.
13
 
14
  == Description ==
15
 
@@ -73,6 +73,12 @@ In WooCommerce->Settings->Ajax Search page, you can choose the minumum size of t
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
76
  = 1.1.1 =
77
 
78
  * Fixed: Settings link doesn't work on WooCommerce 2.1.1
3
  Contributors: yithemes
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
+ Tested up to: 4.0
7
+ Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  YITH WooCommerce Ajax Search allows your users to search products in real time.
12
+ WooCommerce 2.2.x Compatible.
13
 
14
  == Description ==
15
 
73
 
74
  == Changelog ==
75
 
76
+ = 1.1.2 =
77
+
78
+ * Fixed: Prevent undefined title index if the widget is called by the the_widget func
79
+ * Updated: Autocomplete js library
80
+ * Updated: Plugin Core Framework
81
+
82
  = 1.1.1 =
83
 
84
  * Fixed: Settings link doesn't work on WooCommerce 2.1.1
assets/js/devbridge-jquery-autocomplete.js CHANGED
@@ -1,9 +1,9 @@
1
  /**
2
- * Ajax Autocomplete for jQuery, version 1.2.7
3
  * (c) 2013 Tomas Kirda
4
  *
5
  * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
6
- * For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
7
  *
8
  */
9
 
@@ -29,10 +29,12 @@
29
  escapeRegExChars: function (value) {
30
  return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
31
  },
32
- createNode: function (html) {
33
  var div = document.createElement('div');
34
- div.innerHTML = html;
35
- return div.firstChild;
 
 
36
  }
37
  };
38
  }()),
@@ -68,17 +70,22 @@
68
  noCache: false,
69
  onSearchStart: noop,
70
  onSearchComplete: noop,
 
71
  containerClass: 'autocomplete-suggestions',
72
  tabDisabled: false,
73
  dataType: 'text',
74
  currentRequest: null,
 
 
75
  lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
76
  return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
77
  },
78
  paramName: 'query',
79
  transformResult: function (response) {
80
  return typeof response === 'string' ? $.parseJSON(response) : response;
81
- }
 
 
82
  };
83
 
84
  // Shared variables:
@@ -89,7 +96,7 @@
89
  that.selectedIndex = -1;
90
  that.currentValue = that.element.value;
91
  that.intervalId = 0;
92
- that.cachedResponse = [];
93
  that.onChangeInterval = null;
94
  that.onChange = null;
95
  that.isLocal = false;
@@ -139,7 +146,7 @@
139
  }
140
  };
141
 
142
- that.suggestionsContainer = Autocomplete.utils.createNode('<div class="' + options.containerClass + '" style="position: absolute; display: none;"></div>');
143
 
144
  container = $(that.suggestionsContainer);
145
 
@@ -174,15 +181,23 @@
174
  }
175
  };
176
 
177
- $(window).on('resize', that.fixPositionCapture);
178
 
179
  that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
180
  that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
181
  that.el.on('blur.autocomplete', function () { that.onBlur(); });
182
- that.el.on('focus.autocomplete', function () { that.fixPosition(); });
183
  that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
184
  },
185
 
 
 
 
 
 
 
 
 
186
  onBlur: function () {
187
  this.enableKillerFn();
188
  },
@@ -208,7 +223,7 @@
208
  },
209
 
210
  clearCache: function () {
211
- this.cachedResponse = [];
212
  this.badQueries = [];
213
  },
214
 
@@ -219,7 +234,11 @@
219
  },
220
 
221
  disable: function () {
222
- this.disabled = true;
 
 
 
 
223
  },
224
 
225
  enable: function () {
@@ -228,7 +247,8 @@
228
 
229
  fixPosition: function () {
230
  var that = this,
231
- offset;
 
232
 
233
  // Don't adjsut position if custom container has been specified:
234
  if (that.options.appendTo !== 'body') {
@@ -237,10 +257,16 @@
237
 
238
  offset = that.el.offset();
239
 
240
- $(that.suggestionsContainer).css({
241
  top: (offset.top + that.el.outerHeight()) + 'px',
242
  left: offset.left + 'px'
243
- });
 
 
 
 
 
 
244
  },
245
 
246
  enableKillerFn: function () {
@@ -259,7 +285,7 @@
259
  that.intervalId = window.setInterval(function () {
260
  that.hide();
261
  that.stopKillSuggestions();
262
- }, 300);
263
  },
264
 
265
  stopKillSuggestions: function () {
@@ -368,32 +394,57 @@
368
 
369
  onValueChange: function () {
370
  var that = this,
371
- q;
 
 
 
372
 
373
  if (that.selection) {
374
  that.selection = null;
375
- (that.options.onInvalidateSelection || $.noop)();
376
  }
377
 
378
  clearInterval(that.onChangeInterval);
379
- that.currentValue = that.el.val();
380
-
381
- q = that.getQuery(that.currentValue);
382
  that.selectedIndex = -1;
383
 
384
- if (q.length < that.options.minChars) {
 
 
 
 
 
 
 
 
 
385
  that.hide();
386
  } else {
387
- that.getSuggestions(q);
388
  }
389
  },
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  getQuery: function (value) {
392
  var delimiter = this.options.delimiter,
393
  parts;
394
 
395
  if (!delimiter) {
396
- return $.trim(value);
397
  }
398
  parts = value.split(delimiter);
399
  return $.trim(parts[parts.length - 1]);
@@ -401,51 +452,78 @@
401
 
402
  getSuggestionsLocal: function (query) {
403
  var that = this,
 
404
  queryLowerCase = query.toLowerCase(),
405
- filter = that.options.lookupFilter;
 
 
406
 
407
- return {
408
- suggestions: $.grep(that.options.lookup, function (suggestion) {
409
  return filter(suggestion, query, queryLowerCase);
410
  })
411
  };
 
 
 
 
 
 
412
  },
413
 
414
  getSuggestions: function (q) {
415
  var response,
416
  that = this,
417
  options = that.options,
418
- serviceUrl = options.serviceUrl;
 
 
419
 
420
- response = that.isLocal ? that.getSuggestionsLocal(q) : that.cachedResponse[q];
 
 
 
 
 
 
 
 
 
 
 
421
 
422
  if (response && $.isArray(response.suggestions)) {
423
  that.suggestions = response.suggestions;
424
  that.suggest();
425
  } else if (!that.isBadQuery(q)) {
426
- options.params[options.paramName] = q;
427
  if (options.onSearchStart.call(that.element, options.params) === false) {
428
  return;
429
  }
430
- if ($.isFunction(options.serviceUrl)) {
431
- serviceUrl = options.serviceUrl.call(that.element, q);
432
- }
433
- if(this.currentRequest != null) {
434
- this.currentRequest.abort();
435
  }
436
- this.currentRequest = $.ajax({
437
  url: serviceUrl,
438
- data: options.ignoreParams ? null : options.params,
439
  type: options.type,
440
  dataType: options.dataType
441
  }).done(function (data) {
442
- that.processResponse(data, q);
443
- options.onSearchComplete.call(that.element, q);
 
 
 
 
 
444
  });
445
  }
446
  },
447
 
448
  isBadQuery: function (q) {
 
 
 
 
449
  var badQueries = this.badQueries,
450
  i = badQueries.length;
451
 
@@ -468,45 +546,85 @@
468
 
469
  suggest: function () {
470
  if (this.suggestions.length === 0) {
471
- this.hide();
472
  return;
473
  }
474
 
475
  var that = this,
476
- formatResult = that.options.formatResult,
 
477
  value = that.getQuery(that.currentValue),
478
  className = that.classes.suggestion,
479
  classSelected = that.classes.selected,
480
  container = $(that.suggestionsContainer),
 
481
  html = '',
 
482
  width;
483
 
 
 
 
 
 
 
 
 
484
  // Build suggestions inner HTML:
485
  $.each(that.suggestions, function (i, suggestion) {
486
  html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
487
  });
488
 
489
- // If width is auto, adjust width before displaying suggestions,
490
- // because if instance was created before input had width, it will be zero.
491
- // Also it adjusts if input width has changed.
492
- // -2px to account for suggestions border.
493
- if (that.options.width === 'auto') {
494
- width = that.el.outerWidth() - 2;
495
- container.width(width > 0 ? width : 300);
496
- }
497
 
498
- container.html(html).show();
499
- that.visible = true;
500
 
501
  // Select first value by default:
502
- if (that.options.autoSelectFirst) {
503
  that.selectedIndex = 0;
504
  container.children().first().addClass(classSelected);
505
  }
506
 
 
 
 
 
 
 
 
507
  that.findBestHint();
508
  },
509
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  findBestHint: function () {
511
  var that = this,
512
  value = that.el.val().toLowerCase(),
@@ -551,26 +669,27 @@
551
  return suggestions;
552
  },
553
 
554
- processResponse: function (response, originalQuery) {
555
  var that = this,
556
- options = that.options,
557
- result = options.transformResult(response, originalQuery);
558
 
559
  result.suggestions = that.verifySuggestionsFormat(result.suggestions);
560
 
561
  // Cache results if cache is not disabled:
562
  if (!options.noCache) {
563
- that.cachedResponse[result[options.paramName]] = result;
564
- if (result.suggestions.length === 0) {
565
- that.badQueries.push(result[options.paramName]);
566
  }
567
  }
568
 
569
- // Display suggestions only if returned query matches current value:
570
- if (originalQuery === that.getQuery(that.currentValue)) {
571
- that.suggestions = result.suggestions;
572
- that.suggest();
573
  }
 
 
 
574
  },
575
 
576
  activate: function (index) {
@@ -666,7 +785,11 @@
666
  suggestion = that.suggestions[index];
667
 
668
  that.currentValue = that.getValue(suggestion.value);
669
- that.el.val(that.currentValue);
 
 
 
 
670
  that.signalHint(null);
671
  that.suggestions = [];
672
  that.selection = suggestion;
@@ -700,7 +823,7 @@
700
  var that = this;
701
  that.el.off('.autocomplete').removeData('autocomplete');
702
  that.disableKillerFn();
703
- $(window).off('resize', that.fixPositionCapture);
704
  $(that.suggestionsContainer).remove();
705
  }
706
  };
1
  /**
2
+ * Ajax Autocomplete for jQuery, version 1.2.9
3
  * (c) 2013 Tomas Kirda
4
  *
5
  * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
6
+ * For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
7
  *
8
  */
9
 
29
  escapeRegExChars: function (value) {
30
  return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
31
  },
32
+ createNode: function (containerClass) {
33
  var div = document.createElement('div');
34
+ div.className = containerClass;
35
+ div.style.position = 'absolute';
36
+ div.style.display = 'none';
37
+ return div;
38
  }
39
  };
40
  }()),
70
  noCache: false,
71
  onSearchStart: noop,
72
  onSearchComplete: noop,
73
+ onSearchError: noop,
74
  containerClass: 'autocomplete-suggestions',
75
  tabDisabled: false,
76
  dataType: 'text',
77
  currentRequest: null,
78
+ triggerSelectOnValidInput: true,
79
+ preventBadQueries: true,
80
  lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
81
  return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
82
  },
83
  paramName: 'query',
84
  transformResult: function (response) {
85
  return typeof response === 'string' ? $.parseJSON(response) : response;
86
+ },
87
+ showNoSuggestionNotice: false,
88
+ noSuggestionNotice: 'No results'
89
  };
90
 
91
  // Shared variables:
96
  that.selectedIndex = -1;
97
  that.currentValue = that.element.value;
98
  that.intervalId = 0;
99
+ that.cachedResponse = {};
100
  that.onChangeInterval = null;
101
  that.onChange = null;
102
  that.isLocal = false;
146
  }
147
  };
148
 
149
+ that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass);
150
 
151
  container = $(that.suggestionsContainer);
152
 
181
  }
182
  };
183
 
184
+ $(window).on('resize.autocomplete', that.fixPositionCapture);
185
 
186
  that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
187
  that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
188
  that.el.on('blur.autocomplete', function () { that.onBlur(); });
189
+ that.el.on('focus.autocomplete', function () { that.onFocus(); });
190
  that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
191
  },
192
 
193
+ onFocus: function () {
194
+ var that = this;
195
+ that.fixPosition();
196
+ if (that.options.minChars <= that.el.val().length) {
197
+ that.onValueChange();
198
+ }
199
+ },
200
+
201
  onBlur: function () {
202
  this.enableKillerFn();
203
  },
223
  },
224
 
225
  clearCache: function () {
226
+ this.cachedResponse = {};
227
  this.badQueries = [];
228
  },
229
 
234
  },
235
 
236
  disable: function () {
237
+ var that = this;
238
+ that.disabled = true;
239
+ if (that.currentRequest) {
240
+ that.currentRequest.abort();
241
+ }
242
  },
243
 
244
  enable: function () {
247
 
248
  fixPosition: function () {
249
  var that = this,
250
+ offset,
251
+ styles;
252
 
253
  // Don't adjsut position if custom container has been specified:
254
  if (that.options.appendTo !== 'body') {
257
 
258
  offset = that.el.offset();
259
 
260
+ styles = {
261
  top: (offset.top + that.el.outerHeight()) + 'px',
262
  left: offset.left + 'px'
263
+ };
264
+
265
+ if (that.options.width === 'auto') {
266
+ styles.width = (that.el.outerWidth() - 2) + 'px';
267
+ }
268
+
269
+ $(that.suggestionsContainer).css(styles);
270
  },
271
 
272
  enableKillerFn: function () {
285
  that.intervalId = window.setInterval(function () {
286
  that.hide();
287
  that.stopKillSuggestions();
288
+ }, 50);
289
  },
290
 
291
  stopKillSuggestions: function () {
394
 
395
  onValueChange: function () {
396
  var that = this,
397
+ options = that.options,
398
+ value = that.el.val(),
399
+ query = that.getQuery(value),
400
+ index;
401
 
402
  if (that.selection) {
403
  that.selection = null;
404
+ (options.onInvalidateSelection || $.noop).call(that.element);
405
  }
406
 
407
  clearInterval(that.onChangeInterval);
408
+ that.currentValue = value;
 
 
409
  that.selectedIndex = -1;
410
 
411
+ // Check existing suggestion for the match before proceeding:
412
+ if (options.triggerSelectOnValidInput) {
413
+ index = that.findSuggestionIndex(query);
414
+ if (index !== -1) {
415
+ that.select(index);
416
+ return;
417
+ }
418
+ }
419
+
420
+ if (query.length < options.minChars) {
421
  that.hide();
422
  } else {
423
+ that.getSuggestions(query);
424
  }
425
  },
426
 
427
+ findSuggestionIndex: function (query) {
428
+ var that = this,
429
+ index = -1,
430
+ queryLowerCase = query.toLowerCase();
431
+
432
+ $.each(that.suggestions, function (i, suggestion) {
433
+ if (suggestion.value.toLowerCase() === queryLowerCase) {
434
+ index = i;
435
+ return false;
436
+ }
437
+ });
438
+
439
+ return index;
440
+ },
441
+
442
  getQuery: function (value) {
443
  var delimiter = this.options.delimiter,
444
  parts;
445
 
446
  if (!delimiter) {
447
+ return value;
448
  }
449
  parts = value.split(delimiter);
450
  return $.trim(parts[parts.length - 1]);
452
 
453
  getSuggestionsLocal: function (query) {
454
  var that = this,
455
+ options = that.options,
456
  queryLowerCase = query.toLowerCase(),
457
+ filter = options.lookupFilter,
458
+ limit = parseInt(options.lookupLimit, 10),
459
+ data;
460
 
461
+ data = {
462
+ suggestions: $.grep(options.lookup, function (suggestion) {
463
  return filter(suggestion, query, queryLowerCase);
464
  })
465
  };
466
+
467
+ if (limit && data.suggestions.length > limit) {
468
+ data.suggestions = data.suggestions.slice(0, limit);
469
+ }
470
+
471
+ return data;
472
  },
473
 
474
  getSuggestions: function (q) {
475
  var response,
476
  that = this,
477
  options = that.options,
478
+ serviceUrl = options.serviceUrl,
479
+ params,
480
+ cacheKey;
481
 
482
+ options.params[options.paramName] = q;
483
+ params = options.ignoreParams ? null : options.params;
484
+
485
+ if (that.isLocal) {
486
+ response = that.getSuggestionsLocal(q);
487
+ } else {
488
+ if ($.isFunction(serviceUrl)) {
489
+ serviceUrl = serviceUrl.call(that.element, q);
490
+ }
491
+ cacheKey = serviceUrl + '?' + $.param(params || {});
492
+ response = that.cachedResponse[cacheKey];
493
+ }
494
 
495
  if (response && $.isArray(response.suggestions)) {
496
  that.suggestions = response.suggestions;
497
  that.suggest();
498
  } else if (!that.isBadQuery(q)) {
 
499
  if (options.onSearchStart.call(that.element, options.params) === false) {
500
  return;
501
  }
502
+ if (that.currentRequest) {
503
+ that.currentRequest.abort();
 
 
 
504
  }
505
+ that.currentRequest = $.ajax({
506
  url: serviceUrl,
507
+ data: params,
508
  type: options.type,
509
  dataType: options.dataType
510
  }).done(function (data) {
511
+ var result;
512
+ that.currentRequest = null;
513
+ result = options.transformResult(data);
514
+ that.processResponse(result, q, cacheKey);
515
+ options.onSearchComplete.call(that.element, q, result.suggestions);
516
+ }).fail(function (jqXHR, textStatus, errorThrown) {
517
+ options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
518
  });
519
  }
520
  },
521
 
522
  isBadQuery: function (q) {
523
+ if (!this.options.preventBadQueries){
524
+ return false;
525
+ }
526
+
527
  var badQueries = this.badQueries,
528
  i = badQueries.length;
529
 
546
 
547
  suggest: function () {
548
  if (this.suggestions.length === 0) {
549
+ this.options.showNoSuggestionNotice ? this.noSuggestions() : this.hide();
550
  return;
551
  }
552
 
553
  var that = this,
554
+ options = that.options,
555
+ formatResult = options.formatResult,
556
  value = that.getQuery(that.currentValue),
557
  className = that.classes.suggestion,
558
  classSelected = that.classes.selected,
559
  container = $(that.suggestionsContainer),
560
+ beforeRender = options.beforeRender,
561
  html = '',
562
+ index,
563
  width;
564
 
565
+ if (options.triggerSelectOnValidInput) {
566
+ index = that.findSuggestionIndex(value);
567
+ if (index !== -1) {
568
+ that.select(index);
569
+ return;
570
+ }
571
+ }
572
+
573
  // Build suggestions inner HTML:
574
  $.each(that.suggestions, function (i, suggestion) {
575
  html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
576
  });
577
 
578
+ this.adjustContainerWidth();
 
 
 
 
 
 
 
579
 
580
+ container.html(html);
 
581
 
582
  // Select first value by default:
583
+ if (options.autoSelectFirst) {
584
  that.selectedIndex = 0;
585
  container.children().first().addClass(classSelected);
586
  }
587
 
588
+ if ($.isFunction(beforeRender)) {
589
+ beforeRender.call(that.element, container);
590
+ }
591
+
592
+ container.show();
593
+ that.visible = true;
594
+
595
  that.findBestHint();
596
  },
597
 
598
+ noSuggestions: function() {
599
+ var that = this,
600
+ container = $(that.suggestionsContainer),
601
+ html = '',
602
+ width;
603
+
604
+ html += '<div class="autocomplete-no-suggestion">' + this.options.noSuggestionNotice + '</div>';
605
+
606
+ this.adjustContainerWidth();
607
+ container.html(html);
608
+ container.show();
609
+ that.visible = true;
610
+ },
611
+
612
+ adjustContainerWidth: function() {
613
+ var that = this,
614
+ options = that.options,
615
+ width,
616
+ container = $(that.suggestionsContainer)
617
+
618
+ // If width is auto, adjust width before displaying suggestions,
619
+ // because if instance was created before input had width, it will be zero.
620
+ // Also it adjusts if input width has changed.
621
+ // -2px to account for suggestions border.
622
+ if (options.width === 'auto') {
623
+ width = that.el.outerWidth() - 2;
624
+ container.width(width > 0 ? width : 300);
625
+ }
626
+ },
627
+
628
  findBestHint: function () {
629
  var that = this,
630
  value = that.el.val().toLowerCase(),
669
  return suggestions;
670
  },
671
 
672
+ processResponse: function (result, originalQuery, cacheKey) {
673
  var that = this,
674
+ options = that.options;
 
675
 
676
  result.suggestions = that.verifySuggestionsFormat(result.suggestions);
677
 
678
  // Cache results if cache is not disabled:
679
  if (!options.noCache) {
680
+ that.cachedResponse[cacheKey] = result;
681
+ if (options.preventBadQueries && result.suggestions.length === 0) {
682
+ that.badQueries.push(originalQuery);
683
  }
684
  }
685
 
686
+ // Return if originalQuery is not matching current query:
687
+ if (originalQuery !== that.getQuery(that.currentValue)) {
688
+ return;
 
689
  }
690
+
691
+ that.suggestions = result.suggestions;
692
+ that.suggest();
693
  },
694
 
695
  activate: function (index) {
785
  suggestion = that.suggestions[index];
786
 
787
  that.currentValue = that.getValue(suggestion.value);
788
+
789
+ if (that.currentValue !== that.el.val()) {
790
+ that.el.val(that.currentValue);
791
+ }
792
+
793
  that.signalHint(null);
794
  that.suggestions = [];
795
  that.selection = suggestion;
823
  var that = this;
824
  that.el.off('.autocomplete').removeData('autocomplete');
825
  that.disableKillerFn();
826
+ $(window).off('resize.autocomplete', that.fixPositionCapture);
827
  $(that.suggestionsContainer).remove();
828
  }
829
  };
assets/js/devbridge-jquery-autocomplete.min.js CHANGED
@@ -1,27 +1,22 @@
1
- /**
2
- * Ajax Autocomplete for jQuery, version 1.2.7
3
- * (c) 2013 Tomas Kirda
4
- *
5
- * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
6
- * For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
7
- *
8
- */
9
- (function(e){"function"===typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function g(a,b){var c=function(){},c={autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:g.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:c,onSearchComplete:c,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,lookupFilter:function(a,
10
- b,c){return-1!==a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(a){return"string"===typeof a?e.parseJSON(a):a}};this.element=a;this.el=e(a);this.suggestions=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.element.value;this.intervalId=0;this.cachedResponse=[];this.onChange=this.onChangeInterval=null;this.isLocal=!1;this.suggestionsContainer=null;this.options=e.extend({},c,b);this.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"};
11
- this.hint=null;this.hintValue="";this.selection=null;this.initialize();this.setOptions(b)}var k=function(){return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");b.innerHTML=a;return b.firstChild}}}();g.utils=k;e.Autocomplete=g;g.formatResult=function(a,b){var c="("+k.escapeRegExChars(b)+")";return a.value.replace(RegExp(c,"gi"),"<strong>$1</strong>")};g.prototype={killerFn:null,initialize:function(){var a=
12
- this,b="."+a.classes.suggestion,c=a.classes.selected,d=a.options,f;a.element.setAttribute("autocomplete","off");a.killerFn=function(b){0===e(b.target).closest("."+a.options.containerClass).length&&(a.killSuggestions(),a.disableKillerFn())};a.suggestionsContainer=g.utils.createNode('<div class="'+d.containerClass+'" style="position: absolute; display: none;"></div>');f=e(a.suggestionsContainer);f.appendTo(d.appendTo);"auto"!==d.width&&f.width(d.width);f.on("mouseover.autocomplete",b,function(){a.activate(e(this).data("index"))});
13
- f.on("mouseout.autocomplete",function(){a.selectedIndex=-1;f.children("."+c).removeClass(c)});f.on("click.autocomplete",b,function(){a.select(e(this).data("index"))});a.fixPosition();a.fixPositionCapture=function(){a.visible&&a.fixPosition()};e(window).on("resize",a.fixPositionCapture);a.el.on("keydown.autocomplete",function(b){a.onKeyPress(b)});a.el.on("keyup.autocomplete",function(b){a.onKeyUp(b)});a.el.on("blur.autocomplete",function(){a.onBlur()});a.el.on("focus.autocomplete",function(){a.fixPosition()});
14
- a.el.on("change.autocomplete",function(b){a.onKeyUp(b)})},onBlur:function(){this.enableKillerFn()},setOptions:function(a){var b=this.options;e.extend(b,a);if(this.isLocal=e.isArray(b.lookup))b.lookup=this.verifySuggestionsFormat(b.lookup);e(this.suggestionsContainer).css({"max-height":b.maxHeight+"px",width:b.width+"px","z-index":b.zIndex})},clearCache:function(){this.cachedResponse=[];this.badQueries=[]},clear:function(){this.clearCache();this.currentValue="";this.suggestions=[]},disable:function(){this.disabled=
15
- !0},enable:function(){this.disabled=!1},fixPosition:function(){var a;"body"===this.options.appendTo&&(a=this.el.offset(),e(this.suggestionsContainer).css({top:a.top+this.el.outerHeight()+"px",left:a.left+"px"}))},enableKillerFn:function(){e(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){e(document).off("click.autocomplete",this.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions();a.intervalId=window.setInterval(function(){a.hide();a.stopKillSuggestions()},
16
- 300)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var a=this.el.val().length,b=this.element.selectionStart;return"number"===typeof b?b===a:document.selection?(b=document.selection.createRange(),b.moveStart("character",-a),a===b.text.length):!0},onKeyPress:function(a){if(!this.disabled&&!this.visible&&40===a.which&&this.currentValue)this.suggest();else if(!this.disabled&&this.visible){switch(a.which){case 27:this.el.val(this.currentValue);this.hide();
17
- break;case 39:if(this.hint&&this.options.onHint&&this.isCursorAtEnd()){this.selectHint();break}return;case 9:if(this.hint&&this.options.onHint){this.selectHint();return}case 13:if(-1===this.selectedIndex){this.hide();return}this.select(this.selectedIndex);if(9===a.which&&!1===this.options.tabDisabled)return;break;case 38:this.moveUp();break;case 40:this.moveDown();break;default:return}a.stopImmediatePropagation();a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case 38:case 40:return}clearInterval(b.onChangeInterval);
18
- if(b.currentValue!==b.el.val())if(b.findBestHint(),0<b.options.deferRequestBy)b.onChangeInterval=setInterval(function(){b.onValueChange()},b.options.deferRequestBy);else b.onValueChange()}},onValueChange:function(){var a;this.selection&&(this.selection=null,(this.options.onInvalidateSelection||e.noop)());clearInterval(this.onChangeInterval);this.currentValue=this.el.val();a=this.getQuery(this.currentValue);this.selectedIndex=-1;a.length<this.options.minChars?this.hide():this.getSuggestions(a)},getQuery:function(a){var b=
19
- this.options.delimiter;if(!b)return e.trim(a);a=a.split(b);return e.trim(a[a.length-1])},getSuggestionsLocal:function(a){var b=a.toLowerCase(),c=this.options.lookupFilter;return{suggestions:e.grep(this.options.lookup,function(d){return c(d,a,b)})}},getSuggestions:function(a){var b,c=this,d=c.options,f=d.serviceUrl;(b=c.isLocal?c.getSuggestionsLocal(a):c.cachedResponse[a])&&e.isArray(b.suggestions)?(c.suggestions=b.suggestions,c.suggest()):c.isBadQuery(a)||(d.params[d.paramName]=a,!1!==d.onSearchStart.call(c.element,
20
- d.params)&&(e.isFunction(d.serviceUrl)&&(f=d.serviceUrl.call(c.element,a)),null!=this.currentRequest&&this.currentRequest.abort(),this.currentRequest=e.ajax({url:f,data:d.ignoreParams?null:d.params,type:d.type,dataType:d.dataType}).done(function(b){c.processResponse(b,a);d.onSearchComplete.call(c.element,a)})))},isBadQuery:function(a){for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){this.visible=!1;this.selectedIndex=-1;e(this.suggestionsContainer).hide();
21
- this.signalHint(null)},suggest:function(){if(0===this.suggestions.length)this.hide();else{var a=this.options.formatResult,b=this.getQuery(this.currentValue),c=this.classes.suggestion,d=this.classes.selected,f=e(this.suggestionsContainer),g="",h;e.each(this.suggestions,function(d,e){g+='<div class="'+c+'" data-index="'+d+'">'+a(e,b)+"</div>"});"auto"===this.options.width&&(h=this.el.outerWidth()-2,f.width(0<h?h:300));f.html(g).show();this.visible=!0;this.options.autoSelectFirst&&(this.selectedIndex=
22
- 0,f.children().first().addClass(d));this.findBestHint()}},findBestHint:function(){var a=this.el.val().toLowerCase(),b=null;a&&(e.each(this.suggestions,function(c,d){var e=0===d.value.toLowerCase().indexOf(a);e&&(b=d);return!e}),this.signalHint(b))},signalHint:function(a){var b="";a&&(b=this.currentValue+a.value.substr(this.currentValue.length));this.hintValue!==b&&(this.hintValue=b,this.hint=a,(this.options.onHint||e.noop)(b))},verifySuggestionsFormat:function(a){return a.length&&"string"===typeof a[0]?
23
- e.map(a,function(a){return{value:a,data:null}}):a},processResponse:function(a,b){var c=this.options,d=c.transformResult(a,b);d.suggestions=this.verifySuggestionsFormat(d.suggestions);c.noCache||(this.cachedResponse[d[c.paramName]]=d,0===d.suggestions.length&&this.badQueries.push(d[c.paramName]));b===this.getQuery(this.currentValue)&&(this.suggestions=d.suggestions,this.suggest())},activate:function(a){var b=this.classes.selected,c=e(this.suggestionsContainer),d=c.children();c.children("."+b).removeClass(b);
24
- this.selectedIndex=a;return-1!==this.selectedIndex&&d.length>this.selectedIndex?(a=d.get(this.selectedIndex),e(a).addClass(b),a):null},selectHint:function(){var a=e.inArray(this.hint,this.suggestions);this.select(a)},select:function(a){this.hide();this.onSelect(a)},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(e(this.suggestionsContainer).children().first().removeClass(this.classes.selected),this.selectedIndex=-1,this.el.val(this.currentValue),this.findBestHint()):this.adjustScroll(this.selectedIndex-
25
- 1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(a){var b=this.activate(a),c,d;b&&(b=b.offsetTop,c=e(this.suggestionsContainer).scrollTop(),d=c+this.options.maxHeight-25,b<c?e(this.suggestionsContainer).scrollTop(b):b>d&&e(this.suggestionsContainer).scrollTop(b-this.options.maxHeight+25),this.el.val(this.getValue(this.suggestions[a].value)),this.signalHint(null))},onSelect:function(a){var b=this.options.onSelect;
26
- a=this.suggestions[a];this.currentValue=this.getValue(a.value);this.el.val(this.currentValue);this.signalHint(null);this.suggestions=[];this.selection=a;e.isFunction(b)&&b.call(this.element,a)},getValue:function(a){var b=this.options.delimiter,c;if(!b)return a;c=this.currentValue;b=c.split(b);return 1===b.length?a:c.substr(0,c.length-b[b.length-1].length)+a},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete");this.disableKillerFn();e(window).off("resize",this.fixPositionCapture);
27
- e(this.suggestionsContainer).remove()}};e.fn.autocomplete=function(a,b){return 0===arguments.length?this.first().data("autocomplete"):this.each(function(){var c=e(this),d=c.data("autocomplete");if("string"===typeof a){if(d&&"function"===typeof d[a])d[a](b)}else d&&d.dispose&&d.dispose(),d=new g(this,a),c.data("autocomplete",d)})}});
1
+ (function(d){"function"===typeof define&&define.amd?define(["jquery"],d):d(jQuery)})(function(d){function g(a,b){var c=function(){},c={autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:g.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:c,onSearchComplete:c,onSearchError:c,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,
2
+ preventBadQueries:!0,lookupFilter:function(a,b,c){return-1!==a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(a){return"string"===typeof a?d.parseJSON(a):a},showNoSuggestionNotice:!1,noSuggestionNotice:"No results"};this.element=a;this.el=d(a);this.suggestions=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.element.value;this.intervalId=0;this.cachedResponse={};this.onChange=this.onChangeInterval=null;this.isLocal=!1;this.suggestionsContainer=null;this.options=
3
+ d.extend({},c,b);this.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"};this.hint=null;this.hintValue="";this.selection=null;this.initialize();this.setOptions(b)}var h=function(){return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");b.className=a;b.style.position="absolute";b.style.display="none";return b}}}();g.utils=h;d.Autocomplete=g;g.formatResult=function(a,b){var c=
4
+ "("+h.escapeRegExChars(b)+")";return a.value.replace(new RegExp(c,"gi"),"<strong>$1</strong>")};g.prototype={killerFn:null,initialize:function(){var a=this,b="."+a.classes.suggestion,c=a.classes.selected,e=a.options,f;a.element.setAttribute("autocomplete","off");a.killerFn=function(b){0===d(b.target).closest("."+a.options.containerClass).length&&(a.killSuggestions(),a.disableKillerFn())};a.suggestionsContainer=g.utils.createNode(e.containerClass);f=d(a.suggestionsContainer);f.appendTo(e.appendTo);
5
+ "auto"!==e.width&&f.width(e.width);f.on("mouseover.autocomplete",b,function(){a.activate(d(this).data("index"))});f.on("mouseout.autocomplete",function(){a.selectedIndex=-1;f.children("."+c).removeClass(c)});f.on("click.autocomplete",b,function(){a.select(d(this).data("index"))});a.fixPosition();a.fixPositionCapture=function(){a.visible&&a.fixPosition()};d(window).on("resize.autocomplete",a.fixPositionCapture);a.el.on("keydown.autocomplete",function(b){a.onKeyPress(b)});a.el.on("keyup.autocomplete",
6
+ function(b){a.onKeyUp(b)});a.el.on("blur.autocomplete",function(){a.onBlur()});a.el.on("focus.autocomplete",function(){a.onFocus()});a.el.on("change.autocomplete",function(b){a.onKeyUp(b)})},onFocus:function(){this.fixPosition();if(this.options.minChars<=this.el.val().length)this.onValueChange()},onBlur:function(){this.enableKillerFn()},setOptions:function(a){var b=this.options;d.extend(b,a);if(this.isLocal=d.isArray(b.lookup))b.lookup=this.verifySuggestionsFormat(b.lookup);d(this.suggestionsContainer).css({"max-height":b.maxHeight+
7
+ "px",width:b.width+"px","z-index":b.zIndex})},clearCache:function(){this.cachedResponse={};this.badQueries=[]},clear:function(){this.clearCache();this.currentValue="";this.suggestions=[]},disable:function(){this.disabled=!0;this.currentRequest&&this.currentRequest.abort()},enable:function(){this.disabled=!1},fixPosition:function(){var a;"body"===this.options.appendTo&&(a=this.el.offset(),a={top:a.top+this.el.outerHeight()+"px",left:a.left+"px"},"auto"===this.options.width&&(a.width=this.el.outerWidth()-
8
+ 2+"px"),d(this.suggestionsContainer).css(a))},enableKillerFn:function(){d(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){d(document).off("click.autocomplete",this.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions();a.intervalId=window.setInterval(function(){a.hide();a.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var a=this.el.val().length,b=this.element.selectionStart;return"number"===
9
+ typeof b?b===a:document.selection?(b=document.selection.createRange(),b.moveStart("character",-a),a===b.text.length):!0},onKeyPress:function(a){if(!this.disabled&&!this.visible&&40===a.which&&this.currentValue)this.suggest();else if(!this.disabled&&this.visible){switch(a.which){case 27:this.el.val(this.currentValue);this.hide();break;case 39:if(this.hint&&this.options.onHint&&this.isCursorAtEnd()){this.selectHint();break}return;case 9:if(this.hint&&this.options.onHint){this.selectHint();return}case 13:if(-1===
10
+ this.selectedIndex){this.hide();return}this.select(this.selectedIndex);if(9===a.which&&!1===this.options.tabDisabled)return;break;case 38:this.moveUp();break;case 40:this.moveDown();break;default:return}a.stopImmediatePropagation();a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case 38:case 40:return}clearInterval(b.onChangeInterval);if(b.currentValue!==b.el.val())if(b.findBestHint(),0<b.options.deferRequestBy)b.onChangeInterval=setInterval(function(){b.onValueChange()},
11
+ b.options.deferRequestBy);else b.onValueChange()}},onValueChange:function(){var a=this.options,b=this.el.val(),c=this.getQuery(b);this.selection&&(this.selection=null,(a.onInvalidateSelection||d.noop).call(this.element));clearInterval(this.onChangeInterval);this.currentValue=b;this.selectedIndex=-1;if(a.triggerSelectOnValidInput&&(b=this.findSuggestionIndex(c),-1!==b)){this.select(b);return}c.length<a.minChars?this.hide():this.getSuggestions(c)},findSuggestionIndex:function(a){var b=-1,c=a.toLowerCase();
12
+ d.each(this.suggestions,function(a,d){if(d.value.toLowerCase()===c)return b=a,!1});return b},getQuery:function(a){var b=this.options.delimiter;if(!b)return a;a=a.split(b);return d.trim(a[a.length-1])},getSuggestionsLocal:function(a){var b=this.options,c=a.toLowerCase(),e=b.lookupFilter,f=parseInt(b.lookupLimit,10),b={suggestions:d.grep(b.lookup,function(b){return e(b,a,c)})};f&&b.suggestions.length>f&&(b.suggestions=b.suggestions.slice(0,f));return b},getSuggestions:function(a){var b,c=this,e=c.options,
13
+ f=e.serviceUrl,k,g;e.params[e.paramName]=a;k=e.ignoreParams?null:e.params;c.isLocal?b=c.getSuggestionsLocal(a):(d.isFunction(f)&&(f=f.call(c.element,a)),g=f+"?"+d.param(k||{}),b=c.cachedResponse[g]);b&&d.isArray(b.suggestions)?(c.suggestions=b.suggestions,c.suggest()):c.isBadQuery(a)||!1===e.onSearchStart.call(c.element,e.params)||(c.currentRequest&&c.currentRequest.abort(),c.currentRequest=d.ajax({url:f,data:k,type:e.type,dataType:e.dataType}).done(function(b){c.currentRequest=null;b=e.transformResult(b);
14
+ c.processResponse(b,a,g);e.onSearchComplete.call(c.element,a,b.suggestions)}).fail(function(b,d,f){e.onSearchError.call(c.element,a,b,d,f)}))},isBadQuery:function(a){if(!this.options.preventBadQueries)return!1;for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){this.visible=!1;this.selectedIndex=-1;d(this.suggestionsContainer).hide();this.signalHint(null)},suggest:function(){if(0===this.suggestions.length)this.options.showNoSuggestionNotice?this.noSuggestions():
15
+ this.hide();else{var a=this.options,b=a.formatResult,c=this.getQuery(this.currentValue),e=this.classes.suggestion,f=this.classes.selected,g=d(this.suggestionsContainer),h=a.beforeRender,l="",m;if(a.triggerSelectOnValidInput&&(m=this.findSuggestionIndex(c),-1!==m)){this.select(m);return}d.each(this.suggestions,function(a,d){l+='<div class="'+e+'" data-index="'+a+'">'+b(d,c)+"</div>"});this.adjustContainerWidth();g.html(l);a.autoSelectFirst&&(this.selectedIndex=0,g.children().first().addClass(f));d.isFunction(h)&&
16
+ h.call(this.element,g);g.show();this.visible=!0;this.findBestHint()}},noSuggestions:function(){var a=d(this.suggestionsContainer),b;b=""+('<div class="autocomplete-no-suggestion">'+this.options.noSuggestionNotice+"</div>");this.adjustContainerWidth();a.html(b);a.show();this.visible=!0},adjustContainerWidth:function(){var a=this.options,b=d(this.suggestionsContainer);"auto"===a.width&&(a=this.el.outerWidth()-2,b.width(0<a?a:300))},findBestHint:function(){var a=this.el.val().toLowerCase(),b=null;a&&
17
+ (d.each(this.suggestions,function(c,d){var f=0===d.value.toLowerCase().indexOf(a);f&&(b=d);return!f}),this.signalHint(b))},signalHint:function(a){var b="";a&&(b=this.currentValue+a.value.substr(this.currentValue.length));this.hintValue!==b&&(this.hintValue=b,this.hint=a,(this.options.onHint||d.noop)(b))},verifySuggestionsFormat:function(a){return a.length&&"string"===typeof a[0]?d.map(a,function(a){return{value:a,data:null}}):a},processResponse:function(a,b,c){var d=this.options;a.suggestions=this.verifySuggestionsFormat(a.suggestions);
18
+ d.noCache||(this.cachedResponse[c]=a,d.preventBadQueries&&0===a.suggestions.length&&this.badQueries.push(b));b===this.getQuery(this.currentValue)&&(this.suggestions=a.suggestions,this.suggest())},activate:function(a){var b=this.classes.selected,c=d(this.suggestionsContainer),e=c.children();c.children("."+b).removeClass(b);this.selectedIndex=a;return-1!==this.selectedIndex&&e.length>this.selectedIndex?(a=e.get(this.selectedIndex),d(a).addClass(b),a):null},selectHint:function(){var a=d.inArray(this.hint,
19
+ this.suggestions);this.select(a)},select:function(a){this.hide();this.onSelect(a)},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(d(this.suggestionsContainer).children().first().removeClass(this.classes.selected),this.selectedIndex=-1,this.el.val(this.currentValue),this.findBestHint()):this.adjustScroll(this.selectedIndex-1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(a){var b=this.activate(a),
20
+ c,e;b&&(b=b.offsetTop,c=d(this.suggestionsContainer).scrollTop(),e=c+this.options.maxHeight-25,b<c?d(this.suggestionsContainer).scrollTop(b):b>e&&d(this.suggestionsContainer).scrollTop(b-this.options.maxHeight+25),this.el.val(this.getValue(this.suggestions[a].value)),this.signalHint(null))},onSelect:function(a){var b=this.options.onSelect;a=this.suggestions[a];this.currentValue=this.getValue(a.value);this.currentValue!==this.el.val()&&this.el.val(this.currentValue);this.signalHint(null);this.suggestions=
21
+ [];this.selection=a;d.isFunction(b)&&b.call(this.element,a)},getValue:function(a){var b=this.options.delimiter,c;if(!b)return a;c=this.currentValue;b=c.split(b);return 1===b.length?a:c.substr(0,c.length-b[b.length-1].length)+a},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete");this.disableKillerFn();d(window).off("resize.autocomplete",this.fixPositionCapture);d(this.suggestionsContainer).remove()}};d.fn.autocomplete=function(a,b){return 0===arguments.length?this.first().data("autocomplete"):
22
+ this.each(function(){var c=d(this),e=c.data("autocomplete");if("string"===typeof a){if(e&&"function"===typeof e[a])e[a](b)}else e&&e.dispose&&e.dispose(),e=new g(this,a),c.data("autocomplete",e)})}});
 
 
 
 
 
class.yith-wcas.php CHANGED
@@ -22,7 +22,7 @@ if( !class_exists( 'YITH_WCAS' ) ) {
22
  * @var string
23
  * @since 1.0.0
24
  */
25
- public $version = '1.1.1';
26
 
27
  /**
28
  * Plugin object
@@ -102,6 +102,7 @@ if( !class_exists( 'YITH_WCAS' ) ) {
102
  global $woocommerce;
103
 
104
  $search_keyword = esc_attr($_REQUEST['query']);
 
105
  $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
106
  $products = array();
107
 
@@ -121,6 +122,17 @@ if( !class_exists( 'YITH_WCAS' ) ) {
121
  )
122
  )
123
  );
 
 
 
 
 
 
 
 
 
 
 
124
  $products_query = new WP_Query( $args );
125
 
126
  if ( $products_query->have_posts() ) {
22
  * @var string
23
  * @since 1.0.0
24
  */
25
+ public $version = '1.1.2';
26
 
27
  /**
28
  * Plugin object
102
  global $woocommerce;
103
 
104
  $search_keyword = esc_attr($_REQUEST['query']);
105
+
106
  $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
107
  $products = array();
108
 
122
  )
123
  )
124
  );
125
+
126
+ if( isset( $_REQUEST['product_cat']) ){
127
+ $args['tax_query'] = array(
128
+ 'relation' => 'AND',
129
+ array(
130
+ 'taxonomy' => 'product_cat',
131
+ 'field' => 'slug',
132
+ 'terms' => $_REQUEST['product_cat']
133
+ ));
134
+ }
135
+
136
  $products_query = new WP_Query( $args );
137
 
138
  if ( $products_query->have_posts() ) {
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
- * Version: 1.1.1
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
+ * Version: 1.1.2
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
widgets/class.yith-wcas-ajax-search.php CHANGED
@@ -50,7 +50,7 @@ if( !class_exists( 'YITH_WCAS_Ajax_Search_Widget' ) ) {
50
  function widget( $args, $instance ) {
51
  extract($args);
52
 
53
- $title = $instance['title'];
54
  $title = apply_filters('widget_title', $title, $instance, $this->id_base);
55
 
56
  echo $before_widget;
50
  function widget( $args, $instance ) {
51
  extract($args);
52
 
53
+ $title = isset( $instance['title'] ) ? $instance['title'] : '';
54
  $title = apply_filters('widget_title', $title, $instance, $this->id_base);
55
 
56
  echo $before_widget;
yit-common/yit-functions.php CHANGED
@@ -6,9 +6,11 @@
6
  * @version 0.0.1
7
  */
8
 
9
- if( !defined('YITH_FUNCTIONS')) {
10
- define( 'YITH_FUNCTIONS', true);
11
- }
 
 
12
 
13
  if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
14
  /**
6
  * @version 0.0.1
7
  */
8
 
9
+ define( 'YITH_FUNCTIONS', true);
10
+
11
+ /* === Include Common Framework File === */
12
+ require_once( 'google_fonts.php' );
13
+ require_once( 'yith-panel.php' );
14
 
15
  if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
16
  /**