WordPress.org

Make WordPress Core

Changeset 10291


Ignore:
Timestamp:
01/02/2009 03:08:58 PM (11 years ago)
Author:
azaozz
Message:

Minify all js and add the non-minified files as .dev.js

Location:
trunk
Files:
40 added
44 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/cat.js

    r6303 r10291  
    1 jQuery( function($) {
    2     var myConfirm = function() { return '' !== $('#newcat').val(); };
    3     $('#jaxcat').prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" class="add:categorychecklist:jaxcat" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span><span id="cat-ajax-response"></span>')
    4     $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } );
    5 } );
     1jQuery(document).ready(function(b){var a=function(){return""!==b("#newcat").val()};b("#jaxcat").prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" class="add:categorychecklist:jaxcat" id="catadd" value="'+catL10n.add+'"/><input type="hidden"/><input type="hidden"/><span id="howto">'+catL10n.how+'</span></span><span id="cat-ajax-response"></span>');b("#categorychecklist").wpList({alt:"",response:"cat-ajax-response",confirm:a})});
  • trunk/wp-admin/js/categories.js

    r10150 r10291  
    1 jQuery(function($) {
    2     var options = false
    3     if ( document.forms['addcat'].category_parent )
    4         options = document.forms['addcat'].category_parent.options;
    5 
    6     var addAfter = function( r, settings ) {
    7         var name = $("<span>" + $('name', r).text() + "</span>").html();
    8         var id = $('cat', r).attr('id');
    9         options[options.length] = new Option(name, id);
    10 
    11         addAfter2( r, settings );
    12     }
    13 
    14     var addAfter2 = function( x, r ) {
    15         var t = $(r.parsed.responses[0].data);
    16         if ( t.length == 1 )
    17             inlineEditTax.addEvents($(t.id));
    18     }
    19 
    20     var delAfter = function( r, settings ) {
    21         var id = $('cat', r).attr('id');
    22         for ( var o = 0; o < options.length; o++ )
    23             if ( id == options[o].value )
    24                 options[o] = null;
    25     }
    26 
    27     if ( options )
    28         $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
    29     else
    30         $('#the-list').wpList({ addAfter: addAfter2 });
    31 
    32     if ( jQuery('#link-category-search-input').size() ) {
    33         columns.init('edit-link-categories');
    34     } else {
    35         columns.init('categories');
    36     }
    37 });
     1jQuery(document).ready(function(c){var b=false,e,d,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}e=function(h,g){var f,i;f=c("<span>"+c("name",h).text()+"</span>").html();i=c("cat",h).attr("id");b[b.length]=new Option(f,i);d(h,g)};d=function(f,h){var g=c(h.parsed.responses[0].data);if(g.length==1){inlineEditTax.addEvents(c(g.id))}};a=function(g,f){var i=c("cat",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};if(b){c("#the-list").wpList({addAfter:e,delAfter:a})}else{c("#the-list").wpList({addAfter:d})}if(jQuery("#link-category-search-input").size()){columns.init("edit-link-categories")}else{columns.init("categories")}});
  • trunk/wp-admin/js/comment.js

    r10258 r10291  
    1 jQuery(document).ready( function($) {
    2 
    3     var stamp = $('#timestamp').html();
    4     $('.edit-timestamp').click(function () {
    5         if ($('#timestampdiv').is(":hidden")) {
    6             $('#timestampdiv').slideDown("normal");
    7             $('.edit-timestamp').hide();
    8         }
    9         return false;
    10     });
    11 
    12     $('.cancel-timestamp').click(function() {
    13         $('#timestampdiv').slideUp("normal");
    14         $('#mm').val($('#hidden_mm').val());
    15         $('#jj').val($('#hidden_jj').val());
    16         $('#aa').val($('#hidden_aa').val());
    17         $('#hh').val($('#hidden_hh').val());
    18         $('#mn').val($('#hidden_mn').val());
    19         $('#timestamp').html(stamp);
    20         $('.edit-timestamp').show();
    21         return false;
    22     });
    23 
    24     $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
    25         $('#timestampdiv').slideUp("normal");
    26         $('.edit-timestamp').show();
    27         $('#timestamp').html(
    28             commentL10n.submittedOn + ' <b>' +
    29             $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
    30             $('#jj').val() + ', ' +
    31             $('#aa').val() + ' @ ' +
    32             $('#hh').val() + ':' +
    33             $('#mn').val() + '</b> '
    34         );
    35         return false;
    36     });
    37 });
     1jQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+"</b> ");return false})});
  • trunk/wp-admin/js/common.js

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

    r7131 r10291  
    1 jQuery( function($) {
    2     var before = function() {
    3         var nonce = $('#newmeta [@name=_ajax_nonce]').val();
    4         var postId = $('#post_ID').val();
    5         if ( !nonce || !postId ) { return false; }
    6         return [nonce,postId];
    7     }
    8 
    9     var addBefore = function( s ) {
    10         var b = before();
    11         if ( !b ) { return false; }
    12         s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
    13         return s;
    14     };
    15 
    16     var addAfter = function( r, s ) {
    17         var postId = $('postid', r).text();
    18         if ( !postId ) { return; }
    19         $('#post_ID').attr( 'name', 'post_ID' ).val( postId );
    20         var h = $('#hiddenaction');
    21         if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
    22     };
    23 
    24     var delBefore = function( s ) {
    25         var b = before(); if ( !b ) return false;
    26         s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
    27         return s;
    28     }
    29 
    30     $('#the-list')
    31         .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } )
    32         .find('.updatemeta, .deletemeta').attr( 'type', 'button' );
    33 } );
     1jQuery(document).ready(function(d){var c,b,e,a;c=function(){var g=d("#newmeta [@name=_ajax_nonce]").val(),f=d("#post_ID").val();if(!g||!f){return false}return[g,f]};b=function(g){var f=c();if(!f){return false}g.data=g.data.replace(/_ajax_nonce=[a-f0-9]+/,"_ajax_nonce="+f[0])+"&post_id="+f[1];return g};e=function(j,i){var f=d("postid",j).text(),g;if(!f){return}d("#post_ID").attr("name","post_ID").val(f);g=d("#hiddenaction");if("post"==g.val()){g.val("postajaxpost")}};a=function(g){var f=c();if(!f){return false}g.data._ajax_nonce=f[0];g.data.post_id=f[1];return g};d("#the-list").wpList({addBefore:b,addAfter:e,delBefore:a}).find(".updatemeta, .deletemeta").attr("type","button")});
  • trunk/wp-admin/js/dashboard.js

    r10258 r10291  
    1 
    2 jQuery( function($) {
    3 
    4 // These widgets are sometimes populated via ajax
    5 var ajaxWidgets = [
    6     'dashboard_incoming_links',
    7     'dashboard_primary',
    8     'dashboard_secondary',
    9     'dashboard_plugins'
    10 ];
    11 
    12 var ajaxPopulateWidgets = function() {
    13     $.each( ajaxWidgets, function() {
    14         var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading');
    15         if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); }
    16     } );
    17 };
    18 ajaxPopulateWidgets();
    19 
    20 postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } );
    21 
    22 /* QuickPress */
    23 var quickPressLoad = function() {
    24     var act = $('#quickpost-action');
    25     var t = $('#quick-press').submit( function() {
    26         $('#dashboard_quick_press h3').append( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
    27 
    28         if ( 'post' == act.val() ) {
    29             act.val( 'post-quickpress-publish' );
    30         }
    31 
    32         $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
    33             $('#dashboard_quick_press h3 img').remove();
    34             $('#dashboard_quick_press ul').find('li').each( function() {
    35                 $('#dashboard_recent_drafts ul').prepend( this );
    36             } ).end().remove();
    37             tb_init('a.thickbox');
    38             quickPressLoad();
    39         } );
    40         return false;
    41     } );
    42 
    43     $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
    44 
    45 };
    46 quickPressLoad();
    47 
    48 } );
     1jQuery(document).ready(function(c){var a,b,d;a=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];b=function(){c.each(a,function(){var f=jQuery("#"+this+":visible div.inside").find(".widget-loading");if(f.size()){f.parent().load("index-extra.php?jax="+this)}})};b();postboxes.add_postbox_toggles("dashboard",{onShow:b});d=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press h3").append('<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />');if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press h3 img").remove();c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");d()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};d()});
  • trunk/wp-admin/js/edit-comments.js

    r10258 r10291  
    1 var theList; var theExtraList;
    2 (function($) {
    3 
    4 setCommentsList = function() {
    5     var totalInput = $('#comments-form .tablenav :input[name="_total"]');
    6     var perPageInput = $('#comments-form .tablenav :input[name="_per_page"]');
    7     var pageInput = $('#comments-form .tablenav :input[name="_page"]');
    8     var lastConfidentTime = 0;
    9 
    10     var dimAfter = function( r, settings ) {
    11         var c = $('#' + settings.element);
    12 
    13         if ( c.is('.unapproved') )
    14             c.find('div.comment_status').html('0')
    15         else
    16             c.find('div.comment_status').html('1')
    17 
    18         $('span.pending-count').each( function() {
    19             var a = $(this);
    20             var n = a.html().replace(/[ ,.]+/g, '');
    21             n = parseInt(n,10);
    22             if ( isNaN(n) ) return;
    23             n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
    24             if ( n < 0 ) { n = 0; }
    25             $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
    26             n = n.toString();
    27             if ( n.length > 3 )
    28                 n = n.substr(0, n.length-3)+' '+n.substr(-3);
    29             a.html(n);
    30         });
    31     };
    32 
    33     // Send current total, page, per_page and url
    34     var delBefore = function( settings ) {
    35         settings.data._total = totalInput.val();
    36         settings.data._per_page = perPageInput.val();
    37         settings.data._page = pageInput.val();
    38         settings.data._url = document.location.href;
    39         return settings;
    40     };
    41 
    42     /* Updates the current total (as displayed visibly)
    43     */
    44     var updateTotalCount = function( total, time, setConfidentTime ) {
    45         if ( time < lastConfidentTime ) {
    46             return;
    47         }
    48         totalInput.val( total.toString() );
    49         if ( setConfidentTime ) {
    50             lastConfidentTime = time;
    51         }
    52         $('span.total-type-count').each( function() {
    53             var a = $(this);
    54             var n = totalInput.val().toString();
    55             if ( n.length > 3 )
    56                 n = n.substr(0, n.length-3)+' '+n.substr(-3);
    57             a.html(n);
    58         });
    59 
    60     };
    61 
    62     // In admin-ajax.php, we send back the unix time stamp instead of 1 on success
    63     var delAfter = function( r, settings ) {
    64         $('span.pending-count').each( function() {
    65             var a = $(this);
    66             var n = a.html().replace(/[ ,.]+/g, '');
    67             n = parseInt(n,10);
    68             if ( isNaN(n) ) return;
    69             if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
    70                 n = n - 1;
    71             } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
    72                 n = n + 1;
    73             }
    74             if ( n < 0 ) { n = 0; }
    75             $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
    76             n = n.toString();
    77             if ( n.length > 3 )
    78                 n = n.substr(0, n.length-3)+' '+n.substr(-3);
    79             a.html(n);
    80         });
    81 
    82         $('span.spam-count').each( function() {
    83             var a = $(this);
    84             var n = a.html().replace(/[ ,.]+/g, '');
    85             n = parseInt(n,10);
    86             if ( isNaN(n) ) return;
    87             if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
    88                 n = n + 1;
    89             } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
    90                 n = n - 1;
    91             }
    92             if ( n < 0 ) { n = 0; }
    93             n = n.toString();
    94             if ( n.length > 3 )
    95                 n = n.substr(0, n.length-3)+' '+n.substr(-3);
    96             a.html(n);
    97         });
    98 
    99        
    100         // XML response
    101         if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
    102             // Set the total to the known good value (even if this value is a little old, newer values should only be a few less, and so shouldn't mess up the page links)
    103             updateTotalCount( settings.parsed.responses[0].supplemental.total, settings.parsed.responses[0].supplemental.time, true );
    104             if ( $.trim( settings.parsed.responses[0].supplemental.pageLinks ) ) {
    105                 $('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( settings.parsed.responses[0].supplemental.pageLinks ) );
    106             } else if ( 'undefined' != typeof settings.parsed.responses[0].supplemental.pageLinks ) {
    107                 $('.tablenav-pages').find( '.page-numbers' ).remove();
    108             }
    109         } else {
    110             // Decrement the total
    111             var total = parseInt( totalInput.val(), 10 );
    112             if ( total-- < 0 )
    113                 total = 0;
    114             updateTotalCount( total, r, false );
    115         }
    116 
    117         if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
    118             return;
    119         }
    120 
    121         theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
    122         $('#get-extra-comments').submit();
    123     };
    124 
    125     theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
    126     theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
    127 
    128 };
    129 
    130 $(document).ready(function(){
    131     setCommentsList();
    132 });
    133 
    134 commentReply = {
    135 
    136     init : function() {
    137         var row = $('#replyrow');
    138 
    139         $('a.cancel', row).click(function() { return commentReply.revert(); });
    140         $('a.save', row).click(function() { return commentReply.send(this); });
    141 
    142         // add events
    143         $('#the-comment-list .column-comment > p').dblclick(function(){
    144                 commentReply.toggle($(this).parent());
    145             });
    146 
    147         $('#doaction, #doaction2, #post-query-submit').click(function(e){
    148             if ( $('#the-comment-list #replyrow').length > 0 )
    149                 t.close();
    150         });
    151 
    152     },
    153 
    154     addEvents : function(r) {
    155         r.each(function() {
    156             $(this).find('.column-comment > p').dblclick(function(){
    157                 commentReply.toggle($(this).parent());
    158             });
    159         });
    160     },
    161 
    162     toggle : function(el) {
    163         if ( $(el).css('display') != 'none' )
    164             $(el).find('a.vim-q').click();
    165     },
    166 
    167     revert : function() {
    168 
    169         if ( $('#the-comment-list #replyrow').length < 1 )
    170             return false;
    171 
    172         $('#replyrow').fadeOut('fast', function(){
    173             commentReply.close();
    174         });
    175 
    176         return false;
    177     },
    178 
    179     close : function() {
    180         $(this.o).fadeIn('fast').css('backgroundColor', '');
    181         $('#com-reply').append( $('#replyrow') );
    182         $('#replycontent').val('');
    183         $('#edithead input').val('');
    184         $('#replysubmit .error').html('').hide();
    185         $('#replysubmit .waiting').hide();
    186         if ( $.browser.msie )
    187             $('#replycontainer, #replycontent').css('height', '120px');
    188         else
    189             $('#replycontainer').resizable('destroy').css('height', '120px');
    190     },
    191 
    192     open : function(id, p, a) {
    193         var t = this;
    194         t.close();
    195         t.o = '#comment-'+id;
    196 
    197         $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
    198         var editRow = $('#replyrow'), rowData = $('#inline-'+id);
    199         var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
    200 
    201         $('#action', editRow).val(act);
    202         $('#comment_post_ID', editRow).val(p);
    203         $('#comment_ID', editRow).val(id);
    204 
    205         if ( a == 'edit' ) {
    206             $('#author', editRow).val( $('div.author', rowData).text() );
    207             $('#author-email', editRow).val( $('div.author-email', rowData).text() );
    208             $('#author-url', editRow).val( $('div.author-url', rowData).text() );
    209             $('#status', editRow).val( $('div.comment_status', rowData).text() );
    210             $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
    211             $('#edithead, #savebtn', editRow).show();
    212             $('#replyhead, #replybtn', editRow).hide();
    213 
    214             var h = $(t.o).height();
    215             if ( h > 220 )
    216                 if ( $.browser.msie )
    217                     $('#replycontainer, #replycontent', editRow).height(h-105);
    218                 else
    219                     $('#replycontainer', editRow).height(h-105);
    220 
    221             $(t.o).after(editRow.hide()).fadeOut('fast', function(){
    222                 $('#replyrow').fadeIn('fast');
    223             });
    224         } else {
    225             $('#edithead, #savebtn', editRow).hide();
    226             $('#replyhead, #replybtn', editRow).show();
    227             $(t.o).after(editRow);
    228             $('#replyrow').hide().fadeIn('fast');
    229         }
    230 
    231         if ( ! $.browser.msie )
    232             $('#replycontainer').resizable({
    233                 handles : 's',
    234                 axis : 'y',
    235                 minHeight : 80,
    236                 stop : function() {
    237                     $('#replycontainer').width('auto');
    238                 }
    239             });
    240 
    241         setTimeout(function() {
    242             var rtop = $('#replyrow').offset().top;
    243             var rbottom = rtop + $('#replyrow').height();
    244             var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
    245             var vp = document.documentElement.clientHeight || self.innerHeight || 0;
    246             var scrollBottom = scrollTop + vp;
    247 
    248             if ( scrollBottom - 20 < rbottom )
    249                 window.scroll(0, rbottom - vp + 35);
    250             else if ( rtop - 20 < scrollTop )
    251                 window.scroll(0, rtop - 35);
    252 
    253             $('#replycontent').focus().keyup(function(e){
    254                 if (e.which == 27) commentReply.revert(); // close on Escape
    255             });
    256         }, 600);
    257 
    258         return false;
    259     },
    260 
    261     send : function() {
    262         var post = {};
    263 
    264         $('#replysubmit .waiting').show();
    265 
    266         $('#replyrow input').each(function() {
    267             post[ $(this).attr('name') ] = $(this).val();
    268         });
    269 
    270         post.content = $('#replycontent').val();
    271         post.id = post.comment_post_ID;
    272 
    273         $.ajax({
    274             type : 'POST',
    275             url : wpListL10n.url,
    276             data : post,
    277             success : function(x) { commentReply.show(x); },
    278             error : function(r) { commentReply.error(r); }
    279         });
    280 
    281         return false;
    282     },
    283 
    284     show : function(xml) {
    285 
    286         if ( typeof(xml) == 'string' ) {
    287             this.error({'responseText': xml});
    288             return false;
    289         }
    290 
    291         var r = wpAjax.parseAjaxResponse(xml);
    292         if ( r.errors ) {
    293             this.error({'responseText': wpAjax.broken});
    294             return false;
    295         }
    296 
    297         if ( 'edit-comment' == this.act )
    298             $(this.o).remove();
    299 
    300         r = r.responses[0];
    301         var c = r.data;
    302 
    303         $(c).hide()
    304         $('#replyrow').after(c);
    305         this.o = id = '#comment-'+r.id;
    306         this.revert();
    307         this.addEvents($(id));
    308         var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
    309 
    310         $(id)
    311             .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
    312             .animate( { 'backgroundColor': bg }, 600 );
    313 
    314         $.fn.wpList.process($(id))
    315     },
    316 
    317     error : function(r) {
    318         var er = r.statusText;
    319 
    320         $('#replysubmit .waiting').hide();
    321 
    322         if ( r.responseText )
    323             er = r.responseText.replace( /<.[^<>]*?>/g, '' );
    324 
    325         if ( er )
    326             $('#replysubmit .error').html(er).show();
    327 
    328     }
    329 };
    330 toggleWithKeyboard = false;
    331 $(document).ready(function(){
    332     columns.init('edit-comments');
    333     commentReply.init();
    334 
    335     if ( typeof QTags != 'undefined' )
    336         ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
    337 
    338     if ( typeof $.table_hotkeys != 'undefined' ) {
    339         var make_hotkeys_redirect = function(which) {
    340             return function() {
    341                 var first_last = 'next' == which? 'first' : 'last';
    342                 var l=$('.'+which+'.page-numbers');
    343                 if (l.length)
    344                     window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
    345             }
    346         };
    347         var edit_comment = function(event, current_row) {
    348             window.location = $('span.edit a', current_row).attr('href');
    349         };
    350         var toggle_all = function() {
    351             toggleWithKeyboard = true;
    352             var master_checkbox = $('form#comments-form .check-column :checkbox:first');
    353             master_checkbox.click().attr('checked', '');
    354             toggleWithKeyboard = false;
    355         }
    356         var make_bulk = function(value) {
    357             return function(event, _) {
    358                 $('option[value='+value+']').attr('selected', 'selected');
    359                 $('form#comments-form')[0].submit();
    360             }
    361         };
    362         $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
    363                 ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
    364                 ['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
    365                 ['shift+u', make_bulk('unapprove')]],
    366                 {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
    367                 prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
    368         );
    369     }
    370 });
    371 
    372 })(jQuery);
     1var theList,theExtraList;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}a("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;return j};d=function(j,k,l){if(k<f){return}g.val(j.toString());if(l){f=k}a("span.total-type-count").each(function(){var m=a(this),o;o=g.val().toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}a("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f<j.parsed.responses[0].supplemental.time){d(j.parsed.responses[0].supplemental.total,j.parsed.responses[0].supplemental.time,true);if(a.trim(j.parsed.responses[0].supplemental.pageLinks)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(j.parsed.responses[0].supplemental.pageLinks))}else{if("undefined"!=typeof j.parsed.responses[0].supplemental.pageLinks){a(".tablenav-pages").find(".page-numbers").remove()}}}else{var k=parseInt(g.val(),10);if(k--<0){k=0}d(k,l,false)}if(theExtraList.size()==0||theExtraList.children().size()==0){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:c,delAfter:b,addColor:"none"})};a(document).ready(function(){setCommentsList()});commentReply={init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send(this)});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}})},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20<j){window.scroll(0,j-h+35)}else{if(l-20<m){window.scroll(0,l-35)}}a("#replycontent").focus().keyup(function(n){if(n.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;a.ajax({type:"POST",url:wpListL10n.url,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}if("edit-comment"==this.act){a(this.o).remove()}e=e.responses[0];g=e.data;a(g).hide();a("#replyrow").after(g);this.o=f="#comment-"+e.id;this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600);a.fn.wpList.process(a(f))},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};toggleWithKeyboard=false;a(document).ready(function(){var e,b,c,d;columns.init("edit-comments");commentReply.init();if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;var f=a("form#comments-form .check-column :checkbox:first");f.click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);
  • trunk/wp-admin/js/editor.js

    r10232 r10291  
    1 
    2 var switchEditors = {
    3 
    4     mode : '',
    5 
    6     I : function(e) {
    7         return document.getElementById(e);
    8     },
    9 
    10     edInit : function() {
    11         var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
    12 
    13         // Activate TinyMCE if it's the user's default editor
    14         if ( getUserSetting( 'editor' ) == 'html' ) {
    15             if ( h )
    16                 try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
    17         } else {
    18             try {
    19                 this.I("quicktags").style.display = "none";
    20             } catch(e){};
    21             tinyMCE.execCommand("mceAddControl", false, "content");
    22         }
    23     },
    24 
    25     saveCallback : function(el, content, body) {
    26 
    27         if ( tinyMCE.activeEditor.isHidden() )
    28             content = this.I(el).value;
    29         else
    30             content = this.pre_wpautop(content);
    31 
    32         return content;
    33     },
    34 
    35     pre_wpautop : function(content) {
    36         // We have a TON of cleanup to do. Line breaks are already stripped.
    37 
    38         // Protect pre|script tags
    39         content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
    40             a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
    41             return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
    42         });
    43 
    44         // Pretty it up for the source editor
    45         var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
    46         content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
    47         content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
    48 
    49         // Mark </p> if it has any attributes.
    50         content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
    51 
    52         // Sepatate <div> containing <p>
    53         content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
    54 
    55         // Remove <p> and <br />
    56         content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
    57         content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
    58         content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
    59         content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
    60 
    61         // Fix some block element newline issues
    62         content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
    63         content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
    64         content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
    65         content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
    66 
    67         var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
    68         content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
    69         content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
    70         content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
    71 
    72         if ( content.indexOf('<object') != -1 ) {
    73             content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
    74             content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
    75         }
    76 
    77         // Unmark special paragraph closing tags
    78         content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
    79         content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
    80 
    81         // Trim whitespace
    82         content = content.replace(new RegExp('^\\s*', ''), '');
    83         content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), '');
    84 
    85         // put back the line breaks in pre|script
    86         content = content.replace(/<wp_temp>/g, '\n');
    87 
    88         // Hope.
    89         return content;
    90     },
    91 
    92     go : function(id, mode) {
    93         id = id || 'content';
    94         mode = mode || this.mode || '';
    95 
    96         var ed = tinyMCE.get(id) || false;
    97         var qt = this.I('quicktags');
    98         var H = this.I('edButtonHTML');
    99         var P = this.I('edButtonPreview');
    100         var ta = this.I(id);
    101 
    102         if ( 'tinymce' == mode ) {
    103 
    104             if ( ed && ! ed.isHidden() )
    105                 return false;
    106 
    107             this.mode = 'html';
    108             ta.style.color = '#fff';
    109 
    110             P.className = 'active';
    111             H.className = '';
    112             edCloseAllTags(); // :-(
    113 
    114             qt.style.display = 'none';
    115 
    116             ta.value = this.wpautop(ta.value);
    117 
    118             if ( ed ) ed.show();
    119             else tinyMCE.execCommand("mceAddControl", false, id);
    120 
    121             setUserSetting( 'editor', 'tinymce' );
    122         } else {
    123             if ( ! ed || ed.isHidden() )
    124                 return false;
    125 
    126             this.mode = 'tinymce';
    127             H.className = 'active';
    128             P.className = '';
    129 
    130             ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
    131 
    132             ed.hide();
    133             qt.style.display = 'block';
    134 
    135             ta.style.color = '';
    136             setUserSetting( 'editor', 'html' );
    137         }
    138         return false;
    139     },
    140 
    141     wpautop : function(pee) {
    142         var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]';
    143 
    144         pee = pee + "\n\n";
    145         pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
    146         pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
    147         pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
    148         pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
    149         pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
    150         pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
    151         pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
    152         pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
    153         pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
    154         pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
    155         pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
    156         pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
    157         pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
    158         pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
    159         pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
    160         pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
    161         pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
    162         // pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
    163 
    164         // Fix the pre|script tags
    165         pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
    166             a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
    167             return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
    168         });
    169 
    170         return pee;
    171     }
    172 };
     1var switchEditors={mode:"",I:function(a){return document.getElementById(a)},edInit:function(){var a=tinymce.util.Cookie.getHash("TinyMCE_content_size");if(getUserSetting("editor")=="html"){if(a){try{this.I("content").style.height=a.ch-30+"px"}catch(b){}}}else{try{this.I("quicktags").style.display="none"}catch(b){}tinyMCE.execCommand("mceAddControl",false,"content")}},saveCallback:function(b,c,a){if(tinyMCE.activeEditor.isHidden()){c=this.I(b).value}else{c=this.pre_wpautop(c)}return c},pre_wpautop:function(b){var c,a;b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>[\r\n]*/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"<wp_temp>")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(<p [^>]+>.*?)</p>","mg"),"$1</p#>");b=b.replace(new RegExp("<div([^>]*)>\\s*<p>","mgi"),"<div$1>\n\n");b=b.replace(new RegExp("\\s*<p>","mgi"),"");b=b.replace(new RegExp("\\s*</p>\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*<br ?/?>\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*<div","mg"),"\n<div");b=b.replace(new RegExp("</div>\\s*","mg"),"</div>\n");b=b.replace(new RegExp("\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*","gi"),"\n\n[caption$1[/caption]\n\n");b=b.replace(new RegExp("caption\\]\\n\\n+\\[caption","g"),"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre";b=b.replace(new RegExp("\\s*<(("+a+") ?[^>]*)\\s*>","mg"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("<li([^>]*)>","g"),"\t<li$1>");if(b.indexOf("<object")!=-1){b=b.replace(new RegExp("\\s*<param([^>]*)>\\s*","mg"),"<param$1>");b=b.replace(new RegExp("\\s*</embed>\\s*","mg"),"</embed>")}b=b.replace(new RegExp("</p#>","g"),"</p>\n");b=b.replace(new RegExp("\\s*(<p [^>]+>.*</p>)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(/<wp_temp>/g,"\n");return b},go:function(g,e){g=g||"content";e=e||this.mode||"";var b=tinyMCE.get(g)||false,f=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(g);if("tinymce"==e){if(b&&!b.isHidden()){return false}this.mode="html";a.style.color="#fff";d.className="active";c.className="";edCloseAllTags();f.style.display="none";a.value=this.wpautop(a.value);if(b){b.show()}else{tinyMCE.execCommand("mceAddControl",false,g)}setUserSetting("editor","tinymce")}else{if(!b||b.isHidden()){return false}this.mode="tinymce";c.className="active";d.className="";a.style.height=b.getContentAreaContainer().offsetHeight+6+"px";b.hide();f.style.display="block";a.style.color="";setUserSetting("editor","html")}return false},wpautop:function(a){var b="table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]";a=a+"\n\n";a=a.replace(new RegExp("<br />\\s*<br />","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(new RegExp("\\r\\n|\\r","g"),"\n");a=a.replace(new RegExp("\\n\\s*\\n+","g"),"\n\n");a=a.replace(new RegExp("([\\s\\S]+?)\\n\\n","mg"),"<p>$1</p>\n");a=a.replace(new RegExp("<p>\\s*?</p>","gi"),"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("<p>(<li.+?)</p>","gi"),"$1");a=a.replace(new RegExp("<p>\\s*<blockquote([^>]*)>","gi"),"<blockquote$1><p>");a=a.replace(new RegExp("</blockquote>\\s*</p>","gi"),"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(new RegExp("<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)","gi"),"$1");a=a.replace(new RegExp("(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/<br ?\/?>[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}};
  • trunk/wp-admin/js/gallery.js

    r9917 r10291  
    1 jQuery(function($) {
    2     var gallerySortable;
    3     var gallerySortableInit = function() {
    4         gallerySortable = $('#media-items').sortable( {
    5             items: '.media-item',
    6             placeholder: 'sorthelper',
    7             axis: 'y',
    8             distance: 2,
    9             update: galleryReorder
    10         } );
    11     }
    12 
    13     // When an update has occurred, adjust the order for each item
    14     var galleryReorder = function(e, sort) {
    15         jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
    16             jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
    17         });
    18     }
    19 
    20     // initialize sortable
    21     gallerySortableInit();
    22 });
    23 
    24 jQuery(document).ready(function($){
    25     $('.menu_order_input').each(function(){
    26         if ( this.value == '0' ) this.value = '';
    27     });
    28 
    29     if ( $('#media-items>*').length > 1 ) {
    30         var w = wpgallery.getWin();
    31 
    32         $('#save-all, #gallery-settings').show();
    33         if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
    34             wpgallery.mcemode = true;
    35             wpgallery.init();
    36         } else {
    37             $('#insert-gallery').show();
    38         }
    39     }
    40 });
    41 
    42 jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
    43 
    44 /* gallery settings */
    45 var tinymce = null, tinyMCE;
    46 
    47 var wpgallery = {
    48     mcemode : false,
    49     editor : {},
    50     dom : {},
    51     is_update : false,
    52     el : {},
    53 
    54     I : function(e) {
    55         return document.getElementById(e);
    56     },
    57 
    58     init: function() {
    59         var t = this, li, q, i, it, w = t.getWin();
    60 
    61         if ( ! t.mcemode ) return;
    62 
    63         li = ('' + document.location.search).replace(/^\?/, '').split('&');
    64         q = {};
    65         for (i=0; i<li.length; i++) {
    66             it = li[i].split('=');
    67             q[unescape(it[0])] = unescape(it[1]);
    68         }
    69 
    70         if (q.mce_rdomain)
    71             document.domain = q.mce_rdomain;
    72 
    73         // Find window & API
    74         tinymce = w.tinymce;
    75         tinyMCE = w.tinyMCE;
    76         t.editor = tinymce.EditorManager.activeEditor;
    77 
    78         t.setup();
    79     },
    80 
    81     getWin : function() {
    82         return window.dialogArguments || opener || parent || top;
    83     },
    84 
    85     restoreSelection : function() {
    86         var t = this;
    87 
    88         if (tinymce.isIE)
    89             t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
    90     },
    91 
    92     setup : function() {
    93         var t = this, a, f = document.forms[0], ed = t.editor, el, g;
    94         if ( ! t.mcemode ) return;
    95 
    96         t.restoreSelection();
    97         t.el = ed.selection.getNode();
    98 
    99         if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
    100             if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
    101                 t.el = g[0];
    102             } else {
    103                 if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
    104                 if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
    105                 if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
    106                 if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
    107                 jQuery('#insert-gallery').show();
    108                 return;
    109             }
    110         }
    111 
    112         a = ed.dom.getAttrib(t.el, 'title');
    113         a = ed.dom.decode(a);
    114 
    115         if ( a ) {
    116             jQuery('#update-gallery').show();
    117             t.is_update = true;
    118 
    119             var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
    120             var order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
    121 
    122             if ( link && link[1] ) t.I('linkto-file').checked = "checked";
    123             if ( order && order[1] ) t.I('order-desc').checked = "checked";
    124             if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
    125             if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
    126         } else {
    127             jQuery('#insert-gallery').show();
    128         }
    129     },
    130 
    131     update : function() {
    132         var t = this, ed = t.editor, el, all = '';
    133 
    134         if ( ! t.mcemode || ! t.is_update ) {
    135             var s = '[gallery'+t.getSettings()+']';
    136             t.getWin().send_to_editor(s);
    137             return;
    138         }
    139 
    140         if (t.el.nodeName != 'IMG') return;
    141 
    142         all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
    143         all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
    144         all += t.getSettings();
    145 
    146         ed.dom.setAttrib(t.el, 'title', all);
    147         t.getWin().tb_remove();
    148     },
    149 
    150     getSettings : function() {
    151         var I = this.I, s = '';
    152 
    153         if ( I('linkto-file').checked ) {
    154             s += ' link="file"';
    155             setUserSetting('galfile', '1');
    156         }
    157 
    158         if ( I('order-desc').checked ) {
    159             s += ' order="DESC"';
    160             setUserSetting('galdesc', '1');
    161         }
    162 
    163         if ( I('columns').value != 3 ) {
    164             s += ' columns="'+I('columns').value+'"';
    165             setUserSetting('galcols', I('columns').value);
    166         }
    167 
    168         if ( I('orderby').value != 'menu_order' ) {
    169             s += ' orderby="'+I('orderby').value+'"';
    170             setUserSetting('galord', I('orderby').value);
    171         }
    172 
    173         return s;
    174     }
    175 };
     1jQuery(document).ready(function(d){var c,e,b,a;e=function(){c=d("#media-items").sortable({items:".media-item",placeholder:"sorthelper",axis:"y",distance:2,update:b})};b=function(g,f){jQuery.each(f.element.sortable("toArray"),function(h,j){jQuery("#"+j+" .menu_order input")[0].value=(1+h)})};e();d(".menu_order_input").each(function(){if(this.value=="0"){this.value=""}});if(d("#media-items>*").length>1){a=wpgallery.getWin();d("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{d("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},restoreSelection:function(){var a=this;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},setup:function(){var f=this,c,d=f.editor,i;if(!f.mcemode){return}f.restoreSelection();f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;var e=c.match(/columns=['"]([0-9]+)['"]/),h=c.match(/link=['"]([^'"]+)['"]/i),b=c.match(/order=['"]([^'"]+)['"]/i),j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};
  • trunk/wp-admin/js/inline-edit-post.js

    r10258 r10291  
    1 
    2 (function($) {
    3 inlineEditPost = {
    4 
    5     init : function() {
    6         var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
    7 
    8         t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
    9         t.what = '#'+t.type+'-';
    10 
    11         // get all editable rows
    12         t.rows = $('tr.iedit');
    13 
    14         // prepare the edit rows
    15         qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); });
    16         bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); });
    17 
    18         $('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); });
    19         $('a.save', qeRow).click(function() { return inlineEditPost.save(this); });
    20         $('input, select', qeRow).keydown(function(e) { if(e.which == 13) return inlineEditPost.save(this); });
    21 
    22         $('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); });
    23 
    24         $('#inline-edit .inline-edit-private input[value=private]').click( function(){
    25             var pw = $('input.inline-edit-password-input');
    26             if ( $(this).attr('checked') ) {
    27                 pw.val('').attr('disabled', 'disabled');
    28             } else {
    29                 pw.attr('disabled', '');
    30             }
    31         });
    32 
    33         // add events
    34         t.addEvents(t.rows);
    35 
    36         $('#bulk-title-div').parents('fieldset').after(
    37             $('#inline-edit fieldset.inline-edit-categories').clone()
    38         ).siblings( 'fieldset:last' ).prepend(
    39 //      ).siblings( 'fieldset:last' ).after( '<fieldset class="inline-edit-col-bottom"><div class="inline-edit-col"></div></fieldset>' );
    40 //      $('fieldset.inline-edit-col-bottom').prepend(
    41             $('#inline-edit label.inline-edit-tags').clone()
    42         );
    43 
    44         // categories expandable?
    45         $('span.catshow').click(function() {
    46             $('.inline-editor ul.cat-checklist').addClass("cat-hover");
    47             $('.inline-editor span.cathide').show();
    48             $(this).hide();
    49         });
    50 
    51         $('span.cathide').click(function() {
    52             $('.inline-editor ul.cat-checklist').removeClass("cat-hover");
    53             $('.inline-editor span.catshow').show();
    54             $(this).hide();
    55         });
    56 
    57         $('select[name="_status"] option[value="future"]', bulkRow).remove();
    58 
    59         $('#doaction, #doaction2').click(function(e){
    60             var n = $(this).attr('id').substr(2);
    61             if ( $('select[name="'+n+'"]').val() == 'edit' ) {
    62                 e.preventDefault();
    63                 t.setBulk();
    64             } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
    65                 t.revert();
    66             }
    67         });
    68 
    69         $('#post-query-submit').click(function(e){
    70             if ( $('form#posts-filter tr.inline-editor').length > 0 )
    71                 t.revert();
    72         });
    73 
    74     },
    75 
    76     toggle : function(el) {
    77         var t = this;
    78 
    79         $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
    80     },
    81 
    82     addEvents : function(r) {
    83         r.each(function() {
    84             var row = $(this);
    85             $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; });
    86         });
    87     },
    88 
    89     setBulk : function() {
    90         var te = '', c = '', type = this.type;
    91         this.revert();
    92 
    93         $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
    94         $('table.widefat tbody').prepend( $('#bulk-edit') );
    95         $('#bulk-edit').addClass('inline-editor').show();
    96 
    97         $('tbody th.check-column input[type="checkbox"]').each(function(i){
    98             if ( $(this).attr('checked') ) {
    99                 var id = $(this).val();
    100                 var theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
    101                 te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
    102             }
    103         });
    104 
    105         $('#bulk-titles').html(te);
    106         $('#bulk-titles a').click(function() {
    107             var id = $(this).attr('id').substr(1), r = inlineEditPost.type+'-'+id;
    108 
    109             $('table.widefat input[value="'+id+'"]').attr('checked', '');
    110             $('#ttle'+id).remove();
    111         });
    112 
    113         // enable autocomplete for tags
    114         if ( type == 'post' )
    115             $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
    116     },
    117 
    118     edit : function(id) {
    119         var t = this;
    120         t.revert();
    121 
    122         if ( typeof(id) == 'object' )
    123             id = t.getId(id);
    124 
    125         var fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
    126         if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
    127         if ( t.type == 'post' ) fields.push('tags_input');
    128 
    129         // add the new blank row
    130         var editRow = $('#inline-edit').clone(true);
    131         $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
    132 
    133         if ( $(t.what+id).hasClass('alternate') )
    134             $(editRow).addClass('alternate');
    135         $(t.what+id).hide().after(editRow);
    136 
    137         // populate the data
    138         var rowData = $('#inline_'+id);
    139         for ( var f = 0; f < fields.length; f++ ) {
    140             $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
    141         }
    142 
    143         if ( $('.comment_status', rowData).text() == 'open' )
    144             $('input[name="comment_status"]', editRow).attr("checked", "checked");
    145         if ( $('.ping_status', rowData).text() == 'open' )
    146             $('input[name="ping_status"]', editRow).attr("checked", "checked");
    147         if ( $('.sticky', rowData).text() == 'sticky' )
    148             $('input[name="sticky"]', editRow).attr("checked", "checked");
    149 
    150         // categories
    151         var cats;
    152         if ( cats = $('.post_category', rowData).text() )
    153             $('ul.cat-checklist :checkbox', editRow).val(cats.split(','));
    154 
    155         // handle the post status
    156         var status = $('._status', rowData).text();
    157         if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove();
    158         if ( status == 'private' ) {
    159             $('input[name="keep_private"]', editRow).attr("checked", "checked");
    160             $('input.inline-edit-password-input').val('').attr('disabled', 'disabled');
    161         }
    162 
    163         // remove the current page and children from the parent dropdown
    164         var pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow);
    165         if ( pageOpt.length > 0 ) {
    166             var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
    167             while ( pageLoop ) {
    168                 var nextPage = nextPage.next('option');
    169                 if (nextPage.length == 0) break;
    170                 var nextLevel = nextPage[0].className.split('-')[1];
    171                 if ( nextLevel <= pageLevel ) {
    172                     pageLoop = false;
    173                 } else {
    174                     nextPage.remove();
    175                     nextPage = pageOpt;
    176                 }
    177             }
    178             pageOpt.remove();
    179         }
    180 
    181         $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
    182         $('.ptitle', editRow).focus();
    183 
    184         // enable autocomplete for tags
    185         if ( t.type == 'post' )
    186             $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
    187 
    188         return false;
    189     },
    190 
    191     save : function(id) {
    192         if( typeof(id) == 'object' )
    193             id = this.getId(id);
    194 
    195         $('table.widefat .inline-edit-save .waiting').show();
    196 
    197         var params = {
    198             action: 'inline-save',
    199             post_type: this.type,
    200             post_ID: id,
    201             edit_date: 'true'
    202         };
    203 
    204         var fields = $('#edit-'+id+' :input').fieldSerialize();
    205         params = fields + '&' + $.param(params);
    206 
    207         // make ajax request
    208         $.post('admin-ajax.php', params,
    209             function(r) {
    210                 $('table.widefat .inline-edit-save .waiting').hide();
    211 
    212                 if (r) {
    213                     if ( -1 != r.indexOf('<tr') ) {
    214                         $(inlineEditPost.what+id).remove();
    215                         $('#edit-'+id).before(r).remove();
    216 
    217                         var row = $(inlineEditPost.what+id);
    218                         row.hide();
    219 
    220                         if ( 'draft' == $('input[name="post_status"]').val() )
    221                             row.find('td.column-comments').hide();
    222 
    223                         inlineEditPost.addEvents(row);
    224                         row.fadeIn();
    225                     } else {
    226                         r = r.replace( /<.[^<>]*?>/g, '' );
    227                         $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
    228                     }
    229                 } else {
    230                     $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
    231                 }
    232             }
    233         , 'html');
    234         return false;
    235     },
    236 
    237     revert : function() {
    238         var id;
    239 
    240         if ( id = $('table.widefat tr.inline-editor').attr('id') ) {
    241             $('table.widefat .inline-edit-save .waiting').hide();
    242 
    243             if ( 'bulk-edit' == id ) {
    244                 $('table.widefat #bulk-edit').removeClass('inline-editor').hide();
    245                 $('#bulk-titles').html('');
    246                 $('#inlineedit').append( $('#bulk-edit') );
    247             } else  {
    248                 $('#'+id).remove();
    249                 id = id.substr( id.lastIndexOf('-') + 1 );
    250                 $(this.what+id).show();
    251             }
    252         }
    253 
    254         return false;
    255     },
    256 
    257     getId : function(o) {
    258         var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
    259         var parts = id.split('-');
    260         return parts[parts.length - 1];
    261     }
    262 };
    263 
    264 $(document).ready(function(){inlineEditPost.init();});
    265 })(jQuery);
     1(function(a){inlineEditPost={init:function(){var c=this,d=a("#inline-edit"),b=a("#bulk-edit");c.type=a("table.widefat").hasClass("page")?"page":"post";c.what="#"+c.type+"-";c.rows=a("tr.iedit");d.keyup(function(f){if(f.which==27){return inlineEditPost.revert()}});b.keyup(function(f){if(f.which==27){return inlineEditPost.revert()}});a("a.cancel",d).click(function(){return inlineEditPost.revert()});a("a.save",d).click(function(){return inlineEditPost.save(this)});a("input, select",d).keydown(function(f){if(f.which==13){return inlineEditPost.save(this)}});a("a.cancel",b).click(function(){return inlineEditPost.revert()});a("#inline-edit .inline-edit-private input[value=private]").click(function(){var e=a("input.inline-edit-password-input");if(a(this).attr("checked")){e.val("").attr("disabled","disabled")}else{e.attr("disabled","")}});c.addEvents(c.rows);a("#bulk-title-div").parents("fieldset").after(a("#inline-edit fieldset.inline-edit-categories").clone()).siblings("fieldset:last").prepend(a("#inline-edit label.inline-edit-tags").clone());a("span.catshow").click(function(){a(".inline-editor ul.cat-checklist").addClass("cat-hover");a(".inline-editor span.cathide").show();a(this).hide()});a("span.cathide").click(function(){a(".inline-editor ul.cat-checklist").removeClass("cat-hover");a(".inline-editor span.catshow").show();a(this).hide()});a('select[name="_status"] option[value="future"]',b).remove();a("#doaction, #doaction2").click(function(f){var g=a(this).attr("id").substr(2);if(a('select[name="'+g+'"]').val()=="edit"){f.preventDefault();c.setBulk()}else{if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}}});a("#post-query-submit").click(function(f){if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){var c=a(this);a("a.editinline",c).click(function(){inlineEditPost.edit(this);return false})})},setBulk:function(){var c="",b=this.type;this.revert();a("#bulk-edit td").attr("colspan",a(".widefat:first thead th:visible").length);a("table.widefat tbody").prepend(a("#bulk-edit"));a("#bulk-edit").addClass("inline-editor").show();a('tbody th.check-column input[type="checkbox"]').each(function(e){if(a(this).attr("checked")){var f=a(this).val(),d;d=a("#inline_"+f+" .post_title").text()||inlineEditL10n.notitle;c+='<div id="ttle'+f+'"><a id="_'+f+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+d+"</div>"}});a("#bulk-titles").html(c);a("#bulk-titles a").click(function(){var d=a(this).attr("id").substr(1);a('table.widefat input[value="'+d+'"]').attr("checked","");a("#ttle"+d).remove()});if(b=="post"){a('tr.inline-editor textarea[name="tags_input"]').suggest("admin-ajax.php?action=ajax-tag-search",{delay:500,minchars:2,multiple:true,multipleSep:", "})}},edit:function(b){var n=this,i,d,e,m,h,g,j;n.revert();if(typeof(b)=="object"){b=n.getId(b)}i=["post_title","post_name","post_author","_status","jj","mm","aa","hh","mn","ss","post_password"];if(n.type=="page"){i.push("post_parent","menu_order","page_template")}if(n.type=="post"){i.push("tags_input")}d=a("#inline-edit").clone(true);a("td",d).attr("colspan",a(".widefat:first thead th:visible").length);if(a(n.what+b).hasClass("alternate")){a(d).addClass("alternate")}a(n.what+b).hide().after(d);e=a("#inline_"+b);for(j=0;j<i.length;j++){a(':input[name="'+i[j]+'"]',d).val(a("."+i[j],e).text())}if(a(".comment_status",e).text()=="open"){a('input[name="comment_status"]',d).attr("checked","checked")}if(a(".ping_status",e).text()=="open"){a('input[name="ping_status"]',d).attr("checked","checked")}if(a(".sticky",e).text()=="sticky"){a('input[name="sticky"]',d).attr("checked","checked")}if(m=a(".post_category",e).text()){a("ul.cat-checklist :checkbox",d).val(m.split(","))}h=a("._status",e).text();if(h!="future"){a('select[name="_status"] option[value="future"]',d).remove()}if(h=="private"){a('input[name="keep_private"]',d).attr("checked","checked");a("input.inline-edit-password-input").val("").attr("disabled","disabled")}g=a('select[name="post_parent"] option[value="'+b+'"]',d);if(g.length>0){var l=g[0].className.split("-")[1],c=true,k,o;while(c){k=k.next("option");if(k.length==0){break}o=k[0].className.split("-")[1];if(o<=l){c=false}else{k.remove();k=g}}g.remove()}a(d).attr("id","edit-"+b).addClass("inline-editor").show();a(".ptitle",d).focus();if(n.type=="post"){a('tr.inline-editor textarea[name="tags_input"]').suggest("admin-ajax.php?action=ajax-tag-search",{delay:500,minchars:2,multiple:true,multipleSep:", "})}return false},save:function(d){var c,b;if(typeof(d)=="object"){d=this.getId(d)}a("table.widefat .inline-edit-save .waiting").show();c={action:"inline-save",post_type:this.type,post_ID:d,edit_date:"true"};b=a("#edit-"+d+" :input").fieldSerialize();c=b+"&"+a.param(c);a.post("admin-ajax.php",c,function(e){a("table.widefat .inline-edit-save .waiting").hide();if(e){if(-1!=e.indexOf("<tr")){a(inlineEditPost.what+d).remove();a("#edit-"+d).before(e).remove();var f=a(inlineEditPost.what+d);f.hide();if("draft"==a('input[name="post_status"]').val()){f.find("td.column-comments").hide()}inlineEditPost.addEvents(f);f.fadeIn()}else{e=e.replace(/<.[^<>]*?>/g,"");a("#edit-"+d+" .inline-edit-save").append('<span class="error">'+e+"</span>")}}else{a("#edit-"+d+" .inline-edit-save").append('<span class="error">'+inlineEditL10n.error+"</span>")}},"html");return false},revert:function(){var b;if(b=a("table.widefat tr.inline-editor").attr("id")){a("table.widefat .inline-edit-save .waiting").hide();if("bulk-edit"==b){a("table.widefat #bulk-edit").removeClass("inline-editor").hide();a("#bulk-titles").html("");a("#inlineedit").append(a("#bulk-edit"))}else{a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditPost.init()})})(jQuery);
  • trunk/wp-admin/js/inline-edit-tax.js

    r10258 r10291  
    1 
    2 (function($) {
    3 inlineEditTax = {
    4 
    5     init : function() {
    6         var t = this, row = $('#inline-edit');
    7 
    8         t.type = $('#the-list').attr('className').substr(5);
    9         t.what = '#'+t.type+'-';
    10 
    11         // get all editable rows
    12         t.rows = $('tr.iedit');
    13 
    14         // prepare the edit row
    15         row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
    16 
    17         $('a.cancel', row).click(function() { return inlineEditTax.revert(); });
    18         $('a.save', row).click(function() { return inlineEditTax.save(this); });
    19         $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
    20 
    21         // add events
    22         t.addEvents(t.rows);
    23 
    24         $('#posts-filter input[type="submit"]').click(function(e){
    25             if ( $('form#posts-filter tr.inline-editor').length > 0 )
    26                 t.revert();
    27         });
    28     },
    29 
    30     toggle : function(el) {
    31         var t = this;
    32 
    33         $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
    34     },
    35 
    36     addEvents : function(r) {
    37         r.each(function() {
    38             $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
    39         });
    40     },
    41 
    42     edit : function(id) {
    43         var t = this;
    44         t.revert();
    45 
    46         if ( typeof(id) == 'object' )
    47             id = t.getId(id);
    48 
    49         var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
    50         $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
    51 
    52         if ( $(t.what+id).hasClass('alternate') )
    53             $(editRow).addClass('alternate');
    54 
    55         $(t.what+id).hide().after(editRow);
    56 
    57         $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
    58         $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
    59 
    60         // cat parents
    61         var cat_parent = $('.cat_parent', rowData).text();
    62         if ( cat_parent != '0' )
    63             $('select[name="parent"]', editRow).val(cat_parent);
    64 
    65         // remove the current parent and children from the parent dropdown
    66         var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
    67         if ( pageOpt.length > 0 ) {
    68             var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
    69             while ( pageLoop ) {
    70                 var nextPage = nextPage.next('option');
    71                 if (nextPage.length == 0) break;
    72                 var nextLevel = nextPage[0].className.split('-')[1];
    73                 if ( nextLevel <= pageLevel ) {
    74                     pageLoop = false;
    75                 } else {
    76                     nextPage.remove();
    77                     nextPage = pageOpt;
    78                 }
    79             }
    80             pageOpt.remove();
    81         }
    82 
    83         $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
    84         $('.ptitle', editRow).eq(0).focus();
    85 
    86         return false;
    87     },
    88 
    89     save : function(id) {
    90         if( typeof(id) == 'object' )
    91             id = this.getId(id);
    92 
    93         $('table.widefat .inline-edit-save .waiting').show();
    94 
    95         var params = {
    96             action: 'inline-save-tax',
    97             tax_type: this.type,
    98             tax_ID: id
    99         };
    100 
    101         var fields = $('#edit-'+id+' :input').fieldSerialize();
    102         params = fields + '&' + $.param(params);
    103 
    104         // make ajax request
    105         $.post('admin-ajax.php', params,
    106             function(r) {
    107 
    108                 $('table.widefat .inline-edit-save .waiting').hide();
    109 
    110                 if (r) {
    111                     if ( -1 != r.indexOf('<tr') ) {
    112                         $(inlineEditTax.what+id).remove();
    113                         $('#edit-'+id).before(r).remove();
    114 
    115                         var row = $(inlineEditTax.what+id);
    116                         row.hide();
    117 
    118                         inlineEditTax.addEvents(row);
    119                         row.fadeIn();
    120                     } else
    121                         $('#edit-'+id+' .inline-edit-save .error').html(r).show();
    122                 } else
    123                     $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
    124             }
    125         );
    126         return false;
    127     },
    128 
    129     revert : function() {
    130         var id = $('table.widefat tr.inline-editor').attr('id');
    131 
    132         if ( id ) {
    133             $('table.widefat .inline-edit-save .waiting').hide();
    134             $('#'+id).remove();
    135             id = id.substr( id.lastIndexOf('-') + 1 );
    136             $(this.what+id).show();
    137         }
    138 
    139         return false;
    140     },
    141 
    142     getId : function(o) {
    143         var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
    144         var parts = id.split('-');
    145         return parts[parts.length - 1];
    146     }
    147 };
    148 
    149 $(document).ready(function(){inlineEditTax.init();});
    150 })(jQuery);
     1(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";b.rows=a("tr.iedit");c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});b.addEvents(b.rows);a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){a(this).find("a.editinline").click(function(){inlineEditTax.edit(this);return false})})},edit:function(b){var i=this,d,e,f;i.revert();if(typeof(b)=="object"){b=i.getId(b)}d=a("#inline-edit").clone(true),rowData=a("#inline_"+b);a("td",d).attr("colspan",a(".widefat:first thead th:visible").length);if(a(i.what+b).hasClass("alternate")){a(d).addClass("alternate")}a(i.what+b).hide().after(d);a(':input[name="name"]',d).val(a(".name",rowData).text());a(':input[name="slug"]',d).val(a(".slug",rowData).text());e=a(".cat_parent",rowData).text();if(e!="0"){a('select[name="parent"]',d).val(e)}f=a('select[name="parent"] option[value="'+b+'"]',d);if(f.length>0){var h=f[0].className.split("-")[1],g,c=true,j;while(c){g=g.next("option");if(g.length==0){break}j=g[0].className.split("-")[1];if(j<=h){c=false}else{g.remove();g=f}}f.remove()}a(d).attr("id","edit-"+b).addClass("inline-editor").show();a(".ptitle",d).eq(0).focus();return false},save:function(d){var c,b;if(typeof(d)=="object"){d=this.getId(d)}a("table.widefat .inline-edit-save .waiting").show();c={action:"inline-save-tax",tax_type:this.type,tax_ID:d};b=a("#edit-"+d+" :input").fieldSerialize();c=b+"&"+a.param(c);a.post("admin-ajax.php",c,function(e){a("table.widefat .inline-edit-save .waiting").hide();if(e){if(-1!=e.indexOf("<tr")){a(inlineEditTax.what+d).remove();a("#edit-"+d).before(e).remove();var f=a(inlineEditTax.what+d);f.hide();inlineEditTax.addEvents(f);f.fadeIn()}else{a("#edit-"+d+" .inline-edit-save .error").html(e).show()}}else{a("#edit-"+d+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);
  • trunk/wp-admin/js/link.js

    r10259 r10291  
    1 jQuery(document).ready( function($) {
    2 
    3     jQuery('#link_name').focus();
    4     // postboxes
    5     postboxes.add_postbox_toggles('link');
    6 
    7     // category tabs
    8     var categoryTabs = jQuery('#category-tabs').tabs();
    9 
    10     // Ajax Cat
    11     var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
    12     jQuery('#category-add-submit').click( function() { newCat.focus(); } );
    13     var noSyncChecks = false; // prophylactic. necessary?
    14     var syncChecks = function() {
    15         if ( noSyncChecks )
    16             return;
    17         noSyncChecks = true;
    18         var th = jQuery(this);
    19         var c = th.is(':checked');
    20         var id = th.val().toString();
    21         jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
    22         noSyncChecks = false;
    23     };
    24     var catAddAfter = function( r, s ) {
    25         jQuery(s.what + ' response_data', r).each( function() {
    26             var t = jQuery(jQuery(this).text());
    27             t.find( 'label' ).each( function() {
    28                 var th = jQuery(this);
    29                 var val = th.find('input').val();
    30                 var id = th.find('input')[0].id
    31                 jQuery('#' + id).change( syncChecks );
    32                 var name = jQuery.trim( th.text() );
    33                 var o = jQuery( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
    34             } );
    35         } );
    36     };
    37     jQuery('#categorychecklist').wpList( {
    38         alt: '',
    39         what: 'link-category',
    40         response: 'category-ajax-response',
    41         addAfter: catAddAfter
    42     } );
    43 
    44     $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
    45     $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
    46     if ( 'pop' == getUserSetting('cats') )
    47         $('a[href="#categories-pop"]').click();
    48 
    49     jQuery('#category-add-toggle').click( function() {
    50         jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
    51         categoryTabs.tabsClick( 1 );
    52         return false;
    53     } );
    54     jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
    55 });
     1jQuery(document).ready(function(c){var e,b,a=false,d,f;c("#link_name").focus();postboxes.add_postbox_toggles("link");e=c("#category-tabs").tabs();b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var g=c(this),i=g.is(":checked"),h=g.val().toString();c("#in-category-"+h+", #in-popular-category-"+h).attr("checked",i);a=false};f=function(h,g){c(g.what+" response_data",h).each(function(){var i=c(c(this).text());i.find("label").each(function(){var k=c(this),m=k.find("input").val(),n=k.find("input")[0].id,j=c.trim(k.text()),l;c("#"+n).change(d);l=c('<option value="'+parseInt(m,10)+'"></option>').text(j)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:f});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");e.tabsClick(1);return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});
  • trunk/wp-admin/js/media-upload.js

    r9894 r10291  
    1 // send html to the post editor
    2 function send_to_editor(h) {
    3     if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
    4         ed.focus();
    5         if (tinymce.isIE)
    6             ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
    7 
    8         if ( h.indexOf('[caption') === 0 ) {
    9             if ( ed.plugins.wpeditimage )
    10                 h = ed.plugins.wpeditimage._do_shcode(h);
    11         } else if ( h.indexOf('[gallery') === 0 ) {
    12             if ( ed.plugins.wpgallery )
    13                 h = ed.plugins.wpgallery._do_gallery(h);
    14         }
    15 
    16         ed.execCommand('mceInsertContent', false, h);
    17 
    18     } else if ( typeof edInsertContent == 'function' ) {
    19         edInsertContent(edCanvas, h);
    20     } else {
    21         jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
    22     }
    23 
    24     tb_remove();
    25 }
    26 
    27 // thickbox settings
    28 jQuery(function($) {
    29     tb_position = function() {
    30         var tbWindow = $('#TB_window');
    31         var width = $(window).width();
    32         var H = $(window).height();
    33         var W = ( 720 < width ) ? 720 : width;
    34 
    35         if ( tbWindow.size() ) {
    36             tbWindow.width( W - 50 ).height( H - 45 );
    37             $('#TB_iframeContent').width( W - 50 ).height( H - 75 );
    38             tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
    39             if ( typeof document.body.style.maxWidth != 'undefined' )
    40                 tbWindow.css({'top':'20px','margin-top':'0'});
    41             $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    42         };
    43 
    44         return $('a.thickbox').each( function() {
    45             var href = $(this).attr('href');
    46             if ( ! href ) return;
    47             href = href.replace(/&width=[0-9]+/g, '');
    48             href = href.replace(/&height=[0-9]+/g, '');
    49             $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
    50         });
    51     };
    52 
    53     jQuery('a.thickbox').click(function(){
    54         if ( typeof tinyMCE != 'undefined' &&  tinyMCE.activeEditor ) {
    55             tinyMCE.get('content').focus();
    56             tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
    57         }
    58     });
    59 
    60     $(window).resize( function() { tb_position() } );
    61 });
    62 
     1function send_to_editor(b){var a;if(typeof tinyMCE!="undefined"&&(a=tinyMCE.activeEditor)&&!a.isHidden()){a.focus();if(tinymce.isIE){a.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark)}if(b.indexOf("[caption")===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf("[gallery")===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}}a.execCommand("mceInsertContent",false,b)}else{if(typeof edInsertContent=="function"){edInsertContent(edCanvas,b)}else{jQuery(edCanvas).val(jQuery(edCanvas).val()+b)}}tb_remove()}jQuery(document).ready(function(a){tb_position=function(){var e=a("#TB_window"),d=a(window).width(),c=a(window).height(),b=(720<d)?720:d;if(e.size()){e.width(b-50).height(c-45);a("#TB_iframeContent").width(b-50).height(c-75);e.css({"margin-left":"-"+parseInt(((b-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){e.css({top:"20px","margin-top":"0"})}a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"})}return a("a.thickbox").each(function(){var f=a(this).attr("href");if(!f){return}f=f.replace(/&width=[0-9]+/g,"");f=f.replace(/&height=[0-9]+/g,"");a(this).attr("href",f+"&width="+(b-80)+"&height="+(c-85))})};a("a.thickbox").click(function(){if(typeof tinyMCE!="undefined"&&tinyMCE.activeEditor){tinyMCE.get("content").focus();tinyMCE.activeEditor.windowManager.bookmark=tinyMCE.activeEditor.selection.getBookmark("simple")}});a(window).resize(function(){tb_position()})});
  • trunk/wp-admin/js/page.js

    r10258 r10291  
    1 jQuery(document).ready( function($) {
    2     postboxes.add_postbox_toggles('page');
    3     make_slugedit_clickable();
    4 
    5     jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
    6 
    7     var stamp = $('#timestamp').html();
    8 
    9     var visibility = $('#post-visibility-display').html();
    10 
    11     function updateVisibility() {
    12         if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
    13             $('#sticky').attr('checked', false);
    14             $('#sticky-span').hide();
    15         } else {
    16             $('#sticky-span').show();
    17         }
    18         if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
    19             $('#password-span').hide();
    20         } else {
    21             $('#password-span').show();
    22         }
    23     }
    24 
    25     function updateText() {
    26         var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
    27         var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
    28         var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
    29         if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
    30             var publishOn = postL10n.publishOnFuture;
    31             $('#publish').val( postL10n.schedule );
    32         } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
    33             var publishOn = postL10n.publishOn;
    34             $('#publish').val( postL10n.publish );
    35         } else {
    36             var publishOn = postL10n.publishOnPast;
    37             $('#publish').val( postL10n.update );
    38         }
    39         if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
    40             $('#timestamp').html(stamp);
    41         } else {
    42             $('#timestamp').html(
    43                 publishOn + ' <b>' +
    44                 $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
    45                 $('#jj').val() + ', ' +
    46                 $('#aa').val() + ' @ ' +
    47                 $('#hh').val() + ':' +
    48                 $('#mn').val() + '</b> '
    49             );
    50         }
    51 
    52         if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
    53             $('#publish').val( postL10n.update );
    54             if ( $('#post_status option[value=publish]').length == 0 ) {
    55                 $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
    56             }
    57             $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
    58             $('#post_status option[value=publish]').attr('selected', true);
    59             $('.edit-post-status').hide();
    60         } else {
    61             if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
    62                 if ( $('#post_status option[value=publish]').length != 0 ) {
    63                     $('#post_status option[value=publish]').remove();
    64                     $('#post_status').val($('#hidden_post_status').val());
    65                 }
    66             } else {
    67                 $('#post_status option[value=publish]').html( postL10n.published );
    68             }
    69             $('.edit-post-status').show();
    70         }
    71         $('#post-status-display').html($('#post_status :selected').text());
    72         if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
    73             $('#save-post').hide();
    74         } else {
    75             $('#save-post').show();
    76             if ( $('#post_status :selected').val() == 'pending' ) {
    77                 $('#save-post').show().val( postL10n.savePending );
    78             } else {
    79                 $('#save-post').show().val( postL10n.saveDraft );
    80             }
    81         }
    82     }
    83 
    84     $('.edit-visibility').click(function () {
    85         if ($('#post-visibility-select').is(":hidden")) {
    86             updateVisibility();
    87             $('#post-visibility-select').slideDown("normal");
    88             $('.edit-visibility').hide();
    89         }
    90         return false;
    91     });
    92 
    93     $('.cancel-post-visibility').click(function () {
    94         $('#post-visibility-select').slideUp("normal");
    95         $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
    96         $('#post_password').val($('#hidden_post_password').val());
    97         $('#post-visibility-display').html(visibility);
    98         $('.edit-visibility').show();
    99         updateText();
    100         return false;
    101     });
    102 
    103     $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
    104         $('#post-visibility-select').slideUp("normal");
    105         $('.edit-visibility').show();
    106         updateText();
    107 
    108         $('#post-visibility-display').html(
    109             postL10n[$('#post-visibility-select input:radio:checked').val()]
    110         );
    111 
    112         return false;
    113     });
    114 
    115     $('#post-visibility-select input:radio').change(function() {
    116         updateVisibility();
    117     });
    118 
    119     $('.edit-timestamp').click(function () {
    120         if ($('#timestampdiv').is(":hidden")) {
    121             $('#timestampdiv').slideDown("normal");
    122             $('.edit-timestamp').hide();
    123         }
    124 
    125         return false;
    126     });
    127 
    128     $('.cancel-timestamp').click(function() {
    129         $('#timestampdiv').slideUp("normal");
    130         $('#mm').val($('#hidden_mm').val());
    131         $('#jj').val($('#hidden_jj').val());
    132         $('#aa').val($('#hidden_aa').val());
    133         $('#hh').val($('#hidden_hh').val());
    134         $('#mn').val($('#hidden_mn').val());
    135         $('.edit-timestamp').show();
    136 
    137         updateText();
    138         return false;
    139     });
    140 
    141     $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
    142         $('#timestampdiv').slideUp("normal");
    143         $('.edit-timestamp').show();
    144         updateText();
    145 
    146         return false;
    147     });
    148 
    149     $('.edit-post-status').click(function() {
    150         if ($('#post-status-select').is(":hidden")) {
    151             $('#post-status-select').slideDown("normal");
    152             $(this).hide();
    153         }
    154 
    155         return false;
    156     });
    157 
    158     $('.save-post-status').click(function() {
    159         $('#post-status-select').slideUp("normal");
    160         $('.edit-post-status').show();
    161         updateText();
    162         return false;
    163     });
    164 
    165     $('.cancel-post-status').click(function() {
    166         $('#post-status-select').slideUp("normal");
    167         $('#post_status').val($('#hidden_post_status').val());
    168         $('.edit-post-status').show();
    169 
    170         updateText();
    171         return false;
    172     });
    173 
    174     // Custom Fields
    175     jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
    176         $('table#list-table').show();
    177         if ( jQuery.isFunction( autosave_update_post_ID ) ) {
    178             autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
    179         }
    180     }, addBefore: function( s ) {
    181         s.data += '&post_id=' + jQuery('#post_ID').val();
    182         return s;
    183     }
    184     });
    185 
    186     // preview
    187     $('#post-preview').click(function(e){
    188         if ( 1 > $('#post_ID').val() && autosaveFirst ) {
    189             autosaveDelayPreview = true;
    190             autosave();
    191             return false;
    192         }
    193 
    194         $('input#wp-preview').val('dopreview');
    195         $('form#post').attr('target', 'wp-preview').submit().attr('target', '');
    196         $('input#wp-preview').val('');
    197         return false;
    198     });
    199 });
     1jQuery(document).ready(function(e){postboxes.add_postbox_toggles("page");make_slugedit_clickable();jQuery("#title").blur(function(){if((jQuery("#post_ID").val()>0)||(jQuery("#title").val().length==0)){return}autosave()});var b=e("#timestamp").html(),a=e("#post-visibility-display").html();function d(){if(e("#post-visibility-select input:radio:checked").val()!="public"){e("#sticky").attr("checked",false);e("#sticky-span").hide()}else{e("#sticky-span").show()}if(e("#post-visibility-select input:radio:checked").val()!="password"){e("#password-span").hide()}else{e("#password-span").show()}}function c(){var f,h,g,i;f=new Date(e("#aa").val(),e("#mm").val()-1,e("#jj").val(),e("#hh").val(),e("#mn").val());h=new Date(e("#hidden_aa").val(),e("#hidden_mm").val()-1,e("#hidden_jj").val(),e("#hidden_hh").val(),e("#hidden_mn").val());g=new Date(e("#cur_aa").val(),e("#cur_mm").val()-1,e("#cur_jj").val(),e("#cur_hh").val(),e("#cur_mn").val());if(f>g&&e("#original_post_status").val()!="future"){i=postL10n.publishOnFuture;e("#publish").val(postL10n.schedule)}else{if(f<=g&&e("#original_post_status").val()!="publish"){i=postL10n.publishOn;e("#publish").val(postL10n.publish)}else{i=postL10n.publishOnPast;e("#publish").val(postL10n.update)}}if(h.toUTCString()==f.toUTCString()){e("#timestamp").html(b)}else{e("#timestamp").html(i+" <b>"+e("#mm option[value="+e("#mm").val()+"]").text()+" "+e("#jj").val()+", "+e("#aa").val()+" @ "+e("#hh").val()+":"+e("#mn").val()+"</b> ")}if(e("#post-visibility-select input:radio:checked").val()=="private"){e("#publish").val(postL10n.update);if(e("#post_status option[value=publish]").length==0){e("#post_status").append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}e("#post_status option[value=publish]").html(postL10n.privatelyPublished);e("#post_status option[value=publish]").attr("selected",true);e(".edit-post-status").hide()}else{if(e("#original_post_status").val()=="future"||e("#original_post_status").val()=="draft"){if(e("#post_status option[value=publish]").length!=0){e("#post_status option[value=publish]").remove();e("#post_status").val(e("#hidden_post_status").val())}}else{e("#post_status option[value=publish]").html(postL10n.published)}e(".edit-post-status").show()}e("#post-status-display").html(e("#post_status :selected").text());if(e("#post_status :selected").val()=="private"||e("#post_status :selected").val()=="publish"){e("#save-post").hide()}else{e("#save-post").show();if(e("#post_status :selected").val()=="pending"){e("#save-post").show().val(postL10n.savePending)}else{e("#save-post").show().val(postL10n.saveDraft)}}}e(".edit-visibility").click(function(){if(e("#post-visibility-select").is(":hidden")){d();e("#post-visibility-select").slideDown("normal");e(".edit-visibility").hide()}return false});e(".cancel-post-visibility").click(function(){e("#post-visibility-select").slideUp("normal");e("#visibility-radio-"+e("#hidden-post-visibility").val()).attr("checked",true);e("#post_password").val(e("#hidden_post_password").val());e("#post-visibility-display").html(a);e(".edit-visibility").show();c();return false});e(".save-post-visibility").click(function(){e("#post-visibility-select").slideUp("normal");e(".edit-visibility").show();c();e("#post-visibility-display").html(postL10n[e("#post-visibility-select input:radio:checked").val()]);return false});e("#post-visibility-select input:radio").change(function(){d()});e(".edit-timestamp").click(function(){if(e("#timestampdiv").is(":hidden")){e("#timestampdiv").slideDown("normal");e(".edit-timestamp").hide()}return false});e(".cancel-timestamp").click(function(){e("#timestampdiv").slideUp("normal");e("#mm").val(e("#hidden_mm").val());e("#jj").val(e("#hidden_jj").val());e("#aa").val(e("#hidden_aa").val());e("#hh").val(e("#hidden_hh").val());e("#mn").val(e("#hidden_mn").val());e(".edit-timestamp").show();c();return false});e(".save-timestamp").click(function(){e("#timestampdiv").slideUp("normal");e(".edit-timestamp").show();c();return false});e(".edit-post-status").click(function(){if(e("#post-status-select").is(":hidden")){e("#post-status-select").slideDown("normal");e(this).hide()}return false});e(".save-post-status").click(function(){e("#post-status-select").slideUp("normal");e(".edit-post-status").show();c();return false});e(".cancel-post-status").click(function(){e("#post-status-select").slideUp("normal");e("#post_status").val(e("#hidden_post_status").val());e(".edit-post-status").show();c();return false});jQuery("#the-list").wpList({addAfter:function(f,g){e("table#list-table").show();if(jQuery.isFunction(autosave_update_post_ID)){autosave_update_post_ID(g.parsed.responses[0].supplemental.postid)}},addBefore:function(f){f.data+="&post_id="+jQuery("#post_ID").val();return f}});e("#post-preview").click(function(f){if(1>e("#post_ID").val()&&autosaveFirst){autosaveDelayPreview=true;autosave();return false}e("input#wp-preview").val("dopreview");e("form#post").attr("target","wp-preview").submit().attr("target","");e("input#wp-preview").val("");return false})});
  • trunk/wp-admin/js/password-strength-meter.js

    r10150 r10291  
    1 // Password strength meter
    2 
    3 function passwordStrength(password,username) {
    4     var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4;
    5 
    6     //password < 4
    7     if (password.length < 4 ) { return shortPass };
    8 
    9     //password == username
    10     if (password.toLowerCase()==username.toLowerCase()) return badPass;
    11 
    12     var symbolSize = 0;
    13     if (password.match(/[0-9]/)) symbolSize +=10;
    14     if (password.match(/[a-z]/)) symbolSize +=26;
    15     if (password.match(/[A-Z]/)) symbolSize +=26;
    16     if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
    17 
    18     var natLog = Math.log( Math.pow(symbolSize,password.length) );
    19     var score = natLog / Math.LN2;
    20     if (score < 40 )  return badPass
    21     if (score < 56 )  return goodPass
    22     return strongPass;
    23 }
     1function passwordStrength(i,f){var h=1,e=2,b=3,a=4,d=0,g,c;if(i.length<4){return h}if(i.toLowerCase()==f.toLowerCase()){return e}if(i.match(/[0-9]/)){d+=10}if(i.match(/[a-z]/)){d+=26}if(i.match(/[A-Z]/)){d+=26}if(i.match(/[^a-zA-Z0-9]/)){d+=31}g=Math.log(Math.pow(d,i.length));c=g/Math.LN2;if(c<40){return e}if(c<56){return b}return a};
  • trunk/wp-admin/js/plugin-install.js

    r9141 r10291  
    1 /* Plugin Browser Thickbox related JS*/
    2 jQuery(function($) {
    3     var thickDims = function() {
    4         var tbWindow = $('#TB_window');
    5         var width = $(window).width();
    6         var H = $(window).height();
    7         var W = ( 720 < width ) ? 720 : width;
    8 
    9         if ( tbWindow.size() ) {
    10             tbWindow.width( W - 50 ).height( H - 45 );
    11             $('#TB_iframeContent').width( W - 50 ).height( H - 75 );
    12             tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
    13             if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) )
    14                 tbWindow.css({'top':'20px','margin-top':'0'});
    15         };
    16 
    17         return $('a.thickbox').each( function() {
    18             var href = $(this).attr('href');
    19             if ( ! href )
    20                 return;
    21             href = href.replace(/&width=[0-9]+/g, '');
    22             href = href.replace(/&height=[0-9]+/g, '');
    23             $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
    24         });
    25     };
    26 
    27     thickDims().click( function() {
    28         $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    29         $('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
    30         return false;
    31     });
    32 
    33     $(window).resize( function() { tb_position() } );
    34 });
    35 
    36 /* Plugin install related JS*/
    37 jQuery(function($) {
    38     $('#install-plugins tbody.plugins tr').click( function() {
    39         $(this).find('.action-links a.onclick').click();
    40         return false;
    41     });
    42 
    43     $('#plugin-information #sidemenu a').click( function() {
    44         var tab = $(this).attr('name');
    45         //Flip the tab
    46         $('#plugin-information-header a.current').removeClass('current');
    47         $(this).addClass('current');
    48         //Flip the content.
    49         $('#section-holder div.section').hide(); //Hide 'em all
    50         $('#section-' + tab).show();
    51         return false;
    52     });
    53 });
     1jQuery(document).ready(function(b){var a=function(){var f=b("#TB_window"),e=b(window).width(),d=b(window).height(),c=(720<e)?720:e;if(f.size()){f.width(c-50).height(d-45);b("#TB_iframeContent").width(c-50).height(d-75);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(!(b.browser.msie&&b.browser.version.substr(0,1)<7)){f.css({top:"20px","margin-top":"0"})}}return b("a.thickbox").each(function(){var g=b(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");b(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85))})};a().click(function(){b("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});b("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+b(this).attr("title"));return false});b(window).resize(function(){tb_position()});b("#install-plugins tbody.plugins tr").click(function(){b(this).find(".action-links a.onclick").click();return false});b("#plugin-information #sidemenu a").click(function(){var c=b(this).attr("name");b("#plugin-information-header a.current").removeClass("current");b(this).addClass("current");b("#section-holder div.section").hide();b("#section-"+c).show();return false})});
  • trunk/wp-admin/js/post.js

    r10258 r10291  
    1 // this file contains all the scripts used in the post/edit page
    2 
    3 // return an array with any duplicate, whitespace or values removed
    4 function array_unique_noempty(a) {
    5     var out = [];
    6     jQuery.each( a, function(key, val) {
    7         val = jQuery.trim(val);
    8         if ( val && jQuery.inArray(val, out) == -1 )
    9             out.push(val);
    10         } );
    11     return out;
    12 }
    13 
    14 function new_tag_remove_tag() {
    15     var id = jQuery( this ).attr( 'id' );
    16     var num = id.split('-check-num-')[1];
    17     var taxbox = jQuery(this).parents('.tagsdiv');
    18     var current_tags = taxbox.find( '.the-tags' ).val().split(',');
    19     delete current_tags[num];
    20     var new_tags = [];
    21 
    22     jQuery.each( current_tags, function(key, val) {
    23         val = jQuery.trim(val);
    24         if ( val ) {
    25             new_tags.push(val);
    26         }
    27     });
    28 
    29     taxbox.find('.the-tags').val( new_tags.join(',').replace(/\s*,+\s*/, ',').replace(/,+/, ',').replace(/,+\s+,+/, ',').replace(/,+\s*$/, '').replace(/^\s*,+/, '') );
    30 
    31     tag_update_quickclicks(taxbox);
    32     return false;
    33 }
    34 
    35 function tag_update_quickclicks(taxbox) {
    36     if ( jQuery(taxbox).find('.the-tags').length == 0 )
    37         return;
    38 
    39     var current_tags = jQuery(taxbox).find('.the-tags').val().split(',');
    40     jQuery(taxbox).find('.tagchecklist').empty();
    41     shown = false;
    42 
    43     jQuery.each( current_tags, function( key, val ) {
    44         val = jQuery.trim(val);
    45         if ( !val.match(/^\s+$/) && '' != val ) {
    46             var button_id = jQuery(taxbox).attr('id') + '-check-num-' + key;
    47             txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a>&nbsp;' + val + '</span> ';
    48             jQuery(taxbox).find('.tagchecklist').append(txt);
    49             jQuery( '#' + button_id ).click( new_tag_remove_tag );
    50         }
    51     });
    52     if ( shown )
    53         jQuery(taxbox).find('.tagchecklist').prepend('<strong>'+postL10n.tagsUsed+'</strong><br />');
    54 }
    55 
    56 function tag_flush_to_text(id, a) {
    57     a = a || false;
    58     var taxbox = jQuery('#'+id);
    59     var text = a ? jQuery(a).text() : taxbox.find('input.newtag').val();
    60 
    61     // is the input box empty (i.e. showing the 'Add new tag' tip)?
    62     if ( taxbox.find('input.newtag').hasClass('form-input-tip') && ! a )
    63         return false;
    64 
    65     var tags = taxbox.find('.the-tags').val();
    66     var newtags = tags ? tags + ',' + text : text;
    67 
    68     // massage
    69     newtags = newtags.replace(/\s+,+\s*/g, ',').replace(/,+/g, ',').replace(/,+\s+,+/g, ',').replace(/,+\s*$/g, '').replace(/^\s*,+/g, '');
    70     newtags = array_unique_noempty(newtags.split(',')).join(',');
    71     taxbox.find('.the-tags').val(newtags);
    72     tag_update_quickclicks(taxbox);
    73    
    74     if ( ! a )
    75         taxbox.find('input.newtag').val('').focus();
    76 
    77     return false;
    78 }
    79 
    80 function tag_save_on_publish() {
    81     jQuery('.tagsdiv').each( function(i) {
    82         if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') )
    83             tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id'));
    84         } );
    85 }
    86 
    87 function tag_press_key( e ) {
    88     if ( 13 == e.which ) {
    89         tag_flush_to_text(jQuery(e.target).parents('.tagsdiv').attr('id'));
    90         return false;
    91     }
    92 };
    93 
    94 function tag_init() {
    95 
    96     jQuery('.ajaxtag').show();
    97     jQuery('.tagsdiv').each( function(i) {
    98         tag_update_quickclicks(this);
    99     } );
    100 
    101     // add the quickadd form
    102     jQuery('.ajaxtag input.tagadd').click(function(){tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id'));});
    103     jQuery('.ajaxtag input.newtag').focus(function() {
    104         if ( !this.cleared ) {
    105             this.cleared = true;
    106             jQuery(this).val( '' ).removeClass( 'form-input-tip' );
    107         }
    108     });
    109 
    110     jQuery('.ajaxtag input.newtag').blur(function() {
    111         if ( this.value == '' ) {
    112             this.cleared = false;
    113             jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
    114         }
    115     });
    116 
    117     // auto-save tags on post save/publish
    118     jQuery('#publish').click( tag_save_on_publish );
    119     jQuery('#save-post').click( tag_save_on_publish );
    120 
    121     // catch the enter key
    122     jQuery('.ajaxtag input.newtag').keypress( tag_press_key );
    123 }
    124 
    125 (function($){
    126     tagCloud = {
    127         init : function() {
    128             $('.tagcloud-link').click(function(){tagCloud.get($(this).attr('id')); $(this).unbind().click(function(){return false;}); return false;});
    129         },
    130 
    131         get : function(id) {
    132             tax = id.substr(id.indexOf('-')+1);
    133 
    134             $.post('admin-ajax.php', {'action':'get-tagcloud','tax':tax}, function(r, stat) {
    135                 if ( 0 == r || 'success' != stat )
    136                     r = wpAjax.broken;
    137 
    138                 r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
    139                 $('a', r).click(function(){
    140                     var id = $(this).parents('p').attr('id');
    141                     tag_flush_to_text(id.substr(id.indexOf('-')+1), this);
    142                     return false;
    143                 });
    144 
    145                 $('#'+id).after(r);
    146             });
    147         }
    148     }
    149 })(jQuery);
    150 
    151 jQuery(document).ready( function($) {
    152     tagCloud.init();
    153 
    154     // postboxes
    155     postboxes.add_postbox_toggles('post');
    156 
    157     // Editable slugs
    158     make_slugedit_clickable();
    159 
    160     // prepare the tag UI
    161     tag_init();
    162 
    163     jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
    164 
    165     // auto-suggest stuff
    166     jQuery('.newtag').each(function(){
    167         var tax = $(this).parents('div.tagsdiv').attr('id');
    168         $(this).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
    169     });
    170 
    171     // category tabs
    172     var categoryTabs =jQuery('#category-tabs').tabs();
    173 
    174     // Ajax Cat
    175     var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
    176     jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
    177     var newCatParent = false;
    178     var newCatParentOption = false;
    179     var noSyncChecks = false; // prophylactic. necessary?
    180     var syncChecks = function() {
    181         if ( noSyncChecks )
    182             return;
    183         noSyncChecks = true;
    184         var th = jQuery(this);
    185         var c = th.is(':checked');
    186         var id = th.val().toString();
    187         jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
    188         noSyncChecks = false;
    189     };
    190     var popularCats = jQuery('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(',');
    191     var catAddBefore = function( s ) {
    192         s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize();
    193         return s;
    194     };
    195     var catAddAfter = function( r, s ) {
    196         if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
    197         if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
    198         jQuery(s.what + ' response_data', r).each( function() {
    199             var t = jQuery(jQuery(this).text());
    200             t.find( 'label' ).each( function() {
    201                 var th = jQuery(this);
    202                 var val = th.find('input').val();
    203                 var id = th.find('input')[0].id
    204                 jQuery('#' + id).change( syncChecks ).change();
    205                 if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
    206                     return;
    207                 var name = jQuery.trim( th.text() );
    208                 var o = jQuery( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
    209                 newCatParent.prepend( o );
    210             } );
    211             newCatParentOption.attr( 'selected', true );
    212         } );
    213     };
    214     jQuery('#categorychecklist').wpList( {
    215         alt: '',
    216         response: 'category-ajax-response',
    217         addBefore: catAddBefore,
    218         addAfter: catAddAfter
    219     } );
    220     jQuery('#category-add-toggle').click( function() {
    221         jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
    222         // categoryTabs.tabs( 'select', '#categories-all' ); // this is broken (in the UI beta?)
    223         categoryTabs.find( 'a[href="#categories-all"]' ).click();
    224         jQuery('#newcat').focus();
    225         return false;
    226     } );
    227 
    228     $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
    229     $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
    230     if ( 'pop' == getUserSetting('cats') )
    231         $('a[href="#categories-pop"]').click();
    232 
    233     jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
    234     var stamp = $('#timestamp').html();
    235     var visibility = $('#post-visibility-display').html();
    236     var sticky = '';
    237 
    238     function updateVisibility() {
    239         if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
    240             $('#sticky').attr('checked', false);
    241             $('#sticky-span').hide();
    242         } else {
    243             $('#sticky-span').show();
    244         }
    245         if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
    246             $('#password-span').hide();
    247         } else {
    248             $('#password-span').show();
    249         }
    250     }
    251 
    252     function updateText() {
    253         var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
    254         var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
    255         var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
    256         if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
    257             var publishOn = postL10n.publishOnFuture;
    258             $('#publish').val( postL10n.schedule );
    259         } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
    260             var publishOn = postL10n.publishOn;
    261             $('#publish').val( postL10n.publish );
    262         } else {
    263             var publishOn = postL10n.publishOnPast;
    264             $('#publish').val( postL10n.update );
    265         }
    266         if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
    267             $('#timestamp').html(stamp);
    268         } else {
    269             $('#timestamp').html(
    270                 publishOn + ' <b>' +
    271                 $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
    272                 $('#jj').val() + ', ' +
    273                 $('#aa').val() + ' @ ' +
    274                 $('#hh').val() + ':' +
    275                 $('#mn').val() + '</b> '
    276             );
    277         }
    278 
    279         if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
    280             $('#publish').val( postL10n.update );
    281             if ( $('#post_status option[value=publish]').length == 0 ) {
    282                 $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
    283             }
    284             $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
    285             $('#post_status option[value=publish]').attr('selected', true);
    286             $('.edit-post-status').hide();
    287         } else {
    288             if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
    289                 if ( $('#post_status option[value=publish]').length != 0 ) {
    290                     $('#post_status option[value=publish]').remove();
    291                     $('#post_status').val($('#hidden_post_status').val());
    292                 }
    293             } else {
    294                 $('#post_status option[value=publish]').html( postL10n.published );
    295             }
    296             $('.edit-post-status').show();
    297         }
    298         $('#post-status-display').html($('#post_status :selected').text());
    299         if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
    300             $('#save-post').hide();
    301         } else {
    302             $('#save-post').show();
    303             if ( $('#post_status :selected').val() == 'pending' ) {
    304                 $('#save-post').show().val( postL10n.savePending );
    305             } else {
    306                 $('#save-post').show().val( postL10n.saveDraft );
    307             }
    308         }
    309     }
    310 
    311     $('.edit-visibility').click(function () {
    312         if ($('#post-visibility-select').is(":hidden")) {
    313             updateVisibility();
    314             $('#post-visibility-select').slideDown("normal");
    315             $('.edit-visibility').hide();
    316         }
    317         return false;
    318     });
    319 
    320     $('.cancel-post-visibility').click(function () {
    321         $('#post-visibility-select').slideUp("normal");
    322         $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
    323         $('#post_password').val($('#hidden_post_password').val());
    324         $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked'));
    325         $('#post-visibility-display').html(visibility);
    326         $('.edit-visibility').show();
    327         updateText();
    328         return false;
    329     });
    330 
    331     $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
    332         $('#post-visibility-select').slideUp("normal");
    333         $('.edit-visibility').show();
    334         updateText();
    335         if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
    336             $('#sticky').attr('checked', false);
    337         }
    338 
    339         if ( true == $('#sticky').attr('checked') ) {
    340             sticky = 'Sticky';
    341         } else {
    342             sticky = '';
    343         }
    344 
    345         $('#post-visibility-display').html(
    346             postL10n[$('#post-visibility-select input:radio:checked').val() + sticky]
    347         );
    348 
    349         return false;
    350     });
    351 
    352     $('#post-visibility-select input:radio').change(function() {
    353         updateVisibility();
    354     });
    355 
    356     $('.edit-timestamp').click(function () {
    357         if ($('#timestampdiv').is(":hidden")) {
    358             $('#timestampdiv').slideDown("normal");
    359             $('.edit-timestamp').hide();
    360         }
    361 
    362         return false;
    363     });
    364 
    365     $('.cancel-timestamp').click(function() {
    366         $('#timestampdiv').slideUp("normal");
    367         $('#mm').val($('#hidden_mm').val());
    368         $('#jj').val($('#hidden_jj').val());
    369         $('#aa').val($('#hidden_aa').val());
    370         $('#hh').val($('#hidden_hh').val());
    371         $('#mn').val($('#hidden_mn').val());
    372         $('.edit-timestamp').show();
    373         updateText();
    374         return false;
    375     });
    376 
    377     $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
    378         $('#timestampdiv').slideUp("normal");
    379         $('.edit-timestamp').show();
    380         updateText();
    381 
    382         return false;
    383     });
    384 
    385     $('.edit-post-status').click(function() {
    386         if ($('#post-status-select').is(":hidden")) {
    387             $('#post-status-select').slideDown("normal");
    388             $(this).hide();
    389         }
    390 
    391         return false;
    392     });
    393 
    394     $('.save-post-status').click(function() {
    395         $('#post-status-select').slideUp("normal");
    396         $('.edit-post-status').show();
    397         updateText();
    398         return false;
    399     });
    400 
    401     $('.cancel-post-status').click(function() {
    402         $('#post-status-select').slideUp("normal");
    403         $('#post_status').val($('#hidden_post_status').val());
    404         $('.edit-post-status').show();
    405         updateText();
    406         return false;
    407     });
    408 
    409     // Custom Fields
    410     jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
    411         $('table#list-table').show();
    412         if ( jQuery.isFunction( autosave_update_post_ID ) ) {
    413             autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
    414         }
    415     }, addBefore: function( s ) {
    416         s.data += '&post_id=' + jQuery('#post_ID').val();
    417         return s;
    418     }
    419     });
    420 
    421     // preview
    422     $('#post-preview').click(function(e){
    423         if ( 1 > $('#post_ID').val() && autosaveFirst ) {
    424             autosaveDelayPreview = true;
    425             autosave();
    426             return false;
    427         }
    428 
    429         $('input#wp-preview').val('dopreview');
    430         $('form#post').attr('target', 'wp-preview').submit().attr('target', '');
    431         $('input#wp-preview').val('');
    432         return false;
    433     });
    434 
    435 });
    436 
    437 (function($){
    438     commentsBox = {
    439         st : 0,
    440 
    441         get : function(total, num) {
    442             var st = this.st;
    443             if ( ! num )
    444                 num = 20;
    445 
    446             this.st += num;
    447             this.total = total;
    448             $('.waiting').show();
    449 
    450             var data = {
    451                 'action' : 'get-comments',
    452                 'mode' : 'single',
    453                 '_ajax_nonce' : $('#add_comment_nonce').val(),
    454                 'post_ID' : $('#post_ID').val(),
    455                 'start' : st,
    456                 'num' : num
    457             };
    458 
    459             $.post('admin-ajax.php', data,
    460                 function(r) {
    461                     var r = wpAjax.parseAjaxResponse(r);
    462                     $('#commentstatusdiv .widefat').show();
    463                     $('.waiting').hide();
    464 
    465                     if ( 'object' == typeof r && r.responses[0] ) {
    466                         $('#the-comment-list').append( r.responses[0].data );
    467 
    468                         theList = theExtraList = null;
    469                         $("a[className*=':']").unbind();
    470                         setCommentsList();
    471 
    472                         if ( commentsBox.st > commentsBox.total )
    473                             $('#show-comments').hide();
    474                         else
    475                             $('#show-comments').html(postL10n.showcomm);
    476                         return;
    477                     } else if ( 1 == r ) {
    478                         $('#show-comments').parent().html(postL10n.endcomm);
    479                         return;
    480                     }
    481 
    482                     $('#the-comment-list').append('<tr><td colspan="5">'+wpAjax.broken+'</td></tr>');
    483                 }
    484             );
    485 
    486             return false;
    487         }
    488     };
    489 
    490 })(jQuery);
    491 
     1function array_unique_noempty(b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}function new_tag_remove_tag(){var e=jQuery(this).attr("id"),a=e.split("-check-num-")[1],c=jQuery(this).parents(".tagsdiv"),b=c.find(".the-tags").val().split(","),d=[];delete b[a];jQuery.each(b,function(f,g){g=jQuery.trim(g);if(g){d.push(g)}});c.find(".the-tags").val(d.join(",").replace(/\s*,+\s*/,",").replace(/,+/,",").replace(/,+\s+,+/,",").replace(/,+\s*$/,"").replace(/^\s*,+/,""));tag_update_quickclicks(c);return false}function tag_update_quickclicks(b){if(jQuery(b).find(".the-tags").length==0){return}var a=jQuery(b).find(".the-tags").val().split(",");jQuery(b).find(".tagchecklist").empty();shown=false;jQuery.each(a,function(e,f){var c;f=jQuery.trim(f);if(!f.match(/^\s+$/)&&""!=f){var d=jQuery(b).attr("id")+"-check-num-"+e;c='<span><a id="'+d+'" class="ntdelbutton">X</a>&nbsp;'+f+"</span> ";jQuery(b).find(".tagchecklist").append(c);jQuery("#"+d).click(new_tag_remove_tag)}});if(shown){jQuery(b).find(".tagchecklist").prepend("<strong>"+postL10n.tagsUsed+"</strong><br />")}}function tag_flush_to_text(g,b){b=b||false;var e,f,c,d;e=jQuery("#"+g);f=b?jQuery(b).text():e.find("input.newtag").val();if(e.find("input.newtag").hasClass("form-input-tip")&&!b){return false}c=e.find(".the-tags").val();d=c?c+","+f:f;d=d.replace(/\s+,+\s*/g,",").replace(/,+/g,",").replace(/,+\s+,+/g,",").replace(/,+\s*$/g,"").replace(/^\s*,+/g,"");d=array_unique_noempty(d.split(",")).join(",");e.find(".the-tags").val(d);tag_update_quickclicks(e);if(!b){e.find("input.newtag").val("").focus()}return false}function tag_save_on_publish(){jQuery(".tagsdiv").each(function(a){if(!jQuery(this).find("input.newtag").hasClass("form-input-tip")){tag_flush_to_text(jQuery(this).parents(".tagsdiv").attr("id"))}})}function tag_press_key(a){if(13==a.which){tag_flush_to_text(jQuery(a.target).parents(".tagsdiv").attr("id"));return false}}function tag_init(){jQuery(".ajaxtag").show();jQuery(".tagsdiv").each(function(a){tag_update_quickclicks(this)});jQuery(".ajaxtag input.tagadd").click(function(){tag_flush_to_text(jQuery(this).parents(".tagsdiv").attr("id"))});jQuery(".ajaxtag input.newtag").focus(function(){if(!this.cleared){this.cleared=true;jQuery(this).val("").removeClass("form-input-tip")}});jQuery(".ajaxtag input.newtag").blur(function(){if(this.value==""){this.cleared=false;jQuery(this).val(postL10n.addTag).addClass("form-input-tip")}});jQuery("#publish").click(tag_save_on_publish);jQuery("#save-post").click(tag_save_on_publish);jQuery(".ajaxtag input.newtag").keypress(tag_press_key)}(function(a){tagCloud={init:function(){a(".tagcloud-link").click(function(){tagCloud.get(a(this).attr("id"));a(this).unbind().click(function(){return false});return false})},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post("admin-ajax.php",{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");a("a",e).click(function(){var f=a(this).parents("p").attr("id");tag_flush_to_text(f.substr(f.indexOf("-")+1),this);return false});a("#"+c).after(e)})}}})(jQuery);jQuery(document).ready(function(f){var j,g,c=false,h=false,b=false,i,d;tagCloud.init();postboxes.add_postbox_toggles("post");make_slugedit_clickable();tag_init();f("#title").blur(function(){if((f("#post_ID").val()>0)||(f("#title").val().length==0)){return}autosave()});f(".newtag").each(function(){var k=f(this).parents("div.tagsdiv").attr("id");f(this).suggest("admin-ajax.php?action=ajax-tag-search&tax="+k,{delay:500,minchars:2,multiple:true,multipleSep:", "})});j=jQuery("#category-tabs").tabs();g=f("#newcat").one("focus",function(){f(this).val("").removeClass("form-input-tip")});f("#category-add-sumbit").click(function(){g.focus()});i=function(){if(b){return}b=true;var k=jQuery(this),m=k.is(":checked"),l=k.val().toString();f("#in-category-"+l+", #in-popular-category-"+l).attr("checked",m);b=false};popularCats=f("#categorychecklist-pop :checkbox").map(function(){return parseInt(jQuery(this).val(),10)}).get().join(",");catAddBefore=function(k){k.data+="&popular_ids="+popularCats+"&"+jQuery("#categorychecklist :checked").serialize();return k};d=function(l,k){if(!c){c=jQuery("#newcat_parent")}if(!h){h=c.find("option[value=-1]")}f(k.what+" response_data",l).each(function(){var m=f(f(this).text());m.find("label").each(function(){var p=f(this),r=p.find("input").val(),s=p.find("input")[0].id,n,q;f("#"+s).change(i).change();if(c.find("option[value="+r+"]").size()){return}n=f.trim(p.text());q=f('<option value="'+parseInt(r,10)+'"></option>').text(n);c.prepend(q)});h.attr("selected",true)})};f("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:d});f("#category-add-toggle").click(function(){f(this).parents("div:first").toggleClass("wp-hidden-children");j.find('a[href="#categories-all"]').click();f("#newcat").focus();return false});f('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});f('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){f('a[href="#categories-pop"]').click()}f(".categorychecklist .popular-category :checkbox").change(i).filter(":checked").change(),sticky="";function e(){if(f("#post-visibility-select input:radio:checked").val()!="public"){f("#sticky").attr("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("#post-visibility-select input:radio:checked").val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function a(){var k,m,l,n;k=new Date(f("#aa").val(),f("#mm").val()-1,f("#jj").val(),f("#hh").val(),f("#mn").val());m=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());l=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(k>l&&f("#original_post_status").val()!="future"){n=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(k<=l&&f("#original_post_status").val()!="publish"){n=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{n=postL10n.publishOnPast;f("#publish").val(postL10n.update)}}if(m.toUTCString()==k.toUTCString()){f("#timestamp").html(stamp)}else{f("#timestamp").html(n+" <b>"+f("#mm option[value="+f("#mm").val()+"]").text()+" "+f("#jj").val()+", "+f("#aa").val()+" @ "+f("#hh").val()+":"+f("#mn").val()+"</b> ")}if(f("#post-visibility-select input:radio:checked").val()=="private"){f("#publish").val(postL10n.update);if(f("#post_status option[value=publish]").length==0){f("#post_status").append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}f("#post_status option[value=publish]").html(postL10n.privatelyPublished);f("#post_status option[value=publish]").attr("selected",true);f(".edit-post-status").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(f("#post_status option[value=publish]").length!=0){f("#post_status option[value=publish]").remove();f("#post_status").val(f("#hidden_post_status").val())}}else{f("#post_status option[value=publish]").html(postL10n.published)}f(".edit-post-status").show()}f("#post-status-display").html(f("#post_status :selected").text());if(f("#post_status :selected").val()=="private"||f("#post_status :selected").val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("#post_status :selected").val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}}f(".edit-visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){e();f("#post-visibility-select").slideDown("normal");f(".edit-visibility").hide()}return false});f(".cancel-post-visibility").click(function(){f("#post-visibility-select").slideUp("normal");f("#visibility-radio-"+f("#hidden-post-visibility").val()).attr("checked",true);f("#post_password").val(f("#hidden_post_password").val());f("#sticky").attr("checked",f("#hidden-post-sticky").attr("checked"));f("#post-visibility-display").html(visibility);f(".edit-visibility").show();a();return false});f(".save-post-visibility").click(function(){f("#post-visibility-select").slideUp("normal");f(".edit-visibility").show();a();if(f("#post-visibility-select input:radio:checked").val()!="public"){f("#sticky").attr("checked",false)}if(true==f("#sticky").attr("checked")){sticky="Sticky"}else{sticky=""}f("#post-visibility-display").html(postL10n[f("#post-visibility-select input:radio:checked").val()+sticky]);return false});f("#post-visibility-select input:radio").change(function(){e()});f(".edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("normal");f(".edit-timestamp").hide()}return false});f(".cancel-timestamp").click(function(){f("#timestampdiv").slideUp("normal");f("#mm").val(f("#hidden_mm").val());f("#jj").val(f("#hidden_jj").val());f("#aa").val(f("#hidden_aa").val());f("#hh").val(f("#hidden_hh").val());f("#mn").val(f("#hidden_mn").val());f(".edit-timestamp").show();a();return false});f(".save-timestamp").click(function(){f("#timestampdiv").slideUp("normal");f(".edit-timestamp").show();a();return false});f(".edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("normal");f(this).hide()}return false});f(".save-post-status").click(function(){f("#post-status-select").slideUp("normal");f(".edit-post-status").show();a();return false});f(".cancel-post-status").click(function(){f("#post-status-select").slideUp("normal");f("#post_status").val(f("#hidden_post_status").val());f(".edit-post-status").show();a();return false});jQuery("#the-list").wpList({addAfter:function(k,l){f("table#list-table").show();if(jQuery.isFunction(autosave_update_post_ID)){autosave_update_post_ID(l.parsed.responses[0].supplemental.postid)}},addBefore:function(k){k.data+="&post_id="+jQuery("#post_ID").val();return k}});f("#post-preview").click(function(k){if(1>f("#post_ID").val()&&autosaveFirst){autosaveDelayPreview=true;autosave();return false}f("input#wp-preview").val("dopreview");f("form#post").attr("target","wp-preview").submit().attr("target","");f("input#wp-preview").val("");return false})});(function(a){commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a(".waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post("admin-ajax.php",e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentstatusdiv .widefat").show();a(".waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="5">'+wpAjax.broken+"</td></tr>")});return false}}})(jQuery);
  • trunk/wp-admin/js/postbox.js

    r10019 r10291  
    1 (function($) {
    2     postboxes = {
    3         add_postbox_toggles : function(page,args) {
    4             $('.postbox h3, .postbox .handlediv').click( function() {
    5                 $($(this).parent().get(0)).toggleClass('closed');
    6                 postboxes.save_state(page);
    7             } );
    8             $('.postbox h3 a').click( function(e) {
    9                 e.stopPropagation();
    10             } );
    11 
    12             $('.hide-postbox-tog').click( function() {
    13                 var box = jQuery(this).val();
    14                 if ( jQuery(this).attr('checked') ) {
    15                     jQuery('#' + box).show();
    16                     if ( $.isFunction( postboxes.pbshow ) )
    17                         postboxes.pbshow( box );
    18 
    19                 } else {
    20                     jQuery('#' + box).hide();
    21                     if ( $.isFunction( postboxes.pbhide ) )
    22                         postboxes.pbhide( box );
    23 
    24                 }
    25                 postboxes.save_state(page);
    26             } );
    27 
    28             this.expandSidebar();
    29             this.init(page,args);
    30         },
    31 
    32         expandSidebar : function(doIt) {
    33             if ( doIt || $('#side-sortables > .postbox:visible').length ) {
    34                 if ( ! $('#post-body').hasClass('has-sidebar') ) {
    35                     $('#post-body').addClass('has-sidebar');
    36                     var h = Math.min( $('#post-body').height(), 300 );
    37                     $('#side-sortables').css({'minHeight':h+'px','height':'auto'});
    38                 }
    39             } else {
    40                 $('#post-body').removeClass('has-sidebar');
    41                 $('#side-sortables').css({'minHeight':'0'});
    42                 if ( $.browser.msie && $.browser.version.charAt(0) == 7 )
    43                     $('#side-sortables').css({'height':'0'});
    44             }
    45         },
    46 
    47         init : function(page, args) {
    48             $.extend( this, args || {} );
    49             $('#wpbody-content').css('overflow','hidden');
    50             $('.meta-box-sortables').sortable( {
    51                 placeholder: 'sortable-placeholder',
    52                 connectWith: [ '.meta-box-sortables' ],
    53                 items: '> .postbox',
    54                 handle: '.hndle',
    55                 distance: 2,
    56                 tolerance: 'pointer',
    57                 toleranceMove: 'tolerance',
    58                 sort: function(e,ui) {
    59                     if ( $(document).width() - e.clientX < 300 ) {
    60                         if ( ! $('#post-body').hasClass('has-sidebar') ) {
    61                             var pos = $('#side-sortables').offset();
    62 
    63                             $('#side-sortables').append(ui.item)
    64                             $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width())
    65                             postboxes.expandSidebar(1);
    66                         }
    67                     }
    68                 },
    69                 stop: function() {
    70                     var postVars = {
    71                         action: 'meta-box-order',
    72                         _ajax_nonce: $('#meta-box-order-nonce').val(),
    73                         page: page
    74                     }
    75                     $('.meta-box-sortables').each( function() {
    76                         postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
    77                     } );
    78                     $.post( postboxL10n.requestFile, postVars, function() {
    79                         postboxes.expandSidebar();
    80                     } );
    81                 }
    82             } );
    83         },
    84 
    85         save_state : function(page) {
    86             var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
    87             var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
    88             $.post(postboxL10n.requestFile, {
    89                 action: 'closed-postboxes',
    90                 closed: closed,
    91                 hidden: hidden,
    92                 closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
    93                 page: page
    94             });
    95             postboxes.expandSidebar();
    96         },
    97 
    98         /* Callbacks */
    99         pbshow : false,
    100 
    101         pbhide : false
    102     };
    103 
    104 }(jQuery));
     1(function(a){postboxes={add_postbox_toggles:function(c,b){a(".postbox h3, .postbox .handlediv").click(function(){a(a(this).parent().get(0)).toggleClass("closed");postboxes.save_state(c)});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".hide-postbox-tog").click(function(){var d=jQuery(this).val();if(jQuery(this).attr("checked")){jQuery("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{jQuery("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c)});this.expandSidebar();this.init(c,b)},expandSidebar:function(b){if(b||a("#side-sortables > .postbox:visible").length){if(!a("#post-body").hasClass("has-sidebar")){a("#post-body").addClass("has-sidebar");var c=Math.min(a("#post-body").height(),300);a("#side-sortables").css({minHeight:c+"px",height:"auto"})}}else{a("#post-body").removeClass("has-sidebar");a("#side-sortables").css({minHeight:"0"});if(a.browser.msie&&a.browser.version.charAt(0)==7){a("#side-sortables").css({height:"0"})}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:[".meta-box-sortables"],items:"> .postbox",handle:".hndle",distance:2,tolerance:"pointer",toleranceMove:"tolerance",sort:function(f,d){if(a(document).width()-f.clientX<300){if(!a("#post-body").hasClass("has-sidebar")){var g=a("#side-sortables").offset();a("#side-sortables").append(d.item);a(d.placeholder).css({top:g.top,left:g.left}).width(a(d.item).width());postboxes.expandSidebar(1)}}},stop:function(){var d={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page:c};a(".meta-box-sortables").each(function(){d["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(postboxL10n.requestFile,d,function(){postboxes.expandSidebar()})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(postboxL10n.requestFile,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d});postboxes.expandSidebar()},pbshow:false,pbhide:false}}(jQuery));
  • trunk/wp-admin/js/slug.js

    r9606 r10291  
    1 function edit_permalink(post_id) {
    2     var i, c = 0;
    3     var e = jQuery('#editable-post-name');
    4     var revert_e = e.html();
    5     var real_slug = jQuery('#post_name');
    6     var revert_slug = real_slug.html();
    7     var b = jQuery('#edit-slug-buttons');
    8     var revert_b = b.html();
    9     var full = jQuery('#editable-post-name-full').html();
    10 
    11     b.html('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
    12     b.children('.save').click(function() {
    13         var new_slug = e.children('input').val();
    14         jQuery.post(slugL10n.requestFile, {
    15             action: 'sample-permalink',
    16             post_id: post_id,
    17             new_slug: new_slug,
    18             new_title: jQuery('#title').val(),
    19             samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) {
    20                 jQuery('#edit-slug-box').html(data);
    21                 b.html(revert_b);
    22                 real_slug.attr('value', new_slug);
    23                 make_slugedit_clickable();
    24             });
    25         return false;
    26     });
    27     jQuery('#edit-slug-buttons .cancel').click(function() {
    28         e.html(revert_e);
    29         b.html(revert_b);
    30         real_slug.attr('value', revert_slug);
    31         return false;
    32     });
    33     for(i=0; i < full.length; ++i) {
    34         if ('%' == full.charAt(i)) c++;
    35     }
    36     slug_value = (c > full.length/4)? '' : full;
    37     e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
    38         var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
    39         // on enter, just save the new slug, don't save the post
    40         if (13 == key) {b.children('.save').click();return false;}
    41         if (27 == key) {b.children('.cancel').click();return false;}
    42         real_slug.attr('value', this.value)}).focus();
    43 }
    44 
    45 function make_slugedit_clickable() {
    46     jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()});
    47 }
    48 
     1function edit_permalink(a){var d,h=0,g=jQuery("#editable-post-name"),j=g.html(),m=jQuery("#post_name"),n=m.html(),k=jQuery("#edit-slug-buttons"),l=k.html(),f=jQuery("#editable-post-name-full").html();k.html('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+"</a>");k.children(".save").click(function(){var b=g.children("input").val();jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_slug:b,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(c){jQuery("#edit-slug-box").html(c);k.html(l);m.attr("value",b);make_slugedit_clickable()});return false});jQuery("#edit-slug-buttons .cancel").click(function(){g.html(j);k.html(l);m.attr("value",n);return false});for(d=0;d<f.length;++d){if("%"==f.charAt(d)){h++}}slug_value=(h>f.length/4)?"":f;g.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(13==b){k.children(".save").click();return false}if(27==b){k.children(".cancel").click();return false}m.attr("value",this.value)}).focus()}function make_slugedit_clickable(){jQuery("#editable-post-name").click(function(){jQuery("#edit-slug-buttons").children(".edit-slug").click()})};
  • trunk/wp-admin/js/tags.js

    r9735 r10291  
    1 jQuery(function($) {
    2     var options = false
    3 
    4     var addAfter = function( r, settings ) {
    5         var name = $("<span>" + $('name', r).text() + "</span>").html();
    6         var id = $('tag', r).attr('id');
    7         options[options.length] = new Option(name, id);
    8 
    9     }
    10 
    11     var addAfter2 = function( x, r ) {
    12         var t = $(r.parsed.responses[0].data);
    13         if ( t.length == 1 )
    14             inlineEditTax.addEvents($(t.id));
    15     }
    16 
    17     var delAfter = function( r, settings ) {
    18         var id = $('tag', r).attr('id');
    19         for ( var o = 0; o < options.length; o++ )
    20             if ( id == options[o].value )
    21                 options[o] = null;
    22     }
    23 
    24     if ( options )
    25         $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
    26     else
    27         $('#the-list').wpList({ addAfter: addAfter2 });
    28 
    29     columns.init('edit-tags');
    30 });
     1jQuery(document).ready(function(c){var b=false,e,d,a;e=function(h,g){var f=c("<span>"+c("name",h).text()+"</span>").html(),i=c("tag",h).attr("id");b[b.length]=new Option(f,i)};d=function(f,h){var g=c(h.parsed.responses[0].data);if(g.length==1){inlineEditTax.addEvents(c(g.id))}};a=function(g,f){var i=c("tag",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};if(b){c("#the-list").wpList({addAfter:e,delAfter:a})}else{c("#the-list").wpList({addAfter:d})}columns.init("edit-tags")});
  • trunk/wp-admin/js/theme-preview.js

    r10054 r10291  
    1 
    2 jQuery(function($) {
    3     if ( 'undefined' == typeof $.fn.pngFix )
    4         $.fn.pngFix = function() { return this; }
    5 
    6     var thickDims = function() {
    7         var tbWindow = $('#TB_window');
    8         var H = $(window).height();
    9         var W = $(window).width();
    10 
    11         if ( tbWindow.size() ) {
    12             tbWindow.width( W - 90 ).height( H - 60 );
    13             $('#TB_iframeContent').width( W - 90 ).height( H - 90 );
    14             tbWindow.css({'margin-left': '-' + parseInt((( W - 90 ) / 2),10) + 'px'});
    15             if ( typeof document.body.style.maxWidth != 'undefined' )
    16                 tbWindow.css({'top':'30px','margin-top':'0'});
    17         };
    18 
    19         return $('a.thickbox').each( function() {
    20             var href = $(this).parents('.available-theme').find('.previewlink').attr('href');
    21             if ( ! href ) return;
    22             href = href.replace(/&width=[0-9]+/g, '');
    23             href = href.replace(/&height=[0-9]+/g, '');
    24             $(this).attr( 'href', href + '&width=' + ( W - 110 ) + '&height=' + ( H - 100 ) );
    25         });
    26     };
    27 
    28     thickDims()
    29     .click( function() {
    30         var alink = $(this).parents('.available-theme').find('.activatelink');
    31         var url = alink.attr('href');
    32         var text = alink.html();
    33 
    34         $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    35         $('#TB_closeAjaxWindow').css({'float':'left'});
    36         $('#TB_ajaxWindowTitle').css({'float':'right'})
    37             .append('&nbsp;<a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>');
    38 
    39         $('#TB_iframeContent').width('100%');
    40         return false;
    41     } );
    42 
    43     $(window).resize( function() { thickDims() } );
    44 });
     1jQuery(document).ready(function(b){if("undefined"==typeof b.fn.pngFix){b.fn.pngFix=function(){return this}}var a=function(){var e=b("#TB_window"),d=b(window).height(),c=b(window).width();if(e.size()){e.width(c-90).height(d-60);b("#TB_iframeContent").width(c-90).height(d-90);e.css({"margin-left":"-"+parseInt(((c-90)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){e.css({top:"30px","margin-top":"0"})}}return b("a.thickbox").each(function(){var f=b(this).parents(".available-theme").find(".previewlink").attr("href");if(!f){return}f=f.replace(/&width=[0-9]+/g,"");f=f.replace(/&height=[0-9]+/g,"");b(this).attr("href",f+"&width="+(c-110)+"&height="+(d-100))})};a().click(function(){var d=b(this).parents(".available-theme").find(".activatelink"),c=d.attr("href"),e=d.html();b("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});b("#TB_closeAjaxWindow").css({"float":"left"});b("#TB_ajaxWindowTitle").css({"float":"right"}).append('&nbsp;<a href="'+c+'" target="_top" class="tb-theme-preview-link">'+e+"</a>");b("#TB_iframeContent").width("100%");return false});b(window).resize(function(){a()})});
  • trunk/wp-admin/js/widgets.js

    r9822 r10291  
    1 jQuery(function($) {
    2     $('.noscript-action').remove();
    3 
    4     var reminded = false;
    5     var lameWidgetReminder = function() {
    6         if ( reminded )
    7             return;
    8         window.onbeforeunload = function () { return widgetsL10n.lamerReminder };
    9         $('h2:first').after( '<div class="updated"><p>' + widgetsL10n.lameReminder + '</p></div>' );
    10         $('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() {
    11             window.onbeforeunload = null;
    12         } );
    13         reminded = true;
    14     };
    15 
    16     var increment = 1;
    17 
    18     // Open or close widget control form
    19     var toggleWidget = function( li, disableFields ) {
    20         var width = li.find('input.widget-width').val();
    21 
    22         // it seems IE chokes on these animations because of the positioning/floating
    23         var widgetAnim = $.browser.msie ? function() {
    24             var t = $(this);
    25             if ( t.is(':visible') ) {
    26                 if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
    27                 li.css( 'marginLeft', 0 );
    28                 t.siblings('div').children('h4').children('a').text( widgetsL10n.edit );
    29             } else {
    30                 t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
    31                 if ( width > 250 )
    32                     li.css( 'marginLeft', ( width - 250 ) * -1 );
    33                 t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel );
    34             }
    35             t.toggle();
    36         } : function() {
    37             var t = $(this);
    38 
    39             if ( t.is(':visible') ) {
    40                 if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
    41                 if ( width > 250 )
    42                     li.animate( { marginLeft: 0 } );
    43                 t.siblings('div').children('h4').children('a').text( widgetsL10n.edit );
    44             } else {
    45                 t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
    46                 if ( width > 250 )
    47                     li.animate( { marginLeft: ( width - 250 ) * -1 } );
    48                 t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel );
    49             }
    50             t.animate( { height: 'toggle' } );
    51         };
    52 
    53         return li.children('div.widget-control').each( widgetAnim ).end();
    54     };
    55 
    56     // onclick for edit/cancel links
    57     var editClick = function() {
    58         var q = wpAjax.unserialize( this.href );
    59         // if link is in available widgets list, make sure it points to the current sidebar
    60         if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) {
    61             var w = q.edit || q.add;
    62             toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur();
    63             return false;
    64         } else if ( q.sidebar ) { // otherwise, redirect to correct page
    65             return true;
    66         }
    67 
    68         // If link is in current widgets list, just open the form
    69         toggleWidget( $(this).parents('li:first'), true ).blur();
    70         return false;
    71     };
    72 
    73     // onclick for add links
    74     var addClick = function() {
    75         var oldLi = $(this).parents('li:first').find('ul.widget-control-info li');
    76         var newLi = oldLi.clone();
    77 
    78         if ( newLi.html().match( /%i%/ ) ) {
    79             // supplid form is a template, replace %i% by unique id
    80             var i = $('#generated-time').val() + increment.toString();
    81             increment++;
    82             newLi.html( newLi.html().replace( /%i%/g, i ) );
    83         } else {
    84             $(this).text( widgetsL10n.edit ).unbind().click( editClick );
    85             // save form content in textarea so we don't have any conflicting HTML ids
    86             oldLi.html( '<textarea>' + oldLi.html() + '</textarea>' );
    87         }
    88 
    89         // add event handlers
    90         addWidgetControls( newLi );
    91 
    92         // add widget to sidebar sortable
    93         widgetSortable.append( newLi ).SortableAddItem( newLi[0] );
    94 
    95         // increment widget counter
    96         var n = parseInt( $('#widget-count').text(), 10 ) + 1;
    97         $('#widget-count').text( n.toString() )
    98 
    99         lameWidgetReminder();
    100         return false;
    101     };
    102 
    103     // add event handlers to all links found in context
    104     var addWidgetControls = function( context ) {
    105         if ( !context )
    106             context = document;
    107 
    108         $('a.widget-control-edit', context).click( editClick );
    109 
    110         // onclick for save links
    111         $('a.widget-control-save', context).click( function() {
    112             lameWidgetReminder();
    113             toggleWidget( $(this).parents('li:first'), false ).blur()
    114             return false;
    115         } );
    116 
    117         // onclick for remove links
    118         $('a.widget-control-remove', context).click( function() {
    119             var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val();
    120             $(this).parents('li:first').remove();
    121             var t = $('#widget-list ul#widget-control-info-' + w + ' textarea');
    122             t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action')
    123                 .show().text( widgetsL10n.add ).unbind().click( addClick );
    124             var n = parseInt( $('#widget-count').text(), 10 ) - 1;
    125             $('#widget-count').text( n.toString() )
    126             return false;
    127         } );
    128     }
    129 
    130     addWidgetControls();
    131 
    132     $('a.widget-control-add').click( addClick );
    133 
    134     var widgetSortable;
    135     var widgetSortableInit = function() {
    136         try { // a hack to make sortables work in jQuery 1.2+ and IE7
    137             $('#current-sidebar .widget-control-list').SortableDestroy();
    138         } catch(e) {}
    139         widgetSortable = $('#current-sidebar .widget-control-list').Sortable( {
    140             accept: 'widget-sortable',
    141             helperclass: 'sorthelper',
    142             handle: 'h4.widget-title',
    143             onStop: widgetSortableInit
    144         } );
    145     }
    146 
    147     // initialize sortable
    148     widgetSortableInit();
    149 
    150 });
     1jQuery(function(e){e(".noscript-action").remove();var a=false;var h=function(){if(a){return}window.onbeforeunload=function(){return widgetsL10n.lamerReminder};e("h2:first").after('<div class="updated"><p>'+widgetsL10n.lameReminder+"</p></div>");e("#current-widgets .submit input[name=save-widgets]").css("background-color","#ffffe0").click(function(){window.onbeforeunload=null});a=true};var j=1;var g=function(k,m){var l=k.find("input.widget-width").val();var n=e.browser.msie?function(){var o=e(this);if(o.is(":visible")){if(m){o.find(":input:enabled").not('[name="widget-id[]"], [name*="[submit]"]').attr("disabled","disabled")}k.css("marginLeft",0);o.siblings("div").children("h4").children("a").text(widgetsL10n.edit)}else{o.find(":disabled").attr("disabled","");if(l>250){k.css("marginLeft",(l-250)*-1)}o.siblings("div").children("h4").children("a").text(widgetsL10n.cancel)}o.toggle()}:function(){var o=e(this);if(o.is(":visible")){if(m){o.find(":input:enabled").not('[name="widget-id[]"], [name*="[submit]"]').attr("disabled","disabled")}if(l>250){k.animate({marginLeft:0})}o.siblings("div").children("h4").children("a").text(widgetsL10n.edit)}else{o.find(":disabled").attr("disabled","");if(l>250){k.animate({marginLeft:(l-250)*-1})}o.siblings("div").children("h4").children("a").text(widgetsL10n.cancel)}o.animate({height:"toggle"})};return k.children("div.widget-control").each(n).end()};var b=function(){var l=wpAjax.unserialize(this.href);if((l.sidebar&&l.sidebar==e("#sidebar").val())||l.add){var k=l.edit||l.add;g(e('#current-sidebar .widget-control-list input[@name^="widget-id"][@value='+k+"]").parents("li:first"),false).blur();return false}else{if(l.sidebar){return true}}g(e(this).parents("li:first"),true).blur();return false};var c=function(){var o=e(this).parents("li:first").find("ul.widget-control-info li");var l=o.clone();if(l.html().match(/%i%/)){var k=e("#generated-time").val()+j.toString();j++;l.html(l.html().replace(/%i%/g,k))}else{e(this).text(widgetsL10n.edit).unbind().click(b);o.html("<textarea>"+o.html()+"</textarea>")}f(l);i.append(l).SortableAddItem(l[0]);var m=parseInt(e("#widget-count").text(),10)+1;e("#widget-count").text(m.toString());h();return false};var f=function(k){if(!k){k=document}e("a.widget-control-edit",k).click(b);e("a.widget-control-save",k).click(function(){h();g(e(this).parents("li:first"),false).blur();return false});e("a.widget-control-remove",k).click(function(){var l=e(this).parents("li:first").find('input[@name^="widget-id"]').val();e(this).parents("li:first").remove();var m=e("#widget-list ul#widget-control-info-"+l+" textarea");m.parent().html(m.text()).parents("li.widget-list-item:first").children("h4").children("a.widget-action").show().text(widgetsL10n.add).unbind().click(c);var o=parseInt(e("#widget-count").text(),10)-1;e("#widget-count").text(o.toString());return false})};f();e("a.widget-control-add").click(c);var i;var d=function(){try{e("#current-sidebar .widget-control-list").SortableDestroy()}catch(k){}i=e("#current-sidebar .widget-control-list").Sortable({accept:"widget-sortable",helperclass:"sorthelper",handle:"h4.widget-title",onStop:d})};d()});
  • trunk/wp-admin/js/word-count.js

    r8600 r10291  
    1 // Word count
    2 (function(JQ) {
    3     wpWordCount = {
    4 
    5         init : function() {
    6             var t = this, last = 0, co = JQ('#content');
    7 
    8             JQ('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
    9             t.block = 0;
    10             t.wc(co.val());
    11             co.keyup( function(e) {
    12                 if ( e.keyCode == last ) return true;
    13                 if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
    14                 last = e.keyCode;
    15                 return true;
    16             });
    17         },
    18 
    19         wc : function(tx) {
    20             var t = this, w = JQ('#word-count'), tc = 0;
    21 
    22             if ( t.block ) return;
    23             t.block = 1;
    24 
    25             setTimeout( function() {
    26                 if ( tx ) {
    27                     tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( /&nbsp;/gi, ' ' );
    28                     tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
    29                     tx.replace( /\S\s+/g, function(){tc++;} );
    30                 }
    31                 w.html(tc.toString());
    32 
    33                 setTimeout( function() { t.block = 0; }, 2000 );
    34             }, 1 );
    35         }
    36     }
    37 }(jQuery));
    38 
    39 jQuery(document).ready( function(){ wpWordCount.init(); } );
     1(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
  • trunk/wp-admin/js/wp-gears.js

    r10150 r10291  
    1 
    2 wpGears = {
    3 
    4     createStore : function() {
    5         if ( 'undefined' == typeof google || ! google.gears ) return;
    6 
    7         if ( 'undefined' == typeof localServer )
    8             localServer = google.gears.factory.create("beta.localserver");
    9 
    10         store = localServer.createManagedStore(this.storeName());
    11         store.manifestUrl = "gears-manifest.php";
    12         store.checkForUpdate();
    13         this.message(3);
    14     },
    15 
    16     getPermission : function() {
    17         var perm = true;
    18 
    19         if ( 'undefined' != typeof google && google.gears ) {
    20             if ( ! google.gears.factory.hasPermission )
    21                 perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
    22 
    23             if ( perm )
    24                 try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
    25             else
    26                 this.message(4);
    27         }
    28     },
    29 
    30     storeName : function() {
    31         var name = window.location.protocol + window.location.host;
    32 
    33         name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
    34         name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
    35 
    36         return name;
    37     },
    38 
    39     message : function(show) {
    40         var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), msg4 = t.I('gears-msg4'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
    41 
    42         if ( ! msg1 ) return;
    43 
    44         if ( 'undefined' != typeof google && google.gears ) {
    45             if ( show && show == 4 ) {
    46                 msg1.style.display = msg2.style.display = msg3.style.display = 'none';
    47                 msg4.style.display = 'block';
    48             } else if ( google.gears.factory.hasPermission ) {
    49                 msg1.style.display = msg2.style.display = msg4.style.display = 'none';
    50                 msg3.style.display = 'block';
    51 
    52                 if ( 'undefined' == typeof store )
    53                     t.createStore();
    54 
    55                 store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
    56                 store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
    57                 store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
    58             } else {
    59                 msg1.style.display = msg3.style.display = msg4.style.display = 'none';
    60                 msg2.style.display = 'block';
    61             }
    62         }
    63     },
    64 
    65     I : function(id) {
    66         return document.getElementById(id);
    67     }
    68 };
    69 
    70 (function() {
    71     if ( 'undefined' != typeof google && google.gears ) return;
    72 
    73     var gf = false;
    74     if ( 'undefined' != typeof GearsFactory ) {
    75         gf = new GearsFactory();
    76     } else {
    77         try {
    78             gf = new ActiveXObject('Gears.Factory');
    79             if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
    80                 gf.privateSetGlobalObject(this);
    81         } catch (e) {
    82             if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
    83                 gf = document.createElement("object");
    84                 gf.style.display = "none";
    85                 gf.width = 0;
    86                 gf.height = 0;
    87                 gf.type = "application/x-googlegears";
    88                 document.documentElement.appendChild(gf);
    89             }
    90         }
    91     }
    92 
    93     if ( ! gf ) return;
    94     if ( 'undefined' == typeof google ) google = {};
    95     if ( ! google.gears ) google.gears = { factory : gf };
    96 })();
     1var wpGears={createStore:function(){if("undefined"==typeof google||!google.gears){return}if("undefined"==typeof localServer){localServer=google.gears.factory.create("beta.localserver")}store=localServer.createManagedStore(this.storeName());store.manifestUrl="gears-manifest.php";store.checkForUpdate();this.message(3)},getPermission:function(){var a=true;if("undefined"!=typeof google&&google.gears){if(!google.gears.factory.hasPermission){a=google.gears.factory.getPermission("WordPress","images/logo.gif")}if(a){try{this.createStore()}catch(b){this.message()}}else{this.message(4)}}},storeName:function(){var a=window.location.protocol+window.location.host;a=a.replace(/[\/\\:*"?<>|;,]+/g,"_");a="wp_"+a.substring(0,60);return a},message:function(a){var d=this,g=d.I("gears-msg1"),f=d.I("gears-msg2"),e=d.I("gears-msg3"),c=d.I("gears-msg4"),b=d.I("gears-upd-number"),h=d.I("gears-wait");if(!g){return}if("undefined"!=typeof google&&google.gears){if(a&&a==4){g.style.display=f.style.display=e.style.display="none";c.style.display="block"}else{if(google.gears.factory.hasPermission){g.style.display=f.style.display=c.style.display="none";e.style.display="block";if("undefined"==typeof store){d.createStore()}store.oncomplete=function(){h.innerHTML=(" "+wpGearsL10n.updateCompleted)};store.onerror=function(){h.innerHTML=(" "+wpGearsL10n.error+" "+store.lastErrorMessage)};store.onprogress=function(i){if(b){b.innerHTML=(" "+i.filesComplete+" / "+i.filesTotal)}}}else{g.style.display=e.style.display=c.style.display="none";f.style.display="block"}}}},I:function(a){return document.getElementById(a)}};(function(){if("undefined"!=typeof google&&google.gears){return}var a=false;if("undefined"!=typeof GearsFactory){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(factory.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if(("undefined"!=typeof navigator.mimeTypes)&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if("undefined"==typeof google){google={}}if(!google.gears){google.gears={factory:a}}})();
  • trunk/wp-admin/js/xfn.js

    r5631 r10291  
    1 function GetElementsWithClassName(elementName, className) {
    2     var allElements = document.getElementsByTagName(elementName);
    3     var elemColl = new Array();
    4     for (i = 0; i < allElements.length; i++) {
    5         if (allElements[i].className == className) {
    6             elemColl[elemColl.length] = allElements[i];
    7         }
    8     }
    9     return elemColl;
    10 }
    11 
    12 function meChecked() {
    13     var undefined;
    14     var eMe = document.getElementById('me');
    15     if (eMe == undefined) return false;
    16     else return eMe.checked;
    17 }
    18 
    19 function upit() {
    20     var isMe = meChecked(); //document.getElementById('me').checked;
    21     var inputColl = GetElementsWithClassName('input', 'valinp');
    22     var results = document.getElementById('link_rel');
    23     var linkText, linkUrl, inputs = '';
    24     for (i = 0; i < inputColl.length; i++) {
    25          inputColl[i].disabled = isMe;
    26          inputColl[i].parentNode.className = isMe ? 'disabled' : '';
    27          if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
    28             inputs += inputColl[i].value + ' ';
    29                 }
    30          }
    31     inputs = inputs.substr(0,inputs.length - 1);
    32     if (isMe) inputs='me';
    33     results.value = inputs;
    34     }
    35 
    36 function blurry() {
    37     if (!document.getElementById) return;
    38 
    39     var aInputs = document.getElementsByTagName('input');
    40 
    41     for (var i = 0; i < aInputs.length; i++) {
    42          aInputs[i].onclick = aInputs[i].onkeyup = upit;
    43     }
    44 }
    45 
    46 addLoadEvent(blurry);
     1function GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;b<d.length;b++){if(d[b].className==c){e[e.length]=d[b]}}return e}function meChecked(){var b,a=document.getElementById("me");if(a==b){return false}else{return a.checked}}function upit(){var b=meChecked(),e=GetElementsWithClassName("input","valinp"),d=document.getElementById("link_rel"),a="",c;for(c=0;c<e.length;c++){e[c].disabled=b;e[c].parentNode.className=b?"disabled":"";if(!b&&e[c].checked&&e[c].value!=""){a+=e[c].value+" "}}a=a.substr(0,a.length-1);if(b){a="me"}d.value=a}function blurry(){if(!document.getElementById){return}var b=document.getElementsByTagName("input"),a;for(a=0;a<b.length;a++){b[a].onclick=b[a].onkeyup=upit}}addLoadEvent(blurry);
  • trunk/wp-includes/js/autosave.js

    r10251 r10291  
    1 var autosaveLast = '';
    2 var autosavePeriodical;
    3 var autosaveOldMessage = '';
    4 var autosaveDelayPreview = false;
    5 var autosaveFirst = true;
    6 
    7 jQuery(function($) {
    8     autosaveLast = $('#post #title').val()+$('#post #content').val();
    9     autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true});
    10 
    11     //Disable autosave after the form has been submitted
    12     $("#post").submit(function() { $.cancel(autosavePeriodical); });
    13 });
    14 
    15 function autosave_parse_response(response) {
    16     var res = wpAjax.parseAjaxResponse(response, 'autosave'); // parse the ajax response
    17     var message = '';
    18 
    19     if ( res && res.responses && res.responses.length ) {
    20         message = res.responses[0].data; // The saved message or error.
    21         // someone else is editing: disable autosave, set errors
    22         if ( res.responses[0].supplemental ) {
    23             if ( 'disable' == res.responses[0].supplemental['disable_autosave'] ) {
    24                 autosave = function() {};
    25                 res = { errors: true };
    26             }
    27             jQuery.each(res.responses[0].supplemental, function(selector, value) {
    28                 if ( selector.match(/^replace-/) ) {
    29                     jQuery('#'+selector.replace('replace-', '')).val(value);
    30                 }
    31             });
    32         }
    33 
    34         // if no errors: add slug UI
    35         if ( !res.errors ) {
    36             var postID = parseInt( res.responses[0].id, 10 );
    37             if ( !isNaN(postID) && postID > 0 ) {
    38                 autosave_update_slug(postID);
    39             }
    40         }
    41     }
    42     if ( message ) { jQuery('#autosave').html(message); } // update autosave message
    43     else if ( autosaveOldMessage && res ) { jQuery('#autosave').html( autosaveOldMessage ); }
    44     return res;
    45 }
    46 
    47 // called when autosaving pre-existing post
    48 function autosave_saved(response) {
    49     autosave_parse_response(response); // parse the ajax response
    50     autosave_enable_buttons(); // re-enable disabled form buttons
    51 }
    52 
    53 // called when autosaving new post
    54 function autosave_saved_new(response) {
    55     var res = autosave_parse_response(response); // parse the ajax response
    56     // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID
    57     if ( res && res.responses.length && !res.errors ) {
    58         var tempID = jQuery('#post_ID').val();
    59         var postID = parseInt( res.responses[0].id, 10 );
    60         autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here
    61         if ( tempID < 0 && postID > 0 ) // update media buttons
    62             jQuery('#media-buttons a').each(function(){
    63                 this.href = this.href.replace(tempID, postID);
    64             });
    65         // activate preview
    66         autosaveFirst = false;
    67         if ( autosaveDelayPreview )
    68             jQuery('#post-preview').click();
    69     } else {
    70         autosave_enable_buttons(); // re-enable disabled form buttons
    71     }
    72 }
    73 
    74 function autosave_update_post_ID( postID ) {
    75     if ( !isNaN(postID) && postID > 0 ) {
    76         if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once
    77         jQuery('#post_ID').attr({name: "post_ID"});
    78         jQuery('#post_ID').val(postID);
    79         // We need new nonces
    80         jQuery.post(autosaveL10n.requestFile, {
    81             action: "autosave-generate-nonces",
    82             post_ID: postID,
    83             autosavenonce: jQuery('#autosavenonce').val(),
    84             post_type: jQuery('#post_type').val()
    85         }, function(html) {
    86             jQuery('#_wpnonce').val(html);
    87             autosave_enable_buttons(); // re-enable disabled form buttons
    88         });
    89         jQuery('#hiddenaction').val('editpost');
    90     }
    91 }
    92 
    93 function autosave_update_slug(post_id) {
    94     // create slug area only if not already there
    95     if ( jQuery.isFunction(make_slugedit_clickable) && !jQuery('#edit-slug-box > *').size() ) {
    96         jQuery.post(
    97             slugL10n.requestFile,
    98             {
    99                 action: 'sample-permalink',
    100                 post_id: post_id,
    101                 new_title: jQuery('#title').val(),
    102                 samplepermalinknonce: jQuery('#samplepermalinknonce').val()
    103             },
    104             function(data) {
    105                 jQuery('#edit-slug-box').html(data);
    106                 make_slugedit_clickable();
    107             }
    108         );
    109     }
    110 }
    111 
    112 function autosave_loading() {
    113     jQuery('#autosave').html(autosaveL10n.savingText);
    114 }
    115 
    116 function autosave_enable_buttons() {
    117     jQuery(".submitbox :button:disabled, .submitbox :submit:disabled").attr('disabled', '');
    118 }
    119 
    120 function autosave_disable_buttons() {
    121     jQuery(".submitbox :button:enabled, .submitbox :submit:enabled").attr('disabled', 'disabled');
    122     setTimeout(autosave_enable_buttons, 5000); // Re-enable 5 sec later.  Just gives autosave a head start to avoid collisions.
    123 }
    124 
    125 var autosave = function() {
    126     // (bool) is rich editor enabled and active
    127     var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();
    128     var post_data = {
    129         action: "autosave",
    130         post_ID:  jQuery("#post_ID").val() || 0,
    131         post_title: jQuery("#title").val() || "",
    132         autosavenonce: jQuery('#autosavenonce').val(),
    133         //tags_input: jQuery("#tags-input").val() || "",
    134         post_type: jQuery('#post_type').val() || "",
    135         autosave: 1
    136     };
    137    
    138     jQuery('.tags-input').each( function() {
    139         post_data[this.name] = this.value;
    140     } );
    141 
    142     // We always send the ajax request in order to keep the post lock fresh.
    143     // This (bool) tells whether or not to write the post to the DB during the ajax request.
    144     var doAutoSave = true;
    145 
    146     // No autosave while thickbox is open (media buttons)
    147     if ( jQuery("#TB_window").css('display') == 'block' )
    148         doAutoSave = false;
    149 
    150     /* Gotta do this up here so we can check the length when tinyMCE is in use */
    151     if ( rich ) {
    152         var ed = tinyMCE.activeEditor;
    153         if ( 'mce_fullscreen' == ed.id )
    154             tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
    155         tinyMCE.get('content').save();
    156     }
    157 
    158     post_data["content"] = jQuery("#content").val();
    159     if ( jQuery('#post_name').val() )
    160         post_data["post_name"] = jQuery('#post_name').val();
    161 
    162     // Nothing to save or no change.
    163     if( (post_data["post_title"].length==0 && post_data["content"].length==0) || post_data["post_title"] + post_data["content"] == autosaveLast) {
    164         doAutoSave = false
    165     }
    166 
    167     autosave_disable_buttons();
    168 
    169     var origStatus = jQuery('#original_post_status').val();
    170 
    171     autosaveLast = jQuery("#title").val()+jQuery("#content").val();
    172     goodcats = ([]);
    173     jQuery("[@name='post_category[]']:checked").each( function(i) {
    174         goodcats.push(this.value);
    175     } );
    176     post_data["catslist"] = goodcats.join(",");
    177 
    178     if ( jQuery("#comment_status").attr("checked") )
    179         post_data["comment_status"] = 'open';
    180     if ( jQuery("#ping_status").attr("checked") )
    181         post_data["ping_status"] = 'open';
    182     if ( jQuery("#excerpt").size() )
    183         post_data["excerpt"] = jQuery("#excerpt").val();
    184     if ( jQuery("#post_author").size() )
    185         post_data["post_author"] = jQuery("#post_author").val();
    186     post_data["user_ID"] = jQuery("#user-id").val();
    187 
    188     // Don't run while the TinyMCE spellcheck is on.  Why?  Who knows.
    189     if ( rich && tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) {
    190         doAutoSave = false;
    191     }
    192 
    193     if ( parseInt(post_data["post_ID"], 10) < 1 ) {
    194         post_data["temp_ID"] = post_data["post_ID"];
    195         var successCallback = autosave_saved_new; // new post
    196     } else {
    197         var successCallback = autosave_saved; // pre-existing post
    198     }
    199 
    200     if ( !doAutoSave ) {
    201         post_data['autosave'] = 0;
    202     }
    203 
    204     autosaveOldMessage = jQuery('#autosave').html();
    205 
    206     jQuery.ajax({
    207         data: post_data,
    208         beforeSend: doAutoSave ? autosave_loading : null,
    209         type: "POST",
    210         url: autosaveL10n.requestFile,
    211         success: successCallback
    212     });
    213 }
     1var autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,autosaveFirst=true;jQuery(function(a){autosaveLast=a("#post #title").val()+a("#post #content").val();autosavePeriodical=a.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});a("#post").submit(function(){a.cancel(autosavePeriodical)})});function autosave_parse_response(b){var c=wpAjax.parseAjaxResponse(b,"autosave"),d="",a;if(c&&c.responses&&c.responses.length){d=c.responses[0].data;if(c.responses[0].supplemental){if("disable"==c.responses[0].supplemental.disable_autosave){autosave=function(){};c={errors:true}}jQuery.each(c.responses[0].supplemental,function(e,f){if(e.match(/^replace-/)){jQuery("#"+e.replace("replace-","")).val(f)}})}if(!c.errors){a=parseInt(c.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(d){jQuery("#autosave").html(d)}else{if(autosaveOldMessage&&c){jQuery("#autosave").html(autosaveOldMessage)}}return c}function autosave_saved(a){autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){c=jQuery("#post_ID").val();a=parseInt(d.responses[0].id,10);autosave_update_post_ID(a);if(c<0&&a>0){jQuery("#media-buttons a").each(function(){this.href=this.href.replace(c,a)})}autosaveFirst=false;if(autosaveDelayPreview){jQuery("#post-preview").click()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(a){if(!isNaN(a)&&a>0){if(a==parseInt(jQuery("#post_ID").val(),10)){return}jQuery("#post_ID").attr({name:"post_ID"});jQuery("#post_ID").val(a);jQuery.post(autosaveL10n.requestFile,{action:"autosave-generate-nonces",post_ID:a,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()},function(b){jQuery("#_wpnonce").val(b);autosave_enable_buttons()});jQuery("#hiddenaction").val("editpost")}}function autosave_update_slug(a){if(jQuery.isFunction(make_slugedit_clickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);make_slugedit_clickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){jQuery(".submitbox :button:disabled, .submitbox :submit:disabled").attr("disabled","")}function autosave_disable_buttons(){jQuery(".submitbox :button:enabled, .submitbox :submit:enabled").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}var autosave=function(){var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c){b=tinyMCE.activeEditor;if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}autosave_disable_buttons();e=jQuery("#original_post_status").val();autosaveLast=jQuery("#title").val()+jQuery("#content").val();goodcats=([]);jQuery("[@name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}d.user_ID=jQuery("#user-id").val();if(c&&tinyMCE.activeEditor.plugins.spellchecker&&tinyMCE.activeEditor.plugins.spellchecker.active){f=false}if(parseInt(d.post_ID,10)<1){d.temp_ID=d.post_ID;a=autosave_saved_new}else{a=autosave_saved}if(!f){d.autosave=0}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})};
  • trunk/wp-includes/js/colorpicker.js

    r7104 r10291  
    1 // ===================================================================
    2 // Author: Matt Kruse <matt@mattkruse.com>
    3 // WWW: http://www.mattkruse.com/
    4 //
    5 // NOTICE: You may use this code for any purpose, commercial or
    6 // private, without any further permission from the author. You may
    7 // remove this notice from your final code if you wish, however it is
    8 // appreciated by the author if at least my web site address is kept.
    9 //
    10 // You may *NOT* re-distribute this code in any way except through its
    11 // use. That means, you can include it in your product, or your web
    12 // site, or any other form where the code is actually being used. You
    13 // may not put the plain javascript up on your site for download or
    14 // include it in your javascript libraries for download.
    15 // If you wish to share this code with others, please just point them
    16 // to the URL instead.
    17 // Please DO NOT link directly to my .js files from your site. Copy
    18 // the files to your server and use them there. Thank you.
    19 // ===================================================================
    20 
    21 
    22 /* SOURCE FILE: AnchorPosition.js */
    23 
    24 /*
    25 AnchorPosition.js
    26 Author: Matt Kruse
    27 Last modified: 10/11/02
    28 
    29 DESCRIPTION: These functions find the position of an <A> tag in a document,
    30 so other elements can be positioned relative to it.
    31 
    32 COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
    33 positioning errors - usually with Window positioning - occur on the
    34 Macintosh platform.
    35 
    36 FUNCTIONS:
    37 getAnchorPosition(anchorname)
    38   Returns an Object() having .x and .y properties of the pixel coordinates
    39   of the upper-left corner of the anchor. Position is relative to the PAGE.
    40 
    41 getAnchorWindowPosition(anchorname)
    42   Returns an Object() having .x and .y properties of the pixel coordinates
    43   of the upper-left corner of the anchor, relative to the WHOLE SCREEN.
    44 
    45 NOTES:
    46 
    47 1) For popping up separate browser windows, use getAnchorWindowPosition.
    48    Otherwise, use getAnchorPosition
    49 
    50 2) Your anchor tag MUST contain both NAME and ID attributes which are the
    51    same. For example:
    52    <A NAME="test" ID="test"> </A>
    53 
    54 3) There must be at least a space between <A> </A> for IE5.5 to see the
    55    anchor tag correctly. Do not do <A></A> with no space.
    56 */
    57 
    58 // getAnchorPosition(anchorname)
    59 //   This function returns an object having .x and .y properties which are the coordinates
    60 //   of the named anchor, relative to the page.
    61 function getAnchorPosition(anchorname) {
    62     // This function will return an Object with x and y properties
    63     var useWindow=false;
    64     var coordinates=new Object();
    65     var x=0,y=0;
    66     // Browser capability sniffing
    67     var use_gebi=false, use_css=false, use_layers=false;
    68     if (document.getElementById) { use_gebi=true; }
    69     else if (document.all) { use_css=true; }
    70     else if (document.layers) { use_layers=true; }
    71     // Logic to find position
    72     if (use_gebi && document.all) {
    73         x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
    74         y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
    75         }
    76     else if (use_gebi) {
    77         var o=document.getElementById(anchorname);
    78         x=AnchorPosition_getPageOffsetLeft(o);
    79         y=AnchorPosition_getPageOffsetTop(o);
    80         }
    81     else if (use_css) {
    82         x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
    83         y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
    84         }
    85     else if (use_layers) {
    86         var found=0;
    87         for (var i=0; i<document.anchors.length; i++) {
    88             if (document.anchors[i].name==anchorname) { found=1; break; }
    89             }
    90         if (found==0) {
    91             coordinates.x=0; coordinates.y=0; return coordinates;
    92             }
    93         x=document.anchors[i].x;
    94         y=document.anchors[i].y;
    95         }
    96     else {
    97         coordinates.x=0; coordinates.y=0; return coordinates;
    98         }
    99     coordinates.x=x;
    100     coordinates.y=y;
    101     return coordinates;
    102     }
    103 
    104 // getAnchorWindowPosition(anchorname)
    105 //   This function returns an object having .x and .y properties which are the coordinates
    106 //   of the named anchor, relative to the window
    107 function getAnchorWindowPosition(anchorname) {
    108     var coordinates=getAnchorPosition(anchorname);
    109     var x=0;
    110     var y=0;
    111     if (document.getElementById) {
    112         if (isNaN(window.screenX)) {
    113             x=coordinates.x-document.body.scrollLeft+window.screenLeft;
    114             y=coordinates.y-document.body.scrollTop+window.screenTop;
    115             }
    116         else {
    117             x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
    118             y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
    119             }
    120         }
    121     else if (document.all) {
    122         x=coordinates.x-document.body.scrollLeft+window.screenLeft;
    123         y=coordinates.y-document.body.scrollTop+window.screenTop;
    124         }
    125     else if (document.layers) {
    126         x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
    127         y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
    128         }
    129     coordinates.x=x;
    130     coordinates.y=y;
    131     return coordinates;
    132     }
    133 
    134 // Functions for IE to get position of an object
    135 function AnchorPosition_getPageOffsetLeft (el) {
    136     var ol=el.offsetLeft;
    137     while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
    138     return ol;
    139     }
    140 function AnchorPosition_getWindowOffsetLeft (el) {
    141     return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
    142     }
    143 function AnchorPosition_getPageOffsetTop (el) {
    144     var ot=el.offsetTop;
    145     while((el=el.offsetParent) != null) { ot += el.offsetTop; }
    146     return ot;
    147     }
    148 function AnchorPosition_getWindowOffsetTop (el) {
    149     return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
    150     }
    151 
    152 /* SOURCE FILE: PopupWindow.js */
    153 
    154 /*
    155 PopupWindow.js
    156 Author: Matt Kruse
    157 Last modified: 02/16/04
    158 
    159 DESCRIPTION: This object allows you to easily and quickly popup a window
    160 in a certain place. The window can either be a DIV or a separate browser
    161 window.
    162 
    163 COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
    164 positioning errors - usually with Window positioning - occur on the
    165 Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
    166 window with <STYLE> tags may cause errors.
    167 
    168 USAGE:
    169 // Create an object for a WINDOW popup
    170 var win = new PopupWindow();
    171 
    172 // Create an object for a DIV window using the DIV named 'mydiv'
    173 var win = new PopupWindow('mydiv');
    174 
    175 // Set the window to automatically hide itself when the user clicks
    176 // anywhere else on the page except the popup
    177 win.autoHide();
    178 
    179 // Show the window relative to the anchor name passed in
    180 win.showPopup(anchorname);
    181 
    182 // Hide the popup
    183 win.hidePopup();
    184 
    185 // Set the size of the popup window (only applies to WINDOW popups
    186 win.setSize(width,height);
    187 
    188 // Populate the contents of the popup window that will be shown. If you
    189 // change the contents while it is displayed, you will need to refresh()
    190 win.populate(string);
    191 
    192 // set the URL of the window, rather than populating its contents
    193 // manually
    194 win.setUrl("http://www.site.com/");
    195 
    196 // Refresh the contents of the popup
    197 win.refresh();
    198 
    199 // Specify how many pixels to the right of the anchor the popup will appear
    200 win.offsetX = 50;
    201 
    202 // Specify how many pixels below the anchor the popup will appear
    203 win.offsetY = 100;
    204 
    205 NOTES:
    206 1) Requires the functions in AnchorPosition.js
    207 
    208 2) Your anchor tag MUST contain both NAME and ID attributes which are the
    209    same. For example:
    210    <A NAME="test" ID="test"> </A>
    211 
    212 3) There must be at least a space between <A> </A> for IE5.5 to see the
    213    anchor tag correctly. Do not do <A></A> with no space.
    214 
    215 4) When a PopupWindow object is created, a handler for 'onmouseup' is
    216    attached to any event handler you may have already defined. Do NOT define
    217    an event handler for 'onmouseup' after you define a PopupWindow object or
    218    the autoHide() will not work correctly.
    219 */
    220 
    221 // Set the position of the popup window based on the anchor
    222 function PopupWindow_getXYPosition(anchorname) {
    223     var coordinates;
    224     if (this.type == "WINDOW") {
    225         coordinates = getAnchorWindowPosition(anchorname);
    226         }
    227     else {
    228         coordinates = getAnchorPosition(anchorname);
    229         }
    230     this.x = coordinates.x;
    231     this.y = coordinates.y;
    232     }
    233 // Set width/height of DIV/popup window
    234 function PopupWindow_setSize(width,height) {
    235     this.width = width;
    236     this.height = height;
    237     }
    238 // Fill the window with contents
    239 function PopupWindow_populate(contents) {
    240     this.contents = contents;
    241     this.populated = false;
    242     }
    243 // Set the URL to go to
    244 function PopupWindow_setUrl(url) {
    245     this.url = url;
    246     }
    247 // Set the window popup properties
    248 function PopupWindow_setWindowProperties(props) {
    249     this.windowProperties = props;
    250     }
    251 // Refresh the displayed contents of the popup
    252 function PopupWindow_refresh() {
    253     if (this.divName != null) {
    254         // refresh the DIV object
    255         if (this.use_gebi) {
    256             document.getElementById(this.divName).innerHTML = this.contents;
    257             }
    258         else if (this.use_css) {
    259             document.all[this.divName].innerHTML = this.contents;
    260             }
    261         else if (this.use_layers) {
    262             var d = document.layers[this.divName];
    263             d.document.open();
    264             d.document.writeln(this.contents);
    265             d.document.close();
    266             }
    267         }
    268     else {
    269         if (this.popupWindow != null && !this.popupWindow.closed) {
    270             if (this.url!="") {
    271                 this.popupWindow.location.href=this.url;
    272                 }
    273             else {
    274                 this.popupWindow.document.open();
    275                 this.popupWindow.document.writeln(this.contents);
    276                 this.popupWindow.document.close();
    277             }
    278             this.popupWindow.focus();
    279             }
    280         }
    281     }
    282 // Position and show the popup, relative to an anchor object
    283 function PopupWindow_showPopup(anchorname) {
    284     this.getXYPosition(anchorname);
    285     this.x += this.offsetX;
    286     this.y += this.offsetY;
    287     if (!this.populated && (this.contents != "")) {
    288         this.populated = true;
    289         this.refresh();
    290         }
    291     if (this.divName != null) {
    292         // Show the DIV object
    293         if (this.use_gebi) {
    294             document.getElementById(this.divName).style.left = this.x + "px";
    295             document.getElementById(this.divName).style.top = this.y;
    296             document.getElementById(this.divName).style.visibility = "visible";
    297             }
    298         else if (this.use_css) {
    299             document.all[this.divName].style.left = this.x;
    300             document.all[this.divName].style.top = this.y;
    301             document.all[this.divName].style.visibility = "visible";
    302             }
    303         else if (this.use_layers) {
    304             document.layers[this.divName].left = this.x;
    305             document.layers[this.divName].top = this.y;
    306             document.layers[this.divName].visibility = "visible";
    307             }
    308         }
    309     else {
    310         if (this.popupWindow == null || this.popupWindow.closed) {
    311             // If the popup window will go off-screen, move it so it doesn't
    312             if (this.x<0) { this.x=0; }
    313             if (this.y<0) { this.y=0; }
    314             if (screen && screen.availHeight) {
    315                 if ((this.y + this.height) > screen.availHeight) {
    316                     this.y = screen.availHeight - this.height;
    317                     }
    318                 }
    319             if (screen && screen.availWidth) {
    320                 if ((this.x + this.width) > screen.availWidth) {
    321                     this.x = screen.availWidth - this.width;
    322                     }
    323                 }
    324             var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
    325             this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
    326             }
    327         this.refresh();
    328         }
    329     }
    330 // Hide the popup
    331 function PopupWindow_hidePopup() {
    332     if (this.divName != null) {
    333         if (this.use_gebi) {
    334             document.getElementById(this.divName).style.visibility = "hidden";
    335             }
    336         else if (this.use_css) {
    337             document.all[this.divName].style.visibility = "hidden";
    338             }
    339         else if (this.use_layers) {
    340             document.layers[this.divName].visibility = "hidden";
    341             }
    342         }
    343     else {
    344         if (this.popupWindow && !this.popupWindow.closed) {
    345             this.popupWindow.close();
    346             this.popupWindow = null;
    347             }
    348         }
    349     }
    350 // Pass an event and return whether or not it was the popup DIV that was clicked
    351 function PopupWindow_isClicked(e) {
    352     if (this.divName != null) {
    353         if (this.use_layers) {
    354             var clickX = e.pageX;
    355             var clickY = e.pageY;
    356             var t = document.layers[this.divName];
    357             if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
    358                 return true;
    359                 }
    360             else { return false; }
    361             }
    362         else if (document.all) { // Need to hard-code this to trap IE for error-handling
    363             var t = window.event.srcElement;
    364             while (t.parentElement != null) {
    365                 if (t.id==this.divName) {
    366                     return true;
    367                     }
    368                 t = t.parentElement;
    369                 }
    370             return false;
    371             }
    372         else if (this.use_gebi && e) {
    373             var t = e.originalTarget;
    374             while (t.parentNode != null) {
    375                 if (t.id==this.divName) {
    376                     return true;
    377                     }
    378                 t = t.parentNode;
    379                 }
    380             return false;
    381             }
    382         return false;
    383         }
    384     return false;
    385     }
    386 
    387 // Check an onMouseDown event to see if we should hide
    388 function PopupWindow_hideIfNotClicked(e) {
    389     if (this.autoHideEnabled && !this.isClicked(e)) {
    390         this.hidePopup();
    391         }
    392     }
    393 // Call this to make the DIV disable automatically when mouse is clicked outside it
    394 function PopupWindow_autoHide() {
    395     this.autoHideEnabled = true;
    396     }
    397 // This global function checks all PopupWindow objects onmouseup to see if they should be hidden
    398 function PopupWindow_hidePopupWindows(e) {
    399     for (var i=0; i<popupWindowObjects.length; i++) {
    400         if (popupWindowObjects[i] != null) {
    401             var p = popupWindowObjects[i];
    402             p.hideIfNotClicked(e);
    403             }
    404         }
    405     }
    406 // Run this immediately to attach the event listener
    407 function PopupWindow_attachListener() {
    408     if (document.layers) {
    409         document.captureEvents(Event.MOUSEUP);
    410         }
    411     window.popupWindowOldEventListener = document.onmouseup;
    412     if (window.popupWindowOldEventListener != null) {
    413         document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
    414         }
    415     else {
    416         document.onmouseup = PopupWindow_hidePopupWindows;
    417         }
    418     }
    419 // CONSTRUCTOR for the PopupWindow object
    420 // Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
    421 function PopupWindow() {
    422     if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
    423     if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
    424     if (!window.listenerAttached) {
    425         window.listenerAttached = true;
    426         PopupWindow_attachListener();
    427         }
    428     this.index = popupWindowIndex++;
    429     popupWindowObjects[this.index] = this;
    430     this.divName = null;
    431     this.popupWindow = null;
    432     this.width=0;
    433     this.height=0;
    434     this.populated = false;
    435     this.visible = false;
    436     this.autoHideEnabled = false;
    437 
    438     this.contents = "";
    439     this.url="";
    440     this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
    441     if (arguments.length>0) {
    442         this.type="DIV";
    443         this.divName = arguments[0];
    444         }
    445     else {
    446         this.type="WINDOW";
    447         }
    448     this.use_gebi = false;
    449     this.use_css = false;
    450     this.use_layers = false;
    451     if (document.getElementById) { this.use_gebi = true; }
    452     else if (document.all) { this.use_css = true; }
    453     else if (document.layers) { this.use_layers = true; }
    454     else { this.type = "WINDOW"; }
    455     this.offsetX = 0;
    456     this.offsetY = 0;
    457     // Method mappings
    458     this.getXYPosition = PopupWindow_getXYPosition;
    459     this.populate = PopupWindow_populate;
    460     this.setUrl = PopupWindow_setUrl;
    461     this.setWindowProperties = PopupWindow_setWindowProperties;
    462     this.refresh = PopupWindow_refresh;
    463     this.showPopup = PopupWindow_showPopup;
    464     this.hidePopup = PopupWindow_hidePopup;
    465     this.setSize = PopupWindow_setSize;
    466     this.isClicked = PopupWindow_isClicked;
    467     this.autoHide = PopupWindow_autoHide;
    468     this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
    469     }
    470 
    471 /* SOURCE FILE: ColorPicker2.js */
    472 
    473 /*
    474 Last modified: 02/24/2003
    475 
    476 DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB
    477 form. It uses a color "swatch" to display the standard 216-color web-safe
    478 palette. The user can then click on a color to select it.
    479 
    480 COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js.
    481 Only the latest DHTML-capable browsers will show the color and hex values
    482 at the bottom as your mouse goes over them.
    483 
    484 USAGE:
    485 // Create a new ColorPicker object using DHTML popup
    486 var cp = new ColorPicker();
    487 
    488 // Create a new ColorPicker object using Window Popup
    489 var cp = new ColorPicker('window');
    490 
    491 // Add a link in your page to trigger the popup. For example:
    492 <A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A>
    493 
    494 // Or use the built-in "select" function to do the dirty work for you:
    495 <A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A>
    496 
    497 // If using DHTML popup, write out the required DIV tag near the bottom
    498 // of your page.
    499 <SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
    500 
    501 // Write the 'pickColor' function that will be called when the user clicks
    502 // a color and do something with the value. This is only required if you
    503 // want to do something other than simply populate a form field, which is
    504 // what the 'select' function will give you.
    505 function pickColor(color) {
    506     field.value = color;
    507     }
    508 
    509 NOTES:
    510 1) Requires the functions in AnchorPosition.js and PopupWindow.js
    511 
    512 2) Your anchor tag MUST contain both NAME and ID attributes which are the
    513    same. For example:
    514    <A NAME="test" ID="test"> </A>
    515 
    516 3) There must be at least a space between <A> </A> for IE5.5 to see the
    517    anchor tag correctly. Do not do <A></A> with no space.
    518 
    519 4) When a ColorPicker object is created, a handler for 'onmouseup' is
    520    attached to any event handler you may have already defined. Do NOT define
    521    an event handler for 'onmouseup' after you define a ColorPicker object or
    522    the color picker will not hide itself correctly.
    523 */
    524 ColorPicker_targetInput = null;
    525 function ColorPicker_writeDiv() {
    526     document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
    527     }
    528 
    529 function ColorPicker_show(anchorname) {
    530     this.showPopup(anchorname);
    531     }
    532 
    533 function ColorPicker_pickColor(color,obj) {
    534     obj.hidePopup();
    535     pickColor(color);
    536     }
    537 
    538 // A Default "pickColor" function to accept the color passed back from popup.
    539 // User can over-ride this with their own function.
    540 function pickColor(color) {
    541     if (ColorPicker_targetInput==null) {
    542         alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");
    543         return;
    544         }
    545     ColorPicker_targetInput.value = color;
    546     }
    547 
    548 // This function is the easiest way to popup the window, select a color, and
    549 // have the value populate a form field, which is what most people want to do.
    550 function ColorPicker_select(inputobj,linkname) {
    551     if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") {
    552         alert("colorpicker.select: Input object passed is not a valid form input object");
    553         window.ColorPicker_targetInput=null;
    554         return;
    555         }
    556     window.ColorPicker_targetInput = inputobj;
    557     this.show(linkname);
    558     }
    559 
    560 // This function runs when you move your mouse over a color block, if you have a newer browser
    561 function ColorPicker_highlightColor(c) {
    562     var thedoc = (arguments.length>1)?arguments[1]:window.document;
    563     var d = thedoc.getElementById("colorPickerSelectedColor");
    564     d.style.backgroundColor = c;
    565     d = thedoc.getElementById("colorPickerSelectedColorValue");
    566     d.innerHTML = c;
    567     }
    568 
    569 function ColorPicker() {
    570     var windowMode = false;
    571     // Create a new PopupWindow object
    572     if (arguments.length==0) {
    573         var divname = "colorPickerDiv";
    574         }
    575     else if (arguments[0] == "window") {
    576         var divname = '';
    577         windowMode = true;
    578         }
    579     else {
    580         var divname = arguments[0];
    581         }
    582 
    583     if (divname != "") {
    584         var cp = new PopupWindow(divname);
    585         }
    586     else {
    587         var cp = new PopupWindow();
    588         cp.setSize(225,250);
    589         }
    590 
    591     // Object variables
    592     cp.currentValue = "#FFFFFF";
    593 
    594     // Method Mappings
    595     cp.writeDiv = ColorPicker_writeDiv;
    596     cp.highlightColor = ColorPicker_highlightColor;
    597     cp.show = ColorPicker_show;
    598     cp.select = ColorPicker_select;
    599 
    600     // Code to populate color picker window
    601     var colors = new Array( "#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099",
    602                             "#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099",
    603                             "#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099",
    604                             "#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF",
    605                             "#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F",
    606                             "#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000",
    607 
    608                             "#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399",
    609                             "#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399",
    610                             "#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399",
    611                             "#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF",
    612                             "#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F",
    613                             "#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00",
    614 
    615                             "#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699",
    616                             "#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699",
    617                             "#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699",
    618                             "#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F",
    619                             "#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F",
    620                             "#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F",
    621 
    622                             "#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999",
    623                             "#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999",
    624                             "#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999",
    625                             "#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF",
    626                             "#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F",
    627                             "#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000",
    628 
    629                             "#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99",
    630                             "#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99",
    631                             "#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99",
    632                             "#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF",
    633                             "#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F",
    634                             "#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00",
    635 
    636                             "#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99",
    637                             "#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99",
    638                             "#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99",
    639                             "#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F",
    640                             "#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F",
    641                             "#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F",
    642 
    643                             "#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666",
    644                             "#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000",
    645                             "#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000",
    646                             "#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999",
    647                             "#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF",
    648                             "#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF",
    649 
    650                             "#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66",
    651                             "#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00",
    652                             "#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000",
    653                             "#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099",
    654                             "#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF",
    655                             "#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF",
    656 
    657                             "#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF",
    658                             "#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC",
    659                             "#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000",
    660                             "#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900",
    661                             "#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33",
    662                             "#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF",
    663 
    664                             "#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF",
    665                             "#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF",
    666                             "#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F",
    667                             "#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F",
    668                             "#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F",
    669                             "#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000");
    670     var total = colors.length;
    671     var width = 72;
    672     var cp_contents = "";
    673     var windowRef = (windowMode)?"window.opener.":"";
    674     if (windowMode) {
    675         cp_contents += "<html><head><title>Select Color</title></head>";
    676         cp_contents += "<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>";
    677         }
    678     cp_contents += "<table style='border: none;' cellspacing=0 cellpadding=0>";
    679     var use_highlight = (document.getElementById || document.all)?true:false;
    680     for (var i=0; i<total; i++) {
    681         if ((i % width) == 0) { cp_contents += "<tr>"; }
    682         if (use_highlight) { var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"'; }
    683         else { mo = ""; }
    684         cp_contents += '<td style="background-color: '+colors[i]+';"><a href="javascript:void()" onclick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+'>&nbsp;</a></td>';
    685         if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
    686             cp_contents += "</tr>";
    687             }
    688         }
    689     // If the browser supports dynamically changing TD cells, add the fancy stuff
    690     if (document.getElementById) {
    691         var width1 = Math.floor(width/2);
    692         var width2 = width = width1;
    693         cp_contents += "<tr><td colspan='"+width1+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+width2+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>";
    694         }
    695     cp_contents += "</table>";
    696     if (windowMode) {
    697         cp_contents += "</span></body></html>";
    698         }
    699     // end populate code
    700 
    701     // Write the contents to the popup object
    702     cp.populate(cp_contents+"\n");
    703     // Move the table down a bit so you can see it
    704     cp.offsetY = 25;
    705     cp.autoHide();
    706     return cp;
    707     }
     1function getAnchorPosition(b){var e=false;var k=new Object();var j=0,g=0;var d=false,f=false,h=false;if(document.getElementById){d=true}else{if(document.all){f=true}else{if(document.layers){h=true}}}if(d&&document.all){j=AnchorPosition_getPageOffsetLeft(document.all[b]);g=AnchorPosition_getPageOffsetTop(document.all[b])}else{if(d){var a=document.getElementById(b);j=AnchorPosition_getPageOffsetLeft(a);g=AnchorPosition_getPageOffsetTop(a)}else{if(f){j=AnchorPosition_getPageOffsetLeft(document.all[b]);g=AnchorPosition_getPageOffsetTop(document.all[b])}else{if(h){var l=0;for(var c=0;c<document.anchors.length;c++){if(document.anchors[c].name==b){l=1;break}}if(l==0){k.x=0;k.y=0;return k}j=document.anchors[c].x;g=document.anchors[c].y}else{k.x=0;k.y=0;return k}}}}k.x=j;k.y=g;return k}function getAnchorWindowPosition(b){var c=getAnchorPosition(b);var a=0;var d=0;if(document.getElementById){if(isNaN(window.screenX)){a=c.x-document.body.scrollLeft+window.screenLeft;d=c.y-document.body.scrollTop+window.screenTop}else{a=c.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;d=c.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset}}else{if(document.all){a=c.x-document.body.scrollLeft+window.screenLeft;d=c.y-document.body.scrollTop+window.screenTop}else{if(document.layers){a=c.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;d=c.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset}}}c.x=a;c.y=d;return c}function AnchorPosition_getPageOffsetLeft(b){var a=b.offsetLeft;while((b=b.offsetParent)!=null){a+=b.offsetLeft}return a}function AnchorPosition_getWindowOffsetLeft(a){return AnchorPosition_getPageOffsetLeft(a)-document.body.scrollLeft}function AnchorPosition_getPageOffsetTop(a){var b=a.offsetTop;while((a=a.offsetParent)!=null){b+=a.offsetTop}return b}function AnchorPosition_getWindowOffsetTop(a){return AnchorPosition_getPageOffsetTop(a)-document.body.scrollTop}function PopupWindow_getXYPosition(a){var b;if(this.type=="WINDOW"){b=getAnchorWindowPosition(a)}else{b=getAnchorPosition(a)}this.x=b.x;this.y=b.y}function PopupWindow_setSize(b,a){this.width=b;this.height=a}function PopupWindow_populate(a){this.contents=a;this.populated=false}function PopupWindow_setUrl(a){this.url=a}function PopupWindow_setWindowProperties(a){this.windowProperties=a}function PopupWindow_refresh(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).innerHTML=this.contents}else{if(this.use_css){document.all[this.divName].innerHTML=this.contents}else{if(this.use_layers){var a=document.layers[this.divName];a.document.open();a.document.writeln(this.contents);a.document.close()}}}}else{if(this.popupWindow!=null&&!this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close()}this.popupWindow.focus()}}}function PopupWindow_showPopup(a){this.getXYPosition(a);this.x+=this.offsetX;this.y+=this.offsetY;if(!this.populated&&(this.contents!="")){this.populated=true;this.refresh()}if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.left=this.x+"px";document.getElementById(this.divName).style.top=this.y;document.getElementById(this.divName).style.visibility="visible"}else{if(this.use_css){document.all[this.divName].style.left=this.x;document.all[this.divName].style.top=this.y;document.all[this.divName].style.visibility="visible"}else{if(this.use_layers){document.layers[this.divName].left=this.x;document.layers[this.divName].top=this.y;document.layers[this.divName].visibility="visible"}}}}else{if(this.popupWindow==null||this.popupWindow.closed){if(this.x<0){this.x=0}if(this.y<0){this.y=0}if(screen&&screen.availHeight){if((this.y+this.height)>screen.availHeight){this.y=screen.availHeight-this.height}}if(screen&&screen.availWidth){if((this.x+this.width)>screen.availWidth){this.x=screen.availWidth-this.width}}var b=window.opera||(document.layers&&!navigator.mimeTypes["*"])||navigator.vendor=="KDE"||(document.childNodes&&!document.all&&!navigator.taintEnabled);this.popupWindow=window.open(b?"":"about:blank","window_"+a,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"")}this.refresh()}}function PopupWindow_hidePopup(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.visibility="hidden"}else{if(this.use_css){document.all[this.divName].style.visibility="hidden"}else{if(this.use_layers){document.layers[this.divName].visibility="hidden"}}}}else{if(this.popupWindow&&!this.popupWindow.closed){this.popupWindow.close();this.popupWindow=null}}}function PopupWindow_isClicked(c){if(this.divName!=null){if(this.use_layers){var d=c.pageX;var b=c.pageY;var a=document.layers[this.divName];if((d>a.left)&&(d<a.left+a.clip.width)&&(b>a.top)&&(b<a.top+a.clip.height)){return true}else{return false}}else{if(document.all){var a=window.event.srcElement;while(a.parentElement!=null){if(a.id==this.divName){return true}a=a.parentElement}return false}else{if(this.use_gebi&&c){var a=c.originalTarget;while(a.parentNode!=null){if(a.id==this.divName){return true}a=a.parentNode}return false}}}return false}return false}function PopupWindow_hideIfNotClicked(a){if(this.autoHideEnabled&&!this.isClicked(a)){this.hidePopup()}}function PopupWindow_autoHide(){this.autoHideEnabled=true}function PopupWindow_hidePopupWindows(c){for(var a=0;a<popupWindowObjects.length;a++){if(popupWindowObjects[a]!=null){var b=popupWindowObjects[a];b.hideIfNotClicked(c)}}}function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP)}window.popupWindowOldEventListener=document.onmouseup;if(window.popupWindowOldEventListener!=null){document.onmouseup=new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();")}else{document.onmouseup=PopupWindow_hidePopupWindows}}function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex=0}if(!window.popupWindowObjects){window.popupWindowObjects=new Array()}if(!window.listenerAttached){window.listenerAttached=true;PopupWindow_attachListener()}this.index=popupWindowIndex++;popupWindowObjects[this.index]=this;this.divName=null;this.popupWindow=null;this.width=0;this.height=0;this.populated=false;this.visible=false;this.autoHideEnabled=false;this.contents="";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName=arguments[0]}else{this.type="WINDOW"}this.use_gebi=false;this.use_css=false;this.use_layers=false;if(document.getElementById){this.use_gebi=true}else{if(document.all){this.use_css=true}else{if(document.layers){this.use_layers=true}else{this.type="WINDOW"}}}this.offsetX=0;this.offsetY=0;this.getXYPosition=PopupWindow_getXYPosition;this.populate=PopupWindow_populate;this.setUrl=PopupWindow_setUrl;this.setWindowProperties=PopupWindow_setWindowProperties;this.refresh=PopupWindow_refresh;this.showPopup=PopupWindow_showPopup;this.hidePopup=PopupWindow_hidePopup;this.setSize=PopupWindow_setSize;this.isClicked=PopupWindow_isClicked;this.autoHide=PopupWindow_autoHide;this.hideIfNotClicked=PopupWindow_hideIfNotClicked}ColorPicker_targetInput=null;function ColorPicker_writeDiv(){document.writeln('<DIV ID="colorPickerDiv" STYLE="position:absolute;visibility:hidden;"> </DIV>')}function ColorPicker_show(a){this.showPopup(a)}function ColorPicker_pickColor(a,b){b.hidePopup();pickColor(a)}function pickColor(a){if(ColorPicker_targetInput==null){alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");return}ColorPicker_targetInput.value=a}function ColorPicker_select(b,a){if(b.type!="text"&&b.type!="hidden"&&b.type!="textarea"){alert("colorpicker.select: Input object passed is not a valid form input object");window.ColorPicker_targetInput=null;return}window.ColorPicker_targetInput=b;this.show(a)}function ColorPicker_highlightColor(e){var a=(arguments.length>1)?arguments[1]:window.document;var b=a.getElementById("colorPickerSelectedColor");b.style.backgroundColor=e;b=a.getElementById("colorPickerSelectedColorValue");b.innerHTML=e}function ColorPicker(){var g=false;if(arguments.length==0){var e="colorPickerDiv"}else{if(arguments[0]=="window"){var e="";g=true}else{var e=arguments[0]}}if(e!=""){var m=new PopupWindow(e)}else{var m=new PopupWindow();m.setSize(225,250)}m.currentValue="#FFFFFF";m.writeDiv=ColorPicker_writeDiv;m.highlightColor=ColorPicker_highlightColor;m.show=ColorPicker_show;m.select=ColorPicker_select;var a=new Array("#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099","#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099","#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF","#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F","#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000","#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399","#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399","#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF","#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F","#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00","#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699","#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699","#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699","#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F","#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F","#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F","#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999","#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999","#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999","#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF","#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F","#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000","#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99","#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99","#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF","#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F","#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00","#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99","#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99","#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99","#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F","#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F","#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F","#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666","#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000","#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000","#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999","#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF","#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66","#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00","#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000","#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099","#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF","#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF","#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC","#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000","#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900","#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33","#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF","#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF","#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F","#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F","#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F","#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000");var n=a.length;var c=72;var k="";var j=(g)?"window.opener.":"";if(g){k+="<html><head><title>Select Color</title></head>";k+="<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>"}k+="<table style='border: none;' cellspacing=0 cellpadding=0>";var l=(document.getElementById||document.all)?true:false;for(var h=0;h<n;h++){if((h%c)==0){k+="<tr>"}if(l){var f='onMouseOver="'+j+"ColorPicker_highlightColor('"+a[h]+"',window.document)\""}else{f=""}k+='<td style="background-color: '+a[h]+';"><a href="javascript:void()" onclick="'+j+"ColorPicker_pickColor('"+a[h]+"',"+j+"window.popupWindowObjects["+m.index+']);return false;" '+f+">&nbsp;</a></td>";if(((h+1)>=n)||(((h+1)%c)==0)){k+="</tr>"}}if(document.getElementById){var d=Math.floor(c/2);var b=c=d;k+="<tr><td colspan='"+d+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+b+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>"}k+="</table>";if(g){k+="</span></body></html>"}m.populate(k+"\n");m.offsetY=25;m.autoHide();return m};
  • trunk/wp-includes/js/comment-reply.js

    r10169 r10291  
    1 
    2 addComment = {
    3     moveForm : function(commId, parentId, respondId, postId) {
    4         var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
    5 
    6         if ( ! comm || ! respond || ! cancel || ! parent )
    7             return;
    8 
    9         t.respondId = respondId;
    10         postId = postId || false;
    11 
    12         if ( ! t.I('wp-temp-form-div') ) {
    13             div = document.createElement('div');
    14             div.id = 'wp-temp-form-div';
    15             div.style.display = 'none';
    16             respond.parentNode.insertBefore(div, respond);
    17         }
    18 
    19         comm.parentNode.insertBefore(respond, comm.nextSibling);
    20         if ( post && postId )
    21             post.value = postId;
    22         parent.value = parentId;
    23         cancel.style.display = '';
    24 
    25         cancel.onclick = function() {
    26             var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
    27 
    28             if ( ! temp || ! respond )
    29                 return;
    30 
    31             t.I('comment_parent').value = '0';
    32             temp.parentNode.insertBefore(respond, temp);
    33             temp.parentNode.removeChild(temp);
    34             this.style.display = 'none';
    35             this.onclick = null;
    36             return false;
    37         }
    38 
    39         try { t.I('comment').focus(); }
    40         catch(e) {}
    41 
    42         return false;
    43     },
    44 
    45     I : function(e) {
    46         return document.getElementById(e);
    47     }
    48 }
     1addComment={moveForm:function(d,f,i,c){var m=this,a,h=m.I(d),b=m.I(i),l=m.I("cancel-comment-reply-link"),j=m.I("comment_parent"),k=m.I("comment_post_ID");if(!h||!b||!l||!j){return}m.respondId=i;c=c||false;if(!m.I("wp-temp-form-div")){a=document.createElement("div");a.id="wp-temp-form-div";a.style.display="none";b.parentNode.insertBefore(a,b)}h.parentNode.insertBefore(b,h.nextSibling);if(k&&c){k.value=c}j.value=f;l.style.display="";l.onclick=function(){var n=addComment,e=n.I("wp-temp-form-div"),o=n.I(n.respondId);if(!e||!o){return}n.I("comment_parent").value="0";e.parentNode.insertBefore(o,e);e.parentNode.removeChild(e);this.style.display="none";this.onclick=null;return false};try{m.I("comment").focus()}catch(g){}return false},I:function(a){return document.getElementById(a)}};
  • trunk/wp-includes/js/hoverIntent.js

    r9578 r10291  
    1 /**
    2 * hoverIntent is similar to jQuery's built-in "hover" function except that
    3 * instead of firing the onMouseOver event immediately, hoverIntent checks
    4 * to see if the user's mouse has slowed down (beneath the sensitivity
    5 * threshold) before firing the onMouseOver event.
    6 *
    7 * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
    8 * <http://cherne.net/brian/resources/jquery.hoverIntent.html>
    9 *
    10 * hoverIntent is currently available for use in all personal or commercial
    11 * projects under both MIT and GPL licenses. This means that you can choose
    12 * the license that best suits your project, and use it accordingly.
    13 *
    14 * // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
    15 * $("ul li").hoverIntent( showNav , hideNav );
    16 *
    17 * // advanced usage receives configuration object only
    18 * $("ul li").hoverIntent({
    19 *   sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
    20 *   interval: 100,   // number = milliseconds of polling interval
    21 *   over: showNav,  // function = onMouseOver callback (required)
    22 *   timeout: 0,   // number = milliseconds delay before onMouseOut function call
    23 *   out: hideNav    // function = onMouseOut callback (required)
    24 * });
    25 *
    26 * @param  f  onMouseOver function || An object with configuration options
    27 * @param  g  onMouseOut function  || Nothing (use configuration options object)
    28 * @author    Brian Cherne <brian@cherne.net>
    29 */
    30 (function($) {
    31     $.fn.hoverIntent = function(f,g) {
    32         // default configuration options
    33         var cfg = {
    34             sensitivity: 7,
    35             interval: 100,
    36             timeout: 0
    37         };
    38         // override configuration options with user supplied object
    39         cfg = $.extend(cfg, g ? { over: f, out: g } : f );
    40 
    41         // instantiate variables
    42         // cX, cY = current X and Y position of mouse, updated by mousemove event
    43         // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
    44         var cX, cY, pX, pY;
    45 
    46         // A private function for getting mouse position
    47         var track = function(ev) {
    48             cX = ev.pageX;
    49             cY = ev.pageY;
    50         };
    51 
    52         // A private function for comparing current and previous mouse position
    53         var compare = function(ev,ob) {
    54             ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
    55             // compare mouse positions to see if they've crossed the threshold
    56             if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
    57                 $(ob).unbind("mousemove",track);
    58                 // set hoverIntent state to true (so mouseOut can be called)
    59                 ob.hoverIntent_s = 1;
    60                 return cfg.over.apply(ob,[ev]);
    61             } else {
    62                 // set previous coordinates for next time
    63                 pX = cX; pY = cY;
    64                 // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
    65                 ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
    66             }
    67         };
    68 
    69         // A private function for delaying the mouseOut function
    70         var delay = function(ev,ob) {
    71             ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
    72             ob.hoverIntent_s = 0;
    73             return cfg.out.apply(ob,[ev]);
    74         };
    75        
    76         // workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text"
    77         var handleHover = function(e) {
    78             var t = this;
    79            
    80             // next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
    81             var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
    82             while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
    83             if ( p == this ) {
    84                 if ( $.browser.mozilla ) {
    85                     if ( e.type == "mouseout" ) {
    86                         t.mtout = setTimeout( function(){doHover(e,t);}, 30 );
    87                     } else {
    88                         if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
    89                     }
    90                 }
    91                 return;
    92             } else {
    93                 if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
    94                 doHover(e,t);
    95             }
    96         };
    97 
    98         // A private function for handling mouse 'hovering'
    99         var doHover = function(e,ob) {
    100 
    101             // copy objects to be passed into t (required for event object to be passed in IE)
    102             var ev = jQuery.extend({},e);
    103 
    104             // cancel hoverIntent timer if it exists
    105             if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
    106 
    107             // else e.type == "onmouseover"
    108             if (e.type == "mouseover") {
    109                 // set "previous" X and Y position based on initial entry point
    110                 pX = ev.pageX; pY = ev.pageY;
    111                 // update "current" X and Y position based on mousemove
    112                 $(ob).bind("mousemove",track);
    113                 // start polling interval (self-calling timeout) to compare mouse coordinates over time
    114                 if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
    115 
    116             // else e.type == "onmouseout"
    117             } else {
    118                 // unbind expensive mousemove event
    119                 $(ob).unbind("mousemove",track);
    120                 // if hoverIntent state is true, then call the mouseOut function after the specified delay
    121                 if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
    122             }
    123         };
    124 
    125         // bind the function to the two event listeners
    126         return this.mouseover(handleHover).mouseout(handleHover);
    127     };
    128 })(jQuery);
     1(function(a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery);
  • trunk/wp-includes/js/jquery/jquery.color.js

    r7131 r10291  
    1 /*
    2  * jQuery Color Animations
    3  * Copyright 2007 John Resig
    4  * Released under the MIT and GPL licenses.
    5  */
    6 
    7 (function(jQuery){
    8 
    9     // We override the animation for all of these color styles
    10     jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
    11         jQuery.fx.step[attr] = function(fx){
    12             if ( fx.state == 0 ) {
    13                 fx.start = getColor( fx.elem, attr );
    14                 fx.end = getRGB( fx.end );
    15             }
    16 
    17             fx.elem.style[attr] = "rgb(" + [
    18                 Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
    19                 Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
    20                 Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
    21             ].join(",") + ")";
    22         }
    23     });
    24 
    25     // Color Conversion functions from highlightFade
    26     // By Blair Mitchelmore
    27     // http://jquery.offput.ca/highlightFade/
    28 
    29     // Parse strings looking for color tuples [255,255,255]
    30     function getRGB(color) {
    31         var result;
    32 
    33         // Check if we're already dealing with an array of colors
    34         if ( color && color.constructor == Array && color.length == 3 )
    35             return color;
    36 
    37         // Look for rgb(num,num,num)
    38         if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
    39             return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
    40 
    41         // Look for rgb(num%,num%,num%)
    42         if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
    43             return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
    44 
    45         // Look for #a0b1c2
    46         if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
    47             return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
    48 
    49         // Look for #fff
    50         if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
    51             return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
    52 
    53         // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
    54         if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
    55             return colors['transparent']
    56 
    57         // Otherwise, we're most likely dealing with a named color
    58         return colors[jQuery.trim(color).toLowerCase()];
    59     }
    60 
    61     function getColor(elem, attr) {
    62         var color;
    63 
    64         do {
    65             color = jQuery.curCSS(elem, attr);
    66 
    67             // Keep going until we find an element that has color, or we hit the body
    68             if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
    69                 break;
    70 
    71             attr = "backgroundColor";
    72         } while ( elem = elem.parentNode );
    73 
    74         return getRGB(color);
    75     };
    76 
    77     // Some named colors to work with
    78     // From Interface by Stefan Petre
    79     // http://interface.eyecon.ro/
    80 
    81     var colors = {
    82         aqua:[0,255,255],
    83         azure:[240,255,255],
    84         beige:[245,245,220],
    85         black:[0,0,0],
    86         blue:[0,0,255],
    87         brown:[165,42,42],
    88         cyan:[0,255,255],
    89         darkblue:[0,0,139],
    90         darkcyan:[0,139,139],
    91         darkgrey:[169,169,169],
    92         darkgreen:[0,100,0],
    93         darkkhaki:[189,183,107],
    94         darkmagenta:[139,0,139],
    95         darkolivegreen:[85,107,47],
    96         darkorange:[255,140,0],
    97         darkorchid:[153,50,204],
    98         darkred:[139,0,0],
    99         darksalmon:[233,150,122],
    100         darkviolet:[148,0,211],
    101         fuchsia:[255,0,255],
    102         gold:[255,215,0],
    103         green:[0,128,0],
    104         indigo:[75,0,130],
    105         khaki:[240,230,140],
    106         lightblue:[173,216,230],
    107         lightcyan:[224,255,255],
    108         lightgreen:[144,238,144],
    109         lightgrey:[211,211,211],
    110         lightpink:[255,182,193],
    111         lightyellow:[255,255,224],
    112         lime:[0,255,0],
    113         magenta:[255,0,255],
    114         maroon:[128,0,0],
    115         navy:[0,0,128],
    116         olive:[128,128,0],
    117         orange:[255,165,0],
    118         pink:[255,192,203],
    119         purple:[128,0,128],
    120         violet:[128,0,128],
    121         red:[255,0,0],
    122         silver:[192,192,192],
    123         white:[255,255,255],
    124         yellow:[255,255,0],
    125         transparent: [255,255,255]
    126     };
    127 
    128 })(jQuery);
     1(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(g.state==0){g.start=c(g.elem,e);g.end=b(g.end)}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);
  • trunk/wp-includes/js/jquery/jquery.form.js

    r7131 r10291  
    1 /*
    2  * jQuery Form Plugin
    3  * version: 2.02 (12/16/2007)
    4  * @requires jQuery v1.1 or later
    5  *
    6  * Examples at: http://malsup.com/jquery/form/
    7  * Dual licensed under the MIT and GPL licenses:
    8  *   http://www.opensource.org/licenses/mit-license.php
    9  *   http://www.gnu.org/licenses/gpl.html
    10  *
    11  * Revision: $Id$
    12  */
    13  (function($) {
    14 /**
    15  * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
    16  *
    17  * ajaxSubmit accepts a single argument which can be either a success callback function
    18  * or an options Object.  If a function is provided it will be invoked upon successful
    19  * completion of the submit and will be passed the response from the server.
    20  * If an options Object is provided, the following attributes are supported:
    21  *
    22  *  target:   Identifies the element(s) in the page to be updated with the server response.
    23  *            This value may be specified as a jQuery selection string, a jQuery object,
    24  *            or a DOM element.
    25  *            default value: null
    26  *
    27  *  url:      URL to which the form data will be submitted.
    28  *            default value: value of form's 'action' attribute
    29  *
    30  *  type:     The method in which the form data should be submitted, 'GET' or 'POST'.
    31  *            default value: value of form's 'method' attribute (or 'GET' if none found)
    32  *
    33  *  data:     Additional data to add to the request, specified as key/value pairs (see $.ajax).
    34  *
    35  *  beforeSubmit:  Callback method to be invoked before the form is submitted.
    36  *            default value: null
    37  *
    38  *  success:  Callback method to be invoked after the form has been successfully submitted
    39  *            and the response has been returned from the server
    40  *            default value: null
    41  *
    42  *  dataType: Expected dataType of the response.  One of: null, 'xml', 'script', or 'json'
    43  *            default value: null
    44  *
    45  *  semantic: Boolean flag indicating whether data must be submitted in semantic order (slower).
    46  *            default value: false
    47  *
    48  *  resetForm: Boolean flag indicating whether the form should be reset if the submit is successful
    49  *
    50  *  clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful
    51  *
    52  *
    53  * The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for
    54  * validating the form data.  If the 'beforeSubmit' callback returns false then the form will
    55  * not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data
    56  * in array format, the jQuery object, and the options object passed into ajaxSubmit.
    57  * The form data array takes the following form:
    58  *
    59  *     [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
    60  *
    61  * If a 'success' callback method is provided it is invoked after the response has been returned
    62  * from the server.  It is passed the responseText or responseXML value (depending on dataType).
    63  * See jQuery.ajax for further details.
    64  *
    65  *
    66  * The dataType option provides a means for specifying how the server response should be handled.
    67  * This maps directly to the jQuery.httpData method.  The following values are supported:
    68  *
    69  *      'xml':    if dataType == 'xml' the server response is treated as XML and the 'success'
    70  *                   callback method, if specified, will be passed the responseXML value
    71  *      'json':   if dataType == 'json' the server response will be evaluted and passed to
    72  *                   the 'success' callback, if specified
    73  *      'script': if dataType == 'script' the server response is evaluated in the global context
    74  *
    75  *
    76  * Note that it does not make sense to use both the 'target' and 'dataType' options.  If both
    77  * are provided the target will be ignored.
    78  *
    79  * The semantic argument can be used to force form serialization in semantic order.
    80  * This is normally true anyway, unless the form contains input elements of type='image'.
    81  * If your form must be submitted with name/value pairs in semantic order and your form
    82  * contains an input of type='image" then pass true for this arg, otherwise pass false
    83  * (or nothing) to avoid the overhead for this logic.
    84  *
    85  *
    86  * When used on its own, ajaxSubmit() is typically bound to a form's submit event like this:
    87  *
    88  * $("#form-id").submit(function() {
    89  *     $(this).ajaxSubmit(options);
    90  *     return false; // cancel conventional submit
    91  * });
    92  *
    93  * When using ajaxForm(), however, this is done for you.
    94  *
    95  * @example
    96  * $('#myForm').ajaxSubmit(function(data) {
    97  *     alert('Form submit succeeded! Server returned: ' + data);
    98  * });
    99  * @desc Submit form and alert server response
    100  *
    101  *
    102  * @example
    103  * var options = {
    104  *     target: '#myTargetDiv'
    105  * };
    106  * $('#myForm').ajaxSubmit(options);
    107  * @desc Submit form and update page element with server response
    108  *
    109  *
    110  * @example
    111  * var options = {
    112  *     success: function(responseText) {
    113  *         alert(responseText);
    114  *     }
    115  * };
    116  * $('#myForm').ajaxSubmit(options);
    117  * @desc Submit form and alert the server response
    118  *
    119  *
    120  * @example
    121  * var options = {
    122  *     beforeSubmit: function(formArray, jqForm) {
    123  *         if (formArray.length == 0) {
    124  *             alert('Please enter data.');
    125  *             return false;
    126  *         }
    127  *     }
    128  * };
    129  * $('#myForm').ajaxSubmit(options);
    130  * @desc Pre-submit validation which aborts the submit operation if form data is empty
    131  *
    132  *
    133  * @example
    134  * var options = {
    135  *     url: myJsonUrl.php,
    136  *     dataType: 'json',
    137  *     success: function(data) {
    138  *        // 'data' is an object representing the the evaluated json data
    139  *     }
    140  * };
    141  * $('#myForm').ajaxSubmit(options);
    142  * @desc json data returned and evaluated
    143  *
    144  *
    145  * @example
    146  * var options = {
    147  *     url: myXmlUrl.php,
    148  *     dataType: 'xml',
    149  *     success: function(responseXML) {
    150  *        // responseXML is XML document object
    151  *        var data = $('myElement', responseXML).text();
    152  *     }
    153  * };
    154  * $('#myForm').ajaxSubmit(options);
    155  * @desc XML data returned from server
    156  *
    157  *
    158  * @example
    159  * var options = {
    160  *     resetForm: true
    161  * };
    162  * $('#myForm').ajaxSubmit(options);
    163  * @desc submit form and reset it if successful
    164  *
    165  * @example
    166  * $('#myForm).submit(function() {
    167  *    $(this).ajaxSubmit();
    168  *    return false;
    169  * });
    170  * @desc Bind form's submit event to use ajaxSubmit
    171  *
    172  *
    173  * @name ajaxSubmit
    174  * @type jQuery
    175  * @param options  object literal containing options which control the form submission process
    176  * @cat Plugins/Form
    177  * @return jQuery
    178  */
    179 $.fn.ajaxSubmit = function(options) {
    180     if (typeof options == 'function')
    181         options = { success: options };
    182 
    183     options = $.extend({
    184         url:  this.attr('action') || window.location.toString(),
    185         type: this.attr('method') || 'GET'
    186     }, options || {});
    187 
    188     // hook for manipulating the form data before it is extracted;
    189     // convenient for use with rich editors like tinyMCE or FCKEditor
    190     var veto = {};
    191     $.event.trigger('form.pre.serialize', [this, options, veto]);
    192     if (veto.veto) return this;
    193 
    194     var a = this.formToArray(options.semantic);
    195     if (options.data) {
    196         for (var n in options.data)
    197             a.push( { name: n, value: options.data[n] } );
    198     }
    199 
    200     // give pre-submit callback an opportunity to abort the submit
    201     if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this;
    202 
    203     // fire vetoable 'validate' event
    204     $.event.trigger('form.submit.validate', [a, this, options, veto]);
    205     if (veto.veto) return this;
    206 
    207     var q = $.param(a);//.replace(/%20/g,'+');
    208 
    209     if (options.type.toUpperCase() == 'GET') {
    210         options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
    211         options.data = null;  // data is null for 'get'
    212     }
    213     else
    214         options.data = q; // data is the query string for 'post'
    215 
    216     var $form = this, callbacks = [];
    217     if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
    218     if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
    219 
    220     // perform a load on the target only if dataType is not provided
    221     if (!options.dataType && options.target) {
    222         var oldSuccess = options.success || function(){};
    223         callbacks.push(function(data) {
    224             if (this.evalScripts)
    225                 $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, arguments);
    226             else // jQuery v1.1.4
    227                 $(options.target).html(data).each(oldSuccess, arguments);
    228         });
    229     }
    230     else if (options.success)
    231         callbacks.push(options.success);
    232 
    233     options.success = function(data, status) {
    234         for (var i=0, max=callbacks.length; i < max; i++)
    235             callbacks[i](data, status, $form);
    236     };
    237 
    238     // are there files to upload?
    239     var files = $('input:file', this).fieldValue();
    240     var found = false;
    241     for (var j=0; j < files.length; j++)
    242         if (files[j])
    243             found = true;
    244 
    245     // options.iframe allows user to force iframe mode
    246    if (options.iframe || found) {
    247        // hack to fix Safari hang (thanks to Tim Molendijk for this)
    248        // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
    249        if ($.browser.safari && options.closeKeepAlive)
    250            $.get(options.closeKeepAlive, fileUpload);
    251        else
    252            fileUpload();
    253        }
    254    else
    255        $.ajax(options);
    256 
    257     // fire 'notify' event
    258     $.event.trigger('form.submit.notify', [this, options]);
    259     return this;
    260 
    261 
    262     // private function for handling file uploads (hat tip to YAHOO!)
    263     function fileUpload() {
    264         var form = $form[0];
    265         var opts = $.extend({}, $.ajaxSettings, options);
    266 
    267         var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++;
    268         var $io = $('<iframe id="' + id + '" name="' + id + '" />');
    269         var io = $io[0];
    270         var op8 = $.browser.opera && window.opera.version() < 9;
    271         if ($.browser.msie || op8) io.src = 'javascript:false;document.write("");';
    272         $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
    273 
    274         var xhr = { // mock object
    275             responseText: null,
    276             responseXML: null,
    277             status: 0,
    278             statusText: 'n/a',
    279             getAllResponseHeaders: function() {},
    280             getResponseHeader: function() {},
    281             setRequestHeader: function() {}
    282         };
    283 
    284         var g = opts.global;
    285         // trigger ajax global events so that activity/block indicators work like normal
    286         if (g && ! $.active++) $.event.trigger("ajaxStart");
    287         if (g) $.event.trigger("ajaxSend", [xhr, opts]);
    288 
    289         var cbInvoked = 0;
    290         var timedOut = 0;
    291 
    292         // take a breath so that pending repaints get some cpu time before the upload starts
    293         setTimeout(function() {
    294             // make sure form attrs are set
    295             var encAttr = form.encoding ? 'encoding' : 'enctype';
    296             var t = $form.attr('target');
    297             $form.attr({
    298                 target:   id,
    299                 method:  'POST',
    300                 action:   opts.url
    301             });
    302             form[encAttr] = 'multipart/form-data';
    303 
    304             // support timout
    305             if (opts.timeout)
    306                 setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
    307 
    308             // add iframe to doc and submit the form
    309             $io.appendTo('body');
    310             io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
    311             form.submit();
    312             $form.attr('target', t); // reset target
    313         }, 10);
    314 
    315         function cb() {
    316             if (cbInvoked++) return;
    317 
    318             io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
    319 
    320             var ok = true;
    321             try {
    322                 if (timedOut) throw 'timeout';
    323                 // extract the server response from the iframe
    324                 var data, doc;
    325                 doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
    326                 xhr.responseText = doc.body ? doc.body.innerHTML : null;
    327                 xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
    328 
    329                 if (opts.dataType == 'json' || opts.dataType == 'script') {
    330                     var ta = doc.getElementsByTagName('textarea')[0];
    331                     data = ta ? ta.value : xhr.responseText;
    332                     if (opts.dataType == 'json')
    333                         eval("data = " + data);
    334                     else
    335                         $.globalEval(data);
    336                 }
    337                 else if (opts.dataType == 'xml') {
    338                     data = xhr.responseXML;
    339                     if (!data && xhr.responseText != null)
    340                         data = toXml(xhr.responseText);
    341                 }
    342                 else {
    343                     data = xhr.responseText;
    344                 }
    345             }
    346             catch(e){
    347                 ok = false;
    348                 $.handleError(opts, xhr, 'error', e);
    349             }
    350 
    351             // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
    352             if (ok) {
    353                 opts.success(data, 'success');
    354                 if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
    355             }
    356             if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
    357             if (g && ! --$.active) $.event.trigger("ajaxStop");
    358             if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
    359 
    360             // clean up
    361             setTimeout(function() {
    362                 $io.remove();
    363                 xhr.responseXML = null;
    364             }, 100);
    365         };
    366 
    367         function toXml(s, doc) {
    368             if (window.ActiveXObject) {
    369                 doc = new ActiveXObject('Microsoft.XMLDOM');
    370                 doc.async = 'false';
    371                 doc.loadXML(s);
    372             }
    373             else
    374                 doc = (new DOMParser()).parseFromString(s, 'text/xml');
    375             return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
    376         };
    377     };
    378 };
    379 $.fn.ajaxSubmit.counter = 0; // used to create unique iframe ids
    380 
    381 /**
    382  * ajaxForm() provides a mechanism for fully automating form submission.
    383  *
    384  * The advantages of using this method instead of ajaxSubmit() are:
    385  *
    386  * 1: This method will include coordinates for <input type="image" /> elements (if the element
    387  *    is used to submit the form).
    388  * 2. This method will include the submit element's name/value data (for the element that was
    389  *    used to submit the form).
    390  * 3. This method binds the submit() method to the form for you.
    391  *
    392  * Note that for accurate x/y coordinates of image submit elements in all browsers
    393  * you need to also use the "dimensions" plugin (this method will auto-detect its presence).
    394  *
    395  * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
    396  * passes the options argument along after properly binding events for submit elements and
    397  * the form itself.  See ajaxSubmit for a full description of the options argument.
    398  *
    399  *
    400  * @example
    401  * var options = {
    402  *     target: '#myTargetDiv'
    403  * };
    404  * $('#myForm').ajaxSForm(options);
    405  * @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response
    406  *       when the form is submitted.
    407  *
    408  *
    409  * @example
    410  * var options = {
    411  *     success: function(responseText) {
    412  *         alert(responseText);
    413  *     }
    414  * };
    415  * $('#myForm').ajaxSubmit(options);
    416  * @desc Bind form's submit event so that server response is alerted after the form is submitted.
    417  *
    418  *
    419  * @example
    420  * var options = {
    421  *     beforeSubmit: function(formArray, jqForm) {
    422  *         if (formArray.length == 0) {
    423  *             alert('Please enter data.');
    424  *             return false;
    425  *         }
    426  *     }
    427  * };
    428  * $('#myForm').ajaxSubmit(options);
    429  * @desc Bind form's submit event so that pre-submit callback is invoked before the form
    430  *       is submitted.
    431  *
    432  *
    433  * @name   ajaxForm
    434  * @param  options  object literal containing options which control the form submission process
    435  * @return jQuery
    436  * @cat    Plugins/Form
    437  * @type   jQuery
    438  */
    439 $.fn.ajaxForm = function(options) {
    440     return this.ajaxFormUnbind().submit(submitHandler).each(function() {
    441         // store options in hash
    442         this.formPluginId = $.fn.ajaxForm.counter++;
    443         $.fn.ajaxForm.optionHash[this.formPluginId] = options;
    444         $(":submit,input:image", this).click(clickHandler);
    445     });
    446 };
    447 
    448 $.fn.ajaxForm.counter = 1;
    449 $.fn.ajaxForm.optionHash = {};
    450 
    451 function clickHandler(e) {
    452     var $form = this.form;
    453     $form.clk = this;
    454     if (this.type == 'image') {
    455         if (e.offsetX != undefined) {
    456             $form.clk_x = e.offsetX;
    457             $form.clk_y = e.offsetY;
    458         } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
    459             var offset = $(this).offset();
    460             $form.clk_x = e.pageX - offset.left;
    461             $form.clk_y = e.pageY - offset.top;
    462         } else {
    463             $form.clk_x = e.pageX - this.offsetLeft;
    464             $form.clk_y = e.pageY - this.offsetTop;
    465         }
    466     }
    467     // clear form vars
    468     setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null; }, 10);
    469 };
    470 
    471 function submitHandler() {
    472     // retrieve options from hash
    473     var id = this.formPluginId;
    474     var options = $.fn.ajaxForm.optionHash[id];
    475     $(this).ajaxSubmit(options);
    476     return false;
    477 };
    478 
    479 /**
    480  * ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
    481  *
    482  * @name   ajaxFormUnbind
    483  * @return jQuery
    484  * @cat    Plugins/Form
    485  * @type   jQuery
    486  */
    487 $.fn.ajaxFormUnbind = function() {
    488     this.unbind('submit', submitHandler);
    489     return this.each(function() {
    490         $(":submit,input:image", this).unbind('click', clickHandler);
    491     });
    492 
    493 };
    494 
    495 /**
    496  * formToArray() gathers form element data into an array of objects that can
    497  * be passed to any of the following ajax functions: $.get, $.post, or load.
    498  * Each object in the array has both a 'name' and 'value' property.  An example of
    499  * an array for a simple login form might be:
    500  *
    501  * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
    502  *
    503  * It is this array that is passed to pre-submit callback functions provided to the
    504  * ajaxSubmit() and ajaxForm() methods.
    505  *
    506  * The semantic argument can be used to force form serialization in semantic order.
    507  * This is normally true anyway, unless the form contains input elements of type='image'.
    508  * If your form must be submitted with name/value pairs in semantic order and your form
    509  * contains an input of type='image" then pass true for this arg, otherwise pass false
    510  * (or nothing) to avoid the overhead for this logic.
    511  *
    512  * @example var data = $("#myForm").formToArray();
    513  * $.post( "myscript.cgi", data );
    514  * @desc Collect all the data from a form and submit it to the server.
    515  *
    516  * @name formToArray
    517  * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
    518  * @type Array<Object>
    519  * @cat Plugins/Form
    520  */
    521 $.fn.formToArray = function(semantic) {
    522     var a = [];
    523     if (this.length == 0) return a;
    524 
    525     var form = this[0];
    526     var els = semantic ? form.getElementsByTagName('*') : form.elements;
    527     if (!els) return a;
    528     for(var i=0, max=els.length; i < max; i++) {
    529         var el = els[i];
    530         var n = el.name;
    531         if (!n) continue;
    532 
    533         if (semantic && form.clk && el.type == "image") {
    534             // handle image inputs on the fly when semantic == true
    535             if(!el.disabled && form.clk == el)
    536                 a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
    537             continue;
    538         }
    539 
    540         var v = $.fieldValue(el, true);
    541         if (v && v.constructor == Array) {
    542             for(var j=0, jmax=v.length; j < jmax; j++)
    543                 a.push({name: n, value: v[j]});
    544         }
    545         else if (v !== null && typeof v != 'undefined')
    546             a.push({name: n, value: v});
    547     }
    548 
    549     if (!semantic && form.clk) {
    550         // input type=='image' are not found in elements array! handle them here
    551         var inputs = form.getElementsByTagName("input");
    552         for(var i=0, max=inputs.length; i < max; i++) {
    553             var input = inputs[i];
    554             var n = input.name;
    555             if(n && !input.disabled && input.type == "image" && form.clk == input)
    556                 a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
    557         }
    558     }
    559     return a;
    560 };
    561 
    562 
    563 /**
    564  * Serializes form data into a 'submittable' string. This method will return a string
    565  * in the format: name1=value1&amp;name2=value2
    566  *
    567  * The semantic argument can be used to force form serialization in semantic order.
    568  * If your form must be submitted with name/value pairs in semantic order then pass
    569  * true for this arg, otherwise pass false (or nothing) to avoid the overhead for
    570  * this logic (which can be significant for very large forms).
    571  *
    572  * @example var data = $("#myForm").formSerialize();
    573  * $.ajax('POST', "myscript.cgi", data);
    574  * @desc Collect all the data from a form into a single string
    575  *
    576  * @name formSerialize
    577  * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
    578  * @type String
    579  * @cat Plugins/Form
    580  */
    581 $.fn.formSerialize = function(semantic) {
    582     //hand off to jQuery.param for proper encoding
    583     return $.param(this.formToArray(semantic));
    584 };
    585 
    586 
    587 /**
    588  * Serializes all field elements in the jQuery object into a query string.
    589  * This method will return a string in the format: name1=value1&amp;name2=value2
    590  *
    591  * The successful argument controls whether or not serialization is limited to
    592  * 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
    593  * The default value of the successful argument is true.
    594  *
    595  * @example var data = $("input").formSerialize();
    596  * @desc Collect the data from all successful input elements into a query string
    597  *
    598  * @example var data = $(":radio").formSerialize();
    599  * @desc Collect the data from all successful radio input elements into a query string
    600  *
    601  * @example var data = $("#myForm :checkbox").formSerialize();
    602  * @desc Collect the data from all successful checkbox input elements in myForm into a query string
    603  *
    604  * @example var data = $("#myForm :checkbox").formSerialize(false);
    605  * @desc Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string
    606  *
    607  * @example var data = $(":input").formSerialize();
    608  * @desc Collect the data from all successful input, select, textarea and button elements into a query string
    609  *
    610  * @name fieldSerialize
    611  * @param successful true if only successful controls should be serialized (default is true)
    612  * @type String
    613  * @cat Plugins/Form
    614  */
    615 $.fn.fieldSerialize = function(successful) {
    616     var a = [];
    617     this.each(function() {
    618         var n = this.name;
    619         if (!n) return;
    620         var v = $.fieldValue(this, successful);
    621         if (v && v.constructor == Array) {
    622             for (var i=0,max=v.length; i < max; i++)
    623                 a.push({name: n, value: v[i]});
    624         }
    625         else if (v !== null && typeof v != 'undefined')
    626             a.push({name: this.name, value: v});
    627     });
    628     //hand off to jQuery.param for proper encoding
    629     return $.param(a);
    630 };
    631 
    632 
    633 /**
    634  * Returns the value(s) of the element in the matched set.  For example, consider the following form:
    635  *
    636  *  <form><fieldset>
    637  *      <input name="A" type="text" />
    638  *      <input name="A" type="text" />
    639  *      <input name="B" type="checkbox" value="B1" />
    640  *      <input name="B" type="checkbox" value="B2"/>
    641  *      <input name="C" type="radio" value="C1" />
    642  *      <input name="C" type="radio" value="C2" />
    643  *  </fieldset></form>
    644  *
    645  *  var v = $(':text').fieldValue();
    646  *  // if no values are entered into the text inputs
    647  *  v == ['','']
    648  *  // if values entered into the text inputs are 'foo' and 'bar'
    649  *  v == ['foo','bar']
    650  *
    651  *  var v = $(':checkbox').fieldValue();
    652  *  // if neither checkbox is checked
    653  *  v === undefined
    654  *  // if both checkboxes are checked
    655  *  v == ['B1', 'B2']
    656  *
    657  *  var v = $(':radio').fieldValue();
    658  *  // if neither radio is checked
    659  *  v === undefined
    660  *  // if first radio is checked
    661  *  v == ['C1']
    662  *
    663  * The successful argument controls whether or not the field element must be 'successful'
    664  * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
    665  * The default value of the successful argument is true.  If this value is false the value(s)
    666  * for each element is returned.
    667  *
    668  * Note: This method *always* returns an array.  If no valid value can be determined the
    669  *       array will be empty, otherwise it will contain one or more values.
    670  *
    671  * @example var data = $("#myPasswordElement").fieldValue();
    672  * alert(data[0]);
    673  * @desc Alerts the current value of the myPasswordElement element
    674  *
    675  * @example var data = $("#myForm :input").fieldValue();
    676  * @desc Get the value(s) of the form elements in myForm
    677  *
    678  * @example var data = $("#myForm :checkbox").fieldValue();
    679  * @desc Get the value(s) for the successful checkbox element(s) in the jQuery object.
    680  *
    681  * @example var data = $("#mySingleSelect").fieldValue();
    682  * @desc Get the value(s) of the select control
    683  *
    684  * @example var data = $(':text').fieldValue();
    685  * @desc Get the value(s) of the text input or textarea elements
    686  *
    687  * @example var data = $("#myMultiSelect").fieldValue();
    688  * @desc Get the values for the select-multiple control
    689  *
    690  * @name fieldValue
    691  * @param Boolean successful true if only the values for successful controls should be returned (default is true)
    692  * @type Array<String>
    693  * @cat Plugins/Form
    694  */
    695 $.fn.fieldValue = function(successful) {
    696     for (var val=[], i=0, max=this.length; i < max; i++) {
    697         var el = this[i];
    698         var v = $.fieldValue(el, successful);
    699         if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
    700             continue;
    701         v.constructor == Array ? $.merge(val, v) : val.push(v);
    702     }
    703     return val;
    704 };
    705 
    706 /**
    707  * Returns the value of the field element.
    708  *
    709  * The successful argument controls whether or not the field element must be 'successful'
    710  * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
    711  * The default value of the successful argument is true.  If the given element is not
    712  * successful and the successful arg is not false then the returned value will be null.
    713  *
    714  * Note: If the successful flag is true (default) but the element is not successful, the return will be null
    715  * Note: The value returned for a successful select-multiple element will always be an array.
    716  * Note: If the element has no value the return value will be undefined.
    717  *
    718  * @example var data = jQuery.fieldValue($("#myPasswordElement")[0]);
    719  * @desc Gets the current value of the myPasswordElement element
    720  *
    721  * @name fieldValue
    722  * @param Element el The DOM element for which the value will be returned
    723  * @param Boolean successful true if value returned must be for a successful controls (default is true)
    724  * @type String or Array<String> or null or undefined
    725  * @cat Plugins/Form
    726  */
    727 $.fieldValue = function(el, successful) {
    728     var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
    729     if (typeof successful == 'undefined') successful = true;
    730 
    731     if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
    732         (t == 'checkbox' || t == 'radio') && !el.checked ||
    733         (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
    734         tag == 'select' && el.selectedIndex == -1))
    735             return null;
    736 
    737     if (tag == 'select') {
    738         var index = el.selectedIndex;
    739         if (index < 0) return null;
    740         var a = [], ops = el.options;
    741         var one = (t == 'select-one');
    742         var max = (one ? index+1 : ops.length);
    743         for(var i=(one ? index : 0); i < max; i++) {
    744             var op = ops[i];
    745             if (op.selected) {
    746                 // extra pain for IE...
    747                 var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
    748                 if (one) return v;
    749                 a.push(v);
    750             }
    751         }
    752         return a;
    753     }
    754     return el.value;
    755 };
    756 
    757 
    758 /**
    759  * Clears the form data.  Takes the following actions on the form's input fields:
    760  *  - input text fields will have their 'value' property set to the empty string
    761  *  - select elements will have their 'selectedIndex' property set to -1
    762  *  - checkbox and radio inputs will have their 'checked' property set to false
    763  *  - inputs of type submit, button, reset, and hidden will *not* be effected
    764  *  - button elements will *not* be effected
    765  *
    766  * @example $('form').clearForm();
    767  * @desc Clears all forms on the page.
    768  *
    769  * @name clearForm
    770  * @type jQuery
    771  * @cat Plugins/Form
    772  */
    773 $.fn.clearForm = function() {
    774     return this.each(function() {
    775         $('input,select,textarea', this).clearFields();
    776     });
    777 };
    778 
    779 /**
    780  * Clears the selected form elements.  Takes the following actions on the matched elements:
    781  *  - input text fields will have their 'value' property set to the empty string
    782  *  - select elements will have their 'selectedIndex' property set to -1
    783  *  - checkbox and radio inputs will have their 'checked' property set to false
    784  *  - inputs of type submit, button, reset, and hidden will *not* be effected
    785  *  - button elements will *not* be effected
    786  *
    787  * @example $('.myInputs').clearFields();
    788  * @desc Clears all inputs with class myInputs
    789  *
    790  * @name clearFields
    791  * @type jQuery
    792  * @cat Plugins/Form
    793  */
    794 $.fn.clearFields = $.fn.clearInputs = function() {
    795     return this.each(function() {
    796         var t = this.type, tag = this.tagName.toLowerCase();
    797         if (t == 'text' || t == 'password' || tag == 'textarea')
    798             this.value = '';
    799         else if (t == 'checkbox' || t == 'radio')
    800             this.checked = false;
    801         else if (tag == 'select')
    802             this.selectedIndex = -1;
    803     });
    804 };
    805 
    806 
    807 /**
    808  * Resets the form data.  Causes all form elements to be reset to their original value.
    809  *
    810  * @example $('form').resetForm();
    811  * @desc Resets all forms on the page.
    812  *
    813  * @name resetForm
    814  * @type jQuery
    815  * @cat Plugins/Form
    816  */
    817 $.fn.resetForm = function() {
    818     return this.each(function() {
    819         // guard against an input with the name of 'reset'
    820         // note that IE reports the reset function as an 'object'
    821         if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
    822             this.reset();
    823     });
    824 };
    825 
    826 
    827 /**
    828  * Enables or disables any matching elements.
    829  *
    830  * @example $(':radio').enabled(false);
    831  * @desc Disables all radio buttons
    832  *
    833  * @name select
    834  * @type jQuery
    835  * @cat Plugins/Form
    836  */
    837 $.fn.enable = function(b) {
    838     if (b == undefined) b = true;
    839     return this.each(function() {
    840         this.disabled = !b
    841     });
    842 };
    843 
    844 /**
    845  * Checks/unchecks any matching checkboxes or radio buttons and
    846  * selects/deselects and matching option elements.
    847  *
    848  * @example $(':checkbox').selected();
    849  * @desc Checks all checkboxes
    850  *
    851  * @name select
    852  * @type jQuery
    853  * @cat Plugins/Form
    854  */
    855 $.fn.select = function(select) {
    856     if (select == undefined) select = true;
    857     return this.each(function() {
    858         var t = this.type;
    859         if (t == 'checkbox' || t == 'radio')
    860             this.checked = select;
    861         else if (this.tagName.toLowerCase() == 'option') {
    862             var $sel = $(this).parent('select');
    863             if (select && $sel[0] && $sel[0].type == 'select-one') {
    864                 // deselect all other options
    865                 $sel.find('option').select(false);
    866             }
    867             this.selected = select;
    868         }
    869     });
    870 };
    871 
    872 })(jQuery);
     1(function($){$.fn.ajaxSubmit=function(options){if(typeof options=="function"){options={success:options}}options=$.extend({url:this.attr("action")||window.location.toString(),type:this.attr("method")||"GET"},options||{});var veto={};$.event.trigger("form.pre.serialize",[this,options,veto]);if(veto.veto){return this}var a=this.formToArray(options.semantic);if(options.data){for(var n in options.data){a.push({name:n,value:options.data[n]})}}if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){return this}$.event.trigger("form.submit.validate",[a,this,options,veto]);if(veto.veto){return this}var q=$.param(a);if(options.type.toUpperCase()=="GET"){options.url+=(options.url.indexOf("?")>=0?"&":"?")+q;options.data=null}else{options.data=q}var $form=this,callbacks=[];if(options.resetForm){callbacks.push(function(){$form.resetForm()})}if(options.clearForm){callbacks.push(function(){$form.clearForm()})}if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){if(this.evalScripts){$(options.target).attr("innerHTML",data).evalScripts().each(oldSuccess,arguments)}else{$(options.target).html(data).each(oldSuccess,arguments)}})}else{if(options.success){callbacks.push(options.success)}}options.success=function(data,status){for(var i=0,max=callbacks.length;i<max;i++){callbacks[i](data,status,$form)}};var files=$("input:file",this).fieldValue();var found=false;for(var j=0;j<files.length;j++){if(files[j]){found=true}}if(options.iframe||found){if($.browser.safari&&options.closeKeepAlive){$.get(options.closeKeepAlive,fileUpload)}else{fileUpload()}}else{$.ajax(options)}$.event.trigger("form.submit.notify",[this,options]);return this;function fileUpload(){var form=$form[0];var opts=$.extend({},$.ajaxSettings,options);var id="jqFormIO"+$.fn.ajaxSubmit.counter++;var $io=$('<iframe id="'+id+'" name="'+id+'" />');var io=$io[0];var op8=$.browser.opera&&window.opera.version()<9;if($.browser.msie||op8){io.src='javascript:false;document.write("");'}$io.css({position:"absolute",top:"-1000px",left:"-1000px"});var xhr={responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){}};var g=opts.global;if(g&&!$.active++){$.event.trigger("ajaxStart")}if(g){$.event.trigger("ajaxSend",[xhr,opts])}var cbInvoked=0;var timedOut=0;setTimeout(function(){var encAttr=form.encoding?"encoding":"enctype";var t=$form.attr("target");$form.attr({target:id,method:"POST",action:opts.url});form[encAttr]="multipart/form-data";if(opts.timeout){setTimeout(function(){timedOut=true;cb()},opts.timeout)}$io.appendTo("body");io.attachEvent?io.attachEvent("onload",cb):io.addEventListener("load",cb,false);form.submit();$form.attr("target",t)},10);function cb(){if(cbInvoked++){return}io.detachEvent?io.detachEvent("onload",cb):io.removeEventListener("load",cb,false);var ok=true;try{if(timedOut){throw"timeout"}var data,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;if(opts.dataType=="json"||opts.dataType=="script"){var ta=doc.getElementsByTagName("textarea")[0];data=ta?ta.value:xhr.responseText;if(opts.dataType=="json"){eval("data = "+data)}else{$.globalEval(data)}}else{if(opts.dataType=="xml"){data=xhr.responseXML;if(!data&&xhr.responseText!=null){data=toXml(xhr.responseText)}}else{data=xhr.responseText}}}catch(e){ok=false;$.handleError(opts,xhr,"error",e)}if(ok){opts.success(data,"success");if(g){$.event.trigger("ajaxSuccess",[xhr,opts])}}if(g){$.event.trigger("ajaxComplete",[xhr,opts])}if(g&&!--$.active){$.event.trigger("ajaxStop")}if(opts.complete){opts.complete(xhr,ok?"success":"error")}setTimeout(function(){$io.remove();xhr.responseXML=null},100)}function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(s)}else{doc=(new DOMParser()).parseFromString(s,"text/xml")}return(doc&&doc.documentElement&&doc.documentElement.tagName!="parsererror")?doc:null}}};$.fn.ajaxSubmit.counter=0;$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().submit(submitHandler).each(function(){this.formPluginId=$.fn.ajaxForm.counter++;$.fn.ajaxForm.optionHash[this.formPluginId]=options;$(":submit,input:image",this).click(clickHandler)})};$.fn.ajaxForm.counter=1;$.fn.ajaxForm.optionHash={};function clickHandler(e){var $form=this.form;$form.clk=this;if(this.type=="image"){if(e.offsetX!=undefi