jQuery(function(e){e("#adminForm").on("submit",function(a){"page.cancel"!=e("#form_task").val()&&a.preventDefault()});window.onbeforeunload=function(e){if(void 0!==window.warningAtReload&&1==window.warningAtReload){var a="Do you want to lose unsaved data?";return(e=e||window.event)&&(e.returnValue=a),a}return null},e("#btn-save-page, #sp-pagebuilder-btn-save, #btn-save-copy, #btn-save-new, #btn-save-close").on("click",function(a){a.preventDefault();var t=e(this),i=e("#adminForm"),n="page.apply";"btn-save-copy"==a.target.id&&(n="page.save2copy"),e("#form_task").val(n),e.ajax({type:"POST",url:pagebuilder_base+"administrator/index.php?option=com_sppagebuilder&task=page."+n,data:i.serialize(),beforeSend:function(){t.find(".fa-save").removeClass("fa-save").addClass("fa-spinner fa-spin")},success:function(i){try{var n=e.parseJSON(i);t.find(".fa").removeClass("fa-spinner fa-spin").addClass("fa-save");var o="success";if(!n.status)o="error";if(n.title&&e("#jform_title").val(n.title),n.id&&e("#jform_id").val(n.id),e('<div class="notify-'+o+'">'+n.message+"</div>").css({opacity:0,"margin-top":-15,"margin-bottom":0}).animate({opacity:1,"margin-top":0,"margin-bottom":15},200).prependTo(".sp-pagebuilder-notifications"),void 0!==window.warningAtReload&&1==window.warningAtReload&&(window.warningAtReload=!1),e(".sp-pagebuilder-notifications").find(">div").each(function(){var a=e(this);setTimeout(function(){a.animate({opacity:0,"margin-top":-15,"margin-bottom":0},200,function(){a.remove()})},3e3)}),!n.status)return;window.history.replaceState("","",n.redirect),n.frontend_editor_url&&(0===e("#btn-page-frontend-editor").length?e("#btn-page-options").parent().before('<div class="sp-pagebuilder-btn-group"><a id="btn-page-frontend-editor" target="_blank" href="'+n.frontend_editor_url+'" class="sp-pagebuilder-btn sp-pagebuilder-btn-info"><i class="fa fa-edit"></i> '+Joomla.JText._("COM_SPPAGEBUILDER_FRONTEND_EDITOR")+"</a></div>\n"):e("#btn-page-frontend-editor").attr("href",n.frontend_editor_url)),n.preview_url&&(0===e("#btn-page-preview").length?e("#btn-page-options").parent().before('<div class="sp-pagebuilder-btn-group"><a id="btn-page-preview" target="_blank" href="'+n.preview_url+'" class="sp-pagebuilder-btn sp-pagebuilder-btn-inverse"><i class="fa fa-eye"></i> '+Joomla.JText._("COM_SPPAGEBUILDER_PREVIEW")+"</a></div>\n"):e("#btn-page-preview").attr("href",n.preview_url)),"btn-save-new"==a.target.id&&(window.location.href="index.php?option=com_sppagebuilder&view=page&layout=edit"),"btn-save-close"==a.target.id&&(window.location.href="index.php?option=com_sppagebuilder&view=pages")}catch(e){window.location.href="index.php?option=com_sppagebuilder&view=pages"}}})}),e(document).on({mouseenter:function(){var a=e(this).find("img"),t=e(this).find("img").outerHeight()-230;a.css({top:"-"+t+"px"})},mouseleave:function(){e(this).find("img").css({top:0})}},".sp-pagebuilder-page-templates li")});