WordPress/wp-includes/js/autosave.min.js
Aaron Jorbin 0e21d32900 Build/Test: Bump devDependencies for WordPress 5.3
This upgrades a number of devDependencies.  Some of these include changes to how the tasks are configured.

Uglify: There are deprecated options from 2.x to 4.x, see: https://github.com/gruntjs/grunt-contrib-uglify#options

Autoprefixer: Browserslist now warns when passing in the browser list, so that is put into package.json

As with most changes to uglify, this changes every minified JS file.

Fixes #48203.



Built from https://develop.svn.wordpress.org/trunk@46408


git-svn-id: http://core.svn.wordpress.org/trunk@46206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-05 19:49:10 +00:00

1 line
5.4 KiB
JavaScript

window.autosave=function(){return!0},function(c,o){function a(t){var e,n,o,a=(new Date).getTime(),i=[],s=p();return s&&s.isDirty()&&!s.isHidden()&&I<a-3e3&&(s.save(),I=a),o={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(){i.push(this.value)}),o.catslist=i.join(","),(e=c("#post_name").val())&&(o.post_name=e),(n=c("#parent_id").val())&&(o.parent_id=n),c("#comment_status").prop("checked")&&(o.comment_status="open"),c("#ping_status").prop("checked")&&(o.ping_status="open"),"1"===c("#auto_draft").val()&&(o.auto_draft="1")),o}function u(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 p(){return"undefined"!=typeof tinymce&&tinymce.get("content")}function s(){m=!0,o.clearTimeout(e),e=o.setTimeout(function(){m=!1},1e4)}function r(){x=(new Date).getTime()+1e3*autosaveL10n.autosaveInterval||6e4}function l(){var t=!1;return k&&b&&(t=(t=sessionStorage.getItem("wp-autosave-"+b))?JSON.parse(t):{}),t}function v(){var t=l();return t&&S&&t["post_"+S]||!1}function f(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 function(t){var e;return!(!k||!b)&&(e="wp-autosave-"+b,sessionStorage.setItem(e,JSON.stringify(t)),null!==sessionStorage.getItem(e))}(e)}function d(t){var e,n,o;return!(C||!k)&&(t?(e=v()||{},c.extend(e,t)):e=a("local"),n=u(e),void 0===D&&(D=w),n!==D&&(e.save_time=(new Date).getTime(),e.status=c("#post_status").val()||"",(o=f(e))&&(D=n),o))}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,a=v(),i=wpCookies.get("wp-saving-post"),s=c("#has-newer-autosave").parent(".notice"),r=c(".wp-header-end");if(i===S+"-saved")return wpCookies.remove("wp-saving-post"),void f(!1);a&&(t=c("#content").val()||"",e=c("#title").val()||"",n=c("#excerpt").val()||"",g(t,a.content)&&g(e,a.post_title)&&g(n,a.excerpt)||(r.length||(r=c(".wrap h1, .wrap h2").first()),o=c("#local-storage-notice").insertAfter(r).addClass("notice-warning"),s.length?s.slideUp(150,function(){o.slideDown(150)}):o.slideDown(200),o.find(".restore-backup").on("click.autosave-local",function(){!function(t){var e;if(t)return D=u(t),c("#title").val()!==t.post_title&&c("#title").focus().val(t.post_title||""),c("#excerpt").val(t.excerpt||""),(e=p())&&!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||""))}(a),o.fadeTo(250,0,function(){o.slideUp(150)})})))}var w,m,e,h,_,x,y,b,S,k,D,C,I,T;o.wp=o.wp||{},o.wp.autosave=(I=0,(T=c(document)).on("tinymce-editor-init.autosave",function(t,e){"content"===e.id&&o.setTimeout(function(){e.save(),w=u()},1e3)}).ready(function(){w=u()}),{getPostData:a,getCompareString:u,disableButtons:i,enableButtons:n,local:(C=!1,b=void 0!==o.autosaveL10n&&o.autosaveL10n.blog_id,function(){var t=Math.random().toString(),e=!1;try{o.sessionStorage.setItem("wp-test",t),e=o.sessionStorage.getItem("wp-test")===t,o.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(){o.setTimeout(function(){t()},1500)}):t(),o.setInterval(d,15e3),c("form#post").on("submit.autosave-local",function(){var t=p(),e=c("#post_ID").val()||0;t&&!t.isHidden()?t.on("submit",function(){d({post_title:c("#title").val()||"",content:c("#content").val()||"",excerpt:c("#excerpt").val()||""})}):d({post_title:c("#title").val()||"",content:c("#content").val()||"",excerpt:c("#excerpt").val()||""});var n="https:"===o.location.protocol;wpCookies.set("wp-saving-post",e+"-check",86400,!1,!1,n)})}),{hasStorage:k,getSavedPostData:v,save:d,suspend:function(){C=!0},resume:function(){C=!1}}),server:(x=0,y=!1,T.on("heartbeat-send.autosave",function(t,e){var n=function(){var t,e;return!(y||m||!o.autosave())&&!((new Date).getTime()<x)&&(e=u(t=a()),void 0===_&&(_=w),e!==_&&(h=e,s(),i(),T.trigger("wpcountwords",[t.content]).trigger("before-autosave",[t]),t._wpnonce=c("#_wpnonce").val()||"",t))}();n&&(e.wp_autosave=n)}).on("heartbeat-tick.autosave",function(t,e){e.wp_autosave&&function(t){r(),m=!1,_=h,h="",T.trigger("after-autosave",[t]),n(),t.success&&c("#auto_draft").val("")}(e.wp_autosave)}).on("heartbeat-connection-lost.autosave",function(t,e,n){if("timeout"===e||603===n){var o=c("#lost-connection-notice");wp.autosave.local.hasStorage||o.find(".hide-if-no-sessionstorage").hide(),o.show(),i()}}).on("heartbeat-connection-restored.autosave",function(){c("#lost-connection-notice").hide(),n()}).ready(function(){r()}),{tempBlockSave:s,triggerSave:function(){x=0,wp.heartbeat.connectNow()},postChanged:function(){return u()!==w},suspend:function(){y=!0},resume:function(){y=!1}})})}(jQuery,window);