From e6f396880b0f89601f066765614561c51ae70621 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Wed, 26 Mar 2008 20:06:18 +0000 Subject: [PATCH] Clean up the Write Post/Write Page/Edit Comment screens for people without JS. Introduce the hide-if-no-js and hide-if-js automagical classes. fixes #6395 git-svn-id: http://svn.automattic.com/wordpress/trunk@7529 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/global.css | 4 ---- wp-admin/edit-form-advanced.php | 8 ++++---- wp-admin/edit-form-comment.php | 4 ++-- wp-admin/edit-page-form.php | 4 ++-- wp-admin/includes/post.php | 4 ++-- wp-admin/js/comment.js | 14 ++++++++++++++ wp-admin/js/page.js | 7 +++++++ wp-admin/js/post.js | 7 +++++++ wp-admin/wp-admin.css | 6 +++++- wp-includes/general-template.php | 2 +- wp-includes/script-loader.php | 4 ++++ 11 files changed, 48 insertions(+), 16 deletions(-) diff --git a/wp-admin/css/global.css b/wp-admin/css/global.css index 150461ad72..3ed3b46fa7 100644 --- a/wp-admin/css/global.css +++ b/wp-admin/css/global.css @@ -194,7 +194,3 @@ th.check-column + th, th.check-column + td { padding-bottom: 7px; padding-right: 280px; } - -#timestampdiv { - display: none; -} diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 0522933c48..b4355f93d9 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -121,9 +121,9 @@ if ($post_ID) { ?>

-
+
@@ -205,7 +205,7 @@ endif; ?> -
+

@@ -218,7 +218,7 @@ endif; ?>
-

+

0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index 15b8768027..c59a5774ec 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -37,9 +37,9 @@ $date = mysql2date(get_option('date_format'), $comment->comment_date); $time = mysql2date(get_option('time_format'), $comment->comment_date); ?>

-
+
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index 4c80ee5bdc..1a4025fc7d 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -106,9 +106,9 @@ if ($post_ID) { } ?>

-
+
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 63a77f4277..2ee6210b5b 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -589,10 +589,10 @@ function postbox_classes( $id, $page ) { $current_user = wp_get_current_user(); if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) { if ( !is_array( $closed ) ) return ''; - return in_array( $id, $closed )? 'closed' : ''; + return in_array( $id, $closed )? 'if-js-closed' : ''; } else { if ( 'tagsdiv' == $id || 'categorydiv' == $id ) return ''; - else return 'closed'; + else return 'if-js-closed'; } } diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index ddb54a5ee5..11a362765c 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1,11 +1,25 @@ jQuery(document).ready( function() { add_postbox_toggles('comment'); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(commentL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(commentL10n.edit); } return false; }); diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 6f549724c8..2a91e3397a 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -2,6 +2,13 @@ jQuery(document).ready( function() { add_postbox_toggles('page'); make_slugedit_clickable(); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); // hide advanced slug field diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 9dd6fd50a4..78b22ed911 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -59,6 +59,13 @@ function tag_press_key( e ) { } jQuery(document).ready( function() { + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + // postboxes add_postbox_toggles('post'); diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index ee08758d71..fd39c638e7 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -1455,4 +1455,8 @@ td.action-links, th.action-links { #poststuff h3, #poststuff .closed h3 { cursor: pointer; -} \ No newline at end of file +} + +.hide-if-no-js { + display: none; +} \ No newline at end of file diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index b42d7ce95b..301ae9c196 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -940,7 +940,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title', $media_button } if ( $media_buttons ) { ?> -
+
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 2aa53e58d9..7c89dc5005 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -160,6 +160,10 @@ class WP_Scripts { ) ); $this->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' ); $this->add( 'comment', '/wp-admin/js/comment.js', array('postbox'), '20080219' ); + $this->localize( 'comment', 'commentL10n', array( + 'cancel' => __('Cancel'), + 'edit' => __('Edit'), + ) ); $this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' ); $this->localize( 'upload', 'uploadL10n', array( 'browseTitle' => attribute_escape(__('Browse your files')),