3 // The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
5 each : function(o, cb, s) {
13 if (typeof(o.length) != 'undefined') {
14 for (n=0, l = o.length; n<l; n++) {
15 if (cb.call(s, o[n], n, o) === false)
20 if (o.hasOwnProperty(n)) {
21 if (cb.call(s, o[n], n, o) === false)
29 getHash : function(n) {
30 var v = this.get(n), h;
33 this.each(v.split('&'), function(v) {
42 setHash : function(n, v, e, p, d, s) {
45 this.each(v, function(v, k) {
46 o += (!o ? '' : '&') + k + '=' + v;
49 this.set(n, o, e, p, d, s);
53 var c = document.cookie, e, p = n + "=", b;
58 b = c.indexOf("; " + p);
68 e = c.indexOf(";", b);
73 return decodeURIComponent(c.substring(b + p.length, e));
76 set : function(n, v, e, p, d, s) {
77 document.cookie = n + "=" + encodeURIComponent(v) +
78 ((e) ? "; expires=" + e.toGMTString() : "") +
79 ((p) ? "; path=" + p : "") +
80 ((d) ? "; domain=" + d : "") +
81 ((s) ? "; secure" : "");
84 remove : function(n, p) {
87 d.setTime(d.getTime() - 1000);
89 this.set(n, '', d, p, d);
93 // Returns the value as string. Second arg or empty string is returned when value is not set.
94 function getUserSetting( name, def ) {
95 var o = getAllUserSettings();
97 if ( o.hasOwnProperty(name) )
100 if ( typeof def != 'undefined' )
106 // Both name and value must be only ASCII letters, numbers or underscore
107 // and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
108 function setUserSetting( name, value, del ) {
109 var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
110 var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
112 if ( del ) delete o[n];
115 d.setTime( d.getTime() + 31536000000 );
116 p = userSettings.url;
118 wpCookies.setHash(c, o, d, p );
119 wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
122 function deleteUserSetting( name ) {
123 setUserSetting( name, '', 1 );
126 // Returns all settings as js object.
127 function getAllUserSettings() {
128 return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
132 jQuery(document).ready( function($) {
134 $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
136 // show things that should be visible, hide what should be hidden
137 $('.hide-if-no-js').removeClass('hide-if-no-js');
138 $('.hide-if-js').hide();
140 // Basic form validation
141 if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
142 $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
145 // Move .updated and .error alert boxes
146 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
147 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
149 // screen settings tab
150 $('#show-settings-link').click(function () {
151 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
152 $('#contextual-help-link-wrap').addClass('invisible');
154 $('#screen-options-wrap').slideToggle('fast', function(){
155 if ( $(this).hasClass('screen-options-open') ) {
156 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
157 $('#contextual-help-link-wrap').removeClass('invisible');
158 $(this).removeClass('screen-options-open');
161 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
162 $(this).addClass('screen-options-open');
169 $('#contextual-help-link').click(function () {
170 if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
171 $('#screen-options-link-wrap').addClass('invisible');
173 $('#contextual-help-wrap').slideToggle('fast', function(){
174 if ( $(this).hasClass('contextual-help-open') ) {
175 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
176 $('#screen-options-link-wrap').removeClass('invisible');
177 $(this).removeClass('contextual-help-open');
179 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
180 $(this).addClass('contextual-help-open');
186 // check all checkboxes
187 var lastClicked = false;
188 $( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
189 if ( 'undefined' == e.shiftKey ) { return true; }
191 if ( !lastClicked ) { return true; }
192 var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
193 var first = checks.index( lastClicked );
194 var last = checks.index( this );
195 var checked = $(this).attr('checked');
196 if ( 0 < first && 0 < last && first != last ) {
197 checks.slice( first, last ).attr( 'checked', function(){
198 if ( $(this).parents('tr').is(':visible') )
199 return checked ? 'checked' : '';
208 $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
209 var c = $(this).attr('checked');
210 if ( 'undefined' == typeof toggleWithKeyboard)
211 toggleWithKeyboard = false;
212 var toggle = e.shiftKey || toggleWithKeyboard;
213 $(this).parents( 'form:first' ).find( 'table tbody:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
214 if ( $(this).parents('tr').is(':hidden') )
217 return $(this).attr( 'checked' ) ? '' : 'checked';
222 $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
232 var showNotice, adminMenu, columns;
234 // stub for doing better warnings
236 warn : function(text) {
243 note : function(text) {
249 // sidebar admin menu
253 $('#adminmenu div.wp-menu-toggle').each( function() {
254 if ( $(this).siblings('.wp-submenu').length )
255 $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
259 $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
262 $('.wp-menu-separator').click(function(){
263 if ( $('#wpcontent').hasClass('folded') ) {
265 setUserSetting( 'mfold', 'o' );
268 setUserSetting( 'mfold', 'f' );
272 if ( 'f' != getUserSetting( 'mfold' ) ) {
273 this.restoreMenuState();
279 restoreMenuState : function() {
280 $('#adminmenu li.wp-has-submenu').each(function(i, e) {
281 var v = getUserSetting( 'm'+i );
282 if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
284 if ( 'o' == v ) $(e).addClass('wp-menu-open');
285 else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
289 toggle : function(el) {
291 el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
293 $('#adminmenu li.wp-has-submenu').each(function(i, e) {
294 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
295 setUserSetting( 'm'+i, v );
301 fold : function(off) {
303 $('#wpcontent').removeClass('folded');
304 $('#adminmenu li.wp-has-submenu').unbind();
306 $('#wpcontent').addClass('folded');
307 $('#adminmenu li.wp-has-submenu').hoverIntent({
309 var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
311 if ( (t+h+10) > H ) {
313 m.css({'marginTop':'-'+o+'px'});
314 } else if ( m.css('marginTop') ) {
315 m.css({'marginTop':''})
317 m.addClass('sub-open');
319 out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
328 favorites : function() {
329 $('#favorite-inside').width($('#favorite-actions').width()-4);
330 $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
332 $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
336 $(document).ready(function(){adminMenu.init();});
340 // show/hide/save table columns
342 init : function(page) {
343 $('.hide-column-tog').click( function() {
344 var column = $(this).val();
345 var show = $(this).attr('checked');
347 $('.column-' + column).show();
349 $('.column-' + column).hide();
351 columns.save_manage_columns_state(page);
355 save_manage_columns_state : function(page) {
356 var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
357 $.post('admin-ajax.php', {
358 action: 'hidden-columns',
360 hiddencolumnsnonce: $('#hiddencolumnsnonce').val(),
369 jQuery(document).ready(function($){
370 if ( 'undefined' != typeof google && google.gears ) return;
373 if ( 'undefined' != typeof GearsFactory ) {
374 gf = new GearsFactory();
377 gf = new ActiveXObject('Gears.Factory');
378 if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
379 gf.privateSetGlobalObject(this);
381 if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
382 gf = document.createElement("object");
383 gf.style.display = "none";
386 gf.type = "application/x-googlegears";
387 document.documentElement.appendChild(gf);
391 if ( gf && gf.hasPermission )
394 $('.turbo-nag').show();