]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/dashboard.dev.js
75d4521de47d4a8c94f3664f52a76f27c29830b9
[autoinstalls/wordpress.git] / wp-admin / js / dashboard.dev.js
1
2 jQuery(document).ready( function($) {
3         var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
4         // These widgets are sometimes populated via ajax
5         ajaxWidgets = [
6                 'dashboard_incoming_links',
7                 'dashboard_primary',
8                 'dashboard_secondary',
9                 'dashboard_plugins'
10         ];
11
12         ajaxPopulateWidgets = function() {
13                 $.each( ajaxWidgets, function() {
14                         var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading');
15                         if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); }
16                 } );
17         };
18         ajaxPopulateWidgets();
19
20         postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } );
21
22         /* QuickPress */
23         quickPressLoad = function() {
24                 var act = $('#quickpost-action'), t;
25                 t = $('#quick-press').submit( function() {
26                         $('#dashboard_quick_press h3').append( '<img src="images/wpspin_light.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
27                         $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled');
28
29                         if ( 'post' == act.val() ) {
30                                 act.val( 'post-quickpress-publish' );
31                         }
32
33                         $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
34                                 $('#dashboard_quick_press h3 img').remove();
35                                 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','');
36                                 $('#dashboard_quick_press ul').find('li').each( function() {
37                                         $('#dashboard_recent_drafts ul').prepend( this );
38                                 } ).end().remove();
39                                 tb_init('a.thickbox');
40                                 quickPressLoad();
41                         } );
42                         return false;
43                 } );
44
45                 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
46
47         };
48         quickPressLoad();
49
50 } );