From b54484f93729b33d3f15f86765314758b38f880d Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 27 Dec 2008 12:18:38 +0000 Subject: [PATCH] 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 --- wp-admin/admin-header.php | 11 ++++++++++- wp-admin/css/global.css | 2 +- wp-admin/css/no-js.css | 14 ++++++++++++++ wp-admin/includes/post.php | 2 +- wp-admin/js/comment.js | 2 -- wp-admin/js/common.js | 4 ---- wp-admin/js/dashboard.js | 4 ---- wp-admin/js/edit-comments.js | 1 - wp-admin/js/inline-edit-post.js | 1 - wp-admin/js/inline-edit-tax.js | 2 -- wp-admin/js/link.js | 2 -- wp-admin/js/page.js | 3 --- wp-admin/js/post.js | 4 ---- wp-admin/wp-admin.css | 9 ++++++--- wp-includes/class.wp-styles.php | 6 ++++-- wp-includes/script-loader.php | 23 ++++++++++++----------- 16 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 wp-admin/css/no-js.css diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 33e88732c3..ff9d0928a6 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -72,7 +72,16 @@ do_action('admin_print_scripts'); do_action("admin_head-$hook_suffix"); do_action('admin_head'); -if ( $is_iphone ) { ?> +wp_print_styles('no-js'); +?> + + + diff --git a/wp-admin/css/global.css b/wp-admin/css/global.css index d9c91a343c..db731cef68 100644 --- a/wp-admin/css/global.css +++ b/wp-admin/css/global.css @@ -178,7 +178,7 @@ table { .hidden, .closed .inside, -.hide-if-no-js { +.hide-if-js { display: none; } diff --git a/wp-admin/css/no-js.css b/wp-admin/css/no-js.css new file mode 100644 index 0000000000..2aebacdf57 --- /dev/null +++ b/wp-admin/css/no-js.css @@ -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; +} diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index de18643f25..c64c657978 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -871,7 +871,7 @@ function postbox_classes( $id, $page ) { $current_user = wp_get_current_user(); if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) { if ( !is_array( $closed ) ) return ''; - return in_array( $id, $closed )? 'if-js-closed' : ''; + return in_array( $id, $closed )? 'closed' : ''; } else { return ''; } diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index 7d5055255b..1f15b5be30 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1,6 +1,4 @@ jQuery(document).ready( function($) { - jQuery('.hide-if-no-js').show(); - jQuery('.hide-if-js').hide(); var stamp = $('#timestamp').html(); $('.edit-timestamp').click(function () { diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 67e38d81ac..94d5396a36 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -133,10 +133,6 @@ jQuery(document).ready( function($) { // pulse $('.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 if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) { $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index c99163a649..150c432a7e 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -1,9 +1,6 @@ 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 var ajaxWidgets = [ 'dashboard_incoming_links', @@ -37,7 +34,6 @@ var quickPressLoad = function() { $('#dashboard_quick_press ul').find('li').each( function() { $('#dashboard_recent_drafts ul').prepend( this ); } ).end().remove(); - $(this).find('.hide-if-no-js').removeClass('hide-if-no-js'); tb_init('a.thickbox'); quickPressLoad(); } ); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index e1dd210b74..3c69dcb86a 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -303,7 +303,6 @@ commentReply = { $(c).hide() $('#replyrow').after(c); this.o = id = '#comment-'+r.id; - $(id+' .hide-if-no-js').removeClass('hide-if-no-js'); this.revert(); this.addEvents($(id)); var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; diff --git a/wp-admin/js/inline-edit-post.js b/wp-admin/js/inline-edit-post.js index bda63eb265..d183860847 100644 --- a/wp-admin/js/inline-edit-post.js +++ b/wp-admin/js/inline-edit-post.js @@ -220,7 +220,6 @@ inlineEditPost = { if ( 'draft' == $('input[name="post_status"]').val() ) row.find('td.column-comments').hide(); - row.find('.hide-if-no-js').removeClass('hide-if-no-js'); inlineEditPost.addEvents(row); row.fadeIn(); } else { diff --git a/wp-admin/js/inline-edit-tax.js b/wp-admin/js/inline-edit-tax.js index d5539cc2b2..b4cb34130e 100644 --- a/wp-admin/js/inline-edit-tax.js +++ b/wp-admin/js/inline-edit-tax.js @@ -36,7 +36,6 @@ inlineEditTax = { addEvents : function(r) { r.each(function() { $(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); row.hide(); - row.find('.hide-if-no-js').removeClass('hide-if-no-js'); inlineEditTax.addEvents(row); row.fadeIn(); } else diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js index 9c636a087f..4c5ad09e71 100644 --- a/wp-admin/js/link.js +++ b/wp-admin/js/link.js @@ -1,6 +1,4 @@ jQuery(document).ready( function($) { - // close postboxes that should be closed - jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); jQuery('#link_name').focus(); // postboxes diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 943c1de96b..d0f4e5df73 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -2,9 +2,6 @@ jQuery(document).ready( function($) { postboxes.add_postbox_toggles('page'); 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(); } ); var stamp = $('#timestamp').html(); diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index a8528f3138..5b3782df51 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -151,9 +151,6 @@ function tag_init() { jQuery(document).ready( function($) { tagCloud.init(); - // close postboxes that should be closed - jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); - // postboxes postboxes.add_postbox_toggles('post'); @@ -467,7 +464,6 @@ jQuery(document).ready( function($) { if ( 'object' == typeof r && r.responses[0] ) { $('#the-comment-list').append( r.responses[0].data ); - $('#the-comment-list .hide-if-no-js').removeClass('hide-if-no-js'); theList = theExtraList = null; $("a[className*=':']").unbind(); diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index cc0a9532ff..60de07474e 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -670,7 +670,8 @@ p.pagenav { font-size: 11px; } -.tablenav .tablenav-pages a, .tablenav-pages span.current { +.tablenav .tablenav-pages a, +.tablenav-pages span.current { text-decoration: none; border: none; padding: 3px 6px; @@ -704,7 +705,8 @@ td.media-icon img { max-height: 60px; } -#update-nag, .plugin-update { +#update-nag, +.plugin-update { line-height: 29px; font-size: 12px; text-align: center; @@ -714,7 +716,8 @@ td.media-icon img { border-top-style: solid; } -#update-nag a, .plugin-update a { +#update-nag a, +.plugin-update a { font-size: 1.1em; } diff --git a/wp-includes/class.wp-styles.php b/wp-includes/class.wp-styles.php index 3caf63971e..1286106744 100644 --- a/wp-includes/class.wp-styles.php +++ b/wp-includes/class.wp-styles.php @@ -39,6 +39,8 @@ class WP_Styles extends WP_Dependencies { $media = 'all'; $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 = ''; if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) { @@ -46,14 +48,14 @@ class WP_Styles extends WP_Dependencies { $end_cond = "\n"; } - echo apply_filters( 'style_loader_tag', "\n", $handle ); + echo apply_filters( 'style_loader_tag', "\n", $handle ); if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) { if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) $rtl_href = str_replace( '.css', '-rtl.css', $href ); else $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" ); - echo apply_filters( 'style_loader_tag', "\n", $handle ); + echo apply_filters( 'style_loader_tag', "\n", $handle ); } echo $end_cond; diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index c4ee380b7d..1f1d6fb727 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -41,7 +41,7 @@ function wp_default_scripts( &$scripts ) { $scripts->base_url = $guessurl; $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( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' ); @@ -161,7 +161,7 @@ function wp_default_scripts( &$scripts ) { 'strong' => __('Strong'), '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( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) @@ -179,7 +179,7 @@ function wp_default_scripts( &$scripts ) { 'cancel' => __('Cancel'), '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( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), @@ -205,7 +205,7 @@ function wp_default_scripts( &$scripts ) { 'published' => __('Published'), '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( 'cancel' => __('Cancel'), 'edit' => __('Edit'), @@ -226,8 +226,8 @@ function wp_default_scripts( &$scripts ) { 'published' => __('Published'), '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( 'comment', '/wp-admin/js/comment.js', array('jquery'), '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'), '20081226' ); $scripts->localize( 'comment', 'commentL10n', array( 'cancel' => __('Cancel'), '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( '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( 'error' => __('Error while saving the changes.'), 'ntdeltitle' => __('Remove From Bulk Edit'), @@ -270,7 +270,7 @@ function wp_default_scripts( &$scripts ) { '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( 'error' => __('Error while saving the changes.'), '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( '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' ); @@ -321,7 +321,7 @@ function wp_default_styles( &$styles ) { $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); $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-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_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( 'widgets', '/wp-admin/css/widgets.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( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' ); $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 ) $styles->add_data( $rtl_style, 'rtl', true );