2012-04-08 11:23:49 +02:00
|
|
|
;(function($) {
|
2010-04-11 09:25:26 +02:00
|
|
|
$(document).ready(function() {
|
2014-02-02 05:23:55 +01:00
|
|
|
var switched = false;
|
2010-04-11 09:25:26 +02:00
|
|
|
|
2014-02-02 05:23:55 +01:00
|
|
|
var updateTables = function() {
|
|
|
|
if (($(window).width() < 540) && !switched ){
|
|
|
|
switched = true;
|
|
|
|
|
|
|
|
$("table").each(function(i, element) {
|
|
|
|
splitTable($(element));
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (switched && ($(window).width() > 540)) {
|
|
|
|
switched = false;
|
|
|
|
|
|
|
|
$("table").each(function(i, element) {
|
|
|
|
unsplitTable($(element));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$(window).load(updateTables);
|
|
|
|
$(window).on("redraw",function() {
|
|
|
|
switched = false;
|
|
|
|
updateTables();
|
|
|
|
}); // An event to listen for
|
|
|
|
|
|
|
|
$(window).on("resize", updateTables);
|
|
|
|
|
|
|
|
|
|
|
|
function splitTable(original) {
|
|
|
|
original.wrap("<div class='table-wrapper' />");
|
|
|
|
|
|
|
|
var copy = original.clone();
|
|
|
|
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
|
|
|
|
copy.removeClass("responsive");
|
|
|
|
|
|
|
|
original.closest(".table-wrapper").append(copy);
|
|
|
|
copy.wrap("<div class='pinned' />");
|
|
|
|
original.wrap("<div class='scrollable' />");
|
|
|
|
|
|
|
|
setCellHeights(original, copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
function unsplitTable(original) {
|
|
|
|
original.closest(".table-wrapper").find(".pinned").remove();
|
|
|
|
original.unwrap();
|
|
|
|
original.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
function setCellHeights(original, copy) {
|
|
|
|
var tr = original.find('tr'),
|
|
|
|
tr_copy = copy.find('tr'),
|
|
|
|
heights = [];
|
|
|
|
|
|
|
|
tr.each(function (index) {
|
|
|
|
var self = $(this),
|
|
|
|
tx = self.find('th, td');
|
|
|
|
|
|
|
|
tx.each(function () {
|
|
|
|
var height = $(this).outerHeight(true);
|
|
|
|
heights[index] = heights[index] || 0;
|
|
|
|
|
|
|
|
if (height > heights[index]) heights[index] = height;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tr_copy.each(function (index) {
|
|
|
|
$(this).height(heights[index]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-04-11 09:25:26 +02:00
|
|
|
/** -----------------------------------------------
|
|
|
|
* TABLE OF CONTENTS
|
|
|
|
*
|
|
|
|
* Transform a #table-of-contents div to a nested list
|
|
|
|
*/
|
2014-09-07 01:26:12 +02:00
|
|
|
if($("#table-contents-holder").length > 0) {
|
2012-11-08 16:35:40 +01:00
|
|
|
var toc = '<div id="table-of-contents" class="open">' +
|
2012-11-09 12:36:46 +01:00
|
|
|
'<h4>Table of contents<span class="updown">▼</span></h4><ul style="display: none;">';
|
|
|
|
|
2010-09-05 05:17:42 +02:00
|
|
|
// Remove existing anchor redirection in the url
|
|
|
|
var pageURL = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
|
2013-02-19 22:22:18 +01:00
|
|
|
|
|
|
|
var itemCount = 0;
|
2014-09-07 01:26:12 +02:00
|
|
|
$('#content h1[id], #content h2[id], #content h3[id], #content h4[id]').each(function(i) {
|
2010-04-11 09:25:26 +02:00
|
|
|
var current = $(this);
|
2012-11-08 16:29:22 +01:00
|
|
|
var tagName = current.prop("tagName");
|
2012-09-05 11:42:06 +02:00
|
|
|
if(typeof tagName == "String") tagName = tagName.toLowerCase();
|
2013-02-19 22:22:18 +01:00
|
|
|
itemCount++;
|
2012-09-05 11:42:06 +02:00
|
|
|
toc += '<li class="' + tagName + '"><a id="link' + i + '" href="'+ pageURL +'#' + $(this).attr('id') + '" title="' + current.html() + '">' + current.html() + '</a></li>';
|
2010-04-11 09:25:26 +02:00
|
|
|
});
|
2013-02-19 22:22:18 +01:00
|
|
|
|
|
|
|
// if no items in the table of contents, don't show anything
|
|
|
|
if(itemCount == 0) return false;
|
|
|
|
|
2010-04-11 09:25:26 +02:00
|
|
|
toc += '</ul></div>';
|
2013-02-19 22:22:18 +01:00
|
|
|
|
2014-09-19 13:29:22 +02:00
|
|
|
$('#table-contents-holder').prepend(toc);
|
2012-11-08 16:35:40 +01:00
|
|
|
|
|
|
|
// Toggle the TOC
|
|
|
|
$('#table-of-contents').attr('href', 'javascript:void()').toggle(
|
|
|
|
function() {
|
2012-11-09 12:36:46 +01:00
|
|
|
$("#table-of-contents ul").animate({'height':'show'}, 200, function(){$('#table-of-contents h4 span').html('▲');})
|
2012-11-08 16:35:40 +01:00
|
|
|
},
|
|
|
|
function() {
|
2012-11-09 12:36:46 +01:00
|
|
|
$("#table-of-contents ul").animate({'height':'hide'}, 200, function(){$('#table-of-contents h4 span').html('▼');})
|
2012-11-08 16:35:40 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Make sure clicking a link won't toggle the TOC
|
|
|
|
$("#table-of-contents li a").click(function (e) { e.stopPropagation(); });
|
|
|
|
|
2010-04-11 09:25:26 +02:00
|
|
|
}
|
2012-11-08 17:23:59 +01:00
|
|
|
|
2010-09-05 02:27:17 +02:00
|
|
|
/** ---------------------------------------------
|
|
|
|
* HEADING ANCHOR LINKS
|
|
|
|
*
|
|
|
|
* Automatically adds anchor links to headings that have IDs
|
|
|
|
*/
|
2010-10-28 23:27:30 +02:00
|
|
|
var url = window.location.href;
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
$("#content h1[id], #content h2[id], #content h3[id], #content h4[id], #content h5[id], #content h6[id]").each(function() {
|
2010-10-28 23:27:30 +02:00
|
|
|
var link = '<a class="heading-anchor-link" title="Link to this section" href="'+ url + '#' + $(this).attr('id') + '">¶</a>';
|
2010-09-05 02:27:17 +02:00
|
|
|
$(this).append(' ' + link);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseenter(function() {
|
|
|
|
$(this).addClass('hover');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseleave(function() {
|
|
|
|
$(this).removeClass('hover');
|
|
|
|
});
|
2014-09-15 11:47:45 +02:00
|
|
|
|
|
|
|
$(".search input").live("keyup", function(e) {
|
|
|
|
clearTimeout($.data(this, 'timer'));
|
|
|
|
|
|
|
|
var string = $(this).val();
|
|
|
|
var self = $(this);
|
|
|
|
|
|
|
|
if (string == '') {
|
|
|
|
$(".search .autocomplete-results").hide();
|
|
|
|
} else {
|
|
|
|
var container;
|
|
|
|
|
|
|
|
if($(this).siblings('.autocomplete-results').length == 0) {
|
|
|
|
container = $("<div class='autocomplete-results'></div");
|
|
|
|
|
|
|
|
$(this).after(container);
|
|
|
|
} else {
|
|
|
|
container = $(this).siblings('.autocomplete-results').first();
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).data('timer', setTimeout(function() {
|
|
|
|
if(string !== '') {
|
|
|
|
$.getJSON(
|
|
|
|
self.parents('form').attr('action'),
|
|
|
|
{ query: string },
|
|
|
|
function(results) {
|
|
|
|
if(results) {
|
|
|
|
var list = $("<ul></ul>");
|
|
|
|
|
|
|
|
$.each(results, function(i, elem) {
|
|
|
|
list.append(
|
|
|
|
$("<li></li>")
|
|
|
|
.append(
|
|
|
|
$("<a></a>").attr('href', elem.link).text(elem.title)
|
|
|
|
).append(
|
|
|
|
elem.path
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
container.append(list);
|
|
|
|
} else {
|
|
|
|
container.hide().removeClass('loading');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}, 100));
|
|
|
|
};
|
|
|
|
});
|
2010-09-05 02:27:17 +02:00
|
|
|
|
2010-06-24 16:22:41 +02:00
|
|
|
/** ---------------------------------------------
|
|
|
|
* LANGAUGE SELECTER
|
|
|
|
*
|
|
|
|
* Hide the change button and do it onclick
|
|
|
|
*/
|
|
|
|
$("#Form_LanguageForm .Actions").hide();
|
|
|
|
|
|
|
|
$("#Form_LanguageForm select").change(function() {
|
|
|
|
$("#Form_LanguageForm").submit();
|
|
|
|
});
|
2012-04-08 11:23:49 +02:00
|
|
|
|
2014-09-26 10:15:40 +02:00
|
|
|
/** ---------------------------------------------
|
|
|
|
* SYNTAX HIGHLIGHTER
|
|
|
|
*
|
|
|
|
* As the Markdown parser now uses the GFM structure (```yml) this does
|
|
|
|
* not work with SyntaxHighlighter. The below translates the GFM output
|
|
|
|
* to one SyntaxHighter can use
|
|
|
|
*/
|
|
|
|
$("pre").each(function(i, elem) {
|
|
|
|
var code = $(elem).find('code[class^=language]');
|
|
|
|
|
|
|
|
if(code.length > 0) {
|
|
|
|
var brush = code.attr('class').replace('language-', '');
|
2014-11-03 01:03:05 +01:00
|
|
|
$(elem).attr('class', 'prettyprint lang-' + brush);
|
|
|
|
// $(elem).html(code.html());
|
2014-09-26 10:15:40 +02:00
|
|
|
}
|
|
|
|
});
|
2014-11-03 01:03:05 +01:00
|
|
|
|
|
|
|
$('.menu-toggle').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var left = $('#sidebar').is('.visible') ? -270 : 0;
|
|
|
|
$('#sidebar').animate({ left: left}, 'fast', function() {
|
|
|
|
$(this).toggleClass('visible');
|
|
|
|
});
|
|
|
|
})
|
2014-09-26 10:15:40 +02:00
|
|
|
|
2010-04-11 09:25:26 +02:00
|
|
|
});
|
|
|
|
})(jQuery);
|