Use FX class for delete node events.
This commit is contained in:
@@ -81,6 +81,7 @@
|
||||
<!--<filelist dir="${basedir}/src/main/javascript/" files="RichTextEditor.js"/>-->
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TextEditorFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="util/FadeEffect.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
|
@@ -260,8 +260,7 @@ mindplot.CommandContext = new Class({
|
||||
|
||||
createTopic:function(model, isVisible) {
|
||||
$assert(model, "model can not be null");
|
||||
var result = this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||
return result;
|
||||
return this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||
},
|
||||
|
||||
createModel:function() {
|
||||
|
@@ -625,12 +625,19 @@ mindplot.Topic = new Class({
|
||||
model.setChildrenShrunken(value);
|
||||
|
||||
// Change render base on the state.
|
||||
|
||||
var shrinkConnector = this.getShrinkConnector();
|
||||
shrinkConnector.changeRender(value);
|
||||
|
||||
// Hide children ...
|
||||
core.Utils.setChildrenVisibilityAnimated(this, !value);
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeShrinkEvent, this.getModel());
|
||||
// Do some fancy animation ....
|
||||
var elements = this._flatten2DElements(this);
|
||||
var fade = new mindplot.util.FadeEffect(elements, !value);
|
||||
fade.addEvent('complete', function() {
|
||||
|
||||
});
|
||||
fade.start();
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeShrinkEvent, model);
|
||||
|
||||
},
|
||||
|
||||
getShrinkConnector : function() {
|
||||
@@ -1160,6 +1167,25 @@ mindplot.Topic = new Class({
|
||||
this.setSize(size);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_flatten2DElements : function(topic) {
|
||||
var result = [];
|
||||
|
||||
var children = topic.getChildren();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
|
||||
var child = children[i];
|
||||
result.push(child);
|
||||
result.push(child.getOutgoingLine());
|
||||
|
||||
var relationships = child.getRelationships();
|
||||
result = result.concat(relationships);
|
||||
|
||||
var innerChilds = core.Utils.flattenTopicChildElements(child);
|
||||
result = result.concat(innerChilds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -16,55 +16,41 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.AddTopicCommand = new Class(
|
||||
{
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(model, parentTopicId, animated) {
|
||||
$assert(model, 'Model can not be null');
|
||||
mindplot.commands.AddTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(model, parentTopicId) {
|
||||
$assert(model, 'Model can not be null');
|
||||
|
||||
this.parent();
|
||||
this._model = model;
|
||||
this._parentId = parentTopicId;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
this._animated = $defined(animated) ? animated : false;
|
||||
},
|
||||
this.parent();
|
||||
this._model = model;
|
||||
this._parentId = parentTopicId;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
execute: function(commandContext) {
|
||||
|
||||
// Add a new topic ...
|
||||
var topic = commandContext.createTopic(this._model, !this._animated);
|
||||
// Add a new topic ...
|
||||
var topic = commandContext.createTopic(this._model, false);
|
||||
|
||||
// Connect to topic ...
|
||||
if ($defined(this._parentId)) {
|
||||
var parentTopic = commandContext.findTopics(this._parentId)[0];
|
||||
commandContext.connect(topic, parentTopic, !this._animated);
|
||||
}
|
||||
|
||||
var doneFn = function() {
|
||||
// Finally, focus ...
|
||||
var designer = commandContext._designer;
|
||||
designer.onObjectFocusEvent(topic);
|
||||
topic.setOnFocus(true);
|
||||
};
|
||||
|
||||
if (this._animated) {
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], true, doneFn);
|
||||
} else {
|
||||
doneFn.attempt();
|
||||
}
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
// Finally, delete the topic from the workspace ...
|
||||
var topicId = this._model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
var doneFn = function() {
|
||||
commandContext.deleteTopic(topic);
|
||||
};
|
||||
if (this._animated) {
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], false, doneFn);
|
||||
}
|
||||
else
|
||||
doneFn.attempt();
|
||||
// Connect to topic ...
|
||||
if ($defined(this._parentId)) {
|
||||
var parentTopic = commandContext.findTopics(this._parentId)[0];
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
});
|
||||
|
||||
// Finally, focus ...
|
||||
var designer = commandContext._designer;
|
||||
var fade = new mindplot.util.FadeEffect([topic,topic.getOutgoingLine()], true);
|
||||
fade.addEvent('complete', function() {
|
||||
designer.onObjectFocusEvent(topic);
|
||||
topic.setOnFocus(true);
|
||||
});
|
||||
fade.start();
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
// Finally, delete the topic from the workspace ...
|
||||
var topicId = this._model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
commandContext.deleteTopic(topic);
|
||||
}
|
||||
});
|
@@ -73,7 +73,7 @@ mindplot.layout.EventBusDispatcher = new Class({
|
||||
// (function() {
|
||||
this._layoutManager.layout(true);
|
||||
// console.log("---------");
|
||||
this._layoutManager.dump();
|
||||
// this._layoutManager.dump();
|
||||
// console.log("---------");
|
||||
// console.log("---------");
|
||||
// }).delay(0, this);
|
||||
|
50
mindplot/src/main/javascript/util/FadeEffect.js
Normal file
50
mindplot/src/main/javascript/util/FadeEffect.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.util.FadeEffect = new Class({
|
||||
Extends: Fx,
|
||||
initialize: function(elements, isVisible) {
|
||||
this.parent({duration:3000,frames:15,transition:'linear'});
|
||||
this._isVisible = isVisible;
|
||||
this._element = elements;
|
||||
|
||||
|
||||
this.addEvent('complete', function() {
|
||||
this._element.forEach(function(elem) {
|
||||
if(elem){
|
||||
elem.setVisibility(isVisible);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
start: function(){
|
||||
this.parent(this._isVisible ? 0 : 1, this._isVisible ? 1 : 0);
|
||||
},
|
||||
|
||||
set: function(now) {
|
||||
this._element.forEach(function(elem) {
|
||||
if(elem){
|
||||
elem.setOpacity(now);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user