mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Save toggle box open/closed state. Props nbachiyski. fixes #5610
git-svn-id: http://svn.automattic.com/wordpress/trunk@6584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a4f050e486
commit
d3e7affa4b
@ -441,6 +441,13 @@ case 'autosave-generate-nonces' :
|
||||
}
|
||||
die('0');
|
||||
break;
|
||||
case 'closed-postboxes' :
|
||||
check_ajax_referer( $action );
|
||||
$closed = explode(',', $_POST['closed']);
|
||||
if (!is_array($closed)) break;
|
||||
$current_user = wp_get_current_user();
|
||||
update_usermeta($current_user->ID, 'closedpostboxes', $closed);
|
||||
break;
|
||||
default :
|
||||
do_action( 'wp_ajax_' . $_POST['action'] );
|
||||
die('0');
|
||||
|
@ -110,7 +110,7 @@ else
|
||||
echo clean_url(stripslashes(wp_get_referer()));
|
||||
?>" /></p>
|
||||
|
||||
<div id="tagsdiv" class="postbox">
|
||||
<div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv'); ?>">
|
||||
<h3><?php _e('Tags'); ?></h3>
|
||||
<div class="inside">
|
||||
<p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p>
|
||||
@ -118,7 +118,7 @@ else
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="categorydiv" class="postbox">
|
||||
<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv'); ?>">
|
||||
<h3><?php _e('Categories') ?></h3>
|
||||
<div class="inside">
|
||||
<p id="jaxcat"><?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?></p>
|
||||
@ -140,12 +140,12 @@ if (current_user_can('upload_files') && false) {
|
||||
|
||||
<h2><?php _e('Advanced Options'); ?></h2>
|
||||
|
||||
<div id="postexcerpt" class="postbox">
|
||||
<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt'); ?>">
|
||||
<h3><?php _e('Optional Excerpt') ?></h3>
|
||||
<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
|
||||
</div>
|
||||
|
||||
<div id="trackbacksdiv" class="postbox">
|
||||
<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv'); ?>">
|
||||
<h3><?php _e('Trackbacks') ?></h3>
|
||||
<div class="inside">
|
||||
<?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?> (<?php _e('Separate multiple URLs with spaces'); ?>)
|
||||
@ -156,7 +156,7 @@ if ( ! empty($pings) )
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="postcustom" class="postbox">
|
||||
<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom'); ?>">
|
||||
<h3><?php _e('Custom Fields') ?></h3>
|
||||
<div class="inside">
|
||||
<div id="postcustomstuff">
|
||||
@ -177,7 +177,7 @@ list_meta($metadata);
|
||||
|
||||
<?php do_action('dbx_post_advanced'); ?>
|
||||
|
||||
<div id="commentstatusdiv" class="postbox">
|
||||
<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv'); ?>">
|
||||
<h3><?php _e('Discussion') ?></h3>
|
||||
<div class="inside">
|
||||
<input name="advanced_view" type="hidden" value="1" />
|
||||
@ -188,21 +188,21 @@ list_meta($metadata);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="passworddiv" class="postbox">
|
||||
<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv'); ?>">
|
||||
<h3><?php _e('Post Password') ?></h3>
|
||||
<div class="inside">
|
||||
<input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="slugdiv" class="postbox">
|
||||
<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv'); ?>">
|
||||
<h3><?php _e('Post Slug') ?></h3>
|
||||
<div class="inside">
|
||||
<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="poststatusdiv" class="postbox">
|
||||
<div id="poststatusdiv" class="postbox <?php echo postbox_classes('poststatusdiv'); ?>">
|
||||
<h3><?php _e('Post Status') ?></h3>
|
||||
<div class="inside">
|
||||
<?php if ( current_user_can('publish_posts') ) : ?>
|
||||
@ -215,7 +215,7 @@ list_meta($metadata);
|
||||
</div>
|
||||
|
||||
<?php if ( current_user_can('edit_posts') ) : ?>
|
||||
<div id="posttimestampdiv" class="postbox">
|
||||
<div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv'); ?>">
|
||||
<h3><?php _e('Post Timestamp'); ?></h3>
|
||||
<div class="inside"><?php touch_time(($action == 'edit')); ?></div>
|
||||
</div>
|
||||
@ -227,7 +227,7 @@ if ( $post->post_author && !in_array($post->post_author, $authors) )
|
||||
$authors[] = $post->post_author;
|
||||
if ( $authors && count( $authors ) > 1 ) :
|
||||
?>
|
||||
<div id="authordiv" class="postbox">
|
||||
<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv'); ?>">
|
||||
<h3><?php _e('Post Author'); ?></h3>
|
||||
<div class="inside">
|
||||
<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
|
||||
|
@ -513,4 +513,11 @@ function wp_edit_posts_query( $q = false ) {
|
||||
return array($post_stati, $avail_post_stati);
|
||||
}
|
||||
|
||||
function postbox_classes( $id ) {
|
||||
$current_user = wp_get_current_user();
|
||||
$closed = get_usermeta( $current_user->ID, 'closedpostboxes' );
|
||||
if ( !is_array( $closed ) ) return '';
|
||||
return in_array( $id, $closed )? 'closed' : '';
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -31,7 +31,7 @@ function tag_update_quickclicks() {
|
||||
}
|
||||
});
|
||||
if ( shown )
|
||||
jQuery( '#tagchecklist' ).prepend( '<strong>Tags used on this post:</strong><br />' );
|
||||
jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );
|
||||
}
|
||||
|
||||
function tag_flush_to_text() {
|
||||
@ -54,30 +54,40 @@ function tag_press_key( e ) {
|
||||
|
||||
function add_postbox_toggles() {
|
||||
jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
|
||||
jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); } );
|
||||
jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(); } );
|
||||
}
|
||||
|
||||
function save_postboxes_state() {
|
||||
var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
|
||||
jQuery.post(postL10n.requestFile, {
|
||||
action: 'closed-postboxes',
|
||||
closed: closed,
|
||||
cookie: document.cookie});
|
||||
}
|
||||
|
||||
addLoadEvent( function() {
|
||||
jQuery('#tags-input').hide();
|
||||
tag_update_quickclicks();
|
||||
// add the quickadd form
|
||||
jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" size="16" autocomplete="off" value="Add new tag" /><input type="button" class="button" id="tagadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">Separate tags with commas</span></span>');
|
||||
jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
|
||||
jQuery('#tagadd').click( tag_flush_to_text );
|
||||
// jQuery('#newtag').keydown( tag_press_key );
|
||||
jQuery('#newtag').focus(function() {
|
||||
if ( this.value == 'Add new tag' ) {
|
||||
if ( this.value == postL10n.addTag ) {
|
||||
this.value = '';
|
||||
this.style.color = '#333';
|
||||
}
|
||||
});
|
||||
jQuery('#newtag').blur(function() {
|
||||
if ( this.value == '' ) {
|
||||
this.value = 'Add new tag';
|
||||
this.value = postL10n.addTag;
|
||||
this.style.color = '#999'
|
||||
}
|
||||
});
|
||||
|
||||
// auto-suggest stuff
|
||||
jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { onSelect: tag_flush_to_text, delay: 500, minchars: 2 } );
|
||||
|
||||
// postboxes
|
||||
add_postbox_toggles();
|
||||
});
|
||||
});
|
||||
|
@ -108,6 +108,13 @@ class WP_Scripts {
|
||||
$this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
|
||||
$this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
|
||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest'), '20080102' );
|
||||
$this->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
'add' => attribute_escape(__('Add')),
|
||||
'addTag' => attribute_escape(__('Add new tag')),
|
||||
'separate' => __('Separate tags with commas'),
|
||||
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
|
||||
) );
|
||||
$this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' );
|
||||
$this->localize( 'upload', 'uploadL10n', array(
|
||||
'browseTitle' => attribute_escape(__('Browse your files')),
|
||||
|
Loading…
Reference in New Issue
Block a user