2009-01-02 10:08:58 -05:00
|
|
|
jQuery(document).ready( function($) {
|
|
|
|
|
2009-03-25 10:29:22 -04:00
|
|
|
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
|
2009-01-02 10:08:58 -05:00
|
|
|
|
|
|
|
$('#link_name').focus();
|
|
|
|
// postboxes
|
|
|
|
postboxes.add_postbox_toggles('link');
|
|
|
|
|
|
|
|
// category tabs
|
2009-03-25 10:29:22 -04:00
|
|
|
$('#category-tabs a').click(function(){
|
|
|
|
var t = $(this).attr('href');
|
2009-05-06 17:31:07 -04:00
|
|
|
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
|
|
|
|
$('.tabs-panel').hide();
|
2009-03-25 10:29:22 -04:00
|
|
|
$(t).show();
|
|
|
|
if ( '#categories-all' == t )
|
|
|
|
deleteUserSetting('cats');
|
|
|
|
else
|
|
|
|
setUserSetting('cats','pop');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if ( getUserSetting('cats') )
|
|
|
|
$('#category-tabs a[href="#categories-pop"]').click();
|
2009-01-02 10:08:58 -05:00
|
|
|
|
|
|
|
// Ajax Cat
|
|
|
|
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
|
|
|
|
$('#category-add-submit').click( function() { newCat.focus(); } );
|
|
|
|
syncChecks = function() {
|
|
|
|
if ( noSyncChecks )
|
|
|
|
return;
|
|
|
|
noSyncChecks = true;
|
|
|
|
var th = $(this), c = th.is(':checked'), id = th.val().toString();
|
2009-02-01 18:52:10 -05:00
|
|
|
$('#in-link-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
|
2009-01-02 10:08:58 -05:00
|
|
|
noSyncChecks = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
catAddAfter = function( r, s ) {
|
|
|
|
$(s.what + ' response_data', r).each( function() {
|
|
|
|
var t = $($(this).text());
|
|
|
|
t.find( 'label' ).each( function() {
|
|
|
|
var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
|
|
|
|
$('#' + id).change( syncChecks );
|
|
|
|
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#categorychecklist').wpList( {
|
|
|
|
alt: '',
|
|
|
|
what: 'link-category',
|
|
|
|
response: 'category-ajax-response',
|
|
|
|
addAfter: catAddAfter
|
|
|
|
} );
|
|
|
|
|
|
|
|
$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
|
|
|
|
$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
|
|
|
|
if ( 'pop' == getUserSetting('cats') )
|
|
|
|
$('a[href="#categories-pop"]').click();
|
|
|
|
|
2010-05-26 05:17:40 -04:00
|
|
|
$('#category-add-toggle').click( function() {
|
2009-01-02 10:08:58 -05:00
|
|
|
$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
|
2009-03-25 10:29:22 -04:00
|
|
|
$('#category-tabs a[href="#categories-all"]').click();
|
2010-05-26 05:17:40 -04:00
|
|
|
$('#newcategory').focus();
|
2009-01-02 10:08:58 -05:00
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
|
|
|
|
$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
|
|
|
|
});
|