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