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

git-svn-id: http://svn.automattic.com/wordpress/trunk@10291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-01-02 15:08:58 +00:00
parent f5276b5416
commit a750885c8e
84 changed files with 7456 additions and 7375 deletions

5
wp-admin/js/cat.dev.js Normal file
View File

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

View File

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

View File

@ -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 = $("<span>" + $('name', r).text() + "</span>").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');
}
});

View File

@ -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 = $("<span>" + $('name', r).text() + "</span>").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("<span>"+c("name",h).text()+"</span>").html();i=c("cat",h).attr("id");b[b.length]=new Option(f,i);d(h,g)};d=function(f,h){var g=c(h.parsed.responses[0].data);if(g.length==1){inlineEditTax.addEvents(c(g.id))}};a=function(g,f){var i=c("cat",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};if(b){c("#the-list").wpList({addAfter:e,delAfter:a})}else{c("#the-list").wpList({addAfter:d})}if(jQuery("#link-category-search-input").size()){columns.init("edit-link-categories")}else{columns.init("categories")}});

View File

@ -0,0 +1,37 @@
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 + ' <b>' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' +
$('#aa').val() + ' @ ' +
$('#hh').val() + ':' +
$('#mn').val() + '</b> '
);
return false;
});
});

View File

@ -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 + ' <b>' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' +
$('#aa').val() + ' @ ' +
$('#hh').val() + ':' +
$('#mn').val() + '</b> '
);
return false;
});
});
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>"+b("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+"</b> ");return false})});

391
wp-admin/js/common.dev.js Normal file
View File

@ -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<l; n++) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
} else {
for (n in o) {
if (o.hasOwnProperty(n)) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
}
}
return 1;
},
getHash : function(n) {
var v = this.get(n), h;
if (v) {
this.each(v.split('&'), function(v) {
v = v.split('=');
h = h || {};
h[v[0]] = v[1];
});
}
return h;
},
setHash : function(n, v, e, p, d, s) {
var o = '';
this.each(v, function(v, k) {
o += (!o ? '' : '&') + k + '=' + v;
});
this.set(n, o, e, p, d, s);
},
get : function(n) {
var c = document.cookie, e, p = n + "=", b;
if (!c)
return;
b = c.indexOf("; " + p);
if (b == -1) {
b = c.indexOf(p);
if (b != 0)
return null;
} else
b += 2;
e = c.indexOf(";", b);
if (e == -1)
e = c.length;
return decodeURIComponent(c.substring(b + p.length, e));
},
set : function(n, v, e, p, d, s) {
document.cookie = n + "=" + encodeURIComponent(v) +
((e) ? "; expires=" + e.toGMTString() : "") +
((p) ? "; path=" + p : "") +
((d) ? "; domain=" + d : "") +
((s) ? "; secure" : "");
},
remove : function(n, p) {
var d = new Date();
d.setTime(d.getTime() - 1000);
this.set(n, '', d, p, d);
}
};
// Returns the value as string. Second arg or empty string is returned when value is not set.
function getUserSetting( name, def ) {
var o = getAllUserSettings();
if ( o.hasOwnProperty(name) )
return o[name];
if ( typeof def != 'undefined' )
return def;
return '';
}
// Both name and value must be only ASCII letters, numbers or underscore
// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
function setUserSetting( name, value, del ) {
var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date(), p,
n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
if ( del ) delete o[n];
else o[n] = v;
d.setTime( d.getTime() + 31536000000 );
p = userSettings.url;
wpCookies.setHash(c, o, d, p );
wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
}
function deleteUserSetting( name ) {
setUserSetting( name, '', 1 );
}
// Returns all settings as js object.
function getAllUserSettings() {
return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
}
jQuery(document).ready( function($) {
var lastClicked = false, checks, first, last, checked;
// pulse
$('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
// Basic form validation
if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
$('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
}
// Move .updated and .error alert boxes
$('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
$('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
// screen settings tab
$('#show-settings-link').click(function () {
if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
$('#contextual-help-link-wrap').addClass('invisible');
}
$('#screen-options-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('screen-options-open') ) {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#contextual-help-link-wrap').removeClass('invisible');
$(this).removeClass('screen-options-open');
} else {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('screen-options-open');
}
});
return false;
});
// help tab
$('#contextual-help-link').click(function () {
if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
$('#screen-options-link-wrap').addClass('invisible');
}
$('#contextual-help-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('contextual-help-open') ) {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#screen-options-link-wrap').removeClass('invisible');
$(this).removeClass('contextual-help-open');
} else {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('contextual-help-open');
}
});
return false;
});
// check all checkboxes
$( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
if ( 'undefined' == e.shiftKey ) { return true; }
if ( e.shiftKey ) {
if ( !lastClicked ) { return true; }
checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
first = checks.index( lastClicked );
last = checks.index( this );
checked = $(this).attr('checked');
if ( 0 < first && 0 < last && first != last ) {
checks.slice( first, last ).attr( 'checked', function(){
if ( $(this).parents('tr').is(':visible') )
return checked ? 'checked' : '';
return '';
});
}
}
lastClicked = this;
return true;
} );
$( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
var c = $(this).attr('checked'), toggle = e.shiftKey || toggleWithKeyboard;
if ( 'undefined' == typeof toggleWithKeyboard)
toggleWithKeyboard = false;
$(this).parents( 'form:first' ).find( 'table tbody:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
if ( $(this).parents('tr').is(':hidden') )
return '';
if ( toggle )
return $(this).attr( 'checked' ) ? '' : 'checked';
else if (c)
return 'checked';
return '';
});
$(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
if ( toggle )
return '';
else if (c)
return 'checked';
return '';
});
});
});
var showNotice, adminMenu, columns;
// stub for doing better warnings
showNotice = {
warn : function(text) {
if ( confirm(text) )
return true;
return false;
},
note : function(text) {
alert(text);
}
};
(function($){
// sidebar admin menu
adminMenu = {
init : function() {
$('#adminmenu div.wp-menu-toggle').each( function() {
if ( $(this).siblings('.wp-submenu').length )
$(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
else
$(this).hide();
});
$('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
this.favorites();
$('.wp-menu-separator').click(function(){
if ( $('#wpcontent').hasClass('folded') ) {
adminMenu.fold(1);
setUserSetting( 'mfold', 'o' );
} else {
adminMenu.fold();
setUserSetting( 'mfold', 'f' );
}
});
if ( 'f' != getUserSetting( 'mfold' ) ) {
this.restoreMenuState();
} else {
this.fold();
}
},
restoreMenuState : function() {
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = getUserSetting( 'm'+i );
if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
if ( 'o' == v ) $(e).addClass('wp-menu-open');
else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
});
},
toggle : function(el) {
el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
setUserSetting( 'm'+i, v );
});
return false;
},
fold : function(off) {
if (off) {
$('#wpcontent').removeClass('folded');
$('#adminmenu li.wp-has-submenu').unbind();
} else {
$('#wpcontent').addClass('folded');
$('#adminmenu li.wp-has-submenu').hoverIntent({
over: function(e){
var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
if ( (t+h+10) > H ) {
o = (t+h+10) - H;
m.css({'marginTop':'-'+o+'px'});
} else if ( m.css('marginTop') ) {
m.css({'marginTop':''})
}
m.addClass('sub-open');
},
out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
timeout: 220,
sensitivity: 8,
interval: 100
});
}
},
favorites : function() {
$('#favorite-inside').width($('#favorite-actions').width()-4);
$('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
$('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
}
};
$(document).ready(function(){adminMenu.init();});
})(jQuery);
(function($){
// show/hide/save table columns
columns = {
init : function(page) {
$('.hide-column-tog').click( function() {
var column = $(this).val(), 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();
});

File diff suppressed because one or more lines are too long

View File

@ -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' );
} );

View File

@ -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")});

View File

@ -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( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
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();
} );

View File

@ -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( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
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('<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />');if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press h3 img").remove();c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");d()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};d()});

View File

@ -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);

File diff suppressed because one or more lines are too long

168
wp-admin/js/editor.dev.js Normal file
View File

@ -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(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
});
// 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*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
// Mark </p> if it has any attributes.
content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
// Sepatate <div> containing <p>
content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
// Remove <p> and <br />
content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
// Fix some block element newline issues
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\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*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
if ( content.indexOf('<object') != -1 ) {
content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
}
// Unmark special paragraph closing tags
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', '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(/<wp_temp>/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('<br />\\s*<br />', 'gi'), "\n\n");
pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', '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'), "<p>$1</p>\n");
pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
// pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
// Fix the pre|script tags
pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
});
return pee;
}
};

View File

@ -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(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
});
// 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*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
// Mark </p> if it has any attributes.
content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
// Sepatate <div> containing <p>
content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
// Remove <p> and <br />
content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
// Fix some block element newline issues
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\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*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
if ( content.indexOf('<object') != -1 ) {
content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
}
// Unmark special paragraph closing tags
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', '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(/<wp_temp>/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('<br />\\s*<br />', 'gi'), "\n\n");
pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', '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'), "<p>$1</p>\n");
pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
// pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
// Fix the pre|script tags
pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
a = a.replace(/<br ?\/?>[\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(/<br ?\/?>[\r\n]*/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"<wp_temp>")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(<p [^>]+>.*?)</p>","mg"),"$1</p#>");b=b.replace(new RegExp("<div([^>]*)>\\s*<p>","mgi"),"<div$1>\n\n");b=b.replace(new RegExp("\\s*<p>","mgi"),"");b=b.replace(new RegExp("\\s*</p>\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*<br ?/?>\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*<div","mg"),"\n<div");b=b.replace(new RegExp("</div>\\s*","mg"),"</div>\n");b=b.replace(new RegExp("\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*","gi"),"\n\n[caption$1[/caption]\n\n");b=b.replace(new RegExp("caption\\]\\n\\n+\\[caption","g"),"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre";b=b.replace(new RegExp("\\s*<(("+a+") ?[^>]*)\\s*>","mg"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("<li([^>]*)>","g"),"\t<li$1>");if(b.indexOf("<object")!=-1){b=b.replace(new RegExp("\\s*<param([^>]*)>\\s*","mg"),"<param$1>");b=b.replace(new RegExp("\\s*</embed>\\s*","mg"),"</embed>")}b=b.replace(new RegExp("</p#>","g"),"</p>\n");b=b.replace(new RegExp("\\s*(<p [^>]+>.*</p>)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(/<wp_temp>/g,"\n");return b},go:function(g,e){g=g||"content";e=e||this.mode||"";var b=tinyMCE.get(g)||false,f=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(g);if("tinymce"==e){if(b&&!b.isHidden()){return false}this.mode="html";a.style.color="#fff";d.className="active";c.className="";edCloseAllTags();f.style.display="none";a.value=this.wpautop(a.value);if(b){b.show()}else{tinyMCE.execCommand("mceAddControl",false,g)}setUserSetting("editor","tinymce")}else{if(!b||b.isHidden()){return false}this.mode="tinymce";c.className="active";d.className="";a.style.height=b.getContentAreaContainer().offsetHeight+6+"px";b.hide();f.style.display="block";a.style.color="";setUserSetting("editor","html")}return false},wpautop:function(a){var b="table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]";a=a+"\n\n";a=a.replace(new RegExp("<br />\\s*<br />","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(new RegExp("\\r\\n|\\r","g"),"\n");a=a.replace(new RegExp("\\n\\s*\\n+","g"),"\n\n");a=a.replace(new RegExp("([\\s\\S]+?)\\n\\n","mg"),"<p>$1</p>\n");a=a.replace(new RegExp("<p>\\s*?</p>","gi"),"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("<p>(<li.+?)</p>","gi"),"$1");a=a.replace(new RegExp("<p>\\s*<blockquote([^>]*)>","gi"),"<blockquote$1><p>");a=a.replace(new RegExp("</blockquote>\\s*</p>","gi"),"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(new RegExp("<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)","gi"),"$1");a=a.replace(new RegExp("(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/<br ?\/?>[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}};

174
wp-admin/js/gallery.dev.js Normal file
View File

@ -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<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.setup();
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
restoreSelection : function() {
var t = this;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
},
setup : function() {
var t = this, a, ed = t.editor, g;
if ( ! t.mcemode ) return;
t.restoreSelection();
t.el = ed.selection.getNode();
if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
t.el = g[0];
} else {
if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
jQuery('#insert-gallery').show();
return;
}
}
a = ed.dom.getAttrib(t.el, 'title');
a = ed.dom.decode(a);
if ( a ) {
jQuery('#update-gallery').show();
t.is_update = true;
var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i),
order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
if ( order && order[1] ) t.I('order-desc').checked = "checked";
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
} else {
jQuery('#insert-gallery').show();
}
},
update : function() {
var t = this, ed = t.editor, all = '', s;
if ( ! t.mcemode || ! t.is_update ) {
s = '[gallery'+t.getSettings()+']';
t.getWin().send_to_editor(s);
return;
}
if (t.el.nodeName != 'IMG') return;
all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
all += t.getSettings();
ed.dom.setAttrib(t.el, 'title', all);
t.getWin().tb_remove();
},
getSettings : function() {
var I = this.I, s = '';
if ( I('linkto-file').checked ) {
s += ' link="file"';
setUserSetting('galfile', '1');
}
if ( I('order-desc').checked ) {
s += ' order="DESC"';
setUserSetting('galdesc', '1');
}
if ( I('columns').value != 3 ) {
s += ' columns="'+I('columns').value+'"';
setUserSetting('galcols', I('columns').value);
}
if ( I('orderby').value != 'menu_order' ) {
s += ' orderby="'+I('orderby').value+'"';
setUserSetting('galord', I('orderby').value);
}
return s;
}
};

View File

