diff --git a/mindplot/src/main/javascript/widget/IMenu.js b/mindplot/src/main/javascript/widget/IMenu.js index acdc4bae..551e70e5 100644 --- a/mindplot/src/main/javascript/widget/IMenu.js +++ b/mindplot/src/main/javascript/widget/IMenu.js @@ -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(); diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js index 3bc38e27..d297018a 100644 --- a/mindplot/src/main/javascript/widget/Menu.js +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -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) { diff --git a/mindplot/src/main/javascript/widget/ThinkmappingMenu.js b/mindplot/src/main/javascript/widget/ThinkmappingMenu.js index 2c4fb68b..9951f2ab 100644 --- a/mindplot/src/main/javascript/widget/ThinkmappingMenu.js +++ b/mindplot/src/main/javascript/widget/ThinkmappingMenu.js @@ -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) { diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index a7de8fde..01b55646 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -133,7 +133,7 @@
Title: ${mindmap.title}
- <%@ include file="/jsp/toolbar.jsp" %> + <%@ include file="/jsp/toolbar.jsf" %>
diff --git a/wise-webapp/src/main/webapp/jsp/toolbar.jsp b/wise-webapp/src/main/webapp/jsp/toolbar.jsf similarity index 100% rename from wise-webapp/src/main/webapp/jsp/toolbar.jsp rename to wise-webapp/src/main/webapp/jsp/toolbar.jsf