Sync checkboxes only for categories, some white space cleanup, props kevinB, fixes #12244

git-svn-id: http://svn.automattic.com/wordpress/trunk@13195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2010-02-18 11:20:15 +00:00
parent 4f460639c8
commit 4c52731c85
3 changed files with 33 additions and 32 deletions

View File

@ -253,45 +253,44 @@ jQuery(document).ready( function($) {
} }
// categories // categories
$('.categorydiv').each(function(){ $('.categorydiv').each( function(){
var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, popularCats; var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, taxonomyParts, taxonomy, settingName;
var taxonomy_parts = this_id.split('-');
taxonomy_parts.shift(); taxonomyParts = this_id.split('-');
var taxonomy = taxonomy_parts.join('-'); taxonomyParts.shift();
var settingName = taxonomy+'_tab'; taxonomy = taxonomyParts.join('-');
if(taxonomy == 'category') settingName = taxonomy + '_tab';
if ( taxonomy == 'category' )
settingName = 'cats'; settingName = 'cats';
// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.dev.js // TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.dev.js
$('a', '#'+taxonomy+'-tabs').click(function(){ $('a', '#' + taxonomy + '-tabs').click( function(){
var t = $(this).attr('href'); var t = $(this).attr('href');
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs'); $(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
$('#'+taxonomy+'-tabs').siblings('.tabs-panel').hide(); $('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
$(t).show(); $(t).show();
if ( '#'+taxonomy+'-all' == t ) if ( '#' + taxonomy + '-all' == t )
deleteUserSetting(settingName); deleteUserSetting(settingName);
else else
setUserSetting(settingName,'pop'); setUserSetting(settingName, 'pop');
return false; return false;
}); });
if ( getUserSetting(settingName) ) if ( getUserSetting(settingName) )
$('a[href="#'+taxonomy+'-pop"]', '#'+taxonomy+'-tabs').click(); $('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click();
// Ajax Cat // Ajax Cat
$('#new'+taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } ); $('#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
$('#'+taxonomy+'-add-submit').click(function(){$('#new'+taxonomy).focus();}); $('#' + taxonomy + '-add-submit').click( function(){ $('#new' + taxonomy).focus(); });
syncChecks = function() { syncChecks = function() {
if ( noSyncChecks ) if ( noSyncChecks )
return; return;
noSyncChecks = true; noSyncChecks = true;
var th = jQuery(this), c = th.is(':checked'), id = th.val().toString(); var th = jQuery(this), c = th.is(':checked'), id = th.val().toString();
$('#in-'+taxonomy+'-' + id + ', #in-'+taxonomy+'-category-' + id).attr( 'checked', c ); $('#in-' + taxonomy + '-' + id + ', #in-' + taxonomy + '-category-' + id).attr( 'checked', c );
noSyncChecks = false; noSyncChecks = false;
}; };
catAddBefore = function( s ) { catAddBefore = function( s ) {
if ( !$('#new'+taxonomy).val() ) if ( !$('#new'+taxonomy).val() )
@ -309,21 +308,23 @@ jQuery(document).ready( function($) {
} }
}; };
$('#'+taxonomy+'checklist').wpList({ $('#' + taxonomy + 'checklist').wpList({
alt: '', alt: '',
response: taxonomy+'-ajax-response', response: taxonomy + '-ajax-response',
addBefore: catAddBefore, addBefore: catAddBefore,
addAfter: catAddAfter addAfter: catAddAfter
}); });
$('#'+taxonomy+'-add-toggle').click( function() {
$('#'+taxonomy+'-adder').toggleClass( 'wp-hidden-children' ); $('#' + taxonomy + '-add-toggle').click( function() {
$('a[href="#'+taxonomy+'-all"]', '#'+taxonomy+'-tabs').click(); $('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
return false; return false;
}); });
$('#'+taxonomy+'checklist').children('li.popular-category').add( $('#'+taxonomy+'checklist-pop').children() ).find(':checkbox').live( 'click', function(){ $('#' + taxonomy + 'checklist').children('li.popular-category').add( $('#' + taxonomy + 'checklist-pop').children() ).find(':checkbox').live( 'click', function(){
var t = $(this), c = t.is(':checked'), id = t.val(); var t = $(this), c = t.is(':checked'), id = t.val();
$('#in-'+taxonomy+'-' + id + ', #in-popular-'+taxonomy+'-' + id).attr( 'checked', c ); if ( id && t.parents('#taxonomy-'+taxonomy).length )
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).attr( 'checked', c );
}); });
}); // end cats }); // end cats

File diff suppressed because one or more lines are too long

View File

@ -275,7 +275,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' ); $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
$scripts->add_data( 'postbox', 'group', 1 ); $scripts->add_data( 'postbox', 'group', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20091208' ); $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20100217' );
$scripts->add_data( 'post', 'group', 1 ); $scripts->add_data( 'post', 'group', 1 );
$scripts->localize( 'post', 'postL10n', array( $scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'), 'tagsUsed' => __('Tags used on this post:'),