From 31c86d053d310d2a99a41a26adc7ca6d5c1baa6f Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 2 Jul 2012 22:54:59 -0300 Subject: [PATCH] Fix collapse using keybard. --- mindplot/src/main/javascript/Designer.js | 21 ++++ .../src/main/javascript/DesignerKeyboard.js | 92 ++++++++---------- mindplot/src/main/javascript/Topic.js | 1 - .../src/main/webapp/images/favicon.ico | Bin 0 -> 1150 bytes .../WEB-INF/classes/messages_en.properties | 1 + .../WEB-INF/classes/messages_es.properties | 1 + .../src/main/webapp/images/favicon.ico | Bin 0 -> 1150 bytes .../main/webapp/jsp/mindmapEditorKeyboard.jsp | 5 + 8 files changed, 71 insertions(+), 50 deletions(-) diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 129c96ce..8bdba974 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -351,6 +351,27 @@ mindplot.Designer = new Class({ return this._model; }, + + shrinkSelectedBranch:function () { + var nodes = this.getModel().filterSelectedTopics(); + if (nodes.length <= 0) { + // If there are more than one node selected, + $notify($msg('ONE_TOPIC_MUST_BE_SELECTED')); + return; + + } + if (nodes.length != 1) { + // If there are more than one node selected, + $notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED')); + return; + } + + // Execute event ... + var topic = nodes[0]; + this._actionDispatcher.shrinkBranch([topic.getId()], !topic.areChildrenShrunken()); + + }, + createChildForSelectedNode:function () { var nodes = this.getModel().filterSelectedTopics(); if (nodes.length <= 0) { diff --git a/mindplot/src/main/javascript/DesignerKeyboard.js b/mindplot/src/main/javascript/DesignerKeyboard.js index 47b520ca..9b45f9cd 100644 --- a/mindplot/src/main/javascript/DesignerKeyboard.js +++ b/mindplot/src/main/javascript/DesignerKeyboard.js @@ -19,140 +19,134 @@ mindplot.DesignerKeyboard = new Class({ Extends:Keyboard, Static:{ - register: function(designer) { + register:function (designer) { this._instance = new mindplot.DesignerKeyboard(designer); this._instance.activate(); }, - getInstance: function() { + getInstance:function () { return this._instance; } }, - initialize : function(designer) { + initialize:function (designer) { $assert(designer, "designer can not be null"); - this.parent({defaultEventType: 'keydown'}); + this.parent({defaultEventType:'keydown'}); this._registerEvents(designer); }, - _registerEvents : function(designer) { + _registerEvents:function (designer) { // Try with the keyboard .. var model = designer.getModel(); var keyboardEvents = { - 'backspace':function(event) { + 'backspace':function (event) { event.preventDefault(); event.stopPropagation(); designer.deleteCurrentNode(); }.bind(this), - 'space' : function() { - var node = model.selectedTopic(); - if (node) { - var model = topic.getModel(); - var isShrink = !model.areChildrenShrunken(); - topic.setChildrenShrunken(isShrink); - } + 'space':function () { + designer.shrinkSelectedBranch(); }.bind(this), - 'f2' : function() { + 'f2':function () { var node = model.selectedTopic(); if (node) { node.showTextEditor(); } }.bind(this), - 'delete' : function() { + 'delete':function () { designer.deleteCurrentNode(); }.bind(this), - 'enter' : - function() { - designer.createSiblingForSelectedNode(); - }.bind(this), + 'enter':function () { + designer.createSiblingForSelectedNode(); + }.bind(this), - 'insert' : function() { + 'insert':function () { designer.createChildForSelectedNode(); }.bind(this), - 'meta+enter' : function() { + 'meta+enter':function () { designer.createChildForSelectedNode(); }.bind(this), - 'ctrl+z' : function() { + 'ctrl+z':function () { designer.undo(); }.bind(this), - 'meta+z' : function() { + 'meta+z':function () { designer.undo(); }.bind(this), - 'ctrl+z+shift' :function() { + 'ctrl+z+shift':function () { designer.redo(); }.bind(this), - 'meta+z+shift' : function() { + 'meta+z+shift':function () { designer.redo(); }.bind(this), - 'ctrl+y' :function() { + 'ctrl+y':function () { designer.redo(); }.bind(this), - 'meta+y' : function() { + 'meta+y':function () { designer.redo(); }.bind(this), - 'ctrl+a' : function(event) { + 'ctrl+a':function (event) { designer.selectAll(); event.preventDefault(); }, - 'ctrl+b' : function() { + 'ctrl+b':function () { designer.changeFontWeight(); }, - 'meta+b' : function() { + 'meta+b':function () { designer.changeFontWeight(); }, - 'ctrl+s' : function(event) { + 'ctrl+s':function (event) { event.preventDefault(); $('save').fireEvent('click'); }, - 'meta+s' : function(event) { + 'meta+s':function (event) { event.preventDefault(); $('save').fireEvent('click'); }, - 'ctrl+i' : function() { + 'ctrl+i':function () { designer.changeFontStyle(); }, - 'meta+i' : function() { + 'meta+i':function () { designer.changeFontStyle(); }, - 'meta+shift+a' : function(event) { + 'meta+shift+a':function (event) { designer.deselectAll(); event.preventDefault(); }, - 'ctrl+shift+a' : function(event) { + 'ctrl+shift+a':function (event) { designer.deselectAll(); event.preventDefault(); }, - 'meta+a' : function(event) { + 'meta+a':function (event) { designer.selectAll(); event.preventDefault(); }, - 'right' : function() { + 'right':function () { var node = model.selectedTopic(); if (node) { if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { @@ -172,7 +166,7 @@ mindplot.DesignerKeyboard = new Class({ } }.bind(this), - 'left' : function() { + 'left':function () { var node = model.selectedTopic(); if (node) { if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { @@ -192,7 +186,7 @@ mindplot.DesignerKeyboard = new Class({ } }.bind(this), - 'up' : function() { + 'up':function () { var node = model.selectedTopic(); if (node) { if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { @@ -204,7 +198,7 @@ mindplot.DesignerKeyboard = new Class({ } }.bind(this), - 'down' : function() { + 'down':function () { var node = model.selectedTopic(); if (node) { if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { @@ -220,13 +214,13 @@ mindplot.DesignerKeyboard = new Class({ var regex = /^(?:shift|control|ctrl|alt|meta)$/; var modifiers = ['shift', 'control', 'alt', 'meta']; - var excludes = ['esc','capslock','tab','f1','f3','f4','f5','f6','f7','f8','f9','f10','f11','f12','backspace','down','up','left','right','control']; + var excludes = ['esc', 'capslock', 'tab', 'f1', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'backspace', 'down', 'up', 'left', 'right', 'control']; - $(document).addEvent('keydown', function(event) { + $(document).addEvent('keydown', function (event) { // Convert key to mootools keyboard event format... var keys = []; - modifiers.each(function(mod) { + modifiers.each(function (mod) { if (event[mod]) keys.push(mod); }); if (!regex.test(event.key)) @@ -261,7 +255,7 @@ mindplot.DesignerKeyboard = new Class({ }, - _goToBrother : function(designer, node, direction) { + _goToBrother:function (designer, node, direction) { var brothers = node._parent.getChildren(); var target = node; var y = node.getPosition().y; @@ -298,7 +292,7 @@ mindplot.DesignerKeyboard = new Class({ }, - _goToSideChild : function(designer, node, side) { + _goToSideChild:function (designer, node, side) { var children = node.getChildren(); if (children.length > 0) { var target = children[0]; @@ -324,12 +318,12 @@ mindplot.DesignerKeyboard = new Class({ } }, - _goToParent : function(designer, node) { + _goToParent:function (designer, node) { var parent = node._parent; this._goToNode(designer, parent); }, - _goToChild : function(designer, node) { + _goToChild:function (designer, node) { var children = node.getChildren(); if (children.length > 0) { var target = children[0]; @@ -345,7 +339,7 @@ mindplot.DesignerKeyboard = new Class({ } }, - _goToNode : function(designer, node) { + _goToNode:function (designer, node) { // First deselect all the nodes ... designer.deselectAll(); diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 0ca34c2d..2e6984b2 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -624,7 +624,6 @@ mindplot.Topic = new Class({ model.setChildrenShrunken(value); // Change render base on the state. - var shrinkConnector = this.getShrinkConnector(); if ($defined(shrinkConnector)) { shrinkConnector.changeRender(value); diff --git a/wise-editor/src/main/webapp/images/favicon.ico b/wise-editor/src/main/webapp/images/favicon.ico index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f25eeaf480887feeea2a3315f0b2abc40c6c9343 100644 GIT binary patch literal 1150 zcmb7^Yiv|i5XX;cF?=wlf`uTOD8|@8O!^|!z_PV#Fxpy((2|r#LwL9eDWoEls3DTb zt9}qejM4N1F(C%fsFXxWtU?1V)qp$~Dz!C2x0~he`*rv3z4zywi=X)B-OQc2|Cu>+ z&Yb_OQjf^5qC(00Srsf-YL-%}N<<(*9^j&s65qp5x?o`fSrNmuuw1cC2UB!ju!L!o zxAE{;D(}VVSe;{u=qH&@NexQAKAl4x;CEQoFADCVMK7etCuNc$u{Rp9T*IM2OUOGaQh z4n@)0mkm!nh|L?KGjhh9WM_%RCq2Jjb~0vBzj-^;-dIIt$0j}-y25xkGpMH&cy_53#7CN@>Veq$GUhF@q7zrts zmwHKQ^qGNC9-rUB;*Y=Q<^DS?z6G-`B$;{6!1pKAeRG5A506nCgR?%ZwTGSrOb%p!Yi#p14Zw8U%sa`0Q4I(AcD{+Y`F?Muqq2bkP z&X1m@VqO`04sB;5G(v2AjObW|-Y-w0rawjN=^<)9KaMJ^Wbo=ea#I;X!x#AV#}jl0 zTWMMEr_t9yz`v9&Yc{fc)kdmUcQJcy4{Bb3xd$Zo?L(;A6+F@2&78(|-h68V>)O`R zP*=-)J?{tyq<_LQpRbu+y?yljFwEvNH)$UjXWGs$cp50L!-RWoQ5IbYGsL_2&?4M(%p{*5l_`vZ;p`{LON2((^(Q zqmc8Mka0^ytP+}uT?dX(>06Fk;N#J@AZm%&FZr1pXk*vmJ}*Yc<~`169_tZvyRs-f{TCM=vA-NC#AN=3%e*vPZGKK&E literal 0 HcmV?d00001 diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties index c9930193..4513c8a2 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties @@ -202,4 +202,5 @@ SAVE_CHANGES=Save Chages CHANGE_TEXT_ITALIC=Change Text Italic DESELECT_ALL_TOPIC=Deselect All Topic SHORTCUTS=Shortcuts +COLLAPSE_CHILDREN=Collapse Children diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties index 0b624ead..52bae0d8 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties @@ -203,4 +203,5 @@ SAVE_CHANGES=Guardar los Cambios CHANGE_TEXT_ITALIC=Cambiar Texto a Italica DESELECT_ALL_TOPIC=Revertir Selecci\u00f3n de T\u00f3picos SHORTCUTS=Shortcuts +COLLAPSE_CHILDREN=Colapsar Hijos diff --git a/wise-webapp/src/main/webapp/images/favicon.ico b/wise-webapp/src/main/webapp/images/favicon.ico index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f25eeaf480887feeea2a3315f0b2abc40c6c9343 100644 GIT binary patch literal 1150 zcmb7^Yiv|i5XX;cF?=wlf`uTOD8|@8O!^|!z_PV#Fxpy((2|r#LwL9eDWoEls3DTb zt9}qejM4N1F(C%fsFXxWtU?1V)qp$~Dz!C2x0~he`*rv3z4zywi=X)B-OQc2|Cu>+ z&Yb_OQjf^5qC(00Srsf-YL-%}N<<(*9^j&s65qp5x?o`fSrNmuuw1cC2UB!ju!L!o zxAE{;D(}VVSe;{u=qH&@NexQAKAl4x;CEQoFADCVMK7etCuNc$u{Rp9T*IM2OUOGaQh z4n@)0mkm!nh|L?KGjhh9WM_%RCq2Jjb~0vBzj-^;-dIIt$0j}-y25xkGpMH&cy_53#7CN@>Veq$GUhF@q7zrts zmwHKQ^qGNC9-rUB;*Y=Q<^DS?z6G-`B$;{6!1pKAeRG5A506nCgR?%ZwTGSrOb%p!Yi#p14Zw8U%sa`0Q4I(AcD{+Y`F?Muqq2bkP z&X1m@VqO`04sB;5G(v2AjObW|-Y-w0rawjN=^<)9KaMJ^Wbo=ea#I;X!x#AV#}jl0 zTWMMEr_t9yz`v9&Yc{fc)kdmUcQJcy4{Bb3xd$Zo?L(;A6+F@2&78(|-h68V>)O`R zP*=-)J?{tyq<_LQpRbu+y?yljFwEvNH)$UjXWGs$cp50L!-RWoQ5IbYGsL_2&?4M(%p{*5l_`vZ;p`{LON2((^(Q zqmc8Mka0^ytP+}uT?dX(>06Fk;N#J@AZm%&FZr1pXk*vmJ}*Yc<~`169_tZvyRs-f{TCM=vA-NC#AN=3%e*vPZGKK&E literal 0 HcmV?d00001 diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditorKeyboard.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditorKeyboard.jsp index 6ba5cd66..80dd67de 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditorKeyboard.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditorKeyboard.jsp @@ -63,6 +63,11 @@ | F2 | F2 + + + Space bar + Space bar +