Ajax Search for WooCommerce - Version 0.9.1

Version Description

Download this release

Release Info

Developer damian-gora
Plugin Icon 128x128 Ajax Search for WooCommerce
Version 0.9.1
Comparing to
See all releases

Code changes from version 0.9 to 0.9.1

ajax-search-for-woocommerce.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Ajax Search for WooCommerce
5
  * Plugin URI: https://wordpress.org/plugins/ajax-search-for-woocommerce/
6
  * Description: The plugin allows you to display the WooCommerce AJAX search form anywhere on the page.
7
- * Version: 0.9
8
  * Author: Damian Góra
9
  * Author URI: http://damiangora.com
10
  * Text Domain: ajax-search-for-woocommerce
@@ -58,7 +58,7 @@ if ( !class_exists( 'DGWT_WC_Ajax_Search' ) ) {
58
  */
59
  private function constants() {
60
 
61
- $this->define( 'DGWT_WCAS_VERSION', '0.9' );
62
  $this->define( 'DGWT_WCAS_NAME', 'Ajax Search for WooCommerce' );
63
  $this->define( 'DGWT_WCAS_FILE', __FILE__ );
64
  $this->define( 'DGWT_WCAS_DIR', plugin_dir_path( __FILE__ ) );
4
  * Plugin Name: Ajax Search for WooCommerce
5
  * Plugin URI: https://wordpress.org/plugins/ajax-search-for-woocommerce/
6
  * Description: The plugin allows you to display the WooCommerce AJAX search form anywhere on the page.
7
+ * Version: 0.9.1
8
  * Author: Damian Góra
9
  * Author URI: http://damiangora.com
10
  * Text Domain: ajax-search-for-woocommerce
58
  */
59
  private function constants() {
60
 
61
+ $this->define( 'DGWT_WCAS_VERSION', '0.9.1' );
62
  $this->define( 'DGWT_WCAS_NAME', 'Ajax Search for WooCommerce' );
63
  $this->define( 'DGWT_WCAS_FILE', __FILE__ );
64
  $this->define( 'DGWT_WCAS_DIR', plugin_dir_path( __FILE__ ) );
assets/js/jquery.dgwt-wcas.js CHANGED
@@ -314,8 +314,8 @@
314
  }
315
 
316
  that.options.onSearchComplete = function () {
317
- that.preloader( 'hide', $( '.' + options.preloaderClass ), 'dgwt-wcas-inner-preloader', dgwt_wcas.preloader_url, true );
318
- that.preloader( 'show', $( '.' + options.preloaderClass ), options.closeTrigger, '', true );
319
  };
320
 
321
 
@@ -699,7 +699,7 @@
699
  options.params[options.paramName] = q;
700
  params = options.ignoreParams ? null : options.params;
701
 
702
- that.preloader( 'show', $( '.' + options.preloaderClass ), 'dgwt-wcas-inner-preloader', dgwt_wcas.preloader_url, true );
703
 
704
  if ( options.onSearchStart.call( that.element, options.params ) === false ) {
705
  return;
@@ -804,7 +804,7 @@
804
  } else {
805
 
806
  containerDetails.html( '' );
807
- that.preloader( 'show', containerDetails, '', dgwt_wcas.preloader_url );
808
 
809
  $.ajax( {
810
  data: data,
@@ -817,7 +817,7 @@
817
  // Cached response
818
  that.cachedDetails[cacheKey] = result;
819
 
820
- that.preloader( 'hide', containerDetails, '', dgwt_wcas.preloader_url );
821
 
822
  if ( result.details != null ) {
823
  containerDetails.html( result.details );
@@ -830,7 +830,7 @@
830
  },
831
  error: function ( jqXHR, exception ) {
832
 
833
- that.preloader( 'hide', containerDetails, '', dgwt_wcas.preloader_url );
834
 
835
  containerDetails.html( jqXHR );
836
  that.fixPositionDetailsBox();
@@ -1109,10 +1109,9 @@
1109
  * @param action (show or hide)
1110
  * @param container (parent selector)
1111
  * @param cssClass
1112
- * @param customImage absolyt path to te prelader custom image
1113
- * @param viaClass bool
1114
  */
1115
- preloader: function ( action, container, cssClass, customImage, viaClass ) {
1116
 
1117
  var html,
1118
  defaultClass = 'dgwt-wcas-preloader-wrapp',
@@ -1124,7 +1123,7 @@
1124
  return;
1125
  }
1126
 
1127
- if ( customImage == '' && viaClass === true ) {
1128
  if ( action === 'hide' ) {
1129
  container.removeClass( cssClass );
1130
  } else {
@@ -1141,11 +1140,7 @@
1141
 
1142
  // Action show
1143
  if ( action === 'show' ) {
1144
- if ( customImage != '' ) {
1145
- html = '<div class="' + cssClasses + '"><img src="' + customImage + '" /></div>';
1146
- } else {
1147
- html = '<div class="' + cssClasses + '"><div class="dgwt-wcas-default-preloader"></div></div>';
1148
- }
1149
 
1150
  container.html( html );
1151
  }
314
  }
315
 
316
  that.options.onSearchComplete = function () {
317
+ that.preloader( 'hide', $( '.' + options.preloaderClass ), 'dgwt-wcas-inner-preloader');
318
+ that.preloader( 'show', $( '.' + options.preloaderClass ), options.closeTrigger);
319
  };
320
 
321
 
699
  options.params[options.paramName] = q;
700
  params = options.ignoreParams ? null : options.params;
701
 
702
+ that.preloader( 'show', $( '.' + options.preloaderClass ), 'dgwt-wcas-inner-preloader');
703
 
704
  if ( options.onSearchStart.call( that.element, options.params ) === false ) {
705
  return;
804
  } else {
805
 
806
  containerDetails.html( '' );
807
+ that.preloader( 'show', containerDetails, '', true);
808
 
809
  $.ajax( {
810
  data: data,
817
  // Cached response
818
  that.cachedDetails[cacheKey] = result;
819
 
820
+ that.preloader( 'hide', containerDetails, '', true);
821
 
822
  if ( result.details != null ) {
823
  containerDetails.html( result.details );
830
  },
831
  error: function ( jqXHR, exception ) {
832
 
833
+ that.preloader( 'hide', containerDetails, '', true);
834
 
835
  containerDetails.html( jqXHR );
836
  that.fixPositionDetailsBox();
1109
  * @param action (show or hide)
1110
  * @param container (parent selector)
1111
  * @param cssClass
1112
+ * @param detailsBox bool
 
1113
  */
1114
+ preloader: function ( action, container, cssClass, detailsBox ) {
1115
 
1116
  var html,
1117
  defaultClass = 'dgwt-wcas-preloader-wrapp',
1123
  return;
1124
  }
1125
 
1126
+ if ( detailsBox !== true ) {
1127
  if ( action === 'hide' ) {
1128
  container.removeClass( cssClass );
1129
  } else {
1140
 
1141
  // Action show
1142
  if ( action === 'show' ) {
1143
+ html = '<div class="' + cssClasses + '"><div class="dgwt-wcas-default-preloader"></div></div>';
 
 
 
 
1144
 
1145
  container.html( html );
1146
  }
assets/js/jquery.dgwt-wcas.min.js CHANGED
@@ -1 +1,10 @@
1
- !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(e){"use strict";function t(s,n){var i=function(){},o=this,a={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,onMouseOver:null,onMouseLeave:null,width:"auto",containerDetailsWidth:"auto",showDetailsPanel:!1,showImage:!1,showPrice:!1,showDescription:!1,showSaleBadge:!1,showFeaturedBadge:!1,saleBadgeText:"sale",featuredBadgeText:"featured",minChars:1,maxHeight:1e3,deferRequestBy:0,params:{},formatResult:t.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,is_rtl:!1,onSearchStart:i,onSearchComplete:i,onSearchError:i,preserveInput:!1,wrapperaClass:"dgwt-wcas-search-wrapp",containerClass:"dgwt-wcas-suggestions-wrapp",containerDetailsClass:"dgwt-wcas-details-wrapp",cointainerDetailsPos:"right",preloaderClass:"dgwt-wcas-preloader",closeTrigger:"dgwt-wcas-close",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(e,t,s){return-1!==e.value.toLowerCase().indexOf(s)},paramName:"query",transformResult:function(t){return"string"==typeof t?e.parseJSON(t):t},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1};o.element=s,o.el=e(s),o.suggestions=[],o.badQueries=[],o.selectedIndex=-1,o.currentValue=o.element.value,o.intervalId=0,o.cachedResponse={},o.cachedDetails={},o.onChangeInterval=null,o.onChange=null,o.isLocal=!1,o.suggestionsContainer=null,o.detailsContainer=null,o.noSuggestionsContainer=null,o.options=e.extend({},a,n),o.classes={selected:"dgwt-wcas-suggestion-selected",suggestion:"dgwt-wcas-suggestion"},o.hint=null,o.hintValue="",o.selection=null,o.initialize(),o.setOptions(n)}var s=function(){return{escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.position="absolute",t.style.display="none",t}}}(),n={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40};t.utils=s,e.Autocomplete=t,t.formatResult=function(e,t){var n="("+s.escapeRegExChars(t)+")";return e.value.replace(new RegExp(n,"gi"),"<strong>$1</strong>").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/&lt;(\/?strong)&gt;/g,"<$1>")},t.prototype={killerFn:null,initialize:function(){var s,n,i=this,o="."+i.classes.suggestion,a=(i.classes.selected,i.options),l="."+a.closeTrigger;i.element.setAttribute("autocomplete","off"),i.killerFn=function(t){0===e(t.target).closest("."+i.options.containerClass).length&&0===e(t.target).closest("."+i.options.containerDetailsClass).length&&(i.killSuggestions(),i.disableKillerFn())},i.noSuggestionsContainer=e('<div class="dgwt-wcas-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0),i.suggestionsContainer=t.utils.createNode(a.containerClass),s=e(i.suggestionsContainer),s.appendTo(i.el.closest("."+a.wrapperaClass)),a.showImage===!0&&s.addClass("dgwt-wcas-has-img"),a.showPrice===!0&&s.addClass("dgwt-wcas-has-price"),a.showDescription===!0&&s.addClass("dgwt-wcas-has-desc"),"auto"!==a.width&&s.width(a.width),a.showDetailsPanel===!0&&(i.detailsContainer=t.utils.createNode(a.containerDetailsClass),n=e(i.detailsContainer),n.appendTo(i.el.closest("."+a.wrapperaClass))),s.on("mouseover.autocomplete",o,function(){i.onMouseOver(e(this).data("index")),i.activate(e(this).data("index"))}),s.on("mouseout.autocomplete",function(){}),e(document).on("click.autocomplete",l,function(t){i.killerFn(t),i.clear(t),e(this).removeClass(a.closeTrigger),i.el.val("").focus()}),s.on("click.autocomplete",o,function(){i.select(e(this).data("index"))}),i.fixPositionCapture=function(){i.visible&&i.fixPosition()},e(window).on("resize.autocomplete",i.fixPositionCapture),i.el.on("keydown.autocomplete",function(e){i.onKeyPress(e)}),i.el.on("keyup.autocomplete",function(e){i.onKeyUp(e)}),i.el.on("blur.autocomplete",function(){i.onBlur()}),i.el.on("focus.autocomplete",function(){i.onFocus()}),i.el.on("change.autocomplete",function(e){i.onKeyUp(e)}),i.el.on("input.autocomplete",function(e){i.onKeyUp(e)})},onFocus:function(){var e=this;e.fixPosition(),0===e.options.minChars&&0===e.el.val().length&&e.onValueChange()},onBlur:function(){this.enableKillerFn()},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(t){var s=this,n=s.options;e.extend(n,t),s.isLocal=e.isArray(n.lookup),s.isLocal&&(n.lookup=s.verifySuggestionsFormat(n.lookup)),n.orientation=s.validateOrientation(n.orientation,"bottom"),e(s.suggestionsContainer).css({"max-height":n.maxHeight+"px",width:n.width+"px","z-index":n.zIndex}),n.showDetailsPanel===!0&&jQuery(s.suggestionsContainer).parent().addClass("dgwt-wcas-is-details"),s.options.onSearchComplete=function(){s.preloader("hide",e("."+n.preloaderClass),"dgwt-wcas-inner-preloader",dgwt_wcas.preloader_url,!0),s.preloader("show",e("."+n.preloaderClass),n.closeTrigger,"",!0)}},clearCache:function(){this.cachedResponse={},this.cachedDetails={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var e=this;e.disabled=!0,clearInterval(e.onChangeInterval),e.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var t=this,s=(t.options,e(t.suggestionsContainer)),n=(e(t.detailsContainer),s.parent().get(0));if(n===document.body||t.options.forceFixPosition){var i=t.options.orientation,o=s.outerHeight(),a=t.el.outerHeight(),l=t.el.offset(),r={top:l.top,left:l.left};if("auto"===i){var u=e(window).height(),c=e(window).scrollTop(),d=-c+l.top-o,g=c+u-(l.top+a+o);i=Math.max(d,g)===d?"top":"bottom"}if("top"===i?r.top+=-o:r.top+=a,n!==document.body){var h,p=s.css("opacity");t.visible||s.css("opacity",0).show(),h=s.offsetParent().offset(),r.top-=h.top,r.left-=h.left,t.visible||s.css("opacity",p).hide()}"auto"===t.options.width&&(r.width=t.el.outerWidth()-2+"px"),s.css(r)}},fixPositionDetailsBox:function(){var t=this,s=e(t.detailsContainer);if(0==s.length)return!1;var n=e(window).width(),i=s.parent(),o=s.prev(),a=s.width(),l=s.offset(),r=550;i.width()>=r||(n<l.left+a&&(i.removeClass("dgwt-wcas-details-right"),i.addClass("dgwt-wcas-details-left"),s.css("left","-"+s.outerWidth()+"px")),l.left<1&&(i.removeClass("dgwt-wcas-details-left"),i.addClass("dgwt-wcas-details-right"),s.css("left",o.outerWidth()+"px")))},fixHeight:function(t,s){var n=this,i=n.options;if(1!=i.showDetailsPanel)return!1;var s,o=e("."+i.containerClass),a=e("."+i.containerDetailsClass),l=0,r=0;e("."+i.containerClass+"> *").each(function(){l+=e(this).outerHeight()}),e("."+i.containerDetailsClass+"> *").each(function(){r+=e(this).outerHeight()}),s=l>=r?l:r,(s>l||s>r)&&(o.css("height",s+"px"),a.css("height",s+"px")),"undefined"==typeof t&&(t=0),5>t?setTimeout(function(){n.fixHeight(t+1,s)},30):t=0},enableKillerFn:function(){var t=this;e(document).on("click.autocomplete",t.killerFn)},disableKillerFn:function(){var t=this;e(document).off("click.autocomplete",t.killerFn)},killSuggestions:function(){var t=this,s=e(t.suggestionsContainer).parent();t.stopKillSuggestions(),t.intervalId=window.setInterval(function(){t.visible&&(t.el.val(t.currentValue),t.hide(),s.removeClass("dgwt-wcas-open")),t.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var e,t=this,s=t.el.val().length,n=t.element.selectionStart;return"number"==typeof n?n===s:document.selection?(e=document.selection.createRange(),e.moveStart("character",-s),s===e.text.length):!0},onKeyPress:function(e){var t=this;if(!t.disabled&&!t.visible&&e.which===n.DOWN&&t.currentValue)return void t.suggest();if(!t.disabled&&t.visible){switch(e.which){case n.ESC:t.el.val(t.currentValue),t.hide();break;case n.RIGHT:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case n.TAB:if(t.hint&&t.options.onHint)return void t.selectHint();if(-1===t.selectedIndex)return void t.hide();if(t.select(t.selectedIndex),t.options.tabDisabled===!1)return;break;case n.RETURN:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case n.UP:t.moveUp();break;case n.DOWN:t.moveDown();break;default:return}e.stopImmediatePropagation(),e.preventDefault()}},onKeyUp:function(e){var t=this;if(!t.disabled){switch(e.which){case n.UP:case n.DOWN:return}clearInterval(t.onChangeInterval),t.currentValue!==t.el.val()&&(t.findBestHint(),t.options.deferRequestBy>0?t.onChangeInterval=setInterval(function(){t.onValueChange()},t.options.deferRequestBy):t.onValueChange())}},onValueChange:function(){var t=this,s=t.options,n=t.el.val(),i=t.getQuery(n);return t.selection&&t.currentValue!==i&&(t.selection=null,(s.onInvalidateSelection||e.noop).call(t.element)),clearInterval(t.onChangeInterval),t.currentValue=n,t.selectedIndex=-1,s.triggerSelectOnValidInput&&t.isExactMatch(i)?void t.select(0):void(i.length<s.minChars?(e("."+t.options.closeTrigger).removeClass(t.options.closeTrigger),t.hide()):t.getSuggestions(i))},isExactMatch:function(e){var t=this.suggestions;return 1===t.length&&t[0].value.toLowerCase()===e.toLowerCase()},getQuery:function(t){var s,n=this.options.delimiter;return n?(s=t.split(n),e.trim(s[s.length-1])):t},getSuggestionsLocal:function(t){var s,n=this,i=n.options,o=t.toLowerCase(),a=i.lookupFilter,l=parseInt(i.lookupLimit,10);return s={suggestions:e.grep(i.lookup,function(e){return a(e,t,o)})},l&&s.suggestions.length>l&&(s.suggestions=s.suggestions.slice(0,l)),s},getSuggestions:function(t){var s,n,i,o,a=this,l=a.options,r=l.serviceUrl;if(l.params[l.paramName]=t,n=l.ignoreParams?null:l.params,a.preloader("show",e("."+l.preloaderClass),"dgwt-wcas-inner-preloader",dgwt_wcas.preloader_url,!0),l.onSearchStart.call(a.element,l.params)!==!1){if(e.isFunction(l.lookup))return void l.lookup(t,function(e){a.suggestions=e.suggestions,a.suggest(),a.getDetails(e.suggestions[0]),l.onSearchComplete.call(a.element,t,e.suggestions)});a.isLocal?s=a.getSuggestionsLocal(t):(e.isFunction(r)&&(r=r.call(a.element,t)),i=r+"?"+e.param(n||{}),s=a.cachedResponse[i]),s&&e.isArray(s.suggestions)?(a.suggestions=s.suggestions,a.suggest(),a.getDetails(s.suggestions[0]),l.onSearchComplete.call(a.element,t,s.suggestions)):a.isBadQuery(t)?l.onSearchComplete.call(a.element,t,[]):(a.abortAjax(),o={url:r,data:n,type:l.type,dataType:l.dataType},e.extend(o,l.ajaxSettings),a.currentRequest=e.ajax(o).done(function(e){var s;a.currentRequest=null,s=l.transformResult(e,t),"undefined"!=typeof s.suggestions&&(a.processResponse(s,t,i),a.getDetails(s.suggestions[0])),l.onSearchComplete.call(a.element,t,s.suggestions)}).fail(function(e,s,n){l.onSearchError.call(a.element,t,e,s,n)}))}},getDetails:function(t){var s=this,n=s.options;if(1!=n.showDetailsPanel||e(window).width()<992||"ontouchend"in document)return!1;if(null!=t){var i,o,a=e("."+n.containerDetailsClass);s.fixHeight();var l={action:dgwt_wcas.action_result_details,post_id:null!=t.post_id?t.post_id:0,term_id:null!=t.term_id?t.term_id:0,taxonomy:null!=t.taxonomy?t.taxonomy:"",value:null!=t.value?t.value:""};i=l.action+l.post_id+l.term_id+l.taxonomy,o=s.cachedDetails[i],null!=o?(a.html(o.details),s.fixHeight(),s.fixPositionDetailsBox()):(a.html(""),s.preloader("show",a,"",dgwt_wcas.preloader_url),e.ajax({data:l,type:"post",url:dgwt_wcas.ajax_details_endpoint,success:function(e){var t="string"==typeof e?jQuery.parseJSON(e):e;s.cachedDetails[i]=t,s.preloader("hide",a,"",dgwt_wcas.preloader_url),null!=t.details?a.html(t.details):a.html("@TODO BŁĄD"),s.fixPositionDetailsBox(),s.fixHeight()},error:function(e,t){s.preloader("hide",a,"",dgwt_wcas.preloader_url),a.html(e),s.fixPositionDetailsBox(),s.fixHeight()}}))}},isBadQuery:function(e){if(!this.options.preventBadQueries)return!1;for(var t=this.badQueries,s=t.length;s--;)if(0===e.indexOf(t[s]))return!0;return!1},hide:function(){var t=this,s=e(t.suggestionsContainer);e(t.detailsContainer);e.isFunction(t.options.onHide)&&t.visible&&t.options.onHide.call(t.element,s),t.visible=!1,t.selectedIndex=-1,clearInterval(t.onChangeInterval),e(t.suggestionsContainer).hide(),e(t.detailsContainer).hide(),t.signalHint(null)},suggest:function(){if(0===this.suggestions.length)return void(this.options.showNoSuggestionNotice?this.noSuggestions():this.hide());var t,s=this,n=s.options,i=n.groupBy,o=n.formatResult,a=s.getQuery(s.currentValue),l=s.classes.suggestion,r=s.classes.selected,u=e(s.suggestionsContainer),c=e(s.detailsContainer),d=e(s.noSuggestionsContainer),g=n.beforeRender,h="",p=function(e,s){var n=e.data[i];return t===n?"":(t=n,'<div class="autocomplete-group"><strong>'+t+"</strong></div>")};return n.triggerSelectOnValidInput&&s.isExactMatch(a)?void s.select(0):(e.each(s.suggestions,function(e,t){var s="",r="",u=!1;i&&(h+=p(t,a,e)),"undefined"!=typeof t.parents&&(s=t.parents),n.showImage===!0&&"undefined"!=typeof t.thumb_html&&(u=!0),r+="undefined"!=typeof t.post_id?'data-post-id="'+t.post_id+'" ':"",r+="undefined"!=typeof t.taxonomy?'data-taxonomy="'+t.taxonomy+'" ':"",r+="undefined"!=typeof t.term_id?'data-term-id="'+t.term_id+'" ':"",h+='<div class="'+l+'" data-index="'+e+'" '+r+">",u&&(h+='<span class="dgwt-wcas-si">'+t.thumb_html+"</span>"),h+=u?'<div class="dgwt-wcas-content-wrapp">':"",h+='<span class="dgwt-wcas-st">'+o(t,a)+s+"</span>",n.showPrice===!0&&"undefined"!=typeof t.price&&(h+='<span class="dgwt-wcas-sp">'+t.price+"</span>"),n.showDescription===!0&&"undefined"!=typeof t.desc&&(h+='<span class="dgwt-wcas-sd">'+t.desc+"</span>"),n.showFeaturedBadge===!0&&t.on_sale===!0&&(h+='<span class="dgwt-wcas-badge dgwt-wcas-badge-os">'+n.saleBadgeText+"</span>"),n.showFeaturedBadge===!0&&t.featured===!0&&(h+='<span class="dgwt-wcas-badge dgwt-wcas-badge-f">'+n.featuredBadgeText+"</span>"),h+=u?"</div>":"",h+="</div>"}),this.adjustContainerWidth(),d.detach(),u.html(h),e.isFunction(g)&&g.call(s.element,u),s.fixPosition(),u.show(),u.parent().addClass("dgwt-wcas-open"),n.showDetailsPanel===!0&&c.show(),n.autoSelectFirst&&(s.selectedIndex=0,u.scrollTop(0),u.children("."+l).first().addClass(r)),s.visible=!0,void s.findBestHint())},noSuggestions:function(){var t=this,s=e(t.suggestionsContainer),n=e(t.noSuggestionsContainer);this.adjustContainerWidth(),n.detach(),s.empty(),s.append(n),t.fixPosition(),s.show(),t.visible=!0},adjustContainerWidth:function(){var t,s=this,n=s.options,i=e(s.suggestionsContainer).parent(),o=e(s.suggestionsContainer),a=e(s.detailsContainer),l=550;return"auto"===n.width&&(t=s.el.outerWidth(),o.css("width",t+"px")),i.width()>=l&&n.showDetailsPanel===!0?(i.addClass("dgwt-wcas-full-width"),o.outerWidth(300),a.innerWidth(i.width()-300),i.removeClass("dgwt-wcas-details-left"),i.removeClass("dgwt-wcas-details-right"),void(n.is_rtl===!0?(a.css("left","0"),o.css("right","0")):(a.css("right","0"),o.css("left","0")))):void("left"===n.cointainerDetailsPos?(a.parent().addClass("dgwt-wcas-details-left"),a.css("left","-"+a.outerWidth()+"px")):(a.parent().addClass("dgwt-wcas-details-right"),a.css("left",i.outerWidth()+"px")))},findBestHint:function(){var t=this,s=t.el.val().toLowerCase(),n=null;s&&(e.each(t.suggestions,function(e,t){var i=0===t.value.toLowerCase().indexOf(s);return i&&(n=t),!i}),t.signalHint(n))},signalHint:function(t){var s="",n=this;t&&(s=n.currentValue+t.value.substr(n.currentValue.length)),n.hintValue!==s&&(n.hintValue=s,n.hint=t,(this.options.onHint||e.noop)(s))},preloader:function(t,s,n,i,o){var a,l="dgwt-wcas-preloader-wrapp",r=null==n?l:l+" "+n;if(1==dgwt_wcas.show_preloader&&0!=s.length)return""==i&&o===!0?void("hide"===t?s.removeClass(n):s.addClass(n)):"hide"===t?void e(l).remove():void("show"===t&&(a=""!=i?'<div class="'+r+'"><img src="'+i+'" /></div>':'<div class="'+r+'"><div class="dgwt-wcas-default-preloader"></div></div>',s.html(a)))},verifySuggestionsFormat:function(t){return t.length&&"string"==typeof t[0]?e.map(t,function(e){return{value:e,data:null}}):t},validateOrientation:function(t,s){return t=e.trim(t||"").toLowerCase(),-1===e.inArray(t,["auto","bottom","top"])&&(t=s),t},processResponse:function(e,t,s){var n=this,i=n.options;e.suggestions=n.verifySuggestionsFormat(e.suggestions),i.noCache||(n.cachedResponse[s]=e,i.preventBadQueries&&0===e.suggestions.length&&n.badQueries.push(t)),t===n.getQuery(n.currentValue)&&(n.suggestions=e.suggestions,n.suggest())},activate:function(t){var s,n=this,i=n.classes.selected,o=e(n.suggestionsContainer),a=o.find("."+n.classes.suggestion);return o.find("."+i).removeClass(i),n.selectedIndex=t,-1!==n.selectedIndex&&a.length>n.selectedIndex?(s=a.get(n.selectedIndex),e(s).addClass(i),s):null},selectHint:function(){var t=this,s=e.inArray(t.hint,t.suggestions);t.select(s)},select:function(e){var t=this;t.hide(),t.onSelect(e)},moveUp:function(){var t=this;if(-1!==t.selectedIndex)return 0===t.selectedIndex?(e(t.suggestionsContainer).children().first().removeClass(t.classes.selected),t.selectedIndex=-1,t.el.val(t.currentValue),void t.findBestHint()):void t.adjustScroll(t.selectedIndex-1)},moveDown:function(){var e=this;e.selectedIndex!==e.suggestions.length-1&&e.adjustScroll(e.selectedIndex+1)},adjustScroll:function(t){var s=this,n=s.activate(t);if(n){var i,o,a,l=e(n).outerHeight();i=n.offsetTop,o=e(s.suggestionsContainer).scrollTop(),a=o+s.options.maxHeight-l,o>i?e(s.suggestionsContainer).scrollTop(i):i>a&&e(s.suggestionsContainer).scrollTop(i-s.options.maxHeight+l),s.options.preserveInput||s.el.val(s.getValue(s.suggestions[t].value)),s.signalHint(null)}},onSelect:function(t){var s=this,n=s.options.onSelect,i=s.suggestions[t];s.currentValue=s.getValue(i.value),s.currentValue===s.el.val()||s.options.preserveInput||s.el.val(s.currentValue),-1!=i.id&&(window.location.href=i.url),s.signalHint(null),s.suggestions=[],s.selection=i,e.isFunction(n)&&n.call(s.element,i)},onMouseOver:function(t){var s=this,n=s.options.onMouseOver,i=s.suggestions[t];s.getDetails(i),e.isFunction(n)&&n.call(s.element,i)},onMouseLeave:function(t){var s=this,n=s.options.onMouseLeave,i=s.suggestions[t];e.isFunction(n)&&n.call(s.element,i)},getValue:function(e){var t,s,n=this,i=n.options.delimiter;return i?(t=n.currentValue,s=t.split(i),1===s.length?e:t.substr(0,t.length-s[s.length-1].length)+e):e},dispose:function(){var t=this;t.el.off(".autocomplete").removeData("autocomplete"),t.disableKillerFn(),e(window).off("resize.autocomplete",t.fixPositionCapture),e(t.suggestionsContainer).remove()}},e.fn.dgwtWcasAutocomplete=function(s,n){var i="autocomplete";return 0===arguments.length?this.first().data(i):this.each(function(){var o=e(this),a=o.data(i);"string"==typeof s?a&&"function"==typeof a[s]&&a[s](n):(a&&a.dispose&&a.dispose(),a=new t(this,s),o.data(i,a))})},function(){e(document).ready(function(){e(".dgwt-wcas-search-submit").length>0&&e(".dgwt-wcas-preloader").css("right",e(".dgwt-wcas-search-submit").outerWidth()+"px");var t=1==dgwt_wcas.show_details_box?!0:!1;(jQuery(window).width()<992||"ontouchend"in document)&&(t=!1),e(".dgwt-wcas-search-input").dgwtWcasAutocomplete({minChars:dgwt_wcas.min_chars,autoSelectFirst:!0,triggerSelectOnValidInput:!1,serviceUrl:dgwt_wcas.ajax_search_endpoint,paramName:"dgwt_wcas_keyword",showDetailsPanel:t,showImage:1==dgwt_wcas.show_images?!0:!1,showPrice:1==dgwt_wcas.show_price?!0:!1,showDescription:1==dgwt_wcas.show_desc?!0:!1,showSaleBadge:1==dgwt_wcas.show_sale_badge?!0:!1,showFeaturedBadge:1==dgwt_wcas.show_featured_badge?!0:!1,saleBadgeText:dgwt_wcas.t.sale_badge,featuredBadgeText:dgwt_wcas.t.featured_badge,cointainerDetailsPos:dgwt_wcas.details_box_pos,is_rtl:1==dgwt_wcas.is_rtl?!0:!1})})}()});
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Ajax Autocomplete for jQuery
3
+ * (c) 2015 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
+ * Modified by Damian Góra: http://damiangora.com
9
+ */
10
+ !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(e){"use strict";function t(s,n){var i=function(){},o=this,a={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,onMouseOver:null,onMouseLeave:null,width:"auto",containerDetailsWidth:"auto",showDetailsPanel:!1,showImage:!1,showPrice:!1,showDescription:!1,showSaleBadge:!1,showFeaturedBadge:!1,saleBadgeText:"sale",featuredBadgeText:"featured",minChars:1,maxHeight:1e3,deferRequestBy:0,params:{},formatResult:t.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,is_rtl:!1,onSearchStart:i,onSearchComplete:i,onSearchError:i,preserveInput:!1,wrapperaClass:"dgwt-wcas-search-wrapp",containerClass:"dgwt-wcas-suggestions-wrapp",containerDetailsClass:"dgwt-wcas-details-wrapp",cointainerDetailsPos:"right",preloaderClass:"dgwt-wcas-preloader",closeTrigger:"dgwt-wcas-close",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(e,t,s){return-1!==e.value.toLowerCase().indexOf(s)},paramName:"query",transformResult:function(t){return"string"==typeof t?e.parseJSON(t):t},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1};o.element=s,o.el=e(s),o.suggestions=[],o.badQueries=[],o.selectedIndex=-1,o.currentValue=o.element.value,o.intervalId=0,o.cachedResponse={},o.cachedDetails={},o.onChangeInterval=null,o.onChange=null,o.isLocal=!1,o.suggestionsContainer=null,o.detailsContainer=null,o.noSuggestionsContainer=null,o.options=e.extend({},a,n),o.classes={selected:"dgwt-wcas-suggestion-selected",suggestion:"dgwt-wcas-suggestion"},o.hint=null,o.hintValue="",o.selection=null,o.initialize(),o.setOptions(n)}var s=function(){return{escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.position="absolute",t.style.display="none",t}}}(),n={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40};t.utils=s,e.Autocomplete=t,t.formatResult=function(e,t){var n="("+s.escapeRegExChars(t)+")";return e.value.replace(new RegExp(n,"gi"),"<strong>$1</strong>").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/&lt;(\/?strong)&gt;/g,"<$1>")},t.prototype={killerFn:null,initialize:function(){var s,n,i=this,o="."+i.classes.suggestion,a=(i.classes.selected,i.options),l="."+a.closeTrigger;i.element.setAttribute("autocomplete","off"),i.killerFn=function(t){0===e(t.target).closest("."+i.options.containerClass).length&&0===e(t.target).closest("."+i.options.containerDetailsClass).length&&(i.killSuggestions(),i.disableKillerFn())},i.noSuggestionsContainer=e('<div class="dgwt-wcas-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0),i.suggestionsContainer=t.utils.createNode(a.containerClass),s=e(i.suggestionsContainer),s.appendTo(i.el.closest("."+a.wrapperaClass)),a.showImage===!0&&s.addClass("dgwt-wcas-has-img"),a.showPrice===!0&&s.addClass("dgwt-wcas-has-price"),a.showDescription===!0&&s.addClass("dgwt-wcas-has-desc"),"auto"!==a.width&&s.width(a.width),a.showDetailsPanel===!0&&(i.detailsContainer=t.utils.createNode(a.containerDetailsClass),n=e(i.detailsContainer),n.appendTo(i.el.closest("."+a.wrapperaClass))),s.on("mouseover.autocomplete",o,function(){i.onMouseOver(e(this).data("index")),i.activate(e(this).data("index"))}),s.on("mouseout.autocomplete",function(){}),e(document).on("click.autocomplete",l,function(t){i.killerFn(t),i.clear(t),e(this).removeClass(a.closeTrigger),i.el.val("").focus()}),s.on("click.autocomplete",o,function(){i.select(e(this).data("index"))}),i.fixPositionCapture=function(){i.visible&&i.fixPosition()},e(window).on("resize.autocomplete",i.fixPositionCapture),i.el.on("keydown.autocomplete",function(e){i.onKeyPress(e)}),i.el.on("keyup.autocomplete",function(e){i.onKeyUp(e)}),i.el.on("blur.autocomplete",function(){i.onBlur()}),i.el.on("focus.autocomplete",function(){i.onFocus()}),i.el.on("change.autocomplete",function(e){i.onKeyUp(e)}),i.el.on("input.autocomplete",function(e){i.onKeyUp(e)})},onFocus:function(){var e=this;e.fixPosition(),0===e.options.minChars&&0===e.el.val().length&&e.onValueChange()},onBlur:function(){this.enableKillerFn()},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(t){var s=this,n=s.options;e.extend(n,t),s.isLocal=e.isArray(n.lookup),s.isLocal&&(n.lookup=s.verifySuggestionsFormat(n.lookup)),n.orientation=s.validateOrientation(n.orientation,"bottom"),e(s.suggestionsContainer).css({"max-height":n.maxHeight+"px",width:n.width+"px","z-index":n.zIndex}),n.showDetailsPanel===!0&&jQuery(s.suggestionsContainer).parent().addClass("dgwt-wcas-is-details"),s.options.onSearchComplete=function(){s.preloader("hide",e("."+n.preloaderClass),"dgwt-wcas-inner-preloader"),s.preloader("show",e("."+n.preloaderClass),n.closeTrigger)}},clearCache:function(){this.cachedResponse={},this.cachedDetails={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var e=this;e.disabled=!0,clearInterval(e.onChangeInterval),e.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var t=this,s=(t.options,e(t.suggestionsContainer)),n=(e(t.detailsContainer),s.parent().get(0));if(n===document.body||t.options.forceFixPosition){var i=t.options.orientation,o=s.outerHeight(),a=t.el.outerHeight(),l=t.el.offset(),r={top:l.top,left:l.left};if("auto"===i){var u=e(window).height(),c=e(window).scrollTop(),d=-c+l.top-o,g=c+u-(l.top+a+o);i=Math.max(d,g)===d?"top":"bottom"}if("top"===i?r.top+=-o:r.top+=a,n!==document.body){var h,p=s.css("opacity");t.visible||s.css("opacity",0).show(),h=s.offsetParent().offset(),r.top-=h.top,r.left-=h.left,t.visible||s.css("opacity",p).hide()}"auto"===t.options.width&&(r.width=t.el.outerWidth()-2+"px"),s.css(r)}},fixPositionDetailsBox:function(){var t=this,s=e(t.detailsContainer);if(0==s.length)return!1;var n=e(window).width(),i=s.parent(),o=s.prev(),a=s.width(),l=s.offset(),r=550;i.width()>=r||(n<l.left+a&&(i.removeClass("dgwt-wcas-details-right"),i.addClass("dgwt-wcas-details-left"),s.css("left","-"+s.outerWidth()+"px")),l.left<1&&(i.removeClass("dgwt-wcas-details-left"),i.addClass("dgwt-wcas-details-right"),s.css("left",o.outerWidth()+"px")))},fixHeight:function(t,s){var n=this,i=n.options;if(1!=i.showDetailsPanel)return!1;var s,o=e("."+i.containerClass),a=e("."+i.containerDetailsClass),l=0,r=0;e("."+i.containerClass+"> *").each(function(){l+=e(this).outerHeight()}),e("."+i.containerDetailsClass+"> *").each(function(){r+=e(this).outerHeight()}),s=l>=r?l:r,(s>l||s>r)&&(o.css("height",s+"px"),a.css("height",s+"px")),"undefined"==typeof t&&(t=0),5>t?setTimeout(function(){n.fixHeight(t+1,s)},30):t=0},enableKillerFn:function(){var t=this;e(document).on("click.autocomplete",t.killerFn)},disableKillerFn:function(){var t=this;e(document).off("click.autocomplete",t.killerFn)},killSuggestions:function(){var t=this,s=e(t.suggestionsContainer).parent();t.stopKillSuggestions(),t.intervalId=window.setInterval(function(){t.visible&&(t.el.val(t.currentValue),t.hide(),s.removeClass("dgwt-wcas-open")),t.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var e,t=this,s=t.el.val().length,n=t.element.selectionStart;return"number"==typeof n?n===s:document.selection?(e=document.selection.createRange(),e.moveStart("character",-s),s===e.text.length):!0},onKeyPress:function(e){var t=this;if(!t.disabled&&!t.visible&&e.which===n.DOWN&&t.currentValue)return void t.suggest();if(!t.disabled&&t.visible){switch(e.which){case n.ESC:t.el.val(t.currentValue),t.hide();break;case n.RIGHT:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case n.TAB:if(t.hint&&t.options.onHint)return void t.selectHint();if(-1===t.selectedIndex)return void t.hide();if(t.select(t.selectedIndex),t.options.tabDisabled===!1)return;break;case n.RETURN:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case n.UP:t.moveUp();break;case n.DOWN:t.moveDown();break;default:return}e.stopImmediatePropagation(),e.preventDefault()}},onKeyUp:function(e){var t=this;if(!t.disabled){switch(e.which){case n.UP:case n.DOWN:return}clearInterval(t.onChangeInterval),t.currentValue!==t.el.val()&&(t.findBestHint(),t.options.deferRequestBy>0?t.onChangeInterval=setInterval(function(){t.onValueChange()},t.options.deferRequestBy):t.onValueChange())}},onValueChange:function(){var t=this,s=t.options,n=t.el.val(),i=t.getQuery(n);return t.selection&&t.currentValue!==i&&(t.selection=null,(s.onInvalidateSelection||e.noop).call(t.element)),clearInterval(t.onChangeInterval),t.currentValue=n,t.selectedIndex=-1,s.triggerSelectOnValidInput&&t.isExactMatch(i)?void t.select(0):void(i.length<s.minChars?(e("."+t.options.closeTrigger).removeClass(t.options.closeTrigger),t.hide()):t.getSuggestions(i))},isExactMatch:function(e){var t=this.suggestions;return 1===t.length&&t[0].value.toLowerCase()===e.toLowerCase()},getQuery:function(t){var s,n=this.options.delimiter;return n?(s=t.split(n),e.trim(s[s.length-1])):t},getSuggestionsLocal:function(t){var s,n=this,i=n.options,o=t.toLowerCase(),a=i.lookupFilter,l=parseInt(i.lookupLimit,10);return s={suggestions:e.grep(i.lookup,function(e){return a(e,t,o)})},l&&s.suggestions.length>l&&(s.suggestions=s.suggestions.slice(0,l)),s},getSuggestions:function(t){var s,n,i,o,a=this,l=a.options,r=l.serviceUrl;if(l.params[l.paramName]=t,n=l.ignoreParams?null:l.params,a.preloader("show",e("."+l.preloaderClass),"dgwt-wcas-inner-preloader"),l.onSearchStart.call(a.element,l.params)!==!1){if(e.isFunction(l.lookup))return void l.lookup(t,function(e){a.suggestions=e.suggestions,a.suggest(),a.getDetails(e.suggestions[0]),l.onSearchComplete.call(a.element,t,e.suggestions)});a.isLocal?s=a.getSuggestionsLocal(t):(e.isFunction(r)&&(r=r.call(a.element,t)),i=r+"?"+e.param(n||{}),s=a.cachedResponse[i]),s&&e.isArray(s.suggestions)?(a.suggestions=s.suggestions,a.suggest(),a.getDetails(s.suggestions[0]),l.onSearchComplete.call(a.element,t,s.suggestions)):a.isBadQuery(t)?l.onSearchComplete.call(a.element,t,[]):(a.abortAjax(),o={url:r,data:n,type:l.type,dataType:l.dataType},e.extend(o,l.ajaxSettings),a.currentRequest=e.ajax(o).done(function(e){var s;a.currentRequest=null,s=l.transformResult(e,t),"undefined"!=typeof s.suggestions&&(a.processResponse(s,t,i),a.getDetails(s.suggestions[0])),l.onSearchComplete.call(a.element,t,s.suggestions)}).fail(function(e,s,n){l.onSearchError.call(a.element,t,e,s,n)}))}},getDetails:function(t){var s=this,n=s.options;if(1!=n.showDetailsPanel||e(window).width()<992||"ontouchend"in document)return!1;if(null!=t){var i,o,a=e("."+n.containerDetailsClass);s.fixHeight();var l={action:dgwt_wcas.action_result_details,post_id:null!=t.post_id?t.post_id:0,term_id:null!=t.term_id?t.term_id:0,taxonomy:null!=t.taxonomy?t.taxonomy:"",value:null!=t.value?t.value:""};i=l.action+l.post_id+l.term_id+l.taxonomy,o=s.cachedDetails[i],null!=o?(a.html(o.details),s.fixHeight(),s.fixPositionDetailsBox()):(a.html(""),s.preloader("show",a,"",!0),e.ajax({data:l,type:"post",url:dgwt_wcas.ajax_details_endpoint,success:function(e){var t="string"==typeof e?jQuery.parseJSON(e):e;s.cachedDetails[i]=t,s.preloader("hide",a,"",!0),null!=t.details?a.html(t.details):a.html("@TODO BŁĄD"),s.fixPositionDetailsBox(),s.fixHeight()},error:function(e,t){s.preloader("hide",a,"",!0),a.html(e),s.fixPositionDetailsBox(),s.fixHeight()}}))}},isBadQuery:function(e){if(!this.options.preventBadQueries)return!1;for(var t=this.badQueries,s=t.length;s--;)if(0===e.indexOf(t[s]))return!0;return!1},hide:function(){var t=this,s=e(t.suggestionsContainer);e(t.detailsContainer);e.isFunction(t.options.onHide)&&t.visible&&t.options.onHide.call(t.element,s),t.visible=!1,t.selectedIndex=-1,clearInterval(t.onChangeInterval),e(t.suggestionsContainer).hide(),e(t.detailsContainer).hide(),t.signalHint(null)},suggest:function(){if(0===this.suggestions.length)return void(this.options.showNoSuggestionNotice?this.noSuggestions():this.hide());var t,s=this,n=s.options,i=n.groupBy,o=n.formatResult,a=s.getQuery(s.currentValue),l=s.classes.suggestion,r=s.classes.selected,u=e(s.suggestionsContainer),c=e(s.detailsContainer),d=e(s.noSuggestionsContainer),g=n.beforeRender,h="",p=function(e,s){var n=e.data[i];return t===n?"":(t=n,'<div class="autocomplete-group"><strong>'+t+"</strong></div>")};return n.triggerSelectOnValidInput&&s.isExactMatch(a)?void s.select(0):(e.each(s.suggestions,function(e,t){var s="",r="",u=!1;i&&(h+=p(t,a,e)),"undefined"!=typeof t.parents&&(s=t.parents),n.showImage===!0&&"undefined"!=typeof t.thumb_html&&(u=!0),r+="undefined"!=typeof t.post_id?'data-post-id="'+t.post_id+'" ':"",r+="undefined"!=typeof t.taxonomy?'data-taxonomy="'+t.taxonomy+'" ':"",r+="undefined"!=typeof t.term_id?'data-term-id="'+t.term_id+'" ':"",h+='<div class="'+l+'" data-index="'+e+'" '+r+">",u&&(h+='<span class="dgwt-wcas-si">'+t.thumb_html+"</span>"),h+=u?'<div class="dgwt-wcas-content-wrapp">':"",h+='<span class="dgwt-wcas-st">'+o(t,a)+s+"</span>",n.showPrice===!0&&"undefined"!=typeof t.price&&(h+='<span class="dgwt-wcas-sp">'+t.price+"</span>"),n.showDescription===!0&&"undefined"!=typeof t.desc&&(h+='<span class="dgwt-wcas-sd">'+t.desc+"</span>"),n.showFeaturedBadge===!0&&t.on_sale===!0&&(h+='<span class="dgwt-wcas-badge dgwt-wcas-badge-os">'+n.saleBadgeText+"</span>"),n.showFeaturedBadge===!0&&t.featured===!0&&(h+='<span class="dgwt-wcas-badge dgwt-wcas-badge-f">'+n.featuredBadgeText+"</span>"),h+=u?"</div>":"",h+="</div>"}),this.adjustContainerWidth(),d.detach(),u.html(h),e.isFunction(g)&&g.call(s.element,u),s.fixPosition(),u.show(),u.parent().addClass("dgwt-wcas-open"),n.showDetailsPanel===!0&&c.show(),n.autoSelectFirst&&(s.selectedIndex=0,u.scrollTop(0),u.children("."+l).first().addClass(r)),s.visible=!0,void s.findBestHint())},noSuggestions:function(){var t=this,s=e(t.suggestionsContainer),n=e(t.noSuggestionsContainer);this.adjustContainerWidth(),n.detach(),s.empty(),s.append(n),t.fixPosition(),s.show(),t.visible=!0},adjustContainerWidth:function(){var t,s=this,n=s.options,i=e(s.suggestionsContainer).parent(),o=e(s.suggestionsContainer),a=e(s.detailsContainer),l=550;return"auto"===n.width&&(t=s.el.outerWidth(),o.css("width",t+"px")),i.width()>=l&&n.showDetailsPanel===!0?(i.addClass("dgwt-wcas-full-width"),o.outerWidth(300),a.innerWidth(i.width()-300),i.removeClass("dgwt-wcas-details-left"),i.removeClass("dgwt-wcas-details-right"),void(n.is_rtl===!0?(a.css("left","0"),o.css("right","0")):(a.css("right","0"),o.css("left","0")))):void("left"===n.cointainerDetailsPos?(a.parent().addClass("dgwt-wcas-details-left"),a.css("left","-"+a.outerWidth()+"px")):(a.parent().addClass("dgwt-wcas-details-right"),a.css("left",i.outerWidth()+"px")))},findBestHint:function(){var t=this,s=t.el.val().toLowerCase(),n=null;s&&(e.each(t.suggestions,function(e,t){var i=0===t.value.toLowerCase().indexOf(s);return i&&(n=t),!i}),t.signalHint(n))},signalHint:function(t){var s="",n=this;t&&(s=n.currentValue+t.value.substr(n.currentValue.length)),n.hintValue!==s&&(n.hintValue=s,n.hint=t,(this.options.onHint||e.noop)(s))},preloader:function(t,s,n,i){var o,a="dgwt-wcas-preloader-wrapp",l=null==n?a:a+" "+n;if(1==dgwt_wcas.show_preloader&&0!=s.length)return i!==!0?void("hide"===t?s.removeClass(n):s.addClass(n)):"hide"===t?void e(a).remove():void("show"===t&&(o='<div class="'+l+'"><div class="dgwt-wcas-default-preloader"></div></div>',s.html(o)))},verifySuggestionsFormat:function(t){return t.length&&"string"==typeof t[0]?e.map(t,function(e){return{value:e,data:null}}):t},validateOrientation:function(t,s){return t=e.trim(t||"").toLowerCase(),-1===e.inArray(t,["auto","bottom","top"])&&(t=s),t},processResponse:function(e,t,s){var n=this,i=n.options;e.suggestions=n.verifySuggestionsFormat(e.suggestions),i.noCache||(n.cachedResponse[s]=e,i.preventBadQueries&&0===e.suggestions.length&&n.badQueries.push(t)),t===n.getQuery(n.currentValue)&&(n.suggestions=e.suggestions,n.suggest())},activate:function(t){var s,n=this,i=n.classes.selected,o=e(n.suggestionsContainer),a=o.find("."+n.classes.suggestion);return o.find("."+i).removeClass(i),n.selectedIndex=t,-1!==n.selectedIndex&&a.length>n.selectedIndex?(s=a.get(n.selectedIndex),e(s).addClass(i),s):null},selectHint:function(){var t=this,s=e.inArray(t.hint,t.suggestions);t.select(s)},select:function(e){var t=this;t.hide(),t.onSelect(e)},moveUp:function(){var t=this;if(-1!==t.selectedIndex)return 0===t.selectedIndex?(e(t.suggestionsContainer).children().first().removeClass(t.classes.selected),t.selectedIndex=-1,t.el.val(t.currentValue),void t.findBestHint()):void t.adjustScroll(t.selectedIndex-1)},moveDown:function(){var e=this;e.selectedIndex!==e.suggestions.length-1&&e.adjustScroll(e.selectedIndex+1)},adjustScroll:function(t){var s=this,n=s.activate(t);if(n){var i,o,a,l=e(n).outerHeight();i=n.offsetTop,o=e(s.suggestionsContainer).scrollTop(),a=o+s.options.maxHeight-l,o>i?e(s.suggestionsContainer).scrollTop(i):i>a&&e(s.suggestionsContainer).scrollTop(i-s.options.maxHeight+l),s.options.preserveInput||s.el.val(s.getValue(s.suggestions[t].value)),s.signalHint(null)}},onSelect:function(t){var s=this,n=s.options.onSelect,i=s.suggestions[t];s.currentValue=s.getValue(i.value),s.currentValue===s.el.val()||s.options.preserveInput||s.el.val(s.currentValue),-1!=i.id&&(window.location.href=i.url),s.signalHint(null),s.suggestions=[],s.selection=i,e.isFunction(n)&&n.call(s.element,i)},onMouseOver:function(t){var s=this,n=s.options.onMouseOver,i=s.suggestions[t];s.getDetails(i),e.isFunction(n)&&n.call(s.element,i)},onMouseLeave:function(t){var s=this,n=s.options.onMouseLeave,i=s.suggestions[t];e.isFunction(n)&&n.call(s.element,i)},getValue:function(e){var t,s,n=this,i=n.options.delimiter;return i?(t=n.currentValue,s=t.split(i),1===s.length?e:t.substr(0,t.length-s[s.length-1].length)+e):e},dispose:function(){var t=this;t.el.off(".autocomplete").removeData("autocomplete"),t.disableKillerFn(),e(window).off("resize.autocomplete",t.fixPositionCapture),e(t.suggestionsContainer).remove()}},e.fn.dgwtWcasAutocomplete=function(s,n){var i="autocomplete";return 0===arguments.length?this.first().data(i):this.each(function(){var o=e(this),a=o.data(i);"string"==typeof s?a&&"function"==typeof a[s]&&a[s](n):(a&&a.dispose&&a.dispose(),a=new t(this,s),o.data(i,a))})},function(){e(document).ready(function(){e(".dgwt-wcas-search-submit").length>0&&e(".dgwt-wcas-preloader").css("right",e(".dgwt-wcas-search-submit").outerWidth()+"px");var t=1==dgwt_wcas.show_details_box?!0:!1;(jQuery(window).width()<992||"ontouchend"in document)&&(t=!1),e(".dgwt-wcas-search-input").dgwtWcasAutocomplete({minChars:dgwt_wcas.min_chars,autoSelectFirst:!0,triggerSelectOnValidInput:!1,serviceUrl:dgwt_wcas.ajax_search_endpoint,paramName:"dgwt_wcas_keyword",showDetailsPanel:t,showImage:1==dgwt_wcas.show_images?!0:!1,showPrice:1==dgwt_wcas.show_price?!0:!1,showDescription:1==dgwt_wcas.show_desc?!0:!1,showSaleBadge:1==dgwt_wcas.show_sale_badge?!0:!1,showFeaturedBadge:1==dgwt_wcas.show_featured_badge?!0:!1,saleBadgeText:dgwt_wcas.t.sale_badge,featuredBadgeText:dgwt_wcas.t.featured_badge,cointainerDetailsPos:dgwt_wcas.details_box_pos,is_rtl:1==dgwt_wcas.is_rtl?!0:!1})})}()});
includes/functions.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) {
4
  exit;
@@ -77,15 +78,15 @@ function dgwt_wcas_search_css_classes( $args = array() ) {
77
  if ( DGWT_WCAS()->settings->get_opt( 'show_details_box' ) === 'on' ) {
78
  $classes[] = 'dgwt-wcas-is-detail-box';
79
  }
80
-
81
- if ( DGWT_WCAS()->settings->get_opt( 'show_submit_button' ) !== 'on'){
82
  $classes[] = 'dgwt-wcas-no-submit';
83
  }
84
-
85
  if ( isset( $args[ 'class' ] ) && !empty( $args[ 'class' ] ) ) {
86
  $classes[] = esc_html( $args[ 'class' ] );
87
  }
88
-
89
  if ( is_rtl() ) {
90
  $classes[] = 'dgwt_wcas_rtl';
91
  }
@@ -93,26 +94,6 @@ function dgwt_wcas_search_css_classes( $args = array() ) {
93
  return implode( ' ', $classes );
94
  }
95
 
96
- /*
97
- * Add custom preloader to input
98
- */
99
- add_action( 'wp_head', 'dgwt_wcas_custom_preloader_css' );
100
-
101
- function dgwt_wcas_custom_preloader_css() {
102
-
103
- $url = DGWT_WCAS()->settings->get_opt( 'preloader_url' );
104
-
105
- if ( !empty( $url ) ) {
106
- ?>
107
- <style>
108
- .dgwt-wcas-inner-preloader {
109
- background-image: url('<?php echo esc_url( $url ); ?>');
110
- }
111
- </style>
112
- <?php
113
- }
114
- }
115
-
116
  /*
117
  * Print loupe SVG ico
118
  */
@@ -126,6 +107,7 @@ function dgwt_wcas_print_ico_loupe() {
126
  c0-10.176,8.249-18.425,18.425-18.425s18.425,8.249,18.425,18.425S31.436,39.507,21.26,39.507S2.835,31.258,2.835,21.082z"/>
127
  </svg>
128
  <?php
 
129
  }
130
 
131
  /*
@@ -173,6 +155,108 @@ function dgwt_wcas_how_to_use_html() {
173
  include DGWT_WCAS_DIR . 'includes/admin/views/how-to-use.php';
174
 
175
  $html .= ob_get_clean();
176
-
177
  return $html;
178
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) {
5
  exit;
78
  if ( DGWT_WCAS()->settings->get_opt( 'show_details_box' ) === 'on' ) {
79
  $classes[] = 'dgwt-wcas-is-detail-box';
80
  }
81
+
82
+ if ( DGWT_WCAS()->settings->get_opt( 'show_submit_button' ) !== 'on' ) {
83
  $classes[] = 'dgwt-wcas-no-submit';
84
  }
85
+
86
  if ( isset( $args[ 'class' ] ) && !empty( $args[ 'class' ] ) ) {
87
  $classes[] = esc_html( $args[ 'class' ] );
88
  }
89
+
90
  if ( is_rtl() ) {
91
  $classes[] = 'dgwt_wcas_rtl';
92
  }
94
  return implode( ' ', $classes );
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  /*
98
  * Print loupe SVG ico
99
  */
107
  c0-10.176,8.249-18.425,18.425-18.425s18.425,8.249,18.425,18.425S31.436,39.507,21.26,39.507S2.835,31.258,2.835,21.082z"/>
108
  </svg>
109
  <?php
110
+
111
  }
112
 
113
  /*
155
  include DGWT_WCAS_DIR . 'includes/admin/views/how-to-use.php';
156
 
157
  $html .= ob_get_clean();
158
+
159
  return $html;
160
  }
161
+
162
+ /*
163
+ * Minify JS
164
+ *
165
+ * @see https://gist.github.com/tovic/d7b310dea3b33e4732c0
166
+ *
167
+ * @param string
168
+ * @return string
169
+ */
170
+
171
+ function dgwt_wcas_minify_js( $input ) {
172
+
173
+ if ( trim( $input ) === "" )
174
+ return $input;
175
+ return preg_replace(
176
+ array(
177
+ // Remove comment(s)
178
+ '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
179
+ // Remove white-space(s) outside the string and regex
180
+ '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
181
+ // Remove the last semicolon
182
+ '#;+\}#',
183
+ // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
184
+ '#([\{,])([\'])(\d+|[a-z_]\w*)\2(?=\:)#i',
185
+ // --ibid. From `foo['bar']` to `foo.bar`
186
+ '#([\w\)\]])\[([\'"])([a-z_]\w*)\2\]#i',
187
+ // Replace `true` with `!0`
188
+ '#(?<=return |[=:,\(\[])true\b#',
189
+ // Replace `false` with `!1`
190
+ '#(?<=return |[=:,\(\[])false\b#',
191
+ // Clean up ...
192
+ '#\s*(\/\*|\*\/)\s*#'
193
+ ), array(
194
+ '$1',
195
+ '$1$2',
196
+ '}',
197
+ '$1$3',
198
+ '$1.$3',
199
+ '!0',
200
+ '!1',
201
+ '$1'
202
+ ), $input );
203
+ }
204
+
205
+ /*
206
+ * Minify CSS
207
+ *
208
+ * @see https://gist.github.com/tovic/d7b310dea3b33e4732c0
209
+ *
210
+ * @param string
211
+ * @return string
212
+ */
213
+
214
+ function dgwt_wcas_minify_css( $input ) {
215
+
216
+ if ( trim( $input ) === "" )
217
+ return $input;
218
+ // Force white-space(s) in `calc()`
219
+ if ( strpos( $input, 'calc(' ) !== false ) {
220
+ $input = preg_replace_callback( '#(?<=[\s:])calc\(\s*(.*?)\s*\)#', function($matches) {
221
+ return 'calc(' . preg_replace( '#\s+#', "\x1A", $matches[ 1 ] ) . ')';
222
+ }, $input );
223
+ }
224
+ return preg_replace(
225
+ array(
226
+ // Remove comment(s)
227
+ '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
228
+ // Remove unused white-space(s)
229
+ '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~+]|\s*+-(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
230
+ // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
231
+ '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
232
+ // Replace `:0 0 0 0` with `:0`
233
+ '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
234
+ // Replace `background-position:0` with `background-position:0 0`
235
+ '#(background-position):0(?=[;\}])#si',
236
+ // Replace `0.6` with `.6`, but only when preceded by a white-space or `=`, `:`, `,`, `(`, `-`
237
+ '#(?<=[\s=:,\(\-]|&\#32;)0+\.(\d+)#s',
238
+ // Minify string value
239
+ '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][-\w]*?)\2(?=[\s\{\}\];,])#si',
240
+ '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
241
+ // Minify HEX color code
242
+ '#(?<=[\s=:,\(]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
243
+ // Replace `(border|outline):none` with `(border|outline):0`
244
+ '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
245
+ // Remove empty selector(s)
246
+ '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s',
247
+ '#\x1A#'
248
+ ), array(
249
+ '$1',
250
+ '$1$2$3$4$5$6$7',
251
+ '$1',
252
+ ':0',
253
+ '$1:0 0',
254
+ '.$1',
255
+ '$1$3',
256
+ '$1$2$4$5',
257
+ '$1$2$3',
258
+ '$1:0',
259
+ '$1$2',
260
+ ' '
261
+ ), $input );
262
+ }
includes/integrations/wp-tao.php CHANGED
@@ -32,36 +32,42 @@ class DGWT_WCAS_WP_Tao_integrate {
32
  */
33
 
34
  public function print_track_script() {
 
 
35
  ?>
36
- <script>
37
- if ( typeof wptaoEvent == 'function' && window.jQuery ) {
38
- jQuery( function ( $ ) {
39
-
40
- $( document ).on( 'click', '.dgwt-wcas-suggestion', function () {
41
-
42
- var suggestion = $( this ),
43
- value = suggestion.find( '.dgwt-wcas-st' ).text(),
44
- tags = [ 'wp', 'Autocomplete search' ],
45
- meta = { };
46
-
47
- if ( typeof suggestion.data( 'post-id' ) != 'undefined' ) {
48
- meta.post_id = suggestion.data( 'post-id' );
49
- }
50
- if ( typeof suggestion.data( 'taxonomy' ) != 'undefined' ) {
51
- meta.taxonomy = suggestion.data( 'taxonomy' );
52
- }
53
- if ( typeof suggestion.data( 'term-id' ) != 'undefined' ) {
54
- meta.term_id = suggestion.data( 'term-id' );
55
- }
56
-
57
- wptaoEvent( 'search', value, tags, meta );
58
-
59
- } );
60
- } );
61
- }
62
  </script>
63
  <?php
64
 
 
 
 
 
65
  }
66
 
67
  /*
@@ -110,7 +116,7 @@ class DGWT_WCAS_WP_Tao_integrate {
110
 
111
  public function event_search_desc( $description, $event ) {
112
 
113
- if ( !empty( $event->value ) && (isset($event->meta[ 'post_id' ]) || isset($event->meta[ 'taxonomy' ]))) {
114
 
115
  $description .= '<span class="wptao-meta-title">' . __( 'Suggestion type:', WTBP_WPTAO_DOMAIN ) . '</span> ';
116
 
@@ -131,9 +137,8 @@ class DGWT_WCAS_WP_Tao_integrate {
131
  $description .= __( 'product tag', WTBP_WPTAO_DOMAIN ) . '<br />';
132
  }
133
  }
134
-
135
- //$description .= '<span class="wptao-meta-title">' . __( 'Generated by:', WTBP_WPTAO_DOMAIN ) . '</span> Ajax Search for WooCommerce plugin';
136
 
 
137
  }
138
 
139
 
32
  */
33
 
34
  public function print_track_script() {
35
+
36
+ ob_start();
37
  ?>
38
+ <script type="text/javascript">
39
+ if ( typeof wptaoEvent == 'function' && window.jQuery ) {
40
+ jQuery( function ( $ ) {
41
+
42
+ $( document ).on( 'click', '.dgwt-wcas-suggestion', function () {
43
+
44
+ var suggestion = $( this ),
45
+ value = suggestion.find( '.dgwt-wcas-st' ).text(),
46
+ tags = [ 'wp', 'Autocomplete search' ],
47
+ meta = { };
48
+
49
+ if ( typeof suggestion.data( 'post-id' ) != 'undefined' ) {
50
+ meta.post_id = suggestion.data( 'post-id' );
51
+ }
52
+ if ( typeof suggestion.data( 'taxonomy' ) != 'undefined' ) {
53
+ meta.taxonomy = suggestion.data( 'taxonomy' );
54
+ }
55
+ if ( typeof suggestion.data( 'term-id' ) != 'undefined' ) {
56
+ meta.term_id = suggestion.data( 'term-id' );
57
+ }
58
+
59
+ wptaoEvent( 'search', value, tags, meta );
60
+
61
+ } );
62
+ } );
63
+ }
64
  </script>
65
  <?php
66
 
67
+ $js = ob_get_contents();
68
+ ob_end_clean();
69
+
70
+ echo dgwt_wcas_minify_js( $js );
71
  }
72
 
73
  /*
116
 
117
  public function event_search_desc( $description, $event ) {
118
 
119
+ if ( !empty( $event->value ) && (isset( $event->meta[ 'post_id' ] ) || isset( $event->meta[ 'taxonomy' ] )) ) {
120
 
121
  $description .= '<span class="wptao-meta-title">' . __( 'Suggestion type:', WTBP_WPTAO_DOMAIN ) . '</span> ';
122
 
137
  $description .= __( 'product tag', WTBP_WPTAO_DOMAIN ) . '<br />';
138
  }
139
  }
 
 
140
 
141
+ //$description .= '<span class="wptao-meta-title">' . __( 'Generated by:', WTBP_WPTAO_DOMAIN ) . '</span> Ajax Search for WooCommerce plugin';
142
  }
143
 
144
 
includes/register-scripts.php CHANGED
@@ -98,7 +98,7 @@ class DGWT_WCAS_Scripts {
98
  if ( DGWT_WCAS()->settings->get_opt( 'show_preloader' ) === 'on' ) {
99
  $localize[ 'show_preloader' ] = true;
100
 
101
- $localize[ 'preloader_url' ] = esc_url( DGWT_WCAS()->settings->get_opt( 'preloader_url' ) );
102
  }
103
 
104
  if ( DGWT_WCAS_DEBUG === false ) {
98
  if ( DGWT_WCAS()->settings->get_opt( 'show_preloader' ) === 'on' ) {
99
  $localize[ 'show_preloader' ] = true;
100
 
101
+ $localize[ 'preloader_url' ] = esc_url( trim(DGWT_WCAS()->settings->get_opt( 'preloader_url' )) );
102
  }
103
 
104
  if ( DGWT_WCAS_DEBUG === false ) {
includes/style.php CHANGED
@@ -16,8 +16,12 @@ function dgwt_wcas_print_style() {
16
  $sug_text_color = DGWT_WCAS()->settings->get_opt( 'sug_text_color' );
17
  $sug_bg_color = DGWT_WCAS()->settings->get_opt( 'sug_bg_color' );
18
  $sug_border_color = DGWT_WCAS()->settings->get_opt( 'sug_border_color' );
 
 
 
 
19
  ?>
20
- <style>
21
  <?php if ( !empty( $bg_search_input ) || !empty( $text_input_color ) || !empty( $border_input_color ) ): ?>
22
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input,
23
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input:hover,
@@ -26,8 +30,8 @@ function dgwt_wcas_print_style() {
26
  <?php echo!empty( $text_input_color ) ? 'color:' . sanitize_text_field( $text_input_color ) . ';' : ''; ?>
27
  <?php echo!empty( $border_input_color ) ? 'border-color:' . sanitize_text_field( $border_input_color ) . ';' : ''; ?>
28
  }
29
-
30
-
31
  <?php if ( !empty( $text_input_color ) ): ?>
32
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input::-webkit-input-placeholder {
33
  color: <?php echo sanitize_text_field( $text_input_color ); ?>;
@@ -50,9 +54,9 @@ function dgwt_wcas_print_style() {
50
  }
51
  <?php endif; ?>
52
  <?php endif; ?>
53
-
54
-
55
-
56
  <?php
57
  // Submit button
58
  if ( !empty( $bg_submit_color ) || !empty( $text_submit_color ) ):
@@ -68,12 +72,12 @@ function dgwt_wcas_print_style() {
68
  <?php echo!empty( $bg_submit_color ) ? 'background-color: ' . sanitize_text_field( $bg_submit_color ) . ';' : ''; ?>
69
  <?php echo!empty( $text_submit_color ) ? 'color: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
70
  }
71
-
72
  .dgwt-wcas-search-wrapp .dgwt-wcas-ico-loupe{
73
  <?php echo!empty( $text_submit_color ) ? 'fill: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
74
  }
75
  <?php endif; ?>
76
-
77
  <?php
78
  // Submit button
79
  if ( !empty( $bg_submit_color ) || !empty( $text_submit_color ) ):
@@ -89,37 +93,37 @@ function dgwt_wcas_print_style() {
89
  <?php echo!empty( $bg_submit_color ) ? 'background-color: ' . sanitize_text_field( $bg_submit_color ) . ';' : ''; ?>
90
  <?php echo!empty( $text_submit_color ) ? 'color: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
91
  }
92
-
93
  .dgwt-wcas-search-wrapp .dgwt-wcas-ico-loupe{
94
  <?php echo!empty( $text_submit_color ) ? 'fill: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
95
  }
96
  <?php endif; ?>
97
-
98
  <?php if ( !empty( $sug_bg_color ) ): ?>
99
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestions-wrapp{
100
  <?php echo!empty( $sug_bg_color ) ? 'background-color: ' . sanitize_text_field( $sug_bg_color ) . ';' : ''; ?>
101
  }
102
  <?php endif; ?>
103
-
104
  <?php if ( !empty( $sug_hover_color ) ): ?>
105
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestion-selected{
106
  <?php echo!empty( $sug_hover_color ) ? 'background-color: ' . sanitize_text_field( $sug_hover_color ) . ';' : ''; ?>
107
  }
108
  <?php endif; ?>
109
-
110
  <?php if ( !empty( $sug_text_color ) ): ?>
111
  .dgwt-wcas-suggestion *
112
  {
113
  <?php echo!empty( $sug_text_color ) ? 'color: ' . sanitize_text_field( $sug_text_color ) . ';' : ''; ?>
114
  }
115
  <?php endif; ?>
116
-
117
  <?php if ( !empty( $sug_highlight_color ) ): ?>
118
  .dgwt-wcas-search-wrapp .dgwt-wcas-st strong{
119
  <?php echo!empty( $sug_highlight_color ) ? 'color: ' . sanitize_text_field( $sug_highlight_color ) . ';' : ''; ?>
120
  }
121
  <?php endif; ?>
122
-
123
  <?php if ( !empty( $sug_border_color ) ): ?>
124
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestions-wrapp,
125
  .dgwt-wcas-details-wrapp,
@@ -127,9 +131,17 @@ function dgwt_wcas_print_style() {
127
  <?php echo!empty( $sug_border_color ) ? 'border-color: ' . sanitize_text_field( $sug_border_color ) . ';' : ''; ?>
128
  }
129
  <?php endif; ?>
130
-
 
 
 
 
 
 
131
  </style>
132
-
133
-
134
  <?php
 
 
 
 
135
  }
16
  $sug_text_color = DGWT_WCAS()->settings->get_opt( 'sug_text_color' );
17
  $sug_bg_color = DGWT_WCAS()->settings->get_opt( 'sug_bg_color' );
18
  $sug_border_color = DGWT_WCAS()->settings->get_opt( 'sug_border_color' );
19
+
20
+ $preloader_url = trim( DGWT_WCAS()->settings->get_opt( 'preloader_url' ) );
21
+
22
+ ob_start();
23
  ?>
24
+ <style type="text/css">
25
  <?php if ( !empty( $bg_search_input ) || !empty( $text_input_color ) || !empty( $border_input_color ) ): ?>
26
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input,
27
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input:hover,
30
  <?php echo!empty( $text_input_color ) ? 'color:' . sanitize_text_field( $text_input_color ) . ';' : ''; ?>
31
  <?php echo!empty( $border_input_color ) ? 'border-color:' . sanitize_text_field( $border_input_color ) . ';' : ''; ?>
32
  }
33
+
34
+
35
  <?php if ( !empty( $text_input_color ) ): ?>
36
  .dgwt-wcas-search-wrapp .dgwt-wcas-sf-wrapp .dgwt-wcas-search-input::-webkit-input-placeholder {
37
  color: <?php echo sanitize_text_field( $text_input_color ); ?>;
54
  }
55
  <?php endif; ?>
56
  <?php endif; ?>
57
+
58
+
59
+
60
  <?php
61
  // Submit button
62
  if ( !empty( $bg_submit_color ) || !empty( $text_submit_color ) ):
72
  <?php echo!empty( $bg_submit_color ) ? 'background-color: ' . sanitize_text_field( $bg_submit_color ) . ';' : ''; ?>
73
  <?php echo!empty( $text_submit_color ) ? 'color: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
74
  }
75
+
76
  .dgwt-wcas-search-wrapp .dgwt-wcas-ico-loupe{
77
  <?php echo!empty( $text_submit_color ) ? 'fill: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
78
  }
79
  <?php endif; ?>
80
+
81
  <?php
82
  // Submit button
83
  if ( !empty( $bg_submit_color ) || !empty( $text_submit_color ) ):
93
  <?php echo!empty( $bg_submit_color ) ? 'background-color: ' . sanitize_text_field( $bg_submit_color ) . ';' : ''; ?>
94
  <?php echo!empty( $text_submit_color ) ? 'color: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
95
  }
96
+
97
  .dgwt-wcas-search-wrapp .dgwt-wcas-ico-loupe{
98
  <?php echo!empty( $text_submit_color ) ? 'fill: ' . sanitize_text_field( $text_submit_color ) . ';' : ''; ?>
99
  }
100
  <?php endif; ?>
101
+
102
  <?php if ( !empty( $sug_bg_color ) ): ?>
103
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestions-wrapp{
104
  <?php echo!empty( $sug_bg_color ) ? 'background-color: ' . sanitize_text_field( $sug_bg_color ) . ';' : ''; ?>
105
  }
106
  <?php endif; ?>
107
+
108
  <?php if ( !empty( $sug_hover_color ) ): ?>
109
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestion-selected{
110
  <?php echo!empty( $sug_hover_color ) ? 'background-color: ' . sanitize_text_field( $sug_hover_color ) . ';' : ''; ?>
111
  }
112
  <?php endif; ?>
113
+
114
  <?php if ( !empty( $sug_text_color ) ): ?>
115
  .dgwt-wcas-suggestion *
116
  {
117
  <?php echo!empty( $sug_text_color ) ? 'color: ' . sanitize_text_field( $sug_text_color ) . ';' : ''; ?>
118
  }
119
  <?php endif; ?>
120
+
121
  <?php if ( !empty( $sug_highlight_color ) ): ?>
122
  .dgwt-wcas-search-wrapp .dgwt-wcas-st strong{
123
  <?php echo!empty( $sug_highlight_color ) ? 'color: ' . sanitize_text_field( $sug_highlight_color ) . ';' : ''; ?>
124
  }
125
  <?php endif; ?>
126
+
127
  <?php if ( !empty( $sug_border_color ) ): ?>
128
  .dgwt-wcas-search-wrapp .dgwt-wcas-suggestions-wrapp,
129
  .dgwt-wcas-details-wrapp,
131
  <?php echo!empty( $sug_border_color ) ? 'border-color: ' . sanitize_text_field( $sug_border_color ) . ';' : ''; ?>
132
  }
133
  <?php endif; ?>
134
+
135
+ <?php if ( !empty( $preloader_url ) ): ?>
136
+ .dgwt-wcas-inner-preloader {
137
+ background-image: url('<?php echo esc_url( $preloader_url ); ?>');
138
+ }
139
+ <?php endif; ?>
140
+
141
  </style>
 
 
142
  <?php
143
+ $css = ob_get_contents();
144
+ ob_end_clean();
145
+
146
+ echo dgwt_wcas_minify_css( $css );
147
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: damian-gora
3
  Tags: AJAX, ajax search, autocomplete, category search, custom search, ecommerce, instant search, sive search, product search, products, search, search by sku, search highlight, search plugin, shop, woocommerce, woocommerce live search, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress search, wp ajax search, wp search, wp search plugin, wp tao
4
  Requires at least: 3.8
5
  Tested up to: 4.5.2
6
- Stable tag: 0.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -37,7 +37,7 @@ See how it works on the [DEMO](http://damiangora.com/ajax-search-for-woocommerce
37
  * **The minimum number of characters** required to display suggestions – you can set your own
38
  * You can set your own **label on the 'search' button**
39
  * You can set your own **preloader image**
40
- * You can set your own **colour scheme** for the 10 main form elements and hints
41
  * **[WP Tao](https://wordpress.org/plugins/wp-tao) integration** - allows you to track and analyze search results of a website users. Each click on the suggestion is logged. Read more on [wptao.org](http://wptao.org/documentation/user-guide/).
42
 
43
  = How to use? =
@@ -60,8 +60,13 @@ Any suggestions or comments are welcome. Feel free to contact me using this [con
60
  1. Basic suggestions
61
  2. Extra elements
62
  3. Extended suggestions
 
63
 
64
  == Changelog ==
65
 
 
 
 
 
66
  = 0.9, May 17, 2016 =
67
  * First public release
3
  Tags: AJAX, ajax search, autocomplete, category search, custom search, ecommerce, instant search, sive search, product search, products, search, search by sku, search highlight, search plugin, shop, woocommerce, woocommerce live search, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress search, wp ajax search, wp search, wp search plugin, wp tao
4
  Requires at least: 3.8
5
  Tested up to: 4.5.2
6
+ Stable tag: 0.9.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
37
  * **The minimum number of characters** required to display suggestions – you can set your own
38
  * You can set your own **label on the 'search' button**
39
  * You can set your own **preloader image**
40
+ * You can set your own **colour scheme** for the 10 main form elements and suggestions
41
  * **[WP Tao](https://wordpress.org/plugins/wp-tao) integration** - allows you to track and analyze search results of a website users. Each click on the suggestion is logged. Read more on [wptao.org](http://wptao.org/documentation/user-guide/).
42
 
43
  = How to use? =
60
  1. Basic suggestions
61
  2. Extra elements
62
  3. Extended suggestions
63
+ 4. Settings page with colour schemes
64
 
65
  == Changelog ==
66
 
67
+ = 0.9.1, June 5, 2016 =
68
+ * ADD: Javascript and CSS dynamic compression
69
+ * FIX: Incorrect dimensions of the custom preloader
70
+
71
  = 0.9, May 17, 2016 =
72
  * First public release