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