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