/**
* @package SP Page Builder
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2021 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
jQuery((function(e){Joomla.submitbutton=function(a,t,n){var i="",o="";if("page.save"==a?(i=e("#save-group-children-save").length?e("#save-group-children-save"):e("#toolbar-save"),o=i.find("span").attr("class")):"page.save2new"==a?(i=e("#toolbar-save-new"),o=i.find("span").attr("class")):"page.save2copy"==a?(i=e("#toolbar-save-copy"),o=i.find("span").attr("class")):(i=e("#toolbar-apply"),o=i.find("span").attr("class")),""==a)return!1;var r=!0;if("page.cancel"!=a&&"page.close"!=a)for(var s=e("#adminForm.form-validate"),d=0;d<s.length;d++)if(!document.formvalidator.isValid(s[d])){r=!1;break}if(r){if("page.cancel"!=a&&"page.close"!=a){var p=e("#adminForm");p.find('input[name="task"]').val(a),"page.save2copy"==a&&p.find('input[name="jform[hits]"]').val(0),e.ajax({type:"POST",data:p.serialize(),url:pagebuilder_base+"administrator/index.php?option=com_sppagebuilder&task="+a,beforeSend:function(){i.find("span").removeAttr("class").addClass("fas fa-spinner fa-spin")},success:function(t){i.find("span").removeAttr("class").addClass(o);try{var n=e.parseJSON(t),r="success";if(!n.status)r="error";if(n.title&&e("#jform_title").val(n.title),n.id&&e("#jform_id").val(n.id),n.created_on&&e("#jform_created_on").val(n.created_on),n.created_by&&e("#jform_created_by").val(n.created_by),e('<div class="notify-'+r+'">'+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(".sp-pagebuilder-frontend-actions").append('<a id="btn-page-frontend-editor" target="_blank" href="'+n.frontend_editor_url+'" class="btn btn-primary">'+Joomla.JText._("COM_SPPAGEBUILDER_FRONTEND_EDITOR")+"</a>\n"):e("#btn-page-frontend-editor").attr("href",n.frontend_editor_url)),n.preview_url&&(0===e("#btn-page-preview").length?e(".sp-pagebuilder-frontend-actions").append('<a id="btn-page-preview" target="_blank" href="'+n.preview_url+'" class="btn btn-outline-primary ml-3">'+Joomla.JText._("COM_SPPAGEBUILDER_PREVIEW")+"</a>\n"):e("#btn-page-preview").attr("href",n.preview_url)),"page.save2new"==a&&(window.location.href="index.php?option=com_sppagebuilder&view=page&layout=edit"),"page.save"==a&&(window.location.href="index.php?option=com_sppagebuilder&view=pages")}catch(e){window.location.href="index.php?option=com_sppagebuilder&view=pages"}}})}else Joomla.submitform(a,t,n);return!0}return!1};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(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")}));