mp-wp_genesis 1
mp-wp_genesis 2 wpCookies = {
mp-wp_genesis 3 // The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
mp-wp_genesis 4
mp-wp_genesis 5 each : function(o, cb, s) {
mp-wp_genesis 6 var n, l;
mp-wp_genesis 7
mp-wp_genesis 8 if (!o)
mp-wp_genesis 9 return 0;
mp-wp_genesis 10
mp-wp_genesis 11 s = s || o;
mp-wp_genesis 12
mp-wp_genesis 13 if (typeof(o.length) != 'undefined') {
mp-wp_genesis 14 for (n=0, l = o.length; n<l; n++) {
mp-wp_genesis 15 if (cb.call(s, o[n], n, o) === false)
mp-wp_genesis 16 return 0;
mp-wp_genesis 17 }
mp-wp_genesis 18 } else {
mp-wp_genesis 19 for (n in o) {
mp-wp_genesis 20 if (o.hasOwnProperty(n)) {
mp-wp_genesis 21 if (cb.call(s, o[n], n, o) === false)
mp-wp_genesis 22 return 0;
mp-wp_genesis 23 }
mp-wp_genesis 24 }
mp-wp_genesis 25 }
mp-wp_genesis 26 return 1;
mp-wp_genesis 27 },
mp-wp_genesis 28
mp-wp_genesis 29 getHash : function(n) {
mp-wp_genesis 30 var v = this.get(n), h;
mp-wp_genesis 31
mp-wp_genesis 32 if (v) {
mp-wp_genesis 33 this.each(v.split('&'), function(v) {
mp-wp_genesis 34 v = v.split('=');
mp-wp_genesis 35 h = h || {};
mp-wp_genesis 36 h[v[0]] = v[1];
mp-wp_genesis 37 });
mp-wp_genesis 38 }
mp-wp_genesis 39 return h;
mp-wp_genesis 40 },
mp-wp_genesis 41
mp-wp_genesis 42 setHash : function(n, v, e, p, d, s) {
mp-wp_genesis 43 var o = '';
mp-wp_genesis 44
mp-wp_genesis 45 this.each(v, function(v, k) {
mp-wp_genesis 46 o += (!o ? '' : '&') + k + '=' + v;
mp-wp_genesis 47 });
mp-wp_genesis 48
mp-wp_genesis 49 this.set(n, o, e, p, d, s);
mp-wp_genesis 50 },
mp-wp_genesis 51
mp-wp_genesis 52 get : function(n) {
mp-wp_genesis 53 var c = document.cookie, e, p = n + "=", b;
mp-wp_genesis 54
mp-wp_genesis 55 if (!c)
mp-wp_genesis 56 return;
mp-wp_genesis 57
mp-wp_genesis 58 b = c.indexOf("; " + p);
mp-wp_genesis 59
mp-wp_genesis 60 if (b == -1) {
mp-wp_genesis 61 b = c.indexOf(p);
mp-wp_genesis 62
mp-wp_genesis 63 if (b != 0)
mp-wp_genesis 64 return null;
mp-wp_genesis 65 } else
mp-wp_genesis 66 b += 2;
mp-wp_genesis 67
mp-wp_genesis 68 e = c.indexOf(";", b);
mp-wp_genesis 69
mp-wp_genesis 70 if (e == -1)
mp-wp_genesis 71 e = c.length;
mp-wp_genesis 72
mp-wp_genesis 73 return decodeURIComponent(c.substring(b + p.length, e));
mp-wp_genesis 74 },
mp-wp_genesis 75
mp-wp_genesis 76 set : function(n, v, e, p, d, s) {
mp-wp_genesis 77 document.cookie = n + "=" + encodeURIComponent(v) +
mp-wp_genesis 78 ((e) ? "; expires=" + e.toGMTString() : "") +
mp-wp_genesis 79 ((p) ? "; path=" + p : "") +
mp-wp_genesis 80 ((d) ? "; domain=" + d : "") +
mp-wp_genesis 81 ((s) ? "; secure" : "");
mp-wp_genesis 82 },
mp-wp_genesis 83
mp-wp_genesis 84 remove : function(n, p) {
mp-wp_genesis 85 var d = new Date();
mp-wp_genesis 86
mp-wp_genesis 87 d.setTime(d.getTime() - 1000);
mp-wp_genesis 88
mp-wp_genesis 89 this.set(n, '', d, p, d);
mp-wp_genesis 90 }
mp-wp_genesis 91 };
mp-wp_genesis 92
mp-wp_genesis 93 // Returns the value as string. Second arg or empty string is returned when value is not set.
mp-wp_genesis 94 function getUserSetting( name, def ) {
mp-wp_genesis 95 var o = getAllUserSettings();
mp-wp_genesis 96
mp-wp_genesis 97 if ( o.hasOwnProperty(name) )
mp-wp_genesis 98 return o[name];
mp-wp_genesis 99
mp-wp_genesis 100 if ( typeof def != 'undefined' )
mp-wp_genesis 101 return def;
mp-wp_genesis 102
mp-wp_genesis 103 return '';
mp-wp_genesis 104 }
mp-wp_genesis 105
mp-wp_genesis 106 // Both name and value must be only ASCII letters, numbers or underscore
mp-wp_genesis 107 // and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
mp-wp_genesis 108 function setUserSetting( name, value, del ) {
mp-wp_genesis 109 var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
mp-wp_genesis 110 var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
mp-wp_genesis 111
mp-wp_genesis 112 if ( del ) delete o[n];
mp-wp_genesis 113 else o[n] = v;
mp-wp_genesis 114
mp-wp_genesis 115 d.setTime( d.getTime() + 31536000000 );
mp-wp_genesis 116 p = userSettings.url;
mp-wp_genesis 117
mp-wp_genesis 118 wpCookies.setHash(c, o, d, p );
mp-wp_genesis 119 wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
mp-wp_genesis 120 }
mp-wp_genesis 121
mp-wp_genesis 122 function deleteUserSetting( name ) {
mp-wp_genesis 123 setUserSetting( name, '', 1 );
mp-wp_genesis 124 }
mp-wp_genesis 125
mp-wp_genesis 126 // Returns all settings as js object.
mp-wp_genesis 127 function getAllUserSettings() {
mp-wp_genesis 128 return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
mp-wp_genesis 129 }
mp-wp_genesis 130
mp-wp_genesis 131
mp-wp_genesis 132 jQuery(document).ready( function($) {
mp-wp_genesis 133 // pulse
mp-wp_genesis 134 $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
mp-wp_genesis 135
mp-wp_genesis 136 // show things that should be visible, hide what should be hidden
mp-wp_genesis 137 $('.hide-if-no-js').removeClass('hide-if-no-js');
mp-wp_genesis 138 $('.hide-if-js').hide();
mp-wp_genesis 139
mp-wp_genesis 140 // Basic form validation
mp-wp_genesis 141 if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
mp-wp_genesis 142 $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
mp-wp_genesis 143 }
mp-wp_genesis 144
mp-wp_genesis 145 // Move .updated and .error alert boxes
mp-wp_genesis 146 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
mp-wp_genesis 147 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
mp-wp_genesis 148
mp-wp_genesis 149 // screen settings tab
mp-wp_genesis 150 $('#show-settings-link').click(function () {
mp-wp_genesis 151 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
mp-wp_genesis 152 $('#contextual-help-link-wrap').addClass('invisible');
mp-wp_genesis 153 }
mp-wp_genesis 154 $('#screen-options-wrap').slideToggle('fast', function(){
mp-wp_genesis 155 if ( $(this).hasClass('screen-options-open') ) {
mp-wp_update-imag... 156 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.svg")'});
mp-wp_genesis 157 $('#contextual-help-link-wrap').removeClass('invisible');
mp-wp_genesis 158 $(this).removeClass('screen-options-open');
mp-wp_genesis 159
mp-wp_genesis 160 } else {
mp-wp_update-imag... 161 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.svg")'});
mp-wp_genesis 162 $(this).addClass('screen-options-open');
mp-wp_genesis 163 }
mp-wp_genesis 164 });
mp-wp_genesis 165 return false;
mp-wp_genesis 166 });
mp-wp_genesis 167
mp-wp_genesis 168 // help tab
mp-wp_genesis 169 $('#contextual-help-link').click(function () {
mp-wp_genesis 170 if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
mp-wp_genesis 171 $('#screen-options-link-wrap').addClass('invisible');
mp-wp_genesis 172 }
mp-wp_genesis 173 $('#contextual-help-wrap').slideToggle('fast', function(){
mp-wp_genesis 174 if ( $(this).hasClass('contextual-help-open') ) {
mp-wp_update-imag... 175 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.svg")'});
mp-wp_genesis 176 $('#screen-options-link-wrap').removeClass('invisible');
mp-wp_genesis 177 $(this).removeClass('contextual-help-open');
mp-wp_genesis 178 } else {
mp-wp_update-imag... 179 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.svg")'});
mp-wp_genesis 180 $(this).addClass('contextual-help-open');
mp-wp_genesis 181 }
mp-wp_genesis 182 });
mp-wp_genesis 183 return false;
mp-wp_genesis 184 });
mp-wp_genesis 185
mp-wp_genesis 186 // check all checkboxes
mp-wp_genesis 187 var lastClicked = false;
mp-wp_genesis 188 $( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
mp-wp_genesis 189 if ( 'undefined' == e.shiftKey ) { return true; }
mp-wp_genesis 190 if ( e.shiftKey ) {
mp-wp_genesis 191 if ( !lastClicked ) { return true; }
mp-wp_genesis 192 var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
mp-wp_genesis 193 var first = checks.index( lastClicked );
mp-wp_genesis 194 var last = checks.index( this );
mp-wp_genesis 195 var checked = $(this).attr('checked');
mp-wp_genesis 196 if ( 0 < first && 0 < last && first != last ) {
mp-wp_genesis 197 checks.slice( first, last ).attr( 'checked', function(){
mp-wp_genesis 198 if ( $(this).parents('tr').is(':visible') )
mp-wp_genesis 199 return checked ? 'checked' : '';
mp-wp_genesis 200
mp-wp_genesis 201 return '';
mp-wp_genesis 202 });
mp-wp_genesis 203 }
mp-wp_genesis 204 }
mp-wp_genesis 205 lastClicked = this;
mp-wp_genesis 206 return true;
mp-wp_genesis 207 } );
mp-wp_genesis 208 $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
mp-wp_genesis 209 var c = $(this).attr('checked');
mp-wp_genesis 210 if ( 'undefined' == typeof toggleWithKeyboard)
mp-wp_genesis 211 toggleWithKeyboard = false;
mp-wp_genesis 212 var toggle = e.shiftKey || toggleWithKeyboard;
mp-wp_genesis 213 $(this).parents( 'form:first' ).find( 'table tbody:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
mp-wp_genesis 214 if ( $(this).parents('tr').is(':hidden') )
mp-wp_genesis 215 return '';
mp-wp_genesis 216 if ( toggle )
mp-wp_genesis 217 return $(this).attr( 'checked' ) ? '' : 'checked';
mp-wp_genesis 218 else if (c)
mp-wp_genesis 219 return 'checked';
mp-wp_genesis 220 return '';
mp-wp_genesis 221 });
mp-wp_genesis 222 $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
mp-wp_genesis 223 if ( toggle )
mp-wp_genesis 224 return '';
mp-wp_genesis 225 else if (c)
mp-wp_genesis 226 return 'checked';
mp-wp_genesis 227 return '';
mp-wp_genesis 228 });
mp-wp_genesis 229 });
mp-wp_genesis 230 });
mp-wp_genesis 231
mp-wp_genesis 232 var showNotice, adminMenu, columns;
mp-wp_genesis 233
mp-wp_genesis 234 // stub for doing better warnings
mp-wp_genesis 235 showNotice = {
mp-wp_genesis 236 warn : function(text) {
mp-wp_genesis 237 if ( confirm(text) )
mp-wp_genesis 238 return true;
mp-wp_genesis 239
mp-wp_genesis 240 return false;
mp-wp_genesis 241 },
mp-wp_genesis 242
mp-wp_genesis 243 note : function(text) {
mp-wp_genesis 244 alert(text);
mp-wp_genesis 245 }
mp-wp_genesis 246 };
mp-wp_genesis 247
mp-wp_genesis 248 (function($){
mp-wp_genesis 249 // sidebar admin menu
mp-wp_genesis 250 adminMenu = {
mp-wp_genesis 251
mp-wp_genesis 252 init : function() {
mp-wp_genesis 253 $('#adminmenu div.wp-menu-toggle').each( function() {
mp-wp_genesis 254 if ( $(this).siblings('.wp-submenu').length )
mp-wp_genesis 255 $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
mp-wp_genesis 256 else
mp-wp_genesis 257 $(this).hide();
mp-wp_genesis 258 });
mp-wp_genesis 259 $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
mp-wp_genesis 260 this.favorites();
mp-wp_genesis 261
mp-wp_genesis 262 $('.wp-menu-separator').click(function(){
mp-wp_genesis 263 if ( $('#wpcontent').hasClass('folded') ) {
mp-wp_genesis 264 adminMenu.fold(1);
mp-wp_genesis 265 setUserSetting( 'mfold', 'o' );
mp-wp_genesis 266 } else {
mp-wp_genesis 267 adminMenu.fold();
mp-wp_genesis 268 setUserSetting( 'mfold', 'f' );
mp-wp_genesis 269 }
mp-wp_genesis 270 });
mp-wp_genesis 271
mp-wp_genesis 272 if ( 'f' != getUserSetting( 'mfold' ) ) {
mp-wp_genesis 273 this.restoreMenuState();
mp-wp_genesis 274 } else {
mp-wp_genesis 275 this.fold();
mp-wp_genesis 276 }
mp-wp_genesis 277 },
mp-wp_genesis 278
mp-wp_genesis 279 restoreMenuState : function() {
mp-wp_genesis 280 $('#adminmenu li.wp-has-submenu').each(function(i, e) {
mp-wp_genesis 281 var v = getUserSetting( 'm'+i );
mp-wp_genesis 282 if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
mp-wp_genesis 283
mp-wp_genesis 284 if ( 'o' == v ) $(e).addClass('wp-menu-open');
mp-wp_genesis 285 else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
mp-wp_genesis 286 });
mp-wp_genesis 287 },
mp-wp_genesis 288
mp-wp_genesis 289 toggle : function(el) {
mp-wp_genesis 290
mp-wp_genesis 291 el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
mp-wp_genesis 292
mp-wp_genesis 293 $('#adminmenu li.wp-has-submenu').each(function(i, e) {
mp-wp_genesis 294 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
mp-wp_genesis 295 setUserSetting( 'm'+i, v );
mp-wp_genesis 296 });
mp-wp_genesis 297
mp-wp_genesis 298 return false;
mp-wp_genesis 299 },
mp-wp_genesis 300
mp-wp_genesis 301 fold : function(off) {
mp-wp_genesis 302 if (off) {
mp-wp_genesis 303 $('#wpcontent').removeClass('folded');
mp-wp_genesis 304 $('#adminmenu li.wp-has-submenu').unbind();
mp-wp_genesis 305 } else {
mp-wp_genesis 306 $('#wpcontent').addClass('folded');
mp-wp_genesis 307 $('#adminmenu li.wp-has-submenu').hoverIntent({
mp-wp_genesis 308 over: function(e){
mp-wp_genesis 309 var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
mp-wp_genesis 310
mp-wp_genesis 311 if ( (t+h+10) > H ) {
mp-wp_genesis 312 o = (t+h+10) - H;
mp-wp_genesis 313 m.css({'marginTop':'-'+o+'px'});
mp-wp_genesis 314 } else if ( m.css('marginTop') ) {
mp-wp_genesis 315 m.css({'marginTop':''})
mp-wp_genesis 316 }
mp-wp_genesis 317 m.addClass('sub-open');
mp-wp_genesis 318 },
mp-wp_genesis 319 out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
mp-wp_genesis 320 timeout: 220,
mp-wp_genesis 321 sensitivity: 8,
mp-wp_genesis 322 interval: 100
mp-wp_genesis 323 });
mp-wp_genesis 324
mp-wp_genesis 325 }
mp-wp_genesis 326 },
mp-wp_genesis 327
mp-wp_genesis 328 favorites : function() {
mp-wp_genesis 329 $('#favorite-inside').width($('#favorite-actions').width()-4);
mp-wp_genesis 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) } );
mp-wp_genesis 331
mp-wp_genesis 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) } );
mp-wp_genesis 333 }
mp-wp_genesis 334 };
mp-wp_genesis 335
mp-wp_genesis 336 $(document).ready(function(){adminMenu.init();});
mp-wp_genesis 337 })(jQuery);
mp-wp_genesis 338
mp-wp_genesis 339 (function($){
mp-wp_genesis 340 // show/hide/save table columns
mp-wp_genesis 341 columns = {
mp-wp_genesis 342 init : function(page) {
mp-wp_genesis 343 $('.hide-column-tog').click( function() {
mp-wp_genesis 344 var column = $(this).val();
mp-wp_genesis 345 var show = $(this).attr('checked');
mp-wp_genesis 346 if ( show ) {
mp-wp_genesis 347 $('.column-' + column).show();
mp-wp_genesis 348 } else {
mp-wp_genesis 349 $('.column-' + column).hide();
mp-wp_genesis 350 }
mp-wp_genesis 351 columns.save_manage_columns_state(page);
mp-wp_genesis 352 } );
mp-wp_genesis 353 },
mp-wp_genesis 354
mp-wp_genesis 355 save_manage_columns_state : function(page) {
mp-wp_genesis 356 var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
mp-wp_genesis 357 $.post('admin-ajax.php', {
mp-wp_genesis 358 action: 'hidden-columns',
mp-wp_genesis 359 hidden: hidden,
mp-wp_genesis 360 hiddencolumnsnonce: $('#hiddencolumnsnonce').val(),
mp-wp_genesis 361 page: page
mp-wp_genesis 362 });
mp-wp_genesis 363 }
mp-wp_genesis 364 }
mp-wp_genesis 365
mp-wp_genesis 366 })(jQuery);
mp-wp_genesis 367
mp-wp_genesis 368
mp-wp_genesis 369 jQuery(document).ready(function($){
mp-wp_genesis 370 if ( 'undefined' != typeof google && google.gears ) return;
mp-wp_genesis 371
mp-wp_genesis 372 var gf = false;
mp-wp_genesis 373 if ( 'undefined' != typeof GearsFactory ) {
mp-wp_genesis 374 gf = new GearsFactory();
mp-wp_genesis 375 } else {
mp-wp_genesis 376 try {
mp-wp_genesis 377 gf = new ActiveXObject('Gears.Factory');
mp-wp_genesis 378 if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
mp-wp_genesis 379 gf.privateSetGlobalObject(this);
mp-wp_genesis 380 } catch (e) {
mp-wp_genesis 381 if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
mp-wp_genesis 382 gf = document.createElement("object");
mp-wp_genesis 383 gf.style.display = "none";
mp-wp_genesis 384 gf.width = 0;
mp-wp_genesis 385 gf.height = 0;
mp-wp_genesis 386 gf.type = "application/x-googlegears";
mp-wp_genesis 387 document.documentElement.appendChild(gf);
mp-wp_genesis 388 }
mp-wp_genesis 389 }
mp-wp_genesis 390 }
mp-wp_genesis 391 if ( gf && gf.hasPermission )
mp-wp_genesis 392 return;
mp-wp_genesis 393
mp-wp_genesis 394 $('.turbo-nag').show();
mp-wp_genesis 395 });