Commit a863a9c2 authored by jerry wham's avatar jerry wham
Browse files

Update utils.js

parent 1bfb21a1
......@@ -8,7 +8,7 @@ params = params.replace('index.php?','');
var slide = null;
function doAction(className,action) {
var elemWithClass = document.querySelectorAll('.'+className);
var elemWithClass = document.querySelectorAll('.'+className);
var nbElemWithClass = elemWithClass.length;
for (var i = 0; i < nbElemWithClass; i++) {
elemWithClass[i].addEventListener('click', function(e) {
......@@ -43,6 +43,55 @@ function doAction(className,action) {
}
}
var xMousePosition = 0;
var yMousePosition = 0;
document.onmousemove = function(e)
{
xMousePosition = e.clientX + window.pageXOffset;
yMousePosition = e.clientY + window.pageYOffset;
};
function hasClass(object, className) {
if (!object.className || object.className === undefined) return false;
return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}
function removeClass(object,className) {
if (!object || !hasClass(object,className)) return;
object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2);
}
function addClass(object,className) {
if (!object || hasClass(object, className)) return;
if (object.className) {
object.className += ' '+className;
} else {
object.className = className;
}
}
var menus = document.querySelectorAll('.contextmenu');
var nbMenus = menus.length;
for (var i = 0; i < nbMenus; i++) {
d = menus[i];
if (hasClass(d.firstElementChild,'show')) {
removeClass(d.firstElementChild,'show');
}
addClass(d.firstElementChild,'hide');
}
function monmenu(element) {
d = element.firstElementChild;
if (d === undefined) return false;
removeClass(d,'hide');
addClass(d,'show');
d.style.left = xMousePosition + "px";
d.style.top = yMousePosition + "px";
d.onmouseover = function(e) { this.style.cursor = 'pointer'; }
d.onmouseleave = function(e) { removeClass(d,'show');addClass(d,'hide'); }
d.onclick = function(e) { removeClass(d,'show');addClass(d,'hide'); }
document.body.onclick = function(e) { removeClass(d,'show');addClass(d,'hide'); }
return false;
}
var targetBlank = document.querySelector('a.targetBlank').addEventListener('click', function(evt) {
evt.preventDefault();
......@@ -79,8 +128,6 @@ doAction('editor','edit');
doAction('add','add');
danger();
var side = document.querySelector('aside');
var h = window.innerHeight-(50+40);// height of main - (height of header - height of footer)
side.style="height:"+h+"px;";
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment