mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Add support for click event node registration.
This commit is contained in:
parent
da63f53fa8
commit
f82f024fb7
@ -51,7 +51,7 @@
|
|||||||
<mkdir dir="${basedir}/target/classes"/>
|
<mkdir dir="${basedir}/target/classes"/>
|
||||||
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
|
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="TopicEditor.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="TopicEventDispatcher.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="model/INodeModel.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="model/INodeModel.js"/>
|
||||||
|
@ -61,7 +61,7 @@ mindplot.Designer = new Class({
|
|||||||
// Set editor working area ...
|
// Set editor working area ...
|
||||||
this.setViewPort(options.viewPort);
|
this.setViewPort(options.viewPort);
|
||||||
|
|
||||||
mindplot.TopicEditor.configure(this.isReadOnly());
|
mindplot.TopicEventDispatcher.configure(this.isReadOnly());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +71,10 @@ mindplot.Designer = new Class({
|
|||||||
mindplot.DesignerKeyboard.getInstance().deactivate();
|
mindplot.DesignerKeyboard.getInstance().deactivate();
|
||||||
this.deselectAll();
|
this.deselectAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the keyboard events so you can enter text into forms
|
||||||
|
*/
|
||||||
activateKeyboard: function() {
|
activateKeyboard: function() {
|
||||||
mindplot.DesignerKeyboard.getInstance().activate();
|
mindplot.DesignerKeyboard.getInstance().activate();
|
||||||
},
|
},
|
||||||
@ -85,8 +89,8 @@ mindplot.Designer = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addEvent: function(type, listener) {
|
addEvent: function(type, listener) {
|
||||||
if (type == "editnode") {
|
if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) {
|
||||||
var editor = mindplot.TopicEditor.getInstance();
|
var editor = mindplot.TopicEventDispatcher.getInstance();
|
||||||
editor.addEvent(type, listener);
|
editor.addEvent(type, listener);
|
||||||
} else {
|
} else {
|
||||||
this.parent(type, listener);
|
this.parent(type, listener);
|
||||||
@ -302,16 +306,13 @@ mindplot.Designer = new Class({
|
|||||||
setZoom: function(zoom) {
|
setZoom: function(zoom) {
|
||||||
if (zoom > 1.9 || zoom < 0.3) {
|
if (zoom > 1.9 || zoom < 0.3) {
|
||||||
$notify("Zoom too high. Cannot apply zoom above 1.9 or below 0.3");
|
$notify("Zoom too high. Cannot apply zoom above 1.9 or below 0.3");
|
||||||
console.log("Tried to set zoom to " + zoom + " which is utside allowed range.");
|
console.log("Tried to set zoom to " + zoom + " which is outside allowed range.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getModel().setZoom(zoom);
|
this.getModel().setZoom(zoom);
|
||||||
this._workspace.setZoom(zoom);
|
this._workspace.setZoom(zoom);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
zoomOut : function(factor) {
|
zoomOut : function(factor) {
|
||||||
if (!factor)
|
if (!factor)
|
||||||
factor = 1.2;
|
factor = 1.2;
|
||||||
|
@ -49,7 +49,7 @@ mindplot.Topic = new Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.addEvent('dblclick', function (event) {
|
this.addEvent('dblclick', function (event) {
|
||||||
this._getTopicEditor().show(this);
|
this._getTopicEventDispatcher().show(this);
|
||||||
event.stopPropagation(true);
|
event.stopPropagation(true);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
@ -583,7 +583,7 @@ mindplot.Topic = new Class({
|
|||||||
elem.addEvent('mouseout', outout);
|
elem.addEvent('mouseout', outout);
|
||||||
|
|
||||||
// Focus events ...
|
// Focus events ...
|
||||||
var mouseDown = function(event) {
|
elem.addEvent('mousedown', function(event) {
|
||||||
var value = true;
|
var value = true;
|
||||||
if ((event.meta && Browser.Platform.mac) || (event.control && !Browser.Platform.mac)) {
|
if ((event.meta && Browser.Platform.mac) || (event.control && !Browser.Platform.mac)) {
|
||||||
value = !this.isOnFocus();
|
value = !this.isOnFocus();
|
||||||
@ -591,8 +591,10 @@ mindplot.Topic = new Class({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
topic.setOnFocus(value);
|
topic.setOnFocus(value);
|
||||||
}.bind(this);
|
|
||||||
elem.addEvent('mousedown', mouseDown);
|
var eventDispatcher = this._getTopicEventDispatcher();
|
||||||
|
eventDispatcher.process(mindplot.TopicEvent.CLICK, this);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
areChildrenShrunken : function() {
|
areChildrenShrunken : function() {
|
||||||
@ -658,7 +660,7 @@ mindplot.Topic = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
showTextEditor : function(text) {
|
showTextEditor : function(text) {
|
||||||
this._getTopicEditor().show(this, {text:text});
|
this._getTopicEventDispatcher().show(this, {text:text});
|
||||||
},
|
},
|
||||||
|
|
||||||
showNoteEditor : function() {
|
showNoteEditor : function() {
|
||||||
@ -735,11 +737,11 @@ mindplot.Topic = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
closeEditors : function() {
|
closeEditors : function() {
|
||||||
this._getTopicEditor().close(true);
|
this._getTopicEventDispatcher().close(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTopicEditor : function() {
|
_getTopicEventDispatcher : function() {
|
||||||
return mindplot.TopicEditor.getInstance();
|
return mindplot.TopicEventDispatcher.getInstance();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1128,7 +1130,7 @@ mindplot.Topic = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a drag node is create for it, let's hide the editor.
|
// If a drag node is create for it, let's hide the editor.
|
||||||
this._getTopicEditor().close();
|
this._getTopicEventDispatcher().close();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.TopicEditor = new Class({
|
mindplot.TopicEventDispatcher = new Class({
|
||||||
Extends: Events,
|
Extends: Events,
|
||||||
Static: {
|
Static: {
|
||||||
_instance: null,
|
_instance: null,
|
||||||
|
|
||||||
configure: function(readOnly) {
|
configure: function(readOnly) {
|
||||||
this._instance = new mindplot.TopicEditor(readOnly);
|
this._instance = new mindplot.TopicEventDispatcher(readOnly);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstance : function() {
|
getInstance : function() {
|
||||||
@ -44,6 +44,10 @@ mindplot.TopicEditor = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
show : function(topic, options) {
|
show : function(topic, options) {
|
||||||
|
this.process(mindplot.TopicEvent.EDIT, topic, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
process : function(eventType, topic, options) {
|
||||||
|
|
||||||
// Close all previous open editor ....
|
// Close all previous open editor ....
|
||||||
if (this.isVisible()) {
|
if (this.isVisible()) {
|
||||||
@ -52,11 +56,11 @@ mindplot.TopicEditor = new Class({
|
|||||||
|
|
||||||
// Open the new editor ...
|
// Open the new editor ...
|
||||||
var model = topic.getModel();
|
var model = topic.getModel();
|
||||||
if (model.getShapeType() != mindplot.model.TopicShape.IMAGE && !this._readOnly) {
|
if (model.getShapeType() != mindplot.model.TopicShape.IMAGE && !this._readOnly && eventType == mindplot.TopicEvent.EDIT) {
|
||||||
this._multilineEditor.show(topic, options ? options.text : null);
|
this._multilineEditor.show(topic, options ? options.text : null);
|
||||||
this._activeEditor = this._multilineEditor;
|
this._activeEditor = this._multilineEditor;
|
||||||
} else {
|
} else {
|
||||||
this.fireEvent("editnode", {model:model,readOnly:this._readOnly});
|
this.fireEvent(eventType, {model:model,readOnly:this._readOnly});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -65,3 +69,9 @@ mindplot.TopicEditor = new Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
mindplot.TopicEvent = {
|
||||||
|
EDIT : "editnode",
|
||||||
|
CLICK : "clicknode"
|
||||||
|
};
|
||||||
|
|
@ -73,12 +73,22 @@
|
|||||||
designer.addDraggedNode(event, node);
|
designer.addDraggedNode(event, node);
|
||||||
});
|
});
|
||||||
|
|
||||||
designer.addEvent("editnode", function(event) {
|
designer.addEvent(mindplot.TopicEvent.EDIT, function(event) {
|
||||||
var node = event.model;
|
var node = event.model;
|
||||||
|
|
||||||
alert("Node Id:" + node.getId());
|
console.log("Event: edit");
|
||||||
alert("Node Metadata:" + node.getMetadata());
|
console.log("Node Id:" + node.getId());
|
||||||
alert("Is Read Only:" + event.readOnly);
|
console.log("Node Metadata:" + node.getMetadata());
|
||||||
|
console.log("Is Read Only:" + event.readOnly);
|
||||||
|
});
|
||||||
|
|
||||||
|
designer.addEvent(mindplot.TopicEvent.CLICK, function(event) {
|
||||||
|
var node = event.model;
|
||||||
|
|
||||||
|
console.log("Event: click");
|
||||||
|
console.log("Node Id:" + node.getId());
|
||||||
|
console.log("Node Metadata:" + node.getMetadata());
|
||||||
|
console.log("Is Read Only:" + event.readOnly);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user