mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-17 20:15:08 +00:00
This updates the 3.7 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy. Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401). This change also introduces a `packager-lock.json` file to the branch. In addition to backporting the package updates that happened after branching 3.7, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [27053,27299,27721,27848,28796,29270,30060,30062-30063,30066,31557,31650,32356,32988,33726,35513,35521,35538,35540-35541,36861-36865,37019-37020,37212,37612,38111,39113,39115-39117,39478,42460-42461,42887,42989,43320,43323,43977,44219,45446,45765,46408-46409,47867,47872,48705,49636,49933,49939,50185] to the 3.7 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/3.7@50224 git-svn-id: http://core.svn.wordpress.org/branches/3.7@49888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
var autosave,autosavePeriodical,fullscreen,autosaveLast="",autosaveDelayPreview=!1,notSaved=!0,blockSave=!1,autosaveLockRelease=!0;function autosave_parse_response(t){var e,t=wpAjax.parseAjaxResponse(t,"autosave");return t&&t.responses&&t.responses.length&&(t.responses[0].supplemental&&(e=t.responses[0].supplemental,jQuery.each(e,function(t,e){t.match(/^replace-/)&&jQuery("#"+t.replace("replace-","")).val(e)})),t.errors||((e=parseInt(t.responses[0].id,10))&&autosave_update_slug(e),t.responses[0].data&&jQuery(".autosave-message").text(t.responses[0].data))),t}function autosave_saved(t){blockSave=!1,autosave_parse_response(t),autosave_enable_buttons()}function autosave_saved_new(t){blockSave=!1;t=autosave_parse_response(t);t&&t.responses.length&&!t.errors?(parseInt(t.responses[0].id,10)&&(notSaved=!1,jQuery("#auto_draft").val("0")),autosave_enable_buttons(),autosaveDelayPreview&&(autosaveDelayPreview=!1,doPreview())):autosave_enable_buttons()}function autosave_update_slug(t){"undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()&&jQuery.post(ajaxurl,{action:"sample-permalink",post_id:t,new_title:(fullscreen&&fullscreen.settings.visible?jQuery("#wp-fullscreen-title"):jQuery("#title")).val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(t){var e;"-1"!==t&&((e=jQuery("#edit-slug-box")).html(t),e.hasClass("hidden")&&e.fadeIn("fast",function(){e.removeClass("hidden")}),makeSlugeditClickable())})}function autosave_loading(){jQuery(".autosave-message").html(autosaveL10n.savingText)}function autosave_enable_buttons(){jQuery(document).trigger("autosave-enable-buttons"),wp.heartbeat&&wp.heartbeat.hasConnectionError()||setTimeout(function(){var t=jQuery("#submitpost");t.find(":button, :submit").removeAttr("disabled"),t.find(".spinner").hide()},500)}function autosave_disable_buttons(){jQuery(document).trigger("autosave-disable-buttons"),jQuery("#submitpost").find(":button, :submit").prop("disabled",!0),setTimeout(autosave_enable_buttons,5e3)}function delayed_autosave(){setTimeout(function(){blockSave||autosave()},200)}jQuery(document).ready(function(o){autosaveLast=o("#wp-content-wrap").hasClass("tmce-active")&&"undefined"!=typeof switchEditors?wp.autosave.getCompareString({post_title:o("#title").val()||"",content:switchEditors.pre_wpautop(o("#content").val())||"",excerpt:o("#excerpt").val()||""}):wp.autosave.getCompareString(),autosavePeriodical=o.schedule({time:1e3*autosaveL10n.autosaveInterval,func:function(){autosave()},repeat:!0,protect:!0}),o("#post").submit(function(){o.cancel(autosavePeriodical),autosaveLockRelease=!1}),o('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=!0,window.onbeforeunload=null,o(":button, :submit","#submitpost").each(function(){var t=o(this);t.hasClass("button-primary")?t.addClass("button-primary-disabled"):t.addClass("button-disabled")}),("publish"==o(this).attr("id")?o("#major-publishing-actions .spinner"):o("#minor-publishing .spinner")).show()}),window.onbeforeunload=function(){var t="undefined"!=typeof tinymce&&tinymce.activeEditor;if(t&&!t.isHidden()){if(t.isDirty())return autosaveL10n.saveAlert}else if((fullscreen&&fullscreen.settings.visible?wp.autosave.getCompareString({post_title:o("#wp-fullscreen-title").val()||"",content:o("#wp_mce_fullscreen").val()||"",excerpt:o("#excerpt").val()||""}):wp.autosave.getCompareString())!=autosaveLast)return autosaveL10n.saveAlert},o(window).unload(function(t){autosaveLockRelease&&(t.target&&"#document"!=t.target.nodeName||o.ajax({type:"POST",url:ajaxurl,async:!1,data:{action:"wp-remove-post-lock",_wpnonce:o("#_wpnonce").val(),post_ID:o("#post_ID").val(),active_post_lock:o("#active_post_lock").val()}}))}),o("#post-preview").click(function(){return"1"==o("#auto_draft").val()&¬Saved?(autosaveDelayPreview=!0,autosave()):doPreview(),!1}),doPreview=function(){o("input#wp-preview").val("dopreview"),o("form#post").attr("target","wp-preview").submit().attr("target","");var t=navigator.userAgent.toLowerCase();-1!=t.indexOf("safari")&&-1==t.indexOf("chrome")&&o("form#post").attr("action",function(t,e){return e+"?t="+(new Date).getTime()}),o("input#wp-preview").val("")},o("#title").on("keydown.editor-focus",function(t){var e;9==t.which&&(t.ctrlKey||t.altKey||t.shiftKey||((e="undefined"!=typeof tinymce?tinymce.get("content"):e)&&!e.isHidden()?o(this).one("keyup",function(t){o("#content_tbl td.mceToolbar > a").focus()}):o("#content").focus(),t.preventDefault()))}),"1"==o("#auto_draft").val()&&o("#title").blur(function(){this.value&&"1"==o("#auto_draft").val()&&delayed_autosave()}),o(document).on("heartbeat-connection-lost.autosave",function(t,e,a){"timeout"!==e&&503!=a||(a=o("#lost-connection-notice"),wp.autosave.local.hasStorage||a.find(".hide-if-no-sessionstorage").hide(),a.show(),autosave_disable_buttons())}).on("heartbeat-connection-restored.autosave",function(){o("#lost-connection-notice").hide(),autosave_enable_buttons()})}),autosave=function(){var t,e=wp.autosave.getPostData();return blockSave=!0,!!e.autosave&&("block"!=jQuery("#TB_window").css("display")&&((t=wp.autosave.getCompareString(e))!=autosaveLast&&(autosaveLast=t,jQuery(document).triggerHandler("wpcountwords",[e.content]),autosave_disable_buttons(),t="1"==e.auto_draft?autosave_saved_new:autosave_saved,jQuery.ajax({data:e,beforeSend:autosave_loading,type:"POST",url:ajaxurl,success:t}),!0)))},window.wp=window.wp||{},wp.autosave=wp.autosave||{},function(i){wp.autosave.getPostData=function(){var t="undefined"!=typeof tinymce?tinymce.activeEditor:null,e=[],a={action:"autosave",autosave:!0,post_id:i("#post_ID").val()||0,autosavenonce:i("#autosavenonce").val()||"",post_type:i("#post_type").val()||"",post_author:i("#post_author").val()||"",excerpt:i("#excerpt").val()||""};if(t&&!t.isHidden()){if(t.plugins.spellchecker&&t.plugins.spellchecker.active)return a.autosave=!1,a;"mce_fullscreen"==t.id&&tinymce.get("content").setContent(t.getContent({format:"raw"}),{format:"raw"}),tinymce.triggerSave()}return void 0!==fullscreen&&fullscreen.settings.visible?(a.post_title=i("#wp-fullscreen-title").val()||"",a.content=i("#wp_mce_fullscreen").val()||""):(a.post_title=i("#title").val()||"",a.content=i("#content").val()||""),i('input[id^="in-category-"]:checked').each(function(){e.push(this.value)}),a.catslist=e.join(","),(t=i("#post_name").val())&&(a.post_name=t),(t=i("#parent_id").val())&&(a.parent_id=t),i("#comment_status").prop("checked")&&(a.comment_status="open"),i("#ping_status").prop("checked")&&(a.ping_status="open"),"1"==i("#auto_draft").val()&&(a.auto_draft="1"),a},wp.autosave.getCompareString=function(t){return"object"==typeof t?(t.post_title||"")+"::"+(t.content||"")+"::"+(t.excerpt||""):(i("#title").val()||"")+"::"+(i("#content").val()||"")+"::"+(i("#excerpt").val()||"")},wp.autosave.local={lastSavedData:"",blog_id:0,hasStorage:!1,checkStorage:function(){var t=Math.random(),e=!1;try{sessionStorage.setItem("wp-test",t),e=sessionStorage.getItem("wp-test")==t,sessionStorage.removeItem("wp-test")}catch(t){}return this.hasStorage=e},getStorage:function(){var t=!1;return t=this.hasStorage&&this.blog_id?(t=sessionStorage.getItem("wp-autosave-"+this.blog_id))?JSON.parse(t):{}:t},setStorage:function(t){var e;return!(!this.hasStorage||!this.blog_id)&&(e="wp-autosave-"+this.blog_id,sessionStorage.setItem(e,JSON.stringify(t)),null!==sessionStorage.getItem(e))},getData:function(){var t=this.getStorage(),e=i("#post_ID").val();return t&&e&&t["post_"+e]||!1},setData:function(t){var e=this.getStorage(),a=i("#post_ID").val();if(!e||!a)return!1;if(t)e["post_"+a]=t;else{if(!e.hasOwnProperty("post_"+a))return!1;delete e["post_"+a]}return this.setStorage(e)},save:function(t){var e,a;return t?(a=this.getData()||{},i.extend(a,t),a.autosave=!0):a=wp.autosave.getPostData(),!!a.autosave&&((t=wp.autosave.getCompareString(a))!=this.lastSavedData&&(a.save_time=(new Date).getTime(),a.status=i("#post_status").val()||"",(e=this.setData(a))&&(this.lastSavedData=t),e))},init:function(t){var e=this;this.checkStorage()&&(i("#content").length||i("#excerpt").length)&&(t&&i.extend(this,t),this.blog_id||(this.blog_id=void 0!==window.autosaveL10n?window.autosaveL10n.blog_id:0),i(document).ready(function(){e.run()}))},run:function(){var a=this;this.checkPost(),this.schedule=i.schedule({time:15e3,func:function(){wp.autosave.local.save()},repeat:!0,protect:!0}),i("form#post").on("submit.autosave-local",function(){var t="undefined"!=typeof tinymce&&tinymce.get("content"),e=i("#post_ID").val()||0;t&&!t.isHidden()?t.onSubmit.add(function(){wp.autosave.local.save({post_title:i("#title").val()||"",content:i("#content").val()||"",excerpt:i("#excerpt").val()||""})}):a.save({post_title:i("#title").val()||"",content:i("#content").val()||"",excerpt:i("#excerpt").val()||""}),wpCookies.set("wp-saving-post-"+e,"check")})},compare:function(t,e){function a(t){return t.toString().replace(/[\x20\t\r\n\f]+/g,"")}return a(t||"")==a(e||"")},checkPost:function(){var t,e,a=this,o=this.getData(),s=i("#post_ID").val()||0,n=wpCookies.get("wp-saving-post-"+s);o&&(n&&(wpCookies.remove("wp-saving-post-"+s),"saved"==n)?this.setData(!1):i("#has-newer-autosave").length||(t=i("#content").val()||"",e=i("#title").val()||"",s=i("#excerpt").val()||"",i("#wp-content-wrap").hasClass("tmce-active")&&"undefined"!=typeof switchEditors&&(t=switchEditors.pre_wpautop(t)),"check"!=n&&this.compare(t,o.content)&&this.compare(e,o.post_title)&&this.compare(s,o.excerpt)||(this.restore_post_data=o,this.undo_post_data={content:t,post_title:e,excerpt:s},s=i("#local-storage-notice"),i(".wrap h2").first().after(s.addClass("updated").show()),s.on("click",function(t){var e=i(t.target);e.hasClass("restore-backup")?(a.restorePost(a.restore_post_data),e.parent().hide(),i(this).find("p.undo-restore").show()):e.hasClass("undo-restore-backup")&&(a.restorePost(a.undo_post_data),e.parent().hide(),i(this).find("p.local-restore").show()),t.preventDefault()}))))},restorePost:function(t){var e;return!!t&&(this.lastSavedData=wp.autosave.getCompareString(t),i("#title").val()!=t.post_title&&i("#title").focus().val(t.post_title||""),i("#excerpt").val(t.excerpt||""),(e="undefined"!=typeof tinymce&&tinymce.get("content"))&&!e.isHidden()&&"undefined"!=typeof switchEditors?(e.undoManager.add(),e.setContent(t.content?switchEditors.wpautop(t.content):"")):(i("#content-html").click(),i("#content").val(t.content)),!0)}},wp.autosave.local.init()}(jQuery); |