1
|
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 |
show = function(id, i) { |
|
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('index-extra.php?jax=' + id, '', function() { |
|
19 |
p.hide().slideDown('normal', function(){ |
|
20 |
$(this).css('display', ''); |
|
21 |
if ( 'dashboard_plugins' == id && $.isFunction(tb_init) ) |
|
22 |
tb_init('#dashboard_plugins a.thickbox'); |
|
23 |
}); |
|
24 |
}); |
|
25 |
}, i * 500 ); |
|
26 |
} |
|
27 |
} |
|
28 |
if ( el ) { |
|
29 |
el = el.toString(); |
|
30 |
if ( $.inArray(el, ajaxWidgets) != -1 ) |
|
31 |
show(el, 0); |
|
32 |
} else { |
|
33 |
$.each( ajaxWidgets, function(i) { |
|
34 |
show(this, i); |
|
35 |
}); |
|
36 |
} |
|
37 |
}; |
|
38 |
ajaxPopulateWidgets(); |
|
39 |
|
|
40 |
postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } ); |
|
41 |
|
|
42 |
/* QuickPress */ |
|
43 |
quickPressLoad = function() { |
|
44 |
var act = $('#quickpost-action'), t; |
|
45 |
t = $('#quick-press').submit( function() { |
|
46 |
$('#dashboard_quick_press h3').append( '<img src="images/wpspin_light.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' ); |
|
47 |
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled'); |
|
48 |
|
|
49 |
if ( 'post' == act.val() ) { |
|
50 |
act.val( 'post-quickpress-publish' ); |
|
51 |
} |
|
52 |
|
|
53 |
$('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() { |
|
54 |
$('#dashboard_quick_press h3 img').remove(); |
|
55 |
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled',''); |
|
56 |
$('#dashboard_quick_press ul').find('li').each( function() { |
|
57 |
$('#dashboard_recent_drafts ul').prepend( this ); |
|
58 |
} ).end().remove(); |
|
59 |
tb_init('a.thickbox'); |
|
60 |
quickPressLoad(); |
|
61 |
} ); |
|
62 |
return false; |
|
63 |
} ); |
|
64 |
|
|
65 |
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); |
|
66 |
|
|
67 |
}; |
|
68 |
quickPressLoad(); |
|
69 |
|
|
70 |
} ); |