/** * @Website: leotheme.com - prestashop template provider * @author Leotheme * @copyright Leotheme * @description: */ jQuery(window).on("elementor:init",function(){var e=elementor.modules.controls.BaseData.extend({isSearch:!1,resultsRender:function(){var t=this,e=this.getControlValue();e&&(_.isArray(e)||(e=[e]),t.addControlSpinner(),jQuery.ajax({url:ajaxurl,type:"POST",data:{action:t.model.get("render"),ids:e.toString()},success:function(e){t.isSearch=!0,t.model.set("options",e),t.render()}}))},addControlSpinner:function(){this.ui.select.prop("disabled",!0),this.$el.find(".elementor-control-title").after('  ')},onReady:function(){var t=this;this.ui.select.select2({placeholder:"Search",allowClear:!0,minimumInputLength:2,ajax:{url:ajaxurl,dataType:"json",method:"post",delay:250,data:function(e){return{q:e.term,action:t.model.get("search")}},processResults:function(e){return{results:e}},cache:!0}}),this.isSearch||this.resultsRender()},onBeforeDestroy:function(){this.ui.select.data("select2")&&this.ui.select.select2("destroy"),this.$el.remove()}});elementor.addControlView("autocomplete",e)});