1
Fork 0

Add source file sidebar

This commit is contained in:
Guillaume Gomez 2018-11-06 01:40:12 +01:00
parent 4632cf2a2e
commit 93520d2ad1
8 changed files with 384 additions and 63 deletions

View file

@ -13,6 +13,19 @@
/*jslint browser: true, es5: true */
/*globals $: true, rootPath: true */
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(suffix, length) {
var l = length || this.length;
return this.indexOf(suffix, l - suffix.length) !== -1;
};
}
(function() {
"use strict";
@ -57,19 +70,6 @@
var titleBeforeSearch = document.title;
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(suffix, length) {
var l = length || this.length;
return this.indexOf(suffix, l - suffix.length) !== -1;
};
}
function getPageId() {
var id = document.location.href.split('#')[1];
if (id) {
@ -78,46 +78,6 @@
return null;
}
function hasClass(elem, className) {
if (elem && className && elem.className) {
var elemClass = elem.className;
var start = elemClass.indexOf(className);
if (start === -1) {
return false;
} else if (elemClass.length === className.length) {
return true;
} else {
if (start > 0 && elemClass[start - 1] !== ' ') {
return false;
}
var end = start + className.length;
return !(end < elemClass.length && elemClass[end] !== ' ');
}
}
return false;
}
function addClass(elem, className) {
if (elem && className && !hasClass(elem, className)) {
if (elem.className && elem.className.length > 0) {
elem.className += ' ' + className;
} else {
elem.className = className;
}
}
}
function removeClass(elem, className) {
if (elem && className && elem.className) {
elem.className = (" " + elem.className + " ").replace(" " + className + " ", " ")
.trim();
}
}
function isHidden(elem) {
return (elem.offsetParent === null)
}
function showSidebar() {
var elems = document.getElementsByClassName("sidebar-elems")[0];
if (elems) {