mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-29 09:04:54 +01:00
designer keyboard shortcuts refactor
This commit is contained in:
parent
6ebfc1b233
commit
9491f8d4a0
@ -39,19 +39,19 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
// Try with the keyboard ..
|
// Try with the keyboard ..
|
||||||
var model = designer.getModel();
|
var model = designer.getModel();
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'backspace', function (event) {
|
['backspace'], function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.deleteSelectedEntities();
|
designer.deleteSelectedEntities();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'space', function() {
|
['space'], function() {
|
||||||
designer.shrinkSelectedBranch();
|
designer.shrinkSelectedBranch();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'f2',function() {
|
['f2'],function() {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
node.showTextEditor();
|
node.showTextEditor();
|
||||||
@ -59,26 +59,26 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'del', function(event) {
|
['del'], function(event) {
|
||||||
designer.deleteSelectedEntities();
|
designer.deleteSelectedEntities();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'enter', function() {
|
['enter'], function() {
|
||||||
designer.createSiblingForSelectedNode();
|
designer.createSiblingForSelectedNode();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'insert', function(event) {
|
['insert'], function(event) {
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'tab', function(event) {
|
['tab'], function(event) {
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -90,91 +90,49 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+enter', function(event) {
|
['meta+enter'], function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.createChildForSelectedNode();
|
designer.createChildForSelectedNode();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'ctrl+z', function(event) {
|
['ctrl+z', 'meta+z'], function(event) {
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.undo();
|
designer.undo();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+z', function(event) {
|
['ctrl+c', 'meta+c'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.undo();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+c', function (event) {
|
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.copyToClipboard();
|
designer.copyToClipboard();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+c', function (event) {
|
['ctrl+v', 'meta+v'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.copyToClipboard();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+v', function (event) {
|
|
||||||
event.preventDefault(event);
|
event.preventDefault(event);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.pasteClipboard();
|
designer.pasteClipboard();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+v', function (event) {
|
['ctrl+shift+z', 'meta+shift+z', 'ctrl+y', 'meta+y'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.pasteClipboard();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+z+shift', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.redo();
|
designer.redo();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+z+shift', function (event) {
|
['ctrl+a', 'meta+a'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.redo();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+y', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.redo();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'meta+y', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
designer.redo();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+a', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
designer.selectAll();
|
designer.selectAll();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'ctrl+b', function (event) {
|
['ctrl+b', 'meta+b'], function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
@ -182,30 +140,14 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+b', function (event) {
|
['ctrl+s', 'meta+s'], function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
$(document).find('#save').trigger('click');
|
||||||
designer.changeFontWeight();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'ctrl+s', function (event) {
|
['ctrl+i', 'meta+i'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
document.id('save').fireEvent('click');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'meta+s', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
document.id('save').fireEvent('click');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+i', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
@ -213,15 +155,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+i', function (event) {
|
['ctrl+shift+a', 'meta+shift+a'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
designer.changeFontStyle();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'meta+shift+a', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
@ -229,23 +163,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'ctrl+shift+a', function (event) {
|
['meta+=', 'ctrl+='], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
designer.deselectAll();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'meta+a', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
designer.selectAll();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'meta+=', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
@ -253,23 +171,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.addShortcut(
|
this.addShortcut(
|
||||||
'meta+-', function (event) {
|
['meta+-', 'ctrl+-'], function (event) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
designer.zoomOut();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+=', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
designer.zoomIn();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.addShortcut(
|
|
||||||
'ctrl+-', function (event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
|
@ -21,8 +21,15 @@ mindplot.Keyboard = new Class({
|
|||||||
initialize:function () {
|
initialize:function () {
|
||||||
},
|
},
|
||||||
|
|
||||||
addShortcut: function(shortcut, callback) {
|
addShortcut: function(shortcuts, callback) {
|
||||||
|
if (!$.isArray(shortcuts)) {
|
||||||
|
var value = shortcuts;
|
||||||
|
shortcuts = [];
|
||||||
|
shortcuts.push(value);
|
||||||
|
}
|
||||||
|
_.each(shortcuts, function(shortcut) {
|
||||||
$(document).bind('keydown', shortcut, callback);
|
$(document).bind('keydown', shortcut, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user