Skip to content

Commit

Permalink
Docs: Improve load time
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Mar 20, 2018
1 parent 904e762 commit 6a2fc08
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 77 deletions.
2 changes: 1 addition & 1 deletion docs/css/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
html,body{min-height:100%;}
a{text-decoration:none;}
#main{transition: transform .3s ease; }
.main-nav{position:fixed;top:0;left:0;width:250px;height:100%;background:#3B3B3B;color:#fff;overflow:hidden;transition:transform .3s ease;transform:translateX(-250px);}
div.main-nav{position:fixed;top:0;left:0;width:250px;height:100%;background:#3B3B3B;color:#fff;overflow:hidden;transition:transform .3s ease;transform:translateX(-250px);display:block;}
.main-nav h2{color:#fff;font-size:20px;margin:0 0 15px 30px;}
.main-nav em{color:#6cf;font-style:normal;}
.main-nav .page-links a{display:block;background:linear-gradient(#3e3e3e,#383838);border-top:1px solid #484848;border-bottom:1px solid #2E2E2E;color:#FFF;white-space:nowrap;text-overflow:ellipsis;padding:10px;}
Expand Down
38 changes: 22 additions & 16 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
<title>jQuery tablesorter 2.0</title>

<!-- Demo stuff -->
<link rel="stylesheet" href="css/bootstrap-v3.min.css">
<link class="ui-theme" rel="stylesheet" href="css/jquery-ui.min.css">

<link rel="stylesheet" href="css/jq.css">
<link rel="stylesheet" href="css/menu.css">
<link href="css/prettify.css" rel="stylesheet">
<link href="../css/theme.blue.css" rel="stylesheet">
<style>
#banner h1 em {color:#6cf;}
.main-nav {display:none;}
</style>
<link href="css/bootstrap-v3.min.css" rel="preload" as="style" onload="this.rel='stylesheet'">
<link href="css/jquery-ui.min.css" class="ui-theme" rel="preload" as="style" onload="this.rel='stylesheet'">

<link href="css/jq.css" rel="preload" as="style" onload="this.rel='stylesheet'">
<link href="css/menu.css" rel="preload" as="style" onload="this.rel='stylesheet'">
<link href="css/prettify.css" rel="preload" as="style" onload="this.rel='stylesheet'">
<link href="../css/theme.blue.css" rel="preload" as="style" onload="this.rel='stylesheet'">

</head>
<body id="root">
Expand All @@ -21,7 +25,7 @@
<div class="page-search">
<h2 class="title">table<em>sorter</em></h2>
<div class="input-group search-group">
<div class="status" title="results"></div>
<div class="status"></div>
<input type="text" placeholder="Find on page..." size="25" maxlength="25" class="search form-control input-sm">
<div class="input-group-btn">
<button type="button" class="search-clear btn btn-default tooltip-top" title="Clear search">
Expand Down Expand Up @@ -8193,25 +8197,27 @@ <h1>Credits</h1>

<!-- jQuery -->
<script src="js/jquery-latest.min.js"></script>
<script src="js/jquery-migrate-3.0.0.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/prettify.js"></script>
<script src="js/docs.js"></script>
<script src="js/search.js"></script>
<script async src="js/jquery-migrate-3.0.0.min.js"></script>
<script async src="js/jquery-ui.min.js"></script>
<script async src="js/prettify.js"></script>
<script async src="js/docs.js"></script>
<script async src="js/search.js"></script>
<!--[if lte IE 8]>
<script src="js/search-ie.js"></script>
<![endif]-->

<!-- Tablesorter: required -->
<script src="../js/jquery.tablesorter.combined.js"></script>
<script>
<script async>
$.extend( $.tablesorter.defaults, {
theme: 'blue',
widthFixed: true
});
$('.compatibility').tablesorter();
$('#tablesorter-demo').tablesorter({widgets:['zebra']});
$('table.options, table.api').tablesorter({widgets:['stickyHeaders']});
setTimeout(function(){
$('.compatibility').tablesorter();
$('table.options, table.api').tablesorter({widgets:['stickyHeaders']});
}, 1000);
</script>

</body>
Expand Down
80 changes: 40 additions & 40 deletions docs/js/docs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*jshint browser:true, jquery:true, unused:false */
/*global prettyPrint:false */
(function($){
$(function(){
(function($) {
$(function() {
var $t, t, v, animating, clicked,

cleanupCode = function(code){
cleanupCode = function(code) {
return code.replace(/([<>\"\'\t\n]|&#133;)/g, function(m) { return {
'<' : '&lt;',
'>' : '&gt;',
Expand All @@ -16,24 +16,24 @@
}[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 ($('#js').length) {
$('#javascript pre').addClass('mod').html( cleanupCode( $('#js').html() ) );
}
if ($("#js2").length) {
$("#javascript2 pre").addClass('mod').html( cleanupCode( $("#js2").html() ) );
if ($('#js2').length) {
$('#javascript2 pre').addClass('mod').html( cleanupCode( $('#js2').html() ) );
}
if ($("#css").length) {
$("pre.lang-css").not('.locked').addClass('mod').html( cleanupCode( $("#css").html() ) );
if ($('#css').length) {
$('pre.lang-css').not('.locked').addClass('mod').html( cleanupCode( $('#css').html() ) );
}
if ($("#demo").length && $("#html pre").length) {
$("#html pre").addClass('mod').html( cleanupCode( $("#demo").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.prettyprint:not(.mod)').each(function(){
$('pre.prettyprint:not(.mod)').each(function() {
$t = $(this);
$t.html( cleanupCode( $t.html() ) );
});
Expand All @@ -45,7 +45,7 @@
// hide child rows
$('#root .tablesorter-childRow').hide();
// toggle child row content, not hiding the row since we are using rowspan
$('#root .toggle').click(function(){
$('#root .toggle').click(function() {
$(this).closest('tr').nextUntil('tr:not(.tablesorter-childRow)').toggle();
return false;
});
Expand All @@ -54,26 +54,26 @@
clicked = false;
$('.collapsible').hide();

$('a.permalink').click(function(){
$('a.permalink').click(function() {
var $el = $(this);
setTimeout(function(){
setTimeout(function() {
if (!animating && !clicked) {
animating = true;
$el.closest('tr').find('.collapsible').slideToggle();
setTimeout(function(){ animating = false; }, 200);
setTimeout(function() { animating = false; }, 200);
}
}, 200);
return false;
});
$('#root .permalink').dblclick(function(){
$('#root .permalink').dblclick(function() {
clicked = true;
window.location.hash = '#' + $(this).closest('tr')[0].id;
showProperty();
setTimeout(function(){ clicked = false; }, 500);
setTimeout(function() { clicked = false; }, 500);
return false;
});

$('.toggleAll, .showAll, .hideAll').click(function(){
$('.toggleAll, .showAll, .hideAll').click(function() {
t = $.trim($(this).text());
// use nextAll to ignore any <br> or other elements between this link and the table
$(this).parent().nextAll('table:first').find('.collapsible')[t]();
Expand All @@ -89,7 +89,7 @@
// add high visibility tags for newest versions
t = $.tablesorter.version.replace(/(v|version|\+)/g, '').split('.');
v = [ parseInt(t[0], 10) || 1, parseInt(t[1], 10) || 0, parseInt(t[2], 10) || 0 ];
$('.version').each(function(){
$('.version').each(function() {
var i;
$t = $(this);
i = $t.text().replace(/(v|version|\+)/g, '').split('.');
Expand All @@ -107,11 +107,11 @@

$t = $('.accordion');
if ($t.length) {
var id, hashId,
var hashId,
hash = window.location.hash;
// add accodion ids
$t.each(function(i){
$(this).children('h3').each(function(i){
$t.each(function() {
$(this).children('h3').each(function(i) {
var txt = $(this).find('a').text().toLowerCase().replace(/[-:()\"]/g,'').replace(/[\s+\/]/g,'_');
this.id = txt;
if (hash && txt === hash.slice(1)) {
Expand All @@ -120,20 +120,20 @@
});
});
// set up accordions
$t.each(function(i){
$t.each(function() {
var $this = $(this);
$this.accordion({
active: $this.hasClass('start-closed') ? false : hashId,
animate: false,
heightStyle: 'content',
collapsible: true,
create: function() {
$this.children('h3').each(function(i){
$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') );
$this.find('.accordion-link').click(function() {
$this.accordion( 'option', 'active', $(this).data('index') );
});
},
activate: function(e, ui) {
Expand All @@ -154,7 +154,7 @@
widgets: ['stickyHeaders']
});

$('.intlink').click(function(){
$('.intlink').click(function() {
openAccordion( $(this).attr('href') );
});

Expand Down Expand Up @@ -191,7 +191,7 @@
t = $accordion.find(hash).closest('tr');
t.find('.collapsible').show();
if (t.closest('table').hasClass('hasStickyHeaders')) {
setTimeout(function(){
setTimeout(function() {
window.scrollTo( 0, t.offset().top - t.parents('table')[0].config.widgetOptions.$sticky.outerHeight() );
}, 200);
}
Expand All @@ -200,7 +200,7 @@
}
}

function showProperty(){
function showProperty() {
var prop, $t, wo, stickyHt,
h = window.location.hash;
if (h && !/[=,]/.test(h)) {
Expand All @@ -211,7 +211,7 @@
$('#root .tablesorter-childRow').show();
}
// move below sticky header; added delay as there could be some lag
setTimeout(function(){
setTimeout(function() {
$t = prop.closest('table');
if ($t.length && $t[0].config) {
wo = $t[0].config.widgetOptions;
Expand All @@ -229,15 +229,15 @@
}

// update stickyHeader when menu closes
$('#main-nav-check').bind('change', function(){
setTimeout(function(){
$('#main-nav-check').bind('change', function() {
setTimeout(function() {
$(window).scroll();
}, 350); // transition animation 300ms
});

$(window).bind('load', function(){
$(window).bind('load', function() {
if ($('#root').length) {
$(window).bind('hashchange', function(){
$(window).bind('hashchange', function() {
showProperty();
});
showProperty();
Expand All @@ -246,21 +246,21 @@

// append hidden parsed value to cell
// used by feet-inch-fraction & metric parser demos
window.addParsedValues = function($t, cols, format){
window.addParsedValues = function($t, cols, format) {
var r, val,
$r = $t.find('tbody tr'),
c = $t[0].config.cache[0].normalized;
$r.each(function(i){
$r.each(function(i) {
r = this;
$.each(cols, function(v,j){
$.each(cols, function(v,j) {
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>';
}
});
});

$('.toggleparsedvalue').bind('click', function(){
$('.toggleparsedvalue').bind('click', function() {
$('.val').toggleClass('hidden');
return false;
});
Expand Down
Loading

0 comments on commit 6a2fc08

Please sign in to comment.