From 51be944ccaa6b9ad8f9f239d5821ddbf90190edc Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Sat, 30 Jul 2011 05:22:57 -0300 Subject: [PATCH] Mindplot don't need to be compiled. --- core-js/src/main/javascript/Loader.js | 86 ------ core-js/src/main/javascript/Utils.js | 9 +- mindplot/pom.xml | 3 - mindplot/src/main/javascript/ActionIcon.js | 2 +- mindplot/src/main/javascript/CentralTopic.js | 2 +- mindplot/src/main/javascript/MainTopic.js | 2 +- mindplot/src/main/javascript/Note.js | 2 +- .../src/main/javascript/RelationshipLine.js | 11 +- mindplot/src/main/javascript/TextEditor.js | 1 - mindplot/src/main/javascript/Topic.js | 3 +- mindplot/src/main/javascript/TopicBoard.js | 53 ---- mindplot/src/main/javascript/footer.js | 5 - wise-doc/src/main/webapp/html/editor.html | 6 +- wise-doc/src/main/webapp/js/editor.js | 72 ++++- wise-doc/src/main/webapp/js/jsapi.nocache.js | 16 ++ .../webapp/js/mootools-more-1.3.2.1-yui.js | 36 ++- wise-webapp/src/main/webapp/js/editor.js | 270 +++++++----------- wise-webapp/src/main/webapp/js/embedded.js | 54 ++-- 18 files changed, 257 insertions(+), 376 deletions(-) delete mode 100644 core-js/src/main/javascript/Loader.js delete mode 100644 mindplot/src/main/javascript/TopicBoard.js create mode 100644 wise-doc/src/main/webapp/js/jsapi.nocache.js diff --git a/core-js/src/main/javascript/Loader.js b/core-js/src/main/javascript/Loader.js deleted file mode 100644 index 446cc826..00000000 --- a/core-js/src/main/javascript/Loader.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -* 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. -*/ - -core.Loader = -{ - load: function(scriptPath, stylePath,jsFileName) - { - var headElement = document.getElementsByTagName('head'); - var htmlDoc = headElement.item(0); - var baseUrl = this.baseUrl(jsFileName); - if (scriptPath && scriptPath.length > 0) - { - for (var i = 0; i < scriptPath.length; i++) - { - this.includeScriptNode(baseUrl + scriptPath[i]); - } - } - if (stylePath && stylePath.length > 0) - { - for (var i = 0; i < stylePath.length; i++) - { - this.includeStyleNode(baseUrl + stylePath[i]); - } - } - }, - baseUrl: function(jsFileName) - { - var headElement = document.getElementsByTagName('head'); - var htmlDoc = headElement.item(0); - var headChildren = htmlDoc.childNodes; - var result = null; - for (var i = 0; i < headChildren.length; i++) - { - var node = headChildren.item(i); - if (node.nodeName && node.nodeName.toLowerCase() == "script") - { - var libraryUrl = node.src; - if (libraryUrl.indexOf(jsFileName) != -1) - { - var index = libraryUrl.lastIndexOf("/"); - index = libraryUrl.lastIndexOf("/", index - 1); - result = libraryUrl.substring(0, index); - } - } - } - - if (result == null) - { - throw "Could not obtain the base url directory."; - } - return result; - }, - includeScriptNode: function(filename) { - var html_doc = document.getElementsByTagName('head').item(0); - var js = document.createElement('script'); - js.setAttribute('language', 'javascript'); - js.setAttribute('type', 'text/javascript'); - js.setAttribute('src', filename); - html_doc.appendChild(js); - return false; - }, - includeStyleNode: function(filename) { - var html_doc = document.getElementsByTagName('head').item(0); - var js = document.createElement('link'); - js.setAttribute('rel', 'stylesheet'); - js.setAttribute('type', 'text/css'); - js.setAttribute('href', filename); - html_doc.appendChild(js); - return false; - } -}; diff --git a/core-js/src/main/javascript/Utils.js b/core-js/src/main/javascript/Utils.js index c6c369c2..56567599 100644 --- a/core-js/src/main/javascript/Utils.js +++ b/core-js/src/main/javascript/Utils.js @@ -78,14 +78,6 @@ Math.sign = function(value) { }; -// Extensions .... -function $import(src) { - var scriptElem = document.createElement('script'); - scriptElem.setAttribute('src', src); - scriptElem.setAttribute('type', 'text/javascript'); - document.getElementsByTagName('head')[0].appendChild(scriptElem); -} - /** * Retrieve the mouse position. */ @@ -274,6 +266,7 @@ core.Utils.calculateDefaultControlPoints = function(srcPos, tarPos) { core.Utils.setVisibilityAnimated = function(elems, isVisible, doneFn) { core.Utils.animateVisibility(elems, isVisible, doneFn); }; + core.Utils.setChildrenVisibilityAnimated = function(rootElem, isVisible) { var children = core.Utils._addInnerChildrens(rootElem); core.Utils.animateVisibility(children, isVisible); diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 188b0503..17e5f4b5 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -67,7 +67,6 @@ - @@ -154,8 +153,6 @@ files="layout/FreeMindLayoutManager.js"/> - - diff --git a/mindplot/src/main/javascript/ActionIcon.js b/mindplot/src/main/javascript/ActionIcon.js index c262fadc..ff8261ec 100644 --- a/mindplot/src/main/javascript/ActionIcon.js +++ b/mindplot/src/main/javascript/ActionIcon.js @@ -19,7 +19,7 @@ mindplot.ActionIcon = new Class({ Extends:mindplot.Icon, initialize: function(topic, url) { - mindplot.Icon.call(this, url); + this.parent(url); this._node = topic; }, getNode:function() { diff --git a/mindplot/src/main/javascript/CentralTopic.js b/mindplot/src/main/javascript/CentralTopic.js index 22222d1e..035e10d4 100644 --- a/mindplot/src/main/javascript/CentralTopic.js +++ b/mindplot/src/main/javascript/CentralTopic.js @@ -33,7 +33,7 @@ mindplot.CentralTopic = new Class({ setCursor : function(type) { type = (type == 'move') ? 'default' : type; - mindplot.Topic.prototype.setCursor.call(this, type); + this.parent(type); }, isConnectedToCentralTopic : function() { diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index 87fce720..2e335b22 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -119,7 +119,7 @@ mindplot.MainTopic = new Class({ }, disconnect : function(workspace) { - mindplot.Topic.prototype.disconnect.call(this, workspace); + this.parent(workspace); var size = this.getSize(); var model = this.getModel(); diff --git a/mindplot/src/main/javascript/Note.js b/mindplot/src/main/javascript/Note.js index 52979339..c7c783f4 100644 --- a/mindplot/src/main/javascript/Note.js +++ b/mindplot/src/main/javascript/Note.js @@ -21,7 +21,7 @@ mindplot.Note = new Class({ initialize : function(textModel, topic, designer) { var divContainer = designer.getWorkSpace().getScreenManager().getContainer(); var bubbleTip = mindplot.BubbleTip.getInstance(divContainer); - mindplot.Icon.call(this, mindplot.Note.IMAGE_URL); + this.parent(mindplot.Note.IMAGE_URL); this._noteModel = textModel; this._topic = topic; this._designer = designer; diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 44f70861..5c50c08a 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -45,8 +45,7 @@ mindplot.RelationshipLine = new Class({ }, setStroke : function(color, style, opacity) { - // @Todo: How this is supported in mootools ? - mindplot.ConnectionLine.prototype.setStroke.call(this, color, style, opacity); + this.parent(color, style, opacity); this._startArrow.setStrokeColor(color); }, @@ -126,7 +125,7 @@ mindplot.RelationshipLine = new Class({ workspace.appendChild(this._startArrow); workspace.appendChild(this._endArrow); - mindplot.ConnectionLine.prototype.addToWorkspace.call(this, workspace); + this.parent(workspace); }, _initializeControlPointController : function(event, workspace) { @@ -141,7 +140,7 @@ mindplot.RelationshipLine = new Class({ workspace.removeChild(this._startArrow); workspace.removeChild(this._endArrow); - mindplot.ConnectionLine.prototype.removeFromWorkspace.call(this, workspace); + this.parent(workspace); }, getType : function() { @@ -195,13 +194,13 @@ mindplot.RelationshipLine = new Class({ }, setVisibility : function(value) { - mindplot.ConnectionLine.prototype.setVisibility.call(this, value); + this.parent(value); this._endArrow.setVisibility(this._showEndArrow && value); this._startArrow.setVisibility(this._showStartArrow && value); }, setOpacity : function(opacity) { - mindplot.ConnectionLine.prototype.setOpacity.call(this, opacity); + this.parent(opacity); if (this._showEndArrow) this._endArrow.setOpacity(opacity); if (this._showStartArrow) diff --git a/mindplot/src/main/javascript/TextEditor.js b/mindplot/src/main/javascript/TextEditor.js index 7a4b538f..af05a0f8 100644 --- a/mindplot/src/main/javascript/TextEditor.js +++ b/mindplot/src/main/javascript/TextEditor.js @@ -221,7 +221,6 @@ mindplot.TextEditor = new Class({ }; setTimeout(executor(this), 10); - //console.log('init done'); }, setStyle : function (fontStyle) { diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 07e18c1a..5c84de08 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -1013,7 +1013,6 @@ mindplot.Topic = new Class({ var outerShape = this.getOuterShape(); var innerShape = this.getInnerShape(); - var connector = this.getShrinkConnector(); outerShape.setSize(size.width + 4, size.height + 6); innerShape.setSize(size.width, size.height); @@ -1177,7 +1176,7 @@ mindplot.Topic = new Class({ }, createDragNode : function() { - var dragNode = mindplot.NodeGraph.prototype.createDragNode.call(this); + this.parent(); // Is the node already connected ? var targetTopic = this.getOutgoingConnectedTopic(); diff --git a/mindplot/src/main/javascript/TopicBoard.js b/mindplot/src/main/javascript/TopicBoard.js deleted file mode 100644 index b7790479..00000000 --- a/mindplot/src/main/javascript/TopicBoard.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ - -//@Todo: Por que lo cambiaste a Board ? -mindplot.TopicBoard = new Class({ - - initialize: function() { - this._height = null; - }, - - _removeEntryByOrder : function(order, position) { - var board = this._getBoard(position); - var entry = board.lookupEntryByOrder(order); - - $assert(!entry.isAvailable(), 'Entry must not be available in order to be removed.Entry Order:' + order); - entry.removeTopic(); - board.update(entry); - }, - - removeTopicFromBoard : function(topic) { - var position = topic.getPosition(); - var order = topic.getOrder(); - - this._removeEntryByOrder(order, position); - topic.setOrder(null); - }, - - positionateDragTopic :function(dragTopic) { - throw "this method must be overrided"; - }, - - getHeight: function() { - var board = this._getBoard(); - return board.getHeight(); - } - } -); - diff --git a/mindplot/src/main/javascript/footer.js b/mindplot/src/main/javascript/footer.js index 300c8aa3..b6de234d 100644 --- a/mindplot/src/main/javascript/footer.js +++ b/mindplot/src/main/javascript/footer.js @@ -15,8 +15,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -if($defined(afterMindpotLibraryLoading)) -{ - afterMindpotLibraryLoading(); -} diff --git a/wise-doc/src/main/webapp/html/editor.html b/wise-doc/src/main/webapp/html/editor.html index 90c69c77..c1e260e4 100644 --- a/wise-doc/src/main/webapp/html/editor.html +++ b/wise-doc/src/main/webapp/html/editor.html @@ -23,8 +23,6 @@ - - @@ -68,11 +66,11 @@ return false; }); - + // @Todo: This must be persited in the map properties ... var mapId = '1'; var mapXml = ''; - // @Todo: This must be persiste in the map properties ... + var editorProperties = {zoom:0.85,saveOnLoad:true}; function printMap() { diff --git a/wise-doc/src/main/webapp/js/editor.js b/wise-doc/src/main/webapp/js/editor.js index 15904ebe..b07f848f 100644 --- a/wise-doc/src/main/webapp/js/editor.js +++ b/wise-doc/src/main/webapp/js/editor.js @@ -16,9 +16,6 @@ * limitations under the License. */ - -$import("../../../../../mindplot/target/classes/mindplot.svg.js"); - var designer = null; // CSS helper functions @@ -370,7 +367,6 @@ function buildIconChooser() { } - function setCurrentColorPicker(colorPicker) { this.currentColorPicker = colorPicker; } @@ -529,4 +525,72 @@ function buildPanel(buttonElemId, elemLinksContainer, elemLinkIds, updateFunctio var elementId = elemLinkIds[i]; $(elementId).addEvent('click', fontOnClick.bind($(elementId))); } +} + +//######################### Libraries Loading ################################## +function JSPomLoader(pomUrl, callback) { + console.log("POM Load URL:" + pomUrl); + var jsUrls; + var request = new Request({ + url: pomUrl, + method: 'get', + onRequest: function() { + console.log("loading ..."); + }, + onSuccess: function(responseText, responseXML) { + + // Collect JS Urls ... + var concatRoot = responseXML.getElementsByTagName('concat'); + var fileSetArray = Array.filter(concatRoot[0].childNodes, function(elem) { + return elem.nodeType == Node.ELEMENT_NODE + }); + + jsUrls = new Array(); + Array.each(fileSetArray, function(elem) { + var jsUrl = elem.getAttribute("dir") + elem.getAttribute("files"); + jsUrls.push(jsUrl.replace("${basedir}", pomUrl.substring(0, pomUrl.lastIndexOf('/')))); + } + ); + + // Load all JS dynamically .... + jsUrls = jsUrls.reverse(); + + function jsRecLoad(urls) { + if (urls.length == 0) { + if ($defined(callback)) + callback(); + } else { + var url = urls.pop(); + console.log("load url:" + url); + Asset.javascript(url, { + onLoad: function() { + jsRecLoad(urls) + } + }); + } + } + + jsRecLoad(jsUrls); + }, + onFailure: function() { + console.log('Sorry, your request failed :('); + } + }); + request.send(); + +} + +var localEnv = true; +if (localEnv) { + Asset.javascript("../../../../../web2d/target/classes/web2d.svg-min.js", { + onLoad: function() { + JSPomLoader('../../../../../mindplot/pom.xml', afterMindpotLibraryLoading) + } + }); +} else { + Asset.javascript("../js/mindplot.svg.js", { + onLoad: function() { + afterMindpotLibraryLoading(); + } + }); } \ No newline at end of file diff --git a/wise-doc/src/main/webapp/js/jsapi.nocache.js b/wise-doc/src/main/webapp/js/jsapi.nocache.js new file mode 100644 index 00000000..3e21827b --- /dev/null +++ b/wise-doc/src/main/webapp/js/jsapi.nocache.js @@ -0,0 +1,16 @@ +function jsapi(){var L='',ec='\n-',sb='" for "gwt:onLoadErrorFn"',qb='" for "gwt:onPropertyErrorFn"',Tb='"