diff --git a/wp-admin/js/cat.dev.js b/wp-admin/js/cat.dev.js new file mode 100644 index 000000000..7cbfe66b3 --- /dev/null +++ b/wp-admin/js/cat.dev.js @@ -0,0 +1,5 @@ +jQuery(document).ready( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; + $('#jaxcat').prepend('' + catL10n.how + '') + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); +} ); diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js index 4a64994ad..deee8c47e 100644 --- a/wp-admin/js/cat.js +++ b/wp-admin/js/cat.js @@ -1,5 +1 @@ -jQuery( function($) { - var myConfirm = function() { return '' !== $('#newcat').val(); }; - $('#jaxcat').prepend('' + catL10n.how + '') - $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); -} ); +jQuery(document).ready(function(b){var a=function(){return""!==b("#newcat").val()};b("#jaxcat").prepend(''+catL10n.how+'');b("#categorychecklist").wpList({alt:"",response:"cat-ajax-response",confirm:a})}); \ No newline at end of file diff --git a/wp-admin/js/categories.dev.js b/wp-admin/js/categories.dev.js new file mode 100644 index 000000000..f9a1724a4 --- /dev/null +++ b/wp-admin/js/categories.dev.js @@ -0,0 +1,39 @@ +jQuery(document).ready(function($) { + var options = false, addAfter, addAfter2, delAfter; + if ( document.forms['addcat'].category_parent ) + options = document.forms['addcat'].category_parent.options; + + addAfter = function( r, settings ) { + var name, id; + + name = $("" + $('name', r).text() + "").html(); + id = $('cat', r).attr('id'); + options[options.length] = new Option(name, id); + + addAfter2( r, settings ); + } + + addAfter2 = function( x, r ) { + var t = $(r.parsed.responses[0].data); + if ( t.length == 1 ) + inlineEditTax.addEvents($(t.id)); + } + + delAfter = function( r, settings ) { + var id = $('cat', r).attr('id'), o; + for ( o = 0; o < options.length; o++ ) + if ( id == options[o].value ) + options[o] = null; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList({ addAfter: addAfter2 }); + + if ( jQuery('#link-category-search-input').size() ) { + columns.init('edit-link-categories'); + } else { + columns.init('categories'); + } +}); diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js index fa23b226a..484a01c39 100644 --- a/wp-admin/js/categories.js +++ b/wp-admin/js/categories.js @@ -1,37 +1 @@ -jQuery(function($) { - var options = false - if ( document.forms['addcat'].category_parent ) - options = document.forms['addcat'].category_parent.options; - - var addAfter = function( r, settings ) { - var name = $("" + $('name', r).text() + "").html(); - var id = $('cat', r).attr('id'); - options[options.length] = new Option(name, id); - - addAfter2( r, settings ); - } - - var addAfter2 = function( x, r ) { - var t = $(r.parsed.responses[0].data); - if ( t.length == 1 ) - inlineEditTax.addEvents($(t.id)); - } - - var delAfter = function( r, settings ) { - var id = $('cat', r).attr('id'); - for ( var o = 0; o < options.length; o++ ) - if ( id == options[o].value ) - options[o] = null; - } - - if ( options ) - $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); - else - $('#the-list').wpList({ addAfter: addAfter2 }); - - if ( jQuery('#link-category-search-input').size() ) { - columns.init('edit-link-categories'); - } else { - columns.init('categories'); - } -}); +jQuery(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(""+c("name",h).text()+"").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' + + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + + $('#jj').val() + ', ' + + $('#aa').val() + ' @ ' + + $('#hh').val() + ':' + + $('#mn').val() + ' ' + ); + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index 1f15b5be3..ac65c92fa 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1,37 +1 @@ -jQuery(document).ready( function($) { - - var stamp = $('#timestamp').html(); - $('.edit-timestamp').click(function () { - if ($('#timestampdiv').is(":hidden")) { - $('#timestampdiv').slideDown("normal"); - $('.edit-timestamp').hide(); - } - return false; - }); - - $('.cancel-timestamp').click(function() { - $('#timestampdiv').slideUp("normal"); - $('#mm').val($('#hidden_mm').val()); - $('#jj').val($('#hidden_jj').val()); - $('#aa').val($('#hidden_aa').val()); - $('#hh').val($('#hidden_hh').val()); - $('#mn').val($('#hidden_mn').val()); - $('#timestamp').html(stamp); - $('.edit-timestamp').show(); - return false; - }); - - $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels - $('#timestampdiv').slideUp("normal"); - $('.edit-timestamp').show(); - $('#timestamp').html( - commentL10n.submittedOn + ' ' + - $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + - $('#jj').val() + ', ' + - $('#aa').val() + ' @ ' + - $('#hh').val() + ':' + - $('#mn').val() + ' ' - ); - return false; - }); -}); \ No newline at end of file +jQuery(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("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+" ");return false})}); \ No newline at end of file diff --git a/wp-admin/js/common.dev.js b/wp-admin/js/common.dev.js new file mode 100644 index 000000000..03fe415fe --- /dev/null +++ b/wp-admin/js/common.dev.js @@ -0,0 +1,391 @@ + +var wpCookies = { +// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL. + + each : function(o, cb, s) { + var n, l; + + if (!o) + return 0; + + s = s || o; + + if (typeof(o.length) != 'undefined') { + for (n=0, l = o.length; n H ) { + o = (t+h+10) - H; + m.css({'marginTop':'-'+o+'px'}); + } else if ( m.css('marginTop') ) { + m.css({'marginTop':''}) + } + m.addClass('sub-open'); + }, + out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); }, + timeout: 220, + sensitivity: 8, + interval: 100 + }); + + } + }, + + favorites : function() { + $('#favorite-inside').width($('#favorite-actions').width()-4); + $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } ); + + $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } ); + } +}; + +$(document).ready(function(){adminMenu.init();}); +})(jQuery); + +(function($){ +// show/hide/save table columns +columns = { + init : function(page) { + $('.hide-column-tog').click( function() { + var column = $(this).val(), show = $(this).attr('checked'); + if ( show ) { + $('.column-' + column).show(); + } else { + $('.column-' + column).hide(); + } + columns.save_manage_columns_state(page); + } ); + }, + + save_manage_columns_state : function(page) { + var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); + $.post('admin-ajax.php', { + action: 'hidden-columns', + hidden: hidden, + hiddencolumnsnonce: $('#hiddencolumnsnonce').val(), + page: page + }); + } +} + +})(jQuery); + + +jQuery(document).ready(function($){ + if ( 'undefined' != typeof google && google.gears ) return; + + var gf = false; + if ( 'undefined' != typeof GearsFactory ) { + gf = new GearsFactory(); + } else { + try { + gf = new ActiveXObject('Gears.Factory'); + if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 ) + gf.privateSetGlobalObject(this); + } catch (e) { + if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) { + gf = document.createElement("object"); + gf.style.display = "none"; + gf.width = 0; + gf.height = 0; + gf.type = "application/x-googlegears"; + document.documentElement.appendChild(gf); + } + } + } + if ( gf && gf.hasPermission ) + return; + + $('.turbo-nag').show(); +}); diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 94d5396a3..2932bda31 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -1,391 +1 @@ - -var wpCookies = { -// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL. - - each : function(o, cb, s) { - var n, l; - - if (!o) - return 0; - - s = s || o; - - if (typeof(o.length) != 'undefined') { - for (n=0, l = o.length; n H ) { - o = (t+h+10) - H; - m.css({'marginTop':'-'+o+'px'}); - } else if ( m.css('marginTop') ) { - m.css({'marginTop':''}) - } - m.addClass('sub-open'); - }, - out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); }, - timeout: 220, - sensitivity: 8, - interval: 100 - }); - - } - }, - - favorites : function() { - $('#favorite-inside').width($('#favorite-actions').width()-4); - $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } ); - - $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } ); - } -}; - -$(document).ready(function(){adminMenu.init();}); -})(jQuery); - -(function($){ -// show/hide/save table columns -columns = { - init : function(page) { - $('.hide-column-tog').click( function() { - var column = $(this).val(); - var show = $(this).attr('checked'); - if ( show ) { - $('.column-' + column).show(); - } else { - $('.column-' + column).hide(); - } - columns.save_manage_columns_state(page); - } ); - }, - - save_manage_columns_state : function(page) { - var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); - $.post('admin-ajax.php', { - action: 'hidden-columns', - hidden: hidden, - hiddencolumnsnonce: $('#hiddencolumnsnonce').val(), - page: page - }); - } -} - -})(jQuery); - - -jQuery(document).ready(function($){ - if ( 'undefined' != typeof google && google.gears ) return; - - var gf = false; - if ( 'undefined' != typeof GearsFactory ) { - gf = new GearsFactory(); - } else { - try { - gf = new ActiveXObject('Gears.Factory'); - if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 ) - gf.privateSetGlobalObject(this); - } catch (e) { - if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) { - gf = document.createElement("object"); - gf.style.display = "none"; - gf.width = 0; - gf.height = 0; - gf.type = "application/x-googlegears"; - document.documentElement.appendChild(gf); - } - } - } - if ( gf && gf.hasPermission ) - return; - - $('.turbo-nag').show(); -}); +var 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;ed){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()}); \ No newline at end of file diff --git a/wp-admin/js/custom-fields.dev.js b/wp-admin/js/custom-fields.dev.js new file mode 100644 index 000000000..888025992 --- /dev/null +++ b/wp-admin/js/custom-fields.dev.js @@ -0,0 +1,34 @@ +jQuery(document).ready( function($) { + var before, addBefore, addAfter, delBefore; + + before = function() { + var nonce = $('#newmeta [@name=_ajax_nonce]').val(), postId = $('#post_ID').val(); + if ( !nonce || !postId ) { return false; } + return [nonce,postId]; + } + + addBefore = function( s ) { + var b = before(); + if ( !b ) { return false; } + s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; + return s; + }; + + addAfter = function( r, s ) { + var postId = $('postid', r).text(), h; + if ( !postId ) { return; } + $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); + h = $('#hiddenaction'); + if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } + }; + + delBefore = function( s ) { + var b = before(); if ( !b ) return false; + s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; + return s; + } + + $('#the-list') + .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) + .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); +} ); diff --git a/wp-admin/js/custom-fields.js b/wp-admin/js/custom-fields.js index 8f2b1a59c..121b754a6 100644 --- a/wp-admin/js/custom-fields.js +++ b/wp-admin/js/custom-fields.js @@ -1,33 +1 @@ -jQuery( function($) { - var before = function() { - var nonce = $('#newmeta [@name=_ajax_nonce]').val(); - var postId = $('#post_ID').val(); - if ( !nonce || !postId ) { return false; } - return [nonce,postId]; - } - - var addBefore = function( s ) { - var b = before(); - if ( !b ) { return false; } - s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; - return s; - }; - - var addAfter = function( r, s ) { - var postId = $('postid', r).text(); - if ( !postId ) { return; } - $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); - var h = $('#hiddenaction'); - if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } - }; - - var delBefore = function( s ) { - var b = before(); if ( !b ) return false; - s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; - return s; - } - - $('#the-list') - .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) - .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); -} ); +jQuery(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")}); \ No newline at end of file diff --git a/wp-admin/js/dashboard.dev.js b/wp-admin/js/dashboard.dev.js new file mode 100644 index 000000000..1379eb079 --- /dev/null +++ b/wp-admin/js/dashboard.dev.js @@ -0,0 +1,48 @@ + +jQuery(document).ready( function($) { + var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; + // These widgets are sometimes populated via ajax + ajaxWidgets = [ + 'dashboard_incoming_links', + 'dashboard_primary', + 'dashboard_secondary', + 'dashboard_plugins' + ]; + + ajaxPopulateWidgets = function() { + $.each( ajaxWidgets, function() { + var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading'); + if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); } + } ); + }; + ajaxPopulateWidgets(); + + postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } ); + + /* QuickPress */ + quickPressLoad = function() { + var act = $('#quickpost-action'), t; + t = $('#quick-press').submit( function() { + $('#dashboard_quick_press h3').append( '' ); + + if ( 'post' == act.val() ) { + act.val( 'post-quickpress-publish' ); + } + + $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() { + $('#dashboard_quick_press h3 img').remove(); + $('#dashboard_quick_press ul').find('li').each( function() { + $('#dashboard_recent_drafts ul').prepend( this ); + } ).end().remove(); + tb_init('a.thickbox'); + quickPressLoad(); + } ); + return false; + } ); + + $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); + + }; + quickPressLoad(); + +} ); diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index 150c432a7..c7f6bb4ca 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -1,48 +1 @@ - -jQuery( function($) { - -// These widgets are sometimes populated via ajax -var ajaxWidgets = [ - 'dashboard_incoming_links', - 'dashboard_primary', - 'dashboard_secondary', - 'dashboard_plugins' -]; - -var ajaxPopulateWidgets = function() { - $.each( ajaxWidgets, function() { - var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading'); - if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); } - } ); -}; -ajaxPopulateWidgets(); - -postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } ); - -/* QuickPress */ -var quickPressLoad = function() { - var act = $('#quickpost-action'); - var t = $('#quick-press').submit( function() { - $('#dashboard_quick_press h3').append( '' ); - - if ( 'post' == act.val() ) { - act.val( 'post-quickpress-publish' ); - } - - $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() { - $('#dashboard_quick_press h3 img').remove(); - $('#dashboard_quick_press ul').find('li').each( function() { - $('#dashboard_recent_drafts ul').prepend( this ); - } ).end().remove(); - tb_init('a.thickbox'); - quickPressLoad(); - } ); - return false; - } ); - - $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); - -}; -quickPressLoad(); - -} ); +jQuery(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('');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()}); \ No newline at end of file diff --git a/wp-admin/js/edit-comments.dev.js b/wp-admin/js/edit-comments.dev.js new file mode 100644 index 000000000..e8790d6bf --- /dev/null +++ b/wp-admin/js/edit-comments.dev.js @@ -0,0 +1,381 @@ +var theList, theExtraList; +(function($) { + +setCommentsList = function() { + var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter; + + totalInput = $('#comments-form .tablenav :input[name="_total"]'); + perPageInput = $('#comments-form .tablenav :input[name="_per_page"]'); + pageInput = $('#comments-form .tablenav :input[name="_page"]'); + + dimAfter = function( r, settings ) { + var c = $('#' + settings.element); + + if ( c.is('.unapproved') ) + c.find('div.comment_status').html('0') + else + c.find('div.comment_status').html('1') + + $('span.pending-count').each( function() { + var a = $(this), n; + n = a.html().replace(/[ ,.]+/g, ''); + n = parseInt(n,10); + if ( isNaN(n) ) return; + n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + if ( n < 0 ) { n = 0; } + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + n = n.toString(); + if ( n.length > 3 ) + n = n.substr(0, n.length-3)+' '+n.substr(-3); + a.html(n); + }); + }; + + // Send current total, page, per_page and url + delBefore = function( settings ) { + settings.data._total = totalInput.val(); + settings.data._per_page = perPageInput.val(); + settings.data._page = pageInput.val(); + settings.data._url = document.location.href; + return settings; + }; + + /* Updates the current total (as displayed visibly) + */ + updateTotalCount = function( total, time, setConfidentTime ) { + if ( time < lastConfidentTime ) { + return; + } + totalInput.val( total.toString() ); + if ( setConfidentTime ) { + lastConfidentTime = time; + } + $('span.total-type-count').each( function() { + var a = $(this), n; + n = totalInput.val().toString(); + if ( n.length > 3 ) + n = n.substr(0, n.length-3)+' '+n.substr(-3); + a.html(n); + }); + + }; + + // In admin-ajax.php, we send back the unix time stamp instead of 1 on success + delAfter = function( r, settings ) { + $('span.pending-count').each( function() { + var a = $(this), n; + n = a.html().replace(/[ ,.]+/g, ''); + n = parseInt(n,10); + if ( isNaN(n) ) return; + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + n = n - 1; + } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" + n = n + 1; + } + if ( n < 0 ) { n = 0; } + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + n = n.toString(); + if ( n.length > 3 ) + n = n.substr(0, n.length-3)+' '+n.substr(-3); + a.html(n); + }); + + $('span.spam-count').each( function() { + var a = $(this), n; + n = a.html().replace(/[ ,.]+/g, ''); + n = parseInt(n,10); + if ( isNaN(n) ) return; + if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam + n = n + 1; + } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam + n = n - 1; + } + if ( n < 0 ) { n = 0; } + n = n.toString(); + if ( n.length > 3 ) + n = n.substr(0, n.length-3)+' '+n.substr(-3); + a.html(n); + }); + + + // XML response + if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { + // 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) + updateTotalCount( settings.parsed.responses[0].supplemental.total, settings.parsed.responses[0].supplemental.time, true ); + if ( $.trim( settings.parsed.responses[0].supplemental.pageLinks ) ) { + $('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( settings.parsed.responses[0].supplemental.pageLinks ) ); + } else if ( 'undefined' != typeof settings.parsed.responses[0].supplemental.pageLinks ) { + $('.tablenav-pages').find( '.page-numbers' ).remove(); + } + } else { + // Decrement the total + var total = parseInt( totalInput.val(), 10 ); + if ( total-- < 0 ) + total = 0; + updateTotalCount( total, r, false ); + } + + if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { + return; + } + + theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); + $('#get-extra-comments').submit(); + }; + + theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); + theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); + +}; + +$(document).ready(function(){ + setCommentsList(); +}); + +commentReply = { + + init : function() { + var row = $('#replyrow'); + + $('a.cancel', row).click(function() { return commentReply.revert(); }); + $('a.save', row).click(function() { return commentReply.send(this); }); + + // add events + $('#the-comment-list .column-comment > p').dblclick(function(){ + commentReply.toggle($(this).parent()); + }); + + $('#doaction, #doaction2, #post-query-submit').click(function(e){ + if ( $('#the-comment-list #replyrow').length > 0 ) + commentReply.close(); + }); + + }, + + addEvents : function(r) { + r.each(function() { + $(this).find('.column-comment > p').dblclick(function(){ + commentReply.toggle($(this).parent()); + }); + }); + }, + + toggle : function(el) { + if ( $(el).css('display') != 'none' ) + $(el).find('a.vim-q').click(); + }, + + revert : function() { + + if ( $('#the-comment-list #replyrow').length < 1 ) + return false; + + $('#replyrow').fadeOut('fast', function(){ + commentReply.close(); + }); + + return false; + }, + + close : function() { + $(this.o).fadeIn('fast').css('backgroundColor', ''); + $('#com-reply').append( $('#replyrow') ); + $('#replycontent').val(''); + $('#edithead input').val(''); + $('#replysubmit .error').html('').hide(); + $('#replysubmit .waiting').hide(); + if ( $.browser.msie ) + $('#replycontainer, #replycontent').css('height', '120px'); + else + $('#replycontainer').resizable('destroy').css('height', '120px'); + }, + + open : function(id, p, a) { + var t = this, editRow, act, h; + t.close(); + t.o = '#comment-'+id; + + $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length); + editRow = $('#replyrow'), rowData = $('#inline-'+id); + act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment'; + + $('#action', editRow).val(act); + $('#comment_post_ID', editRow).val(p); + $('#comment_ID', editRow).val(id); + + if ( a == 'edit' ) { + $('#author', editRow).val( $('div.author', rowData).text() ); + $('#author-email', editRow).val( $('div.author-email', rowData).text() ); + $('#author-url', editRow).val( $('div.author-url', rowData).text() ); + $('#status', editRow).val( $('div.comment_status', rowData).text() ); + $('#replycontent', editRow).val( $('textarea.comment', rowData).val() ); + $('#edithead, #savebtn', editRow).show(); + $('#replyhead, #replybtn', editRow).hide(); + + h = $(t.o).height(); + if ( h > 220 ) + if ( $.browser.msie ) + $('#replycontainer, #replycontent', editRow).height(h-105); + else + $('#replycontainer', editRow).height(h-105); + + $(t.o).after(editRow.hide()).fadeOut('fast', function(){ + $('#replyrow').fadeIn('fast'); + }); + } else { + $('#edithead, #savebtn', editRow).hide(); + $('#replyhead, #replybtn', editRow).show(); + $(t.o).after(editRow); + $('#replyrow').hide().fadeIn('fast'); + } + + if ( ! $.browser.msie ) + $('#replycontainer').resizable({ + handles : 's', + axis : 'y', + minHeight : 80, + stop : function() { + $('#replycontainer').width('auto'); + } + }); + + setTimeout(function() { + var rtop, rbottom, scrollTop, vp, scrollBottom; + + rtop = $('#replyrow').offset().top; + rbottom = rtop + $('#replyrow').height(); + scrollTop = window.pageYOffset || document.documentElement.scrollTop; + vp = document.documentElement.clientHeight || self.innerHeight || 0; + scrollBottom = scrollTop + vp; + + if ( scrollBottom - 20 < rbottom ) + window.scroll(0, rbottom - vp + 35); + else if ( rtop - 20 < scrollTop ) + window.scroll(0, rtop - 35); + + $('#replycontent').focus().keyup(function(e){ + if (e.which == 27) commentReply.revert(); // close on Escape + }); + }, 600); + + return false; + }, + + send : function() { + var post = {}; + + $('#replysubmit .waiting').show(); + + $('#replyrow input').each(function() { + post[ $(this).attr('name') ] = $(this).val(); + }); + + post.content = $('#replycontent').val(); + post.id = post.comment_post_ID; + + $.ajax({ + type : 'POST', + url : wpListL10n.url, + data : post, + success : function(x) { commentReply.show(x); }, + error : function(r) { commentReply.error(r); } + }); + + return false; + }, + + show : function(xml) { + var r, c, id, bg; + + if ( typeof(xml) == 'string' ) { + this.error({'responseText': xml}); + return false; + } + + r = wpAjax.parseAjaxResponse(xml); + if ( r.errors ) { + this.error({'responseText': wpAjax.broken}); + return false; + } + + if ( 'edit-comment' == this.act ) + $(this.o).remove(); + + r = r.responses[0]; + c = r.data; + + $(c).hide() + $('#replyrow').after(c); + + this.o = id = '#comment-'+r.id; + this.revert(); + this.addEvents($(id)); + bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; + + $(id) + .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) + .animate( { 'backgroundColor': bg }, 600 ); + + $.fn.wpList.process($(id)) + }, + + error : function(r) { + var er = r.statusText; + + $('#replysubmit .waiting').hide(); + + if ( r.responseText ) + er = r.responseText.replace( /<.[^<>]*?>/g, '' ); + + if ( er ) + $('#replysubmit .error').html(er).show(); + + } +}; +toggleWithKeyboard = false; +$(document).ready(function(){ + var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk; + + columns.init('edit-comments'); + commentReply.init(); + + if ( typeof QTags != 'undefined' ) + ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more'); + + if ( typeof $.table_hotkeys != 'undefined' ) { + make_hotkeys_redirect = function(which) { + return function() { + var first_last, l; + + first_last = 'next' == which? 'first' : 'last'; + l = $('.'+which+'.page-numbers'); + if (l.length) + window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; + } + }; + edit_comment = function(event, current_row) { + window.location = $('span.edit a', current_row).attr('href'); + }; + toggle_all = function() { + toggleWithKeyboard = true; + var master_checkbox = $('form#comments-form .check-column :checkbox:first'); + master_checkbox.click().attr('checked', ''); + toggleWithKeyboard = false; + } + make_bulk = function(value) { + return function(event, _) { + $('option[value='+value+']').attr('selected', 'selected'); + $('form#comments-form')[0].submit(); + } + }; + $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment], + ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], + ['shift+d', make_bulk('delete')], ['shift+x', toggle_all], + ['shift+u', make_bulk('unapprove')]], + {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last, + prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')} + ); + } +}); + +})(jQuery); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index 3c69dcb86..f850c8de4 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -1,372 +1 @@ -var theList; var theExtraList; -(function($) { - -setCommentsList = function() { - var totalInput = $('#comments-form .tablenav :input[name="_total"]'); - var perPageInput = $('#comments-form .tablenav :input[name="_per_page"]'); - var pageInput = $('#comments-form .tablenav :input[name="_page"]'); - var lastConfidentTime = 0; - - var dimAfter = function( r, settings ) { - var c = $('#' + settings.element); - - if ( c.is('.unapproved') ) - c.find('div.comment_status').html('0') - else - c.find('div.comment_status').html('1') - - $('span.pending-count').each( function() { - var a = $(this); - var n = a.html().replace(/[ ,.]+/g, ''); - n = parseInt(n,10); - if ( isNaN(n) ) return; - n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); - if ( n < 0 ) { n = 0; } - $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); - n = n.toString(); - if ( n.length > 3 ) - n = n.substr(0, n.length-3)+' '+n.substr(-3); - a.html(n); - }); - }; - - // Send current total, page, per_page and url - var delBefore = function( settings ) { - settings.data._total = totalInput.val(); - settings.data._per_page = perPageInput.val(); - settings.data._page = pageInput.val(); - settings.data._url = document.location.href; - return settings; - }; - - /* Updates the current total (as displayed visibly) - */ - var updateTotalCount = function( total, time, setConfidentTime ) { - if ( time < lastConfidentTime ) { - return; - } - totalInput.val( total.toString() ); - if ( setConfidentTime ) { - lastConfidentTime = time; - } - $('span.total-type-count').each( function() { - var a = $(this); - var n = totalInput.val().toString(); - if ( n.length > 3 ) - n = n.substr(0, n.length-3)+' '+n.substr(-3); - a.html(n); - }); - - }; - - // In admin-ajax.php, we send back the unix time stamp instead of 1 on success - var delAfter = function( r, settings ) { - $('span.pending-count').each( function() { - var a = $(this); - var n = a.html().replace(/[ ,.]+/g, ''); - n = parseInt(n,10); - if ( isNaN(n) ) return; - if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment - n = n - 1; - } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" - n = n + 1; - } - if ( n < 0 ) { n = 0; } - $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); - n = n.toString(); - if ( n.length > 3 ) - n = n.substr(0, n.length-3)+' '+n.substr(-3); - a.html(n); - }); - - $('span.spam-count').each( function() { - var a = $(this); - var n = a.html().replace(/[ ,.]+/g, ''); - n = parseInt(n,10); - if ( isNaN(n) ) return; - if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam - n = n + 1; - } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam - n = n - 1; - } - if ( n < 0 ) { n = 0; } - n = n.toString(); - if ( n.length > 3 ) - n = n.substr(0, n.length-3)+' '+n.substr(-3); - a.html(n); - }); - - - // XML response - if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { - // 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) - updateTotalCount( settings.parsed.responses[0].supplemental.total, settings.parsed.responses[0].supplemental.time, true ); - if ( $.trim( settings.parsed.responses[0].supplemental.pageLinks ) ) { - $('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( settings.parsed.responses[0].supplemental.pageLinks ) ); - } else if ( 'undefined' != typeof settings.parsed.responses[0].supplemental.pageLinks ) { - $('.tablenav-pages').find( '.page-numbers' ).remove(); - } - } else { - // Decrement the total - var total = parseInt( totalInput.val(), 10 ); - if ( total-- < 0 ) - total = 0; - updateTotalCount( total, r, false ); - } - - if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { - return; - } - - theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); - $('#get-extra-comments').submit(); - }; - - theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); - theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); - -}; - -$(document).ready(function(){ - setCommentsList(); -}); - -commentReply = { - - init : function() { - var row = $('#replyrow'); - - $('a.cancel', row).click(function() { return commentReply.revert(); }); - $('a.save', row).click(function() { return commentReply.send(this); }); - - // add events - $('#the-comment-list .column-comment > p').dblclick(function(){ - commentReply.toggle($(this).parent()); - }); - - $('#doaction, #doaction2, #post-query-submit').click(function(e){ - if ( $('#the-comment-list #replyrow').length > 0 ) - t.close(); - }); - - }, - - addEvents : function(r) { - r.each(function() { - $(this).find('.column-comment > p').dblclick(function(){ - commentReply.toggle($(this).parent()); - }); - }); - }, - - toggle : function(el) { - if ( $(el).css('display') != 'none' ) - $(el).find('a.vim-q').click(); - }, - - revert : function() { - - if ( $('#the-comment-list #replyrow').length < 1 ) - return false; - - $('#replyrow').fadeOut('fast', function(){ - commentReply.close(); - }); - - return false; - }, - - close : function() { - $(this.o).fadeIn('fast').css('backgroundColor', ''); - $('#com-reply').append( $('#replyrow') ); - $('#replycontent').val(''); - $('#edithead input').val(''); - $('#replysubmit .error').html('').hide(); - $('#replysubmit .waiting').hide(); - if ( $.browser.msie ) - $('#replycontainer, #replycontent').css('height', '120px'); - else - $('#replycontainer').resizable('destroy').css('height', '120px'); - }, - - open : function(id, p, a) { - var t = this; - t.close(); - t.o = '#comment-'+id; - - $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length); - var editRow = $('#replyrow'), rowData = $('#inline-'+id); - var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment'; - - $('#action', editRow).val(act); - $('#comment_post_ID', editRow).val(p); - $('#comment_ID', editRow).val(id); - - if ( a == 'edit' ) { - $('#author', editRow).val( $('div.author', rowData).text() ); - $('#author-email', editRow).val( $('div.author-email', rowData).text() ); - $('#author-url', editRow).val( $('div.author-url', rowData).text() ); - $('#status', editRow).val( $('div.comment_status', rowData).text() ); - $('#replycontent', editRow).val( $('textarea.comment', rowData).val() ); - $('#edithead, #savebtn', editRow).show(); - $('#replyhead, #replybtn', editRow).hide(); - - var h = $(t.o).height(); - if ( h > 220 ) - if ( $.browser.msie ) - $('#replycontainer, #replycontent', editRow).height(h-105); - else - $('#replycontainer', editRow).height(h-105); - - $(t.o).after(editRow.hide()).fadeOut('fast', function(){ - $('#replyrow').fadeIn('fast'); - }); - } else { - $('#edithead, #savebtn', editRow).hide(); - $('#replyhead, #replybtn', editRow).show(); - $(t.o).after(editRow); - $('#replyrow').hide().fadeIn('fast'); - } - - if ( ! $.browser.msie ) - $('#replycontainer').resizable({ - handles : 's', - axis : 'y', - minHeight : 80, - stop : function() { - $('#replycontainer').width('auto'); - } - }); - - setTimeout(function() { - var rtop = $('#replyrow').offset().top; - var rbottom = rtop + $('#replyrow').height(); - var scrollTop = window.pageYOffset || document.documentElement.scrollTop; - var vp = document.documentElement.clientHeight || self.innerHeight || 0; - var scrollBottom = scrollTop + vp; - - if ( scrollBottom - 20 < rbottom ) - window.scroll(0, rbottom - vp + 35); - else if ( rtop - 20 < scrollTop ) - window.scroll(0, rtop - 35); - - $('#replycontent').focus().keyup(function(e){ - if (e.which == 27) commentReply.revert(); // close on Escape - }); - }, 600); - - return false; - }, - - send : function() { - var post = {}; - - $('#replysubmit .waiting').show(); - - $('#replyrow input').each(function() { - post[ $(this).attr('name') ] = $(this).val(); - }); - - post.content = $('#replycontent').val(); - post.id = post.comment_post_ID; - - $.ajax({ - type : 'POST', - url : wpListL10n.url, - data : post, - success : function(x) { commentReply.show(x); }, - error : function(r) { commentReply.error(r); } - }); - - return false; - }, - - show : function(xml) { - - if ( typeof(xml) == 'string' ) { - this.error({'responseText': xml}); - return false; - } - - var r = wpAjax.parseAjaxResponse(xml); - if ( r.errors ) { - this.error({'responseText': wpAjax.broken}); - return false; - } - - if ( 'edit-comment' == this.act ) - $(this.o).remove(); - - r = r.responses[0]; - var c = r.data; - - $(c).hide() - $('#replyrow').after(c); - this.o = id = '#comment-'+r.id; - this.revert(); - this.addEvents($(id)); - var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; - - $(id) - .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) - .animate( { 'backgroundColor': bg }, 600 ); - - $.fn.wpList.process($(id)) - }, - - error : function(r) { - var er = r.statusText; - - $('#replysubmit .waiting').hide(); - - if ( r.responseText ) - er = r.responseText.replace( /<.[^<>]*?>/g, '' ); - - if ( er ) - $('#replysubmit .error').html(er).show(); - - } -}; -toggleWithKeyboard = false; -$(document).ready(function(){ - columns.init('edit-comments'); - commentReply.init(); - - if ( typeof QTags != 'undefined' ) - ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more'); - - if ( typeof $.table_hotkeys != 'undefined' ) { - var make_hotkeys_redirect = function(which) { - return function() { - var first_last = 'next' == which? 'first' : 'last'; - var l=$('.'+which+'.page-numbers'); - if (l.length) - window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; - } - }; - var edit_comment = function(event, current_row) { - window.location = $('span.edit a', current_row).attr('href'); - }; - var toggle_all = function() { - toggleWithKeyboard = true; - var master_checkbox = $('form#comments-form .check-column :checkbox:first'); - master_checkbox.click().attr('checked', ''); - toggleWithKeyboard = false; - } - var make_bulk = function(value) { - return function(event, _) { - $('option[value='+value+']').attr('selected', 'selected'); - $('form#comments-form')[0].submit(); - } - }; - $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment], - ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], - ['shift+d', make_bulk('delete')], ['shift+x', toggle_all], - ['shift+u', make_bulk('unapprove')]], - {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last, - prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')} - ); - } -}); - -})(jQuery); +var 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(k3){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 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]*?>/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); \ No newline at end of file diff --git a/wp-admin/js/editor.dev.js b/wp-admin/js/editor.dev.js new file mode 100644 index 000000000..74b141158 --- /dev/null +++ b/wp-admin/js/editor.dev.js @@ -0,0 +1,168 @@ + +var switchEditors = { + + mode : '', + + I : function(e) { + return document.getElementById(e); + }, + + edInit : function() { + var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"); + + // Activate TinyMCE if it's the user's default editor + if ( getUserSetting( 'editor' ) == 'html' ) { + if ( h ) + try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){}; + } else { + try { + this.I("quicktags").style.display = "none"; + } catch(e){}; + tinyMCE.execCommand("mceAddControl", false, "content"); + } + }, + + saveCallback : function(el, content, body) { + + if ( tinyMCE.activeEditor.isHidden() ) + content = this.I(el).value; + else + content = this.pre_wpautop(content); + + return content; + }, + + pre_wpautop : function(content) { + var blocklist1, blocklist2; + + // Protect pre|script tags + content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
[\r\n]*/g, ''); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); + }); + + // Pretty it up for the source editor + blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); + + // Mark

