1
/* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
3
jQuery(document).ready( function($) {
5
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
7
$('#link_name').focus();
9
postboxes.add_postbox_toggles('link');
12
$('#category-tabs a').click(function(){
13
var t = $(this).attr('href');
14
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
15
$('.tabs-panel').hide();
17
if ( '#categories-all' == t )
18
deleteUserSetting('cats');
20
setUserSetting('cats','pop');
23
if ( getUserSetting('cats') )
24
$('#category-tabs a[href="#categories-pop"]').click();
27
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
28
$('#link-category-add-submit').click( function() { newCat.focus(); } );
29
syncChecks = function() {
33
var th = $(this), c = th.is(':checked'), id = th.val().toString();
34
$('#in-link-category-' + id + ', #in-popular-link_category-' + id).prop( 'checked', c );
38
catAddAfter = function( r, s ) {
39
$(s.what + ' response_data', r).each( function() {
40
var t = $($(this).text());
41
t.find( 'label' ).each( function() {
42
var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
43
$('#' + id).change( syncChecks );
44
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
49
$('#categorychecklist').wpList( {
51
what: 'link-category',
52
response: 'category-ajax-response',
56
$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
57
$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
58
if ( 'pop' == getUserSetting('cats') )
59
$('a[href="#categories-pop"]').click();
61
$('#category-add-toggle').click( function() {
62
$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
63
$('#category-tabs a[href="#categories-all"]').click();
64
$('#newcategory').focus();
68
$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();