From 787995a1ab711bb5dbcc072a0ce882197e4b2f48 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 26 Apr 2011 01:19:26 +0000 Subject: [PATCH] DFW: remove unneeded JS global, fix screen flash in WebKit, props koopersmith, see #17136 git-svn-id: https://develop.svn.wordpress.org/trunk@17702 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/wp-fullscreen.dev.js | 30 +++++++++++++++--------------- wp-admin/js/wp-fullscreen.js | 2 +- wp-includes/js/autosave.dev.js | 8 ++++---- wp-includes/js/autosave.js | 2 +- wp-includes/script-loader.php | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/wp-admin/js/wp-fullscreen.dev.js b/wp-admin/js/wp-fullscreen.dev.js index 0d9d9a217e..264fcc8274 100644 --- a/wp-admin/js/wp-fullscreen.dev.js +++ b/wp-admin/js/wp-fullscreen.dev.js @@ -1,7 +1,9 @@ /** * PubSub -- A lightweight publish/subscribe implementation. Private use only! */ -var PubSub = function() { +var PubSub, fullscreen, wptitlehint; + +PubSub = function() { this.topics = {}; }; @@ -50,8 +52,6 @@ PubSub.prototype.publish = function( topic, args ) { }; // Distraction Free Writing (wp-fullscreen) access the API globally using the fullscreen variable. -var fullscreen, wp_fullscreen_enabled = false; - (function($){ var api, ps, bounder; @@ -76,7 +76,7 @@ var fullscreen, wp_fullscreen_enabled = false; return; api.block = true; - + setTimeout( function() { api.block = false; }, 500 ); @@ -137,12 +137,12 @@ var fullscreen, wp_fullscreen_enabled = false; } ps.subscribe( 'showToolbar', function() { - api.fade.fadein( api.ui.topbar, 600 ); + api.fade.In( api.ui.topbar, 600 ); $('#wp-fullscreen-body').addClass('wp-fullscreen-focus'); }); ps.subscribe( 'hideToolbar', function() { - api.fade.fadeout( api.ui.topbar, 600 ); + api.fade.Out( api.ui.topbar, 600 ); $('#wp-fullscreen-body').removeClass('wp-fullscreen-focus'); }); @@ -173,11 +173,11 @@ var fullscreen, wp_fullscreen_enabled = false; }); ps.subscribe( 'shown', function() { - api.visible = wp_fullscreen_enabled = true; + api.visible = true; }); ps.subscribe( 'hidden', function() { - api.visible = wp_fullscreen_enabled = false; + api.visible = false; $('#wp_mce_fullscreen').removeAttr('style'); tinyMCE.execCommand('wpFullScreenClose'); }); @@ -222,7 +222,7 @@ var fullscreen, wp_fullscreen_enabled = false; api.ui.element = $('#fullscreen-fader'); api.ui.topbar = $('#fullscreen-topbar'); - if ( 'undefined' != wptitlehint ) + if ( wptitlehint ) wptitlehint('wp-fullscreen-title'); }, @@ -230,11 +230,11 @@ var fullscreen, wp_fullscreen_enabled = false; if ( before ) ps.publish( before ); - api.fade.fadein( api.ui.element, 600, function() { + api.fade.In( api.ui.element, 600, function() { if ( during ) ps.publish( during ); - api.fade.fadeout( api.ui.element, 600, function() { + api.fade.Out( api.ui.element, 600, function() { if ( after ) ps.publish( after ); }) @@ -248,7 +248,7 @@ var fullscreen, wp_fullscreen_enabled = false; // Sensitivity to allow browsers to render the blank element before animating. sensitivity: 100, - fadein: function( element, speed, callback ) { + In: function( element, speed, callback ) { callback = callback || $.noop; speed = speed || 400; @@ -260,10 +260,10 @@ var fullscreen, wp_fullscreen_enabled = false; } element.show(); - setTimeout( function() { element.addClass( 'fade-trigger' ); }, this.sensitivity ); element.one( this.transitionend, function() { callback(); }); + setTimeout( function() { element.addClass( 'fade-trigger' ); }, this.sensitivity ); } else { element.css( 'opacity', 1 ).fadeIn( speed, callback ); } @@ -271,7 +271,7 @@ var fullscreen, wp_fullscreen_enabled = false; return element; }, - fadeout: function( element, speed, callback ) { + Out: function( element, speed, callback ) { callback = callback || $.noop; speed = speed || 400; @@ -280,7 +280,6 @@ var fullscreen, wp_fullscreen_enabled = false; return element; if ( api.fade.transitions ) { - element.removeClass( 'fade-trigger' ); element.one( api.fade.transitionend, function() { if ( element.hasClass('fade-trigger') ) return; @@ -288,6 +287,7 @@ var fullscreen, wp_fullscreen_enabled = false; element.hide(); callback(); }); + setTimeout( function() { element.removeClass( 'fade-trigger' ); }, this.sensitivity ); } else { element.fadeOut( speed, callback ); } diff --git a/wp-admin/js/wp-fullscreen.js b/wp-admin/js/wp-fullscreen.js index 6902ea8a02..e7f7caf0ba 100644 --- a/wp-admin/js/wp-fullscreen.js +++ b/wp-admin/js/wp-fullscreen.js @@ -1 +1 @@ -var PubSub=function(){this.topics={}};PubSub.prototype.subscribe=function(a,b){if(!this.topics[a]){this.topics[a]=[]}this.topics[a].push(b);return b};PubSub.prototype.unsubscribe=function(b,e){var c,a,d=this.topics[b];if(!d){return e||[]}if(e){for(c=0,a=d.length;c0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#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(){};d={errors:true}}if(b.alert){jQuery("#autosave-alert").remove();jQuery("#titlediv").after('

'+b.alert+"

");alert(jQuery("#autosave-alert").text())}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:wp_fullscreen_enabled?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(".ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");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(wp_fullscreen_enabled){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").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("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}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:autosaveL10n.requestFile,success:a})}; \ No newline at end of file +var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,fullscreen;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});if(b(this).attr("id")=="publish"){b("#ajax-loading").css("visibility","visible")}else{b("#draft-ajax-loading").css("visibility","visible")}});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{if(fullscreen&&fullscreen.visible){e=b("#wp-fullscreen-title").val();d=b("#wp_mce_fullscreen").val()}else{e=b("#post #title").val();d=b("#post #content").val()}if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(b("#auto_draft").val()=="1"&¬Saved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#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(){};d={errors:true}}if(b.alert){jQuery("#autosave-alert").remove();jQuery("#titlediv").after('

'+b.alert+"

");alert(jQuery("#autosave-alert").text())}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.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(".ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");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.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").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("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}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:autosaveL10n.requestFile,success:a})}; \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1174b12009..b4d4b7f21f 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -94,7 +94,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' ); $scripts->add_data( 'editor', 'group', 1 ); - $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110424' ); + $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110425' ); $scripts->add_data( 'wp-fullscreen', 'group', 1 ); $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1'); @@ -107,7 +107,7 @@ function wp_default_scripts( &$scripts ) { 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' ) ); - $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110424' ); + $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110425' ); $scripts->add_data( 'autosave', 'group', 1 ); $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20101222' );