jQuery(function(s){s(document).on("change",".sp-pagebuilder-control-padding",function(e){var o="",a=s(this);s(this).closest(".sp-pagebuilder-paddings-list").find(">div").each(function(e){o+=s(this).find(".sp-pagebuilder-control-padding").val()+" "}),a.closest(".sp-pagebuilder-paddings-list").prev().val(s.trim(o))}),s(document).on("change",".sp-pagebuilder-control-margin",function(e){var o="",a=s(this);s(this).closest(".sp-pagebuilder-margins-list").find(">div").each(function(e){o+=s(this).find(".sp-pagebuilder-control-margin").val()+" "}),a.closest(".sp-pagebuilder-margins-list").prev().val(s.trim(o))}),s(document).on("click",".sp-pagebuilder-btn-clear-media",function(e){e.preventDefault();var o=s(this);o.siblings(".sp-pagebuilder-media-preview").addClass("sp-pagebuilder-media-no-image").removeAttr("src"),o.siblings("input").val("")});var a={};s.fn.openPopupAlt=function(){s("#page-options").addClass("sp-pagebuilder-modal-overlay-after-open"),s("#page-options").find(".sp-pagebuilder-modal-content").addClass("sp-pagebuilder-modal-content-after-open"),s("body").addClass("sp-pagebuilder-modal-open"),s(".sp-pagebuilder-modal-alt .form-group").find(">input,>textarea,>select").each(function(){a[s(this).attr("id")]=s(this).val()})},s.fn.closePopupAlt=function(e){var o=s.extend({reset:!1},e);return s("#page-options").addClass("sp-pagebuilder-modal-overlay-before-close"),s("#page-options").find(".sp-pagebuilder-modal-content").addClass("sp-pagebuilder-modal-content-before-close"),s("#page-options").removeClass("sp-pagebuilder-modal-overlay-before-close sp-pagebuilder-modal-overlay-after-open"),s("#page-options").find(".sp-pagebuilder-modal-content").removeClass("sp-pagebuilder-modal-content-before-close sp-pagebuilder-modal-content-after-open"),s("body").removeClass("sp-pagebuilder-modal-open"),o.reset&&s(".sp-pagebuilder-modal-alt .form-group").find(">input,>textarea,>select").each(function(){s(this).val(a[s(this).attr("id")]),"jform_og_image"==s(this).attr("id")&&""!=a[s(this).attr("id")]&&s(this).prev(".sppb-media-preview").removeClass("no-image").attr("src",pagebuilder_base+a[s(this).attr("id")])}),this},s("#btn-page-options").on("click",function(e){e.preventDefault(),s().openPopupAlt()}),s(document).on("click",".sp-pagebuilder-modal-alt .sp-pagebuilder-modal-content-after-open",function(e){e.target===this&&s().closePopupAlt({reset:!0})}),s(document).on("click","#btn-cancel-page-options",function(e){e.preventDefault(),s().closePopupAlt({reset:!0})}),s(document).on("click","#btn-apply-page-options",function(e){s().closePopupAlt()}),s(document).on("click",".sp-pagebuilder-fontawesome-icon-input",function(e){e.preventDefault(),s(this).closest(".sp-pagebuilder-fontawesome-icon-chooser").toggleClass("open"),s(this).closest(".sp-pagebuilder-fontawesome-icon-chooser").hasClass("open")&&s(this).closest(".sp-pagebuilder-fontawesome-icon-chooser").find('input[type="text"]').focus()}),s(document).on("click",".sp-pagebuilder-fa-list-icon",function(e){e.preventDefault();var o=s(this),a=o.closest(".sp-pagebuilder-fontawesome-icon-chooser");s(this).closest("ul").find(">li").removeClass("active"),o.addClass("active"),a.find(".sp-pagebuilder-fontawesome-icon-input>span").html('<i class="fa '+o.data("fontawesome_icon")+'"></i> '+o.data("fontawesome_icon_name")),a.find(".sp-pagebuilder-addon-input-fa").val(o.data("fontawesome_icon_name")),a.addClass("sp-pagebuilder-has-fa-icon").removeClass("open")}),s(document).on("keyup",'.sp-pagebuilder-fontawesome-dropdown input[type="text"]',function(){var e=s(this).val(),o=new RegExp(".*?"+e+".*?","i");s(this).next(".sp-pagebuilder-fontawesome-icons").children().each(function(){var e=o.test(s("span",this).text());s(this).toggle(e)})}),s(document).on("click",".sp-pagebuilder-remove-fa-icon",function(e){e.stopPropagation(),e.preventDefault();var o=s(this).closest(".sp-pagebuilder-fontawesome-icon-chooser");o.removeClass("sp-pagebuilder-has-fa-icon"),o.find(".sp-pagebuilder-fontawesome-icon-input>span").html("--"+Joomla.JText._("COM_SPPAGEBUILDER_ADDON_ICON_SELECT")+"--"),o.find(".sp-pagebuilder-fontawesome-icons>li").removeClass("active"),o.find(".sp-pagebuilder-addon-input-fa").val("")}),0<s(".com_sppagebuilder #sp-pagebuilder-page-tools").length&&s(window).on("scroll",function(){if(220<s(window).scrollTop()){var e=s(".com_sppagebuilder #sp-pagebuilder-page-tools > div");s(".com_sppagebuilder #sp-pagebuilder-page-tools").addClass("fixed-sp-page-tools"),s(".com_sppagebuilder #sp-pagebuilder-page-tools").css({height:e.outerHeight()})}else s(".com_sppagebuilder #sp-pagebuilder-page-tools").removeClass("fixed-sp-page-tools"),s(".com_sppagebuilder #sp-pagebuilder-page-tools").css({height:"auto"})})});