Metamaps.Listeners.js.erb
This commit is contained in:
parent
a5bd0440a8
commit
b10f0cef0e
3 changed files with 79 additions and 76 deletions
|
@ -25,6 +25,7 @@
|
||||||
//= require ./src/views/room
|
//= require ./src/views/room
|
||||||
//= require ./src/JIT
|
//= require ./src/JIT
|
||||||
//= require ./src/Metamaps
|
//= require ./src/Metamaps
|
||||||
|
//= require ./src/Metamaps.Listeners
|
||||||
//= require ./src/Metamaps.Organize
|
//= require ./src/Metamaps.Organize
|
||||||
//= require ./src/Metamaps.Topic
|
//= require ./src/Metamaps.Topic
|
||||||
//= require ./src/Metamaps.Synapse
|
//= require ./src/Metamaps.Synapse
|
||||||
|
|
78
app/assets/javascripts/src/Metamaps.Listeners.js.erb
Normal file
78
app/assets/javascripts/src/Metamaps.Listeners.js.erb
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/* global Metamaps, $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Metamaps.Listeners.js.erb
|
||||||
|
*
|
||||||
|
* Dependencies:
|
||||||
|
* - Metamaps.Active
|
||||||
|
* - Metamaps.JIT
|
||||||
|
* - Metamaps.Control
|
||||||
|
* - Metamaps.Visualize
|
||||||
|
*/
|
||||||
|
Metamaps.Listeners = {
|
||||||
|
init: function () {
|
||||||
|
$(document).on('keydown', function (e) {
|
||||||
|
if (!(Metamaps.Active.Map || Metamaps.Active.Topic)) return
|
||||||
|
|
||||||
|
switch (e.which) {
|
||||||
|
case 13: // if enter key is pressed
|
||||||
|
Metamaps.JIT.enterKeyHandler()
|
||||||
|
e.preventDefault()
|
||||||
|
break
|
||||||
|
case 27: // if esc key is pressed
|
||||||
|
Metamaps.JIT.escKeyHandler()
|
||||||
|
break
|
||||||
|
case 65: // if a or A is pressed
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
Metamaps.Control.deselectAllNodes()
|
||||||
|
Metamaps.Control.deselectAllEdges()
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
|
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
||||||
|
Metamaps.Control.selectNode(n, e)
|
||||||
|
})
|
||||||
|
|
||||||
|
Metamaps.Visualize.mGraph.plot()
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case 69: // if e or E is pressed
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
if (Metamaps.Active.Map) {
|
||||||
|
Metamaps.JIT.zoomExtents(null, Metamaps.Visualize.mGraph.canvas)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 77: // if m or M is pressed
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
Metamaps.Control.removeSelectedNodes()
|
||||||
|
Metamaps.Control.removeSelectedEdges()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 68: // if d or D is pressed
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
Metamaps.Control.deleteSelected()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 72: // if h or H is pressed
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
Metamaps.Control.hideSelectedNodes()
|
||||||
|
Metamaps.Control.hideSelectedEdges()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break; // alert(e.which)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$(window).resize(function () {
|
||||||
|
if (Metamaps.Visualize && Metamaps.Visualize.mGraph) Metamaps.Visualize.mGraph.canvas.resize($(window).width(), $(window).height())
|
||||||
|
if ((Metamaps.Active.Map || Metamaps.Active.Topic) && Metamaps.Famous && Metamaps.Famous.maps.surf) Metamaps.Famous.maps.reposition()
|
||||||
|
if (Metamaps.Active.Map && Metamaps.Realtime.inConversation) Metamaps.Realtime.positionVideos()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}; // end Metamaps.Listeners
|
|
@ -4022,79 +4022,3 @@ Metamaps.Filter = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}; // end Metamaps.Filter
|
}; // end Metamaps.Filter
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* LISTENERS
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Metamaps.Listeners = {
|
|
||||||
|
|
||||||
init: function () {
|
|
||||||
|
|
||||||
$(document).on('keydown', function (e) {
|
|
||||||
if (!(Metamaps.Active.Map || Metamaps.Active.Topic)) return;
|
|
||||||
|
|
||||||
switch (e.which) {
|
|
||||||
case 13: // if enter key is pressed
|
|
||||||
Metamaps.JIT.enterKeyHandler();
|
|
||||||
e.preventDefault();
|
|
||||||
break;
|
|
||||||
case 27: // if esc key is pressed
|
|
||||||
Metamaps.JIT.escKeyHandler();
|
|
||||||
break;
|
|
||||||
case 65: //if a or A is pressed
|
|
||||||
if (e.ctrlKey){
|
|
||||||
Metamaps.Control.deselectAllNodes();
|
|
||||||
Metamaps.Control.deselectAllEdges();
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
|
||||||
Metamaps.Control.selectNode(n,e);
|
|
||||||
});
|
|
||||||
|
|
||||||
Metamaps.Visualize.mGraph.plot();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 69: //if e or E is pressed
|
|
||||||
if (e.ctrlKey){
|
|
||||||
e.preventDefault();
|
|
||||||
if (Metamaps.Active.Map) {
|
|
||||||
Metamaps.JIT.zoomExtents(null, Metamaps.Visualize.mGraph.canvas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 77: //if m or M is pressed
|
|
||||||
if (e.ctrlKey){
|
|
||||||
e.preventDefault();
|
|
||||||
Metamaps.Control.removeSelectedNodes();
|
|
||||||
Metamaps.Control.removeSelectedEdges();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 68: //if d or D is pressed
|
|
||||||
if (e.ctrlKey){
|
|
||||||
e.preventDefault();
|
|
||||||
Metamaps.Control.deleteSelected();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 72: //if h or H is pressed
|
|
||||||
if (e.ctrlKey){
|
|
||||||
e.preventDefault();
|
|
||||||
Metamaps.Control.hideSelectedNodes();
|
|
||||||
Metamaps.Control.hideSelectedEdges();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break; //alert(e.which);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(window).resize(function () {
|
|
||||||
if (Metamaps.Visualize && Metamaps.Visualize.mGraph) Metamaps.Visualize.mGraph.canvas.resize($(window).width(), $(window).height());
|
|
||||||
if ((Metamaps.Active.Map || Metamaps.Active.Topic) && Metamaps.Famous && Metamaps.Famous.maps.surf) Metamaps.Famous.maps.reposition();
|
|
||||||
if (Metamaps.Active.Map && Metamaps.Realtime.inConversation) Metamaps.Realtime.positionVideos();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}; // end Metamaps.Listeners
|
|
||||||
|
|
Loading…
Reference in a new issue