]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/autosave.min.js
WordPress 4.7
[autoinstalls/wordpress.git] / wp-includes / js / autosave.min.js
index 864401f630710a93dd29063366a7313bedf5ab75..f88edf4bf3f96f1e4a7c10356cc48bf4f9f36d19 100644 (file)
@@ -1 +1 @@
-var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,fullscreen,autosaveLockRelease=true;jQuery(document).ready(function(a){autosaveLast=(a("#post #title").val()||"")+(a("#post #content").val()||"");autosavePeriodical=a.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});a("#post").submit(function(){a.cancel(autosavePeriodical);autosaveLockRelease=false});a('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;a(":button, :submit","#submitpost").each(function(){var b=a(this);if(b.hasClass("button-primary")){b.addClass("button-primary-disabled")}else{b.addClass("button-disabled")}});if(a(this).attr("id")=="publish"){a("#major-publishing-actions .spinner").show()}else{a("#minor-publishing .spinner").show()}});window.onbeforeunload=function(){var b=typeof(tinymce)!="undefined"?tinymce.activeEditor:false,d,c;if(b&&!b.isHidden()){if(b.isDirty()){return autosaveL10n.saveAlert}}else{if(fullscreen&&fullscreen.settings.visible){d=a("#wp-fullscreen-title").val()||"";c=a("#wp_mce_fullscreen").val()||""}else{d=a("#post #title").val()||"";c=a("#post #content").val()||""}if((d||c)&&d+c!=autosaveLast){return autosaveL10n.saveAlert}}};a(window).unload(function(b){if(!autosaveLockRelease){return}if(b.target&&b.target.nodeName!="#document"){return}a.ajax({type:"POST",url:ajaxurl,async:false,data:{action:"wp-remove-post-lock",_wpnonce:a("#_wpnonce").val(),post_ID:a("#post_ID").val(),active_post_lock:a("#active_post_lock").val()}})});a("#post-preview").click(function(){if(a("#auto_draft").val()=="1"&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){a("input#wp-preview").val("dopreview");a("form#post").attr("target","wp-preview").submit().attr("target","");if(a.browser.safari){a("form#post").attr("action",function(b,c){return c+"?t="+new Date().getTime()})}a("input#wp-preview").val("")};a("#title").on("keydown.editor-focus",function(c){var b;if(c.which!=9){return}if(!c.ctrlKey&&!c.altKey&&!c.shiftKey){if(typeof(tinymce)!="undefined"){b=tinymce.get("content")}if(b&&!b.isHidden()){a(this).one("keyup",function(d){a("#content_tbl td.mceToolbar > a").focus()})}else{a("#content").focus()}c.preventDefault()}});if("1"==a("#auto_draft").val()){a("#title").blur(function(){if(!this.value||a("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var d=wpAjax.parseAjaxResponse(c,"autosave"),e="",a,b;if(d&&d.responses&&d.responses.length){e=d.responses[0].data;if(d.responses[0].supplemental){b=d.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};autosaveLockRelease=false;d={errors:true}}if(b["active-post-lock"]){jQuery("#active_post_lock").val(b["active-post-lock"])}if(b.alert){jQuery("#autosave-alert").remove();jQuery("#titlediv").after('<div id="autosave-alert" class="error below-h2"><p>'+b.alert+"</p></div>")}jQuery.each(b,function(f,g){if(f.match(/^replace-/)){jQuery("#"+f.replace("replace-","")).val(g)}})}if(!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(e){jQuery(".autosave-message").html(e)}else{if(autosaveOldMessage&&d){jQuery(".autosave-message").html(autosaveOldMessage)}}return d}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var c=autosave_parse_response(b),a;if(c&&c.responses.length&&!c.errors){a=parseInt(c.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:fullscreen&&fullscreen.settings.visible?jQuery("#wp-fullscreen-title").val():jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){if(b!=="-1"){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()}})}}function autosave_loading(){jQuery(".autosave-message").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery(".spinner","#submitpost").hide()},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").prop("disabled",true);setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinymce!="undefined")&&tinymce.activeEditor&&!tinymce.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinymce.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id||"wp_mce_fullscreen"==b.id){tinymce.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinymce.triggerSave()}}if(fullscreen&&fullscreen.settings.visible){d.post_title=jQuery("#wp-fullscreen-title").val()||"";d.content=jQuery("#wp_mce_fullscreen").val()||""}else{d.post_title=jQuery("#title").val()||"";d.content=jQuery("#content").val()||""}if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").prop("checked")){d.comment_status="open"}if(jQuery("#ping_status").prop("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=d.post_title+d.content;jQuery(document).triggerHandler("wpcountwords",[d.content])}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:ajaxurl,success:a})};
\ No newline at end of file
+window.autosave=function(){return!0},function(a,b){function c(){function c(b){var c,d,e,f=(new Date).getTime(),h=[],i=g();return i&&i.isDirty()&&!i.isHidden()&&f-3e3>k&&(i.save(),k=f),e={post_id:a("#post_ID").val()||0,post_type:a("#post_type").val()||"",post_author:a("#post_author").val()||"",post_title:a("#title").val()||"",content:a("#content").val()||"",excerpt:a("#excerpt").val()||""},"local"===b?e:(a('input[id^="in-category-"]:checked').each(function(){h.push(this.value)}),e.catslist=h.join(","),(c=a("#post_name").val())&&(e.post_name=c),(d=a("#parent_id").val())&&(e.parent_id=d),a("#comment_status").prop("checked")&&(e.comment_status="open"),a("#ping_status").prop("checked")&&(e.ping_status="open"),"1"===a("#auto_draft").val()&&(e.auto_draft="1"),e)}function d(b){return"object"==typeof b?(b.post_title||"")+"::"+(b.content||"")+"::"+(b.excerpt||""):(a("#title").val()||"")+"::"+(a("#content").val()||"")+"::"+(a("#excerpt").val()||"")}function e(){l.trigger("autosave-disable-buttons"),setTimeout(f,5e3)}function f(){l.trigger("autosave-enable-buttons")}function g(){return"undefined"!=typeof tinymce&&tinymce.get("content")}function h(){function e(){var a=Math.random().toString(),c=!1;try{b.sessionStorage.setItem("wp-test",a),c=b.sessionStorage.getItem("wp-test")===a,b.sessionStorage.removeItem("wp-test")}catch(d){}return v=c,c}function f(){var a=!1;return v&&t&&(a=sessionStorage.getItem("wp-autosave-"+t),a=a?JSON.parse(a):{}),a}function h(a){var b;return!(!v||!t)&&(b="wp-autosave-"+t,sessionStorage.setItem(b,JSON.stringify(a)),null!==sessionStorage.getItem(b))}function i(){var a=f();return!(!a||!u)&&(a["post_"+u]||!1)}function k(a){var b=f();if(!b||!u)return!1;if(a)b["post_"+u]=a;else{if(!b.hasOwnProperty("post_"+u))return!1;delete b["post_"+u]}return h(b)}function m(){y=!0}function n(){y=!1}function o(b){var e,f,g=!1;return!(y||!v)&&(b?(e=i()||{},a.extend(e,b)):e=c("local"),f=d(e),"undefined"==typeof x&&(x=j),f!==x&&(e.save_time=(new Date).getTime(),e.status=a("#post_status").val()||"",g=k(e),g&&(x=f),g))}function p(){u=a("#post_ID").val()||0,a("#wp-content-wrap").hasClass("tmce-active")?l.on("tinymce-editor-init.autosave",function(){b.setTimeout(function(){r()},1500)}):r(),w=b.setInterval(o,15e3),a("form#post").on("submit.autosave-local",function(){var c=g(),d=a("#post_ID").val()||0;c&&!c.isHidden()?c.on("submit",function(){o({post_title:a("#title").val()||"",content:a("#content").val()||"",excerpt:a("#excerpt").val()||""})}):o({post_title:a("#title").val()||"",content:a("#content").val()||"",excerpt:a("#excerpt").val()||""});var e="https:"===b.location.protocol;wpCookies.set("wp-saving-post",d+"-check",86400,!1,!1,e)})}function q(a,b){function c(a){return a.toString().replace(/[\x20\t\r\n\f]+/g,"")}return c(a||"")===c(b||"")}function r(){var b,c,d,e,f=i(),g=wpCookies.get("wp-saving-post"),h=a("#has-newer-autosave").parent(".notice"),j=a(".wp-header-end");return g===u+"-saved"?(wpCookies.remove("wp-saving-post"),void k(!1)):void(f&&(b=a("#content").val()||"",c=a("#title").val()||"",d=a("#excerpt").val()||"",q(b,f.content)&&q(c,f.post_title)&&q(d,f.excerpt)||(j.length||(j=a(".wrap h1, .wrap h2").first()),e=a("#local-storage-notice").insertAfter(j).addClass("notice-warning"),h.length?h.slideUp(150,function(){e.slideDown(150)}):e.slideDown(200),e.find(".restore-backup").on("click.autosave-local",function(){s(f),e.fadeTo(250,0,function(){e.slideUp(150)})}))))}function s(b){var c;return!!b&&(x=d(b),a("#title").val()!==b.post_title&&a("#title").focus().val(b.post_title||""),a("#excerpt").val(b.excerpt||""),c=g(),c&&!c.isHidden()&&"undefined"!=typeof switchEditors?(c.settings.wpautop&&b.content&&(b.content=switchEditors.wpautop(b.content)),c.undoManager.transact(function(){c.setContent(b.content||""),c.nodeChanged()})):(a("#content-html").click(),a("#content").focus(),document.execCommand("selectAll"),document.execCommand("insertText",!1,b.content||"")),!0)}var t,u,v,w,x,y=!1;return t="undefined"!=typeof b.autosaveL10n&&b.autosaveL10n.blog_id,e()&&t&&(a("#content").length||a("#excerpt").length)&&l.ready(p),{hasStorage:v,getSavedPostData:i,save:o,suspend:m,resume:n}}function i(){function g(){q=!0,b.clearTimeout(r),r=b.setTimeout(function(){q=!1},1e4)}function h(){v=!0}function i(){v=!1}function k(b){p(),q=!1,t=s,s="",l.trigger("after-autosave",[b]),f(),b.success&&a("#auto_draft").val("")}function m(){u=0,wp.heartbeat.connectNow()}function n(){return d()!==j}function o(){var f,h;return!(v||q||!b.autosave())&&(!((new Date).getTime()<u)&&(f=c(),h=d(f),"undefined"==typeof t&&(t=j),h!==t&&(s=h,g(),e(),l.trigger("wpcountwords",[f.content]).trigger("before-autosave",[f]),f._wpnonce=a("#_wpnonce").val()||"",f)))}function p(){u=(new Date).getTime()+1e3*autosaveL10n.autosaveInterval||6e4}var q,r,s,t,u=0,v=!1;return l.on("heartbeat-send.autosave",function(a,b){var c=o();c&&(b.wp_autosave=c)}).on("heartbeat-tick.autosave",function(a,b){b.wp_autosave&&k(b.wp_autosave)}).on("heartbeat-connection-lost.autosave",function(b,c,d){if("timeout"===c||603===d){var f=a("#lost-connection-notice");wp.autosave.local.hasStorage||f.find(".hide-if-no-sessionstorage").hide(),f.show(),e()}}).on("heartbeat-connection-restored.autosave",function(){a("#lost-connection-notice").hide(),f()}).ready(function(){p()}),{tempBlockSave:g,triggerSave:m,postChanged:n,suspend:h,resume:i}}var j,k=0,l=a(document);return l.on("tinymce-editor-init.autosave",function(a,c){"content"===c.id&&b.setTimeout(function(){c.save(),j=d()},1e3)}).ready(function(){j=d()}),{getPostData:c,getCompareString:d,disableButtons:e,enableButtons:f,local:h(),server:i()}}b.wp=b.wp||{},b.wp.autosave=c()}(jQuery,window);
\ No newline at end of file