@ -1,175 +1 @@
jQuery(function($) {
var gallerySortable;
var 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
var 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();
});
jQuery(document).ready(function($){
$('.menu_order_input').each(function(){
if ( this.value == '0' ) this.value = '';
});
if ( $('#media-items>*').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<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.setup();
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
restoreSelection : function() {
var t = this;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
},
setup : function() {
var t = this, a, f = document.forms[0], ed = t.editor, el, g;
if ( ! t.mcemode ) return;
t.restoreSelection();
t.el = ed.selection.getNode();
if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
t.el = g[0];
} else {
if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
jQuery('#insert-gallery').show();
return;
}
}
a = ed.dom.getAttrib(t.el, 'title');
a = ed.dom.decode(a);
if ( a ) {
jQuery('#update-gallery').show();
t.is_update = true;
var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
var order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
if ( order && order[1] ) t.I('order-desc').checked = "checked";
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
} else {
jQuery('#insert-gallery').show();
}
},
update : function() {
var t = this, ed = t.editor, el, all = '';
if ( ! t.mcemode || ! t.is_update ) {
var s = '[gallery'+t.getSettings()+']';
t.getWin().send_to_editor(s);
return;
}
if (t.el.nodeName != 'IMG') return;
all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
all += t.getSettings();
ed.dom.setAttrib(t.el, 'title', all);
t.getWin().tb_remove();
},
getSettings : function() {
var I = this.I, s = '';
if ( I('linkto-file').checked ) {
s += ' link="file"';
setUserSetting('galfile', '1');
}
if ( I('order-desc').checked ) {
s += ' order="DESC"';
setUserSetting('galdesc', '1');
}
if ( I('columns').value != 3 ) {
s += ' columns="'+I('columns').value+'"';
setUserSetting('galcols', I('columns').value);
}
if ( I('orderby').value != 'menu_order' ) {
s += ' orderby="'+I('orderby').value+'"';
setUserSetting('galord', I('orderby').value);
}
return s;
}
};
jQuery(document).ready(function(d){var c,e,b,a;e=function(){c=d("#media-items").sortable({items:".media-item",placeholder:"sorthelper",axis:"y",distance:2,update:b})};b=function(g,f){jQuery.each(f.element.sortable("toArray"),function(h,j){jQuery("#"+j+" .menu_order input")[0].value=(1+h)})};e();d(".menu_order_input").each(function(){if(this.value=="0"){this.value=""}});if(d("#media-items>*").length>1){a=wpgallery.getWin();d("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{d("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},restoreSelection:function(){var a=this;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},setup:function(){var f=this,c,d=f.editor,i;if(!f.mcemode){return}f.restoreSelection();f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;var e=c.match(/columns=['"]([0-9]+)['"]/),h=c.match(/link=['"]([^'"]+)['"]/i),b=c.match(/order=['"]([^'"]+)['"]/i),j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};

View File

@ -0,0 +1,262 @@
(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(
$('#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 = '', 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 += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
}
});
$('#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('<tr') ) {
$(inlineEditPost.what+id).remove();
$('#edit-'+id).before(r).remove();
var row = $(inlineEditPost.what+id);
row.hide();
if ( 'draft' == $('input[name="post_status"]').val() )
row.find('td.column-comments').hide();
inlineEditPost.addEvents(row);
row.fadeIn();
} else {
r = r.replace( /<.[^<>]*?>/g, '' );
$('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
}
} else {
$('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
}
}
, '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);

File diff suppressed because one or more lines are too long

View File

@ -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('<tr') ) {
$(inlineEditTax.what+id).remove();
$('#edit-'+id).before(r).remove();
var row = $(inlineEditTax.what+id);
row.hide();
inlineEditTax.addEvents(row);
row.fadeIn();
} else
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
} else
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
}
);
return false;
},
revert : function() {
var id = $('table.widefat tr.inline-editor').attr('id');
if ( id ) {
$('table.widefat .inline-edit-save .waiting').hide();
$('#'+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(){inlineEditTax.init();});
})(jQuery);

View File

@ -1,150 +1 @@
(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;
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('<tr') ) {
$(inlineEditTax.what+id).remove();
$('#edit-'+id).before(r).remove();
var row = $(inlineEditTax.what+id);
row.hide();
inlineEditTax.addEvents(row);
row.fadeIn();
} else
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
} else
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
}
);
return false;
},
revert : function() {
var id = $('table.widefat tr.inline-editor').attr('id');
if ( id ) {
$('table.widefat .inline-edit-save .waiting').hide();
$('#'+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(){inlineEditTax.init();});
})(jQuery);
(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";b.rows=a("tr.iedit");c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});b.addEvents(b.rows);a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){a(this).find("a.editinline").click(function(){inlineEditTax.edit(this);return false})})},edit:function(b){var i=this,d,e,f;i.revert();if(typeof(b)=="object"){b=i.getId(b)}d=a("#inline-edit").clone(true),rowData=a("#inline_"+b);a("td",d).attr("colspan",a(".widefat:first thead th:visible").length);if(a(i.what+b).hasClass("alternate")){a(d).addClass("alternate")}a(i.what+b).hide().after(d);a(':input[name="name"]',d).val(a(".name",rowData).text());a(':input[name="slug"]',d).val(a(".slug",rowData).text());e=a(".cat_parent",rowData).text();if(e!="0"){a('select[name="parent"]',d).val(e)}f=a('select[name="parent"] option[value="'+b+'"]',d);if(f.length>0){var h=f[0].className.split("-")[1],g,c=true,j;while(c){g=g.next("option");if(g.length==0){break}j=g[0].className.split("-")[1];if(j<=h){c=false}else{g.remove();g=f}}f.remove()}a(d).attr("id","edit-"+b).addClass("inline-editor").show();a(".ptitle",d).eq(0).focus();return false},save:function(d){var c,b;if(typeof(d)=="object"){d=this.getId(d)}a("table.widefat .inline-edit-save .waiting").show();c={action:"inline-save-tax",tax_type:this.type,tax_ID:d};b=a("#edit-"+d+" :input").fieldSerialize();c=b+"&"+a.param(c);a.post("admin-ajax.php",c,function(e){a("table.widefat .inline-edit-save .waiting").hide();if(e){if(-1!=e.indexOf("<tr")){a(inlineEditTax.what+d).remove();a("#edit-"+d).before(e).remove();var f=a(inlineEditTax.what+d);f.hide();inlineEditTax.addEvents(f);f.fadeIn()}else{a("#edit-"+d+" .inline-edit-save .error").html(e).show()}}else{a("#edit-"+d+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);

54
wp-admin/js/link.dev.js Normal file
View File

@ -0,0 +1,54 @@
jQuery(document).ready( function($) {
var categoryTabs, newCat, noSyncChecks = false, syncChecks, catAddAfter;
$('#link_name').focus();
// postboxes
postboxes.add_postbox_toggles('link');
// category tabs
categoryTabs = $('#category-tabs').tabs();
// Ajax Cat
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
$('#category-add-submit').click( function() { newCat.focus(); } );
syncChecks = function() {
if ( noSyncChecks )
return;
noSyncChecks = true;
var th = $(this), c = th.is(':checked'), id = th.val().toString();
$('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
noSyncChecks = false;
};
catAddAfter = function( r, s ) {
$(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 = $.trim( th.text() ), o;
$('#' + id).change( syncChecks );
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).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();
});

View File

@ -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( '<option value="' + parseInt( val, 10 ) + '"></option>' ).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('<option value="'+parseInt(m,10)+'"></option>').text(j)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:f});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");e.tabsClick(1);return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});

View File

@ -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() } );
});

View File

@ -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<d)?720:d;if(e.size()){e.width(b-50).height(c-45);a("#TB_iframeContent").width(b-50).height(c-75);e.css({"margin-left":"-"+parseInt(((b-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){e.css({top:"20px","margin-top":"0"})}a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"})}return a("a.thickbox").each(function(){var f=a(this).attr("href");if(!f){return}f=f.replace(/&width=[0-9]+/g,"");f=f.replace(/&height=[0-9]+/g,"");a(this).attr("href",f+"&width="+(b-80)+"&height="+(c-85))})};a("a.thickbox").click(function(){if(typeof tinyMCE!="undefined"&&tinyMCE.activeEditor){tinyMCE.get("content").focus();tinyMCE.activeEditor.windowManager.bookmark=tinyMCE.activeEditor.selection.getBookmark("simple")}});a(window).resize(function(){tb_position()})});

199
wp-admin/js/page.dev.js Normal file
View File

@ -0,0 +1,199 @@
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(), 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 + ' <b>' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' +
$('#aa').val() + ' @ ' +
$('#hh').val() + ':' +
$('#mn').val() + '</b> '
);
}
if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
$('#publish').val( postL10n.update );
if ( $('#post_status option[value=publish]').length == 0 ) {
$('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
}
$('#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;
});
});

File diff suppressed because one or more lines are too long

View File

@ -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;
}

View File

@ -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;
}
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};

View File

@ -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('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(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;
});
});

View File

@ -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('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(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;
});
});
jQuery(document).ready(function(b){var a=function(){var f=b("#TB_window"),e=b(window).width(),d=b(window).height(),c=(720<e)?720:e;if(f.size()){f.width(c-50).height(d-45);b("#TB_iframeContent").width(c-50).height(d-75);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(!(b.browser.msie&&b.browser.version.substr(0,1)<7)){f.css({top:"20px","margin-top":"0"})}}return b("a.thickbox").each(function(){var g=b(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");b(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85))})};a().click(function(){b("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});b("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+b(this).attr("title"));return false});b(window).resize(function(){tb_position()});b("#install-plugins tbody.plugins tr").click(function(){b(this).find(".action-links a.onclick").click();return false});b("#plugin-information #sidemenu a").click(function(){var c=b(this).attr("name");b("#plugin-information-header a.current").removeClass("current");b(this).addClass("current");b("#section-holder div.section").hide();b("#section-"+c).show();return false})});

490
wp-admin/js/post.dev.js Normal file
View File

@ -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 = '<span><a id="' + button_id + '" class="ntdelbutton">X</a>&nbsp;' + val + '</span> ';
jQuery(taxbox).find('.tagchecklist').append(txt);
jQuery( '#' + button_id ).click( new_tag_remove_tag );
}
});
if ( shown )
jQuery(taxbox).find('.tagchecklist').prepend('<strong>'+postL10n.tagsUsed+'</strong><br />');
}
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 = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
$('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 = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).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 + ' <b>' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' +
$('#aa').val() + ' @ ' +
$('#hh').val() + ':' +
$('#mn').val() + '</b> '
);
}
if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
$('#publish').val( postL10n.update );
if ( $('#post_status option[value=publish]').length == 0 ) {
$('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
}
$('#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('<tr><td colspan="5">'+wpAjax.broken+'</td></tr>');
}
);
return false;
}
};
})(jQuery);

File diff suppressed because one or more lines are too long

104
wp-admin/js/postbox.dev.js Normal file
View File

@ -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));

View File

@ -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));

41
wp-admin/js/slug.dev.js Normal file
View File

@ -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('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
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('<input type="text" id="new-post-slug" value="'+slug_value+'" />').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()});
}

View File

@ -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('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
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('<input type="text" id="new-post-slug" value="'+slug_value+'" />').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('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+"</a>");k.children(".save").click(function(){var b=g.children("input").val();jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_slug:b,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(c){jQuery("#edit-slug-box").html(c);k.html(l);m.attr("value",b);make_slugedit_clickable()});return false});jQuery("#edit-slug-buttons .cancel").click(function(){g.html(j);k.html(l);m.attr("value",n);return false});for(d=0;d<f.length;++d){if("%"==f.charAt(d)){h++}}slug_value=(h>f.length/4)?"":f;g.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(13==b){k.children(".save").click();return false}if(27==b){k.children(".cancel").click();return false}m.attr("value",this.value)}).focus()}function make_slugedit_clickable(){jQuery("#editable-post-name").click(function(){jQuery("#edit-slug-buttons").children(".edit-slug").click()})};

28
wp-admin/js/tags.dev.js Normal file
View File

@ -0,0 +1,28 @@
jQuery(document).ready(function($) {
var options = false, addAfter, addAfter2, delAfter;
addAfter = function( r, settings ) {
var name = $("<span>" + $('name', r).text() + "</span>").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');
});

View File

@ -1,30 +1 @@
jQuery(function($) {
var options = false
var addAfter = function( r, settings ) {
var name = $("<span>" + $('name', r).text() + "</span>").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');
});
jQuery(document).ready(function(c){var b=false,e,d,a;e=function(h,g){var f=c("<span>"+c("name",h).text()+"</span>").html(),i=c("tag",h).attr("id");b[b.length]=new Option(f,i)};d=function(f,h){var g=c(h.parsed.responses[0].data);if(g.length==1){inlineEditTax.addEvents(c(g.id))}};a=function(g,f){var i=c("tag",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};if(b){c("#the-list").wpList({addAfter:e,delAfter:a})}else{c("#the-list").wpList({addAfter:d})}columns.init("edit-tags")});

View File

@ -0,0 +1,40 @@
jQuery(document).ready(function($) {
if ( 'undefined' == typeof $.fn.pngFix )
$.fn.pngFix = function() { return this; }
var thickDims = function() {
var tbWindow = $('#TB_window'), H = $(window).height(), 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'), url = alink.attr('href'), text = alink.html();
$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
$('#TB_closeAjaxWindow').css({'float':'left'});
$('#TB_ajaxWindowTitle').css({'float':'right'})
.append('&nbsp;<a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>');
$('#TB_iframeContent').width('100%');
return false;
} );
$(window).resize( function() { thickDims() } );
});

View File

@ -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('&nbsp;<a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>');
$('#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('&nbsp;<a href="'+c+'" target="_top" class="tb-theme-preview-link">'+e+"</a>");b("#TB_iframeContent").width("100%");return false});b(window).resize(function(){a()})});

150
wp-admin/js/widgets.dev.js Normal file
View File

@ -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( '<div class="updated"><p>' + widgetsL10n.lameReminder + '</p></div>' );
$('#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( '<textarea>' + oldLi.html() + '</textarea>' );
}
// 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();
});

View File

@ -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( '<div class="updated"><p>' + widgetsL10n.lameReminder + '</p></div>' );
$('#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( '<textarea>' + oldLi.html() + '</textarea>' );
}
// 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('<div class="updated"><p>'+widgetsL10n.lameReminder+"</p></div>");e("#current-widgets .submit input[name=save-widgets]").css("background-color","#ffffe0").click(function(){window.onbeforeunload=null});a=true};var j=1;var g=function(k,m){var l=k.find("input.widget-width").val();var n=e.browser.msie?function(){var o=e(this);if(o.is(":visible")){if(m){o.find(":input:enabled").not('[name="widget-id[]"], [name*="[submit]"]').attr("disabled","disabled")}k.css("marginLeft",0);o.siblings("div").children("h4").children("a").text(widgetsL10n.edit)}else{o.find(":disabled").attr("disabled","");if(l>250){k.css("marginLeft",(l-250)*-1)}o.siblings("div").children("h4").children("a").text(widgetsL10n.cancel)}o.toggle()}:function(){var o=e(this);if(o.is(":visible")){if(m){o.find(":input:enabled").not('[name="widget-id[]"], [name*="[submit]"]').attr("disabled","disabled")}if(l>250){k.animate({marginLeft:0})}o.siblings("div").children("h4").children("a").text(widgetsL10n.edit)}else{o.find(":disabled").attr("disabled","");if(l>250){k.animate({marginLeft:(l-250)*-1})}o.siblings("div").children("h4").children("a").text(widgetsL10n.cancel)}o.animate({height:"toggle"})};return k.children("div.widget-control").each(n).end()};var b=function(){var l=wpAjax.unserialize(this.href);if((l.sidebar&&l.sidebar==e("#sidebar").val())||l.add){var k=l.edit||l.add;g(e('#current-sidebar .widget-control-list input[@name^="widget-id"][@value='+k+"]").parents("li:first"),false).blur();return false}else{if(l.sidebar){return true}}g(e(this).parents("li:first"),true).blur();return false};var c=function(){var o=e(this).parents("li:first").find("ul.widget-control-info li");var l=o.clone();if(l.html().match(/%i%/)){var k=e("#generated-time").val()+j.toString();j++;l.html(l.html().replace(/%i%/g,k))}else{e(this).text(widgetsL10n.edit).unbind().click(b);o.html("<textarea>"+o.html()+"</textarea>")}f(l);i.append(l).SortableAddItem(l[0]);var m=parseInt(e("#widget-count").text(),10)+1;e("#widget-count").text(m.toString());h();return false};var f=function(k){if(!k){k=document}e("a.widget-control-edit",k).click(b);e("a.widget-control-save",k).click(function(){h();g(e(this).parents("li:first"),false).blur();return false});e("a.widget-control-remove",k).click(function(){var l=e(this).parents("li:first").find('input[@name^="widget-id"]').val();e(this).parents("li:first").remove();var m=e("#widget-list ul#widget-control-info-"+l+" textarea");m.parent().html(m.text()).parents("li.widget-list-item:first").children("h4").children("a.widget-action").show().text(widgetsL10n.add).unbind().click(c);var o=parseInt(e("#widget-count").text(),10)-1;e("#widget-count").text(o.toString());return false})};f();e("a.widget-control-add").click(c);var i;var d=function(){try{e("#current-sidebar .widget-control-list").SortableDestroy()}catch(k){}i=e("#current-sidebar .widget-control-list").Sortable({accept:"widget-sortable",helperclass:"sorthelper",handle:"h4.widget-title",onStop:d})};d()});

View File

@ -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/, '<span id="word-count">0</span>' ) );
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( /&nbsp;/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));

View File

