YITH WooCommerce Ajax Search - Version 1.3.2

Version Description

  • Fixed: Backward compatibility with Autocomplete function
Download this release

Release Info

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

Code changes from version 1.3.1 to 1.3.2

README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 3.5.1
6
  Tested up to: 4.2
7
- Stable tag: 1.3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -62,6 +62,11 @@ If you have created your own language pack, or have an update for an existing on
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 1.3.1 =
66
 
67
  * Updated: Renamed Autocomplete function with YithAutocomplete
@@ -133,6 +138,11 @@ If you have created your own language pack, or have an update for an existing on
133
 
134
 
135
  == Upgrade notice ==
 
 
 
 
 
136
  = 1.3.1 =
137
 
138
  * Updated: Renamed Autocomplete function with YithAutocomplete
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 3.5.1
6
  Tested up to: 4.2
7
+ Stable tag: 1.3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
62
 
63
  == Changelog ==
64
 
65
+
66
+ = 1.3.2 =
67
+
68
+ * Fixed: Backward compatibility with Autocomplete function
69
+
70
  = 1.3.1 =
71
 
72
  * Updated: Renamed Autocomplete function with YithAutocomplete
138
 
139
 
140
  == Upgrade notice ==
141
+
142
+ = 1.3.2 =
143
+
144
+ * Fixed: Backward compatibility with Autocomplete function
145
+
146
  = 1.3.1 =
147
 
148
  * Updated: Renamed Autocomplete function with YithAutocomplete
assets/js/devbridge-jquery-autocomplete.js CHANGED
@@ -20,7 +20,6 @@
20
  // Browser globals
21
  factory(jQuery);
22
  }
23
-
24
  }(function ($) {
25
  'use strict';
26
  var
@@ -49,7 +48,7 @@
49
  DOWN: 40
50
  };
51
 
52
- function YithAutocomplete(el, options) {
53
  var noop = function () { },
54
  that = this,
55
  defaults = {
@@ -63,7 +62,7 @@
63
  maxHeight: 300,
64
  deferRequestBy: 0,
65
  params: {},
66
- formatResult: YithAutocomplete.formatResult,
67
  delimiter: null,
68
  zIndex: 9999,
69
  type: 'GET',
@@ -115,16 +114,17 @@
115
  that.setOptions(options);
116
  }
117
 
118
- YithAutocomplete.utils = utils;
119
 
120
- $.YithAutocomplete = YithAutocomplete;
121
 
122
- YithAutocomplete.formatResult = function (suggestion, currentValue) {
123
  var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
 
124
  return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
125
  };
126
 
127
- YithAutocomplete.prototype = {
128
 
129
  killerFn: null,
130
 
@@ -145,7 +145,7 @@
145
  }
146
  };
147
 
148
- that.suggestionsContainer = YithAutocomplete.utils.createNode(options.containerClass);
149
 
150
  container = $(that.suggestionsContainer);
151
 
@@ -826,9 +826,9 @@
826
  $(that.suggestionsContainer).remove();
827
  }
828
  };
829
-
830
  // Create chainable jQuery plugin:
831
- $.fn.yithautocomplete = function (options, args) {
832
  var dataKey = 'autocomplete';
833
  // If function invoked without argument return
834
  // instance of the first matched element:
@@ -849,7 +849,7 @@
849
  if (instance && instance.dispose) {
850
  instance.dispose();
851
  }
852
- instance = new YithAutocomplete(this, options);
853
  inputElement.data(dataKey, instance);
854
  }
855
  });
20
  // Browser globals
21
  factory(jQuery);
22
  }
 
23
  }(function ($) {
24
  'use strict';
25
  var
48
  DOWN: 40
49
  };
50
 
51
+ function Autocomplete(el, options) {
52
  var noop = function () { },
53
  that = this,
54
  defaults = {
62
  maxHeight: 300,
63
  deferRequestBy: 0,
64
  params: {},
65
+ formatResult: Autocomplete.formatResult,
66
  delimiter: null,
67
  zIndex: 9999,
68
  type: 'GET',
114
  that.setOptions(options);
115
  }
116
 
117
+ Autocomplete.utils = utils;
118
 
119
+ $.Autocomplete = Autocomplete;
120
 
121
+ Autocomplete.formatResult = function (suggestion, currentValue) {
122
  var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
123
+
124
  return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
125
  };
126
 
127
+ Autocomplete.prototype = {
128
 
129
  killerFn: null,
130
 
145
  }
146
  };
147
 
148
+ that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass);
149
 
150
  container = $(that.suggestionsContainer);
151
 
826
  $(that.suggestionsContainer).remove();
827
  }
828
  };
829
+
830
  // Create chainable jQuery plugin:
831
+ $.fn.autocomplete = function (options, args) {
832
  var dataKey = 'autocomplete';
833
  // If function invoked without argument return
834
  // instance of the first matched element:
849
  if (instance && instance.dispose) {
850
  instance.dispose();
851
  }
852
+ instance = new Autocomplete(this, options);
853
  inputElement.data(dataKey, instance);
854
  }
855
  });
assets/js/devbridge-jquery-autocomplete.min.js CHANGED
@@ -1,7 +1,7 @@
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.YithAutocomplete=g;g.formatResult=function(a,
4
- b){var c="("+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()-
@@ -18,5 +18,5 @@ h.call(this.element,g);g.show();this.visible=!0;this.findBestHint()}},noSuggesti
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.yithautocomplete=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)})}});
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()-
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)})}});
assets/js/frontend.js CHANGED
@@ -5,6 +5,7 @@
5
  * @package YITH WooCommerce Ajax Search
6
  * @version 1.1.1
7
  */
 
