]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/common.js
Wordpress 2.8
[autoinstalls/wordpress.git] / wp-admin / js / common.js
index 67e38d81acc58c29cf03cfb2fe5aea50589f471b..299b57618b583212d575ca009bf9d761cf78b2d2 100644 (file)
@@ -1,395 +1 @@
-
-var wpCookies = {
-// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
-
-       each : function(o, cb, s) {
-               var n, l;
-
-               if (!o)
-                       return 0;
-
-               s = s || o;
-
-               if (typeof(o.length) != 'undefined') {
-                       for (n=0, l = o.length; n<l; n++) {
-                               if (cb.call(s, o[n], n, o) === false)
-                                       return 0;
-                       }
-               } else {
-                       for (n in o) {
-                               if (o.hasOwnProperty(n)) {
-                                       if (cb.call(s, o[n], n, o) === false)
-                                               return 0;
-                               }
-                       }
-               }
-               return 1;
-       },
-
-       getHash : function(n) {
-               var v = this.get(n), h;
-
-               if (v) {
-                       this.each(v.split('&'), function(v) {
-                               v = v.split('=');
-                               h = h || {};
-                               h[v[0]] = v[1];
-                       });
-               }
-               return h;
-       },
-
-       setHash : function(n, v, e, p, d, s) {
-               var o = '';
-
-               this.each(v, function(v, k) {
-                       o += (!o ? '' : '&') + k + '=' + v;
-               });
-
-               this.set(n, o, e, p, d, s);
-       },
-
-       get : function(n) {
-               var c = document.cookie, e, p = n + "=", b;
-
-               if (!c)
-                       return;
-
-               b = c.indexOf("; " + p);
-
-               if (b == -1) {
-                       b = c.indexOf(p);
-
-                       if (b != 0)
-                               return null;
-               } else
-                       b += 2;
-
-               e = c.indexOf(";", b);
-
-               if (e == -1)
-                       e = c.length;
-
-               return decodeURIComponent(c.substring(b + p.length, e));
-       },
-
-       set : function(n, v, e, p, d, s) {
-               document.cookie = n + "=" + encodeURIComponent(v) +
-                       ((e) ? "; expires=" + e.toGMTString() : "") +
-                       ((p) ? "; path=" + p : "") +
-                       ((d) ? "; domain=" + d : "") +
-                       ((s) ? "; secure" : "");
-       },
-
-       remove : function(n, p) {
-               var d = new Date();
-
-               d.setTime(d.getTime() - 1000);
-
-               this.set(n, '', d, p, d);
-       }
-};
-
-// Returns the value as string. Second arg or empty string is returned when value is not set.
-function getUserSetting( name, def ) {
-       var o = getAllUserSettings();
-
-       if ( o.hasOwnProperty(name) )
-               return o[name];
-
-       if ( typeof def != 'undefined' )
-               return def;
-
-       return '';
-}
-
-// Both name and value must be only ASCII letters, numbers or underscore
-// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
-function setUserSetting( name, value, del ) {
-       var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
-       var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
-
-       if ( del ) delete o[n];
-       else o[n] = v;
-
-       d.setTime( d.getTime() + 31536000000 );
-       p = userSettings.url;
-
-       wpCookies.setHash(c, o, d, p );
-       wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
-}
-
-function deleteUserSetting( name ) {
-       setUserSetting( name, '', 1 );
-}
-
-// Returns all settings as js object.
-function getAllUserSettings() {
-       return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
-}
-
-
-jQuery(document).ready( function($) {
-       // pulse
-       $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
-
-       // show things that should be visible, hide what should be hidden
-       $('.hide-if-no-js').removeClass('hide-if-no-js');
-       $('.hide-if-js').hide();
-
-       // Basic form validation
-       if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
-               $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
-       }
-
-       // Move .updated and .error alert boxes
-       $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
-       $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
-
-       // screen settings tab
-       $('#show-settings-link').click(function () {
-               if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
-                       $('#contextual-help-link-wrap').addClass('invisible');
-               }
-               $('#screen-options-wrap').slideToggle('fast', function(){
-                       if ( $(this).hasClass('screen-options-open') ) {
-                               $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
-                               $('#contextual-help-link-wrap').removeClass('invisible');
-                               $(this).removeClass('screen-options-open');
-
-                       } else {
-                               $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
-                               $(this).addClass('screen-options-open');
-                       }
-               });
-               return false;
-       });
-
-       // help tab
-       $('#contextual-help-link').click(function () {
-               if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
-                       $('#screen-options-link-wrap').addClass('invisible');
-               }
-               $('#contextual-help-wrap').slideToggle('fast', function(){
-                       if ( $(this).hasClass('contextual-help-open') ) {
-                               $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
-                               $('#screen-options-link-wrap').removeClass('invisible');
-                               $(this).removeClass('contextual-help-open');
-                       } else {
-                               $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
-                               $(this).addClass('contextual-help-open');
-                       }
-               });
-               return false;
-       });
-
-       // check all checkboxes
-       var lastClicked = false;
-       $( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
-               if ( 'undefined' == e.shiftKey ) { return true; }
-               if ( e.shiftKey ) {
-                       if ( !lastClicked ) { return true; }
-                       var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
-                       var first = checks.index( lastClicked );
-                       var last = checks.index( this );
-                       var checked = $(this).attr('checked');
-                       if ( 0 < first && 0 < last && first != last ) {
-                               checks.slice( first, last ).attr( 'checked', function(){
-                                       if ( $(this).parents('tr').is(':visible') )
-                                               return checked ? 'checked' : '';
-
-                                       return '';
-                               });
-                       }
-               }
-               lastClicked = this;
-               return true;
-       } );
-       $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
-               var c = $(this).attr('checked');
-               if ( 'undefined' == typeof  toggleWithKeyboard)
-                       toggleWithKeyboard = false;
-               var toggle = e.shiftKey || toggleWithKeyboard;
-               $(this).parents( 'form:first' ).find( 'table tbody:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
-                       if ( $(this).parents('tr').is(':hidden') )
-                               return '';
-                       if ( toggle )
-                               return $(this).attr( 'checked' ) ? '' : 'checked';
-                       else if (c)
-                               return 'checked';
-                       return '';
-               });
-               $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
-                       if ( toggle )
-                               return '';
-                       else if (c)
-                               return 'checked';
-                       return '';
-               });
-       });
-});
-
-var showNotice, adminMenu, columns;
-
-// stub for doing better warnings
-showNotice = {
-       warn : function(text) {
-               if ( confirm(text) )
-                       return true;
-
-               return false;
-       },
-
-       note : function(text) {
-               alert(text);
-       }
-};
-
-(function($){
-// sidebar admin menu
-adminMenu = {
-
-       init : function() {
-               $('#adminmenu div.wp-menu-toggle').each( function() {
-                       if ( $(this).siblings('.wp-submenu').length )
-                               $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
-                       else
-                               $(this).hide();
-               });
-               $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
-               this.favorites();
-
-               $('.wp-menu-separator').click(function(){
-                       if ( $('#wpcontent').hasClass('folded') ) {
-                               adminMenu.fold(1);
-                               setUserSetting( 'mfold', 'o' );
-                       } else {
-                               adminMenu.fold();
-                               setUserSetting( 'mfold', 'f' );
-                       }
-               });
-
-               if ( 'f' != getUserSetting( 'mfold' ) ) {
-                       this.restoreMenuState();
-               } else {
-                       this.fold();
-               }
-       },
-
-       restoreMenuState : function() {
-               $('#adminmenu li.wp-has-submenu').each(function(i, e) {
-                       var v = getUserSetting( 'm'+i );
-                       if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
-
-                       if ( 'o' == v ) $(e).addClass('wp-menu-open');
-                       else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
-               });
-       },
-
-       toggle : function(el) {
-
-               el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
-
-               $('#adminmenu li.wp-has-submenu').each(function(i, e) {
-                       var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
-                       setUserSetting( 'm'+i, v );
-               });
-
-               return false;
-       },
-
-       fold : function(off) {
-               if (off) {
-                       $('#wpcontent').removeClass('folded');
-                       $('#adminmenu li.wp-has-submenu').unbind();
-               } else {
-                       $('#wpcontent').addClass('folded');
-                       $('#adminmenu li.wp-has-submenu').hoverIntent({
-                               over: function(e){
-                                       var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
-
-                                       if ( (t+h+10) > H ) {
-                                               o = (t+h+10) - H;
-                                               m.css({'marginTop':'-'+o+'px'});
-                                       } else if ( m.css('marginTop') ) {
-                                               m.css({'marginTop':''})
-                                       }
-                                       m.addClass('sub-open');
-                               },
-                               out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
-                               timeout: 220,
-                               sensitivity: 8,
-                               interval: 100
-                       });
-
-               }
-       },
-
-       favorites : function() {
-               $('#favorite-inside').width($('#favorite-actions').width()-4);
-               $('#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) } );
-
-               $('#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) } );
-       }
-};
-
-$(document).ready(function(){adminMenu.init();});
-})(jQuery);
-
-(function($){
-// show/hide/save table columns
-columns = {
-       init : function(page) {
-               $('.hide-column-tog').click( function() {
-                       var column = $(this).val();
-                       var show = $(this).attr('checked');
-                       if ( show ) {
-                               $('.column-' + column).show();
-                       } else {
-                               $('.column-' + column).hide();
-                       }
-                       columns.save_manage_columns_state(page);
-               } );
-       },
-
-       save_manage_columns_state : function(page) {
-               var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
-               $.post('admin-ajax.php', {
-                       action: 'hidden-columns',
-                       hidden: hidden,
-                       hiddencolumnsnonce: $('#hiddencolumnsnonce').val(),
-                       page: page
-               });
-       }
-}
-
-})(jQuery);
-
-
-jQuery(document).ready(function($){
-       if ( 'undefined' != typeof google && google.gears ) return;
-
-       var gf = false;
-       if ( 'undefined' != typeof GearsFactory ) {
-               gf = new GearsFactory();
-       } else {
-               try {
-                       gf = new ActiveXObject('Gears.Factory');
-                       if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
-                               gf.privateSetGlobalObject(this);
-               } catch (e) {
-                       if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
-                               gf = document.createElement("object");
-                               gf.style.display = "none";
-                               gf.width = 0;
-                               gf.height = 0;
-                               gf.type = "application/x-googlegears";
-                               document.documentElement.appendChild(gf);
-                       }
-               }
-       }
-       if ( gf && gf.hasPermission )
-               return;
-
-       $('.turbo-nag').show();
-});
+var showNotice,adminMenu,columns;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()})})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name="action"]').val()=="delete"||d('select[name="action2"]').val()=="delete"){return showNotice.warn()}});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b(".turbo-nag");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()});
\ No newline at end of file