]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/link.js
Wordpress 2.7.1
[autoinstalls/wordpress.git] / wp-admin / js / link.js
1 jQuery(document).ready( function($) {
2         // close postboxes that should be closed
3         jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
4
5         jQuery('#link_name').focus();
6         // postboxes
7         postboxes.add_postbox_toggles('link');
8
9         // category tabs
10         var categoryTabs = jQuery('#category-tabs').tabs();
11
12         // Ajax Cat
13         var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
14         jQuery('#category-add-submit').click( function() { newCat.focus(); } );
15         var noSyncChecks = false; // prophylactic. necessary?
16         var syncChecks = function() {
17                 if ( noSyncChecks )
18                         return;
19                 noSyncChecks = true;
20                 var th = jQuery(this);
21                 var c = th.is(':checked');
22                 var id = th.val().toString();
23                 jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
24                 noSyncChecks = false;
25         };
26         var catAddAfter = function( r, s ) {
27                 jQuery(s.what + ' response_data', r).each( function() {
28                         var t = jQuery(jQuery(this).text());
29                         t.find( 'label' ).each( function() {
30                                 var th = jQuery(this);
31                                 var val = th.find('input').val();
32                                 var id = th.find('input')[0].id
33                                 jQuery('#' + id).change( syncChecks );
34                                 var name = jQuery.trim( th.text() );
35                                 var o = jQuery( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
36                         } );
37                 } );
38         };
39         jQuery('#categorychecklist').wpList( {
40                 alt: '',
41                 what: 'link-category',
42                 response: 'category-ajax-response',
43                 addAfter: catAddAfter
44         } );
45
46         $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
47         $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
48         if ( 'pop' == getUserSetting('cats') )
49                 $('a[href="#categories-pop"]').click();
50
51         jQuery('#category-add-toggle').click( function() {
52                 jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
53                 categoryTabs.tabsClick( 1 );
54                 return false;
55         } );
56         jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
57 });