WordPress/wp-includes/js/autosave.min.js

1 line
5.3 KiB
JavaScript
Raw Normal View History

window.autosave=function(){return!0},function(c,a){function s(t){var e=(new Date).getTime(),n=[],o=u();return o&&o.isDirty()&&!o.isHidden()&&I<e-3e3&&(o.save(),I=e),e={post_id:c("#post_ID").val()||0,post_type:c("#post_type").val()||"",post_author:c("#post_author").val()||"",post_title:c("#title").val()||"",content:c("#content").val()||"",excerpt:c("#excerpt").val()||""},"local"===t||(c('input[id^="in-category-"]:checked').each(function(){n.push(this.value)}),e.catslist=n.join(","),(t=c("#post_name").val())&&(e.post_name=t),(t=c("#parent_id").val())&&(e.parent_id=t),c("#comment_status").prop("checked")&&(e.comment_status="open"),c("#ping_status").prop("checked")&&(e.ping_status="open"),"1"===c("#auto_draft").val()&&(e.auto_draft="1")),e}function r(t){return"object"==typeof t?(t.post_title||"")+"::"+(t.content||"")+"::"+(t.excerpt||""):(c("#title").val()||"")+"::"+(c("#content").val()||"")+"::"+(c("#excerpt").val()||"")}function i(){T.trigger("autosave-disable-buttons"),setTimeout(n,5e3)}function n(){T.trigger("autosave-enable-buttons")}function u(){return"undefined"!=typeof tinymce&&tinymce.get("content")}function p(){m=!0,a.clearTimeout(e),e=a.setTimeout(function(){m=!1},1e4)}function o(){x=(new Date).getTime()+1e3*autosaveL10n.autosaveInterval||6e4}function l(){var t=!1;return t=k&&b?(t=sessionStorage.getItem("wp-autosave-"+b))?JSON.parse(t):{}:t}function v(){var t=l();return t&&S&&t["post_"+S]||!1}function d(t){var e=l();if(!e||!S)return!1;if(t)e["post_"+S]=t;else{if(!e.hasOwnProperty("post_"+S))return!1;delete e["post_"+S]}return t=e,!(!k||!b)&&(e="wp-autosave-"+b,sessionStorage.setItem(e,JSON.stringify(t)),null!==sessionStorage.getItem(e))}function f(t){var e,n;return!(C||!k)&&(t?(e=v()||{},c.extend(e,t)):e=s("local"),(t=r(e))!==(D=void 0===D?w:D)&&(e.save_time=(new Date).getTime(),e.status=c("#post_status").val()||"",(n=d(e))&&(D=t),n))}function g(t,e){function n(t){return t.toString().replace(/[\x20\t\r\n\f]+/g,"")}return n(t||"")===n(e||"")}function t(){var t,e,n,o=v(),a=wpCookies.get("wp-saving-post"),s=c("#has-newer-autosave").parent(".notice"),i=c(".wp-header-end");if(a===S+"-saved")return wpCookies.remove("wp-saving-post"),void d(!1);o&&(t=c("#content").val()||"",e=c("#title").val()||"",a=c("#excerpt").val()||"",g(t,o.content)&&g(e,o.post_title)&&g(a,o.excerpt)||(i.length||(i=c(".wrap h1, .wrap h2").first()),n=c("#local-storage-notice").insertAfter(i).addClass("notice-warning"),s.length?s.slideUp(150,function(){n.slideDown(150)}):n.slideDown(200),n.find(".restore-backup").on("click.autosave-local",function(){!function(t){var e;if(t)return D=r(t),c("#title").val()!==t.post_title&&c("#title").focus().val(t.post_title||""),c("#excerpt").val(t.excerpt||""),(e=u())&&!e.isHidden()&&"undefined"!=typeof switchEditors?(e.settings.wpautop&&t.content&&(t.content=switchEditors.wpautop(t.content)),e.undoManager.transact(function(){e.setContent(t.content||""),e.nodeChanged()})):(c("#content-html").click(),c("#content").focus(),document.execCommand("selectAll"),document.execCommand("insertText",!1,t.content||""))}(o),n.fadeTo(250,0,function(){n.slideUp(150)})})))}var w,m,e,h,_,x,y,b,S,k,D,C,I,T;a.wp=a.wp||{},a.wp.autosave=(I=0,(T=c(document)).on("tinymce-editor-init.autosave",function(t,e){"content"===e.id&&a.setTimeout(function(){e.save(),w=r()},1e3)}).ready(function(){w=r()}),{getPostData:s,getCompareString:r,disableButtons:i,enableButtons:n,local:(C=!1,b=void 0!==a.autosaveL10n&&a.autosaveL10n.blog_id,function(){var t=Math.random().toString(),e=!1;try{a.sessionStorage.setItem("wp-test",t),e=a.sessionStorage.getItem("wp-test")===t,a.sessionStorage.removeItem("wp-test")}catch(t){}return k=e}()&&b&&(c("#content").length||c("#excerpt").length)&&T.ready(function(){S=c("#post_ID").val()||0,c("#wp-content-wrap").hasClass("tmce-active")?T.on("tinymce-editor-init.autosave",function(){a.setTimeout(function(){t()},1500)}):t(),a.setInterval(f,15e3),c("form#post").on("submit.autosave-local",function(){var t=u(),e=c("#post_ID").val()||0;t&&!t.isHidden()?t.on("submit",function(){f({post_title:c("#title").val()||"",content:c("#content")