tablesorter/docs/js/docs.js

97 lines
2.3 KiB
JavaScript
Raw Normal View History

2011-06-22 23:19:27 +00:00
/* Stop IE flicker */
if ($.browser.msie == true) document.execCommand('BackgroundImageCache', false, true);
jQuery.fn.antispam = function() {
return this.each(function(){
var email = $(this).text().toLowerCase().replace(/\sdot/g,'.').replace(/\sat/g,'@').replace(/\s+/g,'');
var URI = "mailto:" + email;
$(this).hide().before(
$("<a></a>").attr("href",URI).addClass("external").text(email)
);
});
};
2011-07-17 15:01:18 +00:00
$(function(){
2011-09-22 22:32:58 +00:00
$("a.external").each(function() {this.target = '_new'});
2011-06-22 23:19:27 +00:00
$("span.email").antispam();
2011-07-17 15:01:18 +00:00
// get javascript source
if ($("#js").length) {
$("#javascript pre").text( $("#js").html().replace(/\t/g, " ") );
}
if ($("#css").length) {
$("pre.css").text( $("#css").html().replace(/\t/g, " ") );
}
if ($("#demo").length) {
2011-09-22 22:32:58 +00:00
$("#html pre").text( $("#demo").html().replace(/\t/g, " ") );
2011-07-17 15:01:18 +00:00
}
// hide child rows
$('#root .expand-child').hide();
// toggle child row content, not hiding the row since we are using rowspan
$('#root .toggle').click(function(){
$(this).closest('tr').nextUntil('tr:not(.expand-child)').toggle();
return false;
});
2012-05-08 18:13:21 +00:00
var animating = false;
2011-07-17 15:01:18 +00:00
$('.collapsible').hide();
2012-05-08 18:13:21 +00:00
$('.toggle2')
.click(function(e){
if (!animating) {
animating = true;
$(this).closest('tr').find('.collapsible').slideToggle();
setTimeout(function(){ animating = false; }, 200);
}
return false;
});
$('.toggle2, span.permalink')
.dblclick(function(){
window.location.hash = '#' + $(this).closest('tr')[0].id;
return false;
});
2011-07-17 15:01:18 +00:00
$('.toggleAll, .showAll, .hideAll').click(function(){
var t = $.trim($(this).text());
$(this).parent().next('table').find('.collapsible')[t]();
return false;
});
// update version number
var t = $('.current-version');
if (t.length) {
2012-03-18 14:02:49 +00:00
t.html($.tablesorter.version);
}
2011-07-17 15:01:18 +00:00
});
2012-05-08 18:13:21 +00:00
function showProperty(){
var prop, h = window.location.hash;
if (h) {
var prop = $(h);
if (prop.length) {
prop.find('.collapsible').show();
if (h === '#csschildrow') {
$('#root .expand-child').show();
}
// move below sticky header
if (/options/.test(prop.closest('table')[0].id)) {
$(window).scrollTop( prop.position().top - 30 );
}
}
}
};
2011-07-17 15:01:18 +00:00
$(window).load(function(){
$(".js").chili();
$(".html").chili();
$(".css").chili();
2012-05-08 18:13:21 +00:00
$(window).bind('hashchange', function(){
showProperty();
});
showProperty();
2011-06-22 23:19:27 +00:00
});