]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/dashboard.dev.js
Wordpress 3.1
[autoinstalls/wordpress.git] / wp-admin / js / dashboard.dev.js
1 var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
2
3 jQuery(document).ready( function($) {
4         // These widgets are sometimes populated via ajax
5         ajaxWidgets = [
6                 'dashboard_incoming_links',
7                 'dashboard_primary',
8                 'dashboard_secondary',
9                 'dashboard_plugins',
10                 'dashboard_quick_press'
11         ];
12
13         ajaxPopulateWidgets = function(el) {
14                 show = function(id, i) {
15                         var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
16                         if ( e.length ) {
17                                 p = e.parent();
18                                 setTimeout( function(){
19                                         p.load( ajaxurl.replace( '/admin-ajax.php', '' ) + '/index-extra.php?jax=' + id, '', function() {
20                                                 p.hide().slideDown('normal', function(){
21                                                         $(this).css('display', '');
22                                                         if ( 'dashboard_quick_press' == id )
23                                                                 quickPressLoad();
24                                                 });
25                                         });
26                                 }, i * 500 );
27                         }
28                 }
29                 if ( el ) {
30                         el = el.toString();
31                         if ( $.inArray(el, ajaxWidgets) != -1 )
32                                 show(el, 0);
33                 } else {
34                         $.each( ajaxWidgets, function(i) {
35                                 show(this, i);
36                         });
37                 }
38         };
39         ajaxPopulateWidgets();
40
41         postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
42
43         /* QuickPress */
44         quickPressLoad = function() {
45                 var act = $('#quickpost-action'), t;
46                 t = $('#quick-press').submit( function() {
47                         $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible');
48                         $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled');
49
50                         if ( 'post' == act.val() ) {
51                                 act.val( 'post-quickpress-publish' );
52                         }
53
54                         $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
55                                 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden');
56                                 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','');
57                                 $('#dashboard_quick_press ul').next('p').remove();
58                                 $('#dashboard_quick_press ul').find('li').each( function() {
59                                         $('#dashboard_recent_drafts ul').prepend( this );
60                                 } ).end().remove();
61                                 quickPressLoad();
62                         } );
63                         return false;
64                 } );
65
66                 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
67
68         };
69
70 } );