@ -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/, '<span id="word-count">0</span>' ) );
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( /&nbsp;/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/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));

View File

@ -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 };
})();

View File

@ -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}}})();

41
wp-admin/js/xfn.dev.js Normal file
View File

@ -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);

View File

@ -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);
function GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;b<d.length;b++){if(d[b].className==c){e[e.length]=d[b]}}return e}function meChecked(){var b,a=document.getElementById("me");if(a==b){return false}else{return a.checked}}function upit(){var b=meChecked(),e=GetElementsWithClassName("input","valinp"),d=document.getElementById("link_rel"),a="",c;for(c=0;c<e.length;c++){e[c].disabled=b;e[c].parentNode.className=b?"disabled":"";if(!b&&e[c].checked&&e[c].value!=""){a+=e[c].value+" "}}a=a.substr(0,a.length-1);if(b){a="me"}d.value=a}function blurry(){if(!document.getElementById){return}var b=document.getElementsByTagName("input"),a;for(a=0;a<b.length;a++){b[a].onclick=b[a].onkeyup=upit}}addLoadEvent(blurry);

View File

@ -0,0 +1,209 @@
var autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, 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'), message = '', postID;
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 ) {
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), 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
});
}

View File

@ -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})};

View File

@ -0,0 +1,707 @@
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// 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 <A> 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:
<A NAME="test" ID="test"> </A>
3) There must be at least a space between <A> </A> for IE5.5 to see the
anchor tag correctly. Do not do <A></A> 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<document.anchors.length; i++) {
if (document.anchors[i].name==anchorname) { found=1; break; }
}
if (found==0) {
coordinates.x=0; coordinates.y=0; return coordinates;
}
x=document.anchors[i].x;
y=document.anchors[i].y;
}
else {
coordinates.x=0; coordinates.y=0; return coordinates;
}
coordinates.x=x;
coordinates.y=y;
return coordinates;
}
// getAnchorWindowPosition(anchorname)
// This function returns an object having .x and .y properties which are the coordinates
// of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
var coordinates=getAnchorPosition(anchorname);
var x=0;
var y=0;
if (document.getElementById) {
if (isNaN(window.screenX)) {
x=coordinates.x-document.body.scrollLeft+window.screenLeft;
y=coordinates.y-document.body.scrollTop+window.screenTop;
}
else {
x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
}
}
else if (document.all) {
x=coordinates.x-document.body.scrollLeft+window.screenLeft;
y=coordinates.y-document.body.scrollTop+window.screenTop;
}
else if (document.layers) {
x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
}
coordinates.x=x;
coordinates.y=y;
return coordinates;
}
// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
var ol=el.offsetLeft;
while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
return ol;
}
function AnchorPosition_getWindowOffsetLeft (el) {
return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}
function AnchorPosition_getPageOffsetTop (el) {
var ot=el.offsetTop;
while((el=el.offsetParent) != null) { ot += el.offsetTop; }
return ot;
}
function AnchorPosition_getWindowOffsetTop (el) {
return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}
/* SOURCE FILE: PopupWindow.js */
/*
PopupWindow.js
Author: Matt Kruse
Last modified: 02/16/04
DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.
COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
window with <STYLE> 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:
<A NAME="test" ID="test"> </A>
3) There must be at least a space between <A> </A> for IE5.5 to see the
anchor tag correctly. Do not do <A></A> 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; i<popupWindowObjects.length; i++) {
if (popupWindowObjects[i] != null) {
var p = popupWindowObjects[i];
p.hideIfNotClicked(e);
}
}
}
// Run this immediately to attach the event listener
function PopupWindow_attachListener() {
if (document.layers) {
document.captureEvents(Event.MOUSEUP);
}
window.popupWindowOldEventListener = document.onmouseup;
if (window.popupWindowOldEventListener != null) {
document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
}
else {
document.onmouseup = PopupWindow_hidePopupWindows;
}
}
// CONSTRUCTOR for the PopupWindow object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupWindow() {
if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
if (!window.listenerAttached) {
window.listenerAttached = true;
PopupWindow_attachListener();
}
this.index = popupWindowIndex++;
popupWindowObjects[this.index] = this;
this.divName = null;
this.popupWindow = null;
this.width=0;
this.height=0;
this.populated = false;
this.visible = false;
this.autoHideEnabled = false;
this.contents = "";
this.url="";
this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
if (arguments.length>0) {
this.type="DIV";
this.divName = arguments[0];
}
else {
this.type="WINDOW";
}
this.use_gebi = false;
this.use_css = false;
this.use_layers = false;
if (document.getElementById) { this.use_gebi = true; }
else if (document.all) { this.use_css = true; }
else if (document.layers) { this.use_layers = true; }
else { this.type = "WINDOW"; }
this.offsetX = 0;
this.offsetY = 0;
// 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:
<A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A>
// Or use the built-in "select" function to do the dirty work for you:
<A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A>
// If using DHTML popup, write out the required DIV tag near the bottom
// of your page.
<SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
// 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:
<A NAME="test" ID="test"> </A>
3) There must be at least a space between <A> </A> for IE5.5 to see the
anchor tag correctly. Do not do <A></A> 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("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
}
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 += "<html><head><title>Select Color</title></head>";
cp_contents += "<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>";
}
cp_contents += "<table style='border: none;' cellspacing=0 cellpadding=0>";
var use_highlight = (document.getElementById || document.all)?true:false;
for (var i=0; i<total; i++) {
if ((i % width) == 0) { cp_contents += "<tr>"; }
if (use_highlight) { var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"'; }
else { mo = ""; }
cp_contents += '<td style="background-color: '+colors[i]+';"><a href="javascript:void()" onclick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+'>&nbsp;</a></td>';
if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
cp_contents += "</tr>";
}
}
// 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 += "<tr><td colspan='"+width1+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+width2+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>";
}
cp_contents += "</table>";
if (windowMode) {
cp_contents += "</span></body></html>";
}
// 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;
}

File diff suppressed because one or more lines are too long

View File

@ -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);
}
}

View File

@ -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)}};

View File

@ -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+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* 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 <brian@cherne.net>
*/
(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);

View File

@ -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+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* 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 <brian@cherne.net>
*/
(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);
(function(a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery);

View File

@ -0,0 +1,128 @@
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){
// We override the animation for all of these color styles
jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
jQuery.fx.step[attr] = function(fx){
if ( fx.state == 0 ) {
fx.start = getColor( fx.elem, attr );
fx.end = getRGB( fx.end );
}
fx.elem.style[attr] = "rgb(" + [
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
].join(",") + ")";
}
});
// Color Conversion functions from highlightFade
// By Blair Mitchelmore
// http://jquery.offput.ca/highlightFade/
// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
var result;
// Check if we're already dealing with an array of colors
if ( color && color.constructor == Array && color.length == 3 )
return color;
// Look for rgb(num,num,num)
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
// Look for rgb(num%,num%,num%)
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
// Look for #a0b1c2
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
// Look for #fff
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
return colors['transparent']
// Otherwise, we're most likely dealing with a named color
return colors[jQuery.trim(color).toLowerCase()];
}
function getColor(elem, attr) {
var color;
do {
color = jQuery.curCSS(elem, attr);
// Keep going until we find an element that has color, or we hit the body
if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
break;
attr = "backgroundColor";
} while ( elem = elem.parentNode );
return getRGB(color);
};
// Some named colors to work with
// From Interface by Stefan Petre
// http://interface.eyecon.ro/
var colors = {
aqua:[0,255,255],
azure:[240,255,255],
beige:[245,245,220],
black:[0,0,0],
blue:[0,0,255],
brown:[165,42,42],
cyan:[0,255,255],
darkblue:[0,0,139],
darkcyan:[0,139,139],
darkgrey:[169,169,169],
darkgreen:[0,100,0],
darkkhaki:[189,183,107],
darkmagenta:[139,0,139],
darkolivegreen:[85,107,47],
darkorange:[255,140,0],
darkorchid:[153,50,204],
darkred:[139,0,0],
darksalmon:[233,150,122],
darkviolet:[148,0,211],
fuchsia:[255,0,255],
gold:[255,215,0],
green:[0,128,0],
indigo:[75,0,130],
khaki:[240,230,140],
lightblue:[173,216,230],
lightcyan:[224,255,255],
lightgreen:[144,238,144],
lightgrey:[211,211,211],
lightpink:[255,182,193],
lightyellow:[255,255,224],
lime:[0,255,0],
magenta:[255,0,255],
maroon:[128,0,0],
navy:[0,0,128],
olive:[128,128,0],
orange:[255,165,0],
pink:[255,192,203],
purple:[128,0,128],
violet:[128,0,128],
red:[255,0,0],
silver:[192,192,192],
white:[255,255,255],
yellow:[255,255,0],
transparent: [255,255,255]
};
})(jQuery);

View File

@ -1,128 +1 @@
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){
// We override the animation for all of these color styles
jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
jQuery.fx.step[attr] = function(fx){
if ( fx.state == 0 ) {
fx.start = getColor( fx.elem, attr );
fx.end = getRGB( fx.end );
}
fx.elem.style[attr] = "rgb(" + [
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
].join(",") + ")";
}
});
// Color Conversion functions from highlightFade
// By Blair Mitchelmore
// http://jquery.offput.ca/highlightFade/
// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
var result;
// Check if we're already dealing with an array of colors
if ( color && color.constructor == Array && color.length == 3 )
return color;
// Look for rgb(num,num,num)
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
// Look for rgb(num%,num%,num%)
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
// Look for #a0b1c2
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
// Look for #fff
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
return colors['transparent']
// Otherwise, we're most likely dealing with a named color
return colors[jQuery.trim(color).toLowerCase()];
}
function getColor(elem, attr) {
var color;
do {
color = jQuery.curCSS(elem, attr);
// Keep going until we find an element that has color, or we hit the body
if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
break;
attr = "backgroundColor";
} while ( elem = elem.parentNode );
return getRGB(color);
};
// Some named colors to work with
// From Interface by Stefan Petre
// http://interface.eyecon.ro/
var colors = {
aqua:[0,255,255],
azure:[240,255,255],
beige:[245,245,220],
black:[0,0,0],
blue:[0,0,255],
brown:[165,42,42],
cyan:[0,255,255],
darkblue:[0,0,139],
darkcyan:[0,139,139],
darkgrey:[169,169,169],
darkgreen:[0,100,0],
darkkhaki:[189,183,107],
darkmagenta:[139,0,139],
darkolivegreen:[85,107,47],
darkorange:[255,140,0],
darkorchid:[153,50,204],
darkred:[139,0,0],
darksalmon:[233,150,122],
darkviolet:[148,0,211],
fuchsia:[255,0,255],
gold:[255,215,0],
green:[0,128,0],
indigo:[75,0,130],
khaki:[240,230,140],
lightblue:[173,216,230],
lightcyan:[224,255,255],
lightgreen:[144,238,144],
lightgrey:[211,211,211],
lightpink:[255,182,193],
lightyellow:[255,255,224],
lime:[0,255,0],
magenta:[255,0,255],
maroon:[128,0,0],
navy:[0,0,128],
olive:[128,128,0],
orange:[255,165,0],
pink:[255,192,203],
purple:[128,0,128],
violet:[128,0,128],
red:[255,0,0],
silver:[192,192,192],
white:[255,255,255],
yellow:[255,255,0],
transparent: [255,255,255]
};
})(jQuery);
(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(g.state==0){g.start=c(g.elem,e);g.end=b(g.end)}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);

View File

