2018-04-18 10:57:57 +00:00
|
|
|
// ondblclick
|
2018-05-03 08:14:28 +00:00
|
|
|
document.ondblclick = function (event) {
|
2018-07-07 20:32:45 +00:00
|
|
|
var obj = event.target;
|
2018-04-18 10:57:57 +00:00
|
|
|
var callingID = obj.id;
|
2018-07-07 20:32:45 +00:00
|
|
|
var classNM = obj.className;
|
2018-04-18 10:57:57 +00:00
|
|
|
|
|
|
|
// Left click detect
|
|
|
|
if (event.which == 1) {
|
2018-05-03 08:14:28 +00:00
|
|
|
// If clicking on container
|
|
|
|
if (classNM == "fileStyle" || classNM == "movieStyle" ||
|
|
|
|
classNM == "dirStyle") {
|
|
|
|
if (classNM == "dirStyle") {
|
|
|
|
getDir(obj.children[1].value);
|
|
|
|
} else {
|
|
|
|
showMedia(obj.children[1].value);
|
|
|
|
}
|
|
|
|
// If clicking on dir icon
|
|
|
|
} else if (callingID == "dirID") {
|
2018-04-18 10:57:57 +00:00
|
|
|
var node = obj.parentNode;
|
|
|
|
getDir(node.children[1].value);
|
2018-05-03 08:14:28 +00:00
|
|
|
// If clicking on movie thumbnail
|
2018-04-18 10:57:57 +00:00
|
|
|
} else if (callingID == "movieID") {
|
|
|
|
var node = obj.parentNode;
|
|
|
|
showMedia(node.children[1].value);
|
2018-05-03 08:14:28 +00:00
|
|
|
// If clicking on file icon
|
2018-04-18 10:57:57 +00:00
|
|
|
} else if (callingID == "fileID") {
|
|
|
|
var node = obj.parentNode;
|
|
|
|
showMedia(node.children[1].value);
|
2018-05-03 08:14:28 +00:00
|
|
|
// If clicking on image
|
2018-04-18 10:57:57 +00:00
|
|
|
} else if (callingID == "imageID") {
|
|
|
|
showImg(obj.alt);
|
2018-05-03 08:14:28 +00:00
|
|
|
// If clicking on text title
|
2018-04-18 10:57:57 +00:00
|
|
|
} else if (callingID == "titleID") {
|
|
|
|
enableEdit(obj);
|
|
|
|
}
|
|
|
|
// Right click detect
|
|
|
|
} else if (event.which == 3) {
|
|
|
|
if (callingID == "imageID") {
|
|
|
|
startDeleteItem(obj.alt);
|
|
|
|
} else if (callingID == "dirID" || callingID == "fileID" ||
|
|
|
|
callingID == "movieID") {
|
|
|
|
var node = obj.parentNode;
|
|
|
|
startDeleteItem(node.children[1].value);
|
|
|
|
} else if (classNM == "fileStyle" || classNM == "dirStyle" ||
|
|
|
|
classNM == "movieStyle") {
|
|
|
|
startDeleteItem(obj.children[1].value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-23 01:43:19 +00:00
|
|
|
// Mainly for rename event
|
2018-04-18 10:57:57 +00:00
|
|
|
document.onkeydown = function (event) {
|
2018-07-07 20:32:45 +00:00
|
|
|
var obj = event.target;
|
|
|
|
var callingID = event.target.id;
|
2018-04-18 10:57:57 +00:00
|
|
|
var keyCodeVal = event.keyCode;
|
|
|
|
|
|
|
|
// If keycode == Enter
|
|
|
|
if (keyCodeVal == 13) {
|
|
|
|
if (callingID == "titleID") {
|
|
|
|
renameItem(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-05-03 08:14:28 +00:00
|
|
|
// Drage event for the poped out image and media container
|
2018-04-23 01:43:19 +00:00
|
|
|
function dragContainer(elmnt) {
|
|
|
|
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
2018-07-07 20:32:45 +00:00
|
|
|
elmnt.onmousedown = dragMouseDown;
|
2018-04-23 01:43:19 +00:00
|
|
|
|
|
|
|
function dragMouseDown(e) {
|
|
|
|
e = e || window.event;
|
|
|
|
pauseEvent(e);
|
|
|
|
// get the mouse cursor position at startup:
|
|
|
|
pos3 = e.clientX;
|
|
|
|
pos4 = e.clientY;
|
|
|
|
document.onmouseup = closeDragElement;
|
|
|
|
// call a function whenever the cursor moves:
|
|
|
|
document.onmousemove = elementDrag;
|
|
|
|
}
|
|
|
|
|
|
|
|
function elementDrag(e) {
|
|
|
|
e = e || window.event;
|
|
|
|
pauseEvent(e);
|
|
|
|
// calculate the new cursor position:
|
|
|
|
pos1 = pos3 - e.clientX;
|
|
|
|
pos2 = pos4 - e.clientY;
|
|
|
|
pos3 = e.clientX;
|
|
|
|
pos4 = e.clientY;
|
|
|
|
// set the element's new position:
|
|
|
|
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
|
|
|
|
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeDragElement(e) {
|
|
|
|
// stop moving when mouse button is released:
|
|
|
|
document.onmouseup = null;
|
|
|
|
document.onmousemove = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function pauseEvent(e) {
|
|
|
|
if(e.stopPropagation) e.stopPropagation();
|
|
|
|
if(e.preventDefault) e.preventDefault();
|
|
|
|
|
|
|
|
e.cancelBubble=true;
|
|
|
|
e.returnValue=false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|