mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-09 00:43:23 +01:00
reimplementing shortcuts
This commit is contained in:
parent
a26fbed276
commit
c674186e05
@ -17,258 +17,273 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DesignerKeyboard = new Class({
|
mindplot.DesignerKeyboard = new Class({
|
||||||
// Extends:Keyboard,
|
//Extends: mindplot.Keyboard,
|
||||||
// Static:{
|
Static:{
|
||||||
// register:function (designer) {
|
register:function (designer) {
|
||||||
// this._instance = new mindplot.DesignerKeyboard(designer);
|
this._instance = new mindplot.DesignerKeyboard(designer);
|
||||||
// this._instance.activate();
|
//this._instance.activate();
|
||||||
// },
|
|
||||||
//
|
|
||||||
// getInstance:function () {
|
|
||||||
// return this._instance;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
initialize:function (designer) {
|
|
||||||
console.error("Re-impl required ....");
|
|
||||||
// $assert(designer, "designer can not be null");
|
|
||||||
// this.parent({defaultEventType:'keydown'});
|
|
||||||
// this._registerEvents(designer);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInstance:function () {
|
||||||
|
return this._instance;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize:function (designer) {
|
||||||
|
//console.error("Re-impl required ....");
|
||||||
|
$assert(designer, "designer can not be null");
|
||||||
|
this._registerEvents(designer);
|
||||||
|
},
|
||||||
|
|
||||||
|
//FIXME: mover al parent
|
||||||
|
addShortcut: function(shortcut, callback) {
|
||||||
|
$(document).bind('keydown', shortcut, callback);
|
||||||
|
},
|
||||||
|
|
||||||
_registerEvents:function (designer) {
|
_registerEvents:function (designer) {
|
||||||
|
|
||||||
// Try with the keyboard ..
|
// Try with the keyboard ..
|
||||||
var model = designer.getModel();
|
var model = designer.getModel();
|
||||||
var keyboardEvents = {
|
this.addShortcut(
|
||||||
'backspace':function (event) {
|
'backspace', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.deleteSelectedEntities();
|
designer.deleteSelectedEntities();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'space':function () {
|
'space', function() {
|
||||||
designer.shrinkSelectedBranch();
|
designer.shrinkSelectedBranch();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'f2':function () {
|
this.addShortcut(
|
||||||
|
'f2',function() {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
node.showTextEditor();
|
node.showTextEditor();
|
||||||
}
|
}
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'delete':function (event) {
|
this.addShortcut(
|
||||||
|
'delete', function(event) {
|
||||||
designer.deleteSelectedEntities();
|
designer.deleteSelectedEntities();
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'enter':function () {
|
this.addShortcut(
|
||||||
|
'enter', function() {
|
||||||
designer.createSiblingForSelectedNode();
|
designer.createSiblingForSelectedNode();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'insert':function (event) {
|
this.addShortcut(
|
||||||
|
'insert', function(event) {
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'tab':function (event) {
|
this.addShortcut(
|
||||||
|
'tab', function(event) {
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'-':function () { // "-" is a insert on several Browsers. Don't ask why ...
|
this.addShortcut(
|
||||||
|
'-', function() { // "-" is a insert on several Browsers. Don't ask why ...
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'meta+enter':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+enter', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'ctrl+z':function (event) {
|
'ctrl+z', function(event) {
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.undo();
|
designer.undo();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'meta+z':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+z', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.undo();
|
designer.undo();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'ctrl+c':function (event) {
|
'ctrl+c', function (event) {
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.copyToClipboard();
|
designer.copyToClipboard();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'meta+c':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+c', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.copyToClipboard();
|
designer.copyToClipboard();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'ctrl+v':function (event) {
|
'ctrl+v', function (event) {
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.pasteClipboard();
|
designer.pasteClipboard();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'meta+v':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+v', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.pasteClipboard();
|
designer.pasteClipboard();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'ctrl+z+shift':function (event) {
|
'ctrl+z+shift', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.redo();
|
designer.redo();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'meta+z+shift':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+z+shift', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.redo();
|
designer.redo();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'ctrl+y':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+y', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.redo();
|
designer.redo();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'meta+y':function (event) {
|
'meta+y', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.redo();
|
designer.redo();
|
||||||
|
}
|
||||||
}.bind(this),
|
);
|
||||||
|
this.addShortcut(
|
||||||
'ctrl+a':function (event) {
|
'ctrl+a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.selectAll();
|
designer.selectAll();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+b':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+b', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.changeFontWeight();
|
designer.changeFontWeight();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+b':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+b', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.changeFontWeight();
|
designer.changeFontWeight();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+s':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+s', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
document.id('save').fireEvent('click');
|
document.id('save').fireEvent('click');
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+s':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+s', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
document.id('save').fireEvent('click');
|
document.id('save').fireEvent('click');
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+i':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+i', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.changeFontStyle();
|
designer.changeFontStyle();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+i':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+i', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.changeFontStyle();
|
designer.changeFontStyle();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+shift+a':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+shift+a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.deselectAll();
|
designer.deselectAll();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+shift+a':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+shift+a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.deselectAll();
|
designer.deselectAll();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+a':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.selectAll();
|
designer.selectAll();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+=':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+=', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.zoomIn();
|
designer.zoomIn();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'meta+-':function (event) {
|
this.addShortcut(
|
||||||
|
'meta+-', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.zoomOut();
|
designer.zoomOut();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+=':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+=', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.zoomIn();
|
designer.zoomIn();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
'ctrl+-':function (event) {
|
this.addShortcut(
|
||||||
|
'ctrl+-', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
designer.zoomOut();
|
designer.zoomOut();
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
this.addShortcut(
|
||||||
'right':function (event) {
|
'right', function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.isCentralTopic()) {
|
if (node.isCentralTopic()) {
|
||||||
@ -288,9 +303,10 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'left':function (event) {
|
this.addShortcut(
|
||||||
|
'left', function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.isCentralTopic()) {
|
if (node.isCentralTopic()) {
|
||||||
@ -310,9 +326,10 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'up':function (event) {
|
this.addShortcut(
|
||||||
|
'up', function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (!node.isCentralTopic()) {
|
if (!node.isCentralTopic()) {
|
||||||
@ -324,9 +341,10 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this),
|
}
|
||||||
|
);
|
||||||
'down':function (event) {
|
this.addShortcut(
|
||||||
|
'down', function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (!node.isCentralTopic()) {
|
if (!node.isCentralTopic()) {
|
||||||
@ -338,9 +356,8 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}.bind(this)
|
}
|
||||||
};
|
);
|
||||||
this.addEvents(keyboardEvents);
|
|
||||||
|
|
||||||
var regex = /^(?:shift|control|ctrl|alt|meta)$/;
|
var regex = /^(?:shift|control|ctrl|alt|meta)$/;
|
||||||
var modifiers = ['shift', 'control', 'alt', 'meta'];
|
var modifiers = ['shift', 'control', 'alt', 'meta'];
|
||||||
@ -351,6 +368,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
excludes.push("alt");
|
excludes.push("alt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
document.id(document).addEvent('keydown', function (event) {
|
document.id(document).addEvent('keydown', function (event) {
|
||||||
|
|
||||||
// Convert key to mootools keyboard event format...
|
// Convert key to mootools keyboard event format...
|
||||||
@ -387,6 +405,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user