if it has any attributes. + content = content.replace(new RegExp('(

]+>.*?)

', 'mg'), '$1'); + + // Sepatate
containing

+ content = content.replace(new RegExp(']*)>\\s*

', 'mgi'), '\n\n'); + + // Remove

and
+ content = content.replace(new RegExp('\\s*

', 'mgi'), ''); + content = content.replace(new RegExp('\\s*

\\s*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); + + // Fix some block element newline issues + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '
\n'); + content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n'); + content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption'); + + blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp(']*)>', 'g'), '\t'); + + if ( content.indexOf(']*)>\\s*', 'mg'), ""); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), ''); + } + + // Unmark special paragraph closing tags + content = content.replace(new RegExp('', 'g'), '

\n'); + content = content.replace(new RegExp('\\s*(

]+>.*

)', 'mg'), '\n$1'); + + // Trim whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), ''); + + // put back the line breaks in pre|script + content = content.replace(//g, '\n'); + + // Hope. + return content; + }, + + go : function(id, mode) { + id = id || 'content'; + mode = mode || this.mode || ''; + + var ed = tinyMCE.get(id) || false, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id); + + if ( 'tinymce' == mode ) { + + if ( ed && ! ed.isHidden() ) + return false; + + this.mode = 'html'; + ta.style.color = '#fff'; + + P.className = 'active'; + H.className = ''; + edCloseAllTags(); // :-( + + qt.style.display = 'none'; + + ta.value = this.wpautop(ta.value); + + if ( ed ) ed.show(); + else tinyMCE.execCommand("mceAddControl", false, id); + + setUserSetting( 'editor', 'tinymce' ); + } else { + if ( ! ed || ed.isHidden() ) + return false; + + this.mode = 'tinymce'; + H.className = 'active'; + P.className = ''; + + ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px'; + + ed.hide(); + qt.style.display = 'block'; + + ta.style.color = ''; + setUserSetting( 'editor', 'html' ); + } + return false; + }, + + wpautop : function(pee) { + 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]'; + + pee = pee + "\n\n"; + pee = pee.replace(new RegExp('
\\s*
', 'gi'), "\n\n"); + pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1"); + pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); + pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); + pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); + pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "

$1

\n"); + pee = pee.replace(new RegExp('

\\s*?

', 'gi'), ''); + pee = pee.replace(new RegExp('

\\s*(]*>)\\s*

', 'gi'), "$1"); + pee = pee.replace(new RegExp("

(", 'gi'), "$1"); + pee = pee.replace(new RegExp('

\\s*]*)>', 'gi'), "

"); + pee = pee.replace(new RegExp('\\s*

', 'gi'), '

'); + pee = pee.replace(new RegExp('

\\s*(]*>)', 'gi'), "$1"); + pee = pee.replace(new RegExp('(]*>)\\s*

', 'gi'), "$1"); + pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); + pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); + pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); + pee = pee.replace(new RegExp('(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*', 'gi'), '[caption$1[/caption]'); + // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); + + // Fix the pre|script tags + pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
[\r\n]*/g, '\n'); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); + }); + + return pee; + } +}; diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index 935267a28..289234778 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -1,172 +1 @@ - -var switchEditors = { - - mode : '', - - I : function(e) { - return document.getElementById(e); - }, - - edInit : function() { - var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'); - - // Activate TinyMCE if it's the user's default editor - if ( getUserSetting( 'editor' ) == 'html' ) { - if ( h ) - try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){}; - } else { - try { - this.I("quicktags").style.display = "none"; - } catch(e){}; - tinyMCE.execCommand("mceAddControl", false, "content"); - } - }, - - saveCallback : function(el, content, body) { - - if ( tinyMCE.activeEditor.isHidden() ) - content = this.I(el).value; - else - content = this.pre_wpautop(content); - - return content; - }, - - pre_wpautop : function(content) { - // We have a TON of cleanup to do. Line breaks are already stripped. - - // Protect pre|script tags - content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { - a = a.replace(/
[\r\n]*/g, ''); - return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); - }); - - // Pretty it up for the source editor - var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); - - // Mark

if it has any attributes. - content = content.replace(new RegExp('(

]+>.*?)

', 'mg'), '$1'); - - // Sepatate
containing

- content = content.replace(new RegExp(']*)>\\s*

', 'mgi'), '\n\n'); - - // Remove

and
- content = content.replace(new RegExp('\\s*

', 'mgi'), ''); - content = content.replace(new RegExp('\\s*

\\s*', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); - - // Fix some block element newline issues - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '
\n'); - content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n'); - content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption'); - - var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; - content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp(']*)>', 'g'), '\t'); - - if ( content.indexOf(']*)>\\s*', 'mg'), ""); - content = content.replace(new RegExp('\\s*\\s*', 'mg'), ''); - } - - // Unmark special paragraph closing tags - content = content.replace(new RegExp('', 'g'), '

\n'); - content = content.replace(new RegExp('\\s*(

]+>.*

)', 'mg'), '\n$1'); - - // Trim whitespace - content = content.replace(new RegExp('^\\s*', ''), ''); - content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), ''); - - // put back the line breaks in pre|script - content = content.replace(//g, '\n'); - - // Hope. - return content; - }, - - go : function(id, mode) { - id = id || 'content'; - mode = mode || this.mode || ''; - - var ed = tinyMCE.get(id) || false; - var qt = this.I('quicktags'); - var H = this.I('edButtonHTML'); - var P = this.I('edButtonPreview'); - var ta = this.I(id); - - if ( 'tinymce' == mode ) { - - if ( ed && ! ed.isHidden() ) - return false; - - this.mode = 'html'; - ta.style.color = '#fff'; - - P.className = 'active'; - H.className = ''; - edCloseAllTags(); // :-( - - qt.style.display = 'none'; - - ta.value = this.wpautop(ta.value); - - if ( ed ) ed.show(); - else tinyMCE.execCommand("mceAddControl", false, id); - - setUserSetting( 'editor', 'tinymce' ); - } else { - if ( ! ed || ed.isHidden() ) - return false; - - this.mode = 'tinymce'; - H.className = 'active'; - P.className = ''; - - ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px'; - - ed.hide(); - qt.style.display = 'block'; - - ta.style.color = ''; - setUserSetting( 'editor', 'html' ); - } - return false; - }, - - wpautop : function(pee) { - 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]'; - - pee = pee + "\n\n"; - pee = pee.replace(new RegExp('
\\s*
', 'gi'), "\n\n"); - pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1"); - pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); - pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); - pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); - pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "

$1

\n"); - pee = pee.replace(new RegExp('

\\s*?

', 'gi'), ''); - pee = pee.replace(new RegExp('

\\s*(]*>)\\s*

', 'gi'), "$1"); - pee = pee.replace(new RegExp("

(", 'gi'), "$1"); - pee = pee.replace(new RegExp('

\\s*]*)>', 'gi'), "

"); - pee = pee.replace(new RegExp('\\s*

', 'gi'), '

'); - pee = pee.replace(new RegExp('

\\s*(]*>)', 'gi'), "$1"); - pee = pee.replace(new RegExp('(]*>)\\s*

', 'gi'), "$1"); - pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); - pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); - pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); - pee = pee.replace(new RegExp('(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*', 'gi'), '[caption$1[/caption]'); - // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); - - // Fix the pre|script tags - pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { - a = a.replace(/
[\r\n]*/g, '\n'); - return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); - }); - - return pee; - } -}; +var 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(/
[\r\n]*/g,"");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*\\s*","mg"),"\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(

]+>.*?)

","mg"),"$1");b=b.replace(new RegExp("]*)>\\s*

","mgi"),"\n\n");b=b.replace(new RegExp("\\s*

","mgi"),"");b=b.replace(new RegExp("\\s*

\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*
\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*\\s*","mg"),"\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*\\s*","mg"),"\n");b=b.replace(new RegExp("]*)>","g"),"\t");if(b.indexOf("]*)>\\s*","mg"),"");b=b.replace(new RegExp("\\s*\\s*","mg"),"")}b=b.replace(new RegExp("","g"),"

\n");b=b.replace(new RegExp("\\s*(

]+>.*

)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(//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("
\\s*
","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("()","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"),"

$1

\n");a=a.replace(new RegExp("

\\s*?

","gi"),"");a=a.replace(new RegExp("

\\s*(]*>)\\s*

","gi"),"$1");a=a.replace(new RegExp("

(","gi"),"$1");a=a.replace(new RegExp("

\\s*]*)>","gi"),"

");a=a.replace(new RegExp("\\s*

","gi"),"

");a=a.replace(new RegExp("

\\s*(]*>)","gi"),"$1");a=a.replace(new RegExp("(]*>)\\s*

