!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.CS_dashboardPostEditor=t()}}(function(){return function t(e,o,n){function i(s,a){if(!o[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var u=o[s]={exports:{}};e[s][0].call(u.exports,function(t){var o=e[s][1][t];return i(o||t)},u,u.exports,t,e,o,n)}return o[s].exports}for(var r="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,o){jQuery(window).ready(function(t){function e(t){return r.strings[t]||""}var o,n,i,r=csDashboardPostEditorData;o=t(r.editorTabMarkup),n=t("#postdivrich"),n.after(o),i=t('<button type="button" id="content-cornerstone" class="wp-switch-editor switch-cornerstone">'+e("cornerstone-tab")+"</button>"),n.find(".wp-editor-tabs").append(i);var s=function(){n.hide(),o.show();var e=function(){t(".composer-switch").css({visibility:"hidden"})};_.defer(e),jQuery(window).on("load",e)};o.find("#content-tmce, #content-html").click(function(){function i(){n.show(),t(window).trigger("scroll.editor-expand","scroll"),o.hide(),t(".composer-switch").css({visibility:"visible"}),switchEditors.go("content",s?"html":"tmco")}var s=-1!==t(this).attr("id").indexOf("html");if("true"==r.usesCornerstone)return void tco.confirm({message:e("manual-edit-warning"),acceptClass:"tco-btn-nope",acceptBtn:e("manual-edit-accept"),declineBtn:e("manual-edit-decline"),accept:function(){"new"!=r.post_id&&wp.ajax.post("cs_override",{post_id:r.post_id}),r.usesCornerstone="false",i()}});i()}),i.click(function(){if("false"==r.usesCornerstone&&"new"!=r.post_id&&""!=wp.autosave.getPostData().content)return void tco.confirm({message:e("overwrite-warning"),acceptClass:"tco-btn-nope",acceptBtn:e("overwrite-accept"),declineBtn:e("overwrite-decline"),accept:function(){r.usesCornerstone="none",s()}});s()}),"true"==r.usesCornerstone&&s(),window.localStorage.removeItem("cornerstone_auto_draft"),o.find("#cs-edit-button").on("click",function(o){if(o.preventDefault(),o.stopPropagation(),null!=r.editURL)return void(window.location=r.editURL);t("#title-prompt-text").hide();var n=t("#title"),i=n.val();i&&"title"!=i||n.val(e("default-title")),wp.autosave.server.triggerSave(),t(document).on("heartbeat-tick.autosave",function(e,o){var o=wp.autosave.getPostData(),n="?page_id=";"post"==o.post_type&&(n="?p="),"post"!=o.post_type&&"page"!=o.post_type&&(n="?post_type="+o.post_type+"&p="),window.localStorage.setItem("cornerstone_auto_draft",o.post_id),t(window).off("beforeunload.edit-post"),window.location=r.homeURL+n+o.post_id+"&preview=true&cornerstone=1"})})})},{}]},{},[1])(1)});