@ -0,0 +1,872 @@
/*
* jQuery Form Plugin
* version: 2.02 (12/16/2007)
* @requires jQuery v1.1 or later
*
* Examples at: http://malsup.com/jquery/form/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*/
(function($) {
/**
* ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
*
* ajaxSubmit accepts a single argument which can be either a success callback function
* or an options Object. If a function is provided it will be invoked upon successful
* completion of the submit and will be passed the response from the server.
* If an options Object is provided, the following attributes are supported:
*
* target: Identifies the element(s) in the page to be updated with the server response.
* This value may be specified as a jQuery selection string, a jQuery object,
* or a DOM element.
* default value: null
*
* url: URL to which the form data will be submitted.
* default value: value of form's 'action' attribute
*
* type: The method in which the form data should be submitted, 'GET' or 'POST'.
* default value: value of form's 'method' attribute (or 'GET' if none found)
*
* data: Additional data to add to the request, specified as key/value pairs (see $.ajax).
*
* beforeSubmit: Callback method to be invoked before the form is submitted.
* default value: null
*
* success: Callback method to be invoked after the form has been successfully submitted
* and the response has been returned from the server
* default value: null
*
* dataType: Expected dataType of the response. One of: null, 'xml', 'script', or 'json'
* default value: null
*
* semantic: Boolean flag indicating whether data must be submitted in semantic order (slower).
* default value: false
*
* resetForm: Boolean flag indicating whether the form should be reset if the submit is successful
*
* clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful
*
*
* The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for
* validating the form data. If the 'beforeSubmit' callback returns false then the form will
* not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data
* in array format, the jQuery object, and the options object passed into ajaxSubmit.
* The form data array takes the following form:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* If a 'success' callback method is provided it is invoked after the response has been returned
* from the server. It is passed the responseText or responseXML value (depending on dataType).
* See jQuery.ajax for further details.
*
*
* The dataType option provides a means for specifying how the server response should be handled.
* This maps directly to the jQuery.httpData method. The following values are supported:
*
* 'xml': if dataType == 'xml' the server response is treated as XML and the 'success'
* callback method, if specified, will be passed the responseXML value
* 'json': if dataType == 'json' the server response will be evaluted and passed to
* the 'success' callback, if specified
* 'script': if dataType == 'script' the server response is evaluated in the global context
*
*
* Note that it does not make sense to use both the 'target' and 'dataType' options. If both
* are provided the target will be ignored.
*
* The semantic argument can be used to force form serialization in semantic order.
* This is normally true anyway, unless the form contains input elements of type='image'.
* If your form must be submitted with name/value pairs in semantic order and your form
* contains an input of type='image" then pass true for this arg, otherwise pass false
* (or nothing) to avoid the overhead for this logic.
*
*
* When used on its own, ajaxSubmit() is typically bound to a form's submit event like this:
*
* $("#form-id").submit(function() {
* $(this).ajaxSubmit(options);
* return false; // cancel conventional submit
* });
*
* When using ajaxForm(), however, this is done for you.
*
* @example
* $('#myForm').ajaxSubmit(function(data) {
* alert('Form submit succeeded! Server returned: ' + data);
* });
* @desc Submit form and alert server response
*
*
* @example
* var options = {
* target: '#myTargetDiv'
* };
* $('#myForm').ajaxSubmit(options);
* @desc Submit form and update page element with server response
*
*
* @example
* var options = {
* success: function(responseText) {
* alert(responseText);
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc Submit form and alert the server response
*
*
* @example
* var options = {
* beforeSubmit: function(formArray, jqForm) {
* if (formArray.length == 0) {
* alert('Please enter data.');
* return false;
* }
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc Pre-submit validation which aborts the submit operation if form data is empty
*
*
* @example
* var options = {
* url: myJsonUrl.php,
* dataType: 'json',
* success: function(data) {
* // 'data' is an object representing the the evaluated json data
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc json data returned and evaluated
*
*
* @example
* var options = {
* url: myXmlUrl.php,
* dataType: 'xml',
* success: function(responseXML) {
* // responseXML is XML document object
* var data = $('myElement', responseXML).text();
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc XML data returned from server
*
*
* @example
* var options = {
* resetForm: true
* };
* $('#myForm').ajaxSubmit(options);
* @desc submit form and reset it if successful
*
* @example
* $('#myForm).submit(function() {
* $(this).ajaxSubmit();
* return false;
* });
* @desc Bind form's submit event to use ajaxSubmit
*
*
* @name ajaxSubmit
* @type jQuery
* @param options object literal containing options which control the form submission process
* @cat Plugins/Form
* @return jQuery
*/
$.fn.ajaxSubmit = function(options) {
if (typeof options == 'function')
options = { success: options };
options = $.extend({
url: this.attr('action') || window.location.toString(),
type: this.attr('method') || 'GET'
}, options || {});
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
$.event.trigger('form.pre.serialize', [this, options, veto]);
if (veto.veto) return this;
var a = this.formToArray(options.semantic);
if (options.data) {
for (var n in options.data)
a.push( { name: n, value: options.data[n] } );
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this;
// fire vetoable 'validate' event
$.event.trigger('form.submit.validate', [a, this, options, veto]);
if (veto.veto) return this;
var q = $.param(a);//.replace(/%20/g,'+');
if (options.type.toUpperCase() == 'GET') {
options.url += (options.url.indexOf('?') >= 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 = $('<iframe id="' + id + '" name="' + id + '" />');
var io = $io[0];
var op8 = $.browser.opera && window.opera.version() < 9;
if ($.browser.msie || op8) io.src = 'javascript:false;document.write("");';
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
var xhr = { // mock object
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {}
};
var g = opts.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && ! $.active++) $.event.trigger("ajaxStart");
if (g) $.event.trigger("ajaxSend", [xhr, opts]);
var cbInvoked = 0;
var timedOut = 0;
// take a breath so that pending repaints get some cpu time before the upload starts
setTimeout(function() {
// make sure form attrs are set
var encAttr = form.encoding ? 'encoding' : 'enctype';
var t = $form.attr('target');
$form.attr({
target: id,
method: 'POST',
action: opts.url
});
form[encAttr] = 'multipart/form-data';
// support timout
if (opts.timeout)
setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
// add iframe to doc and submit the form
$io.appendTo('body');
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
form.submit();
$form.attr('target', t); // reset target
}, 10);
function cb() {
if (cbInvoked++) return;
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
var ok = true;
try {
if (timedOut) throw 'timeout';
// extract the server response from the iframe
var data, doc;
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
xhr.responseText = doc.body ? doc.body.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
if (opts.dataType == 'json' || opts.dataType == 'script') {
var ta = doc.getElementsByTagName('textarea')[0];
data = ta ? ta.value : xhr.responseText;
if (opts.dataType == 'json')
eval("data = " + data);
else
$.globalEval(data);
}
else if (opts.dataType == 'xml') {
data = xhr.responseXML;
if (!data && xhr.responseText != null)
data = toXml(xhr.responseText);
}
else {
data = xhr.responseText;
}
}
catch(e){
ok = false;
$.handleError(opts, xhr, 'error', e);
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (ok) {
opts.success(data, 'success');
if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
}
if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
if (g && ! --$.active) $.event.trigger("ajaxStop");
if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
// clean up
setTimeout(function() {
$io.remove();
xhr.responseXML = null;
}, 100);
};
function toXml(s, doc) {
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
}
else
doc = (new DOMParser()).parseFromString(s, 'text/xml');
return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
};
};
};
$.fn.ajaxSubmit.counter = 0; // used to create unique iframe ids
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image" /> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* Note that for accurate x/y coordinates of image submit elements in all browsers
* you need to also use the "dimensions" plugin (this method will auto-detect its presence).
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself. See ajaxSubmit for a full description of the options argument.
*
*
* @example
* var options = {
* target: '#myTargetDiv'
* };
* $('#myForm').ajaxSForm(options);
* @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response
* when the form is submitted.
*
*
* @example
* var options = {
* success: function(responseText) {
* alert(responseText);
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc Bind form's submit event so that server response is alerted after the form is submitted.
*
*
* @example
* var options = {
* beforeSubmit: function(formArray, jqForm) {
* if (formArray.length == 0) {
* alert('Please enter data.');
* return false;
* }
* }
* };
* $('#myForm').ajaxSubmit(options);
* @desc Bind form's submit event so that pre-submit callback is invoked before the form
* is submitted.
*
*
* @name ajaxForm
* @param options object literal containing options which control the form submission process
* @return jQuery
* @cat Plugins/Form
* @type jQuery
*/
$.fn.ajaxForm = function(options) {
return this.ajaxFormUnbind().submit(submitHandler).each(function() {
// store options in hash
this.formPluginId = $.fn.ajaxForm.counter++;
$.fn.ajaxForm.optionHash[this.formPluginId] = options;
$(":submit,input:image", this).click(clickHandler);
});
};
$.fn.ajaxForm.counter = 1;
$.fn.ajaxForm.optionHash = {};
function clickHandler(e) {
var $form = this.form;
$form.clk = this;
if (this.type == 'image') {
if (e.offsetX != undefined) {
$form.clk_x = e.offsetX;
$form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
var offset = $(this).offset();
$form.clk_x = e.pageX - offset.left;
$form.clk_y = e.pageY - offset.top;
} else {
$form.clk_x = e.pageX - this.offsetLeft;
$form.clk_y = e.pageY - this.offsetTop;
}
}
// clear form vars
setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null; }, 10);
};
function submitHandler() {
// retrieve options from hash
var id = this.formPluginId;
var options = $.fn.ajaxForm.optionHash[id];
$(this).ajaxSubmit(options);
return false;
};
/**
* ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
*
* @name ajaxFormUnbind
* @return jQuery
* @cat Plugins/Form
* @type jQuery
*/
$.fn.ajaxFormUnbind = function() {
this.unbind('submit', submitHandler);
return this.each(function() {
$(":submit,input:image", this).unbind('click', clickHandler);
});
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*
* The semantic argument can be used to force form serialization in semantic order.
* This is normally true anyway, unless the form contains input elements of type='image'.
* If your form must be submitted with name/value pairs in semantic order and your form
* contains an input of type='image" then pass true for this arg, otherwise pass false
* (or nothing) to avoid the overhead for this logic.
*
* @example var data = $("#myForm").formToArray();
* $.post( "myscript.cgi", data );
* @desc Collect all the data from a form and submit it to the server.
*
* @name formToArray
* @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
* @type Array<Object>
* @cat Plugins/Form
*/
$.fn.formToArray = function(semantic) {
var a = [];
if (this.length == 0) return a;
var form = this[0];
var els = semantic ? form.getElementsByTagName('*') : form.elements;
if (!els) return a;
for(var i=0, max=els.length; i < max; i++) {
var el = els[i];
var n = el.name;
if (!n) continue;
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if(!el.disabled && form.clk == el)
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
continue;
}
var v = $.fieldValue(el, true);
if (v && v.constructor == Array) {
for(var j=0, jmax=v.length; j < jmax; j++)
a.push({name: n, value: v[j]});
}
else if (v !== null && typeof v != 'undefined')
a.push({name: n, value: v});
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle them here
var inputs = form.getElementsByTagName("input");
for(var i=0, max=inputs.length; i < max; i++) {
var input = inputs[i];
var n = input.name;
if(n && !input.disabled && input.type == "image" && form.clk == input)
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&amp;name2=value2
*
* The semantic argument can be used to force form serialization in semantic order.
* If your form must be submitted with name/value pairs in semantic order then pass
* true for this arg, otherwise pass false (or nothing) to avoid the overhead for
* this logic (which can be significant for very large forms).
*
* @example var data = $("#myForm").formSerialize();
* $.ajax('POST', "myscript.cgi", data);
* @desc Collect all the data from a form into a single string
*
* @name formSerialize
* @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
* @type String
* @cat Plugins/Form
*/
$.fn.formSerialize = function(semantic) {
//hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&amp;name2=value2
*
* The successful argument controls whether or not serialization is limited to
* 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true.
*
* @example var data = $("input").formSerialize();
* @desc Collect the data from all successful input elements into a query string
*
* @example var data = $(":radio").formSerialize();
* @desc Collect the data from all successful radio input elements into a query string
*
* @example var data = $("#myForm :checkbox").formSerialize();
* @desc Collect the data from all successful checkbox input elements in myForm into a query string
*
* @example var data = $("#myForm :checkbox").formSerialize(false);
* @desc Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string
*
* @example var data = $(":input").formSerialize();
* @desc Collect the data from all successful input, select, textarea and button elements into a query string
*
* @name fieldSerialize
* @param successful true if only successful controls should be serialized (default is true)
* @type String
* @cat Plugins/Form
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) return;
var v = $.fieldValue(this, successful);
if (v && v.constructor == Array) {
for (var i=0,max=v.length; i < max; i++)
a.push({name: n, value: v[i]});
}
else if (v !== null && typeof v != 'undefined')
a.push({name: this.name, value: v});
});
//hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text" />
* <input name="A" type="text" />
* <input name="B" type="checkbox" value="B1" />
* <input name="B" type="checkbox" value="B2"/>
* <input name="C" type="radio" value="C1" />
* <input name="C" type="radio" value="C2" />
* </fieldset></form>
*
* var v = $(':text').fieldValue();
* // if no values are entered into the text inputs
* v == ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v == ['foo','bar']
*
* var v = $(':checkbox').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $(':radio').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v == ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*
* @example var data = $("#myPasswordElement").fieldValue();
* alert(data[0]);
* @desc Alerts the current value of the myPasswordElement element
*
* @example var data = $("#myForm :input").fieldValue();
* @desc Get the value(s) of the form elements in myForm
*
* @example var data = $("#myForm :checkbox").fieldValue();
* @desc Get the value(s) for the successful checkbox element(s) in the jQuery object.
*
* @example var data = $("#mySingleSelect").fieldValue();
* @desc Get the value(s) of the select control
*
* @example var data = $(':text').fieldValue();
* @desc Get the value(s) of the text input or textarea elements
*
* @example var data = $("#myMultiSelect").fieldValue();
* @desc Get the values for the select-multiple control
*
* @name fieldValue
* @param Boolean successful true if only the values for successful controls should be returned (default is true)
* @type Array<String>
* @cat Plugins/Form
*/
$.fn.fieldValue = function(successful) {
for (var val=[], i=0, max=this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
continue;
v.constructor == Array ? $.merge(val, v) : val.push(v);
}
return val;
};
/**
* Returns the value of the field element.
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If the given element is not
* successful and the successful arg is not false then the returned value will be null.
*
* Note: If the successful flag is true (default) but the element is not successful, the return will be null
* Note: The value returned for a successful select-multiple element will always be an array.
* Note: If the element has no value the return value will be undefined.
*
* @example var data = jQuery.fieldValue($("#myPasswordElement")[0]);
* @desc Gets the current value of the myPasswordElement element
*
* @name fieldValue
* @param Element el The DOM element for which the value will be returned
* @param Boolean successful true if value returned must be for a successful controls (default is true)
* @type String or Array<String> or null or undefined
* @cat Plugins/Form
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (typeof successful == 'undefined') successful = true;
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && !el.checked ||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
tag == 'select' && el.selectedIndex == -1))
return null;
if (tag == 'select') {
var index = el.selectedIndex;
if (index < 0) return null;
var a = [], ops = el.options;
var one = (t == 'select-one');
var max = (one ? index+1 : ops.length);
for(var i=(one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected) {
// extra pain for IE...
var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
if (one) return v;
a.push(v);
}
}
return a;
}
return el.value;
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*
* @example $('form').clearForm();
* @desc Clears all forms on the page.
*
* @name clearForm
* @type jQuery
* @cat Plugins/Form
*/
$.fn.clearForm = function() {
return this.each(function() {
$('input,select,textarea', this).clearFields();
});
};
/**
* Clears the selected form elements. Takes the following actions on the matched elements:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*
* @example $('.myInputs').clearFields();
* @desc Clears all inputs with class myInputs
*
* @name clearFields
* @type jQuery
* @cat Plugins/Form
*/
$.fn.clearFields = $.fn.clearInputs = function() {
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == 'text' || t == 'password' || tag == 'textarea')
this.value = '';
else if (t == 'checkbox' || t == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};
/**
* Resets the form data. Causes all form elements to be reset to their original value.
*
* @example $('form').resetForm();
* @desc Resets all forms on the page.
*
* @name resetForm
* @type jQuery
* @cat Plugins/Form
*/
$.fn.resetForm = function() {
return this.each(function() {
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
this.reset();
});
};
/**
* Enables or disables any matching elements.
*
* @example $(':radio').enabled(false);
* @desc Disables all radio buttons
*
* @name select
* @type jQuery
* @cat Plugins/Form
*/
$.fn.enable = function(b) {
if (b == undefined) b = true;
return this.each(function() {
this.disabled = !b
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*
* @example $(':checkbox').selected();
* @desc Checks all checkboxes
*
* @name select
* @type jQuery
* @cat Plugins/Form
*/
$.fn.select = function(select) {
if (select == undefined) select = true;
return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio')
this.checked = select;
else if (this.tagName.toLowerCase() == 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type == 'select-one') {
// deselect all other options
$sel.find('option').select(false);
}
this.selected = select;
}
});
};
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,128 @@
/******************************************************************************************************************************
* @ Original idea by by Binny V A, Original version: 2.00.A
* @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
* @ Original License : BSD
* @ jQuery Plugin by Tzury Bar Yochay
mail: tzury.by@gmail.com
blog: evalinux.wordpress.com
face: facebook.com/profile.php?id=513676303
(c) Copyrights 2007
* @ jQuery Plugin version Beta (0.0.2)
* @ License: jQuery-License.
TODO:
add queue support (as in gmail) e.g. 'x' then 'y', etc.
add mouse + mouse wheel events.
USAGE:
$.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
$.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
$.hotkeys.remove('Ctrl+c');
$.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
******************************************************************************************************************************/
(function (jQuery){
this.version = '(beta)(0.0.3)';
this.all = {};
this.special_keys = {
27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
".":">", "/":"?", "\\":"|" };
this.add = function(combi, options, callback) {
if (jQuery.isFunction(options)){
callback = options;
options = {};
}
var opt = {},
defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
that = this;
opt = jQuery.extend( opt , defaults, options || {} );
combi = combi.toLowerCase();
// inspect if keystroke matches
var inspector = function(event) {
event = jQuery.event.fix(event); // jQuery event normalization.
var element = event.target;
// @ TextNode -> nodeType == 3
element = (element.nodeType==3) ? element.parentNode : element;
if(opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
var target = jQuery(element);
if( target.is("input") || target.is("textarea")){
return;
}
}
var code = event.which,
type = event.type,
character = String.fromCharCode(code).toLowerCase(),
special = that.special_keys[code],
shift = event.shiftKey,
ctrl = event.ctrlKey,
alt= event.altKey,
meta = event.metaKey,
propagate = true, // default behaivour
mapPoint = null;
// in opera + safari, the event.target is unpredictable.
// for example: 'keydown' might be associated with HtmlBodyElement
// or the element where you last clicked with your mouse.
if (jQuery.browser.opera || jQuery.browser.safari){
while (!that.all[element] && element.parentNode){
element = element.parentNode;
}
}
var cbMap = that.all[element].events[type].callbackMap;
if(!shift && !ctrl && !alt && !meta) { // No Modifiers
mapPoint = cbMap[special] || cbMap[character]
}
// deals with combinaitons (alt|ctrl|shift+anything)
else{
var modif = '';
if(alt) modif +='alt+';
if(ctrl) modif+= 'ctrl+';
if(shift) modif += 'shift+';
if(meta) modif += 'meta+';
// modifiers + special keys or modifiers + characters or modifiers + shift characters
mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
}
if (mapPoint){
mapPoint.cb(event);
if(!mapPoint.propagate) {
event.stopPropagation();
event.preventDefault();
return false;
}
}
};
// first hook for this element
if (!this.all[opt.target]){
this.all[opt.target] = {events:{}};
}
if (!this.all[opt.target].events[opt.type]){
this.all[opt.target].events[opt.type] = {callbackMap: {}}
jQuery.event.add(opt.target, opt.type, inspector);
}
this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
return jQuery;
};
this.remove = function(exp, opt) {
opt = opt || {};
target = opt.target || jQuery('html')[0];
type = opt.type || 'keydown';
exp = exp.toLowerCase();
delete this.all[target].events[type].callbackMap[exp]
return jQuery;
};
jQuery.hotkeys = this;
return jQuery;
})(jQuery);

View File

@ -1,128 +1 @@
/******************************************************************************************************************************
* @ Original idea by by Binny V A, Original version: 2.00.A
* @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
* @ Original License : BSD
* @ jQuery Plugin by Tzury Bar Yochay
mail: tzury.by@gmail.com
blog: evalinux.wordpress.com
face: facebook.com/profile.php?id=513676303
(c) Copyrights 2007
* @ jQuery Plugin version Beta (0.0.2)
* @ License: jQuery-License.
TODO:
add queue support (as in gmail) e.g. 'x' then 'y', etc.
add mouse + mouse wheel events.
USAGE:
$.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
$.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
$.hotkeys.remove('Ctrl+c');
$.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
******************************************************************************************************************************/
(function (jQuery){
this.version = '(beta)(0.0.3)';
this.all = {};
this.special_keys = {
27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
".":">", "/":"?", "\\":"|" };
this.add = function(combi, options, callback) {
if (jQuery.isFunction(options)){
callback = options;
options = {};
}
var opt = {},
defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
that = this;
opt = jQuery.extend( opt , defaults, options || {} );
combi = combi.toLowerCase();
// inspect if keystroke matches
var inspector = function(event) {
event = jQuery.event.fix(event); // jQuery event normalization.
var element = event.target;
// @ TextNode -> nodeType == 3
element = (element.nodeType==3) ? element.parentNode : element;
if(opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
var target = jQuery(element);
if( target.is("input") || target.is("textarea")){
return;
}
}
var code = event.which,
type = event.type,
character = String.fromCharCode(code).toLowerCase(),
special = that.special_keys[code],
shift = event.shiftKey,
ctrl = event.ctrlKey,
alt= event.altKey,
meta = event.metaKey,
propagate = true, // default behaivour
mapPoint = null;
// in opera + safari, the event.target is unpredictable.
// for example: 'keydown' might be associated with HtmlBodyElement
// or the element where you last clicked with your mouse.
if (jQuery.browser.opera || jQuery.browser.safari){
while (!that.all[element] && element.parentNode){
element = element.parentNode;
}
}
var cbMap = that.all[element].events[type].callbackMap;
if(!shift && !ctrl && !alt && !meta) { // No Modifiers
mapPoint = cbMap[special] || cbMap[character]
}
// deals with combinaitons (alt|ctrl|shift+anything)
else{
var modif = '';
if(alt) modif +='alt+';
if(ctrl) modif+= 'ctrl+';
if(shift) modif += 'shift+';
if(meta) modif += 'meta+';
// modifiers + special keys or modifiers + characters or modifiers + shift characters
mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
}
if (mapPoint){
mapPoint.cb(event);
if(!mapPoint.propagate) {
event.stopPropagation();
event.preventDefault();
return false;
}
}
};
// first hook for this element
if (!this.all[opt.target]){
this.all[opt.target] = {events:{}};
}
if (!this.all[opt.target].events[opt.type]){
this.all[opt.target].events[opt.type] = {callbackMap: {}}
jQuery.event.add(opt.target, opt.type, inspector);
}
this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
return jQuery;
};
this.remove = function(exp, opt) {
opt = opt || {};
target = opt.target || jQuery('html')[0];
type = opt.type || 'keydown';
exp = exp.toLowerCase();
delete this.all[target].events[type].callbackMap[exp]
return jQuery;
};
jQuery.hotkeys = this;
return jQuery;
})(jQuery);
(function(a){this.version="(beta)(0.0.3)";this.all={};this.special_keys={27:"esc",9:"tab",32:"space",13:"return",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"};this.shift_nums={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"};this.add=function(c,b,h){if(a.isFunction(b)){h=b;b={}}var d={},f={type:"keydown",propagate:false,disableInInput:false,target:a("html")[0]},e=this;d=a.extend(d,f,b||{});c=c.toLowerCase();var g=function(j){j=a.event.fix(j);var o=j.target;o=(o.nodeType==3)?o.parentNode:o;if(d.disableInInput){var s=a(o);if(s.is("input")||s.is("textarea")){return}}var l=j.which,u=j.type,r=String.fromCharCode(l).toLowerCase(),t=e.special_keys[l],m=j.shiftKey,i=j.ctrlKey,p=j.altKey,w=j.metaKey,q=true,k=null;if(a.browser.opera||a.browser.safari){while(!e.all[o]&&o.parentNode){o=o.parentNode}}var v=e.all[o].events[u].callbackMap;if(!m&&!i&&!p&&!w){k=v[t]||v[r]}else{var n="";if(p){n+="alt+"}if(i){n+="ctrl+"}if(m){n+="shift+"}if(w){n+="meta+"}k=v[n+t]||v[n+r]||v[n+e.shift_nums[r]]}if(k){k.cb(j);if(!k.propagate){j.stopPropagation();j.preventDefault();return false}}};if(!this.all[d.target]){this.all[d.target]={events:{}}}if(!this.all[d.target].events[d.type]){this.all[d.target].events[d.type]={callbackMap:{}};a.event.add(d.target,d.type,g)}this.all[d.target].events[d.type].callbackMap[c]={cb:h,propagate:d.propagate};return a};this.remove=function(c,b){b=b||{};target=b.target||a("html")[0];type=b.type||"keydown";c=c.toLowerCase();delete this.all[target].events[type].callbackMap[c];return a};a.hotkeys=this;return a})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,99 @@
(function($){
$.fn.filter_visible = function(depth) {
depth = depth || 3;
var is_visible = function() {
var p = $(this), i;
for(i=0; i<depth-1; ++i) {
if (!p.is(':visible')) return false;
p = p.parent();
}
return true;
}
return this.filter(is_visible);
};
$.table_hotkeys = function(table, keys, opts) {
opts = $.extend($.table_hotkeys.defaults, opts);
var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row;
selected_class = opts.class_prefix + opts.selected_suffix;
destructive_class = opts.class_prefix + opts.destructive_suffix
set_current_row = function (tr) {
if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
tr.addClass(selected_class);
tr[0].scrollIntoView(false);
$.table_hotkeys.current_row = tr;
};
adjacent_row_callback = function(which) {
if (!adjacent_row(which) && $.isFunction(opts[which+'_page_link_cb'])) {
opts[which+'_page_link_cb']();
}
};
get_adjacent_row = function(which) {
var first_row, method;
if (!$.table_hotkeys.current_row) {
first_row = get_first_row();
$.table_hotkeys.current_row = first_row;
return first_row[0];
}
method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
};
adjacent_row = function(which) {
var adj = get_adjacent_row(which);
if (!adj) return false;
set_current_row($(adj));
return true;
};
prev_row = function() { return adjacent_row('prev'); };
next_row = function() { return adjacent_row('next'); };
check = function() {
$(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
this.checked = !this.checked;
});
};
get_first_row = function() {
return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
};
get_last_row = function() {
var rows = $(opts.cycle_expr, table).filter_visible();
return rows.eq(rows.length-1);
};
make_key_callback = function(expr) {
return function() {
if ( null == $.table_hotkeys.current_row ) return false;
var clickable = $(expr, $.table_hotkeys.current_row);
if (!clickable.length) return false;
if (clickable.is('.'+destructive_class)) next_row() || prev_row();
clickable.click();
}
};
first_row = get_first_row();
if (!first_row.length) return;
if (opts.highlight_first)
set_current_row(first_row);
else if (opts.highlight_last)
set_current_row(get_last_row());
$.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')});
$.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')});
$.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
$.each(keys, function() {
var callback, key;
if ($.isFunction(this[1])) {
callback = this[1];
key = this[0];
$.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
} else {
key = this;
$.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
}
});
};
$.table_hotkeys.current_row = null;
$.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
})(jQuery);

View File

@ -1,93 +1 @@
(function($){
$.fn.filter_visible = function(depth) {
depth = depth || 3;
var is_visible = function() {
var p = $(this);
for(i=0; i<depth-1; ++i) {
if (!p.is(':visible')) return false;
p = p.parent();
}
return true;
}
return this.filter(is_visible);
};
$.table_hotkeys = function(table, keys, opts) {
opts = $.extend($.table_hotkeys.defaults, opts);
var selected_class = opts.class_prefix + opts.selected_suffix;
var destructive_class = opts.class_prefix + opts.destructive_suffix;
var set_current_row = function (tr) {
if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
tr.addClass(selected_class);
tr[0].scrollIntoView(false);
$.table_hotkeys.current_row = tr;
};
var adjacent_row_callback = function(which) {
if (!adjacent_row(which) && $.isFunction(opts[which+'_page_link_cb'])) {
opts[which+'_page_link_cb']();
}
};
var get_adjacent_row = function(which) {
if (!$.table_hotkeys.current_row) {
var first_row = get_first_row();
$.table_hotkeys.current_row = first_row;
return first_row[0];
}
var method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
};
var adjacent_row = function(which) {
var adj = get_adjacent_row(which);
if (!adj) return false;
set_current_row($(adj));
return true;
};
var prev_row = function() { return adjacent_row('prev'); };
var next_row = function() { return adjacent_row('next'); };
var check = function() {
$(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
this.checked = !this.checked;
});
};
var get_first_row = function() {
return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
};
var get_last_row = function() {
var rows = $(opts.cycle_expr, table).filter_visible();
return rows.eq(rows.length-1);
};
var make_key_callback = function(expr) {
return function() {
if ( null == $.table_hotkeys.current_row ) return false;
var clickable = $(expr, $.table_hotkeys.current_row);
if (!clickable.length) return false;
if (clickable.is('.'+destructive_class)) next_row() || prev_row();
clickable.click();
}
};
var first_row = get_first_row();
if (!first_row.length) return;
if (opts.highlight_first)
set_current_row(first_row);
else if (opts.highlight_last)
set_current_row(get_last_row());
jQuery.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')});
jQuery.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')});
jQuery.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
jQuery.each(keys, function() {
if ($.isFunction(this[1])) {
var callback = this[1];
var key = this[0];
jQuery.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
} else {
var key = this;
jQuery.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
}
});
};
$.table_hotkeys.current_row = null;
$.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
})(jQuery);
(function(a){a.fn.filter_visible=function(c){c=c||3;var b=function(){var e=a(this),d;for(d=0;d<c-1;++d){if(!e.is(":visible")){return false}e=e.parent()}return true};return this.filter(b)};a.table_hotkeys=function(p,q,b){b=a.extend(a.table_hotkeys.defaults,b);var i,l,e,f,m,d,k,o,c,h,g,n,j;i=b.class_prefix+b.selected_suffix;l=b.class_prefix+b.destructive_suffix;e=function(r){if(a.table_hotkeys.current_row){a.table_hotkeys.current_row.removeClass(i)}r.addClass(i);r[0].scrollIntoView(false);a.table_hotkeys.current_row=r};f=function(r){if(!d(r)&&a.isFunction(b[r+"_page_link_cb"])){b[r+"_page_link_cb"]()}};m=function(s){var r,t;if(!a.table_hotkeys.current_row){r=h();a.table_hotkeys.current_row=r;return r[0]}t="prev"==s?a.fn.prevAll:a.fn.nextAll;return t.call(a.table_hotkeys.current_row,b.cycle_expr).filter_visible()[0]};d=function(s){var r=m(s);if(!r){return false}e(a(r));return true};k=function(){return d("prev")};o=function(){return d("next")};c=function(){a(b.checkbox_expr,a.table_hotkeys.current_row).each(function(){this.checked=!this.checked})};h=function(){return a(b.cycle_expr,p).filter_visible().eq(b.start_row_index)};g=function(){var r=a(b.cycle_expr,p).filter_visible();return r.eq(r.length-1)};n=function(r){return function(){if(null==a.table_hotkeys.current_row){return false}var s=a(r,a.table_hotkeys.current_row);if(!s.length){return false}if(s.is("."+l)){o()||k()}s.click()}};j=h();if(!j.length){return}if(b.highlight_first){e(j)}else{if(b.highlight_last){e(g())}}a.hotkeys.add(b.prev_key,b.hotkeys_opts,function(){return f("prev")});a.hotkeys.add(b.next_key,b.hotkeys_opts,function(){return f("next")});a.hotkeys.add(b.mark_key,b.hotkeys_opts,c);a.each(q,function(){var s,r;if(a.isFunction(this[1])){s=this[1];r=this[0];a.hotkeys.add(r,b.hotkeys_opts,function(t){return s(t,a.table_hotkeys.current_row)})}else{r=this;a.hotkeys.add(r,b.hotkeys_opts,n("."+b.class_prefix+r))}})};a.table_hotkeys.current_row=null;a.table_hotkeys.defaults={cycle_expr:"tr",class_prefix:"vim-",selected_suffix:"current",destructive_suffix:"destructive",hotkeys_opts:{disableInInput:true,type:"keypress"},checkbox_expr:":checkbox",next_key:"j",prev_key:"k",mark_key:"x",start_row_index:2,highlight_first:false,highlight_last:false,next_page_link_cb:false,prev_page_link_cb:false}})(jQuery);

View File

@ -0,0 +1,332 @@
/*
* jquery.suggest 1.1b - 2007-08-06
* Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting
* See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228
*
* Uses code and techniques from following libraries:
* 1. http://www.dyve.net/jquery/?autocomplete
* 2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js
*
* All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)
* Feel free to do whatever you want with this file
*
*/
(function($) {
$.suggest = function(input, options) {
var $input = $(input).attr("autocomplete", "off");
var $results = $(document.createElement("ul"));
var timeout = false; // hold timeout ID for suggestion results to appear
var prevLength = 0; // last recorded length of $input.val()
var cache = []; // cache MRU list
var cacheSize = 0; // size of cache in chars (bytes?)
$results.addClass(options.resultsClass).appendTo('body');
resetPosition();
$(window)
.load(resetPosition) // just in case user is changing size of page while loading
.resize(resetPosition);
$input.blur(function() {
setTimeout(function() { $results.hide() }, 200);
});
// help IE users if possible
try {
$results.bgiframe();
} catch(e) { }
// I really hate browser detection, but I don't see any other way
if ($.browser.mozilla)
$input.keypress(processKey); // onkeypress repeats arrow keys in Mozilla/Opera
else
$input.keydown(processKey); // onkeydown repeats arrow keys in IE/Safari
function resetPosition() {
// requires jquery.dimension plugin
var offset = $input.offset();
$results.css({
top: (offset.top + input.offsetHeight) + 'px',
left: offset.left + 'px'
});
}
function processKey(e) {
// handling up/down/escape requires results to be visible
// handling enter/tab requires that AND a result to be selected
if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
switch(e.keyCode) {
case 38: // up
prevResult();
break;
case 40: // down
nextResult();
break;
case 9: // tab
case 13: // return
selectCurrentResult();
break;
case 27: // escape
$results.hide();
break;
}
} else if ($input.val().length != prevLength) {
if (timeout)
clearTimeout(timeout);
timeout = setTimeout(suggest, options.delay);
prevLength = $input.val().length;
}
}
function suggest() {
var q = $.trim($input.val());
if ( options.multiple ) {
var multipleSepPos = q.lastIndexOf(options.multipleSep);
if ( multipleSepPos != -1 ) {
q = q.substr(multipleSepPos + options.multipleSep.length);
}
}
if (q.length >= options.minchars) {
cached = checkCache(q);
if (cached) {
displayItems(cached['items']);
} else {
$.get(options.source, {q: q}, function(txt) {
$results.hide();
var items = parseTxt(txt, q);
displayItems(items);
addToCache(q, items, txt.length);
});
}
} else {
$results.hide();
}
}
function checkCache(q) {
for (var i = 0; i < cache.length; i++)
if (cache[i]['q'] == q) {
cache.unshift(cache.splice(i, 1)[0]);
return cache[0];
}
return false;
}
function addToCache(q, items, size) {
while (cache.length && (cacheSize + size > options.maxCacheSize)) {
var cached = cache.pop();
cacheSize -= cached['size'];
}
cache.push({
q: q,
size: size,
items: items
});
cacheSize += size;
}
function displayItems(items) {
if (!items)
return;
if (!items.length) {
$results.hide();
return;
}
resetPosition(); // when the form moves after the page has loaded
var html = '';
for (var i = 0; i < items.length; i++)
html += '<li>' + items[i] + '</li>';
$results.html(html).show();
$results
.children('li')
.mouseover(function() {
$results.children('li').removeClass(options.selectClass);
$(this).addClass(options.selectClass);
})
.click(function(e) {
e.preventDefault();
e.stopPropagation();
selectCurrentResult();
});
}
function parseTxt(txt, q) {
var items = [];
var tokens = txt.split(options.delimiter);
// parse returned data for non-empty items
for (var i = 0; i < tokens.length; i++) {
var token = $.trim(tokens[i]);
if (token) {
token = token.replace(
new RegExp(q, 'ig'),
function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
);
items[items.length] = token;
}
}
return items;
}
function getCurrentResult() {
if (!$results.is(':visible'))
return false;
var $currentResult = $results.children('li.' + options.selectClass);
if (!$currentResult.length)
$currentResult = false;
return $currentResult;
}
function selectCurrentResult() {
$currentResult = getCurrentResult();
if ($currentResult) {
if ( options.multiple ) {
if ( $input.val().indexOf(options.multipleSep) != -1 ) {
$currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) );
} else {
$currentVal = "";
}
$input.val( $currentVal + $currentResult.text() + options.multipleSep);
$input.focus();
} else {
$input.val($currentResult.text());
}
$results.hide();
if (options.onSelect)
options.onSelect.apply($input[0]);
}
}
function nextResult() {
$currentResult = getCurrentResult();
if ($currentResult)
$currentResult
.removeClass(options.selectClass)
.next()
.addClass(options.selectClass);
else
$results.children('li:first-child').addClass(options.selectClass);
}
function prevResult() {
$currentResult = getCurrentResult();
if ($currentResult)
$currentResult
.removeClass(options.selectClass)
.prev()
.addClass(options.selectClass);
else
$results.children('li:last-child').addClass(options.selectClass);
}
}
$.fn.suggest = function(source, options) {
if (!source)
return;
options = options || {};
options.multiple = options.multiple || false;
options.multipleSep = options.multipleSep || ", ";
options.source = source;
options.delay = options.delay || 100;
options.resultsClass = options.resultsClass || 'ac_results';
options.selectClass = options.selectClass || 'ac_over';
options.matchClass = options.matchClass || 'ac_match';
options.minchars = options.minchars || 2;
options.delimiter = options.delimiter || '\n';
options.onSelect = options.onSelect || false;
options.maxCacheSize = options.maxCacheSize || 65536;
this.each(function() {
new $.suggest(this, options);
});
return this;
};
})(jQuery);

