Commit 278dd127 authored by PkSM3's avatar PkSM3

sigma click-events finally fine

parent 6a3a0735
This diff is collapsed.
......@@ -547,24 +547,75 @@ function theListeners(){
.contextmenu(function(){
return false;
})
.mousewheel(onGraphScroll);
.mousewheel(onGraphScroll)
.mousedown(function(e){
$(document).keydown(function(e) {
if( e.shiftKey || e.which==16 ) {
shift_key=true;
partialGraph.draw();
//left click!
if(e.which==1){
var targeted = partialGraph._core.graph.nodes.filter(function(n) {
return !!n['hover'];
}).map(function(n) {
return n.id;
});
partialGraph.dispatch(
e['type'] == 'mousedown' ?
'downgraph' :
'upgraph'
);
if(cursor_size>0) {
//Multiple selection
x1 = partialGraph._core.mousecaptor.mouseX;
y1 = partialGraph._core.mousecaptor.mouseY;
var counter=0;
var actualSel=[];
partialGraph.iterNodes(function(n){
if(!n.hidden){
distance = Math.sqrt(
Math.pow((x1-parseInt(n.displayX)),2) +
Math.pow((y1-parseInt(n.displayY)),2)
);
if(parseInt(distance)<=cursor_size) {
counter++;
actualSel.push(n.id);
}
}
});
MultipleSelection(actualSel);
// //The most brilliant way of knowing if an array is empty in the world of JavaScript
i=0; for(var s in actualSel) { i++; break;}
if(is_empty(actualSel) || i==0){
pr("cursor radius ON, mouseDown -> selecciones vacias");
cancelSelection(false);
LevelButtonDisable(true);
// $("#names").html("");
// $("#opossiteNodes").html("");
// $("#information").html("");
// $("#topPapers").html("");
// $("#tips").html(getTips());
// changeButton("unselectNodes");
// if(counter>0) graphResetColor();
}
} else {
//Unique Selection
partialGraph.dispatch(
e['type'] == 'mousedown' ? 'downnodes' : 'upnodes',
targeted
);
}
$(document).keyup(function(e) {
if(e.shiftKey || e.which==16) {
shift_key=false;
partialGraph.draw();
trackMouse();
}
});
$("#zoomSlider").slider({
orientation: "vertical",
value: partialGraph.position().ratio,
......@@ -690,16 +741,19 @@ function theListeners(){
clustersBy("default");
});
$.doTimeout(10,function (){
var deftoph=$("#defaultop").height();
var refh=$("#fixedtop").height();
pr("deftoph:"+deftoph+" vs refh:"+refh)
pr("deftoph:"+deftoph+" vs refh*2:"+refh*2)
pr("if deftoph > refh*2 ")
pr(deftoph+">"+(refh*2)+" : "+(deftoph>(refh*2))+" then reload window")
// deftoph.height(64);
// if(deftoph>(refh*2)) window.location.reload();
});
// $.doTimeout(10,function (){
// var deftoph=$("#defaultop").height();
// var refh=$("#fixedtop").height();
// pr("deftoph:"+deftoph+" vs refh:"+refh)
// pr("deftoph:"+deftoph+" vs refh*2:"+refh*2)
// pr("if deftoph > refh*2 ")
// pr(deftoph+">"+(refh*2)+" : "+(deftoph>(refh*2))+" then reload window")
// // deftoph.height(64);
// // if(deftoph>(refh*2)) window.location.reload();
// });
}
......@@ -475,99 +475,6 @@ sigma.classes.Cascade = function() {
self.p.auto ? 2 : self.p.drawLabels,
true
);
}).bind('mousedown mouseup', function(e) {
//pr("just click");
var targeted = self.graph.nodes.filter(function(n) {
return !!n['hover'];
}).map(function(n) {
return n.id;
});
self.dispatch(
e['type'] == 'mousedown' ?
'downgraph' :
'upgraph'
);
// pr("=====================================")
// pr("inside mousedown mouseup sigma core");
// pr(targeted);
// pr("targ len: "+targeted.length);
// pr(e.type)
// pr("=====================================")
if (targeted.length) {
if(cursor_size>0) {
if(!shift_key) {
x1 = partialGraph._core.mousecaptor.mouseX;
y1 = partialGraph._core.mousecaptor.mouseY;
var counter=0;
var actualSel=[];
partialGraph.iterNodes(function(n){
if(!n.hidden){
distance = Math.sqrt(
Math.pow((x1-parseInt(n.displayX)),2) +
Math.pow((y1-parseInt(n.displayY)),2)
);
if(parseInt(distance)<=cursor_size) {
counter++;
actualSel.push(n.id);
}
}
});
MultipleSelection(actualSel);
partialGraph.draw();
} else {
self.dispatch(
e['type'] == 'mousedown' ? 'downnodes' : 'upnodes',
targeted
);
MultipleSelection(targeted);
}
} else {
self.dispatch(
e['type'] == 'mousedown' ? 'downnodes' : 'upnodes',
targeted
);
}
} else {
if(cursor_size>0 && e.type=="mousedown" && !shift_key) {/**/
//The click WASN'T in a node and the cursor_size is ON
x1 = partialGraph._core.mousecaptor.mouseX;
y1 = partialGraph._core.mousecaptor.mouseY;
var counter=0;
var actualSel=[];
partialGraph.iterNodes(function(n){
if(!n.hidden){
distance = Math.sqrt(
Math.pow((x1-parseInt(n.displayX)),2) +
Math.pow((y1-parseInt(n.displayY)),2)
);
if(parseInt(distance)<=cursor_size) {
counter++;
actualSel.push(n.id);
}
}
});
MultipleSelection(actualSel);
// //The most brilliant way of knowing if an array is empty in the world of JavaScript
i=0; for(var s in actualSel) { i++; break;}
if(is_empty(actualSel) || i==0){
pr("cursor radius ON, mouseDown -> selecciones vacias");
cancelSelection(false);
LevelButtonDisable(true);
// $("#names").html("");
// $("#opossiteNodes").html("");
// $("#information").html("");
// $("#topPapers").html("");
// $("#tips").html(getTips());
// changeButton("unselectNodes");
// if(counter>0) graphResetColor();
}
partialGraph.draw();
}
}
}).bind('move', function() {
//Detects any movement of the cursor
//pr("move");
......@@ -581,9 +488,9 @@ sigma.classes.Cascade = function() {
drawHover();
drawActive();
// if(cursor_size>0){
// pr("moving with mouse-circle ON");
// }
// if(cursor_size>0){
// pr("moving with mouse-circle ON");
// }
});
sigma.chronos.bind('startgenerators', function() {
......
......@@ -214,13 +214,6 @@ function calculateFull(hex) {
var r = parseInt(hex.substring(0, 2), 16);
var g = parseInt(hex.substring(2, 4), 16);
var b = parseInt(hex.substring(4, 6), 16);
// set results
// pr( "r:"+r)
// pr( "g:"+g)
// pr( "b:"+b)
// pr("")
return [r,g,b];
}
......@@ -229,12 +222,5 @@ function calculatePartial(hex) {
var r = parseInt(hex.substring(0, 1) + hex.substring(0, 1), 16);
var g = parseInt(hex.substring(1, 2) + hex.substring(1, 2), 16);
var b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16);
// set results
// pr( "r:"+r)
// pr( "g:"+g)
// pr( "b:"+b)
// pr("")
return [r,g,b];
}
\ 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