Faster hide-if-no-js, if-js-closed, etc. needed when loading scripts in the footer.

git-svn-id: http://svn.automattic.com/wordpress/trunk@10258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-12-27 12:18:38 +00:00
parent 1ff4349ee5
commit b54484f937
16 changed files with 48 additions and 42 deletions

View File

@ -72,7 +72,16 @@ do_action('admin_print_scripts');
do_action("admin_head-$hook_suffix"); do_action("admin_head-$hook_suffix");
do_action('admin_head'); do_action('admin_head');
if ( $is_iphone ) { ?> wp_print_styles('no-js');
?>
<script type="text/javascript">
(function(){
var nojs = document.getElementById('no-js');
nojs.parentNode.removeChild(nojs);
})();
</script>
<?php if ( $is_iphone ) { ?>
<style type="text/css">.row-actions{visibility:visible;}</style> <style type="text/css">.row-actions{visibility:visible;}</style>
<?php } ?> <?php } ?>
</head> </head>

View File

@ -178,7 +178,7 @@ table {
.hidden, .hidden,
.closed .inside, .closed .inside,
.hide-if-no-js { .hide-if-js {
display: none; display: none;
} }

14
wp-admin/css/no-js.css Normal file
View File

@ -0,0 +1,14 @@
/* styles to be used when Javascript is disabled */
.hide-if-no-js {
display: none;
}
.hide-if-js,
.closed .inside {
display: block;
}
.hide-if-js-inline {
display: inline;
}

View File

@ -871,7 +871,7 @@ function postbox_classes( $id, $page ) {
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) { if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) {
if ( !is_array( $closed ) ) return ''; if ( !is_array( $closed ) ) return '';
return in_array( $id, $closed )? 'if-js-closed' : ''; return in_array( $id, $closed )? 'closed' : '';
} else { } else {
return ''; return '';
} }

View File

