/*
* @title kome_float
* @description my bookmarklet
* @license MIT License
* @require
*/
javascript:(
function(){
$('#kheader').css('display','none');
$('#komediv').css('width','400px');
$('#kome').css('width','25em');
$('#klog_view').css('resize','both');
$('#klog_view').css('width','394px');
$('#klog_view').css('bottom','150px');
$('#klog_view').css('position','absolute');
document.getElementById("klog_view").classList.add("drag-and-drop");
document.getElementById("nama_box").classList.add("drag-and-drop");
var elements = document.getElementsByClassName("drag-and-drop");
var x,y;
for(var i = 0; i < elements.length; i++) {
elements[i].addEventListener("mousedown", mdown, false);
elements[i].addEventListener("touchstart", mdown, false);
}
function mdown(e) {
this.classList.add("drag");
if(e.type === "mousedown") {
var event = e;
} else {
var event = e.changedTouches[0];
}
x = event.pageX - this.offsetLeft;
y = event.pageY - this.offsetTop;
var clientRect = this.getBoundingClientRect() ;
var positionX = clientRect.left + window.pageXOffset ;
var clickX = event.pageX - positionX;
if ((this.offsetWidth - clickX) > 17){
document.body.addEventListener("mousemove", mmove, false);
document.body.addEventListener("touchmove", mmove, false);
}
}
function mmove(e) {
var drag = document.getElementsByClassName("drag")[0];
if(e.type === "mousemove") {
var event = e;
} else {
var event = e.changedTouches[0];
}
e.preventDefault();
if(event.target.className != "lightboxOverlay"){
drag.style.top = event.pageY - y + "px";
drag.style.left = event.pageX - x + "px";
}
drag.addEventListener("mouseup", mup, false);
document.body.addEventListener("mouseleave", mup, false);
drag.addEventListener("touchend", mup, false);
document.body.addEventListener("touchleave", mup, false);
}
function mup(e) {
var drag = document.getElementsByClassName("drag")[0];
document.body.removeEventListener("mousemove", mmove, false);
drag.removeEventListener("mouseup", mup, false);
document.body.removeEventListener("touchmove", mmove, false);
drag.removeEventListener("touchend", mup, false);
drag.classList.remove("drag");
}
}
)()