View File

@ -1,332 +1 @@
/*
* jquery.suggest 1.1b - 2007-08-06
* Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting
* See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228
*
* Uses code and techniques from following libraries:
* 1. http://www.dyve.net/jquery/?autocomplete
* 2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js
*
* All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)
* Feel free to do whatever you want with this file
*
*/
(function($) {
$.suggest = function(input, options) {
var $input = $(input).attr("autocomplete", "off");
var $results = $(document.createElement("ul"));
var timeout = false; // hold timeout ID for suggestion results to appear
var prevLength = 0; // last recorded length of $input.val()
var cache = []; // cache MRU list
var cacheSize = 0; // size of cache in chars (bytes?)
$results.addClass(options.resultsClass).appendTo('body');
resetPosition();
$(window)
.load(resetPosition) // just in case user is changing size of page while loading
.resize(resetPosition);
$input.blur(function() {
setTimeout(function() { $results.hide() }, 200);
});
// help IE users if possible
try {
$results.bgiframe();
} catch(e) { }
// I really hate browser detection, but I don't see any other way
if ($.browser.mozilla)
$input.keypress(processKey); // onkeypress repeats arrow keys in Mozilla/Opera
else
$input.keydown(processKey); // onkeydown repeats arrow keys in IE/Safari
function resetPosition() {
// requires jquery.dimension plugin
var offset = $input.offset();
$results.css({
top: (offset.top + input.offsetHeight) + 'px',
left: offset.left + 'px'
});
}
function processKey(e) {
// handling up/down/escape requires results to be visible
// handling enter/tab requires that AND a result to be selected
if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
switch(e.keyCode) {
case 38: // up
prevResult();
break;
case 40: // down
nextResult();
break;
case 9: // tab
case 13: // return
selectCurrentResult();
break;
case 27: // escape
$results.hide();
break;
}
} else if ($input.val().length != prevLength) {
if (timeout)
clearTimeout(timeout);
timeout = setTimeout(suggest, options.delay);
prevLength = $input.val().length;
}
}
function suggest() {
var q = $.trim($input.val());
if ( options.multiple ) {
var multipleSepPos = q.lastIndexOf(options.multipleSep);
if ( multipleSepPos != -1 ) {
q = q.substr(multipleSepPos + options.multipleSep.length);
}
}
if (q.length >= options.minchars) {
cached = checkCache(q);
if (cached) {
displayItems(cached['items']);
} else {
$.get(options.source, {q: q}, function(txt) {
$results.hide();
var items = parseTxt(txt, q);
displayItems(items);
addToCache(q, items, txt.length);
});
}
} else {
$results.hide();
}
}
function checkCache(q) {
for (var i = 0; i < cache.length; i++)
if (cache[i]['q'] == q) {
cache.unshift(cache.splice(i, 1)[0]);
return cache[0];
}
return false;
}
function addToCache(q, items, size) {
while (cache.length && (cacheSize + size > options.maxCacheSize)) {
var cached = cache.pop();
cacheSize -= cached['size'];
}
cache.push({
q: q,
size: size,
items: items
});
cacheSize += size;
}
function displayItems(items) {
if (!items)
return;
if (!items.length) {
$results.hide();
return;
}
resetPosition(); // when the form moves after the page has loaded
var html = '';
for (var i = 0; i < items.length; i++)
html += '<li>' + items[i] + '</li>';
$results.html(html).show();
$results
.children('li')
.mouseover(function() {
$results.children('li').removeClass(options.selectClass);
$(this).addClass(options.selectClass);
})
.click(function(e) {
e.preventDefault();
e.stopPropagation();
selectCurrentResult();
});
}
function parseTxt(txt, q) {
var items = [];
var tokens = txt.split(options.delimiter);
// parse returned data for non-empty items
for (var i = 0; i < tokens.length; i++) {
var token = $.trim(tokens[i]);
if (token) {
token = token.replace(
new RegExp(q, 'ig'),
function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
);
items[items.length] = token;
}
}
return items;
}
function getCurrentResult() {
if (!$results.is(':visible'))
return false;
var $currentResult = $results.children('li.' + options.selectClass);
if (!$currentResult.length)
$currentResult = false;
return $currentResult;
}
function selectCurrentResult() {
$currentResult = getCurrentResult();
if ($currentResult) {
if ( options.multiple ) {
if ( $input.val().indexOf(options.multipleSep) != -1 ) {
$currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) );
} else {
$currentVal = "";
}
$input.val( $currentVal + $currentResult.text() + options.multipleSep);
$input.focus();
} else {
$input.val($currentResult.text());
}
$results.hide();
if (options.onSelect)
options.onSelect.apply($input[0]);
}
}
function nextResult() {
$currentResult = getCurrentResult();
if ($currentResult)
$currentResult
.removeClass(options.selectClass)
.next()
.addClass(options.selectClass);
else
$results.children('li:first-child').addClass(options.selectClass);
}
function prevResult() {
$currentResult = getCurrentResult();
if ($currentResult)
$currentResult
.removeClass(options.selectClass)
.prev()
.addClass(options.selectClass);
else
$results.children('li:last-child').addClass(options.selectClass);
}
}
$.fn.suggest = function(source, options) {
if (!source)
return;
options = options || {};
options.multiple = options.multiple || false;
options.multipleSep = options.multipleSep || ", ";
options.source = source;
options.delay = options.delay || 100;
options.resultsClass = options.resultsClass || 'ac_results';
options.selectClass = options.selectClass || 'ac_over';
options.matchClass = options.matchClass || 'ac_match';
options.minchars = options.minchars || 2;
options.delimiter = options.delimiter || '\n';
options.onSelect = options.onSelect || false;
options.maxCacheSize = options.maxCacheSize || 65536;
this.each(function() {
new $.suggest(this, options);
});
return this;
};
})(jQuery);
(function(a){a.suggest=function(o,g){var c=a(o).attr("autocomplete","off");var f=a(document.createElement("ul"));var n=false;var d=0;var q=[];var p=0;f.addClass(g.resultsClass).appendTo("body");j();a(window).load(j).resize(j);c.blur(function(){setTimeout(function(){f.hide()},200)});try{f.bgiframe()}catch(s){}if(a.browser.mozilla){c.keypress(m)}else{c.keydown(m)}function j(){var e=c.offset();f.css({top:(e.top+o.offsetHeight)+"px",left:e.left+"px"})}function m(w){if((/27$|38$|40$/.test(w.keyCode)&&f.is(":visible"))||(/^13$|^9$/.test(w.keyCode)&&u())){if(w.preventDefault){w.preventDefault()}if(w.stopPropagation){w.stopPropagation()}w.cancelBubble=true;w.returnValue=false;switch(w.keyCode){case 38:k();break;case 40:t();break;case 9:case 13:r();break;case 27:f.hide();break}}else{if(c.val().length!=d){if(n){clearTimeout(n)}n=setTimeout(l,g.delay);d=c.val().length}}}function l(){var w=a.trim(c.val());if(g.multiple){var e=w.lastIndexOf(g.multipleSep);if(e!=-1){w=w.substr(e+g.multipleSep.length)}}if(w.length>=g.minchars){cached=v(w);if(cached){i(cached.items)}else{a.get(g.source,{q:w},function(x){f.hide();var y=b(x,w);i(y);h(w,y,x.length)})}}else{f.hide()}}function v(w){for(var e=0;e<q.length;e++){if(q[e]["q"]==w){q.unshift(q.splice(e,1)[0]);return q[0]}}return false}function h(y,e,w){while(q.length&&(p+w>g.maxCacheSize)){var x=q.pop();p-=x.size}q.push({q:y,size:w,items:e});p+=w}function i(e){if(!e){return}if(!e.length){f.hide();return}j();var x="";for(var w=0;w<e.length;w++){x+="<li>"+e[w]+"</li>"}f.html(x).show();f.children("li").mouseover(function(){f.children("li").removeClass(g.selectClass);a(this).addClass(g.selectClass)}).click(function(y){y.preventDefault();y.stopPropagation();r()})}function b(e,z){var w=[];var A=e.split(g.delimiter);for(var y=0;y<A.length;y++){var x=a.trim(A[y]);if(x){x=x.replace(new RegExp(z,"ig"),function(B){return'<span class="'+g.matchClass+'">'+B+"</span>"});w[w.length]=x}}return w}function u(){if(!f.is(":visible")){return false}var e=f.children("li."+g.selectClass);if(!e.length){e=false}return e}function r(){$currentResult=u();if($currentResult){if(g.multiple){if(c.val().indexOf(g.multipleSep)!=-1){$currentVal=c.val().substr(0,(c.val().lastIndexOf(g.multipleSep)+g.multipleSep.length))}else{$currentVal=""}c.val($currentVal+$currentResult.text()+g.multipleSep);c.focus()}else{c.val($currentResult.text())}f.hide();if(g.onSelect){g.onSelect.apply(c[0])}}}function t(){$currentResult=u();if($currentResult){$currentResult.removeClass(g.selectClass).next().addClass(g.selectClass)}else{f.children("li:first-child").addClass(g.selectClass)}}function k(){$currentResult=u();if($currentResult){$currentResult.removeClass(g.selectClass).prev().addClass(g.selectClass)}else{f.children("li:last-child").addClass(g.selectClass)}}};a.fn.suggest=function(c,b){if(!c){return}b=b||{};b.multiple=b.multiple||false;b.multipleSep=b.multipleSep||", ";b.source=c;b.delay=b.delay||100;b.resultsClass=b.resultsClass||"ac_results";b.selectClass=b.selectClass||"ac_over";b.matchClass=b.matchClass||"ac_match";b.minchars=b.minchars||2;b.delimiter=b.delimiter||"\n";b.onSelect=b.onSelect||false;b.maxCacheSize=b.maxCacheSize||65536;this.each(function(){new a.suggest(this,b)});return this}})(jQuery);

