mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
Menu refactor cont. toolbar.jsp -> toolbar.jsf
This commit is contained in:
parent
5ffce2bbc3
commit
6d81803047
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
mindplot.widget.IMenu = new Class({
|
||||
|
||||
initialize : function(designer, containerId, mapId) {
|
||||
$assert(designer, "designer can not be null");
|
||||
$assert(containerId, "containerId can not be null");
|
||||
@ -27,67 +28,13 @@ mindplot.widget.IMenu = new Class({
|
||||
this._mapId = mapId;
|
||||
},
|
||||
|
||||
_registerEvents : function(designer) {
|
||||
|
||||
// Register on close events ...
|
||||
this._toolbarElems.forEach(function(elem) {
|
||||
elem.addEvent('show', function() {
|
||||
this.clear()
|
||||
}.bind(this));
|
||||
}.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));
|
||||
},
|
||||
|
||||
clear : function() {
|
||||
this._toolbarElems.forEach(function(item) {
|
||||
item.hide();
|
||||
});
|
||||
},
|
||||
|
||||
_save:function (saveElem, designer, saveHistory) {
|
||||
|
||||
console.log("save!!!!"); //TODO(gb): Remove trace!!!
|
||||
save:function (saveElem, designer, saveHistory) {
|
||||
// Load map content ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var mindmapProp = designer.getMindmapProperties();
|
||||
|
@ -242,21 +242,21 @@ mindplot.widget.Menu = new Class({
|
||||
var saveElem = $('save');
|
||||
if (saveElem) {
|
||||
this._addButton('save', false, false, function() {
|
||||
this._save(saveElem, designer, true);
|
||||
this.save(saveElem, designer, true);
|
||||
}.bind(this));
|
||||
|
||||
if (!readOnly) {
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
$(window).addEvent('beforeunload', function () {
|
||||
if (designer.needsSave()) {
|
||||
this._save(saveElem, designer, false);
|
||||
this.save(saveElem, designer, false);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Autosave on a fixed period of time ...
|
||||
(function() {
|
||||
if (designer.needsSave()) {
|
||||
this._save(saveElem, designer, false);
|
||||
this.save(saveElem, designer, false);
|
||||
}
|
||||
}.bind(this)).periodical(30000);
|
||||
}
|
||||
@ -350,6 +350,58 @@ mindplot.widget.Menu = new Class({
|
||||
this._registerEvents(designer);
|
||||
},
|
||||
|
||||
_registerEvents : function(designer) {
|
||||
|
||||
// Register on close events ...
|
||||
this._toolbarElems.forEach(function(elem) {
|
||||
elem.addEvent('show', function() {
|
||||
this.clear()
|
||||
}.bind(this));
|
||||
}.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;
|
||||
console.log(disable);
|
||||
} 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));
|
||||
},
|
||||
|
||||
_addButton:function (buttonId, topic, rel, fn) {
|
||||
// Register Events ...
|
||||
var button = new mindplot.widget.ToolbarItem(buttonId, function(event) {
|
||||
|
@ -114,6 +114,15 @@ mindplot.widget.ThinkmappingMenu = new Class({
|
||||
this._registerEvents(designer);
|
||||
},
|
||||
|
||||
_registerEvents : function(designer) {
|
||||
// Register on close events ...
|
||||
this._toolbarElems.forEach(function(elem) {
|
||||
elem.addEvent('show', function() {
|
||||
this.clear()
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_addButton:function (buttonId, fn) {
|
||||
// Register Events ...
|
||||
var button = new mindplot.widget.ToolbarItem(buttonId, function(event) {
|
||||
|
@ -133,7 +133,7 @@
|
||||
|
||||
<div id="headerMapTitle">Title: <span>${mindmap.title}</span></div>
|
||||
</div>
|
||||
<%@ include file="/jsp/toolbar.jsp" %>
|
||||
<%@ include file="/jsp/toolbar.jsf" %>
|
||||
</div>
|
||||
|
||||
<div id="mindplot"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user