mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
Docs: fix nested accordions
This commit is contained in:
parent
48b642124d
commit
caeb716e8c
@ -84,6 +84,7 @@ span.alert { padding: 1px 3px; }
|
||||
#main .ui-accordion-content { font-size: 14px; }
|
||||
.accordion { position: relative; }
|
||||
.accordion .accordion-link { position: absolute; right: 1%; margin-top: 16px; z-index: 1; width: 12px; height: 12px;}
|
||||
.accordion .accordion .accordion-link { margin-top: 12px; } /* nested accordion */
|
||||
.remark, .error { font-weight: bold; color: red; font-size: 18px; }
|
||||
table th.nobold { font-weight: normal; }
|
||||
table th a { text-decoration: underline; color: #000; }
|
||||
|
316
docs/js/docs.js
316
docs/js/docs.js
@ -1,173 +1,179 @@
|
||||
$(function(){
|
||||
var $t, t, v, animate, clicked,
|
||||
/*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]});
|
||||
};
|
||||
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';});
|
||||
$("a.external").each(function(){this.target = '_new';});
|
||||
|
||||
// get javascript source
|
||||
if ($("#js").length) {
|
||||
$("#javascript pre").addClass('mod').html( cleanupCode( $("#js").html() ) );
|
||||
}
|
||||
if ($("#css").length) {
|
||||
$("pre.lang-css").addClass('mod').html( cleanupCode( $("#css").html() ) );
|
||||
}
|
||||
if ($("#demo").length && $("#html pre").length) {
|
||||
$("#html pre").addClass('mod').html( cleanupCode( $("#demo").html() ) );
|
||||
}
|
||||
|
||||
// apply to already pre-formatted blocks to add <br> for IE
|
||||
$('pre:not(.mod)').each(function(){
|
||||
$t = $(this);
|
||||
$t.html( cleanupCode( $t.html() ) );
|
||||
});
|
||||
|
||||
if (typeof prettyPrint !== 'undefined') { prettyPrint(); }
|
||||
|
||||
// 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;
|
||||
});
|
||||
|
||||
animating = false;
|
||||
clicked = false;
|
||||
$('.collapsible').hide();
|
||||
|
||||
$('a.permalink').click(function(e){
|
||||
var $el = $(this);
|
||||
setTimeout(function(){
|
||||
if (!animating && !clicked) {
|
||||
animating = true;
|
||||
$el.closest('tr').find('.collapsible').slideToggle();
|
||||
setTimeout(function(){ animating = false; }, 200);
|
||||
}
|
||||
}, 200);
|
||||
return false;
|
||||
});
|
||||
$('.permalink').dblclick(function(){
|
||||
clicked = true;
|
||||
window.location.hash = '#' + $(this).closest('tr')[0].id;
|
||||
showProperty();
|
||||
setTimeout(function(){ clicked = false; }, 500);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.toggleAll, .showAll, .hideAll').click(function(){
|
||||
t = $.trim($(this).text());
|
||||
$(this).parent().next('table').find('.collapsible')[t]();
|
||||
return false;
|
||||
});
|
||||
|
||||
// update version number
|
||||
$t = $('.current-version');
|
||||
if ($t.length) {
|
||||
$t.html($.tablesorter.version);
|
||||
}
|
||||
|
||||
// add high visibility tags for newest versions (just grab the major revision number 2.10.0 -> 10
|
||||
t = $.tablesorter.version.replace(/(v|version|\+)/g, '').split('.');
|
||||
v = [ parseInt(t[0], 10) || 1, parseInt(t[1], 10) || 0 ];
|
||||
$('.version').each(function(){
|
||||
var i;
|
||||
$t = $(this);
|
||||
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 ) {
|
||||
$t.prepend('<span class="label ' + ( t[0] === v[0] && t[1] < v[1] ? ' label-default' : ' label-success' ) +
|
||||
'">'+ ($t.hasClass('updated') ? 'Updated' : 'New') + '</span> ');
|
||||
// get javascript source
|
||||
if ($("#js").length) {
|
||||
$("#javascript pre").addClass('mod').html( cleanupCode( $("#js").html() ) );
|
||||
}
|
||||
});
|
||||
|
||||
$t = $('.accordion');
|
||||
if ($t.length) {
|
||||
var hashId = 0;
|
||||
if (window.location.hash) {
|
||||
$t.children('h3').each(function(i){
|
||||
var txt = $(this).find('a').text().toLowerCase().replace(/[()\"]/g,'').replace(/[\s+\/]/g,'_');
|
||||
this.id = txt;
|
||||
if (txt === window.location.hash.slice(1)) {
|
||||
hashId = i;
|
||||
}
|
||||
});
|
||||
if ($("#css").length) {
|
||||
$("pre.lang-css").addClass('mod').html( cleanupCode( $("#css").html() ) );
|
||||
}
|
||||
$t.accordion({
|
||||
active: hashId,
|
||||
animate: false,
|
||||
heightStyle: 'content',
|
||||
collapsible: true,
|
||||
create: function( event, ui ) {
|
||||
$t.children('h3').each(function(i){
|
||||
this.id = $(this).find('a').text().toLowerCase().replace(/[-()\"]/g,'').replace(/[\s+\/]/g,'_');
|
||||
$(this).before('<a class="accordion-link link" data-index="' + i + '" href="#' + this.id + '"></a>');
|
||||
});
|
||||
$t.find('.accordion-link').click(function(){
|
||||
$t.accordion( "option", "active", $(this).data('index') );
|
||||
});
|
||||
}
|
||||
if ($("#demo").length && $("#html pre").length) {
|
||||
$("#html pre").addClass('mod').html( cleanupCode( $("#demo").html() ) );
|
||||
}
|
||||
|
||||
// apply to already pre-formatted blocks to add <br> for IE
|
||||
$('pre:not(.mod)').each(function(){
|
||||
$t = $(this);
|
||||
$t.html( cleanupCode( $t.html() ) );
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
if (typeof prettyPrint !== 'undefined') { prettyPrint(); }
|
||||
|
||||
function showProperty(){
|
||||
var prop, $t, h = window.location.hash;
|
||||
if (h) {
|
||||
prop = $(h);
|
||||
if (prop.length && !/a|table/i.test(prop[0].tagName)) {
|
||||
prop.find('.collapsible').show();
|
||||
if (h === '#csschildrow') {
|
||||
$('#root .tablesorter-childRow').show();
|
||||
}
|
||||
// move below sticky header; added delay as there could be some lag
|
||||
// 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;
|
||||
});
|
||||
|
||||
animating = false;
|
||||
clicked = false;
|
||||
$('.collapsible').hide();
|
||||
|
||||
$('a.permalink').click(function(){
|
||||
var $el = $(this);
|
||||
setTimeout(function(){
|
||||
$t = prop.closest('table');
|
||||
h = $t[0].config.widgetOptions.$sticky.height() || 27;
|
||||
if ($t.hasClass('options') || $t.hasClass('api')) {
|
||||
$('body').scrollTop( prop.position().top - h );
|
||||
if (!animating && !clicked) {
|
||||
animating = true;
|
||||
$el.closest('tr').find('.collapsible').slideToggle();
|
||||
setTimeout(function(){ animating = false; }, 200);
|
||||
}
|
||||
}, 200);
|
||||
return false;
|
||||
});
|
||||
$('.permalink').dblclick(function(){
|
||||
clicked = true;
|
||||
window.location.hash = '#' + $(this).closest('tr')[0].id;
|
||||
showProperty();
|
||||
setTimeout(function(){ clicked = false; }, 500);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.toggleAll, .showAll, .hideAll').click(function(){
|
||||
t = $.trim($(this).text());
|
||||
$(this).parent().next('table').find('.collapsible')[t]();
|
||||
return false;
|
||||
});
|
||||
|
||||
// update version number
|
||||
$t = $('.current-version');
|
||||
if ($t.length) {
|
||||
$t.html($.tablesorter.version);
|
||||
}
|
||||
|
||||
// add high visibility tags for newest versions (just grab the major revision number 2.10.0 -> 10
|
||||
t = $.tablesorter.version.replace(/(v|version|\+)/g, '').split('.');
|
||||
v = [ parseInt(t[0], 10) || 1, parseInt(t[1], 10) || 0 ];
|
||||
$('.version').each(function(){
|
||||
var i;
|
||||
$t = $(this);
|
||||
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 ) {
|
||||
$t.prepend('<span class="label ' + ( t[0] === v[0] && t[1] < v[1] ? ' label-default' : ' label-success' ) +
|
||||
'">'+ ($t.hasClass('updated') ? 'Updated' : 'New') + '</span> ');
|
||||
}
|
||||
});
|
||||
|
||||
$t = $('.accordion');
|
||||
if ($t.length) {
|
||||
var hashId = 0;
|
||||
if (window.location.hash) {
|
||||
$t.children('h3').each(function(i){
|
||||
var txt = $(this).find('a').text().toLowerCase().replace(/[()\"]/g,'').replace(/[\s+\/]/g,'_');
|
||||
this.id = txt;
|
||||
if (txt === window.location.hash.slice(1)) {
|
||||
hashId = i;
|
||||
}
|
||||
});
|
||||
}
|
||||
$t.each(function(){
|
||||
var $this = $(this);
|
||||
$this.accordion({
|
||||
active: hashId,
|
||||
animate: false,
|
||||
heightStyle: 'content',
|
||||
collapsible: true,
|
||||
create: function() {
|
||||
$this.children('h3').each(function(i){
|
||||
this.id = $(this).find('a').text().toLowerCase().replace(/[-()\"]/g,'').replace(/[\s+\/]/g,'_');
|
||||
$(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') );
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function showProperty(){
|
||||
var prop, $t, h = window.location.hash;
|
||||
if (h) {
|
||||
prop = $(h);
|
||||
if (prop.length && !/a|table/i.test(prop[0].tagName)) {
|
||||
prop.find('.collapsible').show();
|
||||
if (h === '#csschildrow') {
|
||||
$('#root .tablesorter-childRow').show();
|
||||
}
|
||||
// move below sticky header; added delay as there could be some lag
|
||||
setTimeout(function(){
|
||||
$t = prop.closest('table');
|
||||
h = $t[0].config.widgetOptions.$sticky.height() || 27;
|
||||
if ($t.hasClass('options') || $t.hasClass('api')) {
|
||||
$('body').scrollTop( prop.position().top - h );
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(window).load(function(){
|
||||
if ($('#root').length) {
|
||||
$(window).bind('hashchange', function(){
|
||||
$(window).load(function(){
|
||||
if ($('#root').length) {
|
||||
$(window).bind('hashchange', function(){
|
||||
showProperty();
|
||||
});
|
||||
showProperty();
|
||||
});
|
||||
showProperty();
|
||||
}
|
||||
});
|
||||
|
||||
// append hidden parsed value to cell
|
||||
// used by feet-inch-fraction & metric parser demos
|
||||
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){
|
||||
r.cells[j].innerHTML += ' <span class="val hidden removeme">(<span class="results">' + (format ? format(c[i][j]) : c[i][j]) + '</span>)</span>';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('.toggleparsedvalue').on('click', function(){
|
||||
$('.val').toggleClass('hidden');
|
||||
return false;
|
||||
});
|
||||
// append hidden parsed value to cell
|
||||
// used by feet-inch-fraction & metric parser demos
|
||||
var addParsedValues = function($t, cols, format){
|
||||
var r,
|
||||
$r = $t.find('tbody tr'),
|
||||
c = $t[0].config.cache[0].normalized;
|
||||
$r.each(function(i){
|
||||
r = this;
|
||||
$.each(cols, function(v,j){
|
||||
r.cells[j].innerHTML += ' <span class="val hidden removeme">(<span class="results">' + (format ? format(c[i][j]) : c[i][j]) + '</span>)</span>';
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
$('.toggleparsedvalue').on('click', function(){
|
||||
$('.val').toggleClass('hidden');
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user