2018-04-21 04:59:30 -04:00
|
|
|
(function() {
|
|
|
|
"use strict";
|
2018-04-22 15:02:38 -04:00
|
|
|
|
|
|
|
this.syntaxhighlighterConfig = { autoLinks: false };
|
2018-04-21 04:59:30 -04:00
|
|
|
|
|
|
|
this.wrap = function(elem, wrapper) {
|
|
|
|
elem.parentNode.insertBefore(wrapper, elem);
|
|
|
|
wrapper.appendChild(elem);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.unwrap = function(elem) {
|
|
|
|
var wrapper = elem.parentNode;
|
|
|
|
wrapper.parentNode.replaceChild(elem, wrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.createElement = function(tagName, className) {
|
|
|
|
var elem = document.createElement(tagName);
|
|
|
|
elem.classList.add(className);
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
2018-04-22 20:28:30 -04:00
|
|
|
// For old browsers
|
|
|
|
this.each = function(node, callback) {
|
|
|
|
var array = Array.prototype.slice.call(node);
|
|
|
|
for(var i = 0; i < array.length; i++) callback(array[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Viewable on local
|
|
|
|
if (window.location.protocol === "file:") Turbolinks.supported = false;
|
|
|
|
|
|
|
|
document.addEventListener("turbolinks:load", function() {
|
|
|
|
window.SyntaxHighlighter.highlight({ "auto-links": false });
|
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
var guidesMenu = document.getElementById("guidesMenu");
|
|
|
|
var guides = document.getElementById("guides");
|
2018-04-21 04:59:30 -04:00
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
guidesMenu.addEventListener("click", function(e) {
|
2018-04-21 04:59:30 -04:00
|
|
|
e.preventDefault();
|
2018-04-22 15:02:38 -04:00
|
|
|
guides.classList.toggle("visible");
|
2013-06-24 12:43:11 -04:00
|
|
|
});
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2018-04-22 20:28:30 -04:00
|
|
|
each(document.querySelectorAll("#guides a"), function(element) {
|
|
|
|
element.addEventListener("click", function(e) {
|
|
|
|
guides.classList.toggle("visible");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
var guidesIndexItem = document.querySelector("select.guides-index-item");
|
|
|
|
var currentGuidePath = window.location.pathname;
|
|
|
|
guidesIndexItem.value = currentGuidePath.substring(currentGuidePath.lastIndexOf("/") + 1);
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
guidesIndexItem.addEventListener("change", function(e) {
|
2018-04-22 20:28:30 -04:00
|
|
|
if (Turbolinks.supported) {
|
|
|
|
Turbolinks.visit(e.target.value);
|
|
|
|
} else {
|
|
|
|
window.location = e.target.value;
|
|
|
|
}
|
2018-04-21 04:59:30 -04:00
|
|
|
});
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
var moreInfoButton = document.querySelector(".more-info-button");
|
|
|
|
var moreInfoLinks = document.querySelector(".more-info-links");
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
moreInfoButton.addEventListener("click", function(e) {
|
2018-04-21 04:59:30 -04:00
|
|
|
e.preventDefault();
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2018-04-22 15:02:38 -04:00
|
|
|
if (moreInfoLinks.classList.contains("s-hidden")) {
|
|
|
|
wrap(moreInfoLinks, createElement("div", "more-info-container"));
|
|
|
|
moreInfoLinks.classList.remove("s-hidden");
|
2018-04-21 04:59:30 -04:00
|
|
|
} else {
|
2018-04-22 15:02:38 -04:00
|
|
|
moreInfoLinks.classList.add("s-hidden");
|
|
|
|
unwrap(moreInfoLinks);
|
2013-06-24 12:43:11 -04:00
|
|
|
}
|
2012-05-26 00:28:24 -04:00
|
|
|
});
|
2018-04-21 04:59:30 -04:00
|
|
|
});
|
|
|
|
}).call(this);
|