Thinkmapping Menu

This commit is contained in:
Gonzalo Bellver 2011-11-30 18:17:19 -03:00
parent a300899673
commit 5ffce2bbc3

View File

@ -53,7 +53,7 @@ mindplot.widget.ThinkmappingMenu = new Class({
this._toolbarElems.push(new mindplot.widget.SharePanel('shareButton', dummyModel, baseUrl)); this._toolbarElems.push(new mindplot.widget.SharePanel('shareButton', dummyModel, baseUrl));
this._toolbarElems.push(new mindplot.widget.UserPanel('userButton', dummyModel, baseUrl)); this._toolbarElems.push(new mindplot.widget.UserPanel('userButton', dummyModel, baseUrl));
this.addButton('newButton', false, false, function() { this._addButton('newButton', function() {
var reqDialog = new MooDialog.Request('newMapDialog.htm', null, var reqDialog = new MooDialog.Request('newMapDialog.htm', null,
{'class': 'newModalDialog', {'class': 'newModalDialog',
closeButton:true, closeButton:true,
@ -68,7 +68,7 @@ mindplot.widget.ThinkmappingMenu = new Class({
MooDialog.Request.active = reqDialog; MooDialog.Request.active = reqDialog;
}); });
this.addButton('importButton', false, false, function() { this._addButton('importButton', function() {
var reqDialog = new MooDialog.Request('importMap.htm', null, var reqDialog = new MooDialog.Request('importMap.htm', null,
{'class': 'importModalDialog', {'class': 'importModalDialog',
closeButton:true, closeButton:true,
@ -82,7 +82,7 @@ mindplot.widget.ThinkmappingMenu = new Class({
}); });
MooDialog.Request.active = reqDialog; MooDialog.Request.active = reqDialog;
}); });
this.addButton('headerMapTitle', false, false, function() { this._addButton('headerMapTitle', function() {
var reqDialog = new MooDialog.Request('renameMap.htm?mapId='+mapId, null, var reqDialog = new MooDialog.Request('renameMap.htm?mapId='+mapId, null,
{'class': 'renameModalDialog', {'class': 'renameModalDialog',
closeButton:true, closeButton:true,
@ -96,7 +96,7 @@ mindplot.widget.ThinkmappingMenu = new Class({
}); });
MooDialog.Request.active = reqDialog; MooDialog.Request.active = reqDialog;
}); });
this.addButton('communicateButton', false, false, function() { this._addButton('communicateButton', function() {
var reqDialog = new MooDialog.Request('sharing.htm?mapId='+mapId, null, var reqDialog = new MooDialog.Request('sharing.htm?mapId='+mapId, null,
{'class': 'communicateModalDialog', {'class': 'communicateModalDialog',
closeButton:true, closeButton:true,
@ -110,62 +110,16 @@ mindplot.widget.ThinkmappingMenu = new Class({
}); });
MooDialog.Request.active = reqDialog; MooDialog.Request.active = reqDialog;
}); });
this._addButton('save', false, false, function() {
this._save(saveElem, designer, true);
}.bind(this));
this._registerEvents(designer); this._registerEvents(designer);
}, },
_registerEvents : function(designer) { _addButton:function (buttonId, fn) {
// Register Events ...
// Register on close events ... var button = new mindplot.widget.ToolbarItem(buttonId, function(event) {
this._toolbarElems.forEach(function(elem) { fn(event);
elem.addEvent('show', function() { this.clear();
this.clear() }.bind(this), {topicAction:true, relAction:true});
}.bind(this)); this._toolbarElems.push(button);
}.bind(this));
designer.addEvent('onblur', function() {
var topics = designer.getModel().filterSelectedTopics();
var rels = designer.getModel().filterSelectedRelations();
this._toolbarElems.forEach(function(button) {
var disable = false;
if (button.isTopicAction() && button.isRelAction()) {
disable = rels.length == 0 && topics.length == 0;
} else if (!button.isTopicAction() && !button.isRelAction()) {
disable = false;
}
else if (button.isTopicAction() && topics.length == 0) {
disable = true;
} else if (button.isRelAction() && rels.length == 0) {
disable = true;
}
if (disable) {
button.disable();
} else {
button.enable();
}
})
}.bind(this));
designer.addEvent('onfocus', function() {
var topics = designer.getModel().filterSelectedTopics();
var rels = designer.getModel().filterSelectedRelations();
this._toolbarElems.forEach(function(button) {
if (button.isTopicAction() && topics.length > 0) {
button.enable();
}
if (button.isRelAction() && rels.length > 0) {
button.enable();
}
})
}.bind(this));
} }
}) })