@ -1,6 +1,4 @@
jQuery(document).ready( function($) { jQuery(document).ready( function($) {
jQuery('.hide-if-no-js').show();
jQuery('.hide-if-js').hide();
var stamp = $('#timestamp').html(); var stamp = $('#timestamp').html();
$('.edit-timestamp').click(function () { $('.edit-timestamp').click(function () {

View File

@ -133,10 +133,6 @@ jQuery(document).ready( function($) {
// pulse // pulse
$('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
// show things that should be visible, hide what should be hidden
$('.hide-if-no-js').removeClass('hide-if-no-js');
$('.hide-if-js').hide();
// Basic form validation // Basic form validation
if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) { if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
$('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );

View File

@ -1,9 +1,6 @@
jQuery( function($) { jQuery( function($) {
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// These widgets are sometimes populated via ajax // These widgets are sometimes populated via ajax
var ajaxWidgets = [ var ajaxWidgets = [
'dashboard_incoming_links', 'dashboard_incoming_links',
@ -37,7 +34,6 @@ var quickPressLoad = function() {
$('#dashboard_quick_press ul').find('li').each( function() { $('#dashboard_quick_press ul').find('li').each( function() {
$('#dashboard_recent_drafts ul').prepend( this ); $('#dashboard_recent_drafts ul').prepend( this );
} ).end().remove(); } ).end().remove();
$(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
tb_init('a.thickbox'); tb_init('a.thickbox');
quickPressLoad(); quickPressLoad();
} ); } );

View File

@ -303,7 +303,6 @@ commentReply = {
$(c).hide() $(c).hide()
$('#replyrow').after(c); $('#replyrow').after(c);
this.o = id = '#comment-'+r.id; this.o = id = '#comment-'+r.id;
$(id+' .hide-if-no-js').removeClass('hide-if-no-js');
this.revert(); this.revert();
this.addEvents($(id)); this.addEvents($(id));
var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';

View File

@ -220,7 +220,6 @@ inlineEditPost = {
if ( 'draft' == $('input[name="post_status"]').val() ) if ( 'draft' == $('input[name="post_status"]').val() )
row.find('td.column-comments').hide(); row.find('td.column-comments').hide();
row.find('.hide-if-no-js').removeClass('hide-if-no-js');
inlineEditPost.addEvents(row); inlineEditPost.addEvents(row);
row.fadeIn(); row.fadeIn();
} else { } else {

View File

@ -36,7 +36,6 @@ inlineEditTax = {
addEvents : function(r) { addEvents : function(r) {
r.each(function() { r.each(function() {
$(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; }); $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
$(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
}); });
}, },
@ -116,7 +115,6 @@ inlineEditTax = {
var row = $(inlineEditTax.what+id); var row = $(inlineEditTax.what+id);
row.hide(); row.hide();
row.find('.hide-if-no-js').removeClass('hide-if-no-js');
inlineEditTax.addEvents(row); inlineEditTax.addEvents(row);
row.fadeIn(); row.fadeIn();
} else } else

View File

@ -1,6 +1,4 @@
jQuery(document).ready( function($) { jQuery(document).ready( function($) {
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
jQuery('#link_name').focus(); jQuery('#link_name').focus();
// postboxes // postboxes

View File

@ -2,9 +2,6 @@ jQuery(document).ready( function($) {
postboxes.add_postbox_toggles('page'); postboxes.add_postbox_toggles('page');
make_slugedit_clickable(); make_slugedit_clickable();
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
var stamp = $('#timestamp').html(); var stamp = $('#timestamp').html();

View File

@ -151,9 +151,6 @@ function tag_init() {
jQuery(document).ready( function($) { jQuery(document).ready( function($) {
tagCloud.init(); tagCloud.init();
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes // postboxes
postboxes.add_postbox_toggles('post'); postboxes.add_postbox_toggles('post');
@ -467,7 +464,6 @@ jQuery(document).ready( function($) {
if ( 'object' == typeof r && r.responses[0] ) { if ( 'object' == typeof r && r.responses[0] ) {
$('#the-comment-list').append( r.responses[0].data ); $('#the-comment-list').append( r.responses[0].data );
$('#the-comment-list .hide-if-no-js').removeClass('hide-if-no-js');
theList = theExtraList = null; theList = theExtraList = null;
$("a[className*=':']").unbind(); $("a[className*=':']").unbind();

View File

@ -670,7 +670,8 @@ p.pagenav {
font-size: 11px; font-size: 11px;
} }
.tablenav .tablenav-pages a, .tablenav-pages span.current { .tablenav .tablenav-pages a,
.tablenav-pages span.current {
text-decoration: none; text-decoration: none;
border: none; border: none;
padding: 3px 6px; padding: 3px 6px;
@ -704,7 +705,8 @@ td.media-icon img {
max-height: 60px; max-height: 60px;
} }
#update-nag, .plugin-update { #update-nag,
.plugin-update {
line-height: 29px; line-height: 29px;
font-size: 12px; font-size: 12px;
text-align: center; text-align: center;
@ -714,7 +716,8 @@ td.media-icon img {
border-top-style: solid; border-top-style: solid;
} }
#update-nag a, .plugin-update a { #update-nag a,
.plugin-update a {
font-size: 1.1em; font-size: 1.1em;
} }

View File

@ -39,6 +39,8 @@ class WP_Styles extends WP_Dependencies {
$media = 'all'; $media = 'all';
$href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle ); $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
$rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
$title = isset($this->registered[$handle]->extra['title']) ? "title='" . attribute_escape( $this->registered[$handle]->extra['title'] ) . "'" : '';
$end_cond = ''; $end_cond = '';
if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) { if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
@ -46,14 +48,14 @@ class WP_Styles extends WP_Dependencies {
$end_cond = "<![endif]-->\n"; $end_cond = "<![endif]-->\n";
} }
echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$href' type='text/css' media='$media' />\n", $handle ); echo apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle' $title href='$href' type='text/css' media='$media' />\n", $handle );
if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) { if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) if ( is_bool( $this->registered[$handle]->extra['rtl'] ) )
$rtl_href = str_replace( '.css', '-rtl.css', $href ); $rtl_href = str_replace( '.css', '-rtl.css', $href );
else else
$rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" ); $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$rtl_href' type='text/css' media='$media' />\n", $handle ); echo apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
} }
echo $end_cond; echo $end_cond;

View File

@ -41,7 +41,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->base_url = $guessurl; $scripts->base_url = $guessurl;
$scripts->default_version = get_bloginfo( 'version' ); $scripts->default_version = get_bloginfo( 'version' );
$scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081210' ); $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081226' );
$scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
$scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' ); $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' );
@ -161,7 +161,7 @@ function wp_default_scripts( &$scripts ) {
'strong' => __('Strong'), 'strong' => __('Strong'),
'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
) ); ) );
$scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081211' ); $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081226' );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array( $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
@ -179,7 +179,7 @@ function wp_default_scripts( &$scripts ) {
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};'
) ); ) );
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081217' ); $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081226' );
$scripts->localize( 'post', 'postL10n', array( $scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'), 'tagsUsed' => __('Tags used on this post:'),
'add' => attribute_escape(__('Add')), 'add' => attribute_escape(__('Add')),
@ -205,7 +205,7 @@ function wp_default_scripts( &$scripts ) {
'published' => __('Published'), 'published' => __('Published'),
'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
) ); ) );
$scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081210' ); $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081226' );
$scripts->localize( 'page', 'postL10n', array( $scripts->localize( 'page', 'postL10n', array(
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'edit' => __('Edit'), 'edit' => __('Edit'),
@ -226,8 +226,8 @@ function wp_default_scripts( &$scripts ) {
'published' => __('Published'), 'published' => __('Published'),
'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
) ); ) );
$scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081210' ); $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081226' );
$scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081210' ); $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081226' );
$scripts->localize( 'comment', 'commentL10n', array( $scripts->localize( 'comment', 'commentL10n', array(
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'edit' => __('Edit'), 'edit' => __('Edit'),
@ -262,7 +262,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' ); $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' );
$scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081210' ); $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081226' );
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'), 'error' => __('Error while saving the changes.'),
'ntdeltitle' => __('Remove From Bulk Edit'), 'ntdeltitle' => __('Remove From Bulk Edit'),
@ -270,7 +270,7 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
) ); ) );
$scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081210' ); $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081226' );
$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'), 'error' => __('Error while saving the changes.'),
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
@ -284,7 +284,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
$scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081210' ); $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081226' );
$scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' ); $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' );
@ -321,7 +321,7 @@ function wp_default_styles( &$styles ) {
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20081210' ); $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20081210' );
$styles->add_data( 'ie', 'conditional', 'gte IE 6' ); $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
$styles->add( 'colors', true, array(), '20081210' ); // Register "meta" stylesheet for admin colors $styles->add( 'colors', true, array(), '20081210' ); // Register "meta" stylesheet for admin colors
$styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way? $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way?
@ -329,7 +329,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210'); $styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210');
$styles->add_data( 'colors-classic', 'rtl', true ); $styles->add_data( 'colors-classic', 'rtl', true );
$styles->add( 'global', '/wp-admin/css/global.css', array(), '20081210' ); $styles->add( 'global', '/wp-admin/css/global.css', array(), '20081226' );
$styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' ); $styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' );
$styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' ); $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' );
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081210' ); $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081210' );
@ -340,6 +340,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'login', '/wp-admin/css/login.css', array(), '20081210' ); $styles->add( 'login', '/wp-admin/css/login.css', array(), '20081210' );
$styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' ); $styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' );
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' ); $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
$styles->add( 'no-js', '/wp-admin/css/no-js.css', array(), '20081225' );
foreach ( $rtl_styles as $rtl_style ) foreach ( $rtl_styles as $rtl_style )
$styles->add_data( $rtl_style, 'rtl', true ); $styles->add_data( $rtl_style, 'rtl', true );