WordPress/wp-includes/js/autosave.min.js
desrosj 40a294d21e Build/Test Tools: Backport GitHub Action and build improvements to the 5.3 branch.
This backports several build and test tool improvements to the 5.3 branch. Most notably, this includes:

- The changes required to allow each workflow to be triggered by the `workflow_dispatch` event so that tests can be run on a schedule [50590].
- The ability to run PHPUnit tests from `src` instead of `build` [50441-50443].
- Splitting single site and multisite tests into parallel jobs [50379].
- Split slow tests into separate, parallel jobs for PHP 5.6 [50444].
- Better branch and path scoping for GitHub Action workflows when running on `pull_request` [50432,50479].
- Several `devDependency` updates.

Merges [50267,50299,50379,50387,50413,50416,50432,50435-50436,50441-50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50598] to the 5.3 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667.
Built from https://develop.svn.wordpress.org/branches/5.3@50605


git-svn-id: http://core.svn.wordpress.org/branches/5.3@50218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-26 19:23:55 +00:00

1 line
5.3 KiB
JavaScript

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").val()||"",excerpt:c("#excerpt").val()||""})}):f({post_title:c("#title").val()||"",content:c("#content").val()||"",excerpt:c("#excerpt").val()||""});t="https:"===a.location.protocol;wpCookies.set("wp-saving-post",e+"-check",86400,!1,!1,t)})}),{hasStorage:k,getSavedPostData:v,save:f,suspend:function(){C=!0},resume:function(){C=!1}}),server:(x=0,y=!1,T.on("heartbeat-send.autosave",function(t,e){var n,o,n=!(y||m||!a.autosave())&&(!((new Date).getTime()<x)&&((o=r(n=s()))!==(_=void 0===_?w:_)&&(h=o,p(),i(),T.trigger("wpcountwords",[n.content]).trigger("before-autosave",[n]),n._wpnonce=c("#_wpnonce").val()||"",n)));n&&(e.wp_autosave=n)}).on("heartbeat-tick.autosave",function(t,e){e.wp_autosave&&(e=e.wp_autosave,o(),m=!1,_=h,h="",T.trigger("after-autosave",[e]),n(),e.success&&c("#auto_draft").val(""))}).on("heartbeat-connection-lost.autosave",function(t,e,n){"timeout"!==e&&603!==n||(n=c("#lost-connection-notice"),wp.autosave.local.hasStorage||n.find(".hide-if-no-sessionstorage").hide(),n.show(),i())}).on("heartbeat-connection-restored.autosave",function(){c("#lost-connection-notice").hide(),n()}).ready(function(){o()}),{tempBlockSave:p,triggerSave:function(){x=0,wp.heartbeat.connectNow()},postChanged:function(){return r()!==w},suspend:function(){y=!0},resume:function(){y=!1}})})}(jQuery,window);