| 4 |
!function(t){"use strict";let e=wpcWidgets.wpcItemNum;function i(){t(".wpc-sorting-list").sortable({items:"> div.wpc-sorting-item-wrapper",delay:75,placeholder:"wpc-filter-item-shadow",refreshPositions:!0,cursor:"move",handle:".wpc-sorting-item-handle",axis:"y",update:function(t,e){n(e.item.parent(".wpc-sorting-list"))},start:function(e,i){let n=i.item,p=i.item.children(".wpc-sorting-item-top"),r=p.height()+2;p.hasClass("wpc-opened")&&(p.removeClass("wpc-opened"),n.css("max-height",r+"px"),t(this).sortable("refreshPositions"))},stop:function(t,e){e.item.css("max-height","none")}})}function n(i){let n=i.find(".wpc-sorting-item-label"),p="",r="",o=new RegExp("^"+e+"[\\d]{1,100}$");n.length>0&&n.each(function(i,n){p=t(n).val(),r=p.replace(o,e+(i+1)),t(n).val(r).trigger("change")})}t(document).ready(function(){t(document).on("click",".wpc-sorting-item-title",function(){t(this).parent(".wpc-sorting-item-top").toggleClass("wpc-opened")}),t(document).on("click",".wpc-sorting-item-remove",function(){let e=t(this),i=e.parents("div.wpc-sorting-list");if(i.find(".wpc-sorting-item-wrapper").length<2)return;let p=e.parents("div.widget"),r=p.children(".widget-inside"),o=r.find(".widget-control-save"),a=r.find(".widget-id").val();e.parents(".wpc-sorting-item-wrapper").remove(),n(i),window.wpWidgets.dirtyWidgets[a]=!0,p.addClass("widget-dirty"),o.prop("disabled",!1).val(wp.i18n.__("Save"))}),t(document).on("change",".wpc-orderby-select",function(e){let i=t(this),n=i.parents(".wpc-sorting-item-inside").find(".wpc-sorting-item-meta-key-wrapper");return"m"===i.val()||"n"===i.val()?n.addClass("wpc-opened"):n.removeClass("wpc-opened"),!0}),t(document).on("input change",".wpc-sorting-item-label",function(){let e=t(this),i=e.parents(".wpc-sorting-item-wrapper"),n=(i.parents(".wpc-sorting-list"),i.find(".wpc-sorting-item-title"));if(""===e.val()){let t=i.index();n.text(n.data("title")+(t+1))}else p=e,n.text(p.val());var p}),t(document).on("widget-added widget-updated",function(){i(),t(".wpc-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200,keepAlive:!0,maxWidth:"220px"})}),t(document).on("focus",".wpc-sorting-item-label",function(){let i=t(this).val(),n=new RegExp("^"+e+"[\\d]{1,100}$"),p=i.replace(n,"");t(this).val(p)}),t(document).on("click",".wpc-add-sorting-item",function(e){e.preventDefault();let i=t(this).parents(".wpc-add-sorting-item-wrapper").parent(),n=i.find(".wpc-sorting-list"),p=i.find(".wpc-new-sorting-item").html(),r=t(p),o=r.find(".wpc-sorting-item-title"),a="wpc_new_id",s=n.find(".wpc-sorting-item-wrapper").length+1,d=function(t,e){return e.replace(a,s)};r.find('[id*="'+a+'"]').attr("id",d),r.find('[for*="'+a+'"]').attr("for",d),r.find('[name*="'+a+'"]').attr("name",d),r.find('[value*="'+a+'"]').attr("value",d),o.text(o.data("title")+s),r.attr("class",d),r.find(".wpc-sorting-item-top").addClass("wpc-opened"),t("input.wpc-ballast").trigger("change"),n.append(r)}),"undefined"!=typeof elementor&&elementor.hooks.addAction("panel/widgets/wp-widget-wpc_sorting_widget/controls/wp_widget/loaded",function(e){setTimeout(function(){i(),t("input.wpc-ballast").trigger("change")},500)}),i()})}(jQuery); |