View File

@ -1,2 +1 @@
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3(C){C.8={2r:{V:3(E,F,H){6 G=C.8[E].o;1v(6 D 2q H){G.w[D]=G.w[D]||[];G.w[D].2p([F,H[D]])}},1p:3(D,F,E){6 H=D.w[F];5(!H){4}1v(6 G=0;G<H.1e;G++){5(D.a[H[G][0]]){H[G][1].v(D.c,E)}}}},p:{},d:3(D){5(C.8.p[D]){4 C.8.p[D]}6 E=C(\'<2o 2n="8-2m">\').1k(D).d({2l:"2k",12:"-1u",2j:"-1u",2i:"2h"}).2g("1t");C.8.p[D]=!!((!(/2f|2e/).h(E.d("2d"))||(/^[1-9]/).h(E.d("2c"))||(/^[1-9]/).h(E.d("2b"))||!(/1r/).h(E.d("2a"))||!(/29|28\\(0, 0, 0, 0\\)/).h(E.d("27"))));26{C("1t").1s(0).25(E.1s(0))}24(F){}4 C.8.p[D]},23:3(D){C(D).k("j","1i").d("1q","1r")},22:3(D){C(D).k("j","21").d("1q","")},20:3(G,E){6 D=/12/.h(E||"12")?"1Z":"1Y",F=7;5(G[D]>0){4 f}G[D]=1;F=G[D]>0?f:7;G[D]=0;4 F}};6 B=C.10.u;C.10.u=3(){C("*",2).V(2).1X("u");4 B.v(2,1o)};3 A(E,F,G){6 D=C[E][F].1W||[];D=(X D=="W"?D.11(/,?\\s+/):D);4(C.1V(G,D)!=-1)}C.m=3(E,D){6 F=E.11(".")[0];E=E.11(".")[1];C.10[E]=3(J){6 H=(X J=="W"),I=1U.o.1T.1p(1o,1);5(H&&A(F,E,J)){6 G=C.Z(2[0],E);4(G?G[J].v(G,I):1S)}4 2.1R(3(){6 K=C.Z(2,E);5(H&&K&&C.1Q(K[J])){K[J].v(K,I)}1P{5(!H){C.Z(2,E,1O C[F][E](2,J))}}})};C[F][E]=3(I,H){6 G=2;2.e=E;2.1j=F+"-"+E;2.a=C.1n({},C.m.q,C[F][E].q,H);2.c=C(I).g("n."+E,3(L,J,K){4 G.n(J,K)}).g("Y."+E,3(K,J){4 G.Y(J)}).g("u",3(){4 G.1l()});2.1m()};C[F][E].o=C.1n({},C.m.o,D)};C.m.o={1m:3(){},1l:3(){2.c.1N(2.e)},Y:3(D){4 2.a[D]},n:3(D,E){2.a[D]=E;5(D=="l"){2.c[E?"1k":"1M"](2.1j+"-l")}},1L:3(){2.n("l",7)},1K:3(){2.n("l",f)}};C.m.q={l:7};C.8.14={1J:3(){6 D=2;2.c.g("1I."+2.e,3(E){4 D.1g(E)});5(C.U.T){2.1h=2.c.k("j");2.c.k("j","1i")}2.1H=7},1G:3(){2.c.R("."+2.e);(C.U.T&&2.c.k("j",2.1h))},1g:3(F){(2.b&&2.i(F));2.t=F;6 E=2,G=(F.1F==1),D=(X 2.a.y=="W"?C(F.1f).1E().V(F.1f).1D(2.a.y).1e:7);5(!G||D||!2.15(F)){4 f}2.r=!2.a.x;5(!2.r){2.1C=1B(3(){E.r=f},2.a.x)}5(2.P(F)&&2.N(F)){2.b=(2.M(F)!==7);5(!2.b){F.1A();4 f}}2.S=3(H){4 E.1d(H)};2.Q=3(H){4 E.i(H)};C(1c).g("1b."+2.e,2.S).g("1a."+2.e,2.Q);4 7},1d:3(D){5(C.U.T&&!D.1z){4 2.i(D)}5(2.b){2.z(D);4 7}5(2.P(D)&&2.N(D)){2.b=(2.M(2.t,D)!==7);(2.b?2.z(D):2.i(D))}4!2.b},i:3(D){C(1c).R("1b."+2.e,2.S).R("1a."+2.e,2.Q);5(2.b){2.b=7;2.16(D)}4 7},P:3(D){4(O.1y(O.18(2.t.19-D.19),O.18(2.t.17-D.17))>=2.a.13)},N:3(D){4 2.r},M:3(D){},z:3(D){},16:3(D){},15:3(D){4 f}};C.8.14.q={y:1x,13:1,x:0}})(1w)',62,152,'||this|function|return|if|var|false|ui||options|_mouseStarted|element|css|widgetName|true|bind|test|mouseUp|unselectable|attr|disabled|widget|setData|prototype|cssCache|defaults|_mouseDelayMet||_mouseDownEvent|remove|apply|plugins|delay|cancel|mouseDrag|||||||||||||mouseStart|mouseDelayMet|Math|mouseDistanceMet|_mouseUpDelegate|unbind|_mouseMoveDelegate|msie|browser|add|string|typeof|getData|data|fn|split|top|distance|mouse|mouseCapture|mouseStop|pageY|abs|pageX|mouseup|mousemove|document|mouseMove|length|target|mouseDown|_mouseUnselectable|on|widgetBaseClass|addClass|destroy|init|extend|arguments|call|MozUserSelect|none|get|body|5000px|for|jQuery|null|max|button|preventDefault|setTimeout|_mouseDelayTimer|filter|parents|which|mouseDestroy|started|mousedown|mouseInit|disable|enable|removeClass|removeData|new|else|isFunction|each|undefined|slice|Array|inArray|getter|triggerHandler|scrollLeft|scrollTop|hasScroll|off|enableSelection|disableSelection|catch|removeChild|try|backgroundColor|rgba|transparent|backgroundImage|width|height|cursor|default|auto|appendTo|block|display|left|absolute|position|gen|class|div|push|in|plugin'.split('|'),0,{}))
(function(C){C.ui={plugin:{add:function(E,F,H){var G=C.ui[E].prototype;for(var D in H){G.plugins[D]=G.plugins[D]||[];G.plugins[D].push([F,H[D]])}},call:function(D,F,E){var H=D.plugins[F];if(!H){return }for(var G=0;G<H.length;G++){if(D.options[H[G][0]]){H[G][1].apply(D.element,E)}}}},cssCache:{},css:function(D){if(C.ui.cssCache[D]){return C.ui.cssCache[D]}var E=C('<div class="ui-gen">').addClass(D).css({position:"absolute",top:"-5000px",left:"-5000px",display:"block"}).appendTo("body");C.ui.cssCache[D]=!!((!(/auto|default/).test(E.css("cursor"))||(/^[1-9]/).test(E.css("height"))||(/^[1-9]/).test(E.css("width"))||!(/none/).test(E.css("backgroundImage"))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(E.css("backgroundColor"))));try{C("body").get(0).removeChild(E.get(0))}catch(F){}return C.ui.cssCache[D]},disableSelection:function(D){C(D).attr("unselectable","on").css("MozUserSelect","none")},enableSelection:function(D){C(D).attr("unselectable","off").css("MozUserSelect","")},hasScroll:function(G,E){var D=/top/.test(E||"top")?"scrollTop":"scrollLeft",F=false;if(G[D]>0){return true}G[D]=1;F=G[D]>0?true:false;G[D]=0;return F}};var B=C.fn.remove;C.fn.remove=function(){C("*",this).add(this).triggerHandler("remove");return B.apply(this,arguments)};function A(E,F,G){var D=C[E][F].getter||[];D=(typeof D=="string"?D.split(/,?\s+/):D);return(C.inArray(G,D)!=-1)}C.widget=function(E,D){var F=E.split(".")[0];E=E.split(".")[1];C.fn[E]=function(J){var H=(typeof J=="string"),I=Array.prototype.slice.call(arguments,1);if(H&&A(F,E,J)){var G=C.data(this[0],E);return(G?G[J].apply(G,I):undefined)}return this.each(function(){var K=C.data(this,E);if(H&&K&&C.isFunction(K[J])){K[J].apply(K,I)}else{if(!H){C.data(this,E,new C[F][E](this,J))}}})};C[F][E]=function(I,H){var G=this;this.widgetName=E;this.widgetBaseClass=F+"-"+E;this.options=C.extend({},C.widget.defaults,C[F][E].defaults,H);this.element=C(I).bind("setData."+E,function(L,J,K){return G.setData(J,K)}).bind("getData."+E,function(K,J){return G.getData(J)}).bind("remove",function(){return G.destroy()});this.init()};C[F][E].prototype=C.extend({},C.widget.prototype,D)};C.widget.prototype={init:function(){},destroy:function(){this.element.removeData(this.widgetName)},getData:function(D){return this.options[D]},setData:function(D,E){this.options[D]=E;if(D=="disabled"){this.element[E?"addClass":"removeClass"](this.widgetBaseClass+"-disabled")}},enable:function(){this.setData("disabled",false)},disable:function(){this.setData("disabled",true)}};C.widget.defaults={disabled:false};C.ui.mouse={mouseInit:function(){var D=this;this.element.bind("mousedown."+this.widgetName,function(E){return D.mouseDown(E)});if(C.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},mouseDestroy:function(){this.element.unbind("."+this.widgetName);(C.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},mouseDown:function(F){(this._mouseStarted&&this.mouseUp(F));this._mouseDownEvent=F;var E=this,G=(F.which==1),D=(typeof this.options.cancel=="string"?C(F.target).parents().add(F.target).filter(this.options.cancel).length:false);if(!G||D||!this.mouseCapture(F)){return true}this._mouseDelayMet=!this.options.delay;if(!this._mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){E._mouseDelayMet=true},this.options.delay)}if(this.mouseDistanceMet(F)&&this.mouseDelayMet(F)){this._mouseStarted=(this.mouseStart(F)!==false);if(!this._mouseStarted){F.preventDefault();return true}}this._mouseMoveDelegate=function(H){return E.mouseMove(H)};this._mouseUpDelegate=function(H){return E.mouseUp(H)};C(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);return false},mouseMove:function(D){if(C.browser.msie&&!D.button){return this.mouseUp(D)}if(this._mouseStarted){this.mouseDrag(D);return false}if(this.mouseDistanceMet(D)&&this.mouseDelayMet(D)){this._mouseStarted=(this.mouseStart(this._mouseDownEvent,D)!==false);(this._mouseStarted?this.mouseDrag(D):this.mouseUp(D))}return !this._mouseStarted},mouseUp:function(D){C(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this.mouseStop(D)}return false},mouseDistanceMet:function(D){return(Math.max(Math.abs(this._mouseDownEvent.pageX-D.pageX),Math.abs(this._mouseDownEvent.pageY-D.pageY))>=this.options.distance)},mouseDelayMet:function(D){return this._mouseDelayMet},mouseStart:function(D){},mouseDrag:function(D){},mouseStop:function(D){},mouseCapture:function(D){return true}};C.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,575 @@
// new edit toolbar used with permission
// by Alex King
// http://www.alexking.org/
var edButtons = new Array(), edLinks = new Array(), edOpenTags = new Array(), now = new Date(), datetime;
function edButton(id, display, tagStart, tagEnd, access, open) {
this.id = id; // used to name the toolbar button
this.display = display; // label on button
this.tagStart = tagStart; // open tag
this.tagEnd = tagEnd; // close tag
this.access = access; // access key
this.open = open; // set to -1 if tag does not need to be closed
}
function zeroise(number, threshold) {
// FIXME: or we could use an implementation of printf in js here
var str = number.toString();
if (number < 0) { str = str.substr(1, str.length) }
while (str.length < threshold) { str = "0" + str }
if (number < 0) { str = '-' + str }
return str;
}
datetime = now.getUTCFullYear() + '-' +
zeroise(now.getUTCMonth() + 1, 2) + '-' +
zeroise(now.getUTCDate(), 2) + 'T' +
zeroise(now.getUTCHours(), 2) + ':' +
zeroise(now.getUTCMinutes(), 2) + ':' +
zeroise(now.getUTCSeconds() ,2) +
'+00:00';
edButtons[edButtons.length] =
new edButton('ed_strong'
,'b'
,'<strong>'
,'</strong>'
,'b'
);
edButtons[edButtons.length] =
new edButton('ed_em'
,'i'
,'<em>'
,'</em>'
,'i'
);
edButtons[edButtons.length] =
new edButton('ed_link'
,'link'
,''
,'</a>'
,'a'
); // special case
edButtons[edButtons.length] =
new edButton('ed_block'
,'b-quote'
,'\n\n<blockquote>'
,'</blockquote>\n\n'
,'q'
);
edButtons[edButtons.length] =
new edButton('ed_del'
,'del'
,'<del datetime="' + datetime + '">'
,'</del>'
,'d'
);
edButtons[edButtons.length] =
new edButton('ed_ins'
,'ins'
,'<ins datetime="' + datetime + '">'
,'</ins>'
,'s'
);
edButtons[edButtons.length] =
new edButton('ed_img'
,'img'
,''
,''
,'m'
,-1
); // special case
edButtons[edButtons.length] =
new edButton('ed_ul'
,'ul'
,'<ul>\n'
,'</ul>\n\n'
,'u'
);
edButtons[edButtons.length] =
new edButton('ed_ol'
,'ol'
,'<ol>\n'
,'</ol>\n\n'
,'o'
);
edButtons[edButtons.length] =
new edButton('ed_li'
,'li'
,'\t<li>'
,'</li>\n'
,'l'
);
edButtons[edButtons.length] =
new edButton('ed_code'
,'code'
,'<code>'
,'</code>'
,'c'
);
edButtons[edButtons.length] =
new edButton('ed_more'
,'more'
,'<!--more-->'
,''
,'t'
,-1
);
/*
edButtons[edButtons.length] =
new edButton('ed_next'
,'page'
,'<!--nextpage-->'
,''
,'p'
,-1
);
*/
function edLink() {
this.display = '';
this.URL = '';
this.newWin = 0;
}
edLinks[edLinks.length] = new edLink('WordPress'
,'http://wordpress.org/'
);
edLinks[edLinks.length] = new edLink('alexking.org'
,'http://www.alexking.org/'
);
function edShowButton(button, i) {
if (button.id == 'ed_img') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');
}
else if (button.id == 'ed_link') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
else {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
}
function edShowLinks() {
var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>' + quicktagsL10n.quickLinks + '</option>', i;
for (i = 0; i < edLinks.length; i++) {
tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>';
}
tempStr += '</select>';
document.write(tempStr);
}
function edAddTag(button) {
if (edButtons[button].tagEnd != '') {
edOpenTags[edOpenTags.length] = button;
document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
}
}
function edRemoveTag(button) {
for (var i = 0; i < edOpenTags.length; i++) {
if (edOpenTags[i] == button) {
edOpenTags.splice(i, 1);
document.getElementById(edButtons[button].id).value = document.getElementById(edButtons[button].id).value.replace('/', '');
}
}
}
function edCheckOpenTags(button) {
var tag = 0, i;
for (i = 0; i < edOpenTags.length; i++) {
if (edOpenTags[i] == button) {
tag++;
}
}
if (tag > 0) {
return true; // tag found
}
else {
return false; // tag not found
}
}
function edCloseAllTags() {
var count = edOpenTags.length, o;
for (o = 0; o < count; o++) {
edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]);
}
}
function edQuickLink(i, thisSelect) {
if (i > -1) {
var newWin = '', tempStr;
if (edLinks[i].newWin == 1) {
newWin = ' target="_blank"';
}
tempStr = '<a href="' + edLinks[i].URL + '"' + newWin + '>'
+ edLinks[i].display
+ '</a>';
thisSelect.selectedIndex = 0;
edInsertContent(edCanvas, tempStr);
}
else {
thisSelect.selectedIndex = 0;
}
}
function edSpell(myField) {
var word = '', sel, startPos, endPos;
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
if (sel.text.length > 0) {
word = sel.text;
}
}
else if (myField.selectionStart || myField.selectionStart == '0') {
startPos = myField.selectionStart;
endPos = myField.selectionEnd;
if (startPos != endPos) {
word = myField.value.substring(startPos, endPos);
}
}
if (word == '') {
word = prompt(quicktagsL10n.wordLookup, '');
}
if (word !== null && /^\w[\w ]*$/.test(word)) {
window.open('http://www.answers.com/' + escape(word));
}
}
function edToolbar() {
document.write('<div id="ed_toolbar">');
for (var i = 0; i < edButtons.length; i++) {
edShowButton(edButtons[i], i);
}
document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');
document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');
// edShowLinks(); // disabled by default
document.write('</div>');
}
// insertion code
function edInsertTag(myField, i) {
//IE support
if (document.selection) {
myField.focus();
var sel = document.selection.createRange();
if (sel.text.length > 0) {
sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
}
else {
if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
sel.text = edButtons[i].tagStart;
edAddTag(i);
}
else {
sel.text = edButtons[i].tagEnd;
edRemoveTag(i);
}
}
myField.focus();
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart, endPos = myField.selectionEnd, cursorPos = endPos, scrollTop = myField.scrollTop;
if (startPos != endPos) {
myField.value = myField.value.substring(0, startPos)
+ edButtons[i].tagStart
+ myField.value.substring(startPos, endPos)
+ edButtons[i].tagEnd
+ myField.value.substring(endPos, myField.value.length);
cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length;
}
else {
if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
myField.value = myField.value.substring(0, startPos)
+ edButtons[i].tagStart
+ myField.value.substring(endPos, myField.value.length);
edAddTag(i);
cursorPos = startPos + edButtons[i].tagStart.length;
}
else {
myField.value = myField.value.substring(0, startPos)
+ edButtons[i].tagEnd
+ myField.value.substring(endPos, myField.value.length);
edRemoveTag(i);
cursorPos = startPos + edButtons[i].tagEnd.length;
}
}
myField.focus();
myField.selectionStart = cursorPos;
myField.selectionEnd = cursorPos;
myField.scrollTop = scrollTop;
}
else {
if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
myField.value += edButtons[i].tagStart;
edAddTag(i);
}
else {
myField.value += edButtons[i].tagEnd;
edRemoveTag(i);
}
myField.focus();
}
}
function edInsertContent(myField, myValue) {
var sel, startPos, endPos;
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
myField.focus();
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
startPos = myField.selectionStart;
endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
myField.focus();
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
myField.focus();
}
}
function edInsertLink(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = 'http://';
}
if (!edCheckOpenTags(i)) {
var URL = prompt(quicktagsL10n.enterURL, defaultValue);
if (URL) {
edButtons[i].tagStart = '<a href="' + URL + '">';
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}
function edInsertImage(myField) {
var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
if (myValue) {
myValue = '<img src="'
+ myValue
+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ '" />';
edInsertContent(myField, myValue);
}
}
// Allow multiple instances.
// Name = unique value, id = textarea id, container = container div.
// Can disable some buttons by passing comma delimited string as 4th param.
var QTags = function(name, id, container, disabled) {
var t = this, cont = document.getElementById(container), i, tag, tb, html, sel;
t.Buttons = [];
t.Links = [];
t.OpenTags = [];
t.Canvas = document.getElementById(id);
if ( ! t.Canvas || ! cont )
return;
disabled = ( typeof disabled != 'undefined' ) ? ','+disabled+',' : '';
t.edShowButton = function(button, i) {
if ( disabled && (disabled.indexOf(','+button.display+',') != -1) )
return '';
else if ( button.id == name+'_img' )
return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage('+name+'.Canvas);" value="' + button.display + '" />';
else if (button.id == name+'_link')
return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="'+name+'.edInsertLink('+i+');" value="'+button.display+'" />';
else
return '<input type="button" id="' + button.id + '" accesskey="'+button.access+'" class="ed_button" onclick="'+name+'.edInsertTag('+i+');" value="'+button.display+'" />';
};
t.edAddTag = function(button) {
if ( t.Buttons[button].tagEnd != '' ) {
t.OpenTags[t.OpenTags.length] = button;
document.getElementById(t.Buttons[button].id).value = '/' + document.getElementById(t.Buttons[button].id).value;
}
};
t.edRemoveTag = function(button) {
for ( i = 0; i < t.OpenTags.length; i++ ) {
if ( t.OpenTags[i] == button ) {
t.OpenTags.splice(i, 1);
document.getElementById(t.Buttons[button].id).value = document.getElementById(t.Buttons[button].id).value.replace('/', '');
}
}
};
t.edCheckOpenTags = function(button) {
tag = 0;
for ( var i = 0; i < t.OpenTags.length; i++ ) {
if ( t.OpenTags[i] == button )
tag++;
}
if ( tag > 0 ) return true; // tag found
else return false; // tag not found
};
this.edCloseAllTags = function() {
var count = t.OpenTags.length;
for ( var o = 0; o < count; o++ )
t.edInsertTag(t.OpenTags[t.OpenTags.length - 1]);
};
this.edQuickLink = function(i, thisSelect) {
if ( i > -1 ) {
var newWin = '', tempStr;
if ( Links[i].newWin == 1 ) {
newWin = ' target="_blank"';
}
tempStr = '<a href="' + Links[i].URL + '"' + newWin + '>'
+ Links[i].display
+ '</a>';
thisSelect.selectedIndex = 0;
edInsertContent(t.Canvas, tempStr);
} else {
thisSelect.selectedIndex = 0;
}
};
// insertion code
t.edInsertTag = function(i) {
//IE support
if ( document.selection ) {
t.Canvas.focus();
sel = document.selection.createRange();
if ( sel.text.length > 0 ) {
sel.text = t.Buttons[i].tagStart + sel.text + t.Buttons[i].tagEnd;
} else {
if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
sel.text = t.Buttons[i].tagStart;
t.edAddTag(i);
} else {
sel.text = t.Buttons[i].tagEnd;
t.edRemoveTag(i);
}
}
t.Canvas.focus();
} else if ( t.Canvas.selectionStart || t.Canvas.selectionStart == '0' ) { //MOZILLA/NETSCAPE support
var startPos = t.Canvas.selectionStart, endPos = t.Canvas.selectionEnd, cursorPos = endPos, scrollTop = t.Canvas.scrollTop;
if ( startPos != endPos ) {
t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ t.Buttons[i].tagStart
+ t.Canvas.value.substring(startPos, endPos)
+ t.Buttons[i].tagEnd
+ t.Canvas.value.substring(endPos, t.Canvas.value.length);
cursorPos += t.Buttons[i].tagStart.length + t.Buttons[i].tagEnd.length;
} else {
if ( !t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ t.Buttons[i].tagStart
+ t.Canvas.value.substring(endPos, t.Canvas.value.length);
t.edAddTag(i);
cursorPos = startPos + t.Buttons[i].tagStart.length;
} else {
t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ t.Buttons[i].tagEnd
+ t.Canvas.value.substring(endPos, t.Canvas.value.length);
t.edRemoveTag(i);
cursorPos = startPos + t.Buttons[i].tagEnd.length;
}
}
t.Canvas.focus();
t.Canvas.selectionStart = cursorPos;
t.Canvas.selectionEnd = cursorPos;
t.Canvas.scrollTop = scrollTop;
} else {
if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
t.Canvas.value += Buttons[i].tagStart;
t.edAddTag(i);
} else {
t.Canvas.value += Buttons[i].tagEnd;
t.edRemoveTag(i);
}
t.Canvas.focus();
}
};
this.edInsertLink = function(i, defaultValue) {
if ( ! defaultValue )
defaultValue = 'http://';
if ( ! t.edCheckOpenTags(i) ) {
var URL = prompt(quicktagsL10n.enterURL, defaultValue);
if ( URL ) {
t.Buttons[i].tagStart = '<a href="' + URL + '">';
t.edInsertTag(i);
}
} else {
t.edInsertTag(i);
}
};
this.edInsertImage = function() {
var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
if ( myValue ) {
myValue = '<img src="'
+ myValue
+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ '" />';
edInsertContent(t.Canvas, myValue);
}
};
t.Buttons[t.Buttons.length] = new edButton(name+'_strong','b','<strong>','</strong>','b');
t.Buttons[t.Buttons.length] = new edButton(name+'_em','i','<em>','</em>','i');
t.Buttons[t.Buttons.length] = new edButton(name+'_link','link','','</a>','a'); // special case
t.Buttons[t.Buttons.length] = new edButton(name+'_block','b-quote','\n\n<blockquote>','</blockquote>\n\n','q');
t.Buttons[t.Buttons.length] = new edButton(name+'_del','del','<del datetime="' + datetime + '">','</del>','d');
t.Buttons[t.Buttons.length] = new edButton(name+'_ins','ins','<ins datetime="' + datetime + '">','</ins>','s');
t.Buttons[t.Buttons.length] = new edButton(name+'_img','img','','','m',-1); // special case
t.Buttons[t.Buttons.length] = new edButton(name+'_ul','ul','<ul>\n','</ul>\n\n','u');
t.Buttons[t.Buttons.length] = new edButton(name+'_ol','ol','<ol>\n','</ol>\n\n','o');
t.Buttons[t.Buttons.length] = new edButton(name+'_li','li','\t<li>','</li>\n','l');
t.Buttons[t.Buttons.length] = new edButton(name+'_code','code','<code>','</code>','c');
t.Buttons[t.Buttons.length] = new edButton(name+'_more','more','<!--more-->','','t',-1);
// t.Buttons[t.Buttons.length] = new edButton(name+'_next','page','<!--nextpage-->','','p',-1);
tb = document.createElement('div');
tb.id = name+'_qtags';
html = '<div id="'+name+'_toolbar">';
for (i = 0; i < t.Buttons.length; i++)
html += t.edShowButton(t.Buttons[i], i);
html += '<input type="button" id="'+name+'_ed_spell" class="ed_button" onclick="edSpell('+name+'.Canvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />';
html += '<input type="button" id="'+name+'_ed_close" class="ed_button" onclick="'+name+'.edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" /></div>';
tb.innerHTML = html;
cont.parentNode.insertBefore(tb, cont);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,320 @@
/*
* 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("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
jQuery("#TB_overlay").click(tb_remove);
}
}else{//all others
if(document.getElementById("TB_overlay") === null){
jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
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("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//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 = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
} else {
TB_PrevCaption = TB_TempArray[TB_Counter].title;
TB_PrevURL = TB_TempArray[TB_Counter].href;
TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
}
} 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("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>");
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("<div id='TB_window'></div>");
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("<div id='TB_window'></div>");
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("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
}else{//iframe modal
jQuery("#TB_overlay").unbind();
jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
}
}else{// not an iframe, ajax
if(jQuery("#TB_window").css("display") != "block"){
if(params['modal'] != "true"){//ajax no modal
jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><img src='" + tb_closeImage + "' /></a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
}else{//ajax modal
jQuery("#TB_overlay").unbind();
jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
}
}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;
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,193 @@
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
see documentation or authors website for more details */
function sack(file) {
this.xmlhttp = null;
this.resetData = function() {
this.method = "POST";
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.element = null;
this.elementObj = null;
this.requestFile = file;
this.vars = new Object();
this.responseStatus = new Array(2);
};
this.resetFunctions = function() {
this.onLoading = function() { };
this.onLoaded = function() { };
this.onInteractive = function() { };
this.onCompletion = function() { };
this.onError = function() { };
this.onFail = function() { };
};
this.reset = function() {
this.resetFunctions();
this.resetData();
};
this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
this.xmlhttp = null;
}
}
if (! this.xmlhttp) {
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
} else {
this.failed = true;
}
}
};
this.setVar = function(name, value){
this.vars[name] = Array(value, false);
};
this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
} else {
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}
this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++){
urlVars = varArray[i].split("=");
if (true == encode){
this.encVar(urlVars[0], urlVars[1]);
} else {
this.setVar(urlVars[0], urlVars[1]);
}
}
}
this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
}
if (urlstring) {
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
} else {
this.URLString = urlstring;
}
}
// prevents caching of URLString
this.setVar("rndval", new Date().getTime());
urlstringtemp = new Array();
for (key in this.vars) {
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
delete this.vars[key];
this.vars[encoded[0]] = Array(encoded[1], true);
key = encoded[0];
}
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
}
if (urlstring){
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
} else {
this.URLString += urlstringtemp.join(this.argumentSeparator);
}
}
this.runResponse = function() {
eval(this.response);
}
this.runAJAX = function(urlstring) {
if (this.failed) {
this.onFail();
} else {
this.createURLString(urlstring);
if (this.element) {
this.elementObj = document.getElementById(this.element);
}
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
try {
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
}
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
case 1:
self.onLoading();
break;
case 2:
self.onLoaded();
break;
case 3:
self.onInteractive();
break;
case 4:
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
if (self.execute) {
self.runResponse();
}
if (self.elementObj) {
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input"
|| elemNodeName == "select"
|| elemNodeName == "option"
|| elemNodeName == "textarea") {
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
if (self.responseStatus[0] == "200") {
self.onCompletion();
} else {
self.onError();
}
self.URLString = "";
break;
}
};
this.xmlhttp.send(this.URLString);
}
}
};
this.reset();
this.createAJAX();
}

