From 5496b9b076fef8a16230ccdaf324e1f5d1214524 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 23 Mar 2012 08:43:07 -0300 Subject: [PATCH] Fix event registration event capture during drag. --- mindplot/src/main/javascript/NodeGraph.js | 4 ++++ mindplot/src/main/javascript/Topic.js | 23 +++++++++++-------- .../main/javascript/TopicEventDispatcher.js | 1 + wise-editor/src/main/webapp/html/drag.html | 3 +-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/mindplot/src/main/javascript/NodeGraph.js b/mindplot/src/main/javascript/NodeGraph.js index 53d0771c..a5611432 100644 --- a/mindplot/src/main/javascript/NodeGraph.js +++ b/mindplot/src/main/javascript/NodeGraph.js @@ -28,6 +28,10 @@ mindplot.NodeGraph = new Class({ this._size = {width:50,height:20}; }, + isReadOnly : function(){ + return this._options.readOnly; + }, + getType : function() { var model = this.getModel(); return model.getType(); diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index cbaebb49..df3d98c3 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -34,7 +34,7 @@ mindplot.Topic = new Class({ } // Register events for the topic ... - if (!options.readOnly) { + if (!this.isReadOnly()) { this._registerEvents(); } }, @@ -50,7 +50,7 @@ mindplot.Topic = new Class({ this.addEvent('dblclick', function (event) { this._getTopicEventDispatcher().show(this); - event.stopPropagation(true); + event.stopPropagation(); }.bind(this)); }, @@ -134,7 +134,7 @@ mindplot.Topic = new Class({ this._setBorderColor(brColor, false); // Define the pointer ... - if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { + if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && !this.isReadOnly()) { this._innerShape.setCursor('move'); } else { this._innerShape.setCursor('default'); @@ -584,16 +584,21 @@ mindplot.Topic = new Class({ // Focus events ... elem.addEvent('mousedown', function(event) { - var value = true; - if ((event.meta && Browser.Platform.mac) || (event.control && !Browser.Platform.mac)) { - value = !this.isOnFocus(); - event.stopPropagation(); - event.preventDefault(); + if (!this.isReadOnly()) { + // Disable topic selection of readOnly mode ... + var value = true; + if ((event.meta && Browser.Platform.mac) || (event.control && !Browser.Platform.mac)) { + value = !this.isOnFocus(); + event.stopPropagation(); + event.preventDefault(); + } + topic.setOnFocus(value); } - topic.setOnFocus(value); var eventDispatcher = this._getTopicEventDispatcher(); eventDispatcher.process(mindplot.TopicEvent.CLICK, this); + event.stopPropagation(); + }.bind(this)); }, diff --git a/mindplot/src/main/javascript/TopicEventDispatcher.js b/mindplot/src/main/javascript/TopicEventDispatcher.js index 5e37869e..90eea789 100644 --- a/mindplot/src/main/javascript/TopicEventDispatcher.js +++ b/mindplot/src/main/javascript/TopicEventDispatcher.js @@ -48,6 +48,7 @@ mindplot.TopicEventDispatcher = new Class({ }, process : function(eventType, topic, options) { + $assert(eventType, "eventType can not be null"); // Close all previous open editor .... if (this.isVisible()) { diff --git a/wise-editor/src/main/webapp/html/drag.html b/wise-editor/src/main/webapp/html/drag.html index 901f5509..7170252e 100644 --- a/wise-editor/src/main/webapp/html/drag.html +++ b/wise-editor/src/main/webapp/html/drag.html @@ -4,8 +4,7 @@ WiseMapping - Editor - +