","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"
\n");a=a.replace(new RegExp("(]*>)\\s*
","gi"),"$1");a=a.replace(new RegExp("
(\\s*)","gi"),"$1");a=a.replace(new RegExp("(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/
[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}}; \ No newline at end of file diff --git a/wp-admin/js/gallery.dev.js b/wp-admin/js/gallery.dev.js new file mode 100644 index 000000000..8071d4565 --- /dev/null +++ b/wp-admin/js/gallery.dev.js @@ -0,0 +1,174 @@ +jQuery(document).ready(function($) { + var gallerySortable, gallerySortableInit, galleryReorder, w; + + gallerySortableInit = function() { + gallerySortable = $('#media-items').sortable( { + items: '.media-item', + placeholder: 'sorthelper', + axis: 'y', + distance: 2, + update: galleryReorder + } ); + } + + // When an update has occurred, adjust the order for each item + galleryReorder = function(e, sort) { + jQuery.each(sort['element'].sortable('toArray'), function(i, id) { + jQuery('#' + id + ' .menu_order input')[0].value = (1+i); + }); + } + + // initialize sortable + gallerySortableInit(); + + $('.menu_order_input').each(function(){ + if ( this.value == '0' ) this.value = ''; + }); + + if ( $('#media-items>*').length > 1 ) { + w = wpgallery.getWin(); + + $('#save-all, #gallery-settings').show(); + if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) { + wpgallery.mcemode = true; + wpgallery.init(); + } else { + $('#insert-gallery').show(); + } + } +}); + +jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup + +/* gallery settings */ +var tinymce = null, tinyMCE, wpgallery; + +wpgallery = { + mcemode : false, + editor : {}, + dom : {}, + is_update : false, + el : {}, + + I : function(e) { + return document.getElementById(e); + }, + + init: function() { + var t = this, li, q, i, it, w = t.getWin(); + + if ( ! t.mcemode ) return; + + li = ('' + document.location.search).replace(/^\?/, '').split('&'); + q = {}; + for (i=0; i*').length > 1 ) { - var w = wpgallery.getWin(); - - $('#save-all, #gallery-settings').show(); - if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) { - wpgallery.mcemode = true; - wpgallery.init(); - } else { - $('#insert-gallery').show(); - } - } -}); - -jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup - -/* gallery settings */ -var tinymce = null, tinyMCE; - -var wpgallery = { - mcemode : false, - editor : {}, - dom : {}, - is_update : false, - el : {}, - - I : function(e) { - return document.getElementById(e); - }, - - init: function() { - var t = this, li, q, i, it, w = t.getWin(); - - if ( ! t.mcemode ) return; - - li = ('' + document.location.search).replace(/^\?/, '').split('&'); - q = {}; - for (i=0; i*").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 0 ) { + t.revert(); + } + }); + + $('#post-query-submit').click(function(e){ + if ( $('form#posts-filter tr.inline-editor').length > 0 ) + t.revert(); + }); + + }, + + toggle : function(el) { + var t = this; + $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); + }, + + addEvents : function(r) { + r.each(function() { + var row = $(this); + $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; }); + }); + }, + + setBulk : function() { + var te = '', type = this.type; + this.revert(); + + $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length); + $('table.widefat tbody').prepend( $('#bulk-edit') ); + $('#bulk-edit').addClass('inline-editor').show(); + + $('tbody th.check-column input[type="checkbox"]').each(function(i){ + if ( $(this).attr('checked') ) { + var id = $(this).val(), theTitle; + theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle; + te += '
X'+theTitle+'
'; + } + }); + + $('#bulk-titles').html(te); + $('#bulk-titles a').click(function() { + var id = $(this).attr('id').substr(1); + + $('table.widefat input[value="'+id+'"]').attr('checked', ''); + $('#ttle'+id).remove(); + }); + + // enable autocomplete for tags + if ( type == 'post' ) + $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); + }, + + edit : function(id) { + var t = this, fields, editRow, rowData, cats, status, pageOpt, f; + t.revert(); + + if ( typeof(id) == 'object' ) + id = t.getId(id); + + fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password']; + if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template'); + if ( t.type == 'post' ) fields.push('tags_input'); + + // add the new blank row + editRow = $('#inline-edit').clone(true); + $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + + if ( $(t.what+id).hasClass('alternate') ) + $(editRow).addClass('alternate'); + $(t.what+id).hide().after(editRow); + + // populate the data + rowData = $('#inline_'+id); + for ( f = 0; f < fields.length; f++ ) { + $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() ); + } + + if ( $('.comment_status', rowData).text() == 'open' ) + $('input[name="comment_status"]', editRow).attr("checked", "checked"); + if ( $('.ping_status', rowData).text() == 'open' ) + $('input[name="ping_status"]', editRow).attr("checked", "checked"); + if ( $('.sticky', rowData).text() == 'sticky' ) + $('input[name="sticky"]', editRow).attr("checked", "checked"); + + // categories + if ( cats = $('.post_category', rowData).text() ) + $('ul.cat-checklist :checkbox', editRow).val(cats.split(',')); + + // handle the post status + status = $('._status', rowData).text(); + if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove(); + if ( status == 'private' ) { + $('input[name="keep_private"]', editRow).attr("checked", "checked"); + $('input.inline-edit-password-input').val('').attr('disabled', 'disabled'); + } + + // remove the current page and children from the parent dropdown + pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow); + if ( pageOpt.length > 0 ) { + var pageLevel = pageOpt[0].className.split('-')[1], pageLoop = true, nextPage, nextLevel; + while ( pageLoop ) { + nextPage = nextPage.next('option'); + if (nextPage.length == 0) break; + nextLevel = nextPage[0].className.split('-')[1]; + if ( nextLevel <= pageLevel ) { + pageLoop = false; + } else { + nextPage.remove(); + nextPage = pageOpt; + } + } + pageOpt.remove(); + } + + $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); + $('.ptitle', editRow).focus(); + + // enable autocomplete for tags + if ( t.type == 'post' ) + $('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(id) { + var params, fields; + + if( typeof(id) == 'object' ) + id = this.getId(id); + + $('table.widefat .inline-edit-save .waiting').show(); + + params = { + action: 'inline-save', + post_type: this.type, + post_ID: id, + edit_date: 'true' + }; + + fields = $('#edit-'+id+' :input').fieldSerialize(); + params = fields + '&' + $.param(params); + + // make ajax request + $.post('admin-ajax.php', params, + function(r) { + $('table.widefat .inline-edit-save .waiting').hide(); + + if (r) { + if ( -1 != r.indexOf(']*?>/g, '' ); + $('#edit-'+id+' .inline-edit-save').append(''+r+''); + } + } else { + $('#edit-'+id+' .inline-edit-save').append(''+inlineEditL10n.error+''); + } + } + , 'html'); + return false; + }, + + revert : function() { + var id; + + if ( id = $('table.widefat tr.inline-editor').attr('id') ) { + $('table.widefat .inline-edit-save .waiting').hide(); + + if ( 'bulk-edit' == id ) { + $('table.widefat #bulk-edit').removeClass('inline-editor').hide(); + $('#bulk-titles').html(''); + $('#inlineedit').append( $('#bulk-edit') ); + } else { + $('#'+id).remove(); + id = id.substr( id.lastIndexOf('-') + 1 ); + $(this.what+id).show(); + } + } + + return false; + }, + + getId : function(o) { + var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-'); + return parts[parts.length - 1]; + } +}; + +$(document).ready(function(){inlineEditPost.init();}); +})(jQuery); diff --git a/wp-admin/js/inline-edit-post.js b/wp-admin/js/inline-edit-post.js index d18386084..af8723c91 100644 --- a/wp-admin/js/inline-edit-post.js +++ b/wp-admin/js/inline-edit-post.js @@ -1,265 +1 @@ - -(function($) { -inlineEditPost = { - - init : function() { - var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); - - t.type = $('table.widefat').hasClass('page') ? 'page' : 'post'; - t.what = '#'+t.type+'-'; - - // get all editable rows - t.rows = $('tr.iedit'); - - // prepare the edit rows - qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); }); - bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); }); - - $('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); }); - $('a.save', qeRow).click(function() { return inlineEditPost.save(this); }); - $('input, select', qeRow).keydown(function(e) { if(e.which == 13) return inlineEditPost.save(this); }); - - $('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); }); - - $('#inline-edit .inline-edit-private input[value=private]').click( function(){ - var pw = $('input.inline-edit-password-input'); - if ( $(this).attr('checked') ) { - pw.val('').attr('disabled', 'disabled'); - } else { - pw.attr('disabled', ''); - } - }); - - // add events - t.addEvents(t.rows); - - $('#bulk-title-div').parents('fieldset').after( - $('#inline-edit fieldset.inline-edit-categories').clone() - ).siblings( 'fieldset:last' ).prepend( -// ).siblings( 'fieldset:last' ).after( '
' ); -// $('fieldset.inline-edit-col-bottom').prepend( - $('#inline-edit label.inline-edit-tags').clone() - ); - - // categories expandable? - $('span.catshow').click(function() { - $('.inline-editor ul.cat-checklist').addClass("cat-hover"); - $('.inline-editor span.cathide').show(); - $(this).hide(); - }); - - $('span.cathide').click(function() { - $('.inline-editor ul.cat-checklist').removeClass("cat-hover"); - $('.inline-editor span.catshow').show(); - $(this).hide(); - }); - - $('select[name="_status"] option[value="future"]', bulkRow).remove(); - - $('#doaction, #doaction2').click(function(e){ - var n = $(this).attr('id').substr(2); - if ( $('select[name="'+n+'"]').val() == 'edit' ) { - e.preventDefault(); - t.setBulk(); - } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) { - t.revert(); - } - }); - - $('#post-query-submit').click(function(e){ - if ( $('form#posts-filter tr.inline-editor').length > 0 ) - t.revert(); - }); - - }, - - toggle : function(el) { - var t = this; - - $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - - addEvents : function(r) { - r.each(function() { - var row = $(this); - $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; }); - }); - }, - - setBulk : function() { - var te = '', c = '', type = this.type; - this.revert(); - - $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length); - $('table.widefat tbody').prepend( $('#bulk-edit') ); - $('#bulk-edit').addClass('inline-editor').show(); - - $('tbody th.check-column input[type="checkbox"]').each(function(i){ - if ( $(this).attr('checked') ) { - var id = $(this).val(); - var theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle; - te += '
X'+theTitle+'
'; - } - }); - - $('#bulk-titles').html(te); - $('#bulk-titles a').click(function() { - var id = $(this).attr('id').substr(1), r = inlineEditPost.type+'-'+id; - - $('table.widefat input[value="'+id+'"]').attr('checked', ''); - $('#ttle'+id).remove(); - }); - - // enable autocomplete for tags - if ( type == 'post' ) - $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); - }, - - edit : function(id) { - var t = this; - t.revert(); - - if ( typeof(id) == 'object' ) - id = t.getId(id); - - var fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password']; - if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template'); - if ( t.type == 'post' ) fields.push('tags_input'); - - // add the new blank row - var editRow = $('#inline-edit').clone(true); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); - - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); - $(t.what+id).hide().after(editRow); - - // populate the data - var rowData = $('#inline_'+id); - for ( var f = 0; f < fields.length; f++ ) { - $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() ); - } - - if ( $('.comment_status', rowData).text() == 'open' ) - $('input[name="comment_status"]', editRow).attr("checked", "checked"); - if ( $('.ping_status', rowData).text() == 'open' ) - $('input[name="ping_status"]', editRow).attr("checked", "checked"); - if ( $('.sticky', rowData).text() == 'sticky' ) - $('input[name="sticky"]', editRow).attr("checked", "checked"); - - // categories - var cats; - if ( cats = $('.post_category', rowData).text() ) - $('ul.cat-checklist :checkbox', editRow).val(cats.split(',')); - - // handle the post status - var status = $('._status', rowData).text(); - if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove(); - if ( status == 'private' ) { - $('input[name="keep_private"]', editRow).attr("checked", "checked"); - $('input.inline-edit-password-input').val('').attr('disabled', 'disabled'); - } - - // remove the current page and children from the parent dropdown - var pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow); - if ( pageOpt.length > 0 ) { - var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true; - while ( pageLoop ) { - var nextPage = nextPage.next('option'); - if (nextPage.length == 0) break; - var nextLevel = nextPage[0].className.split('-')[1]; - if ( nextLevel <= pageLevel ) { - pageLoop = false; - } else { - nextPage.remove(); - nextPage = pageOpt; - } - } - pageOpt.remove(); - } - - $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).focus(); - - // enable autocomplete for tags - if ( t.type == 'post' ) - $('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(id) { - if( typeof(id) == 'object' ) - id = this.getId(id); - - $('table.widefat .inline-edit-save .waiting').show(); - - var params = { - action: 'inline-save', - post_type: this.type, - post_ID: id, - edit_date: 'true' - }; - - var fields = $('#edit-'+id+' :input').fieldSerialize(); - params = fields + '&' + $.param(params); - - // make ajax request - $.post('admin-ajax.php', params, - function(r) { - $('table.widefat .inline-edit-save .waiting').hide(); - - if (r) { - if ( -1 != r.indexOf(']*?>/g, '' ); - $('#edit-'+id+' .inline-edit-save').append(''+r+''); - } - } else { - $('#edit-'+id+' .inline-edit-save').append(''+inlineEditL10n.error+''); - } - } - , 'html'); - return false; - }, - - revert : function() { - var id; - - if ( id = $('table.widefat tr.inline-editor').attr('id') ) { - $('table.widefat .inline-edit-save .waiting').hide(); - - if ( 'bulk-edit' == id ) { - $('table.widefat #bulk-edit').removeClass('inline-editor').hide(); - $('#bulk-titles').html(''); - $('#inlineedit').append( $('#bulk-edit') ); - } else { - $('#'+id).remove(); - id = id.substr( id.lastIndexOf('-') + 1 ); - $(this.what+id).show(); - } - } - - return false; - }, - - getId : function(o) { - var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'); - var parts = id.split('-'); - return parts[parts.length - 1]; - } -}; - -$(document).ready(function(){inlineEditPost.init();}); -})(jQuery); +(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+='
X'+d+"
"}});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;j0){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("]*?>/g,"");a("#edit-"+d+" .inline-edit-save").append(''+e+"")}}else{a("#edit-"+d+" .inline-edit-save").append(''+inlineEditL10n.error+"")}},"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); \ No newline at end of file diff --git a/wp-admin/js/inline-edit-tax.dev.js b/wp-admin/js/inline-edit-tax.dev.js new file mode 100644 index 000000000..3b219f342 --- /dev/null +++ b/wp-admin/js/inline-edit-tax.dev.js @@ -0,0 +1,150 @@ + +(function($) { +inlineEditTax = { + + init : function() { + var t = this, row = $('#inline-edit'); + + t.type = $('#the-list').attr('className').substr(5); + t.what = '#'+t.type+'-'; + + // get all editable rows + t.rows = $('tr.iedit'); + + // prepare the edit row + row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); }); + + $('a.cancel', row).click(function() { return inlineEditTax.revert(); }); + $('a.save', row).click(function() { return inlineEditTax.save(this); }); + $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); }); + + // add events + t.addEvents(t.rows); + + $('#posts-filter input[type="submit"]').click(function(e){ + if ( $('form#posts-filter tr.inline-editor').length > 0 ) + t.revert(); + }); + }, + + toggle : function(el) { + var t = this; + $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); + }, + + addEvents : function(r) { + r.each(function() { + $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; }); + }); + }, + + edit : function(id) { + var t = this, editRow, cat_parent, pageOpt; + t.revert(); + + if ( typeof(id) == 'object' ) + id = t.getId(id); + + editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); + $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + + if ( $(t.what+id).hasClass('alternate') ) + $(editRow).addClass('alternate'); + + $(t.what+id).hide().after(editRow); + + $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); + $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); + + // cat parents + cat_parent = $('.cat_parent', rowData).text(); + if ( cat_parent != '0' ) + $('select[name="parent"]', editRow).val(cat_parent); + + // remove the current parent and children from the parent dropdown + pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow); + if ( pageOpt.length > 0 ) { + var pageLevel = pageOpt[0].className.split('-')[1], nextPage, pageLoop = true, nextLevel; + while ( pageLoop ) { + nextPage = nextPage.next('option'); + if (nextPage.length == 0) break; + nextLevel = nextPage[0].className.split('-')[1]; + if ( nextLevel <= pageLevel ) { + pageLoop = false; + } else { + nextPage.remove(); + nextPage = pageOpt; + } + } + pageOpt.remove(); + } + + $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); + $('.ptitle', editRow).eq(0).focus(); + + return false; + }, + + save : function(id) { + var params, fields; + + if( typeof(id) == 'object' ) + id = this.getId(id); + + $('table.widefat .inline-edit-save .waiting').show(); + + params = { + action: 'inline-save-tax', + tax_type: this.type, + tax_ID: id + }; + + fields = $('#edit-'+id+' :input').fieldSerialize(); + params = fields + '&' + $.param(params); + + // make ajax request + $.post('admin-ajax.php', params, + function(r) { + + $('table.widefat .inline-edit-save .waiting').hide(); + + if (r) { + if ( -1 != r.indexOf(' 0 ) - t.revert(); - }); - }, - - toggle : function(el) { - var t = this; - - $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - - addEvents : function(r) { - r.each(function() { - $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; }); - }); - }, - - edit : function(id) { - var t = this; - t.revert(); - - if ( typeof(id) == 'object' ) - id = t.getId(id); - - var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); - - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); - - $(t.what+id).hide().after(editRow); - - $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); - $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); - - // cat parents - var cat_parent = $('.cat_parent', rowData).text(); - if ( cat_parent != '0' ) - $('select[name="parent"]', editRow).val(cat_parent); - - // remove the current parent and children from the parent dropdown - var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow); - if ( pageOpt.length > 0 ) { - var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true; - while ( pageLoop ) { - var nextPage = nextPage.next('option'); - if (nextPage.length == 0) break; - var nextLevel = nextPage[0].className.split('-')[1]; - if ( nextLevel <= pageLevel ) { - pageLoop = false; - } else { - nextPage.remove(); - nextPage = pageOpt; - } - } - pageOpt.remove(); - } - - $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).eq(0).focus(); - - return false; - }, - - save : function(id) { - if( typeof(id) == 'object' ) - id = this.getId(id); - - $('table.widefat .inline-edit-save .waiting').show(); - - var params = { - action: 'inline-save-tax', - tax_type: this.type, - tax_ID: id - }; - - var fields = $('#edit-'+id+' :input').fieldSerialize(); - params = fields + '&' + $.param(params); - - // make ajax request - $.post('admin-ajax.php', params, - function(r) { - - $('table.widefat .inline-edit-save .waiting').hide(); - - if (r) { - if ( -1 != r.indexOf('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("' ).text( name ); + } ); + } ); + }; + + $('#categorychecklist').wpList( { + alt: '', + what: 'link-category', + response: 'category-ajax-response', + addAfter: catAddAfter + } ); + + $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); + $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); + if ( 'pop' == getUserSetting('cats') ) + $('a[href="#categories-pop"]').click(); + + $('#category-add-toggle').click( function() { + $(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + categoryTabs.tabsClick( 1 ); + return false; + } ); + + $('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); +}); diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js index 3338d3cde..d9a0a316e 100644 --- a/wp-admin/js/link.js +++ b/wp-admin/js/link.js @@ -1,55 +1 @@ -jQuery(document).ready( function($) { - - jQuery('#link_name').focus(); - // postboxes - postboxes.add_postbox_toggles('link'); - - // category tabs - var categoryTabs = jQuery('#category-tabs').tabs(); - - // Ajax Cat - var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); - jQuery('#category-add-submit').click( function() { newCat.focus(); } ); - var noSyncChecks = false; // prophylactic. necessary? - var syncChecks = function() { - if ( noSyncChecks ) - return; - noSyncChecks = true; - var th = jQuery(this); - var c = th.is(':checked'); - var id = th.val().toString(); - jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); - noSyncChecks = false; - }; - var catAddAfter = function( r, s ) { - jQuery(s.what + ' response_data', r).each( function() { - var t = jQuery(jQuery(this).text()); - t.find( 'label' ).each( function() { - var th = jQuery(this); - var val = th.find('input').val(); - var id = th.find('input')[0].id - jQuery('#' + id).change( syncChecks ); - var name = jQuery.trim( th.text() ); - var o = jQuery( '' ).text( name ); - } ); - } ); - }; - jQuery('#categorychecklist').wpList( { - alt: '', - what: 'link-category', - response: 'category-ajax-response', - addAfter: catAddAfter - } ); - - $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); - $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); - if ( 'pop' == getUserSetting('cats') ) - $('a[href="#categories-pop"]').click(); - - jQuery('#category-add-toggle').click( function() { - jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); - categoryTabs.tabsClick( 1 ); - return false; - } ); - jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); -}); +jQuery(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('').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()}); \ No newline at end of file diff --git a/wp-admin/js/media-upload.dev.js b/wp-admin/js/media-upload.dev.js new file mode 100644 index 000000000..429dcf4b2 --- /dev/null +++ b/wp-admin/js/media-upload.dev.js @@ -0,0 +1,61 @@ +// send html to the post editor +function send_to_editor(h) { + var ed; + + if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { + ed.focus(); + if (tinymce.isIE) + ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); + + if ( h.indexOf('[caption') === 0 ) { + if ( ed.plugins.wpeditimage ) + h = ed.plugins.wpeditimage._do_shcode(h); + } else if ( h.indexOf('[gallery') === 0 ) { + if ( ed.plugins.wpgallery ) + h = ed.plugins.wpgallery._do_gallery(h); + } + + ed.execCommand('mceInsertContent', false, h); + + } else if ( typeof edInsertContent == 'function' ) { + edInsertContent(edCanvas, h); + } else { + jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h ); + } + + tb_remove(); +} + +// thickbox settings +jQuery(document).ready(function($) { + tb_position = function() { + var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width; + + if ( tbWindow.size() ) { + tbWindow.width( W - 50 ).height( H - 45 ); + $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); + tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); + if ( typeof document.body.style.maxWidth != 'undefined' ) + tbWindow.css({'top':'20px','margin-top':'0'}); + $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); + }; + + return $('a.thickbox').each( function() { + var href = $(this).attr('href'); + if ( ! href ) return; + href = href.replace(/&width=[0-9]+/g, ''); + href = href.replace(/&height=[0-9]+/g, ''); + $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); + }); + }; + + $('a.thickbox').click(function(){ + if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) { + tinyMCE.get('content').focus(); + tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple'); + } + }); + + $(window).resize( function() { tb_position() } ); +}); + diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index beb8c96b7..205dcd0da 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -1,62 +1 @@ -// send html to the post editor -function send_to_editor(h) { - if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { - ed.focus(); - if (tinymce.isIE) - ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); - - if ( h.indexOf('[caption') === 0 ) { - if ( ed.plugins.wpeditimage ) - h = ed.plugins.wpeditimage._do_shcode(h); - } else if ( h.indexOf('[gallery') === 0 ) { - if ( ed.plugins.wpgallery ) - h = ed.plugins.wpgallery._do_gallery(h); - } - - ed.execCommand('mceInsertContent', false, h); - - } else if ( typeof edInsertContent == 'function' ) { - edInsertContent(edCanvas, h); - } else { - jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h ); - } - - tb_remove(); -} - -// thickbox settings -jQuery(function($) { - tb_position = function() { - var tbWindow = $('#TB_window'); - var width = $(window).width(); - var H = $(window).height(); - var W = ( 720 < width ) ? 720 : width; - - if ( tbWindow.size() ) { - tbWindow.width( W - 50 ).height( H - 45 ); - $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); - tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); - if ( typeof document.body.style.maxWidth != 'undefined' ) - tbWindow.css({'top':'20px','margin-top':'0'}); - $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); - }; - - return $('a.thickbox').each( function() { - var href = $(this).attr('href'); - if ( ! href ) return; - href = href.replace(/&width=[0-9]+/g, ''); - href = href.replace(/&height=[0-9]+/g, ''); - $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); - }); - }; - - jQuery('a.thickbox').click(function(){ - if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) { - tinyMCE.get('content').focus(); - tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple'); - } - }); - - $(window).resize( function() { tb_position() } ); -}); - +function 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 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + + var stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(); + + function updateVisibility() { + if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { + $('#sticky').attr('checked', false); + $('#sticky-span').hide(); + } else { + $('#sticky-span').show(); + } + if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { + $('#password-span').hide(); + } else { + $('#password-span').show(); + } + } + + function updateText() { + var attemptedDate, originalDate, currentDate, publishOn; + + attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); + originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); + currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); + if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { + publishOn = postL10n.publishOnFuture; + $('#publish').val( postL10n.schedule ); + } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { + publishOn = postL10n.publishOn; + $('#publish').val( postL10n.publish ); + } else { + publishOn = postL10n.publishOnPast; + $('#publish').val( postL10n.update ); + } + if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack + $('#timestamp').html(stamp); + } else { + $('#timestamp').html( + publishOn + ' ' + + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + + $('#jj').val() + ', ' + + $('#aa').val() + ' @ ' + + $('#hh').val() + ':' + + $('#mn').val() + ' ' + ); + } + + if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { + $('#publish').val( postL10n.update ); + if ( $('#post_status option[value=publish]').length == 0 ) { + $('#post_status').append(''); + } + $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); + $('#post_status option[value=publish]').attr('selected', true); + $('.edit-post-status').hide(); + } else { + if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { + if ( $('#post_status option[value=publish]').length != 0 ) { + $('#post_status option[value=publish]').remove(); + $('#post_status').val($('#hidden_post_status').val()); + } + } else { + $('#post_status option[value=publish]').html( postL10n.published ); + } + $('.edit-post-status').show(); + } + $('#post-status-display').html($('#post_status :selected').text()); + if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { + $('#save-post').hide(); + } else { + $('#save-post').show(); + if ( $('#post_status :selected').val() == 'pending' ) { + $('#save-post').show().val( postL10n.savePending ); + } else { + $('#save-post').show().val( postL10n.saveDraft ); + } + } + } + + $('.edit-visibility').click(function () { + if ($('#post-visibility-select').is(":hidden")) { + updateVisibility(); + $('#post-visibility-select').slideDown("normal"); + $('.edit-visibility').hide(); + } + return false; + }); + + $('.cancel-post-visibility').click(function () { + $('#post-visibility-select').slideUp("normal"); + $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); + $('#post_password').val($('#hidden_post_password').val()); + $('#post-visibility-display').html(visibility); + $('.edit-visibility').show(); + updateText(); + return false; + }); + + $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels + $('#post-visibility-select').slideUp("normal"); + $('.edit-visibility').show(); + updateText(); + + $('#post-visibility-display').html( + postL10n[$('#post-visibility-select input:radio:checked').val()] + ); + + return false; + }); + + $('#post-visibility-select input:radio').change(function() { + updateVisibility(); + }); + + $('.edit-timestamp').click(function () { + if ($('#timestampdiv').is(":hidden")) { + $('#timestampdiv').slideDown("normal"); + $('.edit-timestamp').hide(); + } + + return false; + }); + + $('.cancel-timestamp').click(function() { + $('#timestampdiv').slideUp("normal"); + $('#mm').val($('#hidden_mm').val()); + $('#jj').val($('#hidden_jj').val()); + $('#aa').val($('#hidden_aa').val()); + $('#hh').val($('#hidden_hh').val()); + $('#mn').val($('#hidden_mn').val()); + $('.edit-timestamp').show(); + + updateText(); + return false; + }); + + $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels + $('#timestampdiv').slideUp("normal"); + $('.edit-timestamp').show(); + updateText(); + + return false; + }); + + $('.edit-post-status').click(function() { + if ($('#post-status-select').is(":hidden")) { + $('#post-status-select').slideDown("normal"); + $(this).hide(); + } + + return false; + }); + + $('.save-post-status').click(function() { + $('#post-status-select').slideUp("normal"); + $('.edit-post-status').show(); + updateText(); + return false; + }); + + $('.cancel-post-status').click(function() { + $('#post-status-select').slideUp("normal"); + $('#post_status').val($('#hidden_post_status').val()); + $('.edit-post-status').show(); + + updateText(); + return false; + }); + + // Custom Fields + jQuery('#the-list').wpList( { addAfter: function( xml, s ) { + $('table#list-table').show(); + if ( jQuery.isFunction( autosave_update_post_ID ) ) { + autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); + } + }, addBefore: function( s ) { + s.data += '&post_id=' + jQuery('#post_ID').val(); + return s; + } + }); + + // preview + $('#post-preview').click(function(e){ + if ( 1 > $('#post_ID').val() && autosaveFirst ) { + autosaveDelayPreview = true; + autosave(); + return false; + } + + $('input#wp-preview').val('dopreview'); + $('form#post').attr('target', 'wp-preview').submit().attr('target', ''); + $('input#wp-preview').val(''); + return false; + }); +}); diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index d0f4e5df7..696e32354 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -1,199 +1 @@ -jQuery(document).ready( function($) { - 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 stamp = $('#timestamp').html(); - - var visibility = $('#post-visibility-display').html(); - - function updateVisibility() { - if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { - $('#sticky').attr('checked', false); - $('#sticky-span').hide(); - } else { - $('#sticky-span').show(); - } - if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { - $('#password-span').hide(); - } else { - $('#password-span').show(); - } - } - - function updateText() { - var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); - var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); - var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); - if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { - var publishOn = postL10n.publishOnFuture; - $('#publish').val( postL10n.schedule ); - } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { - var publishOn = postL10n.publishOn; - $('#publish').val( postL10n.publish ); - } else { - var publishOn = postL10n.publishOnPast; - $('#publish').val( postL10n.update ); - } - if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack - $('#timestamp').html(stamp); - } else { - $('#timestamp').html( - publishOn + ' ' + - $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + - $('#jj').val() + ', ' + - $('#aa').val() + ' @ ' + - $('#hh').val() + ':' + - $('#mn').val() + ' ' - ); - } - - if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { - $('#publish').val( postL10n.update ); - if ( $('#post_status option[value=publish]').length == 0 ) { - $('#post_status').append(''); - } - $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); - $('#post_status option[value=publish]').attr('selected', true); - $('.edit-post-status').hide(); - } else { - if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { - if ( $('#post_status option[value=publish]').length != 0 ) { - $('#post_status option[value=publish]').remove(); - $('#post_status').val($('#hidden_post_status').val()); - } - } else { - $('#post_status option[value=publish]').html( postL10n.published ); - } - $('.edit-post-status').show(); - } - $('#post-status-display').html($('#post_status :selected').text()); - if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { - $('#save-post').hide(); - } else { - $('#save-post').show(); - if ( $('#post_status :selected').val() == 'pending' ) { - $('#save-post').show().val( postL10n.savePending ); - } else { - $('#save-post').show().val( postL10n.saveDraft ); - } - } - } - - $('.edit-visibility').click(function () { - if ($('#post-visibility-select').is(":hidden")) { - updateVisibility(); - $('#post-visibility-select').slideDown("normal"); - $('.edit-visibility').hide(); - } - return false; - }); - - $('.cancel-post-visibility').click(function () { - $('#post-visibility-select').slideUp("normal"); - $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); - $('#post_password').val($('#hidden_post_password').val()); - $('#post-visibility-display').html(visibility); - $('.edit-visibility').show(); - updateText(); - return false; - }); - - $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels - $('#post-visibility-select').slideUp("normal"); - $('.edit-visibility').show(); - updateText(); - - $('#post-visibility-display').html( - postL10n[$('#post-visibility-select input:radio:checked').val()] - ); - - return false; - }); - - $('#post-visibility-select input:radio').change(function() { - updateVisibility(); - }); - - $('.edit-timestamp').click(function () { - if ($('#timestampdiv').is(":hidden")) { - $('#timestampdiv').slideDown("normal"); - $('.edit-timestamp').hide(); - } - - return false; - }); - - $('.cancel-timestamp').click(function() { - $('#timestampdiv').slideUp("normal"); - $('#mm').val($('#hidden_mm').val()); - $('#jj').val($('#hidden_jj').val()); - $('#aa').val($('#hidden_aa').val()); - $('#hh').val($('#hidden_hh').val()); - $('#mn').val($('#hidden_mn').val()); - $('.edit-timestamp').show(); - - updateText(); - return false; - }); - - $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels - $('#timestampdiv').slideUp("normal"); - $('.edit-timestamp').show(); - updateText(); - - return false; - }); - - $('.edit-post-status').click(function() { - if ($('#post-status-select').is(":hidden")) { - $('#post-status-select').slideDown("normal"); - $(this).hide(); - } - - return false; - }); - - $('.save-post-status').click(function() { - $('#post-status-select').slideUp("normal"); - $('.edit-post-status').show(); - updateText(); - return false; - }); - - $('.cancel-post-status').click(function() { - $('#post-status-select').slideUp("normal"); - $('#post_status').val($('#hidden_post_status').val()); - $('.edit-post-status').show(); - - updateText(); - return false; - }); - - // Custom Fields - jQuery('#the-list').wpList( { addAfter: function( xml, s ) { - $('table#list-table').show(); - if ( jQuery.isFunction( autosave_update_post_ID ) ) { - autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); - } - }, addBefore: function( s ) { - s.data += '&post_id=' + jQuery('#post_ID').val(); - return s; - } - }); - - // preview - $('#post-preview').click(function(e){ - if ( 1 > $('#post_ID').val() && autosaveFirst ) { - autosaveDelayPreview = true; - autosave(); - return false; - } - - $('input#wp-preview').val('dopreview'); - $('form#post').attr('target', 'wp-preview').submit().attr('target', ''); - $('input#wp-preview').val(''); - return false; - }); -}); +jQuery(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+" "+e("#mm option[value="+e("#mm").val()+"]").text()+" "+e("#jj").val()+", "+e("#aa").val()+" @ "+e("#hh").val()+":"+e("#mn").val()+" ")}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('")}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})}); \ No newline at end of file diff --git a/wp-admin/js/password-strength-meter.dev.js b/wp-admin/js/password-strength-meter.dev.js new file mode 100644 index 000000000..0adb4ecc9 --- /dev/null +++ b/wp-admin/js/password-strength-meter.dev.js @@ -0,0 +1,21 @@ +// Password strength meter +function passwordStrength(password,username) { + var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, symbolSize = 0, natLog, score; + + //password < 4 + if (password.length < 4 ) { return shortPass }; + + //password == username + if (password.toLowerCase()==username.toLowerCase()) return badPass; + + if (password.match(/[0-9]/)) symbolSize +=10; + if (password.match(/[a-z]/)) symbolSize +=26; + if (password.match(/[A-Z]/)) symbolSize +=26; + if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31; + + natLog = Math.log( Math.pow(symbolSize,password.length) ); + score = natLog / Math.LN2; + if (score < 40 ) return badPass + if (score < 56 ) return goodPass + return strongPass; +} diff --git a/wp-admin/js/password-strength-meter.js b/wp-admin/js/password-strength-meter.js index 516a3e251..f79937ec9 100644 --- a/wp-admin/js/password-strength-meter.js +++ b/wp-admin/js/password-strength-meter.js @@ -1,23 +1 @@ -// Password strength meter - -function passwordStrength(password,username) { - var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4; - - //password < 4 - if (password.length < 4 ) { return shortPass }; - - //password == username - if (password.toLowerCase()==username.toLowerCase()) return badPass; - - var symbolSize = 0; - if (password.match(/[0-9]/)) symbolSize +=10; - if (password.match(/[a-z]/)) symbolSize +=26; - if (password.match(/[A-Z]/)) symbolSize +=26; - if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31; - - var natLog = Math.log( Math.pow(symbolSize,password.length) ); - var score = natLog / Math.LN2; - if (score < 40 ) return badPass - if (score < 56 ) return goodPass - return strongPass; -} \ No newline at end of file +function 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}; \ No newline at end of file diff --git a/wp-admin/js/plugin-install.dev.js b/wp-admin/js/plugin-install.dev.js new file mode 100644 index 000000000..136f00e14 --- /dev/null +++ b/wp-admin/js/plugin-install.dev.js @@ -0,0 +1,48 @@ +/* Plugin Browser Thickbox related JS*/ +jQuery(document).ready(function($) { + var thickDims = function() { + var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width; + + if ( tbWindow.size() ) { + tbWindow.width( W - 50 ).height( H - 45 ); + $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); + tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); + if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) ) + tbWindow.css({'top':'20px','margin-top':'0'}); + }; + + return $('a.thickbox').each( function() { + var href = $(this).attr('href'); + if ( ! href ) + return; + href = href.replace(/&width=[0-9]+/g, ''); + href = href.replace(/&height=[0-9]+/g, ''); + $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); + }); + }; + + thickDims().click( function() { + $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); + $('#TB_ajaxWindowTitle').html('' + plugininstallL10n.plugin_information + ' ' + $(this).attr('title') ); + return false; + }); + + $(window).resize( function() { tb_position() } ); + + /* Plugin install related JS*/ + $('#install-plugins tbody.plugins tr').click( function() { + $(this).find('.action-links a.onclick').click(); + return false; + }); + + $('#plugin-information #sidemenu a').click( function() { + var tab = $(this).attr('name'); + //Flip the tab + $('#plugin-information-header a.current').removeClass('current'); + $(this).addClass('current'); + //Flip the content. + $('#section-holder div.section').hide(); //Hide 'em all + $('#section-' + tab).show(); + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/plugin-install.js b/wp-admin/js/plugin-install.js index ed7659d41..1e7c4fe47 100644 --- a/wp-admin/js/plugin-install.js +++ b/wp-admin/js/plugin-install.js @@ -1,53 +1 @@ -/* Plugin Browser Thickbox related JS*/ -jQuery(function($) { - var thickDims = function() { - var tbWindow = $('#TB_window'); - var width = $(window).width(); - var H = $(window).height(); - var W = ( 720 < width ) ? 720 : width; - - if ( tbWindow.size() ) { - tbWindow.width( W - 50 ).height( H - 45 ); - $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); - tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); - if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) ) - tbWindow.css({'top':'20px','margin-top':'0'}); - }; - - return $('a.thickbox').each( function() { - var href = $(this).attr('href'); - if ( ! href ) - return; - href = href.replace(/&width=[0-9]+/g, ''); - href = href.replace(/&height=[0-9]+/g, ''); - $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); - }); - }; - - thickDims().click( function() { - $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); - $('#TB_ajaxWindowTitle').html('' + plugininstallL10n.plugin_information + ' ' + $(this).attr('title') ); - return false; - }); - - $(window).resize( function() { tb_position() } ); -}); - -/* Plugin install related JS*/ -jQuery(function($) { - $('#install-plugins tbody.plugins tr').click( function() { - $(this).find('.action-links a.onclick').click(); - return false; - }); - - $('#plugin-information #sidemenu a').click( function() { - var tab = $(this).attr('name'); - //Flip the tab - $('#plugin-information-header a.current').removeClass('current'); - $(this).addClass('current'); - //Flip the content. - $('#section-holder div.section').hide(); //Hide 'em all - $('#section-' + tab).show(); - return false; - }); -}); \ No newline at end of file +jQuery(document).ready(function(b){var a=function(){var f=b("#TB_window"),e=b(window).width(),d=b(window).height(),c=(720"+plugininstallL10n.plugin_information+" "+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})}); \ No newline at end of file diff --git a/wp-admin/js/post.dev.js b/wp-admin/js/post.dev.js new file mode 100644 index 000000000..666d30264 --- /dev/null +++ b/wp-admin/js/post.dev.js @@ -0,0 +1,490 @@ +// this file contains all the scripts used in the post/edit page + +// return an array with any duplicate, whitespace or values removed +function array_unique_noempty(a) { + var out = []; + jQuery.each( a, function(key, val) { + val = jQuery.trim(val); + if ( val && jQuery.inArray(val, out) == -1 ) + out.push(val); + } ); + return out; +} + +function new_tag_remove_tag() { + var id = jQuery( this ).attr( 'id' ), num = id.split('-check-num-')[1], taxbox = jQuery(this).parents('.tagsdiv'), current_tags = taxbox.find( '.the-tags' ).val().split(','), new_tags = []; + delete current_tags[num]; + + jQuery.each( current_tags, function(key, val) { + val = jQuery.trim(val); + if ( val ) { + new_tags.push(val); + } + }); + + taxbox.find('.the-tags').val( new_tags.join(',').replace(/\s*,+\s*/, ',').replace(/,+/, ',').replace(/,+\s+,+/, ',').replace(/,+\s*$/, '').replace(/^\s*,+/, '') ); + + tag_update_quickclicks(taxbox); + return false; +} + +function tag_update_quickclicks(taxbox) { + if ( jQuery(taxbox).find('.the-tags').length == 0 ) + return; + + var current_tags = jQuery(taxbox).find('.the-tags').val().split(','); + jQuery(taxbox).find('.tagchecklist').empty(); + shown = false; + + jQuery.each( current_tags, function( key, val ) { + var txt; + + val = jQuery.trim(val); + if ( !val.match(/^\s+$/) && '' != val ) { + var button_id = jQuery(taxbox).attr('id') + '-check-num-' + key; + txt = 'X ' + val + ' '; + jQuery(taxbox).find('.tagchecklist').append(txt); + jQuery( '#' + button_id ).click( new_tag_remove_tag ); + } + }); + if ( shown ) + jQuery(taxbox).find('.tagchecklist').prepend(''+postL10n.tagsUsed+'
'); +} + +function tag_flush_to_text(id, a) { + a = a || false; + var taxbox, text, tags, newtags; + + taxbox = jQuery('#'+id); + text = a ? jQuery(a).text() : taxbox.find('input.newtag').val(); + + // is the input box empty (i.e. showing the 'Add new tag' tip)? + if ( taxbox.find('input.newtag').hasClass('form-input-tip') && ! a ) + return false; + + tags = taxbox.find('.the-tags').val(); + newtags = tags ? tags + ',' + text : text; + + // massage + newtags = newtags.replace(/\s+,+\s*/g, ',').replace(/,+/g, ',').replace(/,+\s+,+/g, ',').replace(/,+\s*$/g, '').replace(/^\s*,+/g, ''); + newtags = array_unique_noempty(newtags.split(',')).join(','); + taxbox.find('.the-tags').val(newtags); + tag_update_quickclicks(taxbox); + + if ( ! a ) + taxbox.find('input.newtag').val('').focus(); + + return false; +} + +function tag_save_on_publish() { + jQuery('.tagsdiv').each( function(i) { + if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') ) + tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id')); + } ); +} + +function tag_press_key( e ) { + if ( 13 == e.which ) { + tag_flush_to_text(jQuery(e.target).parents('.tagsdiv').attr('id')); + return false; + } +}; + +function tag_init() { + + jQuery('.ajaxtag').show(); + jQuery('.tagsdiv').each( function(i) { + tag_update_quickclicks(this); + } ); + + // add the quickadd form + 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' ); + } + }); + + // auto-save tags on post save/publish + jQuery('#publish').click( tag_save_on_publish ); + jQuery('#save-post').click( tag_save_on_publish ); + + // catch the enter key + jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); +} + +(function($){ + tagCloud = { + init : function() { + $('.tagcloud-link').click(function(){tagCloud.get($(this).attr('id')); $(this).unbind().click(function(){return false;}); return false;}); + }, + + get : function(id) { + var tax = id.substr(id.indexOf('-')+1); + + $.post('admin-ajax.php', {'action':'get-tagcloud','tax':tax}, function(r, stat) { + if ( 0 == r || 'success' != stat ) + r = wpAjax.broken; + + r = $('

'+r+'

'); + $('a', r).click(function(){ + var id = $(this).parents('p').attr('id'); + tag_flush_to_text(id.substr(id.indexOf('-')+1), this); + return false; + }); + + $('#'+id).after(r); + }); + } + } +})(jQuery); + +jQuery(document).ready( function($) { + var categoryTabs, newCat, newCatParent = false, newCatParentOption = false, noSyncChecks = false, syncChecks, catAddAfter; + + tagCloud.init(); + + // postboxes + postboxes.add_postbox_toggles('post'); + + // Editable slugs + make_slugedit_clickable(); + + // prepare the tag UI + tag_init(); + + $('#title').blur( function() { if ( ($("#post_ID").val() > 0) || ($("#title").val().length == 0) ) return; autosave(); } ); + + // auto-suggest stuff + $('.newtag').each(function(){ + var tax = $(this).parents('div.tagsdiv').attr('id'); + $(this).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); + }); + + // category tabs + categoryTabs =jQuery('#category-tabs').tabs(); + + // Ajax Cat + newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } ); + $('#category-add-sumbit').click( function() { newCat.focus(); } ); + + syncChecks = function() { + if ( noSyncChecks ) + return; + noSyncChecks = true; + var th = jQuery(this), c = th.is(':checked'), id = th.val().toString(); + $('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + + popularCats = $('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(','); + catAddBefore = function( s ) { + s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize(); + return s; + }; + + catAddAfter = function( r, s ) { + if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); + if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); + $(s.what + ' response_data', r).each( function() { + var t = $($(this).text()); + t.find( 'label' ).each( function() { + var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name, o; + $('#' + id).change( syncChecks ).change(); + if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) + return; + name = $.trim( th.text() ); + o = $( '' ).text( name ); + newCatParent.prepend( o ); + } ); + newCatParentOption.attr( 'selected', true ); + } ); + }; + + $('#categorychecklist').wpList( { + alt: '', + response: 'category-ajax-response', + addBefore: catAddBefore, + addAfter: catAddAfter + } ); + + $('#category-add-toggle').click( function() { + $(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + // categoryTabs.tabs( 'select', '#categories-all' ); // this is broken (in the UI beta?) + categoryTabs.find( 'a[href="#categories-all"]' ).click(); + $('#newcat').focus(); + return false; + } ); + + $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); + $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); + if ( 'pop' == getUserSetting('cats') ) + $('a[href="#categories-pop"]').click(); + + $('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(), sticky = ''; + + function updateVisibility() { + if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { + $('#sticky').attr('checked', false); + $('#sticky-span').hide(); + } else { + $('#sticky-span').show(); + } + if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { + $('#password-span').hide(); + } else { + $('#password-span').show(); + } + } + + function updateText() { + var attemptedDate, originalDate, currentDate, publishOn; + + attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); + originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); + currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); + if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { + publishOn = postL10n.publishOnFuture; + $('#publish').val( postL10n.schedule ); + } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { + publishOn = postL10n.publishOn; + $('#publish').val( postL10n.publish ); + } else { + publishOn = postL10n.publishOnPast; + $('#publish').val( postL10n.update ); + } + if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack + $('#timestamp').html(stamp); + } else { + $('#timestamp').html( + publishOn + ' ' + + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + + $('#jj').val() + ', ' + + $('#aa').val() + ' @ ' + + $('#hh').val() + ':' + + $('#mn').val() + ' ' + ); + } + + if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { + $('#publish').val( postL10n.update ); + if ( $('#post_status option[value=publish]').length == 0 ) { + $('#post_status').append(''); + } + $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); + $('#post_status option[value=publish]').attr('selected', true); + $('.edit-post-status').hide(); + } else { + if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { + if ( $('#post_status option[value=publish]').length != 0 ) { + $('#post_status option[value=publish]').remove(); + $('#post_status').val($('#hidden_post_status').val()); + } + } else { + $('#post_status option[value=publish]').html( postL10n.published ); + } + $('.edit-post-status').show(); + } + $('#post-status-display').html($('#post_status :selected').text()); + if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { + $('#save-post').hide(); + } else { + $('#save-post').show(); + if ( $('#post_status :selected').val() == 'pending' ) { + $('#save-post').show().val( postL10n.savePending ); + } else { + $('#save-post').show().val( postL10n.saveDraft ); + } + } + } + + $('.edit-visibility').click(function () { + if ($('#post-visibility-select').is(":hidden")) { + updateVisibility(); + $('#post-visibility-select').slideDown("normal"); + $('.edit-visibility').hide(); + } + return false; + }); + + $('.cancel-post-visibility').click(function () { + $('#post-visibility-select').slideUp("normal"); + $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); + $('#post_password').val($('#hidden_post_password').val()); + $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked')); + $('#post-visibility-display').html(visibility); + $('.edit-visibility').show(); + updateText(); + return false; + }); + + $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels + $('#post-visibility-select').slideUp("normal"); + $('.edit-visibility').show(); + updateText(); + if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { + $('#sticky').attr('checked', false); + } + + if ( true == $('#sticky').attr('checked') ) { + sticky = 'Sticky'; + } else { + sticky = ''; + } + + $('#post-visibility-display').html( + postL10n[$('#post-visibility-select input:radio:checked').val() + sticky] + ); + + return false; + }); + + $('#post-visibility-select input:radio').change(function() { + updateVisibility(); + }); + + $('.edit-timestamp').click(function () { + if ($('#timestampdiv').is(":hidden")) { + $('#timestampdiv').slideDown("normal"); + $('.edit-timestamp').hide(); + } + + return false; + }); + + $('.cancel-timestamp').click(function() { + $('#timestampdiv').slideUp("normal"); + $('#mm').val($('#hidden_mm').val()); + $('#jj').val($('#hidden_jj').val()); + $('#aa').val($('#hidden_aa').val()); + $('#hh').val($('#hidden_hh').val()); + $('#mn').val($('#hidden_mn').val()); + $('.edit-timestamp').show(); + updateText(); + return false; + }); + + $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels + $('#timestampdiv').slideUp("normal"); + $('.edit-timestamp').show(); + updateText(); + + return false; + }); + + $('.edit-post-status').click(function() { + if ($('#post-status-select').is(":hidden")) { + $('#post-status-select').slideDown("normal"); + $(this).hide(); + } + + return false; + }); + + $('.save-post-status').click(function() { + $('#post-status-select').slideUp("normal"); + $('.edit-post-status').show(); + updateText(); + return false; + }); + + $('.cancel-post-status').click(function() { + $('#post-status-select').slideUp("normal"); + $('#post_status').val($('#hidden_post_status').val()); + $('.edit-post-status').show(); + updateText(); + return false; + }); + + // Custom Fields + jQuery('#the-list').wpList( { addAfter: function( xml, s ) { + $('table#list-table').show(); + if ( jQuery.isFunction( autosave_update_post_ID ) ) { + autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); + } + }, addBefore: function( s ) { + s.data += '&post_id=' + jQuery('#post_ID').val(); + return s; + } + }); + + // preview + $('#post-preview').click(function(e){ + if ( 1 > $('#post_ID').val() && autosaveFirst ) { + autosaveDelayPreview = true; + autosave(); + return false; + } + + $('input#wp-preview').val('dopreview'); + $('form#post').attr('target', 'wp-preview').submit().attr('target', ''); + $('input#wp-preview').val(''); + return false; + }); + +}); + +(function($){ + commentsBox = { + st : 0, + + get : function(total, num) { + var st = this.st, data; + if ( ! num ) + num = 20; + + this.st += num; + this.total = total; + $('.waiting').show(); + + data = { + 'action' : 'get-comments', + 'mode' : 'single', + '_ajax_nonce' : $('#add_comment_nonce').val(), + 'post_ID' : $('#post_ID').val(), + 'start' : st, + 'num' : num + }; + + $.post('admin-ajax.php', data, + function(r) { + r = wpAjax.parseAjaxResponse(r); + $('#commentstatusdiv .widefat').show(); + $('.waiting').hide(); + + if ( 'object' == typeof r && r.responses[0] ) { + $('#the-comment-list').append( r.responses[0].data ); + + theList = theExtraList = null; + $("a[className*=':']").unbind(); + setCommentsList(); + + if ( commentsBox.st > commentsBox.total ) + $('#show-comments').hide(); + else + $('#show-comments').html(postL10n.showcomm); + return; + } else if ( 1 == r ) { + $('#show-comments').parent().html(postL10n.endcomm); + return; + } + + $('#the-comment-list').append(''+wpAjax.broken+''); + } + ); + + return false; + } + }; + +})(jQuery); + diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 5b3782df5..f09760cf3 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -1,491 +1 @@ -// this file contains all the scripts used in the post/edit page - -// return an array with any duplicate, whitespace or values removed -function array_unique_noempty(a) { - var out = []; - jQuery.each( a, function(key, val) { - val = jQuery.trim(val); - if ( val && jQuery.inArray(val, out) == -1 ) - out.push(val); - } ); - return out; -} - -function new_tag_remove_tag() { - var id = jQuery( this ).attr( 'id' ); - var num = id.split('-check-num-')[1]; - var taxbox = jQuery(this).parents('.tagsdiv'); - var current_tags = taxbox.find( '.the-tags' ).val().split(','); - delete current_tags[num]; - var new_tags = []; - - jQuery.each( current_tags, function(key, val) { - val = jQuery.trim(val); - if ( val ) { - new_tags.push(val); - } - }); - - taxbox.find('.the-tags').val( new_tags.join(',').replace(/\s*,+\s*/, ',').replace(/,+/, ',').replace(/,+\s+,+/, ',').replace(/,+\s*$/, '').replace(/^\s*,+/, '') ); - - tag_update_quickclicks(taxbox); - return false; -} - -function tag_update_quickclicks(taxbox) { - if ( jQuery(taxbox).find('.the-tags').length == 0 ) - return; - - var current_tags = jQuery(taxbox).find('.the-tags').val().split(','); - jQuery(taxbox).find('.tagchecklist').empty(); - shown = false; - - jQuery.each( current_tags, function( key, val ) { - val = jQuery.trim(val); - if ( !val.match(/^\s+$/) && '' != val ) { - var button_id = jQuery(taxbox).attr('id') + '-check-num-' + key; - txt = 'X ' + val + ' '; - jQuery(taxbox).find('.tagchecklist').append(txt); - jQuery( '#' + button_id ).click( new_tag_remove_tag ); - } - }); - if ( shown ) - jQuery(taxbox).find('.tagchecklist').prepend(''+postL10n.tagsUsed+'
'); -} - -function tag_flush_to_text(id, a) { - a = a || false; - var taxbox = jQuery('#'+id); - var text = a ? jQuery(a).text() : taxbox.find('input.newtag').val(); - - // is the input box empty (i.e. showing the 'Add new tag' tip)? - if ( taxbox.find('input.newtag').hasClass('form-input-tip') && ! a ) - return false; - - var tags = taxbox.find('.the-tags').val(); - var newtags = tags ? tags + ',' + text : text; - - // massage - newtags = newtags.replace(/\s+,+\s*/g, ',').replace(/,+/g, ',').replace(/,+\s+,+/g, ',').replace(/,+\s*$/g, '').replace(/^\s*,+/g, ''); - newtags = array_unique_noempty(newtags.split(',')).join(','); - taxbox.find('.the-tags').val(newtags); - tag_update_quickclicks(taxbox); - - if ( ! a ) - taxbox.find('input.newtag').val('').focus(); - - return false; -} - -function tag_save_on_publish() { - jQuery('.tagsdiv').each( function(i) { - if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') ) - tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id')); - } ); -} - -function tag_press_key( e ) { - if ( 13 == e.which ) { - tag_flush_to_text(jQuery(e.target).parents('.tagsdiv').attr('id')); - return false; - } -}; - -function tag_init() { - - jQuery('.ajaxtag').show(); - jQuery('.tagsdiv').each( function(i) { - tag_update_quickclicks(this); - } ); - - // add the quickadd form - 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' ); - } - }); - - // auto-save tags on post save/publish - jQuery('#publish').click( tag_save_on_publish ); - jQuery('#save-post').click( tag_save_on_publish ); - - // catch the enter key - jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); -} - -(function($){ - tagCloud = { - init : function() { - $('.tagcloud-link').click(function(){tagCloud.get($(this).attr('id')); $(this).unbind().click(function(){return false;}); return false;}); - }, - - get : function(id) { - tax = id.substr(id.indexOf('-')+1); - - $.post('admin-ajax.php', {'action':'get-tagcloud','tax':tax}, function(r, stat) { - if ( 0 == r || 'success' != stat ) - r = wpAjax.broken; - - r = $('

