2014-03-09 03:42:51 +00:00
|
|
|
/*jshint browser:true, jquery:true, unused:false */
|
|
|
|
/*global prettyPrint:false */
|
|
|
|
(function($){
|
|
|
|
$(function(){
|
|
|
|
var $t, t, v, animating, clicked,
|
|
|
|
|
|
|
|
cleanupCode = function(code){
|
|
|
|
return code.replace(/[<>\"\'\t\n]/g, function(m) { return {
|
|
|
|
'<' : '<',
|
|
|
|
'>' : '>',
|
|
|
|
"'" : ''',
|
|
|
|
'"' : '"',
|
|
|
|
'\t': ' ',
|
|
|
|
'\n': '<br/>' // needed for IE
|
|
|
|
}[m];});
|
|
|
|
};
|
|
|
|
|
|
|
|
$("a.external").each(function(){this.target = '_new';});
|
|
|
|
|
|
|
|
// get javascript source
|
|
|
|
if ($("#js").length) {
|
|
|
|
$("#javascript pre").addClass('mod').html( cleanupCode( $("#js").html() ) );
|
|
|
|
}
|
2015-05-15 02:32:41 +00:00
|
|
|
if ($("#js2").length) {
|
|
|
|
$("#javascript2 pre").addClass('mod').html( cleanupCode( $("#js2").html() ) );
|
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
if ($("#css").length) {
|
2015-05-17 17:29:54 +00:00
|
|
|
$("pre.lang-css").not('.locked').addClass('mod').html( cleanupCode( $("#css").html() ) );
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
|
|
|
if ($("#demo").length && $("#html pre").length) {
|
|
|
|
$("#html pre").addClass('mod').html( cleanupCode( $("#demo").html() ) );
|
|
|
|
}
|
2013-05-09 04:36:06 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
// apply to already pre-formatted blocks to add <br> for IE
|
2014-06-19 16:36:32 +00:00
|
|
|
$('pre.prettyprint:not(.mod)').each(function(){
|
2014-03-09 03:42:51 +00:00
|
|
|
$t = $(this);
|
|
|
|
$t.html( cleanupCode( $t.html() ) );
|
|
|
|
});
|
2011-07-17 15:01:18 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
if (typeof prettyPrint !== 'undefined') { prettyPrint(); }
|
2013-03-27 23:13:44 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
// hide child rows
|
|
|
|
$('#root .tablesorter-childRow').hide();
|
|
|
|
// toggle child row content, not hiding the row since we are using rowspan
|
|
|
|
$('#root .toggle').click(function(){
|
|
|
|
$(this).closest('tr').nextUntil('tr:not(.tablesorter-childRow)').toggle();
|
|
|
|
return false;
|
|
|
|
});
|
2013-01-26 15:21:13 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
animating = false;
|
|
|
|
clicked = false;
|
|
|
|
$('.collapsible').hide();
|
2011-07-17 15:01:18 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
$('a.permalink').click(function(){
|
|
|
|
var $el = $(this);
|
|
|
|
setTimeout(function(){
|
|
|
|
if (!animating && !clicked) {
|
|
|
|
animating = true;
|
|
|
|
$el.closest('tr').find('.collapsible').slideToggle();
|
|
|
|
setTimeout(function(){ animating = false; }, 200);
|
|
|
|
}
|
|
|
|
}, 200);
|
|
|
|
return false;
|
|
|
|
});
|
2014-03-12 21:03:49 +00:00
|
|
|
$('#root .permalink').dblclick(function(){
|
2014-03-09 03:42:51 +00:00
|
|
|
clicked = true;
|
|
|
|
window.location.hash = '#' + $(this).closest('tr')[0].id;
|
|
|
|
showProperty();
|
|
|
|
setTimeout(function(){ clicked = false; }, 500);
|
|
|
|
return false;
|
|
|
|
});
|
2011-07-17 15:01:18 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
$('.toggleAll, .showAll, .hideAll').click(function(){
|
|
|
|
t = $.trim($(this).text());
|
2014-06-19 16:14:39 +00:00
|
|
|
// use nextAll to ignore any <br> or other elements between this link and the table
|
|
|
|
$(this).parent().nextAll('table:first').find('.collapsible')[t]();
|
2014-03-09 03:42:51 +00:00
|
|
|
return false;
|
|
|
|
});
|
2011-12-13 04:25:26 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
// update version number
|
|
|
|
$t = $('.current-version');
|
|
|
|
if ($t.length) {
|
|
|
|
$t.html($.tablesorter.version);
|
2013-05-09 04:36:06 +00:00
|
|
|
}
|
|
|
|
|
2015-01-17 14:10:17 +00:00
|
|
|
// add high visibility tags for newest versions
|
2014-03-09 03:42:51 +00:00
|
|
|
t = $.tablesorter.version.replace(/(v|version|\+)/g, '').split('.');
|
2015-01-17 14:10:17 +00:00
|
|
|
v = [ parseInt(t[0], 10) || 1, parseInt(t[1], 10) || 0, parseInt(t[2], 10) || 0 ];
|
2014-03-09 03:42:51 +00:00
|
|
|
$('.version').each(function(){
|
|
|
|
var i;
|
|
|
|
$t = $(this);
|
|
|
|
i = $t.text().replace(/(v|version|\+)/g, '').split('.');
|
2015-01-17 14:10:17 +00:00
|
|
|
t = [ parseInt(i[0], 10) || 1, parseInt(i[1], 10) || 0, parseInt(i[2], 10) || 0 ];
|
2014-03-09 03:42:51 +00:00
|
|
|
if (t[0] === v[0] && t[1] >= v[1] - 1 ) {
|
|
|
|
$t.prepend('<span class="label ' + ( t[0] === v[0] && t[1] < v[1] ? ' label-default' : ' label-success' ) +
|
|
|
|
'">'+ ($t.hasClass('updated') ? 'Updated' : 'New') + '</span> ');
|
2015-01-17 14:10:17 +00:00
|
|
|
// updates for current version are brighter
|
|
|
|
if (t[2] <= v[2] - 1) {
|
|
|
|
// new labels for revisions > 1 back are lighter
|
|
|
|
$t.addClass('older');
|
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$t = $('.accordion');
|
|
|
|
if ($t.length) {
|
2014-03-29 00:29:17 +00:00
|
|
|
var id, hashId,
|
|
|
|
hash = window.location.hash;
|
|
|
|
// add accodion ids
|
|
|
|
$t.each(function(i){
|
|
|
|
$(this).children('h3').each(function(i){
|
|
|
|
var txt = $(this).find('a').text().toLowerCase().replace(/[-:()\"]/g,'').replace(/[\s+\/]/g,'_');
|
2014-03-09 03:42:51 +00:00
|
|
|
this.id = txt;
|
2014-03-29 00:29:17 +00:00
|
|
|
if (hash && txt === hash.slice(1)) {
|
2014-03-09 03:42:51 +00:00
|
|
|
hashId = i;
|
|
|
|
}
|
2014-02-01 16:19:26 +00:00
|
|
|
});
|
2014-03-29 00:29:17 +00:00
|
|
|
});
|
|
|
|
// set up accordions
|
|
|
|
$t.each(function(i){
|
2014-03-09 03:42:51 +00:00
|
|
|
var $this = $(this);
|
|
|
|
$this.accordion({
|
2015-05-15 02:32:41 +00:00
|
|
|
active: $this.hasClass('start-closed') ? false : hashId,
|
2014-03-09 03:42:51 +00:00
|
|
|
animate: false,
|
|
|
|
heightStyle: 'content',
|
|
|
|
collapsible: true,
|
|
|
|
create: function() {
|
|
|
|
$this.children('h3').each(function(i){
|
2014-03-29 00:29:17 +00:00
|
|
|
this.id = $(this).find('a').text().toLowerCase().replace(/[-:()\"]/g,'').replace(/[\s+\/]/g,'_');
|
2014-03-09 03:42:51 +00:00
|
|
|
$(this).before('<a class="accordion-link link" data-index="' + i + '" href="#' + this.id + '"></a>');
|
|
|
|
});
|
|
|
|
$this.find('.accordion-link').click(function(){
|
|
|
|
$this.accordion( "option", "active", $(this).data('index') );
|
|
|
|
});
|
2014-04-23 22:51:49 +00:00
|
|
|
},
|
|
|
|
activate: function(e, ui) {
|
|
|
|
// refresh zebra widget when rows are visible
|
|
|
|
ui.newPanel.find('table').trigger('applyWidgets');
|
2015-07-21 21:15:09 +00:00
|
|
|
var $opt = ui.newPanel.find('table.options');
|
|
|
|
// options tables are hidden, so colgroup won't find any visible columns to get widths
|
|
|
|
if ( $opt.length && $opt[0].config ) {
|
|
|
|
$.tablesorter.fixColumnWidth( $opt );
|
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
|
|
|
});
|
2015-09-26 13:47:38 +00:00
|
|
|
openAccordion( hash, $this );
|
2014-03-09 03:42:51 +00:00
|
|
|
});
|
2015-02-07 05:04:28 +00:00
|
|
|
|
|
|
|
$t.find('table.options').not('.tablesorter-jui').tablesorter({
|
|
|
|
widthFixed: true,
|
|
|
|
widgets: ['stickyHeaders']
|
|
|
|
});
|
|
|
|
|
2015-09-26 13:47:38 +00:00
|
|
|
$('.intlink').click(function(){
|
|
|
|
openAccordion( $(this).attr('href') );
|
|
|
|
});
|
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
2014-02-01 16:19:26 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
});
|
2011-07-17 15:01:18 +00:00
|
|
|
|
2015-09-26 13:47:38 +00:00
|
|
|
function openAccordion( hash, $accordion ) {
|
|
|
|
// hash is not a jQuery selector
|
|
|
|
if ( /[=,]/.test(hash) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var t, id, $hash;
|
|
|
|
if ( !$accordion ) {
|
|
|
|
$accordion = $(hash).closest('.accordion');
|
|
|
|
}
|
|
|
|
$hash = $accordion.find(hash);
|
|
|
|
|
|
|
|
if ( $hash.length ) {
|
|
|
|
if ( $hash.hasClass('ui-accordion-header') && !$hash.hasClass('ui-accordion-header-active') ) {
|
|
|
|
$hash.click();
|
|
|
|
|
|
|
|
// open parent accordion of nested accordion
|
|
|
|
} else if ( !$accordion.children(hash).length ) {
|
|
|
|
// div should have an id of ui-accordion-#-panel-#
|
|
|
|
id = $(hash).closest('.ui-accordion-content').attr('id').match(/\d+$/);
|
|
|
|
if (id && id.length) {
|
|
|
|
$accordion.accordion('option', 'active', Number(id[0]) - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// open table row of nested accordion
|
|
|
|
if ( ($accordion.find(hash).closest('tr').attr('id') || '') !== '') {
|
|
|
|
t = $accordion.find(hash).closest('tr');
|
|
|
|
t.find('.collapsible').show();
|
|
|
|
if (t.closest('table').hasClass('hasStickyHeaders')) {
|
|
|
|
setTimeout(function(){
|
|
|
|
window.scrollTo( 0, t.offset().top - t.parents('table')[0].config.widgetOptions.$sticky.outerHeight() );
|
|
|
|
}, 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
function showProperty(){
|
2015-03-10 16:41:40 +00:00
|
|
|
var prop, $t, wo, stickyHt,
|
|
|
|
h = window.location.hash;
|
2015-07-13 17:41:18 +00:00
|
|
|
if (h && !/[=,]/.test(h)) {
|
2014-03-09 03:42:51 +00:00
|
|
|
prop = $(h);
|
2015-03-23 21:08:07 +00:00
|
|
|
if (prop.length && !/h3|a|table/i.test(prop[0].nodeName)) {
|
2014-03-09 03:42:51 +00:00
|
|
|
prop.find('.collapsible').show();
|
|
|
|
if (h === '#csschildrow') {
|
|
|
|
$('#root .tablesorter-childRow').show();
|
2013-05-27 13:38:55 +00:00
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
// move below sticky header; added delay as there could be some lag
|
|
|
|
setTimeout(function(){
|
|
|
|
$t = prop.closest('table');
|
2015-02-07 05:04:28 +00:00
|
|
|
if ($t.length && $t[0].config) {
|
2014-04-05 13:38:44 +00:00
|
|
|
wo = $t[0].config.widgetOptions;
|
2015-07-21 21:15:09 +00:00
|
|
|
if ( wo.$sticky ) {
|
|
|
|
stickyHt = wo.$sticky.outerHeight();
|
|
|
|
h = ( wo.$sticky ? wo.$sticky.height() : '' ) || $t.hasClass('hasStickHeaders') ? stickyHt : 0;
|
|
|
|
if ($t.hasClass('options') || $t.hasClass('api')) {
|
|
|
|
window.scrollTo( 0, prop.offset().top - h );
|
|
|
|
}
|
2014-04-05 13:38:44 +00:00
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
|
|
|
}, 200);
|
|
|
|
}
|
2012-05-08 18:13:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-21 02:31:17 +00:00
|
|
|
// update stickyHeader when menu closes
|
2015-10-22 21:41:34 +00:00
|
|
|
$('#main-nav-check').bind('change', function(){
|
2015-10-21 02:31:17 +00:00
|
|
|
setTimeout(function(){
|
|
|
|
$(window).scroll();
|
|
|
|
}, 350); // transition animation 300ms
|
|
|
|
});
|
|
|
|
|
2015-07-15 02:17:57 +00:00
|
|
|
$(window).bind('load', function(){
|
2014-03-09 03:42:51 +00:00
|
|
|
if ($('#root').length) {
|
|
|
|
$(window).bind('hashchange', function(){
|
|
|
|
showProperty();
|
|
|
|
});
|
2013-05-09 04:36:06 +00:00
|
|
|
showProperty();
|
2014-03-09 03:42:51 +00:00
|
|
|
}
|
2013-03-27 23:13:44 +00:00
|
|
|
});
|
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
// append hidden parsed value to cell
|
|
|
|
// used by feet-inch-fraction & metric parser demos
|
2014-04-13 17:11:24 +00:00
|
|
|
window.addParsedValues = function($t, cols, format){
|
2015-08-23 12:16:01 +00:00
|
|
|
var r, val,
|
2014-03-09 03:42:51 +00:00
|
|
|
$r = $t.find('tbody tr'),
|
|
|
|
c = $t[0].config.cache[0].normalized;
|
|
|
|
$r.each(function(i){
|
|
|
|
r = this;
|
|
|
|
$.each(cols, function(v,j){
|
2015-08-23 12:16:01 +00:00
|
|
|
val = format ? format(c[i][j]) : c[i][j];
|
|
|
|
if (val !== '') {
|
|
|
|
r.cells[j].innerHTML += ' <span class="val hidden removeme">(<span class="results">' + val + '</span>)</span>';
|
|
|
|
}
|
2014-03-09 03:42:51 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-10-22 21:41:34 +00:00
|
|
|
$('.toggleparsedvalue').bind('click', function(){
|
2014-03-09 03:42:51 +00:00
|
|
|
$('.val').toggleClass('hidden');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
2013-03-27 23:13:44 +00:00
|
|
|
|
2014-03-09 03:42:51 +00:00
|
|
|
})(jQuery);
|