2011-07-17 15:01:18 +00:00
|
|
|
$(function(){
|
2013-11-14 02:11:23 +00:00
|
|
|
var $t, t, v, animate, clicked,
|
2011-07-17 15:01:18 +00:00
|
|
|
|
2013-05-09 04:36:06 +00:00
|
|
|
cleanupCode = function(code){
|
2013-03-27 23:13:44 +00:00
|
|
|
return code.replace(/[<>\"\'\t\n]/g, function(m) { return {
|
|
|
|
'<' : '<',
|
|
|
|
'>' : '>',
|
|
|
|
"'" : ''',
|
|
|
|
'"' : '"',
|
|
|
|
'\t': ' ',
|
|
|
|
'\n': '<br/>' // needed for IE
|
|
|
|
}[m]});
|
|
|
|
};
|
|
|
|
|
2013-05-09 04:36:06 +00:00
|
|
|
$("a.external").each(function(){this.target = '_new';});
|
|
|
|
|
2011-07-17 15:01:18 +00:00
|
|
|
// get javascript source
|
|
|
|
if ($("#js").length) {
|
2013-03-27 23:13:44 +00:00
|
|
|
$("#javascript pre").addClass('mod').html( cleanupCode( $("#js").html() ) );
|
2011-07-17 15:01:18 +00:00
|
|
|
}
|
|
|
|
if ($("#css").length) {
|
2013-03-27 23:13:44 +00:00
|
|
|
$("pre.lang-css").addClass('mod').html( cleanupCode( $("#css").html() ) );
|
2011-07-17 15:01:18 +00:00
|
|
|
}
|
|
|
|
if ($("#demo").length) {
|
2013-03-27 23:13:44 +00:00
|
|
|
$("#html pre").addClass('mod').html( cleanupCode( $("#demo").html() ) );
|
2011-07-17 15:01:18 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 23:13:44 +00:00
|
|
|
// apply to already pre-formatted blocks to add <br> for IE
|
|
|
|
$('pre:not(.mod)').each(function(){
|
2013-05-09 04:36:06 +00:00
|
|
|
$t = $(this);
|
2013-03-27 23:13:44 +00:00
|
|
|
$t.html( cleanupCode( $t.html() ) );
|
|
|
|
});
|
|
|
|
|
2013-01-26 15:21:13 +00:00
|
|
|
if (typeof prettyPrint !== 'undefined') { prettyPrint(); }
|
|
|
|
|
2011-07-17 15:01:18 +00:00
|
|
|
// hide child rows
|
2012-09-27 19:57:19 +00:00
|
|
|
$('#root .tablesorter-childRow').hide();
|
2011-07-17 15:01:18 +00:00
|
|
|
// toggle child row content, not hiding the row since we are using rowspan
|
|
|
|
$('#root .toggle').click(function(){
|
2012-09-27 19:57:19 +00:00
|
|
|
$(this).closest('tr').nextUntil('tr:not(.tablesorter-childRow)').toggle();
|
2011-07-17 15:01:18 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2013-05-09 04:36:06 +00:00
|
|
|
animating = false;
|
2013-11-14 02:11:23 +00:00
|
|
|
clicked = false;
|
2011-07-17 15:01:18 +00:00
|
|
|
$('.collapsible').hide();
|
2013-11-14 02:11:23 +00:00
|
|
|
|
|
|
|
$('a.permalink').click(function(e){
|
|
|
|
var $el = $(this);
|
|
|
|
setTimeout(function(){
|
|
|
|
if (!animating && !clicked) {
|
2012-05-08 18:13:21 +00:00
|
|
|
animating = true;
|
2013-11-14 02:11:23 +00:00
|
|
|
$el.closest('tr').find('.collapsible').slideToggle();
|
2012-05-08 18:13:21 +00:00
|
|
|
setTimeout(function(){ animating = false; }, 200);
|
|
|
|
}
|
2013-11-14 02:11:23 +00:00
|
|
|
}, 200);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$('.permalink').dblclick(function(){
|
|
|
|
clicked = true;
|
|
|
|
window.location.hash = '#' + $(this).closest('tr')[0].id;
|
|
|
|
setTimeout(function(){ clicked = false; }, 500);
|
|
|
|
return false;
|
|
|
|
});
|
2011-07-17 15:01:18 +00:00
|
|
|
|
|
|
|
$('.toggleAll, .showAll, .hideAll').click(function(){
|
2013-05-09 04:36:06 +00:00
|
|
|
t = $.trim($(this).text());
|
2011-07-17 15:01:18 +00:00
|
|
|
$(this).parent().next('table').find('.collapsible')[t]();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2011-12-13 04:25:26 +00:00
|
|
|
// update version number
|
2013-05-09 04:36:06 +00:00
|
|
|
$t = $('.current-version');
|
|
|
|
if ($t.length) {
|
|
|
|
$t.html($.tablesorter.version);
|
2011-12-13 04:25:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-09 04:36:06 +00:00
|
|
|
// add high visibility tags for newest versions (just grab the major revision number 2.10.0 -> 10
|
2013-10-07 01:18:44 +00:00
|
|
|
t = $.tablesorter.version.replace(/(v|version|\+)/g, '').split('.');
|
|
|
|
v = [ parseInt(t[0], 10) || 1, parseInt(t[1], 10) || 0 ];
|
2013-05-09 04:36:06 +00:00
|
|
|
$('.version').each(function(){
|
2013-10-07 01:18:44 +00:00
|
|
|
var i;
|
2013-05-09 04:36:06 +00:00
|
|
|
$t = $(this);
|
2013-10-07 01:18:44 +00:00
|
|
|
i = $t.text().replace(/(v|version|\+)/g, '').split('.');
|
|
|
|
t = [ parseInt(i[0], 10) || 1, parseInt(i[1], 10) || 0 ];
|
|
|
|
if (t[0] === v[0] && t[1] >= v[1] - 1 ) {
|
2013-11-16 07:01:26 +00:00
|
|
|
$t.prepend('<span class="label ' + ( t[0] === v[0] && t[1] < v[1] ? ' label-default' : ' label-success' ) +
|
|
|
|
'"><em>'+ ($t.hasClass('updated') ? 'Updated' : 'New') + '</em></span> ');
|
2013-05-09 04:36:06 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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) {
|
2012-09-27 19:57:19 +00:00
|
|
|
prop = $(h);
|
2013-02-17 19:23:36 +00:00
|
|
|
if (prop.length && prop[0].tagName !== "TABLE") {
|
2012-05-08 18:13:21 +00:00
|
|
|
prop.find('.collapsible').show();
|
|
|
|
if (h === '#csschildrow') {
|
2012-09-27 19:57:19 +00:00
|
|
|
$('#root .tablesorter-childRow').show();
|
2012-05-08 18:13:21 +00:00
|
|
|
}
|
2013-05-27 13:38:55 +00:00
|
|
|
// move below sticky header; added delay as there could be some lag
|
|
|
|
setTimeout(function(){
|
|
|
|
if (/options/.test(prop.closest('table').attr('id') || '')) {
|
|
|
|
$(window).scrollTop( prop.position().top - 28 );
|
|
|
|
}
|
|
|
|
}, 200);
|
2012-05-08 18:13:21 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-27 19:57:19 +00:00
|
|
|
}
|
2012-05-08 18:13:21 +00:00
|
|
|
|
2011-07-17 15:01:18 +00:00
|
|
|
$(window).load(function(){
|
2012-05-08 18:13:21 +00:00
|
|
|
|
2013-05-09 04:36:06 +00:00
|
|
|
if ($('#root').length) {
|
|
|
|
$(window).bind('hashchange', function(){
|
|
|
|
showProperty();
|
|
|
|
});
|
2012-05-08 18:13:21 +00:00
|
|
|
showProperty();
|
2013-05-09 04:36:06 +00:00
|
|
|
}
|
2012-05-08 18:13:21 +00:00
|
|
|
|
2013-03-27 23:13:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// append hidden parsed value to cell
|
2013-05-09 04:36:06 +00:00
|
|
|
// used by feet-inch-fraction & metric parser demos
|
2013-03-27 23:13:44 +00:00
|
|
|
var addParsedValues = function($t, cols, format){
|
|
|
|
var i, j, r,
|
|
|
|
$r = $t.find('tbody tr'),
|
|
|
|
c = $t[0].config.cache[0].normalized,
|
|
|
|
l = c.length - 1;
|
|
|
|
$r.each(function(i){
|
|
|
|
r = this;
|
|
|
|
$.each(cols, function(v,j){
|
2013-10-17 23:32:03 +00:00
|
|
|
r.cells[j].innerHTML += ' <span class="val hidden removeme">(<span class="results">' + (format ? format(c[i][j]) : c[i][j]) + '</span>)</span>';
|
2013-03-27 23:13:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.toggleparsedvalue').on('click', function(){
|
|
|
|
$('.val').toggleClass('hidden');
|
2013-05-16 15:25:14 +00:00
|
|
|
return false;
|
2013-03-27 23:13:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
};
|