'+r+'

'); - $('a', r).click(function(){ - var id = $(this).parents('p').attr('id'); - tag_flush_to_text(id.substr(id.indexOf('-')+1), this); - return false; - }); - - $('#'+id).after(r); - }); - } - } -})(jQuery); - -jQuery(document).ready( function($) { - tagCloud.init(); - - // postboxes - postboxes.add_postbox_toggles('post'); - - // Editable slugs - make_slugedit_clickable(); - - // prepare the tag UI - tag_init(); - - jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); - - // auto-suggest stuff - jQuery('.newtag').each(function(){ - var tax = $(this).parents('div.tagsdiv').attr('id'); - $(this).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); - }); - - // category tabs - var categoryTabs =jQuery('#category-tabs').tabs(); - - // Ajax Cat - var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); - jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); - var newCatParent = false; - var newCatParentOption = false; - var noSyncChecks = false; // prophylactic. necessary? - var syncChecks = function() { - if ( noSyncChecks ) - return; - noSyncChecks = true; - var th = jQuery(this); - var c = th.is(':checked'); - var id = th.val().toString(); - jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); - noSyncChecks = false; - }; - var popularCats = jQuery('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(','); - var catAddBefore = function( s ) { - s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize(); - return s; - }; - var catAddAfter = function( r, s ) { - if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); - if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); - jQuery(s.what + ' response_data', r).each( function() { - var t = jQuery(jQuery(this).text()); - t.find( 'label' ).each( function() { - var th = jQuery(this); - var val = th.find('input').val(); - var id = th.find('input')[0].id - jQuery('#' + id).change( syncChecks ).change(); - if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) - return; - var name = jQuery.trim( th.text() ); - var o = jQuery( '' ).text( name ); - newCatParent.prepend( o ); - } ); - newCatParentOption.attr( 'selected', true ); - } ); - }; - jQuery('#categorychecklist').wpList( { - alt: '', - response: 'category-ajax-response', - addBefore: catAddBefore, - addAfter: catAddAfter - } ); - jQuery('#category-add-toggle').click( function() { - jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); - // categoryTabs.tabs( 'select', '#categories-all' ); // this is broken (in the UI beta?) - categoryTabs.find( 'a[href="#categories-all"]' ).click(); - jQuery('#newcat').focus(); - return false; - } ); - - $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); - $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); - if ( 'pop' == getUserSetting('cats') ) - $('a[href="#categories-pop"]').click(); - - jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(); - var stamp = $('#timestamp').html(); - var visibility = $('#post-visibility-display').html(); - var sticky = ''; - - function updateVisibility() { - if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { - $('#sticky').attr('checked', false); - $('#sticky-span').hide(); - } else { - $('#sticky-span').show(); - } - if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { - $('#password-span').hide(); - } else { - $('#password-span').show(); - } - } - - function updateText() { - var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); - var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); - var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); - if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { - var publishOn = postL10n.publishOnFuture; - $('#publish').val( postL10n.schedule ); - } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { - var publishOn = postL10n.publishOn; - $('#publish').val( postL10n.publish ); - } else { - var publishOn = postL10n.publishOnPast; - $('#publish').val( postL10n.update ); - } - if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack - $('#timestamp').html(stamp); - } else { - $('#timestamp').html( - publishOn + ' ' + - $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + - $('#jj').val() + ', ' + - $('#aa').val() + ' @ ' + - $('#hh').val() + ':' + - $('#mn').val() + ' ' - ); - } - - if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { - $('#publish').val( postL10n.update ); - if ( $('#post_status option[value=publish]').length == 0 ) { - $('#post_status').append(''); - } - $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); - $('#post_status option[value=publish]').attr('selected', true); - $('.edit-post-status').hide(); - } else { - if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { - if ( $('#post_status option[value=publish]').length != 0 ) { - $('#post_status option[value=publish]').remove(); - $('#post_status').val($('#hidden_post_status').val()); - } - } else { - $('#post_status option[value=publish]').html( postL10n.published ); - } - $('.edit-post-status').show(); - } - $('#post-status-display').html($('#post_status :selected').text()); - if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { - $('#save-post').hide(); - } else { - $('#save-post').show(); - if ( $('#post_status :selected').val() == 'pending' ) { - $('#save-post').show().val( postL10n.savePending ); - } else { - $('#save-post').show().val( postL10n.saveDraft ); - } - } - } - - $('.edit-visibility').click(function () { - if ($('#post-visibility-select').is(":hidden")) { - updateVisibility(); - $('#post-visibility-select').slideDown("normal"); - $('.edit-visibility').hide(); - } - return false; - }); - - $('.cancel-post-visibility').click(function () { - $('#post-visibility-select').slideUp("normal"); - $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); - $('#post_password').val($('#hidden_post_password').val()); - $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked')); - $('#post-visibility-display').html(visibility); - $('.edit-visibility').show(); - updateText(); - return false; - }); - - $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels - $('#post-visibility-select').slideUp("normal"); - $('.edit-visibility').show(); - updateText(); - if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { - $('#sticky').attr('checked', false); - } - - if ( true == $('#sticky').attr('checked') ) { - sticky = 'Sticky'; - } else { - sticky = ''; - } - - $('#post-visibility-display').html( - postL10n[$('#post-visibility-select input:radio:checked').val() + sticky] - ); - - return false; - }); - - $('#post-visibility-select input:radio').change(function() { - updateVisibility(); - }); - - $('.edit-timestamp').click(function () { - if ($('#timestampdiv').is(":hidden")) { - $('#timestampdiv').slideDown("normal"); - $('.edit-timestamp').hide(); - } - - return false; - }); - - $('.cancel-timestamp').click(function() { - $('#timestampdiv').slideUp("normal"); - $('#mm').val($('#hidden_mm').val()); - $('#jj').val($('#hidden_jj').val()); - $('#aa').val($('#hidden_aa').val()); - $('#hh').val($('#hidden_hh').val()); - $('#mn').val($('#hidden_mn').val()); - $('.edit-timestamp').show(); - updateText(); - return false; - }); - - $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels - $('#timestampdiv').slideUp("normal"); - $('.edit-timestamp').show(); - updateText(); - - return false; - }); - - $('.edit-post-status').click(function() { - if ($('#post-status-select').is(":hidden")) { - $('#post-status-select').slideDown("normal"); - $(this).hide(); - } - - return false; - }); - - $('.save-post-status').click(function() { - $('#post-status-select').slideUp("normal"); - $('.edit-post-status').show(); - updateText(); - return false; - }); - - $('.cancel-post-status').click(function() { - $('#post-status-select').slideUp("normal"); - $('#post_status').val($('#hidden_post_status').val()); - $('.edit-post-status').show(); - updateText(); - return false; - }); - - // Custom Fields - jQuery('#the-list').wpList( { addAfter: function( xml, s ) { - $('table#list-table').show(); - if ( jQuery.isFunction( autosave_update_post_ID ) ) { - autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); - } - }, addBefore: function( s ) { - s.data += '&post_id=' + jQuery('#post_ID').val(); - return s; - } - }); - - // preview - $('#post-preview').click(function(e){ - if ( 1 > $('#post_ID').val() && autosaveFirst ) { - autosaveDelayPreview = true; - autosave(); - return false; - } - - $('input#wp-preview').val('dopreview'); - $('form#post').attr('target', 'wp-preview').submit().attr('target', ''); - $('input#wp-preview').val(''); - return false; - }); - -}); - -(function($){ - commentsBox = { - st : 0, - - get : function(total, num) { - var st = this.st; - if ( ! num ) - num = 20; - - this.st += num; - this.total = total; - $('.waiting').show(); - - var data = { - 'action' : 'get-comments', - 'mode' : 'single', - '_ajax_nonce' : $('#add_comment_nonce').val(), - 'post_ID' : $('#post_ID').val(), - 'start' : st, - 'num' : num - }; - - $.post('admin-ajax.php', data, - function(r) { - var r = wpAjax.parseAjaxResponse(r); - $('#commentstatusdiv .widefat').show(); - $('.waiting').hide(); - - if ( 'object' == typeof r && r.responses[0] ) { - $('#the-comment-list').append( r.responses[0].data ); - - theList = theExtraList = null; - $("a[className*=':']").unbind(); - setCommentsList(); - - if ( commentsBox.st > commentsBox.total ) - $('#show-comments').hide(); - else - $('#show-comments').html(postL10n.showcomm); - return; - } else if ( 1 == r ) { - $('#show-comments').parent().html(postL10n.endcomm); - return; - } - - $('#the-comment-list').append(''+wpAjax.broken+''); - } - ); - - return false; - } - }; - -})(jQuery); - +function 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='X '+f+" ";jQuery(b).find(".tagchecklist").append(c);jQuery("#"+d).click(new_tag_remove_tag)}});if(shown){jQuery(b).find(".tagchecklist").prepend(""+postL10n.tagsUsed+"
")}}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('

'+e+"

");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('').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+" "+f("#mm option[value="+f("#mm").val()+"]").text()+" "+f("#jj").val()+", "+f("#aa").val()+" @ "+f("#hh").val()+":"+f("#mn").val()+" ")}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('")}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(''+wpAjax.broken+"")});return false}}})(jQuery); \ No newline at end of file diff --git a/wp-admin/js/postbox.dev.js b/wp-admin/js/postbox.dev.js new file mode 100644 index 000000000..8ff2bae73 --- /dev/null +++ b/wp-admin/js/postbox.dev.js @@ -0,0 +1,104 @@ +(function($) { + postboxes = { + add_postbox_toggles : function(page,args) { + $('.postbox h3, .postbox .handlediv').click( function() { + $($(this).parent().get(0)).toggleClass('closed'); + postboxes.save_state(page); + } ); + $('.postbox h3 a').click( function(e) { + e.stopPropagation(); + } ); + + $('.hide-postbox-tog').click( function() { + var box = jQuery(this).val(); + if ( jQuery(this).attr('checked') ) { + jQuery('#' + box).show(); + if ( $.isFunction( postboxes.pbshow ) ) + postboxes.pbshow( box ); + + } else { + jQuery('#' + box).hide(); + if ( $.isFunction( postboxes.pbhide ) ) + postboxes.pbhide( box ); + + } + postboxes.save_state(page); + } ); + + this.expandSidebar(); + this.init(page,args); + }, + + expandSidebar : function(doIt) { + if ( doIt || $('#side-sortables > .postbox:visible').length ) { + if ( ! $('#post-body').hasClass('has-sidebar') ) { + $('#post-body').addClass('has-sidebar'); + var h = Math.min( $('#post-body').height(), 300 ); + $('#side-sortables').css({'minHeight':h+'px','height':'auto'}); + } + } else { + $('#post-body').removeClass('has-sidebar'); + $('#side-sortables').css({'minHeight':'0'}); + if ( $.browser.msie && $.browser.version.charAt(0) == 7 ) + $('#side-sortables').css({'height':'0'}); + } + }, + + init : function(page, args) { + $.extend( this, args || {} ); + $('#wpbody-content').css('overflow','hidden'); + $('.meta-box-sortables').sortable( { + placeholder: 'sortable-placeholder', + connectWith: [ '.meta-box-sortables' ], + items: '> .postbox', + handle: '.hndle', + distance: 2, + tolerance: 'pointer', + toleranceMove: 'tolerance', + sort: function(e,ui) { + if ( $(document).width() - e.clientX < 300 ) { + if ( ! $('#post-body').hasClass('has-sidebar') ) { + var pos = $('#side-sortables').offset(); + + $('#side-sortables').append(ui.item) + $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width()) + postboxes.expandSidebar(1); + } + } + }, + stop: function() { + var postVars = { + action: 'meta-box-order', + _ajax_nonce: $('#meta-box-order-nonce').val(), + page: page + } + $('.meta-box-sortables').each( function() { + postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(','); + } ); + $.post( postboxL10n.requestFile, postVars, function() { + postboxes.expandSidebar(); + } ); + } + } ); + }, + + save_state : function(page) { + var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','), + hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(','); + $.post(postboxL10n.requestFile, { + action: 'closed-postboxes', + closed: closed, + hidden: hidden, + closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), + page: page + }); + postboxes.expandSidebar(); + }, + + /* Callbacks */ + pbshow : false, + + pbhide : false + }; + +}(jQuery)); diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js index 07f4df941..495f0fe41 100644 --- a/wp-admin/js/postbox.js +++ b/wp-admin/js/postbox.js @@ -1,104 +1 @@ -(function($) { - postboxes = { - add_postbox_toggles : function(page,args) { - $('.postbox h3, .postbox .handlediv').click( function() { - $($(this).parent().get(0)).toggleClass('closed'); - postboxes.save_state(page); - } ); - $('.postbox h3 a').click( function(e) { - e.stopPropagation(); - } ); - - $('.hide-postbox-tog').click( function() { - var box = jQuery(this).val(); - if ( jQuery(this).attr('checked') ) { - jQuery('#' + box).show(); - if ( $.isFunction( postboxes.pbshow ) ) - postboxes.pbshow( box ); - - } else { - jQuery('#' + box).hide(); - if ( $.isFunction( postboxes.pbhide ) ) - postboxes.pbhide( box ); - - } - postboxes.save_state(page); - } ); - - this.expandSidebar(); - this.init(page,args); - }, - - expandSidebar : function(doIt) { - if ( doIt || $('#side-sortables > .postbox:visible').length ) { - if ( ! $('#post-body').hasClass('has-sidebar') ) { - $('#post-body').addClass('has-sidebar'); - var h = Math.min( $('#post-body').height(), 300 ); - $('#side-sortables').css({'minHeight':h+'px','height':'auto'}); - } - } else { - $('#post-body').removeClass('has-sidebar'); - $('#side-sortables').css({'minHeight':'0'}); - if ( $.browser.msie && $.browser.version.charAt(0) == 7 ) - $('#side-sortables').css({'height':'0'}); - } - }, - - init : function(page, args) { - $.extend( this, args || {} ); - $('#wpbody-content').css('overflow','hidden'); - $('.meta-box-sortables').sortable( { - placeholder: 'sortable-placeholder', - connectWith: [ '.meta-box-sortables' ], - items: '> .postbox', - handle: '.hndle', - distance: 2, - tolerance: 'pointer', - toleranceMove: 'tolerance', - sort: function(e,ui) { - if ( $(document).width() - e.clientX < 300 ) { - if ( ! $('#post-body').hasClass('has-sidebar') ) { - var pos = $('#side-sortables').offset(); - - $('#side-sortables').append(ui.item) - $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width()) - postboxes.expandSidebar(1); - } - } - }, - stop: function() { - var postVars = { - action: 'meta-box-order', - _ajax_nonce: $('#meta-box-order-nonce').val(), - page: page - } - $('.meta-box-sortables').each( function() { - postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(','); - } ); - $.post( postboxL10n.requestFile, postVars, function() { - postboxes.expandSidebar(); - } ); - } - } ); - }, - - save_state : function(page) { - var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','); - var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(','); - $.post(postboxL10n.requestFile, { - action: 'closed-postboxes', - closed: closed, - hidden: hidden, - closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), - page: page - }); - postboxes.expandSidebar(); - }, - - /* Callbacks */ - pbshow : false, - - pbhide : false - }; - -}(jQuery)); +(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)); \ No newline at end of file diff --git a/wp-admin/js/slug.dev.js b/wp-admin/js/slug.dev.js new file mode 100644 index 000000000..f15cf97d0 --- /dev/null +++ b/wp-admin/js/slug.dev.js @@ -0,0 +1,41 @@ +function edit_permalink(post_id) { + var i, c = 0, e = jQuery('#editable-post-name'), revert_e = e.html(), real_slug = jQuery('#post_name'), revert_slug = real_slug.html(), b = jQuery('#edit-slug-buttons'), revert_b = b.html(), full = jQuery('#editable-post-name-full').html(); + + b.html(''+slugL10n.save+' '+slugL10n.cancel+''); + b.children('.save').click(function() { + var new_slug = e.children('input').val(); + jQuery.post(slugL10n.requestFile, { + action: 'sample-permalink', + post_id: post_id, + new_slug: new_slug, + new_title: jQuery('#title').val(), + samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) { + jQuery('#edit-slug-box').html(data); + b.html(revert_b); + real_slug.attr('value', new_slug); + make_slugedit_clickable(); + }); + return false; + }); + jQuery('#edit-slug-buttons .cancel').click(function() { + e.html(revert_e); + b.html(revert_b); + real_slug.attr('value', revert_slug); + return false; + }); + for(i=0; i < full.length; ++i) { + if ('%' == full.charAt(i)) c++; + } + slug_value = (c > full.length/4)? '' : full; + e.html('').children('input').keypress(function(e){ + var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; + // on enter, just save the new slug, don't save the post + if (13 == key) {b.children('.save').click();return false;} + if (27 == key) {b.children('.cancel').click();return false;} + real_slug.attr('value', this.value)}).focus(); +} + +function make_slugedit_clickable() { + jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); +} + diff --git a/wp-admin/js/slug.js b/wp-admin/js/slug.js index cfd5ce407..2fed33ac9 100644 --- a/wp-admin/js/slug.js +++ b/wp-admin/js/slug.js @@ -1,48 +1 @@ -function edit_permalink(post_id) { - var i, c = 0; - var e = jQuery('#editable-post-name'); - var revert_e = e.html(); - var real_slug = jQuery('#post_name'); - var revert_slug = real_slug.html(); - var b = jQuery('#edit-slug-buttons'); - var revert_b = b.html(); - var full = jQuery('#editable-post-name-full').html(); - - b.html(''+slugL10n.save+' '+slugL10n.cancel+''); - b.children('.save').click(function() { - var new_slug = e.children('input').val(); - jQuery.post(slugL10n.requestFile, { - action: 'sample-permalink', - post_id: post_id, - new_slug: new_slug, - new_title: jQuery('#title').val(), - samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) { - jQuery('#edit-slug-box').html(data); - b.html(revert_b); - real_slug.attr('value', new_slug); - make_slugedit_clickable(); - }); - return false; - }); - jQuery('#edit-slug-buttons .cancel').click(function() { - e.html(revert_e); - b.html(revert_b); - real_slug.attr('value', revert_slug); - return false; - }); - for(i=0; i < full.length; ++i) { - if ('%' == full.charAt(i)) c++; - } - slug_value = (c > full.length/4)? '' : full; - e.html('').children('input').keypress(function(e){ - var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; - // on enter, just save the new slug, don't save the post - if (13 == key) {b.children('.save').click();return false;} - if (27 == key) {b.children('.cancel').click();return false;} - real_slug.attr('value', this.value)}).focus(); -} - -function make_slugedit_clickable() { - jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); -} - +function 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(''+slugL10n.save+' '+slugL10n.cancel+"");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;df.length/4)?"":f;g.html('').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()})}; \ No newline at end of file diff --git a/wp-admin/js/tags.dev.js b/wp-admin/js/tags.dev.js new file mode 100644 index 000000000..943ea44de --- /dev/null +++ b/wp-admin/js/tags.dev.js @@ -0,0 +1,28 @@ +jQuery(document).ready(function($) { + var options = false, addAfter, addAfter2, delAfter; + + addAfter = function( r, settings ) { + var name = $("" + $('name', r).text() + "").html(), id = $('tag', r).attr('id'); + options[options.length] = new Option(name, id); + } + + addAfter2 = function( x, r ) { + var t = $(r.parsed.responses[0].data); + if ( t.length == 1 ) + inlineEditTax.addEvents($(t.id)); + } + + delAfter = function( r, settings ) { + var id = $('tag', r).attr('id'), o; + for ( o = 0; o < options.length; o++ ) + if ( id == options[o].value ) + options[o] = null; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList({ addAfter: addAfter2 }); + + columns.init('edit-tags'); +}); \ No newline at end of file diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js index c5b2d6f28..b55ef21f4 100644 --- a/wp-admin/js/tags.js +++ b/wp-admin/js/tags.js @@ -1,30 +1 @@ -jQuery(function($) { - var options = false - - var addAfter = function( r, settings ) { - var name = $("" + $('name', r).text() + "").html(); - var id = $('tag', r).attr('id'); - options[options.length] = new Option(name, id); - - } - - var addAfter2 = function( x, r ) { - var t = $(r.parsed.responses[0].data); - if ( t.length == 1 ) - inlineEditTax.addEvents($(t.id)); - } - - var delAfter = function( r, settings ) { - var id = $('tag', r).attr('id'); - for ( var o = 0; o < options.length; o++ ) - if ( id == options[o].value ) - options[o] = null; - } - - if ( options ) - $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); - else - $('#the-list').wpList({ addAfter: addAfter2 }); - - columns.init('edit-tags'); -}); \ No newline at end of file +jQuery(document).ready(function(c){var b=false,e,d,a;e=function(h,g){var f=c(""+c("name",h).text()+"").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' + text + ''); + + $('#TB_iframeContent').width('100%'); + return false; + } ); + + $(window).resize( function() { thickDims() } ); +}); diff --git a/wp-admin/js/theme-preview.js b/wp-admin/js/theme-preview.js index f4f85e8bf..5b25dbb75 100644 --- a/wp-admin/js/theme-preview.js +++ b/wp-admin/js/theme-preview.js @@ -1,44 +1 @@ - -jQuery(function($) { - if ( 'undefined' == typeof $.fn.pngFix ) - $.fn.pngFix = function() { return this; } - - var thickDims = function() { - var tbWindow = $('#TB_window'); - var H = $(window).height(); - var W = $(window).width(); - - if ( tbWindow.size() ) { - tbWindow.width( W - 90 ).height( H - 60 ); - $('#TB_iframeContent').width( W - 90 ).height( H - 90 ); - tbWindow.css({'margin-left': '-' + parseInt((( W - 90 ) / 2),10) + 'px'}); - if ( typeof document.body.style.maxWidth != 'undefined' ) - tbWindow.css({'top':'30px','margin-top':'0'}); - }; - - return $('a.thickbox').each( function() { - var href = $(this).parents('.available-theme').find('.previewlink').attr('href'); - if ( ! href ) return; - href = href.replace(/&width=[0-9]+/g, ''); - href = href.replace(/&height=[0-9]+/g, ''); - $(this).attr( 'href', href + '&width=' + ( W - 110 ) + '&height=' + ( H - 100 ) ); - }); - }; - - thickDims() - .click( function() { - var alink = $(this).parents('.available-theme').find('.activatelink'); - var url = alink.attr('href'); - var text = alink.html(); - - $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); - $('#TB_closeAjaxWindow').css({'float':'left'}); - $('#TB_ajaxWindowTitle').css({'float':'right'}) - .append(' ' + text + ''); - - $('#TB_iframeContent').width('100%'); - return false; - } ); - - $(window).resize( function() { thickDims() } ); -}); +jQuery(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(' '+e+"");b("#TB_iframeContent").width("100%");return false});b(window).resize(function(){a()})}); \ No newline at end of file diff --git a/wp-admin/js/widgets.dev.js b/wp-admin/js/widgets.dev.js new file mode 100644 index 000000000..1d2cca32e --- /dev/null +++ b/wp-admin/js/widgets.dev.js @@ -0,0 +1,150 @@ +jQuery(function($) { + $('.noscript-action').remove(); + + var reminded = false; + var lameWidgetReminder = function() { + if ( reminded ) + return; + window.onbeforeunload = function () { return widgetsL10n.lamerReminder }; + $('h2:first').after( '

' + widgetsL10n.lameReminder + '

' ); + $('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() { + window.onbeforeunload = null; + } ); + reminded = true; + }; + + var increment = 1; + + // Open or close widget control form + var toggleWidget = function( li, disableFields ) { + var width = li.find('input.widget-width').val(); + + // it seems IE chokes on these animations because of the positioning/floating + var widgetAnim = $.browser.msie ? function() { + var t = $(this); + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + li.css( 'marginLeft', 0 ); + t.siblings('div').children('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.css( 'marginLeft', ( width - 250 ) * -1 ); + t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel ); + } + t.toggle(); + } : function() { + var t = $(this); + + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + if ( width > 250 ) + li.animate( { marginLeft: 0 } ); + t.siblings('div').children('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.animate( { marginLeft: ( width - 250 ) * -1 } ); + t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel ); + } + t.animate( { height: 'toggle' } ); + }; + + return li.children('div.widget-control').each( widgetAnim ).end(); + }; + + // onclick for edit/cancel links + var editClick = function() { + var q = wpAjax.unserialize( this.href ); + // if link is in available widgets list, make sure it points to the current sidebar + if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) { + var w = q.edit || q.add; + toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur(); + return false; + } else if ( q.sidebar ) { // otherwise, redirect to correct page + return true; + } + + // If link is in current widgets list, just open the form + toggleWidget( $(this).parents('li:first'), true ).blur(); + return false; + }; + + // onclick for add links + var addClick = function() { + var oldLi = $(this).parents('li:first').find('ul.widget-control-info li'); + var newLi = oldLi.clone(); + + if ( newLi.html().match( /%i%/ ) ) { + // supplid form is a template, replace %i% by unique id + var i = $('#generated-time').val() + increment.toString(); + increment++; + newLi.html( newLi.html().replace( /%i%/g, i ) ); + } else { + $(this).text( widgetsL10n.edit ).unbind().click( editClick ); + // save form content in textarea so we don't have any conflicting HTML ids + oldLi.html( '' ); + } + + // add event handlers + addWidgetControls( newLi ); + + // add widget to sidebar sortable + widgetSortable.append( newLi ).SortableAddItem( newLi[0] ); + + // increment widget counter + var n = parseInt( $('#widget-count').text(), 10 ) + 1; + $('#widget-count').text( n.toString() ) + + lameWidgetReminder(); + return false; + }; + + // add event handlers to all links found in context + var addWidgetControls = function( context ) { + if ( !context ) + context = document; + + $('a.widget-control-edit', context).click( editClick ); + + // onclick for save links + $('a.widget-control-save', context).click( function() { + lameWidgetReminder(); + toggleWidget( $(this).parents('li:first'), false ).blur() + return false; + } ); + + // onclick for remove links + $('a.widget-control-remove', context).click( function() { + var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val(); + $(this).parents('li:first').remove(); + var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); + t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action') + .show().text( widgetsL10n.add ).unbind().click( addClick ); + var n = parseInt( $('#widget-count').text(), 10 ) - 1; + $('#widget-count').text( n.toString() ) + return false; + } ); + } + + addWidgetControls(); + + $('a.widget-control-add').click( addClick ); + + var widgetSortable; + var widgetSortableInit = function() { + try { // a hack to make sortables work in jQuery 1.2+ and IE7 + $('#current-sidebar .widget-control-list').SortableDestroy(); + } catch(e) {} + widgetSortable = $('#current-sidebar .widget-control-list').Sortable( { + accept: 'widget-sortable', + helperclass: 'sorthelper', + handle: 'h4.widget-title', + onStop: widgetSortableInit + } ); + } + + // initialize sortable + widgetSortableInit(); + +}); diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js index 1d2cca32e..00e7e23ab 100644 --- a/wp-admin/js/widgets.js +++ b/wp-admin/js/widgets.js @@ -1,150 +1 @@ -jQuery(function($) { - $('.noscript-action').remove(); - - var reminded = false; - var lameWidgetReminder = function() { - if ( reminded ) - return; - window.onbeforeunload = function () { return widgetsL10n.lamerReminder }; - $('h2:first').after( '

