1 var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
3 jQuery(document).ready( function($) {
4 /* Dashboard Welcome Panel */
5 var welcomePanel = $('#welcome-panel'),
6 welcomePanelHide = $('#wp_welcome_panel-hide'),
7 updateWelcomePanel = function( visible ) {
9 action: 'update-welcome-panel',
11 welcomepanelnonce: $('#welcomepanelnonce').val()
15 if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') )
16 welcomePanel.removeClass('hidden');
18 $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
20 welcomePanel.addClass('hidden');
21 updateWelcomePanel( 0 );
22 $('#wp_welcome_panel-hide').prop('checked', false);
25 welcomePanelHide.click( function() {
26 welcomePanel.toggleClass('hidden', ! this.checked );
27 updateWelcomePanel( this.checked ? 1 : 0 );
30 // These widgets are sometimes populated via ajax
32 'dashboard_incoming_links',
34 'dashboard_secondary',
38 ajaxPopulateWidgets = function(el) {
39 function show(i, id) {
40 var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
43 setTimeout( function(){
44 p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id, '', function() {
45 p.hide().slideDown('normal', function(){
46 $(this).css('display', '');
55 if ( $.inArray(el, ajaxWidgets) != -1 )
58 $.each( ajaxWidgets, show );
61 ajaxPopulateWidgets();
63 postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
66 quickPressLoad = function() {
67 var act = $('#quickpost-action'), t;
68 t = $('#quick-press').submit( function() {
69 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible');
70 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
72 if ( 'post' == act.val() ) {
73 act.val( 'post-quickpress-publish' );
76 $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
77 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden');
78 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', false);
79 $('#dashboard_quick_press ul').next('p').remove();
80 $('#dashboard_quick_press ul').find('li').each( function() {
81 $('#dashboard_recent_drafts ul').prepend( this );
88 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );