]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/dashboard.dev.js
Wordpress 3.0
[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('index-extra.php?jax=' + id, '', function() {
20                                                 p.hide().slideDown('normal', function(){
21                                                         $(this).css('display', '');
22                                                         if ( 'dashboard_plugins' == id && $.isFunction(tb_init) )
23                                                                 tb_init('#dashboard_plugins a.thickbox');
24                                                         if ( 'dashboard_quick_press' == id && $.isFunction(tb_init) ) {
25                                                                 tb_init('#dashboard_quick_press a.thickbox');
26                                                                 quickPressLoad();
27                                                         }
28                                                 });
29                                         });
30                                 }, i * 500 );
31                         }
32                 }
33                 if ( el ) {
34                         el = el.toString();
35                         if ( $.inArray(el, ajaxWidgets) != -1 )
36                                 show(el, 0);
37                 } else {
38                         $.each( ajaxWidgets, function(i) {
39                                 show(this, i);
40                         });
41                 }
42         };
43         ajaxPopulateWidgets();
44
45         postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } );
46
47         /* QuickPress */
48         quickPressLoad = function() {
49                 var act = $('#quickpost-action'), t;
50                 t = $('#quick-press').submit( function() {
51                         $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible');
52                         $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled');
53
54                         if ( 'post' == act.val() ) {
55                                 act.val( 'post-quickpress-publish' );
56                         }
57
58                         $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
59                                 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden');
60                                 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','');
61                                 $('#dashboard_quick_press ul').next('p').remove();
62                                 $('#dashboard_quick_press ul').find('li').each( function() {
63                                         $('#dashboard_recent_drafts ul').prepend( this );
64                                 } ).end().remove();
65                                 tb_init('a.thickbox');
66                                 quickPressLoad();
67                         } );
68                         return false;
69                 } );
70
71                 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
72
73         };
74
75 } );