' + widgetsL10n.lameReminder + '

' ); - $('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() { - window.onbeforeunload = null; - } ); - reminded = true; - }; - - var increment = 1; - - // Open or close widget control form - var toggleWidget = function( li, disableFields ) { - var width = li.find('input.widget-width').val(); - - // it seems IE chokes on these animations because of the positioning/floating - var widgetAnim = $.browser.msie ? function() { - var t = $(this); - if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } - li.css( 'marginLeft', 0 ); - t.siblings('div').children('h4').children('a').text( widgetsL10n.edit ); - } else { - t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open - if ( width > 250 ) - li.css( 'marginLeft', ( width - 250 ) * -1 ); - t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel ); - } - t.toggle(); - } : function() { - var t = $(this); - - if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } - if ( width > 250 ) - li.animate( { marginLeft: 0 } ); - t.siblings('div').children('h4').children('a').text( widgetsL10n.edit ); - } else { - t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open - if ( width > 250 ) - li.animate( { marginLeft: ( width - 250 ) * -1 } ); - t.siblings('div').children('h4').children('a').text( widgetsL10n.cancel ); - } - t.animate( { height: 'toggle' } ); - }; - - return li.children('div.widget-control').each( widgetAnim ).end(); - }; - - // onclick for edit/cancel links - var editClick = function() { - var q = wpAjax.unserialize( this.href ); - // if link is in available widgets list, make sure it points to the current sidebar - if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) { - var w = q.edit || q.add; - toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur(); - return false; - } else if ( q.sidebar ) { // otherwise, redirect to correct page - return true; - } - - // If link is in current widgets list, just open the form - toggleWidget( $(this).parents('li:first'), true ).blur(); - return false; - }; - - // onclick for add links - var addClick = function() { - var oldLi = $(this).parents('li:first').find('ul.widget-control-info li'); - var newLi = oldLi.clone(); - - if ( newLi.html().match( /%i%/ ) ) { - // supplid form is a template, replace %i% by unique id - var i = $('#generated-time').val() + increment.toString(); - increment++; - newLi.html( newLi.html().replace( /%i%/g, i ) ); - } else { - $(this).text( widgetsL10n.edit ).unbind().click( editClick ); - // save form content in textarea so we don't have any conflicting HTML ids - oldLi.html( '' ); - } - - // add event handlers - addWidgetControls( newLi ); - - // add widget to sidebar sortable - widgetSortable.append( newLi ).SortableAddItem( newLi[0] ); - - // increment widget counter - var n = parseInt( $('#widget-count').text(), 10 ) + 1; - $('#widget-count').text( n.toString() ) - - lameWidgetReminder(); - return false; - }; - - // add event handlers to all links found in context - var addWidgetControls = function( context ) { - if ( !context ) - context = document; - - $('a.widget-control-edit', context).click( editClick ); - - // onclick for save links - $('a.widget-control-save', context).click( function() { - lameWidgetReminder(); - toggleWidget( $(this).parents('li:first'), false ).blur() - return false; - } ); - - // onclick for remove links - $('a.widget-control-remove', context).click( function() { - var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val(); - $(this).parents('li:first').remove(); - var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); - t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action') - .show().text( widgetsL10n.add ).unbind().click( addClick ); - var n = parseInt( $('#widget-count').text(), 10 ) - 1; - $('#widget-count').text( n.toString() ) - return false; - } ); - } - - addWidgetControls(); - - $('a.widget-control-add').click( addClick ); - - var widgetSortable; - var widgetSortableInit = function() { - try { // a hack to make sortables work in jQuery 1.2+ and IE7 - $('#current-sidebar .widget-control-list').SortableDestroy(); - } catch(e) {} - widgetSortable = $('#current-sidebar .widget-control-list').Sortable( { - accept: 'widget-sortable', - helperclass: 'sorthelper', - handle: 'h4.widget-title', - onStop: widgetSortableInit - } ); - } - - // initialize sortable - widgetSortableInit(); - -}); +jQuery(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('

'+widgetsL10n.lameReminder+"

");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("")}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()}); \ No newline at end of file diff --git a/wp-admin/js/word-count.dev.js b/wp-admin/js/word-count.dev.js new file mode 100644 index 000000000..2207f758a --- /dev/null +++ b/wp-admin/js/word-count.dev.js @@ -0,0 +1,39 @@ +// Word count +(function($) { + wpWordCount = { + + init : function() { + var t = this, last = 0, co = $('#content'); + + $('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '0' ) ); + t.block = 0; + t.wc(co.val()); + co.keyup( function(e) { + if ( e.keyCode == last ) return true; + if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val()); + last = e.keyCode; + return true; + }); + }, + + wc : function(tx) { + var t = this, w = $('#word-count'), tc = 0; + + if ( t.block ) return; + t.block = 1; + + setTimeout( function() { + if ( tx ) { + tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / /gi, ' ' ); + tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); + tx.replace( /\S\s+/g, function(){tc++;} ); + } + w.html(tc.toString()); + + setTimeout( function() { t.block = 0; }, 2000 ); + }, 1 ); + } + } + + $(document).ready( function(){ wpWordCount.init(); } ); +}(jQuery)); diff --git a/wp-admin/js/word-count.js b/wp-admin/js/word-count.js index 474056e99..6384eba71 100644 --- a/wp-admin/js/word-count.js +++ b/wp-admin/js/word-count.js @@ -1,39 +1 @@ -// Word count -(function(JQ) { - wpWordCount = { - - init : function() { - var t = this, last = 0, co = JQ('#content'); - - JQ('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '0' ) ); - t.block = 0; - t.wc(co.val()); - co.keyup( function(e) { - if ( e.keyCode == last ) return true; - if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val()); - last = e.keyCode; - return true; - }); - }, - - wc : function(tx) { - var t = this, w = JQ('#word-count'), tc = 0; - - if ( t.block ) return; - t.block = 1; - - setTimeout( function() { - if ( tx ) { - tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / /gi, ' ' ); - tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); - tx.replace( /\S\s+/g, function(){tc++;} ); - } - w.html(tc.toString()); - - setTimeout( function() { t.block = 0; }, 2000 ); - }, 1 ); - } - } -}(jQuery)); - -jQuery(document).ready( function(){ wpWordCount.init(); } ); +(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'0'));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(/ /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)); \ No newline at end of file diff --git a/wp-admin/js/wp-gears.dev.js b/wp-admin/js/wp-gears.dev.js new file mode 100644 index 000000000..3e9519c47 --- /dev/null +++ b/wp-admin/js/wp-gears.dev.js @@ -0,0 +1,96 @@ + +var 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 perm = true; + + if ( 'undefined' != typeof google && google.gears ) { + if ( ! google.gears.factory.hasPermission ) + perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' ); + + if ( perm ) + try { this.createStore(); } catch(e) { this.message(); } // silence if canceled + else + this.message(4); + } + }, + + storeName : function() { + var name = window.location.protocol + window.location.host; + + name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name + name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars + + return name; + }, + + message : function(show) { + 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'); + + if ( ! msg1 ) return; + + if ( 'undefined' != typeof google && google.gears ) { + if ( show && show == 4 ) { + msg1.style.display = msg2.style.display = msg3.style.display = 'none'; + msg4.style.display = 'block'; + } else if ( google.gears.factory.hasPermission ) { + msg1.style.display = msg2.style.display = msg4.style.display = 'none'; + msg3.style.display = 'block'; + + if ( 'undefined' == typeof store ) + t.createStore(); + + store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);}; + store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);}; + store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);}; + } else { + msg1.style.display = msg3.style.display = msg4.style.display = 'none'; + msg2.style.display = 'block'; + } + } + }, + + I : function(id) { + return document.getElementById(id); + } +}; + +(function() { + if ( 'undefined' != typeof google && google.gears ) return; + + var gf = false; + if ( 'undefined' != typeof GearsFactory ) { + gf = new GearsFactory(); + } else { + try { + gf = new ActiveXObject('Gears.Factory'); + if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 ) + gf.privateSetGlobalObject(this); + } catch (e) { + if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) { + gf = document.createElement("object"); + gf.style.display = "none"; + gf.width = 0; + gf.height = 0; + gf.type = "application/x-googlegears"; + document.documentElement.appendChild(gf); + } + } + } + + if ( ! gf ) return; + if ( 'undefined' == typeof google ) google = {}; + if ( ! google.gears ) google.gears = { factory : gf }; +})(); diff --git a/wp-admin/js/wp-gears.js b/wp-admin/js/wp-gears.js index 0509373ef..375234c44 100644 --- a/wp-admin/js/wp-gears.js +++ b/wp-admin/js/wp-gears.js @@ -1,96 +1 @@ - -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 perm = true; - - if ( 'undefined' != typeof google && google.gears ) { - if ( ! google.gears.factory.hasPermission ) - perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' ); - - if ( perm ) - try { this.createStore(); } catch(e) { this.message(); } // silence if canceled - else - this.message(4); - } - }, - - storeName : function() { - var name = window.location.protocol + window.location.host; - - name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name - name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars - - return name; - }, - - message : function(show) { - 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'); - - if ( ! msg1 ) return; - - if ( 'undefined' != typeof google && google.gears ) { - if ( show && show == 4 ) { - msg1.style.display = msg2.style.display = msg3.style.display = 'none'; - msg4.style.display = 'block'; - } else if ( google.gears.factory.hasPermission ) { - msg1.style.display = msg2.style.display = msg4.style.display = 'none'; - msg3.style.display = 'block'; - - if ( 'undefined' == typeof store ) - t.createStore(); - - store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);}; - store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);}; - store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);}; - } else { - msg1.style.display = msg3.style.display = msg4.style.display = 'none'; - msg2.style.display = 'block'; - } - } - }, - - I : function(id) { - return document.getElementById(id); - } -}; - -(function() { - if ( 'undefined' != typeof google && google.gears ) return; - - var gf = false; - if ( 'undefined' != typeof GearsFactory ) { - gf = new GearsFactory(); - } else { - try { - gf = new ActiveXObject('Gears.Factory'); - if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 ) - gf.privateSetGlobalObject(this); - } catch (e) { - if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) { - gf = document.createElement("object"); - gf.style.display = "none"; - gf.width = 0; - gf.height = 0; - gf.type = "application/x-googlegears"; - document.documentElement.appendChild(gf); - } - } - } - - if ( ! gf ) return; - if ( 'undefined' == typeof google ) google = {}; - if ( ! google.gears ) google.gears = { factory : gf }; -})(); +var 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}}})(); \ No newline at end of file diff --git a/wp-admin/js/xfn.dev.js b/wp-admin/js/xfn.dev.js new file mode 100644 index 000000000..fdb596972 --- /dev/null +++ b/wp-admin/js/xfn.dev.js @@ -0,0 +1,41 @@ +function GetElementsWithClassName(elementName, className) { + var allElements = document.getElementsByTagName(elementName), elemColl = new Array(), i; + for (i = 0; i < allElements.length; i++) { + if (allElements[i].className == className) { + elemColl[elemColl.length] = allElements[i]; + } + } + return elemColl; +} + +function meChecked() { + var undefined, eMe = document.getElementById('me'); + if (eMe == undefined) return false; + else return eMe.checked; +} + +function upit() { + var isMe = meChecked(), inputColl = GetElementsWithClassName('input', 'valinp'), results = document.getElementById('link_rel'), inputs = '', i; + for (i = 0; i < inputColl.length; i++) { + inputColl[i].disabled = isMe; + inputColl[i].parentNode.className = isMe ? 'disabled' : ''; + if (!isMe && inputColl[i].checked && inputColl[i].value != '') { + inputs += inputColl[i].value + ' '; + } + } + inputs = inputs.substr(0,inputs.length - 1); + if (isMe) inputs='me'; + results.value = inputs; + } + +function blurry() { + if (!document.getElementById) return; + + var aInputs = document.getElementsByTagName('input'), i; + + for ( i = 0; i < aInputs.length; i++) { + aInputs[i].onclick = aInputs[i].onkeyup = upit; + } +} + +addLoadEvent(blurry); \ No newline at end of file diff --git a/wp-admin/js/xfn.js b/wp-admin/js/xfn.js index 2fe41eb14..d37a80af9 100644 --- a/wp-admin/js/xfn.js +++ b/wp-admin/js/xfn.js @@ -1,46 +1 @@ -function GetElementsWithClassName(elementName, className) { - var allElements = document.getElementsByTagName(elementName); - var elemColl = new Array(); - for (i = 0; i < allElements.length; i++) { - if (allElements[i].className == className) { - elemColl[elemColl.length] = allElements[i]; - } - } - return elemColl; -} - -function meChecked() { - var undefined; - var eMe = document.getElementById('me'); - if (eMe == undefined) return false; - else return eMe.checked; -} - -function upit() { - var isMe = meChecked(); //document.getElementById('me').checked; - var inputColl = GetElementsWithClassName('input', 'valinp'); - var results = document.getElementById('link_rel'); - var linkText, linkUrl, inputs = ''; - for (i = 0; i < inputColl.length; i++) { - inputColl[i].disabled = isMe; - inputColl[i].parentNode.className = isMe ? 'disabled' : ''; - if (!isMe && inputColl[i].checked && inputColl[i].value != '') { - inputs += inputColl[i].value + ' '; - } - } - inputs = inputs.substr(0,inputs.length - 1); - if (isMe) inputs='me'; - results.value = inputs; - } - -function blurry() { - if (!document.getElementById) return; - - var aInputs = document.getElementsByTagName('input'); - - for (var i = 0; i < aInputs.length; i++) { - aInputs[i].onclick = aInputs[i].onkeyup = upit; - } -} - -addLoadEvent(blurry); \ No newline at end of file +function GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;b 0 ) { + autosave_update_slug(postID); + } + } + } + if ( message ) { jQuery('#autosave').html(message); } // update autosave message + else if ( autosaveOldMessage && res ) { jQuery('#autosave').html( autosaveOldMessage ); } + return res; +} + +// called when autosaving pre-existing post +function autosave_saved(response) { + autosave_parse_response(response); // parse the ajax response + autosave_enable_buttons(); // re-enable disabled form buttons +} + +// called when autosaving new post +function autosave_saved_new(response) { + var res = autosave_parse_response(response), tempID, postID; + // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID + if ( res && res.responses.length && !res.errors ) { + tempID = jQuery('#post_ID').val(); + postID = parseInt( res.responses[0].id, 10 ); + autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here + if ( tempID < 0 && postID > 0 ) // update media buttons + jQuery('#media-buttons a').each(function(){ + this.href = this.href.replace(tempID, postID); + }); + // activate preview + autosaveFirst = false; + if ( autosaveDelayPreview ) + jQuery('#post-preview').click(); + } else { + autosave_enable_buttons(); // re-enable disabled form buttons + } +} + +function autosave_update_post_ID( postID ) { + if ( !isNaN(postID) && postID > 0 ) { + if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once + jQuery('#post_ID').attr({name: "post_ID"}); + jQuery('#post_ID').val(postID); + // We need new nonces + jQuery.post(autosaveL10n.requestFile, { + action: "autosave-generate-nonces", + post_ID: postID, + autosavenonce: jQuery('#autosavenonce').val(), + post_type: jQuery('#post_type').val() + }, function(html) { + jQuery('#_wpnonce').val(html); + autosave_enable_buttons(); // re-enable disabled form buttons + }); + jQuery('#hiddenaction').val('editpost'); + } +} + +function autosave_update_slug(post_id) { + // create slug area only if not already there + if ( jQuery.isFunction(make_slugedit_clickable) && !jQuery('#edit-slug-box > *').size() ) { + jQuery.post( + slugL10n.requestFile, + { + action: 'sample-permalink', + post_id: post_id, + new_title: jQuery('#title').val(), + samplepermalinknonce: jQuery('#samplepermalinknonce').val() + }, + function(data) { + jQuery('#edit-slug-box').html(data); + 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); // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions. +} + +var autosave = function() { + // (bool) is rich editor enabled and active + var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback; + + post_data = { + action: "autosave", + post_ID: jQuery("#post_ID").val() || 0, + post_title: jQuery("#title").val() || "", + autosavenonce: jQuery('#autosavenonce').val(), + //tags_input: jQuery("#tags-input").val() || "", + post_type: jQuery('#post_type').val() || "", + autosave: 1 + }; + + jQuery('.tags-input').each( function() { + post_data[this.name] = this.value; + } ); + + // We always send the ajax request in order to keep the post lock fresh. + // This (bool) tells whether or not to write the post to the DB during the ajax request. + doAutoSave = true; + + // No autosave while thickbox is open (media buttons) + if ( jQuery("#TB_window").css('display') == 'block' ) + doAutoSave = false; + + /* Gotta do this up here so we can check the length when tinyMCE is in use */ + if ( rich ) { + ed = tinyMCE.activeEditor; + if ( 'mce_fullscreen' == ed.id ) + tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'}); + tinyMCE.get('content').save(); + } + + post_data["content"] = jQuery("#content").val(); + if ( jQuery('#post_name').val() ) + post_data["post_name"] = jQuery('#post_name').val(); + + // Nothing to save or no change. + if( (post_data["post_title"].length==0 && post_data["content"].length==0) || post_data["post_title"] + post_data["content"] == autosaveLast) { + doAutoSave = false + } + + autosave_disable_buttons(); + + origStatus = jQuery('#original_post_status').val(); + + autosaveLast = jQuery("#title").val()+jQuery("#content").val(); + goodcats = ([]); + jQuery("[@name='post_category[]']:checked").each( function(i) { + goodcats.push(this.value); + } ); + post_data["catslist"] = goodcats.join(","); + + if ( jQuery("#comment_status").attr("checked") ) + post_data["comment_status"] = 'open'; + if ( jQuery("#ping_status").attr("checked") ) + post_data["ping_status"] = 'open'; + if ( jQuery("#excerpt").size() ) + post_data["excerpt"] = jQuery("#excerpt").val(); + if ( jQuery("#post_author").size() ) + post_data["post_author"] = jQuery("#post_author").val(); + post_data["user_ID"] = jQuery("#user-id").val(); + + // Don't run while the TinyMCE spellcheck is on. Why? Who knows. + if ( rich && tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) { + doAutoSave = false; + } + + if ( parseInt(post_data["post_ID"], 10) < 1 ) { + post_data["temp_ID"] = post_data["post_ID"]; + successCallback = autosave_saved_new; // new post + } else { + successCallback = autosave_saved; // pre-existing post + } + + if ( !doAutoSave ) { + post_data['autosave'] = 0; + } + + autosaveOldMessage = jQuery('#autosave').html(); + + jQuery.ajax({ + data: post_data, + beforeSend: doAutoSave ? autosave_loading : null, + type: "POST", + url: autosaveL10n.requestFile, + success: successCallback + }); +} diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index 5b473878a..534cf1683 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -1,213 +1 @@ -var autosaveLast = ''; -var autosavePeriodical; -var autosaveOldMessage = ''; -var autosaveDelayPreview = false; -var autosaveFirst = true; - -jQuery(function($) { - autosaveLast = $('#post #title').val()+$('#post #content').val(); - autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true}); - - //Disable autosave after the form has been submitted - $("#post").submit(function() { $.cancel(autosavePeriodical); }); -}); - -function autosave_parse_response(response) { - var res = wpAjax.parseAjaxResponse(response, 'autosave'); // parse the ajax response - var message = ''; - - if ( res && res.responses && res.responses.length ) { - message = res.responses[0].data; // The saved message or error. - // someone else is editing: disable autosave, set errors - if ( res.responses[0].supplemental ) { - if ( 'disable' == res.responses[0].supplemental['disable_autosave'] ) { - autosave = function() {}; - res = { errors: true }; - } - jQuery.each(res.responses[0].supplemental, function(selector, value) { - if ( selector.match(/^replace-/) ) { - jQuery('#'+selector.replace('replace-', '')).val(value); - } - }); - } - - // if no errors: add slug UI - if ( !res.errors ) { - var postID = parseInt( res.responses[0].id, 10 ); - if ( !isNaN(postID) && postID > 0 ) { - autosave_update_slug(postID); - } - } - } - if ( message ) { jQuery('#autosave').html(message); } // update autosave message - else if ( autosaveOldMessage && res ) { jQuery('#autosave').html( autosaveOldMessage ); } - return res; -} - -// called when autosaving pre-existing post -function autosave_saved(response) { - autosave_parse_response(response); // parse the ajax response - autosave_enable_buttons(); // re-enable disabled form buttons -} - -// called when autosaving new post -function autosave_saved_new(response) { - var res = autosave_parse_response(response); // parse the ajax response - // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID - if ( res && res.responses.length && !res.errors ) { - var tempID = jQuery('#post_ID').val(); - var postID = parseInt( res.responses[0].id, 10 ); - autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here - if ( tempID < 0 && postID > 0 ) // update media buttons - jQuery('#media-buttons a').each(function(){ - this.href = this.href.replace(tempID, postID); - }); - // activate preview - autosaveFirst = false; - if ( autosaveDelayPreview ) - jQuery('#post-preview').click(); - } else { - autosave_enable_buttons(); // re-enable disabled form buttons - } -} - -function autosave_update_post_ID( postID ) { - if ( !isNaN(postID) && postID > 0 ) { - if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once - jQuery('#post_ID').attr({name: "post_ID"}); - jQuery('#post_ID').val(postID); - // We need new nonces - jQuery.post(autosaveL10n.requestFile, { - action: "autosave-generate-nonces", - post_ID: postID, - autosavenonce: jQuery('#autosavenonce').val(), - post_type: jQuery('#post_type').val() - }, function(html) { - jQuery('#_wpnonce').val(html); - autosave_enable_buttons(); // re-enable disabled form buttons - }); - jQuery('#hiddenaction').val('editpost'); - } -} - -function autosave_update_slug(post_id) { - // create slug area only if not already there - if ( jQuery.isFunction(make_slugedit_clickable) && !jQuery('#edit-slug-box > *').size() ) { - jQuery.post( - slugL10n.requestFile, - { - action: 'sample-permalink', - post_id: post_id, - new_title: jQuery('#title').val(), - samplepermalinknonce: jQuery('#samplepermalinknonce').val() - }, - function(data) { - jQuery('#edit-slug-box').html(data); - 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); // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions. -} - -var autosave = function() { - // (bool) is rich editor enabled and active - var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); - var post_data = { - action: "autosave", - post_ID: jQuery("#post_ID").val() || 0, - post_title: jQuery("#title").val() || "", - autosavenonce: jQuery('#autosavenonce').val(), - //tags_input: jQuery("#tags-input").val() || "", - post_type: jQuery('#post_type').val() || "", - autosave: 1 - }; - - jQuery('.tags-input').each( function() { - post_data[this.name] = this.value; - } ); - - // We always send the ajax request in order to keep the post lock fresh. - // This (bool) tells whether or not to write the post to the DB during the ajax request. - var doAutoSave = true; - - // No autosave while thickbox is open (media buttons) - if ( jQuery("#TB_window").css('display') == 'block' ) - doAutoSave = false; - - /* Gotta do this up here so we can check the length when tinyMCE is in use */ - if ( rich ) { - var ed = tinyMCE.activeEditor; - if ( 'mce_fullscreen' == ed.id ) - tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'}); - tinyMCE.get('content').save(); - } - - post_data["content"] = jQuery("#content").val(); - if ( jQuery('#post_name').val() ) - post_data["post_name"] = jQuery('#post_name').val(); - - // Nothing to save or no change. - if( (post_data["post_title"].length==0 && post_data["content"].length==0) || post_data["post_title"] + post_data["content"] == autosaveLast) { - doAutoSave = false - } - - autosave_disable_buttons(); - - var origStatus = jQuery('#original_post_status').val(); - - autosaveLast = jQuery("#title").val()+jQuery("#content").val(); - goodcats = ([]); - jQuery("[@name='post_category[]']:checked").each( function(i) { - goodcats.push(this.value); - } ); - post_data["catslist"] = goodcats.join(","); - - if ( jQuery("#comment_status").attr("checked") ) - post_data["comment_status"] = 'open'; - if ( jQuery("#ping_status").attr("checked") ) - post_data["ping_status"] = 'open'; - if ( jQuery("#excerpt").size() ) - post_data["excerpt"] = jQuery("#excerpt").val(); - if ( jQuery("#post_author").size() ) - post_data["post_author"] = jQuery("#post_author").val(); - post_data["user_ID"] = jQuery("#user-id").val(); - - // Don't run while the TinyMCE spellcheck is on. Why? Who knows. - if ( rich && tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) { - doAutoSave = false; - } - - if ( parseInt(post_data["post_ID"], 10) < 1 ) { - post_data["temp_ID"] = post_data["post_ID"]; - var successCallback = autosave_saved_new; // new post - } else { - var successCallback = autosave_saved; // pre-existing post - } - - if ( !doAutoSave ) { - post_data['autosave'] = 0; - } - - autosaveOldMessage = jQuery('#autosave').html(); - - jQuery.ajax({ - data: post_data, - beforeSend: doAutoSave ? autosave_loading : null, - type: "POST", - url: autosaveL10n.requestFile, - success: successCallback - }); -} +var 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})}; \ No newline at end of file diff --git a/wp-includes/js/colorpicker.dev.js b/wp-includes/js/colorpicker.dev.js new file mode 100644 index 000000000..1fc32cf24 --- /dev/null +++ b/wp-includes/js/colorpicker.dev.js @@ -0,0 +1,707 @@ +// =================================================================== +// Author: Matt Kruse +// WWW: http://www.mattkruse.com/ +// +// NOTICE: You may use this code for any purpose, commercial or +// private, without any further permission from the author. You may +// remove this notice from your final code if you wish, however it is +// appreciated by the author if at least my web site address is kept. +// +// You may *NOT* re-distribute this code in any way except through its +// use. That means, you can include it in your product, or your web +// site, or any other form where the code is actually being used. You +// may not put the plain javascript up on your site for download or +// include it in your javascript libraries for download. +// If you wish to share this code with others, please just point them +// to the URL instead. +// Please DO NOT link directly to my .js files from your site. Copy +// the files to your server and use them there. Thank you. +// =================================================================== + + +/* SOURCE FILE: AnchorPosition.js */ + +/* +AnchorPosition.js +Author: Matt Kruse +Last modified: 10/11/02 + +DESCRIPTION: These functions find the position of an tag in a document, +so other elements can be positioned relative to it. + +COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small +positioning errors - usually with Window positioning - occur on the +Macintosh platform. + +FUNCTIONS: +getAnchorPosition(anchorname) + Returns an Object() having .x and .y properties of the pixel coordinates + of the upper-left corner of the anchor. Position is relative to the PAGE. + +getAnchorWindowPosition(anchorname) + Returns an Object() having .x and .y properties of the pixel coordinates + of the upper-left corner of the anchor, relative to the WHOLE SCREEN. + +NOTES: + +1) For popping up separate browser windows, use getAnchorWindowPosition. + Otherwise, use getAnchorPosition + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + + +3) There must be at least a space between for IE5.5 to see the + anchor tag correctly. Do not do with no space. +*/ + +// getAnchorPosition(anchorname) +// This function returns an object having .x and .y properties which are the coordinates +// of the named anchor, relative to the page. +function getAnchorPosition(anchorname) { + // This function will return an Object with x and y properties + var useWindow=false; + var coordinates=new Object(); + var x=0,y=0; + // Browser capability sniffing + var use_gebi=false, use_css=false, use_layers=false; + if (document.getElementById) { use_gebi=true; } + else if (document.all) { use_css=true; } + else if (document.layers) { use_layers=true; } + // Logic to find position + if (use_gebi && document.all) { + x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_gebi) { + var o=document.getElementById(anchorname); + x=AnchorPosition_getPageOffsetLeft(o); + y=AnchorPosition_getPageOffsetTop(o); + } + else if (use_css) { + x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_layers) { + var found=0; + for (var i=0; i tags may cause errors. + +USAGE: +// Create an object for a WINDOW popup +var win = new PopupWindow(); + +// Create an object for a DIV window using the DIV named 'mydiv' +var win = new PopupWindow('mydiv'); + +// Set the window to automatically hide itself when the user clicks +// anywhere else on the page except the popup +win.autoHide(); + +// Show the window relative to the anchor name passed in +win.showPopup(anchorname); + +// Hide the popup +win.hidePopup(); + +// Set the size of the popup window (only applies to WINDOW popups +win.setSize(width,height); + +// Populate the contents of the popup window that will be shown. If you +// change the contents while it is displayed, you will need to refresh() +win.populate(string); + +// set the URL of the window, rather than populating its contents +// manually +win.setUrl("http://www.site.com/"); + +// Refresh the contents of the popup +win.refresh(); + +// Specify how many pixels to the right of the anchor the popup will appear +win.offsetX = 50; + +// Specify how many pixels below the anchor the popup will appear +win.offsetY = 100; + +NOTES: +1) Requires the functions in AnchorPosition.js + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + + +3) There must be at least a space between for IE5.5 to see the + anchor tag correctly. Do not do with no space. + +4) When a PopupWindow object is created, a handler for 'onmouseup' is + attached to any event handler you may have already defined. Do NOT define + an event handler for 'onmouseup' after you define a PopupWindow object or + the autoHide() will not work correctly. +*/ + +// Set the position of the popup window based on the anchor +function PopupWindow_getXYPosition(anchorname) { + var coordinates; + if (this.type == "WINDOW") { + coordinates = getAnchorWindowPosition(anchorname); + } + else { + coordinates = getAnchorPosition(anchorname); + } + this.x = coordinates.x; + this.y = coordinates.y; + } +// Set width/height of DIV/popup window +function PopupWindow_setSize(width,height) { + this.width = width; + this.height = height; + } +// Fill the window with contents +function PopupWindow_populate(contents) { + this.contents = contents; + this.populated = false; + } +// Set the URL to go to +function PopupWindow_setUrl(url) { + this.url = url; + } +// Set the window popup properties +function PopupWindow_setWindowProperties(props) { + this.windowProperties = props; + } +// Refresh the displayed contents of the popup +function PopupWindow_refresh() { + if (this.divName != null) { + // refresh the DIV object + 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 d = document.layers[this.divName]; + d.document.open(); + d.document.writeln(this.contents); + d.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(); + } + } + } +// Position and show the popup, relative to an anchor object +function PopupWindow_showPopup(anchorname) { + this.getXYPosition(anchorname); + this.x += this.offsetX; + this.y += this.offsetY; + if (!this.populated && (this.contents != "")) { + this.populated = true; + this.refresh(); + } + if (this.divName != null) { + // Show the DIV object + 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 the popup window will go off-screen, move it so it doesn't + 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 avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ); + 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+""); + } + this.refresh(); + } + } +// Hide the popup +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; + } + } + } +// Pass an event and return whether or not it was the popup DIV that was clicked +function PopupWindow_isClicked(e) { + if (this.divName != null) { + if (this.use_layers) { + var clickX = e.pageX; + var clickY = e.pageY; + var t = document.layers[this.divName]; + if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) { + return true; + } + else { return false; } + } + else if (document.all) { // Need to hard-code this to trap IE for error-handling + var t = window.event.srcElement; + while (t.parentElement != null) { + if (t.id==this.divName) { + return true; + } + t = t.parentElement; + } + return false; + } + else if (this.use_gebi && e) { + var t = e.originalTarget; + while (t.parentNode != null) { + if (t.id==this.divName) { + return true; + } + t = t.parentNode; + } + return false; + } + return false; + } + return false; + } + +// Check an onMouseDown event to see if we should hide +function PopupWindow_hideIfNotClicked(e) { + if (this.autoHideEnabled && !this.isClicked(e)) { + this.hidePopup(); + } + } +// Call this to make the DIV disable automatically when mouse is clicked outside it +function PopupWindow_autoHide() { + this.autoHideEnabled = true; + } +// This global function checks all PopupWindow objects onmouseup to see if they should be hidden +function PopupWindow_hidePopupWindows(e) { + for (var i=0; i0) { + 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; + // Method mappings + 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; + } + +/* SOURCE FILE: ColorPicker2.js */ + +/* +Last modified: 02/24/2003 + +DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB +form. It uses a color "swatch" to display the standard 216-color web-safe +palette. The user can then click on a color to select it. + +COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js. +Only the latest DHTML-capable browsers will show the color and hex values +at the bottom as your mouse goes over them. + +USAGE: +// Create a new ColorPicker object using DHTML popup +var cp = new ColorPicker(); + +// Create a new ColorPicker object using Window Popup +var cp = new ColorPicker('window'); + +// Add a link in your page to trigger the popup. For example: +Pick + +// Or use the built-in "select" function to do the dirty work for you: +Pick + +// If using DHTML popup, write out the required DIV tag near the bottom +// of your page. + + +// Write the 'pickColor' function that will be called when the user clicks +// a color and do something with the value. This is only required if you +// want to do something other than simply populate a form field, which is +// what the 'select' function will give you. +function pickColor(color) { + field.value = color; + } + +NOTES: +1) Requires the functions in AnchorPosition.js and PopupWindow.js + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + + +3) There must be at least a space between for IE5.5 to see the + anchor tag correctly. Do not do with no space. + +4) When a ColorPicker object is created, a handler for 'onmouseup' is + attached to any event handler you may have already defined. Do NOT define + an event handler for 'onmouseup' after you define a ColorPicker object or + the color picker will not hide itself correctly. +*/ +ColorPicker_targetInput = null; +function ColorPicker_writeDiv() { + document.writeln(""); + } + +function ColorPicker_show(anchorname) { + this.showPopup(anchorname); + } + +function ColorPicker_pickColor(color,obj) { + obj.hidePopup(); + pickColor(color); + } + +// A Default "pickColor" function to accept the color passed back from popup. +// User can over-ride this with their own function. +function pickColor(color) { + 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 = color; + } + +// This function is the easiest way to popup the window, select a color, and +// have the value populate a form field, which is what most people want to do. +function ColorPicker_select(inputobj,linkname) { + if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { + alert("colorpicker.select: Input object passed is not a valid form input object"); + window.ColorPicker_targetInput=null; + return; + } + window.ColorPicker_targetInput = inputobj; + this.show(linkname); + } + +// This function runs when you move your mouse over a color block, if you have a newer browser +function ColorPicker_highlightColor(c) { + var thedoc = (arguments.length>1)?arguments[1]:window.document; + var d = thedoc.getElementById("colorPickerSelectedColor"); + d.style.backgroundColor = c; + d = thedoc.getElementById("colorPickerSelectedColorValue"); + d.innerHTML = c; + } + +function ColorPicker() { + var windowMode = false; + // Create a new PopupWindow object + if (arguments.length==0) { + var divname = "colorPickerDiv"; + } + else if (arguments[0] == "window") { + var divname = ''; + windowMode = true; + } + else { + var divname = arguments[0]; + } + + if (divname != "") { + var cp = new PopupWindow(divname); + } + else { + var cp = new PopupWindow(); + cp.setSize(225,250); + } + + // Object variables + cp.currentValue = "#FFFFFF"; + + // Method Mappings + cp.writeDiv = ColorPicker_writeDiv; + cp.highlightColor = ColorPicker_highlightColor; + cp.show = ColorPicker_show; + cp.select = ColorPicker_select; + + // Code to populate color picker window + var colors = 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 total = colors.length; + var width = 72; + var cp_contents = ""; + var windowRef = (windowMode)?"window.opener.":""; + if (windowMode) { + cp_contents += "Select Color"; + cp_contents += ""; + } + cp_contents += ""; + var use_highlight = (document.getElementById || document.all)?true:false; + for (var i=0; i '; + if ( ((i+1)>=total) || (((i+1) % width) == 0)) { + cp_contents += ""; + } + } + // If the browser supports dynamically changing TD cells, add the fancy stuff + if (document.getElementById) { + var width1 = Math.floor(width/2); + var width2 = width = width1; + cp_contents += ""; + } + cp_contents += "
 #FFFFFF
"; + if (windowMode) { + cp_contents += "
"; + } + // end populate code + + // Write the contents to the popup object + cp.populate(cp_contents+"\n"); + // Move the table down a bit so you can see it + cp.offsetY = 25; + cp.autoHide(); + return cp; + } diff --git a/wp-includes/js/colorpicker.js b/wp-includes/js/colorpicker.js index 1fc32cf24..acd88a339 100644 --- a/wp-includes/js/colorpicker.js +++ b/wp-includes/js/colorpicker.js @@ -1,707 +1 @@ -// =================================================================== -// Author: Matt Kruse -// WWW: http://www.mattkruse.com/ -// -// NOTICE: You may use this code for any purpose, commercial or -// private, without any further permission from the author. You may -// remove this notice from your final code if you wish, however it is -// appreciated by the author if at least my web site address is kept. -// -// You may *NOT* re-distribute this code in any way except through its -// use. That means, you can include it in your product, or your web -// site, or any other form where the code is actually being used. You -// may not put the plain javascript up on your site for download or -// include it in your javascript libraries for download. -// If you wish to share this code with others, please just point them -// to the URL instead. -// Please DO NOT link directly to my .js files from your site. Copy -// the files to your server and use them there. Thank you. -// =================================================================== - - -/* SOURCE FILE: AnchorPosition.js */ - -/* -AnchorPosition.js -Author: Matt Kruse -Last modified: 10/11/02 - -DESCRIPTION: These functions find the position of an tag in a document, -so other elements can be positioned relative to it. - -COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small -positioning errors - usually with Window positioning - occur on the -Macintosh platform. - -FUNCTIONS: -getAnchorPosition(anchorname) - Returns an Object() having .x and .y properties of the pixel coordinates - of the upper-left corner of the anchor. Position is relative to the PAGE. - -getAnchorWindowPosition(anchorname) - Returns an Object() having .x and .y properties of the pixel coordinates - of the upper-left corner of the anchor, relative to the WHOLE SCREEN. - -NOTES: - -1) For popping up separate browser windows, use getAnchorWindowPosition. - Otherwise, use getAnchorPosition - -2) Your anchor tag MUST contain both NAME and ID attributes which are the - same. For example: - - -3) There must be at least a space between for IE5.5 to see the - anchor tag correctly. Do not do with no space. -*/ - -// getAnchorPosition(anchorname) -// This function returns an object having .x and .y properties which are the coordinates -// of the named anchor, relative to the page. -function getAnchorPosition(anchorname) { - // This function will return an Object with x and y properties - var useWindow=false; - var coordinates=new Object(); - var x=0,y=0; - // Browser capability sniffing - var use_gebi=false, use_css=false, use_layers=false; - if (document.getElementById) { use_gebi=true; } - else if (document.all) { use_css=true; } - else if (document.layers) { use_layers=true; } - // Logic to find position - if (use_gebi && document.all) { - x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); - y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); - } - else if (use_gebi) { - var o=document.getElementById(anchorname); - x=AnchorPosition_getPageOffsetLeft(o); - y=AnchorPosition_getPageOffsetTop(o); - } - else if (use_css) { - x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); - y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); - } - else if (use_layers) { - var found=0; - for (var i=0; i tags may cause errors. - -USAGE: -// Create an object for a WINDOW popup -var win = new PopupWindow(); - -// Create an object for a DIV window using the DIV named 'mydiv' -var win = new PopupWindow('mydiv'); - -// Set the window to automatically hide itself when the user clicks -// anywhere else on the page except the popup -win.autoHide(); - -// Show the window relative to the anchor name passed in -win.showPopup(anchorname); - -// Hide the popup -win.hidePopup(); - -// Set the size of the popup window (only applies to WINDOW popups -win.setSize(width,height); - -// Populate the contents of the popup window that will be shown. If you -// change the contents while it is displayed, you will need to refresh() -win.populate(string); - -// set the URL of the window, rather than populating its contents -// manually -win.setUrl("http://www.site.com/"); - -// Refresh the contents of the popup -win.refresh(); - -// Specify how many pixels to the right of the anchor the popup will appear -win.offsetX = 50; - -// Specify how many pixels below the anchor the popup will appear -win.offsetY = 100; - -NOTES: -1) Requires the functions in AnchorPosition.js - -2) Your anchor tag MUST contain both NAME and ID attributes which are the - same. For example: - - -3) There must be at least a space between for IE5.5 to see the - anchor tag correctly. Do not do with no space. - -4) When a PopupWindow object is created, a handler for 'onmouseup' is - attached to any event handler you may have already defined. Do NOT define - an event handler for 'onmouseup' after you define a PopupWindow object or - the autoHide() will not work correctly. -*/ - -// Set the position of the popup window based on the anchor -function PopupWindow_getXYPosition(anchorname) { - var coordinates; - if (this.type == "WINDOW") { - coordinates = getAnchorWindowPosition(anchorname); - } - else { - coordinates = getAnchorPosition(anchorname); - } - this.x = coordinates.x; - this.y = coordinates.y; - } -// Set width/height of DIV/popup window -function PopupWindow_setSize(width,height) { - this.width = width; - this.height = height; - } -// Fill the window with contents -function PopupWindow_populate(contents) { - this.contents = contents; - this.populated = false; - } -// Set the URL to go to -function PopupWindow_setUrl(url) { - this.url = url; - } -// Set the window popup properties -function PopupWindow_setWindowProperties(props) { - this.windowProperties = props; - } -// Refresh the displayed contents of the popup -function PopupWindow_refresh() { - if (this.divName != null) { - // refresh the DIV object - 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 d = document.layers[this.divName]; - d.document.open(); - d.document.writeln(this.contents); - d.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(); - } - } - } -// Position and show the popup, relative to an anchor object -function PopupWindow_showPopup(anchorname) { - this.getXYPosition(anchorname); - this.x += this.offsetX; - this.y += this.offsetY; - if (!this.populated && (this.contents != "")) { - this.populated = true; - this.refresh(); - } - if (this.divName != null) { - // Show the DIV object - 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 the popup window will go off-screen, move it so it doesn't - 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 avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ); - 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+""); - } - this.refresh(); - } - } -// Hide the popup -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; - } - } - } -// Pass an event and return whether or not it was the popup DIV that was clicked -function PopupWindow_isClicked(e) { - if (this.divName != null) { - if (this.use_layers) { - var clickX = e.pageX; - var clickY = e.pageY; - var t = document.layers[this.divName]; - if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) { - return true; - } - else { return false; } - } - else if (document.all) { // Need to hard-code this to trap IE for error-handling - var t = window.event.srcElement; - while (t.parentElement != null) { - if (t.id==this.divName) { - return true; - } - t = t.parentElement; - } - return false; - } - else if (this.use_gebi && e) { - var t = e.originalTarget; - while (t.parentNode != null) { - if (t.id==this.divName) { - return true; - } - t = t.parentNode; - } - return false; - } - return false; - } - return false; - } - -// Check an onMouseDown event to see if we should hide -function PopupWindow_hideIfNotClicked(e) { - if (this.autoHideEnabled && !this.isClicked(e)) { - this.hidePopup(); - } - } -// Call this to make the DIV disable automatically when mouse is clicked outside it -function PopupWindow_autoHide() { - this.autoHideEnabled = true; - } -// This global function checks all PopupWindow objects onmouseup to see if they should be hidden -function PopupWindow_hidePopupWindows(e) { - for (var i=0; i0) { - 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; - // Method mappings - 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; - } - -/* SOURCE FILE: ColorPicker2.js */ - -/* -Last modified: 02/24/2003 - -DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB -form. It uses a color "swatch" to display the standard 216-color web-safe -palette. The user can then click on a color to select it. - -COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js. -Only the latest DHTML-capable browsers will show the color and hex values -at the bottom as your mouse goes over them. - -USAGE: -// Create a new ColorPicker object using DHTML popup -var cp = new ColorPicker(); - -// Create a new ColorPicker object using Window Popup -var cp = new ColorPicker('window'); - -// Add a link in your page to trigger the popup. For example: -Pick - -// Or use the built-in "select" function to do the dirty work for you: -Pick - -// If using DHTML popup, write out the required DIV tag near the bottom -// of your page. - - -// Write the 'pickColor' function that will be called when the user clicks -// a color and do something with the value. This is only required if you -// want to do something other than simply populate a form field, which is -// what the 'select' function will give you. -function pickColor(color) { - field.value = color; - } - -NOTES: -1) Requires the functions in AnchorPosition.js and PopupWindow.js - -2) Your anchor tag MUST contain both NAME and ID attributes which are the - same. For example: - - -3) There must be at least a space between for IE5.5 to see the - anchor tag correctly. Do not do with no space. - -4) When a ColorPicker object is created, a handler for 'onmouseup' is - attached to any event handler you may have already defined. Do NOT define - an event handler for 'onmouseup' after you define a ColorPicker object or - the color picker will not hide itself correctly. -*/ -ColorPicker_targetInput = null; -function ColorPicker_writeDiv() { - document.writeln(""); - } - -function ColorPicker_show(anchorname) { - this.showPopup(anchorname); - } - -function ColorPicker_pickColor(color,obj) { - obj.hidePopup(); - pickColor(color); - } - -// A Default "pickColor" function to accept the color passed back from popup. -// User can over-ride this with their own function. -function pickColor(color) { - 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 = color; - } - -// This function is the easiest way to popup the window, select a color, and -// have the value populate a form field, which is what most people want to do. -function ColorPicker_select(inputobj,linkname) { - if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { - alert("colorpicker.select: Input object passed is not a valid form input object"); - window.ColorPicker_targetInput=null; - return; - } - window.ColorPicker_targetInput = inputobj; - this.show(linkname); - } - -// This function runs when you move your mouse over a color block, if you have a newer browser -function ColorPicker_highlightColor(c) { - var thedoc = (arguments.length>1)?arguments[1]:window.document; - var d = thedoc.getElementById("colorPickerSelectedColor"); - d.style.backgroundColor = c; - d = thedoc.getElementById("colorPickerSelectedColorValue"); - d.innerHTML = c; - } - -function ColorPicker() { - var windowMode = false; - // Create a new PopupWindow object - if (arguments.length==0) { - var divname = "colorPickerDiv"; - } - else if (arguments[0] == "window") { - var divname = ''; - windowMode = true; - } - else { - var divname = arguments[0]; - } - - if (divname != "") { - var cp = new PopupWindow(divname); - } - else { - var cp = new PopupWindow(); - cp.setSize(225,250); - } - - // Object variables - cp.currentValue = "#FFFFFF"; - - // Method Mappings - cp.writeDiv = ColorPicker_writeDiv; - cp.highlightColor = ColorPicker_highlightColor; - cp.show = ColorPicker_show; - cp.select = ColorPicker_select; - - // Code to populate color picker window - var colors = 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 total = colors.length; - var width = 72; - var cp_contents = ""; - var windowRef = (windowMode)?"window.opener.":""; - if (windowMode) { - cp_contents += "Select Color"; - cp_contents += ""; - } - cp_contents += ""; - var use_highlight = (document.getElementById || document.all)?true:false; - for (var i=0; i '; - if ( ((i+1)>=total) || (((i+1) % width) == 0)) { - cp_contents += ""; - } - } - // If the browser supports dynamically changing TD cells, add the fancy stuff - if (document.getElementById) { - var width1 = Math.floor(width/2); - var width2 = width = width1; - cp_contents += ""; - } - cp_contents += "
 #FFFFFF
"; - if (windowMode) { - cp_contents += "
"; - } - // end populate code - - // Write the contents to the popup object - cp.populate(cp_contents+"\n"); - // Move the table down a bit so you can see it - cp.offsetY = 25; - cp.autoHide(); - return cp; - } +function 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;cscreen.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)&&(da.top)&&(b0){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('')}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+="Select Color";k+=""}k+="";var l=(document.getElementById||document.all)?true:false;for(var h=0;h"}if(l){var f='onMouseOver="'+j+"ColorPicker_highlightColor('"+a[h]+"',window.document)\""}else{f=""}k+='";if(((h+1)>=n)||(((h+1)%c)==0)){k+=""}}if(document.getElementById){var d=Math.floor(c/2);var b=c=d;k+=""}k+="
 
 #FFFFFF