8
  jQuery(document).ready(function ($) {
9
  "use strict";
10
 
5
  * @package YITH WooCommerce Ajax Search
6
  * @version 1.1.1
7
  */
8
+
9
  jQuery(document).ready(function ($) {
10
  "use strict";
11
 
assets/js/yith-autocomplete.js ADDED
@@ -0,0 +1,857 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
10
+ /*jslint browser: true, white: true, plusplus: true */
11
+ /*global define, window, document, jQuery */
12
+
13
+ // Expose plugin as an AMD module if AMD loader is present:
14
+ (function (factory) {
15
+ 'use strict';
16
+ if (typeof define === 'function' && define.amd) {
17
+ // AMD. Register as an anonymous module.
18
+ define(['jquery'], factory);
19
+ } else {
20
+ // Browser globals
21
+ factory(jQuery);
22
+ }
23
+
24
+ }(function ($) {
25
+ 'use strict';
26
+ var
27
+ utils = (function () {
28
+ return {
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
+ }()),
41
+
42
+ keys = {
43
+ ESC: 27,
44
+ TAB: 9,
45
+ RETURN: 13,
46
+ LEFT: 37,
47
+ UP: 38,
48
+ RIGHT: 39,
49
+ DOWN: 40
50
+ };
51
+
52
+ function YithAutocomplete(el, options) {
53
+ var noop = function () { },
54
+ that = this,
55
+ defaults = {
56
+ autoSelectFirst: false,
57
+ appendTo: 'body',
58
+ serviceUrl: null,
59
+ lookup: null,
60
+ onSelect: null,
61
+ width: 'auto',
62
+ minChars: 1,
63
+ maxHeight: 300,
64
+ deferRequestBy: 0,
65
+ params: {},
66
+ formatResult: YithAutocomplete.formatResult,
67
+ delimiter: null,
68
+ zIndex: 9999,
69
+ type: 'GET',
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:
92
+ that.element = el;
93
+ that.el = $(el);
94
+ that.suggestions = [];
95
+ that.badQueries = [];
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;
103
+ that.suggestionsContainer = null;
104
+ that.options = $.extend({}, defaults, options);
105
+ that.classes = {
106
+ selected: 'autocomplete-selected',
107
+ suggestion: 'autocomplete-suggestion'
108
+ };
109
+ that.hint = null;
110
+ that.hintValue = '';
111
+ that.selection = null;
112
+
113
+ // Initialize and set options:
114
+ that.initialize();
115
+ that.setOptions(options);
116
+ }
117
+
118
+ YithAutocomplete.utils = utils;
119
+
120
+ $.YithAutocomplete = YithAutocomplete;
121
+
122
+ YithAutocomplete.formatResult = function (suggestion, currentValue) {
123
+ var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
124
+ return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
125
+ };
126
+
127
+ YithAutocomplete.prototype = {
128
+
129
+ killerFn: null,
130
+
131
+ initialize: function () {
132
+ var that = this,
133
+ suggestionSelector = '.' + that.classes.suggestion,
134
+ selected = that.classes.selected,
135
+ options = that.options,
136
+ container;
137
+
138
+ // Remove autocomplete attribute to prevent native suggestions:
139
+ that.element.setAttribute('autocomplete', 'off');
140
+
141
+ that.killerFn = function (e) {
142
+ if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
143
+ that.killSuggestions();
144
+ that.disableKillerFn();
145
+ }
146
+ };
147
+
148
+ that.suggestionsContainer = YithAutocomplete.utils.createNode(options.containerClass);
149
+
150
+ container = $(that.suggestionsContainer);
151
+
152
+ container.appendTo(options.appendTo);
153
+
154
+ // Only set width if it was provided:
155
+ if (options.width !== 'auto') {
156
+ container.width(options.width);
157
+ }
158
+
159
+ // Listen for mouse over event on suggestions list:
160
+ container.on('mouseover.autocomplete', suggestionSelector, function () {
161
+ that.activate($(this).data('index'));
162
+ });
163
+
164
+ // Deselect active element when mouse leaves suggestions container:
165
+ container.on('mouseout.autocomplete', function () {
166
+ that.selectedIndex = -1;
167
+ container.children('.' + selected).removeClass(selected);
168
+ });
169
+
170
+ // Listen for click event on suggestions list:
171
+ container.on('click.autocomplete', suggestionSelector, function () {
172
+ that.select($(this).data('index'));
173
+ });
174
+
175
+ that.fixPosition();
176
+
177
+ that.fixPositionCapture = function () {
178
+ if (that.visible) {
179
+ that.fixPosition();
180
+ }
181
+ };
182
+
183
+ $(window).on('resize.autocomplete', that.fixPositionCapture);
184
+
185
+ that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
186
+ that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
187
+ that.el.on('blur.autocomplete', function () { that.onBlur(); });
188
+ that.el.on('focus.autocomplete', function () { that.onFocus(); });
189
+ that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
190
+ },
191
+
192
+ onFocus: function () {
193
+ var that = this;
194
+ that.fixPosition();
195
+ if (that.options.minChars <= that.el.val().length) {
196
+ that.onValueChange();
197
+ }
198
+ },
199
+
200
+ onBlur: function () {
201
+ this.enableKillerFn();
202
+ },
203
+
204
+ setOptions: function (suppliedOptions) {
205
+ var that = this,
206
+ options = that.options;
207
+
208
+ $.extend(options, suppliedOptions);
209
+
210
+ that.isLocal = $.isArray(options.lookup);
211
+
212
+ if (that.isLocal) {
213
+ options.lookup = that.verifySuggestionsFormat(options.lookup);
214
+ }
215
+
216
+ // Adjust height, width and z-index:
217
+ $(that.suggestionsContainer).css({
218
+ 'max-height': options.maxHeight + 'px',
219
+ 'width': options.width + 'px',
220
+ 'z-index': options.zIndex
221
+ });
222
+ },
223
+
224
+ clearCache: function () {
225
+ this.cachedResponse = {};
226
+ this.badQueries = [];
227
+ },
228
+
229
+ clear: function () {
230
+ this.clearCache();
231
+ this.currentValue = '';
232
+ this.suggestions = [];
233
+ },
234
+
235
+ disable: function () {
236
+ var that = this;
237
+ that.disabled = true;
238
+ if (that.currentRequest) {
239
+ that.currentRequest.abort();
240
+ }
241
+ },
242
+
243
+ enable: function () {
244
+ this.disabled = false;
245
+ },
246
+
247
+ fixPosition: function () {
248
+ var that = this,
249
+ offset,
250
+ styles;
251
+
252
+ // Don't adjsut position if custom container has been specified:
253
+ if (that.options.appendTo !== 'body') {
254
+ return;
255
+ }
256
+
257
+ offset = that.el.offset();
258
+
259
+ styles = {
260
+ top: (offset.top + that.el.outerHeight()) + 'px',
261
+ left: offset.left + 'px'
262
+ };
263
+
264
+ if (that.options.width === 'auto') {
265
+ styles.width = (that.el.outerWidth() - 2) + 'px';
266
+ }
267
+
268
+ $(that.suggestionsContainer).css(styles);
269
+ },
270
+
271
+ enableKillerFn: function () {
272
+ var that = this;
273
+ $(document).on('click.autocomplete', that.killerFn);
274
+ },
275
+
276
+ disableKillerFn: function () {
277
+ var that = this;
278
+ $(document).off('click.autocomplete', that.killerFn);
279
+ },
280
+
281
+ killSuggestions: function () {
282
+ var that = this;
283
+ that.stopKillSuggestions();
284
+ that.intervalId = window.setInterval(function () {
285
+ that.hide();
286
+ that.stopKillSuggestions();
287
+ }, 50);
288
+ },
289
+
290
+ stopKillSuggestions: function () {
291
+ window.clearInterval(this.intervalId);
292
+ },
293
+
294
+ isCursorAtEnd: function () {
295
+ var that = this,
296
+ valLength = that.el.val().length,
297
+ selectionStart = that.element.selectionStart,
298
+ range;
299
+
300
+ if (typeof selectionStart === 'number') {
301
+ return selectionStart === valLength;
302
+ }
303
+ if (document.selection) {
304
+ range = document.selection.createRange();
305
+ range.moveStart('character', -valLength);
306
+ return valLength === range.text.length;
307
+ }
308
+ return true;
309
+ },
310
+
311
+ onKeyPress: function (e) {
312
+ var that = this;
313
+
314
+ // If suggestions are hidden and user presses arrow down, display suggestions:
315
+ if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
316
+ that.suggest();
317
+ return;
318
+ }
319
+
320
+ if (that.disabled || !that.visible) {
321
+ return;
322
+ }
323
+
324
+ switch (e.which) {
325
+ case keys.ESC:
326
+ that.el.val(that.currentValue);
327
+ that.hide();
328
+ break;
329
+ case keys.RIGHT:
330
+ if (that.hint && that.options.onHint && that.isCursorAtEnd()) {
331
+ that.selectHint();
332
+ break;
333
+ }
334
+ return;
335
+ case keys.TAB:
336
+ if (that.hint && that.options.onHint) {
337
+ that.selectHint();
338
+ return;
339
+ }
340
+ // Fall through to RETURN
341
+ case keys.RETURN:
342
+ if (that.selectedIndex === -1) {
343
+ that.hide();
344
+ return;
345
+ }
346
+ that.select(that.selectedIndex);
347
+ if (e.which === keys.TAB && that.options.tabDisabled === false) {
348
+ return;
349
+ }
350
+ break;
351
+ case keys.UP:
352
+ that.moveUp();
353
+ break;
354
+ case keys.DOWN:
355
+ that.moveDown();
356
+ break;
357
+ default:
358
+ return;
359
+ }
360
+
361
+ // Cancel event if function did not return:
362
+ e.stopImmediatePropagation();
363
+ e.preventDefault();
364
+ },
365
+
366
+ onKeyUp: function (e) {
367
+ var that = this;
368
+
369
+ if (that.disabled) {
370
+ return;
371
+ }
372
+
373
+ switch (e.which) {
374
+ case keys.UP:
375
+ case keys.DOWN:
376
+ return;
377
+ }
378
+
379
+ clearInterval(that.onChangeInterval);
380
+
381
+ if (that.currentValue !== that.el.val()) {
382
+ that.findBestHint();
383
+ if (that.options.deferRequestBy > 0) {
384
+ // Defer lookup in case when value changes very quickly:
385
+ that.onChangeInterval = setInterval(function () {
386
+ that.onValueChange();
387
+ }, that.options.deferRequestBy);
388
+ } else {
389
+ that.onValueChange();
390
+ }
391
+ }
392
+ },
393
+
394
+ onValueChange: function () {
395
+ var that = this,
396
+ options = that.options,
397
+ value = that.el.val(),
398
+ query = that.getQuery(value),
399
+ index;
400
+
401
+ if (that.selection) {
402
+ that.selection = null;
403
+ (options.onInvalidateSelection || $.noop).call(that.element);
404
+ }
405
+
406
+ clearInterval(that.onChangeInterval);
407
+ that.currentValue = value;
408
+ that.selectedIndex = -1;
409
+
410
+ // Check existing suggestion for the match before proceeding:
411
+ if (options.triggerSelectOnValidInput) {
412
+ index = that.findSuggestionIndex(query);
413
+ if (index !== -1) {
414
+ that.select(index);
415
+ return;
416
+ }
417
+ }
418
+
419
+ if (query.length < options.minChars) {
420
+ that.hide();
421
+ } else {
422
+ that.getSuggestions(query);
423
+ }
424
+ },
425
+
426
+ findSuggestionIndex: function (query) {
427
+ var that = this,
428
+ index = -1,
429
+ queryLowerCase = query.toLowerCase();
430
+
431
+ $.each(that.suggestions, function (i, suggestion) {
432
+ if (suggestion.value.toLowerCase() === queryLowerCase) {
433
+ index = i;
434
+ return false;
435
+ }
436
+ });
437
+
438
+ return index;
439
+ },
440
+
441
+ getQuery: function (value) {
442
+ var delimiter = this.options.delimiter,
443
+ parts;
444
+
445
+ if (!delimiter) {
446
+ return value;
447
+ }
448
+ parts = value.split(delimiter);
449
+ return $.trim(parts[parts.length - 1]);
450
+ },
451
+
452
+ getSuggestionsLocal: function (query) {
453
+ var that = this,
454
+ options = that.options,
455
+ queryLowerCase = query.toLowerCase(),
456
+ filter = options.lookupFilter,
457
+ limit = parseInt(options.lookupLimit, 10),
458
+ data;
459
+
460
+ data = {
461
+ suggestions: $.grep(options.lookup, function (suggestion) {
462
+ return filter(suggestion, query, queryLowerCase);
463
+ })
464
+ };
465
+
466
+ if (limit && data.suggestions.length > limit) {
467
+ data.suggestions = data.suggestions.slice(0, limit);
468
+ }
469
+
470
+ return data;
471
+ },
472
+
473
+ getSuggestions: function (q) {
474
+ var response,
475
+ that = this,
476
+ options = that.options,
477
+ serviceUrl = options.serviceUrl,
478
+ params,
479
+ cacheKey;
480
+
481
+ options.params[options.paramName] = q;
482
+ params = options.ignoreParams ? null : options.params;
483
+
484
+ if (that.isLocal) {
485
+ response = that.getSuggestionsLocal(q);
486
+ } else {
487
+ if ($.isFunction(serviceUrl)) {
488
+ serviceUrl = serviceUrl.call(that.element, q);
489
+ }
490
+ cacheKey = serviceUrl + '?' + $.param(params || {});
491
+ response = that.cachedResponse[cacheKey];
492
+ }
493
+
494
+ if (response && $.isArray(response.suggestions)) {
495
+ that.suggestions = response.suggestions;
496
+ that.suggest();
497
+ } else if (!that.isBadQuery(q)) {
498
+ if (options.onSearchStart.call(that.element, options.params) === false) {
499
+ return;
500
+ }
501
+ if (that.currentRequest) {
502
+ that.currentRequest.abort();
503
+ }
504
+ that.currentRequest = $.ajax({
505
+ url: serviceUrl,
506
+ data: params,
507
+ type: options.type,
508
+ dataType: options.dataType
509
+ }).done(function (data) {
510
+ var result;
511
+ that.currentRequest = null;
512
+ result = options.transformResult(data);
513
+ that.processResponse(result, q, cacheKey);
514
+ options.onSearchComplete.call(that.element, q, result.suggestions);
515
+ }).fail(function (jqXHR, textStatus, errorThrown) {
516
+ options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
517
+ });
518
+ }
519
+ },
520
+
521
+ isBadQuery: function (q) {
522
+ if (!this.options.preventBadQueries){
523
+ return false;
524
+ }
525
+
526
+ var badQueries = this.badQueries,
527
+ i = badQueries.length;
528
+
529
+ while (i--) {
530
+ if (q.indexOf(badQueries[i]) === 0) {
531
+ return true;
532
+ }
533
+ }
534
+
535
+ return false;
536
+ },
537
+
538
+ hide: function () {
539
+ var that = this;
540
+ that.visible = false;
541
+ that.selectedIndex = -1;
542
+ $(that.suggestionsContainer).hide();
543
+ that.signalHint(null);
544
+ },
545
+
546
+ suggest: function () {
547
+ if (this.suggestions.length === 0) {
548
+ this.options.showNoSuggestionNotice ? this.noSuggestions() : this.hide();
549
+ return;
550
+ }
551
+
552
+ var that = this,
553
+ options = that.options,
554
+ formatResult = options.formatResult,
555
+ value = that.getQuery(that.currentValue),
556
+ className = that.classes.suggestion,
557
+ classSelected = that.classes.selected,
558
+ container = $(that.suggestionsContainer),
559
+ beforeRender = options.beforeRender,
560
+ html = '',
561
+ index,
562
+ width;
563
+
564
+ if (options.triggerSelectOnValidInput) {
565
+ index = that.findSuggestionIndex(value);
566
+ if (index !== -1) {
567
+ that.select(index);
568
+ return;
569
+ }
570
+ }
571
+
572
+ // Build suggestions inner HTML:
573
+ $.each(that.suggestions, function (i, suggestion) {
574
+ html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
575
+ });
576
+
577
+ this.adjustContainerWidth();
578
+
579
+ container.html(html);
580
+
581
+ // Select first value by default:
582
+ if (options.autoSelectFirst) {
583
+ that.selectedIndex = 0;
584
+ container.children().first().addClass(classSelected);
585
+ }
586
+
587
+ if ($.isFunction(beforeRender)) {
588
+ beforeRender.call(that.element, container);
589
+ }
590
+
591
+ container.show();
592
+ that.visible = true;
593
+
594
+ that.findBestHint();
595
+ },
596
+
597
+ noSuggestions: function() {
598
+ var that = this,
599
+ container = $(that.suggestionsContainer),
600
+ html = '',
601
+ width;
602
+
603
+ html += '<div class="autocomplete-no-suggestion">' + this.options.noSuggestionNotice + '</div>';
604
+
605
+ this.adjustContainerWidth();
606
+ container.html(html);
607
+ container.show();
608
+ that.visible = true;
609
+ },
610
+
611
+ adjustContainerWidth: function() {
612
+ var that = this,
613
+ options = that.options,
614
+ width,
615
+ container = $(that.suggestionsContainer)
616
+
617
+ // If width is auto, adjust width before displaying suggestions,
618
+ // because if instance was created before input had width, it will be zero.
619
+ // Also it adjusts if input width has changed.
620
+ // -2px to account for suggestions border.
621
+ if (options.width === 'auto') {
622
+ width = that.el.outerWidth() - 2;
623
+ container.width(width > 0 ? width : 300);
624
+ }
625
+ },
626
+
627
+ findBestHint: function () {
628
+ var that = this,
629
+ value = that.el.val().toLowerCase(),
630
+ bestMatch = null;
631
+
632
+ if (!value) {
633
+ return;
634
+ }
635
+
636
+ $.each(that.suggestions, function (i, suggestion) {
637
+ var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
638
+ if (foundMatch) {
639
+ bestMatch = suggestion;
640
+ }
641
+ return !foundMatch;
642
+ });
643
+
644
+ that.signalHint(bestMatch);
645
+ },
646
+
647
+ signalHint: function (suggestion) {
648
+ var hintValue = '',
649
+ that = this;
650
+ if (suggestion) {
651
+ hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
652
+ }
653
+ if (that.hintValue !== hintValue) {
654
+ that.hintValue = hintValue;
655
+ that.hint = suggestion;
656
+ (this.options.onHint || $.noop)(hintValue);
657
+ }
658
+ },
659
+
660
+ verifySuggestionsFormat: function (suggestions) {
661
+ // If suggestions is string array, convert them to supported format:
662
+ if (suggestions.length && typeof suggestions[0] === 'string') {
663
+ return $.map(suggestions, function (value) {
664
+ return { value: value, data: null };
665
+ });
666
+ }
667
+
668
+ return suggestions;
669
+ },
670
+
671
+ processResponse: function (result, originalQuery, cacheKey) {
672
+ var that = this,
673
+ options = that.options;
674
+
675
+ result.suggestions = that.verifySuggestionsFormat(result.suggestions);
676
+
677
+ // Cache results if cache is not disabled:
678
+ if (!options.noCache) {
679
+ that.cachedResponse[cacheKey] = result;
680
+ if (options.preventBadQueries && result.suggestions.length === 0) {
681
+ that.badQueries.push(originalQuery);
682
+ }
683
+ }
684
+
685
+ // Return if originalQuery is not matching current query:
686
+ if (originalQuery !== that.getQuery(that.currentValue)) {
687
+ return;
688
+ }
689
+
690
+ that.suggestions = result.suggestions;
691
+ that.suggest();
692
+ },
693
+
694
+ activate: function (index) {
695
+ var that = this,
696
+ activeItem,
697
+ selected = that.classes.selected,
698
+ container = $(that.suggestionsContainer),
699
+ children = container.children();
700
+
701
+ container.children('.' + selected).removeClass(selected);
702
+
703
+ that.selectedIndex = index;
704
+
705
+ if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
706
+ activeItem = children.get(that.selectedIndex);
707
+ $(activeItem).addClass(selected);
708
+ return activeItem;
709
+ }
710
+
711
+ return null;
712
+ },
713
+
714
+ selectHint: function () {
715
+ var that = this,
716
+ i = $.inArray(that.hint, that.suggestions);
717
+
718
+ that.select(i);
719
+ },
720
+
721
+ select: function (i) {
722
+ var that = this;
723
+ that.hide();
724
+ that.onSelect(i);
725
+ },
726
+
727
+ moveUp: function () {
728
+ var that = this;
729
+
730
+ if (that.selectedIndex === -1) {
731
+ return;
732
+ }
733
+
734
+ if (that.selectedIndex === 0) {
735
+ $(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
736
+ that.selectedIndex = -1;
737
+ that.el.val(that.currentValue);
738
+ that.findBestHint();
739
+ return;
740
+ }
741
+
742
+ that.adjustScroll(that.selectedIndex - 1);
743
+ },
744
+
745
+ moveDown: function () {
746
+ var that = this;
747
+
748
+ if (that.selectedIndex === (that.suggestions.length - 1)) {
749
+ return;
750
+ }
751
+
752
+ that.adjustScroll(that.selectedIndex + 1);
753
+ },
754
+
755
+ adjustScroll: function (index) {
756
+ var that = this,
757
+ activeItem = that.activate(index),
758
+ offsetTop,
759
+ upperBound,
760
+ lowerBound,
761
+ heightDelta = 25;
762
+
763
+ if (!activeItem) {
764
+ return;
765
+ }
766
+
767
+ offsetTop = activeItem.offsetTop;
768
+ upperBound = $(that.suggestionsContainer).scrollTop();
769
+ lowerBound = upperBound + that.options.maxHeight - heightDelta;
770
+
771
+ if (offsetTop < upperBound) {
772
+ $(that.suggestionsContainer).scrollTop(offsetTop);
773
+ } else if (offsetTop > lowerBound) {
774
+ $(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta);
775
+ }
776
+
777
+ that.el.val(that.getValue(that.suggestions[index].value));
778
+ that.signalHint(null);
779
+ },
780
+
781
+ onSelect: function (index) {
782
+ var that = this,
783
+ onSelectCallback = that.options.onSelect,
784
+ suggestion = that.suggestions[index];
785
+
786
+ that.currentValue = that.getValue(suggestion.value);
787
+
788
+ if (that.currentValue !== that.el.val()) {
789
+ that.el.val(that.currentValue);
790
+ }
791
+
792
+ that.signalHint(null);
793
+ that.suggestions = [];
794
+ that.selection = suggestion;
795
+
796
+ if ($.isFunction(onSelectCallback)) {
797
+ onSelectCallback.call(that.element, suggestion);
798
+ }
799
+ },
800
+
801
+ getValue: function (value) {
802
+ var that = this,
803
+ delimiter = that.options.delimiter,
804
+ currentValue,
805
+ parts;
806
+
807
+ if (!delimiter) {
808
+ return value;
809
+ }
810
+
811
+ currentValue = that.currentValue;
812
+ parts = currentValue.split(delimiter);
813
+
814
+ if (parts.length === 1) {
815
+ return value;
816
+ }
817
+
818
+ return currentValue.substr(0, currentValue.length - parts[parts.length - 1].length) + value;
819
+ },
820
+
821
+ dispose: function () {
822
+ var that = this;
823
+ that.el.off('.autocomplete').removeData('autocomplete');
824
+ that.disableKillerFn();
825
+ $(window).off('resize.autocomplete', that.fixPositionCapture);
826
+ $(that.suggestionsContainer).remove();
827
+ }
828
+ };
829
+
830
+ // Create chainable jQuery plugin:
831
+ $.fn.yithautocomplete = function (options, args) {
832
+ var dataKey = 'autocomplete';
833
+ // If function invoked without argument return
834
+ // instance of the first matched element:
835
+ if (arguments.length === 0) {
836
+ return this.first().data(dataKey);
837
+ }
838
+
839
+ return this.each(function () {
840
+ var inputElement = $(this),
841
+ instance = inputElement.data(dataKey);
842
+
843
+ if (typeof options === 'string') {
844
+ if (instance && typeof instance[options] === 'function') {
845
+ instance[options](args);
846
+ }
847
+ } else {
848
+ // If instance already exists, destroy it:
849
+ if (instance && instance.dispose) {
850
+ instance.dispose();
851
+ }
852
+ instance = new YithAutocomplete(this, options);
853
+ inputElement.data(dataKey, instance);
854
+ }
855
+ });
856
+ };
857
+ }));
assets/js/yith-autocomplete.min.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.YithAutocomplete=g;g.formatResult=function(a,
4
+ b){var c="("+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.yithautocomplete=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-frontend.php CHANGED
@@ -47,14 +47,20 @@ if( !class_exists( 'YITH_WCAS_Frontend' ) ) {
47
  */
48
  public function enqueue_styles_scripts() {
49
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
- wp_register_script('yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
51
- wp_register_script('yith_wcas_frontend', YITH_WCAS_URL . 'assets/js/frontend' . $suffix .'.js', array('jquery'), '1.0', true);
 
 
52
 
53
  $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
54
  wp_enqueue_style( 'yith_wcas_frontend', $css );
 
55
  wp_localize_script( 'yith_wcas_frontend', 'yith_wcas_params', array(
56
  'loading' => YITH_WCAS_ASSETS_IMAGES_URL.'ajax-loader.gif'
57
  ));
 
 
 
58
  }
59
  }
60
  }
47
  */
48
  public function enqueue_styles_scripts() {
49
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
+ wp_register_script('yith_autocomplete', YITH_WCAS_URL . 'assets/js/yith-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
51
+ wp_register_script('yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
52
+
53
+ wp_register_script('yith_wcas_frontend', YITH_WCAS_URL . 'assets/js/frontend' . $suffix .'.js', array('jquery'), '1.0', true);
54
 
55
  $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
56
  wp_enqueue_style( 'yith_wcas_frontend', $css );
57
+
58
  wp_localize_script( 'yith_wcas_frontend', 'yith_wcas_params', array(
59
  'loading' => YITH_WCAS_ASSETS_IMAGES_URL.'ajax-loader.gif'
60
  ));
61
+
62
+ wp_enqueue_script('yith_autocomplete' );
63
+
64
  }
65
  }
66
  }
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.3.1
7
  * Author: Yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
@@ -59,7 +59,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
59
  if ( defined( 'YITH_WCAS_VERSION' ) ){
60
  return;
61
  }else{
62
- define( 'YITH_WCAS_VERSION', '1.3.1' );
63
  }
64
 
65
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
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.3.2
7
  * Author: Yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
59
  if ( defined( 'YITH_WCAS_VERSION' ) ){
60
  return;
61
  }else{
62
+ define( 'YITH_WCAS_VERSION', '1.3.2' );
63
  }
64
 
65
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
plugin-fw/assets/js/chosen/ajax-chosen.jquery.min.js CHANGED
@@ -1,2 +1,3 @@
1
- // Generated by CoffeeScript 1.3.1
2
- (function(e){return e.fn.ajaxChosen=function(t,n){var r,i,s,o;t==null&&(t={});n==null&&(n=function(){});i={minTermLength:3,afterTypeDelay:500,jsonTermKey:"term"};o=this;r=null;s=e.extend({},i,t);this.chosen();return this.each(function(){return e(this).next(".chosen-container").find(".search-field > input, .chosen-search > input").bind("keyup",function(){var t,i,u,a;a=e.trim(e(this).attr("value"));i=a.length<s.minTermLength?"Keep typing...":"Looking for '"+a+"'";o.next(".chosen-container").find(".no-results").text(i);if(a===e(this).data("prevVal"))return!1;e(this).data("prevVal",a);this.timer&&clearTimeout(this.timer);if(a.length<s.minTermLength)return!1;t=e(this);s.data==null&&(s.data={});s.data[s.jsonTermKey]=a;s.dataCallback!=null&&(s.data=s.dataCallback(s.data));u=s.success;s.success=function(r){var i,s;if(r==null)return;s=[];o.find("option").each(function(){return e(this).is(":selected")?s.push(e(this).val()+"-"+e(this).text()):e(this).remove()});i=n(r);e.each(i,function(t,n){if(e.inArray(t+"-"+n,s)===-1)return e("<option />").attr("value",t).html(n).appendTo(o)});o.trigger("chosen:updated");u!=null&&u(r);t.attr("value",a);return t.css("width","auto")};return this.timer=setTimeout(function(){r&&r.abort();return r=e.ajax(s)},s.afterTypeDelay)})})}})(jQuery);
 
1
+ (function(b){return b.fn.ajaxChosen=function(d,g){var e,a,f;null==d&&(d={});null==g&&(g=function(){});f=this;e=null;a=b.extend({},{minTermLength:3,afterTypeDelay:500,jsonTermKey:"term"},d);this.chosen();return this.each(function(){return b(this).next(".chosen-container").find(".search-field > input, .chosen-search > input").bind("keyup",function(){var d,l,h,c;c=b.trim(b(this).attr("value"));l=c.length<a.minTermLength?"Keep typing...":"Looking for '"+c+"'";f.next(".chosen-container").find(".no-results").text(l);
2
+ if(c===b(this).data("prevVal"))return!1;b(this).data("prevVal",c);this.timer&&clearTimeout(this.timer);if(c.length<a.minTermLength)return!1;d=b(this);null==a.data&&(a.data={});a.data[a.jsonTermKey]=c;null!=a.dataCallback&&(a.data=a.dataCallback(a.data));h=a.success;a.success=function(a){var e,k;if(null!=a)return k=[],f.find("option").each(function(){return b(this).is(":selected")?k.push(b(this).val()+"-"+b(this).text()):b(this).remove()}),e=g(a),b.each(e,function(a,c){if(-1===b.inArray(a+"-"+c,k))return b("<option />").attr("value",
3
+ a).html(c).appendTo(f)}),f.trigger("chosen:updated"),null!=h&&h(a),d.attr("value",c),d.css("width","auto")};return this.timer=setTimeout(function(){e&&e.abort();return e=b.ajax(a)},a.afterTypeDelay)})})}})(jQuery);
plugin-fw/assets/js/metabox.min.js CHANGED
@@ -1,6 +1,6 @@
1
  (function(a){function k(b,c,d){var e=!0;if("string"==typeof c){":radio"==c.substr(0,6)&&(c+=":checked");var g=a(c).val();"checkbox"==a(c).attr("type")&&(g=a(c).is(":checked")?"yes":"no");d=d.split(",");for(c=0;c<d.length;c++)if(g!=d[c])e=!1;else{e=!0;break}}e?a(b+"-container").parent().show():a(b+"-container").parent().hide()}a(".metaboxes-tab").each(function(){a(".tabs-panel",this).hide();var b=wpCookies.get("active_metabox_tab"),b=null==b?a("ul.metaboxes-tabs li:first-child a",this).attr("href"):
2
- "#"+b;a(b).show();a(".metaboxes-tabs a",this).click(function(b){if(a(this).parent().hasClass("tabs"))b.preventDefault();else return b=a(this).attr("href"),a(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),a(this).closest(".metaboxes-tab").find(".tabs-panel").slideUp("fast"),a(b).delay(350).slideDown("fast"),!1})});var h=!0,l=wp.media.editor.send.attachment;a(document).on("click",".metaboxes-tab .upload_button",function(b){b=a(this);var c=b.attr("id").replace("-button","");h=!0;
3
- wp.media.editor.send.attachment=function(b,e){if(h)a("#"+c).is("input[type=text]")?a("#"+c).val(e.url):a("#"+c+"_custom").val(e.url);else return l.apply(this,[b,e])};wp.media.editor.open(b);return!1});a(".metaboxes-tab .add_media").on("click",function(){h=!1});a(".metaboxes-tab .panel-colorpicker").wpColorPicker({onInit:function(){console.log("test")},change:function(a,c){},clear:function(){var b=a(this);b.val(b.data("default-color"));b.change()}});a(".metaboxes-tab .panel-colorpicker").each(function(){var b=
4
  a(this).data("variations-label");a(this).parent().parent().find("a.wp-color-result").attr("title",b)});a(".metaboxes-tab .panel-datepicker").each(function(){a(this).datepicker()});var f=function(){var b="";a(this).attr("multiple")?(a(this).children("option:selected").each(function(c,d){0!=c&&(b+=", ");b+=a(d).text()}),""==b&&a(this).children().children("option:selected").each(function(c,d){0!=c&&(b+=", ");b+=a(d).text()})):(b=a(this).children("option:selected").text(),""==b&&(b=a(this).children().children("option:selected").text()));
5
  0>=a(this).parent().find("span").length&&a(this).before("<span></span>");a(this).parent().children("span").replaceWith("<span>"+b+"</span>")};a(".metaboxes-tab .select_wrapper select").not(".chosen").each(f).change(f);a(".metaboxes-tab .select_wrapper").click(function(b){b.stopPropagation();a(this).find("select[multiple]").not(".chosen").toggle()});a(".metaboxes-tab .select_wrapper select[multiple]").not(".chosen").click(function(a){a.stopPropagation()});a(window).click(function(){a(".metaboxes-tab .select_wrapper select[multiple]").not(".chosen").hide()});
6
  a(".metaboxes-tab .onoff_container span").on("click",function(){var b=a(this).prev("input");b.prop("checked")?b.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):b.prop("checked",!0).attr("value","yes").addClass("onoffchecked");b.change()});a(".metaboxes-tab .chosen .select_wrapper select").chosen();a(".metaboxes-tab .slider_container .ui-slider-horizontal").each(function(){var b=a(this).data("val"),c=a(this).data("min"),d=a(this).data("max"),e=a(this).data("step"),g=a(this).data("labels");
1
  (function(a){function k(b,c,d){var e=!0;if("string"==typeof c){":radio"==c.substr(0,6)&&(c+=":checked");var g=a(c).val();"checkbox"==a(c).attr("type")&&(g=a(c).is(":checked")?"yes":"no");d=d.split(",");for(c=0;c<d.length;c++)if(g!=d[c])e=!1;else{e=!0;break}}e?a(b+"-container").parent().show():a(b+"-container").parent().hide()}a(".metaboxes-tab").each(function(){a(".tabs-panel",this).hide();var b=wpCookies.get("active_metabox_tab"),b=null==b?a("ul.metaboxes-tabs li:first-child a",this).attr("href"):
2
+ "#"+b;a(b).show();a(".metaboxes-tabs a",this).click(function(b){if(a(this).parent().hasClass("tabs"))b.preventDefault();else return b=a(this).attr("href"),a(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),a(this).closest(".metaboxes-tab").find(".tabs-panel").slideUp("fast"),a(b).delay(350).slideDown("fast"),!1})});var h=!0,l=wp.media.editor.send.attachment;a(document).on("click",".metaboxes-tab .upload_button",function(b){b=a(this);if("undefined"!=typeof b.attr("id")){var c=b.attr("id").replace("-button",
3
+ "");h=!0;wp.media.editor.send.attachment=function(b,e){if(h)a("#"+c).is("input[type=text]")?a("#"+c).val(e.url):a("#"+c+"_custom").val(e.url);else return l.apply(this,[b,e])};wp.media.editor.open(b);return!1}});a(".metaboxes-tab .add_media").on("click",function(){h=!1});a(".metaboxes-tab .panel-colorpicker").wpColorPicker({onInit:function(){console.log("test")},change:function(a,c){},clear:function(){var b=a(this);b.val(b.data("default-color"));b.change()}});a(".metaboxes-tab .panel-colorpicker").each(function(){var b=
4
  a(this).data("variations-label");a(this).parent().parent().find("a.wp-color-result").attr("title",b)});a(".metaboxes-tab .panel-datepicker").each(function(){a(this).datepicker()});var f=function(){var b="";a(this).attr("multiple")?(a(this).children("option:selected").each(function(c,d){0!=c&&(b+=", ");b+=a(d).text()}),""==b&&a(this).children().children("option:selected").each(function(c,d){0!=c&&(b+=", ");b+=a(d).text()})):(b=a(this).children("option:selected").text(),""==b&&(b=a(this).children().children("option:selected").text()));
5
  0>=a(this).parent().find("span").length&&a(this).before("<span></span>");a(this).parent().children("span").replaceWith("<span>"+b+"</span>")};a(".metaboxes-tab .select_wrapper select").not(".chosen").each(f).change(f);a(".metaboxes-tab .select_wrapper").click(function(b){b.stopPropagation();a(this).find("select[multiple]").not(".chosen").toggle()});a(".metaboxes-tab .select_wrapper select[multiple]").not(".chosen").click(function(a){a.stopPropagation()});a(window).click(function(){a(".metaboxes-tab .select_wrapper select[multiple]").not(".chosen").hide()});
6
  a(".metaboxes-tab .onoff_container span").on("click",function(){var b=a(this).prev("input");b.prop("checked")?b.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):b.prop("checked",!0).attr("value","yes").addClass("onoffchecked");b.change()});a(".metaboxes-tab .chosen .select_wrapper select").chosen();a(".metaboxes-tab .slider_container .ui-slider-horizontal").each(function(){var b=a(this).data("val"),c=a(this).data("min"),d=a(this).data("max"),e=a(this).data("step"),g=a(this).data("labels");
plugin-fw/assets/js/multisite-updater.min.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(m){function n(c,d,k){this.php_js=this.php_js||{};this.php_js.ENV=this.php_js.ENV||{};var a=0,e=0,b=0,f={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},a=function(a){a=(""+a).replace(/[_\-+]/g,".");a=a.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,".");return a.length?a.split("."):[-8]};numVersion=function(a){return a?isNaN(a)?f[a]||-7:parseInt(a,10):0};c=a(c);d=a(d);e=Math.max(c.length,d.length);for(a=0;a<e;a++)if(c[a]!=d[a])if(c[a]=numVersion(c[a]),d[a]=numVersion(d[a]),
2
- c[a]<d[a]){b=-1;break}else if(c[a]>d[a]){b=1;break}if(!k)return b;switch(k){case ">":case "gt":return 0<b;case ">=":case "ge":return 0<=b;case "<=":case "le":return 0>=b;case "==":case "=":case "eq":return 0===b;case "<>":case "!=":case "ne":return 0!==b;case "":case "<":case "lt":return 0>b;default:return null}}var l=m("#menu-plugins"),g=l.find(".update-plugins").find(".update-count").text(),p=plugins.registered,q=plugins.activated;if(0==g||""==g)g=0,l.find(".wp-menu-name").append('<span class="update-plugins"><span class="plugin-count"></span></span>');
3
- (function(c,d,k,a){for(var e in c){var b=c[e],f;for(f in b)if("slug"!=f&&!n(b[f].Version,b[f].Latest,">=")){k=parseInt(k)+1;m(".plugin-count").empty().html(k);var g=""+b[f].Name,l="#"+g.replace(RegExp(" ","g"),"-").trim().toLowerCase();m(l).addClass("update");var h='<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">'+a.strings.new_version.replace("%plugin_name%",g)+'<a class="thickbox" href="'+a.details_url[e]+'">'+a.strings.latest.replace("%latest%",
4
- b[f].Latest)+"</a>",h="undefined"==typeof d[e]?h+" <em>"+a.strings.unavailable+"</em>"+a.strings.activate.replace("%activate_link%",a.licence_activation_url).replace("%plugin_name%",g):h+'. <a href="'+a.update_url[e]+'">'+a.strings.update_now+"</a>";"undefined"!=typeof a.changelogs[e]&&(h+=a.changelogs[e]);h+="</div></td></tr>";m(h).insertAfter(l)}}})(p,q,g,plugins)})(jQuery);
1
+ (function(m){function n(c,d,k){this.php_js=this.php_js||{};this.php_js.ENV=this.php_js.ENV||{};var a=0,e=0,b=0,f={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},a=function(a){a=(""+a).replace(/[_\-+]/g,".");a=a.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,".");return a.length?a.split("."):[-8]};numVersion=function(a){return a?isNaN(a)?f[a]||-7:parseInt(a,10):0};c=a(c);d=a(d);e=Math.max(c.length,d.length);for(a=0;a<e;a++)if(c[a]!=d[a])if(c[a]=numVersion(c[a]),d[a]=numVersion(d[a]),
2
+ c[a]<d[a]){b=-1;break}else if(c[a]>d[a]){b=1;break}if(!k)return b;switch(k){case ">":case "gt":return 0<b;case ">=":case "ge":return 0<=b;case "<=":case "le":return 0>=b;case "==":case "=":case "eq":return 0===b;case "<>":case "!=":case "ne":return 0!==b;case "":case "<":case "lt":return 0>b;default:return null}}var l=m("#menu-plugins"),g=l.find(".update-plugins").find(".update-count").text(),p=plugins.registered,q=plugins.activated;if(0==g||""==g)g=0,l.find(".wp-menu-name").append('<span class="update-plugins"><span class="plugin-count"></span></span>');
3
+ (function(c,d,k,a){for(var e in c){var b=c[e],f;for(f in b)if("slug"!=f&&!n(b[f].Version,b[f].Latest,">=")){k=parseInt(k)+1;m(".plugin-count").empty().html(k);var g=""+b[f].Name,l="#"+g.replace(RegExp(" ","g"),"-").trim().toLowerCase();m(l).addClass("update");var h='<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">'+a.strings.new_version.replace("%plugin_name%",g)+'<a class="thickbox" href="'+a.details_url[e]+'">'+a.strings.latest.replace("%latest%",
4
+ b[f].Latest)+"</a>",h="undefined"==typeof d[e]?h+" <em>"+a.strings.unavailable+"</em>"+a.strings.activate.replace("%activate_link%",a.licence_activation_url).replace("%plugin_name%",g):h+'. <a href="'+a.update_url[e]+'">'+a.strings.update_now+"</a>";"undefined"!=typeof a.changelogs[e]&&(h+=a.changelogs[e]);h+="</div></td></tr>";m(h).insertAfter(l)}}})(p,q,g,plugins)})(jQuery);
plugin-fw/assets/js/yit-plugin-panel.min.js CHANGED
@@ -7,4 +7,4 @@ function(){});a("[data-field]").each(function(){var b=a(this),c="#"+b.data("fiel
7
  b.sortable({connectWith:b,update:function(d,e){var f={};b.each(function(){var b={};a(this).children().each(function(){b[a(this).data("option")]=a(this).text()});f[a(this).data("list")]=b});c.val(JSON.stringify(f).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()});a(document).ready(function(){a(".yith-video-link").click(function(b){b.preventDefault();b=a(this).data("video-id");a("."+b).dialog({dialogClass:"wp-dialog yit-dialog yit-video-dialog",modal:!0,closeOnEscape:!0,width:"auto",
8
  resizable:!1,draggable:!1,create:function(b,d){a(this).css("maxWidth","853px")},open:function(b,d){a(".ui-widget-overlay").bind("click",function(){a(this).siblings(".ui-dialog").find(".ui-dialog-content").dialog("close")})}});a(".ui-dialog :button").blur()})});a(document).ready(function(){a(".codemirror").each(function(b,c){var d=CodeMirror.fromTextArea(c,{lineNumbers:1,mode:"javascript",showCursorWhenSelecting:!0});a(c).data("codemirrorInstance",d)})});a(document).ready(function(){a(".google-analytic-generate").click(function(){var b=
9
  a("#"+a(this).data("textarea")).data("codemirrorInstance"),c=a("#"+a(this).data("input")).val(),d=a(this).data("basename"),e;e="(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n";e+="})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n";e+="ga('create', '"+c+"', '"+d+"');\n";e+="ga('send', 'pageview');\n";
10
- b.replaceRange(e,b.getCursor("start"),b.getCursor("end"))})})})(jQuery);
7
  b.sortable({connectWith:b,update:function(d,e){var f={};b.each(function(){var b={};a(this).children().each(function(){b[a(this).data("option")]=a(this).text()});f[a(this).data("list")]=b});c.val(JSON.stringify(f).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()});a(document).ready(function(){a(".yith-video-link").click(function(b){b.preventDefault();b=a(this).data("video-id");a("."+b).dialog({dialogClass:"wp-dialog yit-dialog yit-video-dialog",modal:!0,closeOnEscape:!0,width:"auto",
8
  resizable:!1,draggable:!1,create:function(b,d){a(this).css("maxWidth","853px")},open:function(b,d){a(".ui-widget-overlay").bind("click",function(){a(this).siblings(".ui-dialog").find(".ui-dialog-content").dialog("close")})}});a(".ui-dialog :button").blur()})});a(document).ready(function(){a(".codemirror").each(function(b,c){var d=CodeMirror.fromTextArea(c,{lineNumbers:1,mode:"javascript",showCursorWhenSelecting:!0});a(c).data("codemirrorInstance",d)})});a(document).ready(function(){a(".google-analytic-generate").click(function(){var b=
9
  a("#"+a(this).data("textarea")).data("codemirrorInstance"),c=a("#"+a(this).data("input")).val(),d=a(this).data("basename"),e;e="(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n";e+="})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n";e+="ga('create', '"+c+"', '"+d+"');\n";e+="ga('send', 'pageview');\n";
10
+ b.replaceRange(e,b.getCursor("start"),b.getCursor("end"))})})})(jQuery);
plugin-fw/assets/js/yit-wp-pointer.min.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready(function(b){var c=custom_pointer.pointers[0],d=c.options,a=b(c.target),e=c.pointer_id;b(a).find(".wp-submenu li a").each(function(){var f=b(this),h=f.attr("href"),h=h.replace("admin.php?page=","");if(h==e){var k=f.add(a),g=a.find(c.target.replace("#","."));a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");f.pointer({pointerClass:"yit-wp-pointer",content:d.content,position:d.position,open:function(){console.log("here");k.toggleClass("yit-pointer-selected-row");
2
- g.addClass("yit-pointer")},close:function(){a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");k.toggleClass("yit-pointer-selected-row");g.removeClass("yit-pointer");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}else if("yith_default_pointer"==e){var k=f.add(a),g=a.find(c.target.replace("#",".")),l=b(c.target);l.addClass("wp-has-current-submenu");g.pointer({pointerClass:"yit-wp-pointer",content:d.content,
3
- position:d.position,open:function(){l.addClass("yit-pointer-selected-row")},close:function(){l.removeClass("yit-pointer-selected-row wp-has-current-submenu");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}})});
1
+ jQuery(document).ready(function(b){var c=custom_pointer.pointers[0],d=c.options,a=b(c.target),e=c.pointer_id;b(a).find(".wp-submenu li a").each(function(){var f=b(this),h=f.attr("href"),h=h.replace("admin.php?page=","");if(h==e){var k=f.add(a),g=a.find(c.target.replace("#","."));a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");f.pointer({pointerClass:"yit-wp-pointer",content:d.content,position:d.position,open:function(){k.toggleClass("yit-pointer-selected-row");g.addClass("yit-pointer")},
2
+ close:function(){a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");k.toggleClass("yit-pointer-selected-row");g.removeClass("yit-pointer");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}else if("yith_default_pointer"==e){var k=f.add(a),g=a.find(c.target.replace("#",".")),l=b(c.target);l.addClass("wp-has-current-submenu");g.pointer({pointerClass:"yit-wp-pointer",content:d.content,position:d.position,open:function(){l.addClass("yit-pointer-selected-row")},
3
+ close:function(){l.removeClass("yit-pointer-selected-row wp-has-current-submenu");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}})});
plugin-fw/licence/assets/js/yit-licence.min.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(b){var g=function(d){d.on("click",function(u,d){u.preventDefault();var e=b(this),a=e.data("formid"),c=b("#"+a),f=c.serialize(),h=b(c).find(".message"),l=b(c).find(".message-wrapper"),r=c.find(".user-email"),t=c.find(".licence-key"),g=c.find(".user-email").val(),q=c.find(".licence-key").val(),m=!1,a=[],n=c.find(".product-row"),p=b("h3.to-active").find(".spinner");h.empty();l.removeClass("visible");r.removeClass("require");t.removeClass("require");n.removeClass("error");p.addClass("show");
2
- e.prop("disabled",!0).addClass("clicked");""==g&&(m=!0,a[a.length]="Email",r.addClass("require"));""==q&&(m=!0,a[a.length]="Licence Key",t.addClass("require"));if(0==m)jQuery.ajax({type:"POST",url:ajaxurl,data:f,success:function(a){p.removeClass("show");e.prop("disabled",!1).removeClass("clicked");1==a.activated?(b(".product-licence-activation").empty().replaceWith(a.template),k()):(0!=a?h.text(a.error):h.text(licence_message.server),l.addClass("visible"),n.addClass("error"))}});else{if(1==a.length)h.text(licence_message.error.replace("%field%",
3
- a[0]));else{c=licence_message.errors;for(f=0;f<a.length;f++)c=c.replace("%field_"+(f+1)+"%",a[f]),l.addClass("visible");h.text(c)}l.addClass("visible");n.addClass("error");p.removeClass("show");e.prop("disabled",!1).removeClass("clicked")}})},q=function(d){d.on("click",function(d){d.preventDefault();d=b(this);var g=b("#licence-check-update"),e=g.serialize();d.prop("disabled",!0).addClass("clicked");g.find("div.spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(a){b(".product-licence-activation").empty().replaceWith(a.template);
4
- k()}})})},k=function(){var d=b(".licence-activation"),k=b(".licence-check");g(d);q(k)};k();b("body").on("click",".yit-changelog-button",function(d){b("#TB_window").remove()})})(jQuery);
1
+ (function(b){var g=function(d){d.on("click",function(u,d){u.preventDefault();var e=b(this),a=e.data("formid"),c=b("#"+a),f=c.serialize(),h=b(c).find(".message"),l=b(c).find(".message-wrapper"),r=c.find(".user-email"),t=c.find(".licence-key"),g=c.find(".user-email").val(),q=c.find(".licence-key").val(),m=!1,a=[],n=c.find(".product-row"),p=b("h3.to-active").find(".spinner");h.empty();l.removeClass("visible");r.removeClass("require");t.removeClass("require");n.removeClass("error");p.addClass("show");
2
+ e.prop("disabled",!0).addClass("clicked");""==g&&(m=!0,a[a.length]="Email",r.addClass("require"));""==q&&(m=!0,a[a.length]="Licence Key",t.addClass("require"));if(0==m)jQuery.ajax({type:"POST",url:ajaxurl,data:f,success:function(a){p.removeClass("show");e.prop("disabled",!1).removeClass("clicked");1==a.activated?(b(".product-licence-activation").empty().replaceWith(a.template),k()):(0!=a?h.text(a.error):h.text(licence_message.server),l.addClass("visible"),n.addClass("error"))}});else{if(1==a.length)h.text(licence_message.error.replace("%field%",
3
+ a[0]));else{c=licence_message.errors;for(f=0;f<a.length;f++)c=c.replace("%field_"+(f+1)+"%",a[f]),l.addClass("visible");h.text(c)}l.addClass("visible");n.addClass("error");p.removeClass("show");e.prop("disabled",!1).removeClass("clicked")}})},q=function(d){d.on("click",function(d){d.preventDefault();d=b(this);var g=b("#licence-check-update"),e=g.serialize();d.prop("disabled",!0).addClass("clicked");g.find("div.spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(a){b(".product-licence-activation").empty().replaceWith(a.template);
4
+ k()}})})},k=function(){var d=b(".licence-activation"),k=b(".licence-check");g(d);q(k)};k();b("body").on("click",".yit-changelog-button",function(d){b("#TB_window").remove()})})(jQuery);
templates/yith-woocommerce-ajax-search.php CHANGED
@@ -8,8 +8,6 @@
8
  */
9
 
10
  if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
-
12
- wp_enqueue_script('yith_wcas_jquery-autocomplete' );
13
  wp_enqueue_script('yith_wcas_frontend' );
14
 
15
  ?>
8
  */
9
 
10
  if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
 
 
11
  wp_enqueue_script('yith_wcas_frontend' );
12
 
13
  ?>