View File

@ -1,193 +1 @@
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
see documentation or authors website for more details */
function sack(file) {
this.xmlhttp = null;
this.resetData = function() {
this.method = "POST";
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.element = null;
this.elementObj = null;
this.requestFile = file;
this.vars = new Object();
this.responseStatus = new Array(2);
};
this.resetFunctions = function() {
this.onLoading = function() { };
this.onLoaded = function() { };
this.onInteractive = function() { };
this.onCompletion = function() { };
this.onError = function() { };
this.onFail = function() { };
};
this.reset = function() {
this.resetFunctions();
this.resetData();
};
this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
this.xmlhttp = null;
}
}
if (! this.xmlhttp) {
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
} else {
this.failed = true;
}
}
};
this.setVar = function(name, value){
this.vars[name] = Array(value, false);
};
this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
} else {
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}
this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++){
urlVars = varArray[i].split("=");
if (true == encode){
this.encVar(urlVars[0], urlVars[1]);
} else {
this.setVar(urlVars[0], urlVars[1]);
}
}
}
this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
}
if (urlstring) {
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
} else {
this.URLString = urlstring;
}
}
// prevents caching of URLString
this.setVar("rndval", new Date().getTime());
urlstringtemp = new Array();
for (key in this.vars) {
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
delete this.vars[key];
this.vars[encoded[0]] = Array(encoded[1], true);
key = encoded[0];
}
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
}
if (urlstring){
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
} else {
this.URLString += urlstringtemp.join(this.argumentSeparator);
}
}
this.runResponse = function() {
eval(this.response);
}
this.runAJAX = function(urlstring) {
if (this.failed) {
this.onFail();
} else {
this.createURLString(urlstring);
if (this.element) {
this.elementObj = document.getElementById(this.element);
}
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
try {
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
}
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
case 1:
self.onLoading();
break;
case 2:
self.onLoaded();
break;
case 3:
self.onInteractive();
break;
case 4:
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
if (self.execute) {
self.runResponse();
}
if (self.elementObj) {
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input"
|| elemNodeName == "select"
|| elemNodeName == "option"
|| elemNodeName == "textarea") {
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
if (self.responseStatus[0] == "200") {
self.onCompletion();
} else {
self.onError();
}
self.URLString = "";
break;
}
};
this.xmlhttp.send(this.URLString);
}
}
};
this.reset();
this.createAJAX();
}
function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()};