";if(g){k+="
"}m.populate(k+"\n");m.offsetY=25;m.autoHide();return m}; \ No newline at end of file diff --git a/wp-includes/js/comment-reply.dev.js b/wp-includes/js/comment-reply.dev.js new file mode 100644 index 000000000..20154253a --- /dev/null +++ b/wp-includes/js/comment-reply.dev.js @@ -0,0 +1,48 @@ + +addComment = { + moveForm : function(commId, parentId, respondId, postId) { + 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'); + + if ( ! comm || ! respond || ! cancel || ! parent ) + return; + + t.respondId = respondId; + postId = postId || false; + + if ( ! t.I('wp-temp-form-div') ) { + div = document.createElement('div'); + div.id = 'wp-temp-form-div'; + div.style.display = 'none'; + respond.parentNode.insertBefore(div, respond); + } + + comm.parentNode.insertBefore(respond, comm.nextSibling); + if ( post && postId ) + post.value = postId; + parent.value = parentId; + cancel.style.display = ''; + + cancel.onclick = function() { + var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId); + + if ( ! temp || ! respond ) + return; + + t.I('comment_parent').value = '0'; + temp.parentNode.insertBefore(respond, temp); + temp.parentNode.removeChild(temp); + this.style.display = 'none'; + this.onclick = null; + return false; + } + + try { t.I('comment').focus(); } + catch(e) {} + + return false; + }, + + I : function(e) { + return document.getElementById(e); + } +} diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js index 20154253a..524f2ede9 100644 --- a/wp-includes/js/comment-reply.js +++ b/wp-includes/js/comment-reply.js @@ -1,48 +1 @@ - -addComment = { - moveForm : function(commId, parentId, respondId, postId) { - 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'); - - if ( ! comm || ! respond || ! cancel || ! parent ) - return; - - t.respondId = respondId; - postId = postId || false; - - if ( ! t.I('wp-temp-form-div') ) { - div = document.createElement('div'); - div.id = 'wp-temp-form-div'; - div.style.display = 'none'; - respond.parentNode.insertBefore(div, respond); - } - - comm.parentNode.insertBefore(respond, comm.nextSibling); - if ( post && postId ) - post.value = postId; - parent.value = parentId; - cancel.style.display = ''; - - cancel.onclick = function() { - var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId); - - if ( ! temp || ! respond ) - return; - - t.I('comment_parent').value = '0'; - temp.parentNode.insertBefore(respond, temp); - temp.parentNode.removeChild(temp); - this.style.display = 'none'; - this.onclick = null; - return false; - } - - try { t.I('comment').focus(); } - catch(e) {} - - return false; - }, - - I : function(e) { - return document.getElementById(e); - } -} +addComment={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)}}; \ No newline at end of file diff --git a/wp-includes/js/hoverIntent.dev.js b/wp-includes/js/hoverIntent.dev.js new file mode 100644 index 000000000..5cbf9782b --- /dev/null +++ b/wp-includes/js/hoverIntent.dev.js @@ -0,0 +1,128 @@ +/** +* hoverIntent is similar to jQuery's built-in "hover" function except that +* instead of firing the onMouseOver event immediately, hoverIntent checks +* to see if the user's mouse has slowed down (beneath the sensitivity +* threshold) before firing the onMouseOver event. +* +* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+ +* +* +* hoverIntent is currently available for use in all personal or commercial +* projects under both MIT and GPL licenses. This means that you can choose +* the license that best suits your project, and use it accordingly. +* +* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions +* $("ul li").hoverIntent( showNav , hideNav ); +* +* // advanced usage receives configuration object only +* $("ul li").hoverIntent({ +* sensitivity: 7, // number = sensitivity threshold (must be 1 or higher) +* interval: 100, // number = milliseconds of polling interval +* over: showNav, // function = onMouseOver callback (required) +* timeout: 0, // number = milliseconds delay before onMouseOut function call +* out: hideNav // function = onMouseOut callback (required) +* }); +* +* @param f onMouseOver function || An object with configuration options +* @param g onMouseOut function || Nothing (use configuration options object) +* @author Brian Cherne +*/ +(function($) { + $.fn.hoverIntent = function(f,g) { + // default configuration options + var cfg = { + sensitivity: 7, + interval: 100, + timeout: 0 + }; + // override configuration options with user supplied object + cfg = $.extend(cfg, g ? { over: f, out: g } : f ); + + // instantiate variables + // cX, cY = current X and Y position of mouse, updated by mousemove event + // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval + var cX, cY, pX, pY; + + // A private function for getting mouse position + var track = function(ev) { + cX = ev.pageX; + cY = ev.pageY; + }; + + // A private function for comparing current and previous mouse position + var compare = function(ev,ob) { + ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); + // compare mouse positions to see if they've crossed the threshold + if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { + $(ob).unbind("mousemove",track); + // set hoverIntent state to true (so mouseOut can be called) + ob.hoverIntent_s = 1; + return cfg.over.apply(ob,[ev]); + } else { + // set previous coordinates for next time + pX = cX; pY = cY; + // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) + ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); + } + }; + + // A private function for delaying the mouseOut function + var delay = function(ev,ob) { + ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); + ob.hoverIntent_s = 0; + return cfg.out.apply(ob,[ev]); + }; + + // workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text" + var handleHover = function(e) { + var t = this; + + // next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut + var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; + while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } } + if ( p == this ) { + if ( $.browser.mozilla ) { + if ( e.type == "mouseout" ) { + t.mtout = setTimeout( function(){doHover(e,t);}, 30 ); + } else { + if (t.mtout) { t.mtout = clearTimeout(t.mtout); } + } + } + return; + } else { + if (t.mtout) { t.mtout = clearTimeout(t.mtout); } + doHover(e,t); + } + }; + + // A private function for handling mouse 'hovering' + var doHover = function(e,ob) { + + // copy objects to be passed into t (required for event object to be passed in IE) + var ev = jQuery.extend({},e); + + // cancel hoverIntent timer if it exists + if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } + + // else e.type == "onmouseover" + if (e.type == "mouseover") { + // set "previous" X and Y position based on initial entry point + pX = ev.pageX; pY = ev.pageY; + // update "current" X and Y position based on mousemove + $(ob).bind("mousemove",track); + // start polling interval (self-calling timeout) to compare mouse coordinates over time + if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} + + // else e.type == "onmouseout" + } else { + // unbind expensive mousemove event + $(ob).unbind("mousemove",track); + // if hoverIntent state is true, then call the mouseOut function after the specified delay + if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} + } + }; + + // bind the function to the two event listeners + return this.mouseover(handleHover).mouseout(handleHover); + }; +})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/hoverIntent.js b/wp-includes/js/hoverIntent.js index 5cbf9782b..bed4129c9 100644 --- a/wp-includes/js/hoverIntent.js +++ b/wp-includes/js/hoverIntent.js @@ -1,128 +1 @@ -/** -* hoverIntent is similar to jQuery's built-in "hover" function except that -* instead of firing the onMouseOver event immediately, hoverIntent checks -* to see if the user's mouse has slowed down (beneath the sensitivity -* threshold) before firing the onMouseOver event. -* -* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+ -* -* -* hoverIntent is currently available for use in all personal or commercial -* projects under both MIT and GPL licenses. This means that you can choose -* the license that best suits your project, and use it accordingly. -* -* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions -* $("ul li").hoverIntent( showNav , hideNav ); -* -* // advanced usage receives configuration object only -* $("ul li").hoverIntent({ -* sensitivity: 7, // number = sensitivity threshold (must be 1 or higher) -* interval: 100, // number = milliseconds of polling interval -* over: showNav, // function = onMouseOver callback (required) -* timeout: 0, // number = milliseconds delay before onMouseOut function call -* out: hideNav // function = onMouseOut callback (required) -* }); -* -* @param f onMouseOver function || An object with configuration options -* @param g onMouseOut function || Nothing (use configuration options object) -* @author Brian Cherne -*/ -(function($) { - $.fn.hoverIntent = function(f,g) { - // default configuration options - var cfg = { - sensitivity: 7, - interval: 100, - timeout: 0 - }; - // override configuration options with user supplied object - cfg = $.extend(cfg, g ? { over: f, out: g } : f ); - - // instantiate variables - // cX, cY = current X and Y position of mouse, updated by mousemove event - // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval - var cX, cY, pX, pY; - - // A private function for getting mouse position - var track = function(ev) { - cX = ev.pageX; - cY = ev.pageY; - }; - - // A private function for comparing current and previous mouse position - var compare = function(ev,ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - // compare mouse positions to see if they've crossed the threshold - if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { - $(ob).unbind("mousemove",track); - // set hoverIntent state to true (so mouseOut can be called) - ob.hoverIntent_s = 1; - return cfg.over.apply(ob,[ev]); - } else { - // set previous coordinates for next time - pX = cX; pY = cY; - // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) - ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); - } - }; - - // A private function for delaying the mouseOut function - var delay = function(ev,ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - ob.hoverIntent_s = 0; - return cfg.out.apply(ob,[ev]); - }; - - // workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text" - var handleHover = function(e) { - var t = this; - - // next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut - var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; - while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } } - if ( p == this ) { - if ( $.browser.mozilla ) { - if ( e.type == "mouseout" ) { - t.mtout = setTimeout( function(){doHover(e,t);}, 30 ); - } else { - if (t.mtout) { t.mtout = clearTimeout(t.mtout); } - } - } - return; - } else { - if (t.mtout) { t.mtout = clearTimeout(t.mtout); } - doHover(e,t); - } - }; - - // A private function for handling mouse 'hovering' - var doHover = function(e,ob) { - - // copy objects to be passed into t (required for event object to be passed in IE) - var ev = jQuery.extend({},e); - - // cancel hoverIntent timer if it exists - if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } - - // else e.type == "onmouseover" - if (e.type == "mouseover") { - // set "previous" X and Y position based on initial entry point - pX = ev.pageX; pY = ev.pageY; - // update "current" X and Y position based on mousemove - $(ob).bind("mousemove",track); - // start polling interval (self-calling timeout) to compare mouse coordinates over time - if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} - - // else e.type == "onmouseout" - } else { - // unbind expensive mousemove event - $(ob).unbind("mousemove",track); - // if hoverIntent state is true, then call the mouseOut function after the specified delay - if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} - } - }; - - // bind the function to the two event listeners - return this.mouseover(handleHover).mouseout(handleHover); - }; -})(jQuery); \ No newline at end of file +(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))= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else + options.data = q; // data is the query string for 'post' + + var $form = this, callbacks = []; + if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); + if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); + + // perform a load on the target only if dataType is not provided + 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 // jQuery v1.1.4 + $(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); + }; + + // are there files to upload? + var files = $('input:file', this).fieldValue(); + var found = false; + for (var j=0; j < files.length; j++) + if (files[j]) + found = true; + + // options.iframe allows user to force iframe mode + if (options.iframe || found) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if ($.browser.safari && options.closeKeepAlive) + $.get(options.closeKeepAlive, fileUpload); + else + fileUpload(); + } + else + $.ajax(options); + + // fire 'notify' event + $.event.trigger('form.submit.notify', [this, options]); + return this; + + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUpload() { + var form = $form[0]; + var opts = $.extend({}, $.ajaxSettings, options); + + var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++; + var $io = $('
"); + jQuery("#TB_overlay").click(tb_remove); + } + }else{//all others + if(document.getElementById("TB_overlay") === null){ + jQuery("body").append("
"); + jQuery("#TB_overlay").click(tb_remove); + } + } + + if(tb_detectMacXFF()){ + jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash + }else{ + jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity + } + + if(caption===null){caption="";} + jQuery("body").append("
");//add loader to the page + jQuery('#TB_load').show();//show loader + + var baseURL; + if(url.indexOf("?")!==-1){ //ff there is a query string involved + baseURL = url.substr(0, url.indexOf("?")); + }else{ + baseURL = url; + } + + var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; + var urlType = baseURL.toLowerCase().match(urlString); + + if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images + + TB_PrevCaption = ""; + TB_PrevURL = ""; + TB_PrevHTML = ""; + TB_NextCaption = ""; + TB_NextURL = ""; + TB_NextHTML = ""; + TB_imageCount = ""; + TB_FoundURL = false; + if(imageGroup){ + TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get(); + for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { + var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); + if (!(TB_TempArray[TB_Counter].href == url)) { + if (TB_FoundURL) { + TB_NextCaption = TB_TempArray[TB_Counter].title; + TB_NextURL = TB_TempArray[TB_Counter].href; + TB_NextHTML = "  Next >"; + } else { + TB_PrevCaption = TB_TempArray[TB_Counter].title; + TB_PrevURL = TB_TempArray[TB_Counter].href; + TB_PrevHTML = "  < Prev"; + } + } else { + TB_FoundURL = true; + TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); + } + } + } + + imgPreloader = new Image(); + imgPreloader.onload = function(){ + imgPreloader.onload = null; + + // Resizing large images - orginal by Christian Montoya edited by me. + var pagesize = tb_getPageSize(); + var x = pagesize[0] - 150; + var y = pagesize[1] - 150; + var imageWidth = imgPreloader.width; + var imageHeight = imgPreloader.height; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + } + } else if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + } + } + // End Resizing + + TB_WIDTH = imageWidth + 30; + TB_HEIGHT = imageHeight + 60; + jQuery("#TB_window").append(""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
"); + + jQuery("#TB_closeWindowButton").click(tb_remove); + + if (!(TB_PrevHTML === "")) { + function goPrev(){ + if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);} + jQuery("#TB_window").remove(); + jQuery("body").append("
"); + tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); + return false; + } + jQuery("#TB_prev").click(goPrev); + } + + if (!(TB_NextHTML === "")) { + function goNext(){ + jQuery("#TB_window").remove(); + jQuery("body").append("
"); + tb_show(TB_NextCaption, TB_NextURL, imageGroup); + return false; + } + jQuery("#TB_next").click(goNext); + + } + + document.onkeydown = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } else if(keycode == 190){ // display previous image + if(!(TB_NextHTML == "")){ + document.onkeydown = ""; + goNext(); + } + } else if(keycode == 188){ // display next image + if(!(TB_PrevHTML == "")){ + document.onkeydown = ""; + goPrev(); + } + } + }; + + tb_position(); + jQuery("#TB_load").remove(); + jQuery("#TB_ImageOff").click(tb_remove); + jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show + }; + + imgPreloader.src = url; + }else{//code to show html + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = tb_parseQuery( queryString ); + + TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL + TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL + ajaxContentW = TB_WIDTH - 30; + ajaxContentH = TB_HEIGHT - 45; + + if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window + urlNoQuery = url.split('TB_'); + jQuery("#TB_iframeContent").remove(); + if(params['modal'] != "true"){//iframe no modal + jQuery("#TB_window").append("
"+caption+"
"); + }else{//iframe modal + jQuery("#TB_overlay").unbind(); + jQuery("#TB_window").append(""); + } + }else{// not an iframe, ajax + if(jQuery("#TB_window").css("display") != "block"){ + if(params['modal'] != "true"){//ajax no modal + jQuery("#TB_window").append("
"+caption+"
"); + }else{//ajax modal + jQuery("#TB_overlay").unbind(); + jQuery("#TB_window").append("
"); + } + }else{//this means the window is already up, we are just loading new content via ajax + jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; + jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; + jQuery("#TB_ajaxContent")[0].scrollTop = 0; + jQuery("#TB_ajaxWindowTitle").html(caption); + } + } + + jQuery("#TB_closeWindowButton").click(tb_remove); + + if(url.indexOf('TB_inline') != -1){ + jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); + jQuery("#TB_window").unload(function () { + jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished + }); + tb_position(); + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); + }else if(url.indexOf('TB_iframe') != -1){ + tb_position(); + if($.browser.safari){//safari needs help because it will not fire iframe onload + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); + } + }else{ + jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method + tb_position(); + jQuery("#TB_load").remove(); + tb_init("#TB_ajaxContent a.thickbox"); + jQuery("#TB_window").css({display:"block"}); + }); + } + + } + + if(!params['modal']){ + document.onkeyup = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } + }; + } + + } catch(e) { + //nothing here + } +} + +//helper functions below +function tb_showIframe(){ + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); +} + +function tb_remove() { + jQuery("#TB_imageOff").unbind("click"); + jQuery("#TB_closeWindowButton").unbind("click"); + jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); + jQuery("#TB_load").remove(); + if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 + jQuery("body","html").css({height: "auto", width: "auto"}); + jQuery("html").css("overflow",""); + } + document.onkeydown = ""; + document.onkeyup = ""; + return false; +} + +function tb_position() { +jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); + if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 + jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); + } +} + +function tb_parseQuery ( query ) { + var Params = {}; + if ( ! query ) {return Params;}// return empty object + var Pairs = query.split(/[;&]/); + for ( var i = 0; i < Pairs.length; i++ ) { + var KeyVal = Pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) {continue;} + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ); + val = val.replace(/\+/g, ' '); + Params[key] = val; + } + return Params; +} + +function tb_getPageSize(){ + var de = document.documentElement; + var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; + arrayPageSize = [w,h]; + return arrayPageSize; +} + +function tb_detectMacXFF() { + var userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { + return true; + } +} + + diff --git a/wp-includes/js/thickbox/thickbox.js b/wp-includes/js/thickbox/thickbox.js index 5770c8b0a..949c87707 100644 --- a/wp-includes/js/thickbox/thickbox.js +++ b/wp-includes/js/thickbox/thickbox.js @@ -1,320 +1 @@ -/* - * Thickbox 3.1 - One Box To Rule Them All. - * By Cody Lindley (http://www.codylindley.com) - * Copyright (c) 2007 cody lindley - * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif"; -var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png"; - -/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ - -//on page load call tb_init -jQuery(document).ready(function(){ - tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox - imgLoader = new Image();// preload image - imgLoader.src = tb_pathToImage; -}); - -//add thickbox to href & area elements that have a class of .thickbox -function tb_init(domChunk){ - jQuery(domChunk).click(function(){ - var t = this.title || this.name || null; - var a = this.href || this.alt; - var g = this.rel || false; - tb_show(t,a,g); - this.blur(); - return false; - }); -} - -function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link - - try { - if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 - jQuery("body","html").css({height: "100%", width: "100%"}); - jQuery("html").css("overflow","hidden"); - if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 - jQuery("body").append("
"); - jQuery("#TB_overlay").click(tb_remove); - } - }else{//all others - if(document.getElementById("TB_overlay") === null){ - jQuery("body").append("
"); - jQuery("#TB_overlay").click(tb_remove); - } - } - - if(tb_detectMacXFF()){ - jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash - }else{ - jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity - } - - if(caption===null){caption="";} - jQuery("body").append("
");//add loader to the page - jQuery('#TB_load').show();//show loader - - var baseURL; - if(url.indexOf("?")!==-1){ //ff there is a query string involved - baseURL = url.substr(0, url.indexOf("?")); - }else{ - baseURL = url; - } - - var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; - var urlType = baseURL.toLowerCase().match(urlString); - - if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images - - TB_PrevCaption = ""; - TB_PrevURL = ""; - TB_PrevHTML = ""; - TB_NextCaption = ""; - TB_NextURL = ""; - TB_NextHTML = ""; - TB_imageCount = ""; - TB_FoundURL = false; - if(imageGroup){ - TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get(); - for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { - var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); - if (!(TB_TempArray[TB_Counter].href == url)) { - if (TB_FoundURL) { - TB_NextCaption = TB_TempArray[TB_Counter].title; - TB_NextURL = TB_TempArray[TB_Counter].href; - TB_NextHTML = "  Next >"; - } else { - TB_PrevCaption = TB_TempArray[TB_Counter].title; - TB_PrevURL = TB_TempArray[TB_Counter].href; - TB_PrevHTML = "  < Prev"; - } - } else { - TB_FoundURL = true; - TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); - } - } - } - - imgPreloader = new Image(); - imgPreloader.onload = function(){ - imgPreloader.onload = null; - - // Resizing large images - orginal by Christian Montoya edited by me. - var pagesize = tb_getPageSize(); - var x = pagesize[0] - 150; - var y = pagesize[1] - 150; - var imageWidth = imgPreloader.width; - var imageHeight = imgPreloader.height; - if (imageWidth > x) { - imageHeight = imageHeight * (x / imageWidth); - imageWidth = x; - if (imageHeight > y) { - imageWidth = imageWidth * (y / imageHeight); - imageHeight = y; - } - } else if (imageHeight > y) { - imageWidth = imageWidth * (y / imageHeight); - imageHeight = y; - if (imageWidth > x) { - imageHeight = imageHeight * (x / imageWidth); - imageWidth = x; - } - } - // End Resizing - - TB_WIDTH = imageWidth + 30; - TB_HEIGHT = imageHeight + 60; - jQuery("#TB_window").append(""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
"); - - jQuery("#TB_closeWindowButton").click(tb_remove); - - if (!(TB_PrevHTML === "")) { - function goPrev(){ - if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);} - jQuery("#TB_window").remove(); - jQuery("body").append("
"); - tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); - return false; - } - jQuery("#TB_prev").click(goPrev); - } - - if (!(TB_NextHTML === "")) { - function goNext(){ - jQuery("#TB_window").remove(); - jQuery("body").append("
"); - tb_show(TB_NextCaption, TB_NextURL, imageGroup); - return false; - } - jQuery("#TB_next").click(goNext); - - } - - document.onkeydown = function(e){ - if (e == null) { // ie - keycode = event.keyCode; - } else { // mozilla - keycode = e.which; - } - if(keycode == 27){ // close - tb_remove(); - } else if(keycode == 190){ // display previous image - if(!(TB_NextHTML == "")){ - document.onkeydown = ""; - goNext(); - } - } else if(keycode == 188){ // display next image - if(!(TB_PrevHTML == "")){ - document.onkeydown = ""; - goPrev(); - } - } - }; - - tb_position(); - jQuery("#TB_load").remove(); - jQuery("#TB_ImageOff").click(tb_remove); - jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show - }; - - imgPreloader.src = url; - }else{//code to show html - - var queryString = url.replace(/^[^\?]+\??/,''); - var params = tb_parseQuery( queryString ); - - TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL - TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL - ajaxContentW = TB_WIDTH - 30; - ajaxContentH = TB_HEIGHT - 45; - - if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window - urlNoQuery = url.split('TB_'); - jQuery("#TB_iframeContent").remove(); - if(params['modal'] != "true"){//iframe no modal - jQuery("#TB_window").append("
"+caption+"
"); - }else{//iframe modal - jQuery("#TB_overlay").unbind(); - jQuery("#TB_window").append(""); - } - }else{// not an iframe, ajax - if(jQuery("#TB_window").css("display") != "block"){ - if(params['modal'] != "true"){//ajax no modal - jQuery("#TB_window").append("
"+caption+"
"); - }else{//ajax modal - jQuery("#TB_overlay").unbind(); - jQuery("#TB_window").append("
"); - } - }else{//this means the window is already up, we are just loading new content via ajax - jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; - jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; - jQuery("#TB_ajaxContent")[0].scrollTop = 0; - jQuery("#TB_ajaxWindowTitle").html(caption); - } - } - - jQuery("#TB_closeWindowButton").click(tb_remove); - - if(url.indexOf('TB_inline') != -1){ - jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); - jQuery("#TB_window").unload(function () { - jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished - }); - tb_position(); - jQuery("#TB_load").remove(); - jQuery("#TB_window").css({display:"block"}); - }else if(url.indexOf('TB_iframe') != -1){ - tb_position(); - if($.browser.safari){//safari needs help because it will not fire iframe onload - jQuery("#TB_load").remove(); - jQuery("#TB_window").css({display:"block"}); - } - }else{ - jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method - tb_position(); - jQuery("#TB_load").remove(); - tb_init("#TB_ajaxContent a.thickbox"); - jQuery("#TB_window").css({display:"block"}); - }); - } - - } - - if(!params['modal']){ - document.onkeyup = function(e){ - if (e == null) { // ie - keycode = event.keyCode; - } else { // mozilla - keycode = e.which; - } - if(keycode == 27){ // close - tb_remove(); - } - }; - } - - } catch(e) { - //nothing here - } -} - -//helper functions below -function tb_showIframe(){ - jQuery("#TB_load").remove(); - jQuery("#TB_window").css({display:"block"}); -} - -function tb_remove() { - jQuery("#TB_imageOff").unbind("click"); - jQuery("#TB_closeWindowButton").unbind("click"); - jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); - jQuery("#TB_load").remove(); - if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 - jQuery("body","html").css({height: "auto", width: "auto"}); - jQuery("html").css("overflow",""); - } - document.onkeydown = ""; - document.onkeyup = ""; - return false; -} - -function tb_position() { -jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); - if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 - jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); - } -} - -function tb_parseQuery ( query ) { - var Params = {}; - if ( ! query ) {return Params;}// return empty object - var Pairs = query.split(/[;&]/); - for ( var i = 0; i < Pairs.length; i++ ) { - var KeyVal = Pairs[i].split('='); - if ( ! KeyVal || KeyVal.length != 2 ) {continue;} - var key = unescape( KeyVal[0] ); - var val = unescape( KeyVal[1] ); - val = val.replace(/\+/g, ' '); - Params[key] = val; - } - return Params; -} - -function tb_getPageSize(){ - var de = document.documentElement; - var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; - var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; - arrayPageSize = [w,h]; - return arrayPageSize; -} - -function tb_detectMacXFF() { - var userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { - return true; - } -} - - +var tb_pathToImage="../wp-includes/js/thickbox/loadingAnimation.gif",tb_closeImage="../wp-includes/js/thickbox/tb-close.png";jQuery(document).ready(function(){tb_init("a.thickbox, area.thickbox, input.thickbox");imgLoader=new Image();imgLoader.src=tb_pathToImage});function tb_init(a){jQuery(a).click(function(){var c=this.title||this.name||null,b=this.href||this.alt,d=this.rel||false;tb_show(c,b,d);this.blur();return false})}function tb_show(o,b,i){try{var c,f=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/,p=c.toLowerCase().match(f),g,h,n,m,l,j,a,d;if(typeof document.body.style.maxHeight==="undefined"){jQuery("body","html").css({height:"100%",width:"100%"});jQuery("html").css("overflow","hidden");if(document.getElementById("TB_HideSelect")===null){jQuery("body").append("
");jQuery("#TB_overlay").click(tb_remove)}}else{if(document.getElementById("TB_overlay")===null){jQuery("body").append("
");jQuery("#TB_overlay").click(tb_remove)}}if(tb_detectMacXFF()){jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack")}else{jQuery("#TB_overlay").addClass("TB_overlayBG")}if(o===null){o=""}jQuery("body").append("
");jQuery("#TB_load").show();if(b.indexOf("?")!==-1){c=b.substr(0,b.indexOf("?"))}else{c=b}if(p==".jpg"||p==".jpeg"||p==".png"||p==".gif"||p==".bmp"){TB_PrevCaption="";TB_PrevURL="";TB_PrevHTML="";TB_NextCaption="";TB_NextURL="";TB_NextHTML="";TB_imageCount="";TB_FoundURL=false;if(i){TB_TempArray=jQuery("a[@rel="+i+"]").get();for(TB_Counter=0;((TB_Counter  Next >"}else{TB_PrevCaption=TB_TempArray[TB_Counter].title;TB_PrevURL=TB_TempArray[TB_Counter].href;TB_PrevHTML="  < Prev"}}else{TB_FoundURL=true;TB_imageCount="Image "+(TB_Counter+1)+" of "+(TB_TempArray.length)}}}imgPreloader=new Image();imgPreloader.onload=function(){imgPreloader.onload=null;h=tb_getPageSize();n=h[0]-150;m=h[1]-150;l=imgPreloader.width;j=imgPreloader.height;if(l>n){j=j*(n/l);l=n;if(j>m){l=l*(m/j);j=m}}else{if(j>m){l=l*(m/j);j=m;if(l>n){j=j*(n/l);l=n}}}TB_WIDTH=l+30;TB_HEIGHT=j+60;jQuery("#TB_window").append(""+o+"
"+o+"
"+TB_imageCount+TB_PrevHTML+TB_NextHTML+"
");jQuery("#TB_closeWindowButton").click(tb_remove);if(!(TB_PrevHTML==="")){function q(){if(jQuery(document).unbind("click",q)){jQuery(document).unbind("click",q)}jQuery("#TB_window").remove();jQuery("body").append("
");tb_show(TB_PrevCaption,TB_PrevURL,i);return false}jQuery("#TB_prev").click(q)}if(!(TB_NextHTML==="")){function e(){jQuery("#TB_window").remove();jQuery("body").append("
");tb_show(TB_NextCaption,TB_NextURL,i);return false}jQuery("#TB_next").click(e)}document.onkeydown=function(r){if(r==null){keycode=event.keyCode}else{keycode=r.which}if(keycode==27){tb_remove()}else{if(keycode==190){if(!(TB_NextHTML=="")){document.onkeydown="";e()}}else{if(keycode==188){if(!(TB_PrevHTML=="")){document.onkeydown="";q()}}}}};tb_position();jQuery("#TB_load").remove();jQuery("#TB_ImageOff").click(tb_remove);jQuery("#TB_window").css({display:"block"})};imgPreloader.src=b}else{a=b.replace(/^[^\?]+\??/,"");d=tb_parseQuery(a);TB_WIDTH=(d.width*1)+30||630;TB_HEIGHT=(d.height*1)+40||440;ajaxContentW=TB_WIDTH-30;ajaxContentH=TB_HEIGHT-45;if(b.indexOf("TB_iframe")!=-1){urlNoQuery=b.split("TB_");jQuery("#TB_iframeContent").remove();if(d.modal!="true"){jQuery("#TB_window").append("
"+o+"
")}else{jQuery("#TB_overlay").unbind();jQuery("#TB_window").append("")}}else{if(jQuery("#TB_window").css("display")!="block"){if(d.modal!="true"){jQuery("#TB_window").append("
"+o+"
")}else{jQuery("#TB_overlay").unbind();jQuery("#TB_window").append("
")}}else{jQuery("#TB_ajaxContent")[0].style.width=ajaxContentW+"px";jQuery("#TB_ajaxContent")[0].style.height=ajaxContentH+"px";jQuery("#TB_ajaxContent")[0].scrollTop=0;jQuery("#TB_ajaxWindowTitle").html(o)}}jQuery("#TB_closeWindowButton").click(tb_remove);if(b.indexOf("TB_inline")!=-1){jQuery("#TB_ajaxContent").append(jQuery("#"+d.inlineId).children());jQuery("#TB_window").unload(function(){jQuery("#"+d.inlineId).append(jQuery("#TB_ajaxContent").children())});tb_position();jQuery("#TB_load").remove();jQuery("#TB_window").css({display:"block"})}else{if(b.indexOf("TB_iframe")!=-1){tb_position();if(jQuery.browser.safari){jQuery("#TB_load").remove();jQuery("#TB_window").css({display:"block"})}}else{jQuery("#TB_ajaxContent").load(b+="&random="+(new Date().getTime()),function(){tb_position();jQuery("#TB_load").remove();tb_init("#TB_ajaxContent a.thickbox");jQuery("#TB_window").css({display:"block"})})}}}if(!d.modal){document.onkeyup=function(q){if(q==null){keycode=event.keyCode}else{keycode=q.which}if(keycode==27){tb_remove()}}}}catch(k){}}function tb_showIframe(){jQuery("#TB_load").remove();jQuery("#TB_window").css({display:"block"})}function tb_remove(){jQuery("#TB_imageOff").unbind("click");jQuery("#TB_closeWindowButton").unbind("click");jQuery("#TB_window").fadeOut("fast",function(){jQuery("#TB_window,#TB_overlay,#TB_HideSelect").trigger("unload").unbind().remove()});jQuery("#TB_load").remove();if(typeof document.body.style.maxHeight=="undefined"){jQuery("body","html").css({height:"auto",width:"auto"});jQuery("html").css("overflow","")}document.onkeydown="";document.onkeyup="";return false}function tb_position(){jQuery("#TB_window").css({marginLeft:"-"+parseInt((TB_WIDTH/2),10)+"px",width:TB_WIDTH+"px"});if(!(jQuery.browser.msie&&jQuery.browser.version<7)){jQuery("#TB_window").css({marginTop:"-"+parseInt((TB_HEIGHT/2),10)+"px"})}}function tb_parseQuery(d){var e={},a,c,g,b,f;if(!d){return e}a=d.split(/[;&]/);for(c=0;c'; + response.errors.push( anError ); + parsed.errors = true; + } ).size() ) { response.errors = false; } + parsed.responses.push( response ); + } ); + if ( err.length ) { re.html( '
' + err + '
' ); } + return parsed; + } + if ( isNaN(x) ) { return !re.html('

' + x + '

'); } + x = parseInt(x,10); + if ( -1 == x ) { return !re.html('

' + wpAjax.noPerm + '

'); } + else if ( 0 === x ) { return !re.html('

' + wpAjax.broken + '

'); } + return true; + }, + invalidateForm: function ( selector ) { + return jQuery( selector ).addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ); + }, + validateForm: function( selector ) { + selector = jQuery( selector ); + return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size(); + } +}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } ); diff --git a/wp-includes/js/wp-ajax-response.js b/wp-includes/js/wp-ajax-response.js index d941f2179..417c73073 100644 --- a/wp-includes/js/wp-ajax-response.js +++ b/wp-includes/js/wp-ajax-response.js @@ -1,60 +1 @@ -var wpAjax = jQuery.extend( { - unserialize: function( s ) { - var r = {}; if ( !s ) { return r; } - var q = s.split('?'); if ( q[1] ) { s = q[1]; } - var pp = s.split('&'); - for ( var i in pp ) { - if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; } - var p = pp[i].split('='); - r[p[0]] = p[1]; - } - return r; - }, - parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission - var parsed = {}; - var re = jQuery('#' + r).html(''); - if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { - parsed.responses = []; - parsed.errors = false; - var err = ''; - jQuery('response', x).each( function() { - var th = jQuery(this); - var child = jQuery(this.firstChild); - var response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') }; - response.data = jQuery( 'response_data', child ).text(); - response.supplemental = {}; - if ( !jQuery( 'supplemental', child ).children().each( function() { - response.supplemental[this.nodeName] = jQuery(this).text(); - } ).size() ) { response.supplemental = false } - response.errors = []; - if ( !jQuery('wp_error', child).each( function() { - var code = jQuery(this).attr('code'); - var anError = { code: code, message: this.firstChild.nodeValue, data: false }; - var errorData = jQuery('wp_error_data[code="' + code + '"]', x); - if ( errorData ) { anError.data = errorData.get(); } - var formField = jQuery( 'form-field', errorData ).text(); - if ( formField ) { code = formField; } - if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); } - err += '

' + anError.message + '

'; - response.errors.push( anError ); - parsed.errors = true; - } ).size() ) { response.errors = false; } - parsed.responses.push( response ); - } ); - if ( err.length ) { re.html( '
' + err + '
' ); } - return parsed; - } - if ( isNaN(x) ) { return !re.html('

' + x + '

'); } - x = parseInt(x,10); - if ( -1 == x ) { return !re.html('

' + wpAjax.noPerm + '

'); } - else if ( 0 === x ) { return !re.html('

' + wpAjax.broken + '

'); } - return true; - }, - invalidateForm: function ( selector ) { - return jQuery( selector ).addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ); - }, - validateForm: function( selector ) { - selector = jQuery( selector ); - return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size(); - } -}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } ); +var wpAjax=jQuery.extend({unserialize:function(c){var d={},e,a,b,f;if(!c){return d}e=c.split("?");if(e[1]){c=e[1]}a=c.split("&");for(b in a){if(jQuery.isFunction(a.hasOwnProperty)&&!a.hasOwnProperty(b)){continue}f=a[b].split("=");d[f[0]]=f[1]}return d},parseAjaxResponse:function(a,f,g){var b={},c=jQuery("#"+f).html(""),d="";if(a&&typeof a=="object"&&a.getElementsByTagName("wp_ajax")){b.responses=[];b.errors=false;jQuery("response",a).each(function(){var h=jQuery(this),i=jQuery(this.firstChild),e;e={action:h.attr("action"),what:i.get(0).nodeName,id:i.attr("id"),oldId:i.attr("old_id"),position:i.attr("position")};e.data=jQuery("response_data",i).text();e.supplemental={};if(!jQuery("supplemental",i).children().each(function(){e.supplemental[this.nodeName]=jQuery(this).text()}).size()){e.supplemental=false}e.errors=[];if(!jQuery("wp_error",i).each(function(){var j=jQuery(this).attr("code"),m,l,k;m={code:j,message:this.firstChild.nodeValue,data:false};l=jQuery('wp_error_data[code="'+j+'"]',a);if(l){m.data=l.get()}k=jQuery("form-field",l).text();if(k){j=k}if(g){wpAjax.invalidateForm(jQuery("#"+g+' :input[name="'+j+'"]').parents(".form-field:first"))}d+="

"+m.message+"

";e.errors.push(m);b.errors=true}).size()){e.errors=false}b.responses.push(e)});if(d.length){c.html('
'+d+"
")}return b}if(isNaN(a)){return !c.html('

'+a+"

")}a=parseInt(a,10);if(-1==a){return !c.html('

'+wpAjax.noPerm+"

")}else{if(0===a){return !c.html('

'+wpAjax.broken+"

")}}return true},invalidateForm:function(a){return jQuery(a).addClass("form-invalid").change(function(){jQuery(this).removeClass("form-invalid")})},validateForm:function(a){a=jQuery(a);return !wpAjax.invalidateForm(a.find(".form-required").andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]')).size()}},wpAjax||{noPerm:"You do not have permission to do that.",broken:"An unidentified error has occurred."}); \ No newline at end of file diff --git a/wp-includes/js/wp-lists.dev.js b/wp-includes/js/wp-lists.dev.js new file mode 100644 index 000000000..e8c7dc150 --- /dev/null +++ b/wp-includes/js/wp-lists.dev.js @@ -0,0 +1,373 @@ +(function($) { +var currentFormEl = false, fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList; + +wpList = { + settings: { + url: wpListL10n.url, type: 'POST', + response: 'ajax-response', + + what: '', + alt: 'alternate', altOffset: 0, + addColor: null, delColor: null, dimAddColor: null, dimDelColor: null, + + confirm: null, + addBefore: null, addAfter: null, + delBefore: null, delAfter: null, + dimBefore: null, dimAfter: null + }, + + nonce: function(e,s) { + var url = wpAjax.unserialize(e.attr('href')); + return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0; + }, + + parseClass: function(e,t) { + var c = [], cl; + try { + cl = $(e).attr('class') || ''; + cl = cl.match(new RegExp(t+':[\\S]+')); + if ( cl ) { c = cl[0].split(':'); } + } catch(r) {} + return c; + }, + + pre: function(e,s,a) { + var bg, r; + s = $.extend( {}, this.wpList.settings, { + element: null, + nonce: 0, + target: e.get(0) + }, s || {} ); + if ( $.isFunction( s.confirm ) ) { + if ( 'add' != a ) { + bg = $('#' + s.element).css('backgroundColor'); + $('#' + s.element).css('backgroundColor', '#FF9966'); + } + r = s.confirm.call(this,e,s,a,bg); + if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); } + if ( !r ) { return false; } + } + return s; + }, + + ajaxAdd: function( e, s ) { + e = $(e); + s = s || {}; + var list = this, cls = wpList.parseClass(e,'add'), es, valid, formData; + s = wpList.pre.call( list, e, s, 'add' ); + + s.element = cls[2] || e.attr( 'id' ) || s.element || null; + if ( cls[3] ) { s.addColor = '#' + cls[3]; } + else { s.addColor = s.addColor || '#FFFF33'; } + + if ( !s ) { return false; } + + if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); } + + if ( !s.element ) { return true; } + + s.action = 'add-' + s.what; + + s.nonce = wpList.nonce(e,s); + + es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]'); + valid = wpAjax.validateForm( '#' + s.element ); + if ( !valid ) { return false; } + + s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) ); + formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize(); + if ( formData ) { s.data += '&' + formData; } + + if ( $.isFunction(s.addBefore) ) { + s = s.addBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o; + if ( !res || res.errors ) { return false; } + + if ( true === res ) { return true; } + + jQuery.each( res.responses, function() { + wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue + pos: this.position || 0, + id: this.id || 0, + oldId: this.oldId || null + } ) ); + } ); + + if ( $.isFunction(s.addAfter) ) { + o = this.complete; + this.complete = function(x,st) { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.addAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + }; + } + list.wpList.recolor(); + wpList.clear.call(list,'#' + s.element); + }; + + $.ajax( s ); + return false; + }, + + ajaxDel: function( e, s ) { + e = $(e); s = s || {}; + var list = this, cls = wpList.parseClass(e,'delete'), element, anim; + s = wpList.pre.call( list, e, s, 'delete' ); + + s.element = cls[2] || s.element || null; + if ( cls[3] ) { s.delColor = '#' + cls[3]; } + else { s.delColor = s.delColor || '#FF3333'; } + + if ( !s || !s.element ) { return false; } + + s.action = 'delete-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce }, + wpAjax.unserialize( cls[4] || '' ) + ); + + if ( $.isFunction(s.delBefore) ) { + s = s.delBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data._ajax_nonce ) { return true; } + + element = $('#' + s.element); + + if ( 'none' != s.delColor ) { + anim = 'slideUp'; + if ( element.css( 'display' ).match(/table/) ) + anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug + element + .animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' ) + .queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + } else { + list.wpList.recolor(); + } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o; + if ( !res || res.errors ) { + element.stop().stop().css( 'backgroundColor', '#FF3333' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.delAfter) ) { + o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.delAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + $.ajax( s ); + return false; + }, + + ajaxDim: function( e, s ) { + if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys + return false; + e = $(e); s = s || {}; + var list = this, cls = wpList.parseClass(e,'dim'), element, isClass, color, dimColor; + s = wpList.pre.call( list, e, s, 'dim' ); + + s.element = cls[2] || s.element || null; + s.dimClass = cls[3] || s.dimClass || null; + if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; } + else { s.dimAddColor = s.dimAddColor || '#FFFF33'; } + if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; } + else { s.dimDelColor = s.dimDelColor || '#FF3333'; } + + if ( !s || !s.element || !s.dimClass ) { return true; } + + s.action = 'dim-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce }, + wpAjax.unserialize( cls[6] || '' ) + ); + + if ( $.isFunction(s.dimBefore) ) { + s = s.dimBefore( s ); + if ( !s ) { return true; } + } + + element = $('#' + s.element); + isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass); + color = wpList.getColor( element ); + element.toggleClass( s.dimClass ) + dimColor = isClass ? s.dimAddColor : s.dimDelColor; + if ( 'none' != dimColor ) { + element + .animate( { backgroundColor: dimColor }, 'fast' ) + .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } ) + .animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + + if ( !s.data._ajax_nonce ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o; + if ( !res || res.errors ) { + element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.dimAfter) ) { + o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.dimAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + + $.ajax( s ); + return false; + }, + + // From jquery.color.js: jQuery Color Animation by John Resig + getColor: function( el ) { + if ( el.constructor == Object ) + el = el.get(0); + var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" ); + do { + color = jQuery.curCSS(elem, 'backgroundColor'); + if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") ) + break; + } while ( elem = elem.parentNode ); + return color || '#ffffff'; + }, + + add: function( e, s ) { + e = $(e); + + var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color; + if ( 'string' == typeof s ) { s = { what: s }; } + s = $.extend(_s, this.wpList.settings, s); + if ( !e.size() || !s.what ) { return false; } + if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); } + if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); } + + if ( old && old.size() ) { + old.replaceWith(e); + } else if ( isNaN(s.pos) ) { + ba = 'after'; + if ( '-' == s.pos.substr(0,1) ) { + s.pos = s.pos.substr(1); + ba = 'before'; + } + ref = list.find( '#' + s.pos ); + if ( 1 === ref.size() ) { ref[ba](e); } + else { list.append(e); } + } else if ( s.pos < 0 ) { + list.prepend(e); + } else { + list.append(e); + } + + if ( s.alt ) { + if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); } + else { e.addClass( s.alt ); } + } + + if ( 'none' != s.addColor ) { + color = wpList.getColor( e ); + e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + list.each( function() { this.wpList.process( e ); } ); + return e; + }, + + clear: function(e) { + var list = this, t, tag; + e = $(e); + if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; } + e.find(':input').each( function() { + if ( $(this).parents('.form-no-clear').size() ) + return; + t = this.type.toLowerCase(); + tag = this.tagName.toLowerCase(); + if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; } + else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; } + else if ( 'select' == tag ) { this.selectedIndex = null; } + }); + }, + + process: function(el) { + var list = this; + $("[class^=add:" + list.id + ":]", el || null) + .filter('form').submit( function() { return list.wpList.add(this); } ).end() + .not('form').click( function() { return list.wpList.add(this); } ).each( function() { + var addEl = this, c = wpList.parseClass(this,'add')[2] || addEl.id, forms, ins; + if ( !c ) { return; } + forms = []; + ins = []; // this is all really inefficient + $('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() { + ins.push(this); + var f = $(this).parents('form:first').get(0); + if ( $.inArray(f,forms) < 0 ) { forms.push(f); } + } ); + $(forms).submit( function() { + if ( 0 <= $.inArray(currentFormEl,ins) ) { + $(addEl).trigger( 'click' ); + $(currentFormEl).focus(); + return false; + } + } ); + } ); + $("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } ); + $("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } ); + }, + + recolor: function() { + var list = this, items, eo; + if ( !list.wpList.settings.alt ) { return; } + items = $('.list-item:visible', list); + if ( !items.size() ) { items = $(list).children(':visible'); } + eo = [':even',':odd']; + if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); } + items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt); + }, + + init: function() { + var lists = this; + lists.wpList.process = function(a) { + lists.each( function() { + this.wpList.process(a); + } ); + }; + lists.wpList.recolor = function() { + lists.each( function() { + this.wpList.recolor(); + } ); + }; + } +}; + +$.fn.wpList = function( settings ) { + this.each( function() { + var _this = this; + this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) }; + $.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } ); + } ); + wpList.init.call(this); + this.wpList.process(); + return this; +}; + +})(jQuery); diff --git a/wp-includes/js/wp-lists.js b/wp-includes/js/wp-lists.js index 128cf157a..32df1b041 100644 --- a/wp-includes/js/wp-lists.js +++ b/wp-includes/js/wp-lists.js @@ -1,374 +1 @@ -(function($) { -var currentFormEl = false; -var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}; - -var wpList = { - settings: { - url: wpListL10n.url, type: 'POST', - response: 'ajax-response', - - what: '', - alt: 'alternate', altOffset: 0, - addColor: null, delColor: null, dimAddColor: null, dimDelColor: null, - - confirm: null, - addBefore: null, addAfter: null, - delBefore: null, delAfter: null, - dimBefore: null, dimAfter: null - }, - - nonce: function(e,s) { - var url = wpAjax.unserialize(e.attr('href')); - return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0; - }, - - parseClass: function(e,t) { - var c = [], cl; - try { - cl = $(e).attr('class') || ''; - cl = cl.match(new RegExp(t+':[\\S]+')); - if ( cl ) { c = cl[0].split(':'); } - } catch(r) {} - return c; - }, - - pre: function(e,s,a) { - var bg; var r; - s = $.extend( {}, this.wpList.settings, { - element: null, - nonce: 0, - target: e.get(0) - }, s || {} ); - if ( $.isFunction( s.confirm ) ) { - if ( 'add' != a ) { - bg = $('#' + s.element).css('backgroundColor'); - $('#' + s.element).css('backgroundColor', '#FF9966'); - } - r = s.confirm.call(this,e,s,a,bg); - if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); } - if ( !r ) { return false; } - } - return s; - }, - - ajaxAdd: function( e, s ) { - var list = this; e = $(e); s = s || {}; - var cls = wpList.parseClass(e,'add'); - s = wpList.pre.call( list, e, s, 'add' ); - - s.element = cls[2] || e.attr( 'id' ) || s.element || null; - if ( cls[3] ) { s.addColor = '#' + cls[3]; } - else { s.addColor = s.addColor || '#FFFF33'; } - - if ( !s ) { return false; } - - if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); } - - if ( !s.element ) { return true; } - - s.action = 'add-' + s.what; - - s.nonce = wpList.nonce(e,s); - - var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]'); - var valid = wpAjax.validateForm( '#' + s.element ); - if ( !valid ) { return false; } - - s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) ); - var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize(); - if ( formData ) { s.data += '&' + formData; } - - if ( $.isFunction(s.addBefore) ) { - s = s.addBefore( s ); - if ( !s ) { return true; } - } - if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; } - - s.success = function(r) { - var res = wpAjax.parseAjaxResponse(r, s.response, s.element); - if ( !res || res.errors ) { return false; } - - if ( true === res ) { return true; } - - jQuery.each( res.responses, function() { - wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue - pos: this.position || 0, - id: this.id || 0, - oldId: this.oldId || null - } ) ); - } ); - - if ( $.isFunction(s.addAfter) ) { - var o = this.complete; - this.complete = function(x,st) { - var _s = $.extend( { xml: x, status: st, parsed: res }, s ); - s.addAfter( r, _s ); - if ( $.isFunction(o) ) { o(x,st); } - }; - } - list.wpList.recolor(); - wpList.clear.call(list,'#' + s.element); - }; - - $.ajax( s ); - return false; - }, - - ajaxDel: function( e, s ) { - var list = this; e = $(e); s = s || {}; - var cls = wpList.parseClass(e,'delete'); - s = wpList.pre.call( list, e, s, 'delete' ); - - s.element = cls[2] || s.element || null; - if ( cls[3] ) { s.delColor = '#' + cls[3]; } - else { s.delColor = s.delColor || '#FF3333'; } - - if ( !s || !s.element ) { return false; } - - s.action = 'delete-' + s.what; - - s.nonce = wpList.nonce(e,s); - - s.data = $.extend( - { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce }, - wpAjax.unserialize( cls[4] || '' ) - ); - - if ( $.isFunction(s.delBefore) ) { - s = s.delBefore( s ); - if ( !s ) { return true; } - } - if ( !s.data._ajax_nonce ) { return true; } - - var element = $('#' + s.element); - - if ( 'none' != s.delColor ) { - var anim = 'slideUp'; - if ( element.css( 'display' ).match(/table/) ) - anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug - element - .animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' ) - .queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); - } else { - list.wpList.recolor(); - } - - s.success = function(r) { - var res = wpAjax.parseAjaxResponse(r, s.response, s.element); - if ( !res || res.errors ) { - element.stop().stop().css( 'backgroundColor', '#FF3333' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); - return false; - } - if ( $.isFunction(s.delAfter) ) { - var o = this.complete; - this.complete = function(x,st) { - element.queue( function() { - var _s = $.extend( { xml: x, status: st, parsed: res }, s ); - s.delAfter( r, _s ); - if ( $.isFunction(o) ) { o(x,st); } - } ).dequeue(); - }; - } - }; - $.ajax( s ); - return false; - }, - - ajaxDim: function( e, s ) { - if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys - return false; - var list = this; e = $(e); s = s || {}; - var cls = wpList.parseClass(e,'dim'); - s = wpList.pre.call( list, e, s, 'dim' ); - - s.element = cls[2] || s.element || null; - s.dimClass = cls[3] || s.dimClass || null; - if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; } - else { s.dimAddColor = s.dimAddColor || '#FFFF33'; } - if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; } - else { s.dimDelColor = s.dimDelColor || '#FF3333'; } - - if ( !s || !s.element || !s.dimClass ) { return true; } - - s.action = 'dim-' + s.what; - - s.nonce = wpList.nonce(e,s); - - s.data = $.extend( - { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce }, - wpAjax.unserialize( cls[6] || '' ) - ); - - if ( $.isFunction(s.dimBefore) ) { - s = s.dimBefore( s ); - if ( !s ) { return true; } - } - - var element = $('#' + s.element); - var isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass); - var color = wpList.getColor( element ); - element.toggleClass( s.dimClass ) - var dimColor = isClass ? s.dimAddColor : s.dimDelColor; - if ( 'none' != dimColor ) { - element - .animate( { backgroundColor: dimColor }, 'fast' ) - .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } ) - .animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); - } - - if ( !s.data._ajax_nonce ) { return true; } - - s.success = function(r) { - var res = wpAjax.parseAjaxResponse(r, s.response, s.element); - if ( !res || res.errors ) { - element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); - return false; - } - if ( $.isFunction(s.dimAfter) ) { - var o = this.complete; - this.complete = function(x,st) { - element.queue( function() { - var _s = $.extend( { xml: x, status: st, parsed: res }, s ); - s.dimAfter( r, _s ); - if ( $.isFunction(o) ) { o(x,st); } - } ).dequeue(); - }; - } - }; - - $.ajax( s ); - return false; - }, - - // From jquery.color.js: jQuery Color Animation by John Resig - getColor: function( el ) { - if ( el.constructor == Object ) - el = el.get(0); - var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" ); - do { - color = jQuery.curCSS(elem, 'backgroundColor'); - if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") ) - break; - } while ( elem = elem.parentNode ); - return color || '#ffffff'; - }, - - add: function( e, s ) { - var list = $(this); - e = $(e); - - var old = false; - var _s = { pos: 0, id: 0, oldId: null }; - if ( 'string' == typeof s ) { s = { what: s }; } - s = $.extend(_s, this.wpList.settings, s); - if ( !e.size() || !s.what ) { return false; } - if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); } - if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); } - - if ( old && old.size() ) { - old.replaceWith(e); - } else if ( isNaN(s.pos) ) { - var ba = 'after'; - if ( '-' == s.pos.substr(0,1) ) { - s.pos = s.pos.substr(1); - ba = 'before'; - } - var ref = list.find( '#' + s.pos ); - if ( 1 === ref.size() ) { ref[ba](e); } - else { list.append(e); } - } else if ( s.pos < 0 ) { - list.prepend(e); - } else { - list.append(e); - } - - if ( s.alt ) { - if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); } - else { e.addClass( s.alt ); } - } - - if ( 'none' != s.addColor ) { - var color = wpList.getColor( e ); - e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); - } - list.each( function() { this.wpList.process( e ); } ); - return e; - }, - - clear: function(e) { - var list = this; - e = $(e); - if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; } - e.find(':input').each( function() { - if ( $(this).parents('.form-no-clear').size() ) - return; - var t = this.type.toLowerCase(); var tag = this.tagName.toLowerCase(); - if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; } - else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; } - else if ( 'select' == tag ) { this.selectedIndex = null; } - }); - }, - - process: function(el) { - var list = this; - $("[class^=add:" + list.id + ":]", el || null) - .filter('form').submit( function() { return list.wpList.add(this); } ).end() - .not('form').click( function() { return list.wpList.add(this); } ).each( function() { - var addEl = this; - var c = wpList.parseClass(this,'add')[2] || addEl.id; - if ( !c ) { return; } - var forms = []; var ins = []; // this is all really inefficient - $('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() { - ins.push(this); - var f = $(this).parents('form:first').get(0); - if ( $.inArray(f,forms) < 0 ) { forms.push(f); } - } ); - $(forms).submit( function() { - if ( 0 <= $.inArray(currentFormEl,ins) ) { - $(addEl).trigger( 'click' ); - $(currentFormEl).focus(); - return false; - } - } ); - } ); - $("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } ); - $("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } ); - }, - - recolor: function() { - var list = this; - if ( !list.wpList.settings.alt ) { return; } - var items = $('.list-item:visible', list); - if ( !items.size() ) { items = $(list).children(':visible'); } - var eo = [':even',':odd']; - if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); } - items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt); - }, - - init: function() { - var lists = this; - lists.wpList.process = function(a) { - lists.each( function() { - this.wpList.process(a); - } ); - }; - lists.wpList.recolor = function() { - lists.each( function() { - this.wpList.recolor(); - } ); - }; - } -}; - -$.fn.wpList = function( settings ) { - this.each( function() { - var _this = this; - this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) }; - $.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } ); - } ); - wpList.init.call(this); - this.wpList.process(); - return this; -}; - -})(jQuery); +(function(c){var b=false,a={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},d;d={settings:{url:wpListL10n.url,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:null,delColor:null,dimAddColor:null,dimDelColor:null,confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(h,g){var f=wpAjax.unserialize(h.attr("href"));return g.nonce||f._ajax_nonce||c("#"+g.element+" input[name=_ajax_nonce]").val()||f._wpnonce||c("#"+g.element+" input[name=_wpnonce]").val()||0},parseClass:function(i,g){var j=[],f;try{f=c(i).attr("class")||"";f=f.match(new RegExp(g+":[\\S]+"));if(f){j=f[0].split(":")}}catch(h){}return j},pre:function(j,h,f){var g,i;h=c.extend({},this.wpList.settings,{element:null,nonce:0,target:j.get(0)},h||{});if(c.isFunction(h.confirm)){if("add"!=f){g=c("#"+h.element).css("backgroundColor");c("#"+h.element).css("backgroundColor","#FF9966")}i=h.confirm.call(this,j,h,f,g);if("add"!=f){c("#"+h.element).css("backgroundColor",g)}if(!i){return false}}return h},ajaxAdd:function(k,g){k=c(k);g=g||{};var i=this,f=d.parseClass(k,"add"),l,h,j;g=d.pre.call(i,k,g,"add");g.element=f[2]||k.attr("id")||g.element||null;if(f[3]){g.addColor="#"+f[3]}else{g.addColor=g.addColor||"#FFFF33"}if(!g){return false}if(!k.is("[class^=add:"+i.id+":]")){return !d.add.call(i,k,g)}if(!g.element){return true}g.action="add-"+g.what;g.nonce=d.nonce(k,g);l=c("#"+g.element+" :input").not("[name=_ajax_nonce], [name=_wpnonce], [name=action]");h=wpAjax.validateForm("#"+g.element);if(!h){return false}g.data=c.param(c.extend({_ajax_nonce:g.nonce,action:g.action},wpAjax.unserialize(f[4]||"")));j=c.isFunction(l.fieldSerialize)?l.fieldSerialize():l.serialize();if(j){g.data+="&"+j}if(c.isFunction(g.addBefore)){g=g.addBefore(g);if(!g){return true}}if(!g.data.match(/_ajax_nonce=[a-f0-9]+/)){return true}g.success=function(m){var e=wpAjax.parseAjaxResponse(m,g.response,g.element),n;if(!e||e.errors){return false}if(true===e){return true}jQuery.each(e.responses,function(){d.add.call(i,this.data,c.extend({},g,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))});if(c.isFunction(g.addAfter)){n=this.complete;this.complete=function(o,p){var q=c.extend({xml:o,status:p,parsed:e},g);g.addAfter(m,q);if(c.isFunction(n)){n(o,p)}}}i.wpList.recolor();d.clear.call(i,"#"+g.element)};c.ajax(g);return false},ajaxDel:function(k,h){k=c(k);h=h||{};var j=this,f=d.parseClass(k,"delete"),g,i;h=d.pre.call(j,k,h,"delete");h.element=f[2]||h.element||null;if(f[3]){h.delColor="#"+f[3]}else{h.delColor=h.delColor||"#FF3333"}if(!h||!h.element){return false}h.action="delete-"+h.what;h.nonce=d.nonce(k,h);h.data=c.extend({action:h.action,id:h.element.split("-").pop(),_ajax_nonce:h.nonce},wpAjax.unserialize(f[4]||""));if(c.isFunction(h.delBefore)){h=h.delBefore(h);if(!h){return true}}if(!h.data._ajax_nonce){return true}g=c("#"+h.element);if("none"!=h.delColor){i="slideUp";if(g.css("display").match(/table/)){i="fadeOut"}g.animate({backgroundColor:h.delColor},"fast")[i]("fast").queue(function(){j.wpList.recolor();c(this).dequeue()})}else{j.wpList.recolor()}h.success=function(l){var e=wpAjax.parseAjaxResponse(l,h.response,h.element),m;if(!e||e.errors){g.stop().stop().css("backgroundColor","#FF3333").show().queue(function(){j.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(h.delAfter)){m=this.complete;this.complete=function(n,o){g.queue(function(){var p=c.extend({xml:n,status:o,parsed:e},h);h.delAfter(l,p);if(c.isFunction(m)){m(n,o)}}).dequeue()}}};c.ajax(h);return false},ajaxDim:function(l,i){if(c(l).parent().css("display")=="none"){return false}l=c(l);i=i||{};var k=this,f=d.parseClass(l,"dim"),h,m,g,j;i=d.pre.call(k,l,i,"dim");i.element=f[2]||i.element||null;i.dimClass=f[3]||i.dimClass||null;if(f[4]){i.dimAddColor="#"+f[4]}else{i.dimAddColor=i.dimAddColor||"#FFFF33"}if(f[5]){i.dimDelColor="#"+f[5]}else{i.dimDelColor=i.dimDelColor||"#FF3333"}if(!i||!i.element||!i.dimClass){return true}i.action="dim-"+i.what;i.nonce=d.nonce(l,i);i.data=c.extend({action:i.action,id:i.element.split("-").pop(),dimClass:i.dimClass,_ajax_nonce:i.nonce},wpAjax.unserialize(f[6]||""));if(c.isFunction(i.dimBefore)){i=i.dimBefore(i);if(!i){return true}}h=c("#"+i.element);m=h.toggleClass(i.dimClass).is("."+i.dimClass);g=d.getColor(h);h.toggleClass(i.dimClass);j=m?i.dimAddColor:i.dimDelColor;if("none"!=j){h.animate({backgroundColor:j},"fast").queue(function(){h.toggleClass(i.dimClass);c(this).dequeue()}).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}if(!i.data._ajax_nonce){return true}i.success=function(n){var e=wpAjax.parseAjaxResponse(n,i.response,i.element),p;if(!e||e.errors){h.stop().stop().css("backgroundColor","#FF3333")[m?"removeClass":"addClass"](i.dimClass).show().queue(function(){k.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(i.dimAfter)){p=this.complete;this.complete=function(o,q){h.queue(function(){var r=c.extend({xml:o,status:q,parsed:e},i);i.dimAfter(n,r);if(c.isFunction(p)){p(o,q)}}).dequeue()}}};c.ajax(i);return false},getColor:function(f){if(f.constructor==Object){f=f.get(0)}var g=f,e,h=new RegExp("rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)","i");do{e=jQuery.curCSS(g,"backgroundColor");if(e!=""&&e!="transparent"&&!e.match(h)||jQuery.nodeName(g,"body")){break}}while(g=g.parentNode);return e||"#ffffff"},add:function(l,h){l=c(l);var j=c(this),f=false,k={pos:0,id:0,oldId:null},m,i,g;if("string"==typeof h){h={what:h}}h=c.extend(k,this.wpList.settings,h);if(!l.size()||!h.what){return false}if(h.oldId){f=c("#"+h.what+"-"+h.oldId)}if(h.id&&(h.id!=h.oldId||!f||!f.size())){c("#"+h.what+"-"+h.id).remove()}if(f&&f.size()){f.replaceWith(l)}else{if(isNaN(h.pos)){m="after";if("-"==h.pos.substr(0,1)){h.pos=h.pos.substr(1);m="before"}i=j.find("#"+h.pos);if(1===i.size()){i[m](l)}else{j.append(l)}}else{if(h.pos<0){j.prepend(l)}else{j.append(l)}}}if(h.alt){if((j.children(":visible").index(l[0])+h.altOffset)%2){l.removeClass(h.alt)}else{l.addClass(h.alt)}}if("none"!=h.addColor){g=d.getColor(l);l.css("backgroundColor",h.addColor).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}j.each(function(){this.wpList.process(l)});return l},clear:function(i){var h=this,g,f;i=c(i);if(h.wpList&&i.parents("#"+h.id).size()){return}i.find(":input").each(function(){if(c(this).parents(".form-no-clear").size()){return}g=this.type.toLowerCase();f=this.tagName.toLowerCase();if("text"==g||"password"==g||"textarea"==f){this.value=""}else{if("checkbox"==g||"radio"==g){this.checked=false}else{if("select"==f){this.selectedIndex=null}}}})},process:function(e){var f=this;c("[class^=add:"+f.id+":]",e||null).filter("form").submit(function(){return f.wpList.add(this)}).end().not("form").click(function(){return f.wpList.add(this)}).each(function(){var j=this,i=d.parseClass(this,"add")[2]||j.id,g,h;if(!i){return}g=[];h=[];c("#"+i+" :input").focus(function(){b=this}).blur(function(){b=false}).each(function(){h.push(this);var k=c(this).parents("form:first").get(0);if(c.inArray(k,g)<0){g.push(k)}});c(g).submit(function(){if(0<=c.inArray(b,h)){c(j).trigger("click");c(b).focus();return false}})});c("[class^=delete:"+f.id+":]",e||null).click(function(){return f.wpList.del(this)});c("[class^=dim:"+f.id+":]",e||null).click(function(){return f.wpList.dim(this)})},recolor:function(){var g=this,f,e;if(!g.wpList.settings.alt){return}f=c(".list-item:visible",g);if(!f.size()){f=c(g).children(":visible")}e=[":even",":odd"];if(g.wpList.settings.altOffset%2){e.reverse()}f.filter(e[0]).addClass(g.wpList.settings.alt).end().filter(e[1]).removeClass(g.wpList.settings.alt)},init:function(){var e=this;e.wpList.process=function(f){e.each(function(){this.wpList.process(f)})};e.wpList.recolor=function(){e.each(function(){this.wpList.recolor()})}}};c.fn.wpList=function(e){this.each(function(){var f=this;this.wpList={settings:c.extend({},d.settings,{what:d.parseClass(this,"list")[1]||""},e)};c.each(a,function(g,h){f.wpList[g]=function(j,i){return d[h].call(f,j,i)}})});d.init.call(this);this.wpList.process();return this}})(jQuery); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1f1d6fb72..7eba37a01 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -40,11 +40,13 @@ function wp_default_scripts( &$scripts ) { $scripts->base_url = $guessurl; $scripts->default_version = get_bloginfo( 'version' ); + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; - $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081226' ); - $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); + $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent'), '20090102' ); - $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' ); + $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' ); + + $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20090102' ); $scripts->localize( 'quicktags', 'quicktagsL10n', array( 'quickLinks' => __('(Quick Links)'), 'wordLookup' => __('Enter a word to look up:'), @@ -58,7 +60,7 @@ function wp_default_scripts( &$scripts ) { 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};' ) ); - $scripts->add( 'colorpicker', '/wp-includes/js/colorpicker.js', array('prototype'), '3517' ); + $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); // Modify this version when tinyMCE plugins are changed. function mce_version() { @@ -66,20 +68,20 @@ function wp_default_scripts( &$scripts ) { } add_filter( 'tiny_mce_version', 'mce_version' ); - $scripts->add( 'editor', '/wp-admin/js/editor.js', false, mce_version() ); + $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", false, mce_version() ); $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); - $scripts->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20081210' ); + $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20090102' ); $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 'noPerm' => __('You do not have permission to do that.'), 'broken' => __('An unidentified error has occurred.'), 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' ) ); - $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081217' ); + $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20090102' ); - $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' ); + $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090102' ); $scripts->localize( 'wp-lists', 'wpListL10n', array( 'url' => admin_url('admin-ajax.php') ) ); @@ -96,42 +98,70 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.2.6'); - $scripts->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '2.02'); - $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.js', array('jquery'), '2.0-4561'); + $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.02m'); + $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m'); $scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' ); - $scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1b'); - $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); - $scripts->add( 'jquery-hotkeys', '/wp-includes/js/jquery/jquery.hotkeys.js', array('jquery'), '0.0.2' ); - $scripts->add( 'jquery-table-hotkeys', '/wp-includes/js/jquery/jquery.table-hotkeys.js', array('jquery', 'jquery-hotkeys'), '20081128' ); - $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430'); - $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.2.0-20081031'); + $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1bm'); + $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m'); + $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' ); + $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' ); + $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox$suffix.js", array('jquery'), '3.1-20080430m'); + + if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) { + $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.2.0-20081031'); + $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.2.0-20081031'); + $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.2.0-20081031'); + $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.2.0-20081201'); + // these error messages came from the sample swfupload js, they might need changing. + $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( + 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), + 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), + 'zero_byte_file' => __('This file is empty. Please try another.'), + 'invalid_filetype' => __('This file type is not allowed. Please try another.'), + 'default_error' => __('An error occurred in the upload. Please try again later.'), + 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), + 'upload_limit_exceeded' => __('You may only upload 1 file.'), + 'http_error' => __('HTTP error.'), + 'upload_failed' => __('Upload failed.'), + 'io_error' => __('IO error.'), + 'security_error' => __('Security error.'), + 'file_cancelled' => __('File cancelled.'), + 'upload_stopped' => __('Upload stopped.'), + 'dismiss' => __('Dismiss'), + 'crunching' => __('Crunching…'), + 'deleted' => __('Deleted'), + 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' + ) ); + } else { + $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload-all.js', false, '2.2.0-20081201m'); + // these error messages came from the sample swfupload js, they might need changing. + $scripts->localize( 'swfupload', 'swfuploadL10n', array( + 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), + 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), + 'zero_byte_file' => __('This file is empty. Please try another.'), + 'invalid_filetype' => __('This file type is not allowed. Please try another.'), + 'default_error' => __('An error occurred in the upload. Please try again later.'), + 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), + 'upload_limit_exceeded' => __('You may only upload 1 file.'), + 'http_error' => __('HTTP error.'), + 'upload_failed' => __('Upload failed.'), + 'io_error' => __('IO error.'), + 'security_error' => __('Security error.'), + 'file_cancelled' => __('File cancelled.'), + 'upload_stopped' => __('Upload stopped.'), + 'dismiss' => __('Dismiss'), + 'crunching' => __('Crunching…'), + 'deleted' => __('Deleted'), + 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' + ) ); + $scripts->add( 'swfupload-swfobject', false, array('swfupload') ); + $scripts->add( 'swfupload-queue', false, array('swfupload') ); + $scripts->add( 'swfupload-handlers', false, array('swfupload') ); + } $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.2.0-20081031'); - $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.2.0-20081031'); $scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array( 'is_lighttpd_before_150' => is_lighttpd_before_150(), ) ); - $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.2.0-20081031'); - $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.2.0-20081201'); - // these error messages came from the sample swfupload js, they might need changing. - $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( - 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), - 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), - 'zero_byte_file' => __('This file is empty. Please try another.'), - 'invalid_filetype' => __('This file type is not allowed. Please try another.'), - 'default_error' => __('An error occurred in the upload. Please try again later.'), - 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), - 'upload_limit_exceeded' => __('You may only upload 1 file.'), - 'http_error' => __('HTTP error.'), - 'upload_failed' => __('Upload failed.'), - 'io_error' => __('IO error.'), - 'security_error' => __('Security error.'), - 'file_cancelled' => __('File cancelled.'), - 'upload_stopped' => __('Upload stopped.'), - 'dismiss' => __('Dismiss'), - 'crunching' => __('Crunching…'), - 'deleted' => __('Deleted'), - 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' - ) ); $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.2' ); $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.2' ); @@ -140,19 +170,23 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); - $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210'); + $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102'); if ( is_admin() ) { - $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20081210' ); + $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' ); $scripts->localize( 'ajaxcat', 'catL10n', array( 'add' => attribute_escape(__('Add')), 'how' => __('Separate multiple categories with commas.'), 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};' ) ); - $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081210' ); - $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20081210' ); - $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20081210' ); - $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081210' ); + + $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20090102' ); + + $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('wp-lists'), '20090102' ); + + $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090102' ); + + $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20090102' ); $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 'empty' => __('Strength indicator'), 'short' => __('Very weak'), @@ -161,25 +195,31 @@ function wp_default_scripts( &$scripts ) { 'strong' => __('Strong'), 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' ) ); - $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081226' ); + + $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090102' ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) ) ); - $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20081210' ); - $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); - $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081210' ); + + $scripts->add( 'admin-users', "/wp-admin/js/users$suffix.js", array('wp-lists'), '20090102' ); + + $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' ); + + $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090102' ); $scripts->localize( 'postbox', 'postboxL10n', array( 'requestFile' => admin_url('admin-ajax.php') ) ); - $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20081210' ); + + $scripts->add( 'slug', "/wp-admin/js/slug$suffix.js", array('jquery'), '20090102' ); $scripts->localize( 'slug', 'slugL10n', array( 'requestFile' => admin_url('admin-ajax.php'), 'save' => __('Save'), 'cancel' => __('Cancel'), 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' ) ); - $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081226' ); + + $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20090102' ); $scripts->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), @@ -205,7 +245,8 @@ function wp_default_scripts( &$scripts ) { 'published' => __('Published'), 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' ) ); - $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081226' ); + + $scripts->add( 'page', "/wp-admin/js/page$suffix.js", array('jquery', 'slug', 'wp-lists', 'postbox'), '20090102' ); $scripts->localize( 'page', 'postL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'), @@ -226,18 +267,21 @@ function wp_default_scripts( &$scripts ) { 'published' => __('Published'), 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' ) ); - $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081226' ); - $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081226' ); + + $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20090102' ); + + $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20090102' ); $scripts->localize( 'comment', 'commentL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'), 'submittedOn' => __('Submitted on:'), 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};' ) ); - $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081210' ); - $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081210' ); + $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090102' ); - $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081210' ); + $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20090102' ); + + $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'interface' ), '20090102' ); $scripts->localize( 'admin-widgets', 'widgetsL10n', array( 'add' => __('Add'), 'edit' => __('Edit'), @@ -247,22 +291,22 @@ function wp_default_scripts( &$scripts ) { 'l10n_print_after' => 'try{convertEntities(widgetsL10n);}catch(e){};' )); - $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20081210' ); + $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090102' ); $scripts->localize( 'word-count', 'wordCountL10n', array( 'count' => __('Word count: %d'), 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};' )); - $scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20081210' ); + $scripts->add( 'wp-gears', "/wp-admin/js/wp-gears$suffix.js", false, '20090102' ); $scripts->localize( 'wp-gears', 'wpGearsL10n', array( 'updateCompleted' => __('Update completed.'), 'error' => __('Error:'), 'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};' )); - $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' ); + $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20090102' ); - $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081226' ); + $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'jquery-form', 'suggest' ), '20090102' ); $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.'), 'ntdeltitle' => __('Remove From Bulk Edit'), @@ -270,13 +314,13 @@ function wp_default_scripts( &$scripts ) { 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' ) ); - $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081226' ); + $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'jquery-form' ), '20090102' ); $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.'), 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' ) ); - $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20081210' ); + $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'thickbox', 'jquery' ), '20090102' ); $scripts->localize( 'plugin-install', 'plugininstallL10n', array( 'plugin_information' => __('Plugin Information:'), 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};' @@ -284,9 +328,9 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); - $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081226' ); + $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090102' ); - $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' ); + $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' ); } } diff --git a/wp-settings.php b/wp-settings.php index 692370dfc..dcaddda22 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -204,6 +204,11 @@ if (defined('WP_DEBUG') and WP_DEBUG == true) { error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE); } +// When this is defined and set to true the non-minified versions of the Javascripts will be used. +// Add define('SCRIPT_DEBUG', false); to wp-config.php to test the minified versions. +if ( !defined('SCRIPT_DEBUG') ) + define('SCRIPT_DEBUG', true); + // For an advanced caching plugin to use, static because you would only want one if ( defined('WP_CACHE') ) @include WP_CONTENT_DIR . '/advanced-cache.php';