mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
- Fix do and undo buttons disable action
This commit is contained in:
parent
8d4b336908
commit
3986a97717
@ -239,17 +239,34 @@ mindplot.widget.Menu = new Class({
|
||||
this._registerTooltip('zoomOut', $msg('ZOOM_OUT'));
|
||||
|
||||
|
||||
this._addButton('undoEdition', false, false, function () {
|
||||
var undoButton = this._addButton('undoEdition', false, false, function () {
|
||||
designer.undo();
|
||||
});
|
||||
undoButton.disable();
|
||||
this._registerTooltip('undoEdition', $msg('UNDO'), "meta+Z");
|
||||
|
||||
|
||||
this._addButton('redoEdition', false, false, function () {
|
||||
var redoButton = this._addButton('redoEdition', false, false, function () {
|
||||
designer.redo();
|
||||
});
|
||||
redoButton.disable();
|
||||
this._registerTooltip('redoEdition', $msg('REDO'), "meta+shift+Z");
|
||||
|
||||
if (redoButton && undoButton) {
|
||||
designer.addEvent('modelUpdate', function (event) {
|
||||
if (event.undoSteps > 0) {
|
||||
undoButton.enable();
|
||||
} else {
|
||||
undoButton.disable();
|
||||
}
|
||||
if (event.redoSteps > 0) {
|
||||
redoButton.enable();
|
||||
} else {
|
||||
redoButton.disable();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
this._addButton('addTopics', true, false, function () {
|
||||
designer.createChildForSelectedNode();
|
||||
@ -442,6 +459,9 @@ mindplot.widget.Menu = new Class({
|
||||
var rels = designer.getModel().filterSelectedRelationships();
|
||||
|
||||
this._toolbarElems.each(function (button) {
|
||||
var buttonId = button.getButtonId();
|
||||
if (buttonId != "undoEdition" && buttonId != "redoEdition") {
|
||||
|
||||
var disable = false;
|
||||
if (button.isTopicAction() && button.isRelAction()) {
|
||||
disable = rels.length == 0 && topics.length == 0;
|
||||
@ -459,7 +479,7 @@ mindplot.widget.Menu = new Class({
|
||||
} else {
|
||||
button.enable();
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}.bind(this));
|
||||
|
||||
@ -468,6 +488,9 @@ mindplot.widget.Menu = new Class({
|
||||
var rels = designer.getModel().filterSelectedRelationships();
|
||||
|
||||
this._toolbarElems.each(function (button) {
|
||||
var buttonId = button.getButtonId();
|
||||
if (buttonId != "undoEdition" && buttonId != "redoEdition") {
|
||||
|
||||
if (button.isTopicAction() && topics.length > 0) {
|
||||
button.enable();
|
||||
}
|
||||
@ -475,12 +498,14 @@ mindplot.widget.Menu = new Class({
|
||||
if (button.isRelAction() && rels.length > 0) {
|
||||
button.enable();
|
||||
}
|
||||
}
|
||||
})
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_addButton:function (buttonId, topic, rel, fn) {
|
||||
// Register Events ...
|
||||
var result = null;
|
||||
if ($(buttonId)) {
|
||||
|
||||
var button = new mindplot.widget.ToolbarItem(buttonId, function (event) {
|
||||
@ -489,7 +514,9 @@ mindplot.widget.Menu = new Class({
|
||||
}.bind(this), {topicAction:topic, relAction:rel});
|
||||
|
||||
this._toolbarElems.push(button);
|
||||
result = button;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_registerTooltip:function (buttonId, text, shortcut) {
|
||||
|
@ -55,6 +55,10 @@ mindplot.widget.ToolbarItem = new Class({
|
||||
return elem;
|
||||
}.protect(),
|
||||
|
||||
getButtonId : function(){
|
||||
return this._buttonId;
|
||||
},
|
||||
|
||||
show : function() {
|
||||
this.fireEvent('show');
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user