View File

@ -0,0 +1,59 @@
var wpAjax = jQuery.extend( {
unserialize: function( s ) {
var r = {}, q, pp, i, p;
if ( !s ) { return r; }
q = s.split('?'); if ( q[1] ) { s = q[1]; }
pp = s.split('&');
for ( i in pp ) {
if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; }
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 = {}, re = jQuery('#' + r).html(''), err = '';
if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) {
parsed.responses = [];
parsed.errors = false;
jQuery('response', x).each( function() {
var th = jQuery(this), child = jQuery(this.firstChild), response;
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'), anError, errorData, formField;
anError = { code: code, message: this.firstChild.nodeValue, data: false };
errorData = jQuery('wp_error_data[code="' + code + '"]', x);
if ( errorData ) { anError.data = errorData.get(); }
formField = jQuery( 'form-field', errorData ).text();
if ( formField ) { code = formField; }
if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); }
err += '<p>' + anError.message + '</p>';
response.errors.push( anError );
parsed.errors = true;
} ).size() ) { response.errors = false; }
parsed.responses.push( response );
} );
if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
return parsed;
}
if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
x = parseInt(x,10);
if ( -1 == x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken + '</p></div>'); }
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.' } );

View File

@ -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 += '<p>' + anError.message + '</p>';
response.errors.push( anError );
parsed.errors = true;
} ).size() ) { response.errors = false; }
parsed.responses.push( response );
} );
if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
return parsed;
}
if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
x = parseInt(x,10);
if ( -1 == x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken + '</p></div>'); }
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+="<p>"+m.message+"</p>";e.errors.push(m);b.errors=true}).size()){e.errors=false}b.responses.push(e)});if(d.length){c.html('<div class="error">'+d+"</div>")}return b}if(isNaN(a)){return !c.html('<div class="error"><p>'+a+"</p></div>")}a=parseInt(a,10);if(-1==a){return !c.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>")}else{if(0===a){return !c.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")}}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."});

View File

@ -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);

File diff suppressed because one or more lines are too long

View File

@ -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&hellip;'),
'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&hellip;'),
'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&hellip;'),
'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' );
}
}

View File

@ -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';