ORIENT/themes/modern2/assets/js/menu.js

44 lines
1.4 KiB
JavaScript

var menu = document.getElementById("menu");
var menuBtn = document.getElementById("menuBtn");
var closeMenu = document.getElementById("closeMenu");
menuBtn.onclick = function () {
menu.classList.add("showMenu");
};
closeMenu.onclick = function () {
menu.classList.remove("showMenu");
};
var searchModal = document.getElementById("searchModal");
var searchBtn = document.getElementById("searchBtn");
var searchClose = document.getElementById("searchClose");
searchBtn.onclick = function () {
searchModal.classList.add("active");
};
searchClose.onclick = function () {
searchModal.classList.remove("active");
};
// =============================================
function addLink() {
//Get the selected text and append the extra info
var selection = window.getSelection();
pagelink = ". Orient: " + document.location.href;
copytext = selection + pagelink;
//Create a new div to hold the prepared text
newdiv = document.createElement('div');
//hide the newly created container
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
//insert the container, fill it with the extended text, and define the new selection
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () {
document.body.removeChild(newdiv);
}, 100);
}
document.addEventListener('copy', addLink);