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 9f81212b..e340a744 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -55,6 +55,9 @@ + + + @@ -67,7 +70,6 @@ - @@ -171,6 +173,18 @@ files="collaboration/frameworks/brix/BrixFramework.js"/> + + + + + + diff --git a/mindplot/src/main/javascript/ActionDispatcher.js b/mindplot/src/main/javascript/ActionDispatcher.js new file mode 100644 index 00000000..ecf15e99 --- /dev/null +++ b/mindplot/src/main/javascript/ActionDispatcher.js @@ -0,0 +1,116 @@ +/* + * 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. + */ + +//noinspection JSUnusedLocalSymbols +mindplot.ActionDispatcher = new Class({ + Implements:[Events], + initialize: function(commandContext) { + $assert(commandContext, "commandContext can not be null"); + }, + + addIconToTopic: function(topicId, iconType) { + throw "method must be implemented."; + }, + + addLinkToTopic: function(topicId, url) { + throw "method must be implemented."; + }, + + addNoteToTopic: function(topicId, text) { + throw "method must be implemented."; + }, + + addRelationship: function(model, mindmap) { + throw "method must be implemented."; + }, + + addTopic: function(model, parentTopicId, animated) { + throw "method must be implemented."; + }, + + deleteTopics: function(topicsIds) { + throw "method must be implemented."; + }, + + dragTopic: function(topicId, position, order, parentTopic) { + throw "method must be implemented."; + }, + + moveControlPoint: function(ctrlPoint, point) { + throw "method must be implemented."; + }, + + removeIconFromTopic: function(topicId, iconModel) { + throw "method must be implemented."; + }, + + removeLinkFromTopic: function(topicId) { + throw "method must be implemented."; + }, + + removeNoteFromTopic: function(topicId) { + throw "method must be implemented."; + }, + + changeFontFamilyToTopic: function(topicIds, fontFamily) { + throw "method must be implemented."; + }, + + changeFontStyleToTopic: function(topicsIds) { + throw "method must be implemented."; + }, + + changeFontColorToTopic: function(topicsIds, color) { + throw "method must be implemented."; + }, + + changeBackgroundColorToTopic: function(topicsIds, color) { + throw "method must be implemented."; + }, + + changeBorderColorToTopic: function(topicsIds, color) { + throw "method must be implemented."; + }, + + changeShapeToTopic : function(topicsIds, shapeType) { + throw "method must be implemented."; + }, + + changeFontWeightToTopic : function(topicsIds) { + throw "method must be implemented."; + }, + + changeTextOnTopic : function(topicsIds, text) { + throw "method must be implemented."; + }, + + shrinkBranch : function(topicsIds, collapse) + { + throw "method must be implemented."; + } + +}); + +mindplot.ActionDispatcher.setInstance = function(dispatcher) { + mindplot.ActionDispatcher._instance = dispatcher; +}; + +mindplot.ActionDispatcher.getInstance = function() { + return mindplot.ActionDispatcher._instance; +}; + 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/BaseCommandDispatcher.js b/mindplot/src/main/javascript/BaseCommandDispatcher.js deleted file mode 100644 index 95c62904..00000000 --- a/mindplot/src/main/javascript/BaseCommandDispatcher.js +++ /dev/null @@ -1,51 +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. - */ - -mindplot.BaseCommandDispatcher = new Class({ - - initialize: function() { - }, - addIconToTopic: function() { - throw "method must be implemented."; - }, - addLinkToTopic: function() { - throw "method must be implemented."; - }, - addNoteToTopic: function() { - throw "method must be implemented."; - },addRelationship: function() { - throw "method must be implemented."; - },addTopic: function() { - throw "method must be implemented."; - },changeIcon: function() { - throw "method must be implemented."; - },deleteTopic: function() { - throw "method must be implemented."; - },dragTopic: function() { - throw "method must be implemented."; - },moveControllPoint: function() { - throw "method must be implemented."; - } ,removeIconFromTopic: function() { - throw "method must be implemented."; - },removeLinkFromTopic: function() { - throw "method must be implemented."; - },removeNodeFromTopic: function() { - throw "method must be implemented."; - } -}); - diff --git a/mindplot/src/main/javascript/BrixActionDispatcher.js b/mindplot/src/main/javascript/BrixActionDispatcher.js new file mode 100644 index 00000000..13745be0 --- /dev/null +++ b/mindplot/src/main/javascript/BrixActionDispatcher.js @@ -0,0 +1,25 @@ +/* + * 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. + */ + +mindplot.BrixActionDispatcher = new Class({ + Extends: mindplot.ActionDispatcher, + initialize: function(commandContext, fireOnChange) { + this.parent(commandContext, fireOnChange); + } +}); + diff --git a/mindplot/src/main/javascript/CentralTopic.js b/mindplot/src/main/javascript/CentralTopic.js index fa75f00e..6534a9e4 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/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js index cf8c4c2b..59214bee 100644 --- a/mindplot/src/main/javascript/ControlPoint.js +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -113,8 +113,10 @@ mindplot.ControlPoint = new Class({ _mouseUp : function(event, point) { this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction); this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction); - var command = new mindplot.commands.MoveControlPointCommand(this, point); - designer._actionRunner.execute(command); //todo:Uggly!! designer is global!! + + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.moveControlPoint(this, point); + this._isBinded = false; /*event.preventDefault(); event.stop(); diff --git a/mindplot/src/main/javascript/DesignerActionRunner.js b/mindplot/src/main/javascript/DesignerActionRunner.js index 4c88498c..18881bb9 100644 --- a/mindplot/src/main/javascript/DesignerActionRunner.js +++ b/mindplot/src/main/javascript/DesignerActionRunner.js @@ -17,40 +17,34 @@ */ mindplot.DesignerActionRunner = new Class({ - initialize: function(designer) { - this._designer = designer; + initialize: function(commandContext, notifier) { + $assert(commandContext, "commandContext can not be null"); + this._undoManager = new mindplot.DesignerUndoManager(); - this._context = new mindplot.CommandContext(this._designer); + this._context = commandContext; + this._notifier = notifier; }, execute:function(command) { $assert(command, "command can not be null"); - // Execute action ... command.execute(this._context); - - // Enqueue it ... this._undoManager.enqueue(command); - - // Fire event - var event = this._undoManager._buildEvent(); - this._designer._fireEvent("change", event); + this.fireChangeEvent(); }, undo: function() { this._undoManager.execUndo(this._context); - - // Fire event - var event = this._undoManager._buildEvent(); - this._designer._fireEvent("change", event); + this.fireChangeEvent(); }, redo: function() { this._undoManager.execRedo(this._context); + this.fireChangeEvent(); + }, - // Fire event - var event = this._undoManager._buildEvent(); - this._designer._fireEvent("change", event); - + fireChangeEvent : function () { + var event = this._undoManager.buildEvent(); + this._notifier.fireEvent("modelUpdate", event); }, markAsChangeBase: function() { @@ -60,75 +54,3 @@ mindplot.DesignerActionRunner = new Class({ return this._undoManager.hasBeenChanged(); } }); - -mindplot.CommandContext = new Class({ - initialize: function(designer) { - this._designer = designer; - }, - findTopics:function(topicsIds) { - var designerTopics = this._designer._topics; - if (!(topicsIds instanceof Array)) { - topicsIds = [topicsIds]; - } - - var result = designerTopics.filter(function(topic) { - var found = false; - if (topic != null) { - var topicId = topic.getId(); - found = topicsIds.contains(topicId); - } - return found; - - }); - return result; - }, - deleteTopic:function(topic) { - this._designer._removeNode(topic); - }, - createTopic:function(model, isVisible) { - $assert(model, "model can not be null"); - var topic = this._designer._nodeModelToNodeGraph(model, isVisible); - - return topic; - }, - createModel:function() { - var mindmap = this._designer.getMindmap(); - var model = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE); - return model; - }, - connect:function(childTopic, parentTopic, isVisible) { - childTopic.connectTo(parentTopic, this._designer._workspace, isVisible); - } , - disconnect:function(topic) { - topic.disconnect(this._designer._workspace); - }, - createRelationship:function(model) { - $assert(model, "model cannot be null"); - var relationship = this._designer.createRelationship(model); - return relationship; - }, - removeRelationship:function(model) { - this._designer.removeRelationship(model); - }, - findRelationships:function(lineIds) { - var result = []; - lineIds.forEach(function(lineId, index) { - var line = this._designer._relationships[lineId]; - if ($defined(line)) { - result.push(line); - } - }.bind(this)); - return result; - }, - getSelectedRelationshipLines:function() { - return this._designer.getSelectedRelationshipLines(); - } -}); - -mindplot.DesignerActionRunner.setInstance = function(actionRunner) { - mindplot.DesignerActionRunner._instance = actionRunner; -}; - -mindplot.DesignerActionRunner.getInstance = function() { - return mindplot.DesignerActionRunner._instance; -}; diff --git a/mindplot/src/main/javascript/DesignerUndoManager.js b/mindplot/src/main/javascript/DesignerUndoManager.js index 91205e12..48bf215b 100644 --- a/mindplot/src/main/javascript/DesignerUndoManager.js +++ b/mindplot/src/main/javascript/DesignerUndoManager.js @@ -17,10 +17,12 @@ */ mindplot.DesignerUndoManager = new Class({ - initialize: function() { + initialize: function(fireChange) { this._undoQueue = []; this._redoQueue = []; this._baseId = 0; + this._fireChange = fireChange; + }, enqueue:function(command) { @@ -55,7 +57,7 @@ mindplot.DesignerUndoManager = new Class({ } }, - _buildEvent: function() { + buildEvent: function() { return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length}; }, diff --git a/mindplot/src/main/javascript/DragPivot.js b/mindplot/src/main/javascript/DragPivot.js index 4debdb2d..95867d38 100644 --- a/mindplot/src/main/javascript/DragPivot.js +++ b/mindplot/src/main/javascript/DragPivot.js @@ -201,8 +201,11 @@ mindplot.DragPivot = new Class({ // Connected to Rect ... var connectRect = this._connectRect; var targetSize = targetTopic.getSize(); - var width = targetSize.width; - var height = targetSize.height; + + // Add 4 pixel in order to keep create a rect bigger than the topic. + var width = targetSize.width + 4; + var height = targetSize.height + 4; + connectRect.setSize(width, height); var targetPosition = targetTopic.getPosition(); diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js index fc38eaf0..dadae382 100644 --- a/mindplot/src/main/javascript/DragTopic.js +++ b/mindplot/src/main/javascript/DragTopic.js @@ -1,239 +1,203 @@ /* -* 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. -*/ + * 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. + */ -mindplot.DragTopic = function(dragShape, draggedNode) -{ - $assert(dragShape, 'Rect can not be null.'); - $assert(draggedNode, 'draggedNode can not be null.'); +mindplot.DragTopic = new Class({ + initialize:function(dragShape, draggedNode) { + $assert(dragShape, 'Rect can not be null.'); + $assert(draggedNode, 'draggedNode can not be null.'); - this._elem2d = dragShape; - this._order = null; - this._draggedNode = draggedNode; - this._position = new core.Point(); -}; + this._elem2d = dragShape; + this._order = null; + this._draggedNode = draggedNode; + this._position = new core.Point(); + }, -mindplot.DragTopic.initialize = function(workspace) -{ + setOrder : function(order) { + this._order = order; + }, + + setPosition : function(x, y) { + this._position.setValue(x, y); + + // Elements are positioned in the center. + // All topic element must be positioned based on the innerShape. + var draggedNode = this._draggedNode; + var size = draggedNode.getSize(); + + var cx = Math.ceil(x - (size.width / 2)); + var cy = Math.ceil(y - (size.height / 2)); + + // Update visual position. + this._elem2d.setPosition(cx, cy); + }, + + getInnerShape : function() { + return this._elem2d; + }, + + disconnect : function(workspace) { + // Clear connection line ... + var dragPivot = this._getDragPivot(); + dragPivot.disconnect(workspace); + }, + + canBeConnectedTo : function(targetTopic) { + $assert(targetTopic, 'parent can not be null'); + + var result = true; + if (!targetTopic.areChildrenShrinked() && !targetTopic.isCollapsed()) { + // Dragged node can not be connected to himself. + if (targetTopic == this._draggedNode) { + result = false; + } else { + var draggedNode = this.getDraggedTopic(); + var topicPosition = this.getPosition(); + + var targetTopicModel = targetTopic.getModel(); + var childTopicModel = draggedNode.getModel(); + + result = targetTopicModel.canBeConnected(childTopicModel, topicPosition, 18); + } + } else { + result = false; + } + return result; + }, + + connectTo : function(parent) { + $assert(parent, 'Parent connection node can not be null.'); + + var dragPivot = this._getDragPivot(); + dragPivot.connectTo(parent); + }, + + getDraggedTopic : function() { + return this._draggedNode; + }, + + + removeFromWorkspace : function(workspace) { + // Remove drag shadow. + workspace.removeChild(this._elem2d); + + // Remove pivot shape. To improve performace it will not be removed. Only the visilility will be changed. + var dragPivot = this._getDragPivot(); + dragPivot.setVisibility(false); + }, + + addToWorkspace : function(workspace) { + workspace.appendChild(this._elem2d); + var dragPivot = this._getDragPivot(); + + dragPivot.addToWorkspace(workspace); + dragPivot.setVisibility(true); + }, + + _getDragPivot : function() { + return mindplot.DragTopic.__getDragPivot(); + }, + + getPosition:function() { + return this._position; + } + , + + isDragTopic : function() { + return true; + }, + + updateDraggedTopic : function(workspace) { + $assert(workspace, 'workspace can not be null'); + + var dragPivot = this._getDragPivot(); + var draggedTopic = this.getDraggedTopic(); + + var isDragConnected = this.isConnected(); + // @Todo: Remove this static ... + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + var topicId = draggedTopic.getId(); + + if (isDragConnected) { + + var targetTopic = this.getConnectedToTopic(); + if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { + // Update topic position ... + var dragPivotPosition = dragPivot.getPosition(); + + // Must position the dragged topic taking into account the current node size. + var pivotSize = dragPivot.getSize(); + var draggedTopicSize = draggedTopic.getSize(); + var xOffset = draggedTopicSize.width - pivotSize.width; + xOffset = Math.round(xOffset / 2); + + if (dragPivotPosition.x > 0) { + dragPivotPosition.x = parseInt(dragPivotPosition.x) + xOffset; + } + else { + dragPivotPosition.x = parseInt(dragPivotPosition.x) - xOffset; + } + // Set new position ... + actionDispatcher.dragTopic(topicId, dragPivotPosition, null, targetTopic); + + } else { + // Main topic connections can be positioned only with the order ... + actionDispatcher.dragTopic(topicId, null, this._order, targetTopic); + } + } else { + + // If the node is not connected, positionate based on the original drag topic position. + var dragPosition = this.getPosition(); + actionDispatcher.dragTopic(topicId, dragPosition); + } + }, + + setBoardPosition : function(point) { + $assert(point, 'point can not be null'); + var dragPivot = this._getDragPivot(); + dragPivot.setPosition(point); + }, + + getConnectedToTopic : function() { + var dragPivot = this._getDragPivot(); + return dragPivot.getTargetTopic(); + }, + + isConnected : function() { + return this.getConnectedToTopic() != null; + } + +}); + +mindplot.DragTopic.PIVOT_SIZE = {width:50,height:10}; + +mindplot.DragTopic.init = function(workspace) { + + $assert(workspace, "workspace can not be null"); var pivot = mindplot.DragTopic.__getDragPivot(); workspace.appendChild(pivot); -}; +} -mindplot.DragTopic.prototype.setOrder = function(order) -{ - this._order = order; -}; - -mindplot.DragTopic.prototype.setPosition = function(x, y) -{ - this._position.setValue(x, y); - - // Elements are positioned in the center. - // All topic element must be positioned based on the innerShape. - var draggedNode = this._draggedNode; - var size = draggedNode.getSize(); - - var cx = Math.ceil(x - (size.width / 2)); - var cy = Math.ceil(y - (size.height / 2)); - - // Update visual position. - this._elem2d.setPosition(cx, cy); -}; - -mindplot.DragTopic.prototype.getInnerShape = function() -{ - return this._elem2d; -}; - -mindplot.DragTopic.prototype.disconnect = function(workspace) -{ - // Clear connection line ... - var dragPivot = this._getDragPivot(); - dragPivot.disconnect(workspace); -}; - -mindplot.DragTopic.prototype.canBeConnectedTo = function(targetTopic) -{ - $assert(targetTopic, 'parent can not be null'); - - var result = true; - if (!targetTopic.areChildrenShrinked() && !targetTopic.isCollapsed()) - { - // Dragged node can not be connected to himself. - if (targetTopic == this._draggedNode) - { - result = false; - } else - { - var draggedNode = this.getDraggedTopic(); - var topicPosition = this.getPosition(); - - var targetTopicModel = targetTopic.getModel(); - var childTopicModel = draggedNode.getModel(); - - result = targetTopicModel.canBeConnected(childTopicModel, topicPosition, 18); - } - } else - { - result = false; - } - return result; -}; - -mindplot.DragTopic.prototype.connectTo = function(parent) -{ - $assert(parent, 'Parent connection node can not be null.'); - - var dragPivot = this._getDragPivot(); - dragPivot.connectTo(parent); -}; - -mindplot.DragTopic.prototype.getDraggedTopic = function() -{ - return this._draggedNode; -}; - - -mindplot.DragTopic.prototype.removeFromWorkspace = function(workspace) -{ - // Remove drag shadow. - workspace.removeChild(this._elem2d); - - // Remove pivot shape. To improve performace it will not be removed. Only the visilility will be changed. - var dragPivot = this._getDragPivot(); - dragPivot.setVisibility(false); -}; - -mindplot.DragTopic.prototype.addToWorkspace = function(workspace) -{ - workspace.appendChild(this._elem2d); - var dragPivot = this._getDragPivot(); - - dragPivot.addToWorkspace(workspace); - dragPivot.setVisibility(true); -}; - -mindplot.DragTopic.prototype._getDragPivot = function() -{ - return mindplot.DragTopic.__getDragPivot(); -}; - -mindplot.DragTopic.__getDragPivot = function() -{ +mindplot.DragTopic.__getDragPivot = function() { var result = mindplot.DragTopic._dragPivot; - if (!$defined(result)) - { + if (!$defined(result)) { result = new mindplot.DragPivot(); mindplot.DragTopic._dragPivot = result; } return result; -}; - - -mindplot.DragTopic.prototype.getPosition = function() -{ - return this._position; -}; - -mindplot.DragTopic.prototype.isDragTopic = function() -{ - return true; -}; - -mindplot.DragTopic.prototype.updateDraggedTopic = function(workspace) -{ - $assert(workspace, 'workspace can not be null'); - - var dragPivot = this._getDragPivot(); - var draggedTopic = this.getDraggedTopic(); - - var isDragConnected = this.isConnected(); - var actionRunner = mindplot.DesignerActionRunner.getInstance(); - var topicId = draggedTopic.getId(); - var command = new mindplot.commands.DragTopicCommand(topicId); - - if (isDragConnected) - { - - var targetTopic = this.getConnectedToTopic(); - if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) - { - // Update topic position ... - var dragPivotPosition = dragPivot.getPosition(); - - // Must position the dragged topic taking into account the current node size. - var pivotSize = dragPivot.getSize(); - var draggedTopicSize = draggedTopic.getSize(); - var xOffset = draggedTopicSize.width - pivotSize.width; - xOffset = Math.round(xOffset / 2); - - if (dragPivotPosition.x > 0) - { - dragPivotPosition.x = parseInt(dragPivotPosition.x) + xOffset; - } - else - { - dragPivotPosition.x = parseInt(dragPivotPosition.x) - xOffset; - } - // Set new position ... - command.setPosition(dragPivotPosition); - - } else - { - // Main topic connections can be positioned only with the order ... - command.setOrder(this._order); - } - - // Set new parent topic .. - command.setParetTopic(targetTopic); - } else { - - // If the node is not connected, positionate based on the original drag topic position. - var dragPosition = this.getPosition(); - command = new mindplot.commands.DragTopicCommand(topicId, dragPosition); - command.setPosition(dragPosition); - } - actionRunner.execute(command); -}; - -mindplot.DragTopic.prototype.setBoardPosition = function(point) -{ - $assert(point, 'point can not be null'); - var dragPivot = this._getDragPivot(); - dragPivot.setPosition(point); -}; - - -mindplot.DragTopic.prototype.getBoardPosition = function(point) -{ - $assert(point, 'point can not be null'); - var dragPivot = this._getDragPivot(); - return dragPivot.getPosition(); -}; - -mindplot.DragTopic.prototype.getConnectedToTopic = function() -{ - var dragPivot = this._getDragPivot(); - return dragPivot.getTargetTopic(); -}; - -mindplot.DragTopic.prototype.isConnected = function() -{ - return this.getConnectedToTopic() != null; -}; - -mindplot.DragTopic.PIVOT_SIZE = {width:50,height:10}; +} + diff --git a/mindplot/src/main/javascript/DragTopicPositioner.js b/mindplot/src/main/javascript/DragTopicPositioner.js index a8478556..1a4deafc 100644 --- a/mindplot/src/main/javascript/DragTopicPositioner.js +++ b/mindplot/src/main/javascript/DragTopicPositioner.js @@ -71,7 +71,8 @@ mindplot.DragTopicPositioner = new Class({ // Finally, connect nodes ... if (!dragTopic.isConnected()) { var centalTopic = topics[0]; - if ($defined(mainTopicToMainTopicConnection)) { + if ($defined(mainTopicToMainTopicConnection)) + { dragTopic.connectTo(mainTopicToMainTopicConnection); } else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) { dragTopic.connectTo(centalTopic); @@ -82,7 +83,6 @@ mindplot.DragTopicPositioner = new Class({ _lookUpForMainTopicToMainTopicConnection : function(dragTopic) { var topics = this._topics; var result = null; - var clouserDistance = -1; var draggedNode = dragTopic.getDraggedTopic(); var distance = null; diff --git a/mindplot/src/main/javascript/IconGroup.js b/mindplot/src/main/javascript/IconGroup.js index d6c265e6..8f4c6065 100644 --- a/mindplot/src/main/javascript/IconGroup.js +++ b/mindplot/src/main/javascript/IconGroup.js @@ -55,9 +55,12 @@ mindplot.IconGroup = new Class({ }, addIcon : function(icon) { + $defined(icon,"icon is not defined"); icon.setGroup(this); + var newIcon = icon.getImage(); var nativeElem = this.options.nativeElem; + var iconSize = newIcon.getSize(); var size = nativeElem.getSize(); newIcon.setPosition(size.width, 0); @@ -186,8 +189,10 @@ mindplot.IconGroup = new Class({ _calculateOffsets : function() { var offset = this.options.topic.getOffset(); var text = this.options.topic.getTextShape(); + var sizeHeight = text.getHtmlFontSize(); var yOffset = offset; + var shape = this.options.topic.getShapeType(); yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1; return {x:offset, y:yOffset}; diff --git a/mindplot/src/main/javascript/ImageIcon.js b/mindplot/src/main/javascript/ImageIcon.js index 695f924e..e5ceb605 100644 --- a/mindplot/src/main/javascript/ImageIcon.js +++ b/mindplot/src/main/javascript/ImageIcon.js @@ -16,13 +16,13 @@ * limitations under the License. */ -mindplot.ImageIcon = new Class( - { +mindplot.ImageIcon = new Class({ Extends:mindplot.Icon, initialize:function(iconModel, topic, designer) { $assert(iconModel, 'iconModel can not be null'); $assert(topic, 'topic can not be null'); $assert(designer, 'designer can not be null'); + this._topic = topic; this._iconModel = iconModel; this._designer = designer; @@ -44,16 +44,16 @@ mindplot.ImageIcon = new Class( if (!$defined(designer._viewMode) || ($defined(designer._viewMode) && !designer._viewMode)) { - removeImage.addEvent('click', function(event) { - var actionRunner = designer._actionRunner; - var command = new mindplot.commands.RemoveIconFromTopicCommand(this._topic.getId(), iconModel); - actionRunner.execute(command); + removeImage.addEvent('click', function() { + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.removeIconFromTopic(this._topic.getId(), iconModel); tip.forceClose(); - }.bindWithEvent(this)); + }); //Icon var image = this.getImage(); - image.addEventListener('click', function(event) { + image.addEventListener('click', function() { + var iconType = iconModel.getIconType(); var newIconType = this._getNextFamilyIconId(iconType); iconModel.setIconType(newIconType); @@ -61,21 +61,16 @@ mindplot.ImageIcon = new Class( var imgUrl = this._getImageUrl(newIconType); this._image.setHref(imgUrl); - // // @Todo: Support revert of change icon ... - // var actionRunner = designer._actionRunner; - // var command = new mindplot.commands.ChangeIconFromTopicCommand(this._topic.getId()); - // this._actionRunner.execute(command); + }.bind(this)); - - }.bindWithEvent(this)); - - var imageIcon = this; image.addEventListener('mouseover', function(event) { - tip.open(event, container, imageIcon); - }); + tip.open(event, container, this); + }.bind(this)); + image.addEventListener('mouseout', function(event) { tip.close(event); }); + image.addEventListener('mousemove', function(event) { tip.updatePosition(event); }); @@ -83,7 +78,7 @@ mindplot.ImageIcon = new Class( } }, - _getImageUrl : function(iconId) { + _getImageUrl : function(iconId) { return "../icons/" + iconId + ".png"; }, @@ -99,7 +94,6 @@ mindplot.ImageIcon = new Class( var result = null; for (var i = 0; i < familyIcons.length && result == null; i++) { if (familyIcons[i] == iconId) { - var nextIconId; //Is last one? if (i == (familyIcons.length - 1)) { result = familyIcons[0]; @@ -164,7 +158,7 @@ mindplot.ImageIcon.prototype.ICON_FAMILIES = [ {"id": "bullet", "icons" : ["bullet_black","bullet_blue","bullet_green","bullet_orange","bullet_red","bullet_pink","bullet_purple"]}, {"id": "tag", "icons" : ["tag_blue","tag_green","tag_orange","tag_red","tag_pink","tag_yellow"]}, {"id": "object", "icons" : ["object_bell","object_clanbomber","object_key","object_pencil","object_phone","object_magnifier","object_clip","object_music","object_star","object_wizard","object_house","object_cake","object_camera","object_palette","object_rainbow"]} -] +]; diff --git a/mindplot/src/main/javascript/LinkIcon.js b/mindplot/src/main/javascript/LinkIcon.js index 3d6c38d2..29b34173 100644 --- a/mindplot/src/main/javascript/LinkIcon.js +++ b/mindplot/src/main/javascript/LinkIcon.js @@ -90,8 +90,9 @@ mindplot.LinkIcon = new Class({ removeBtn.setStyle("margin-left", "3px"); removeBtn.addEvent('click', function(event) { - var command = new mindplot.commands.RemoveLinkFromTopicCommand(this._topic.getId()); - designer._actionRunner.execute(command); + + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.removeLinkFromTopic(this._topic.getId()); bubbleTip.forceClose(); }.bindWithEvent(this)); @@ -148,7 +149,7 @@ mindplot.LinkIcon = new Class({ }); }, - getUrl : function() { + getUrl : function() { return this._url; }, diff --git a/mindplot/src/main/javascript/LocalActionDispatcher.js b/mindplot/src/main/javascript/LocalActionDispatcher.js new file mode 100644 index 00000000..b32b96da --- /dev/null +++ b/mindplot/src/main/javascript/LocalActionDispatcher.js @@ -0,0 +1,310 @@ +/* + * 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. + */ + +mindplot.LocalActionDispatcher = new Class({ + Extends: mindplot.ActionDispatcher, + initialize: function(commandContext) { + this.parent(commandContext); + this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this); + }, + + hasBeenChanged: function() { + // @todo: This don't seems to belong here. + this._actionRunner.hasBeenChanged(); + }, + + addIconToTopic: function(topicId, iconType) { + var command = new mindplot.commands.AddIconToTopicCommand(topicId, iconType); + this.execute(command); + }, + + addLinkToTopic: function(topicId, url) { + var command = new mindplot.commands.AddLinkToTopicCommand(topicId, url); + this.execute(command); + }, + + addTopic:function(model, parentTopicId, animated) { + var command = new mindplot.commands.AddTopicCommand(model, parentTopicId, animated); + this.execute(command); + }, + + addNoteToTopic: function(topicId, text) { + var command = new mindplot.commands.AddNoteToTopicCommand(topicId, text); + this.execute(command); + }, + + addRelationship: function(model, mindmap) { + var command = new mindplot.commands.AddRelationshipCommand(model, mindmap); + this.execute(command); + }, + + deleteTopics: function(topicsIds) { + var command = new mindplot.commands.DeleteTopicCommand(topicsIds); + this.execute(command); + }, + + dragTopic: function(topicId, position, order, parentTopic) { + var command = new mindplot.commands.DragTopicCommand(topicId, position, order, parentTopic); + this.execute(command); + }, + + moveControlPoint: function(ctrlPoint, point) { + var command = new mindplot.commands.MoveControlPointCommand(ctrlPoint, point); + this.execute(command); + }, + + removeIconFromTopic: function(topicId, iconModel) { + var command = new mindplot.commands.RemoveIconFromTopicCommand(topicId, iconModel); + this.execute(command); + }, + removeLinkFromTopic: function(topicId) { + var command = new mindplot.commands.RemoveLinkFromTopicCommand(topicId); + this.execute(command); + }, + + removeNoteFromTopic: function(topicId) { + var command = new mindplot.commands.RemoveNoteFromTopicCommand(topicId); + this.execute(command); + }, + changeFontStyleToTopic: function(topicsIds) { + + var commandFunc = function(topic) { + var result = topic.getFontStyle(); + var style = (result == "italic") ? "normal" : "italic"; + topic.setFontStyle(style, true); + return result; + }; + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds); + this._actionRunner.execute(command); + + }, + + changeTextOnTopic : function(topicsIds, text) { + $assert(topicsIds, "topicsIds can not be null"); + + var commandFunc = function(topic, value) { + + var result = topic.getText(); + topic.setText(value); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, text); + this._actionRunner.execute(command); + }, + + changeFontFamilyToTopic: function(topicIds, fontFamily) { + $assert(topicIds, "topicIds can not be null"); + $assert(fontFamily, "fontFamily can not be null"); + + + var commandFunc = function(topic, fontFamily) { + var result = topic.getFontFamily(); + topic.setFontFamily(fontFamily, true); + + core.Executor.instance.delay(topic.updateNode, 0, topic); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicIds, fontFamily); + this.execute(command); + }, + + changeFontColorToTopic: function(topicsIds, color) { + $assert(topicsIds, "topicIds can not be null"); + $assert(color, "color can not be null"); + + var commandFunc = function(topic, color) { + var result = topic.getFontColor(); + topic.setFontColor(color, true); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color); + command.discartDuplicated = "fontColorCommandId"; + this.execute(command); + }, + + changeBackgroundColorToTopic: function(topicsIds, color) { + $assert(topicsIds, "topicIds can not be null"); + $assert(color, "color can not be null"); + + var commandFunc = function(topic, color) { + var result = topic.getBackgroundColor(); + topic.setBackgroundColor(color); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color); + command.discartDuplicated = "backColor"; + this.execute(command); + }, + + changeBorderColorToTopic : function(topicsIds, color) { + $assert(topicsIds, "topicIds can not be null"); + $assert(color, "topicIds can not be null"); + + var commandFunc = function(topic, color) { + var result = topic.getBorderColor(); + topic.setBorderColor(color); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color); + command.discartDuplicated = "borderColorCommandId"; + this.execute(command); + }, + + changeFontSizeToTopic : function(topicsIds, size) { + $assert(topicsIds, "topicIds can not be null"); + $assert(size, "size can not be null"); + + var commandFunc = function(topic, size) { + var result = topic.getFontSize(); + topic.setFontSize(size, true); + + core.Executor.instance.delay(topic.updateNode, 0, topic); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, size); + this.execute(command); + }, + + changeShapeToTopic : function(topicsIds, shapeType) { + $assert(topicsIds, "topicsIds can not be null"); + $assert(shapeType, "shapeType can not be null"); + + var commandFunc = function(topic, shapeType) { + var result = topic.getShapeType(); + topic.setShapeType(shapeType, true); + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, shapeType); + this.execute(command); + }, + + changeFontWeightToTopic : function(topicsIds) { + $assert(topicsIds, "topicsIds can not be null"); + + var commandFunc = function(topic) { + var result = topic.getFontWeight(); + var weight = (result == "bold") ? "normal" : "bold"; + topic.setFontWeight(weight, true); + + core.Executor.instance.delay(topic.updateNode, 0, topic); + /*var updated = function() { + topic.updateNode(); + }; + updated.delay(0);*/ + return result; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds); + this.execute(command); + }, + + shrinkBranch : function(topicsIds, collapse) { + $assert(topicsIds, "topicsIds can not be null"); + + var commandFunc = function(topic, isShrink) { + topic.setChildrenShrinked(isShrink); + return !isShrink; + }; + + var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse); + this.execute(command); + }, + + execute:function(command) { + this._actionRunner.execute(command); + } + +}); + +mindplot.CommandContext = new Class({ + initialize: function(designer) { + $assert(designer, "designer can not be null"); + this._designer = designer; + }, + findTopics:function(topicsIds) { + var designerTopics = this._designer._topics; + if (!(topicsIds instanceof Array)) { + topicsIds = [topicsIds]; + } + + var result = designerTopics.filter(function(topic) { + var found = false; + if (topic != null) { + var topicId = topic.getId(); + found = topicsIds.contains(topicId); + } + return found; + + }); + return result; + }, + + deleteTopic:function(topic) { + this._designer._removeNode(topic); + }, + + createTopic:function(model, isVisible) { + $assert(model, "model can not be null"); + return this._designer._nodeModelToNodeGraph(model, isVisible); + }, + + createModel:function() { + var mindmap = this._designer.getMindmap(); + return mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE); + }, + + connect:function(childTopic, parentTopic, isVisible) { + childTopic.connectTo(parentTopic, this._designer._workspace, isVisible); + } , + + disconnect:function(topic) { + topic.disconnect(this._designer._workspace); + }, + + createRelationship:function(model) { + $assert(model, "model cannot be null"); + return this._designer.createRelationship(model); + }, + removeRelationship:function(model) { + this._designer.removeRelationship(model); + }, + + findRelationships:function(lineIds) { + var result = []; + lineIds.forEach(function(lineId, index) { + var line = this._designer._relationships[lineId]; + if ($defined(line)) { + result.push(line); + } + }.bind(this)); + return result; + }, + + getSelectedRelationshipLines:function() { + return this._designer.getSelectedRelationshipLines(); + } +}); + + diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index 56cc6ee6..7e22e2de 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/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 50a8230e..ecfe74d3 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -22,9 +22,14 @@ mindplot.MindmapDesigner = new Class({ $assert(profile.zoom, "zoom must be defined"); $assert(divElement, "divElement must be defined"); - // Undo manager ... - this._actionRunner = new mindplot.DesignerActionRunner(this); - mindplot.DesignerActionRunner.setInstance(this._actionRunner); + // Dispatcher manager ... + var commandContext = new mindplot.CommandContext(this); + this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext); + this._actionDispatcher.addEvent("modelUpdate", function(event) { + this._fireEvent("modelUpdate", event); + }.bind(this)); + + mindplot.ActionDispatcher.setInstance(this._actionDispatcher); // Initial Zoom this._zoom = profile.zoom; @@ -39,18 +44,13 @@ mindplot.MindmapDesigner = new Class({ var editorClass = mindplot.TextEditorFactory.getTextEditorFromName(mindplot.EditorOptions.textEditor); this._editor = new editorClass(this, this._actionRunner); - // Init layout managers ... this._topics = []; -// var layoutManagerClass = mindplot.layout.LayoutManagerFactory.getManagerByName(mindplot.EditorOptions.LayoutManager); -// this._layoutManager = new layoutManagerClass(this); this._layoutManager = new mindplot.layout.OriginalLayoutManager(this); // Register handlers.. this._registerEvents(); - this._relationships = {}; - this._events = {}; }, @@ -63,11 +63,8 @@ mindplot.MindmapDesigner = new Class({ return topics[0]; }, - addEventListener : function(eventType, listener) { - this._events[eventType] = listener; - }, _fireEvent : function(eventType, event) { @@ -87,7 +84,7 @@ mindplot.MindmapDesigner = new Class({ // Create nodes on double click... screenManager.addEventListener('click', function(event) { if (workspace.isWorkspaceEventsEnabled()) { - var t = mindmapDesigner.getEditor().isVisible(); + mindmapDesigner.getEditor().isVisible(); mindmapDesigner.getEditor().lostFocus(); // @todo: Puaj hack... mindmapDesigner._cleanScreen(); @@ -110,8 +107,7 @@ mindplot.MindmapDesigner = new Class({ var centralTopicId = centralTopic.getId(); // Execute action ... - var command = new mindplot.commands.AddTopicCommand(model, centralTopicId, true); - this._actionRunner.execute(command); + this._actionDispatcher.addTopic(model, centralTopicId, true); } }.bind(this)); } @@ -159,14 +155,14 @@ mindplot.MindmapDesigner = new Class({ onObjectFocusEvent : function(currentObject, event) { this.getEditor().lostFocus(); var selectableObjects = this.getSelectedObjects(); + // Disable all nodes on focus but not the current if Ctrl key isn't being pressed if (!$defined(event) || event.ctrlKey == false) { - for (var i = 0; i < selectableObjects.length; i++) { - var selectableObject = selectableObjects[i]; + selectableObjects.forEach(function(selectableObject) { if (selectableObject.isOnFocus() && selectableObject != currentObject) { selectableObject.setOnFocus(false); } - } + }); } }, @@ -214,8 +210,9 @@ mindplot.MindmapDesigner = new Class({ var parentTopicId = centalTopic.getId(); var childModel = centalTopic.createChildModel(this._layoutManager.needsPrepositioning()); - var command = new mindplot.commands.AddTopicCommand(childModel, parentTopicId, true); - this._actionRunner.execute(command); + // Execute event ... + this._actionDispatcher.addTopic(childModel, parentTopicId, true); + }, createSiblingForSelectedNode : function() { @@ -241,9 +238,8 @@ mindplot.MindmapDesigner = new Class({ var parentTopic = topic.getOutgoingConnectedTopic(); var siblingModel = topic.createSiblingModel(this._layoutManager.needsPrepositioning()); var parentTopicId = parentTopic.getId(); - var command = new mindplot.commands.AddTopicCommand(siblingModel, parentTopicId, true); - this._actionRunner.execute(command); + this._actionDispatcher.addTopic(siblingModel, parentTopicId, true); } }, @@ -303,8 +299,8 @@ mindplot.MindmapDesigner = new Class({ var mindmap = this.getMindmap(); var model = mindmap.createRelationship(fromNode.getModel().getId(), toNode.getModel().getId()); - var command = new mindplot.commands.AddRelationshipCommand(model, mindmap); - this._actionRunner.execute(command); + this._actionDispatcher.addRelationship(model, mindmap); + }, needsSave : function() { @@ -364,7 +360,8 @@ mindplot.MindmapDesigner = new Class({ this._fireEvent("loadsuccess"); - }, + } + , load : function(mapId) { $assert(mapId, 'mapName can not be null'); @@ -383,7 +380,8 @@ mindplot.MindmapDesigner = new Class({ this._goToNode.attempt(centralTopic, this); this._fireEvent("loadsuccess"); - }, + } + , _loadMap : function(mapId, mindmapModel) { var designer = this; @@ -396,7 +394,7 @@ mindplot.MindmapDesigner = new Class({ for (var i = 0; i < branches.length; i++) { // NodeModel -> NodeGraph ... var nodeModel = branches[i]; - var nodeGraph = this._nodeModelToNodeGraph(nodeModel); + var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false); // Update shrink render state... nodeGraph.setBranchVisibility(true); @@ -412,42 +410,46 @@ mindplot.MindmapDesigner = new Class({ }); this._fireEvent("loadsuccess"); - }, + } + , getMindmap : function() { return this._mindmap; - }, + } + , undo : function() { this._actionRunner.undo(); - }, + } + , redo : function() { this._actionRunner.redo(); - }, + } + , _nodeModelToNodeGraph : function(nodeModel, isVisible) { $assert(nodeModel, "Node model can not be null"); var nodeGraph = this._buildNodeGraph(nodeModel); - if ($defined(isVisible)) + if (isVisible) nodeGraph.setVisibility(isVisible); var children = nodeModel.getChildren().slice(); - children = this._layoutManager.prepareNode(nodeGraph, children); for (var i = 0; i < children.length; i++) { var child = children[i]; if ($defined(child)) - this._nodeModelToNodeGraph(child); + this._nodeModelToNodeGraph(child, false); } var workspace = this._workspace; workspace.appendChild(nodeGraph); return nodeGraph; - }, + } + , _relationshipModelToRelationship : function(model) { $assert(model, "Node model can not be null"); @@ -480,7 +482,6 @@ mindplot.MindmapDesigner = new Class({ }, _buildRelationship : function (model) { - var workspace = this._workspace; var elem = this; var fromNodeId = model.getFromNode(); @@ -521,7 +522,6 @@ mindplot.MindmapDesigner = new Class({ relationLine.setModel(model); //Add Listeners - var elem = this; relationLine.addEventListener('onfocus', function(event) { elem.onObjectFocusEvent.attempt([relationLine, event], elem); }); @@ -567,8 +567,7 @@ mindplot.MindmapDesigner = new Class({ var validateError = 'Central topic can not be deleted.'; var selectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError); if (selectedObjects.nodes.length > 0 || selectedObjects.relationshipLines.length > 0) { - var command = new mindplot.commands.DeleteTopicCommand(selectedObjects); - this._actionRunner.execute(command); + this._actionDispatcher.deleteTopics(selectedObjects); } }, @@ -577,19 +576,8 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic, font) { - var result = topic.getFontFamily(); - topic.setFontFamily(font, true); + this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font); - core.Executor.instance.delay(topic.updateNode, 0, topic); - /*var updated = function() { - topic.updateNode(); - }; - updated.delay(0);*/ - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, font, topicsIds); - this._actionRunner.execute(command); } }, @@ -597,14 +585,7 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic) { - var result = topic.getFontStyle(); - var style = (result == "italic") ? "normal" : "italic"; - topic.setFontStyle(style, true); - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, "", topicsIds); - this._actionRunner.execute(command); + this._actionDispatcher.changeFontStyleToTopic(topicsIds); } }, @@ -612,14 +593,7 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic, color) { - var result = topic.getFontColor(); - topic.setFontColor(color, true); - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds); - command.discartDuplicated = "fontColorCommandId"; - this._actionRunner.execute(command); + this._actionDispatcher.changeFontColorToTopic(topicsIds, color); } }, @@ -628,20 +602,11 @@ mindplot.MindmapDesigner = new Class({ var validateFunc = function(topic) { return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE }; - var validateError = 'Color can not be setted to line topics.'; + var validateError = 'Color can not be set to line topics.'; var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError); - ; var topicsIds = validSelectedObjects.nodes; - if (topicsIds.length > 0) { - var commandFunc = function(topic, color) { - var result = topic.getBackgroundColor(); - topic.setBackgroundColor(color); - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds); - command.discartDuplicated = "backColor"; - this._actionRunner.execute(command); + this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color); } }, @@ -688,20 +653,12 @@ mindplot.MindmapDesigner = new Class({ var validateFunc = function(topic) { return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE }; - var validateError = 'Color can not be setted to line topics.'; + var validateError = 'Color can not be set to line topics.'; var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError); - ; var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic, color) { - var result = topic.getBorderColor(); - topic.setBorderColor(color); - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds); - command.discartDuplicated = "borderColorCommandId"; - this._actionRunner.execute(command); + this._actionDispatcher.changeBorderColorToTopic(topicsIds, color); } }, @@ -709,19 +666,7 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic, size) { - var result = topic.getFontSize(); - topic.setFontSize(size, true); - - core.Executor.instance.delay(topic.updateNode, 0, topic); - /*var updated = function() { - topic.updateNode(); - }; - updated.delay(0);*/ - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, size, topicsIds); - this._actionRunner.execute(command); + this._actionDispatcher.changeFontSizeToTopic(topicsIds, size); } }, @@ -734,13 +679,7 @@ mindplot.MindmapDesigner = new Class({ var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic, size) { - var result = topic.getShapeType(); - topic.setShapeType(size, true); - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, shape, topicsIds); - this._actionRunner.execute(command); + this._actionDispatcher.changeShapeToTopic(topicsIds, shape); } }, @@ -749,30 +688,15 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var commandFunc = function(topic) { - var result = topic.getFontWeight(); - var weight = (result == "bold") ? "normal" : "bold"; - topic.setFontWeight(weight, true); - - core.Executor.instance.delay(topic.updateNode, 0, topic); - /*var updated = function() { - topic.updateNode(); - }; - updated.delay(0);*/ - return result; - } - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, "", topicsIds); - this._actionRunner.execute(command); + this._actionDispatcher.changeFontWeightToTopic(topicsIds); } }, - addImage2SelectedNode : function(iconType) { + addIconType2SelectedNode : function(iconType) { var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - - var command = new mindplot.commands.AddIconToTopicCommand(topicsIds[0], iconType); - this._actionRunner.execute(command); + this._actionDispatcher.addIconToTopic(topicsIds[0], iconType); } }, @@ -780,8 +704,7 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var command = new mindplot.commands.AddLinkToTopicCommand(topicsIds[0], url); - this._actionRunner.execute(command); + this._actionDispatcher.addLinkToTopic(topicsIds[0], url); } }, @@ -793,11 +716,11 @@ mindplot.MindmapDesigner = new Class({ if (!$defined(topic._hasLink)) { var msg = new Element('div'); var urlText = new Element('div').inject(msg); - urlText.innerHTML = "URL:" + urlText.innerHTML = "URL:"; var formElem = new Element('form', {'action': 'none', 'id':'linkFormId'}); var urlInput = new Element('input', {'type': 'text', 'size':30}); urlInput.inject(formElem); - formElem.inject(msg) + formElem.inject(msg); var okButtonId = "linkOkButtonId"; formElem.addEvent('submit', function(e) { @@ -833,8 +756,7 @@ mindplot.MindmapDesigner = new Class({ var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { - var command = new mindplot.commands.AddNoteToTopicCommand(topicsIds[0], text); - this._actionRunner.execute(command); + this._actionDispatcher.addNoteToTopic(topicsIds[0], text); } }, @@ -881,27 +803,6 @@ mindplot.MindmapDesigner = new Class({ } }, - removeLastImageFromSelectedNode : function() { - var nodes = this._getSelectedNodes(); - if (nodes.length == 0) { - core.Monitor.getInstance().logMessage('A topic must be selected in order to execute this operation.'); - } else { - var elem = nodes[0]; - elem.removeLastIcon(this); - core.Executor.instance.delay(elem.updateNode, 0, elem); - /*var executor = function(editor) - { - return function() - { - elem.updateNode(); - }; - }; - - setTimeout(executor(this), 0);*/ - } - }, - - _getSelectedNodes : function() { var result = new Array(); for (var i = 0; i < this._topics.length; i++) { @@ -951,6 +852,7 @@ mindplot.MindmapDesigner = new Class({ evt.returnValue = false; } else { + // @ToDo: I think that some of the keys has been removed ... Check this... evt = new Event(event); var key = evt.key; if (!this._editor.isVisible()) { @@ -961,6 +863,8 @@ mindplot.MindmapDesigner = new Class({ this._showEditor(key); } else { + var nodes; + var node; switch (key) { case 'delete': this.deleteCurrentNode(); @@ -974,9 +878,9 @@ mindplot.MindmapDesigner = new Class({ this.createChildForSelectedNode(); break; case 'right': - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); if (nodes.length > 0) { - var node = nodes[0]; + node = nodes[0]; if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { this._goToSideChild(node, 'RIGHT'); } @@ -991,9 +895,9 @@ mindplot.MindmapDesigner = new Class({ } break; case 'left': - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); if (nodes.length > 0) { - var node = nodes[0]; + node = nodes[0]; if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { this._goToSideChild(node, 'LEFT'); } @@ -1008,18 +912,18 @@ mindplot.MindmapDesigner = new Class({ } break; case'up': - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); if (nodes.length > 0) { - var node = nodes[0]; + node = nodes[0]; if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { this._goToBrother(node, 'UP'); } } break; case 'down': - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); if (nodes.length > 0) { - var node = nodes[0]; + node = nodes[0]; if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { this._goToBrother(node, 'DOWN'); } @@ -1029,8 +933,7 @@ mindplot.MindmapDesigner = new Class({ this._showEditor(); break; case 'space': - - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); if (nodes.length > 0) { var topic = nodes[0]; @@ -1043,9 +946,9 @@ mindplot.MindmapDesigner = new Class({ evt.preventDefault(); break; case 'esc': - var nodes = this._getSelectedNodes(); + nodes = this._getSelectedNodes(); for (var i = 0; i < nodes.length; i++) { - var node = nodes[i]; + node = nodes[i]; node.setOnFocus(false); } break; @@ -1170,17 +1073,6 @@ mindplot.MindmapDesigner = new Class({ getWorkSpace : function() { return this._workspace; - }, - - findRelationShipsByTopicId : function(topicId) { - var result = []; - for (var relationshipId in this._relationships) { - var relationship = this._relationships[relationshipId]; - if (relationship.getModel().getFromNode() == topicId || relationship.getModel().getToNode() == topicId) { - result.push(relationship); - } - } - return result; } } ); diff --git a/mindplot/src/main/javascript/NodeGraph.js b/mindplot/src/main/javascript/NodeGraph.js index 1f7c55f3..e46c64eb 100644 --- a/mindplot/src/main/javascript/NodeGraph.js +++ b/mindplot/src/main/javascript/NodeGraph.js @@ -18,7 +18,7 @@ mindplot.NodeGraph = new Class({ initialize:function(nodeModel) { - $assert(nodeModel,"model can not be null"); + $assert(nodeModel, "model can not be null"); this._mouseEvents = true; this.setModel(nodeModel); this._onFocus = false; @@ -74,13 +74,10 @@ mindplot.NodeGraph = new Class({ this._model.setSize(size.width, size.height); }, - getModel - : - function() { - $assert(this._model, 'Model has not been initialized yet'); - return this._model; - } - , + getModel:function() { + $assert(this._model, 'Model has not been initialized yet'); + return this._model; + }, setModel : function(model) { $assert(model, 'Model can not be null'); diff --git a/mindplot/src/main/javascript/Note.js b/mindplot/src/main/javascript/Note.js index 52979339..b0fc6712 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; @@ -50,8 +50,9 @@ mindplot.Note = new Class({ removeBtn.setStyle("margin-left", "3px"); removeBtn.addEvent('click', function(event) { - var command = new mindplot.commands.RemoveNoteFromTopicCommand(this._topic.getId()); - designer._actionRunner.execute(command); + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.removeNoteFromTopic(this._topic.getId()); + bubbleTip.forceClose(); }.bindWithEvent(this)); 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/ShrinkConnector.js b/mindplot/src/main/javascript/ShrinkConnector.js index 5a661d9b..ed8356d0 100644 --- a/mindplot/src/main/javascript/ShrinkConnector.js +++ b/mindplot/src/main/javascript/ShrinkConnector.js @@ -26,18 +26,11 @@ mindplot.ShirinkConnector = new Class({ elipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH); elipse.addEventListener('click', function(event) { var model = topic.getModel(); - var isShrink = !model.areChildrenShrinked(); + var collapse = !model.areChildrenShrinked(); - var actionRunner = mindplot.DesignerActionRunner.getInstance(); var topicId = topic.getId(); - - var commandFunc = function(topic, isShrink) { - topic.setChildrenShrinked(isShrink); - return !isShrink; - }; - - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, isShrink, [topicId]); - actionRunner.execute(command); + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.shrinkBranch([topicId],collapse); var e = new Event(event).stop(); e.preventDefault(); diff --git a/mindplot/src/main/javascript/SingleCommandDispatcher.js b/mindplot/src/main/javascript/SingleCommandDispatcher.js deleted file mode 100644 index 7093aa51..00000000 --- a/mindplot/src/main/javascript/SingleCommandDispatcher.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. - */ - -mindplot.SingleCommandDispatcher = new Class( -{ - Extends:mindplot.BaseCommandDispatcher, - initialize: function() { - - }, - addIconToTopic: function() { - throw "method must be implemented."; - }, - addLinkToTopic: function() { - throw "method must be implemented."; - }, - addNoteToTopic: function() { - throw "method must be implemented."; - },addRelationship: function() { - throw "method must be implemented."; - },addTopic: function() { - throw "method must be implemented."; - },changeIcon: function() { - throw "method must be implemented."; - },deleteTopic: function() { - throw "method must be implemented."; - },dragTopic: function() { - throw "method must be implemented."; - },moveControllPoint: function() { - throw "method must be implemented."; - } ,removeIconFromTopic: function() { - throw "method must be implemented."; - },removeLinkFromTopic: function() { - throw "method must be implemented."; - },removeNodeFromTopic: function() { - throw "method must be implemented."; - } -}); - diff --git a/mindplot/src/main/javascript/TextEditor.js b/mindplot/src/main/javascript/TextEditor.js index 7a4b538f..7b71f511 100644 --- a/mindplot/src/main/javascript/TextEditor.js +++ b/mindplot/src/main/javascript/TextEditor.js @@ -17,11 +17,10 @@ */ mindplot.TextEditor = new Class({ - initialize:function(designer, actionRunner) { + initialize:function(designer) { this._designer = designer; this._screenManager = designer.getWorkSpace().getScreenManager(); this._container = this._screenManager.getContainer(); - this._actionRunner = actionRunner; this._isVisible = false; //Create editor ui @@ -132,13 +131,8 @@ mindplot.TextEditor = new Class({ var text = this.getText(); var topicId = this._currentNode.getId(); - var commandFunc = function(topic, value) { - var result = topic.getText(); - topic.setText(value); - return result; - }; - var command = new mindplot.commands.GenericFunctionCommand(commandFunc, text, [topicId]); - this._actionRunner.execute(command); + var actionDispatcher = mindplot.ActionDispatcher.getInstance(); + actionDispatcher.changeTextOnTopic([topicId], text); } }, @@ -221,7 +215,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 93ba30e8..e7b8ade7 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -30,8 +30,7 @@ mindplot.Topic = new Class({ this._buildShape(); this.setMouseEventsEnabled(true); - // Positionate topic .... - var model = this.getModel(); + // Position a topic .... var pos = model.getPosition(); if (pos != null && model.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { this.setPosition(pos); @@ -65,8 +64,8 @@ mindplot.Topic = new Class({ //Let's register all the events. The first one is the default one. The others will be copied. //this._registerDefaultListenersToElement(innerShape, this); - var dispatcher = dispatcherByEventType['mousedown']; + if ($defined(dispatcher)) { for (var i = 1; i < dispatcher._listeners.length; i++) { innerShape.addEventListener('mousedown', dispatcher._listeners[i]); @@ -245,7 +244,7 @@ mindplot.Topic = new Class({ return this._icon; }, - _buildIconGroup : function(disableEventsListeners) { + _buildIconGroup : function() { var result = new mindplot.IconGroup(this); var model = this.getModel(); @@ -455,16 +454,6 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontFamily(value); } - /*var elem = this; - var executor = function(editor) - { - return function() - { - elem.updateNode(updateModel); - }; - }; - - setTimeout(executor(this), 0);*/ core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); }, @@ -475,16 +464,6 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontSize(value); } - /*var elem = this; - var executor = function(editor) - { - return function() - { - elem.updateNode(updateModel); - }; - }; - - setTimeout(executor(this), 0);*/ core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); }, @@ -496,16 +475,6 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontStyle(value); } - /*var elem = this; - var executor = function(editor) - { - return function() - { - elem.updateNode(updateModel); - }; - }; - - setTimeout(executor(this), 0);*/ core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); }, @@ -870,9 +839,7 @@ mindplot.Topic = new Class({ }, moveToBack : function() { -// this._helpers.forEach(function(helper, index){ -// helper.moveToBack(); -// }); + // Update relationship lines for (var j = 0; j < this._relationships.length; j++) { this._relationships[j].moveToBack(); @@ -883,8 +850,6 @@ mindplot.Topic = new Class({ } this.get2DElement().moveToBack(); - - }, moveToFront : function() { @@ -906,7 +871,6 @@ mindplot.Topic = new Class({ }, _setRelationshipLinesVisibility : function(value) { - //var relationships = designer.findRelationShipsByTopicId(this.getId()); this._relationships.forEach(function(relationship, index) { relationship.setVisibility(value); }); @@ -974,14 +938,6 @@ mindplot.Topic = new Class({ type = 'mousedown'; } - /* var textShape = this.getTextShape(); - textShape.addEventListener(type, listener); - - var outerShape = this.getOuterShape(); - outerShape.addEventListener(type, listener); - - var innerShape = this.getInnerShape(); - innerShape.addEventListener(type, listener);*/ var shape = this.get2DElement(); shape.addEventListener(type, listener); }, @@ -991,15 +947,6 @@ mindplot.Topic = new Class({ if (type == 'onfocus') { type = 'mousedown'; } - /*var textShape = this.getTextShape(); - textShape.removeEventListener(type, listener); - - var outerShape = this.getOuterShape(); - outerShape.removeEventListener(type, listener); - - var innerShape = this.getInnerShape(); - innerShape.removeEventListener(type, listener);*/ - var shape = this.get2DElement(); shape.removeEventListener(type, listener); }, @@ -1013,7 +960,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,14 +1123,14 @@ mindplot.Topic = new Class({ }, createDragNode : function() { - var dragNode = mindplot.NodeGraph.prototype.createDragNode.call(this); + var result = this.parent(); // Is the node already connected ? var targetTopic = this.getOutgoingConnectedTopic(); if ($defined(targetTopic)) { - dragNode.connectTo(targetTopic); + result.connectTo(targetTopic); } - return dragNode; + return result; }, updateNode : function(updatePosition) { 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/collaboration/frameworks/brix/BrixFramework.js b/mindplot/src/main/javascript/collaboration/frameworks/brix/BrixFramework.js index 977eee92..aeeb0199 100644 --- a/mindplot/src/main/javascript/collaboration/frameworks/brix/BrixFramework.js +++ b/mindplot/src/main/javascript/collaboration/frameworks/brix/BrixFramework.js @@ -29,6 +29,7 @@ mindplot.collaboration.frameworks.brix.BrixFramework.instanciate=function(){ if($defined(isGoogleBrix) && !instanciated){ instanciated=true; var app = new goog.collab.CollaborativeApp(); + mindplot.collaboration.frameworks.brix.BrixFramework.buildMenu(app); app.start(); app.addListener('modelLoad', function(model){ var framework = new mindplot.collaboration.frameworks.brix.BrixFramework(model, app); @@ -37,6 +38,32 @@ mindplot.collaboration.frameworks.brix.BrixFramework.instanciate=function(){ } }; +mindplot.collaboration.frameworks.brix.BrixFramework.buildMenu=function(app){ + var menuBar = new goog.collab.ui.MenuBar(); + + // Configure toolbar menu ... + var fileMenu = menuBar.addSubMenu("File"); + fileMenu.addItem("Save", function() { + }); + fileMenu.addItem("Export", function() { + }); + + var editMenu = menuBar.addSubMenu("Edit"); + editMenu.addItem("Undo", function() { + }); + editMenu.addItem("Redo", function() { + }); + + var formatMenu = menuBar.addSubMenu("Format"); + formatMenu.addItem("Bold", function() { + }); + + var helpMenu = menuBar.addSubMenu("Help"); + helpMenu.addItem("Shortcuts", function() { + }); + + app.setMenuBar(menuBar); +}; mindplot.collaboration.frameworks.brix.BrixFramework.instanciate(); diff --git a/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js b/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js index a6eb2dff..b079fd7d 100644 --- a/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js @@ -1,33 +1,30 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.AddIconToTopicCommand = new Class( -{ +mindplot.commands.AddIconToTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicId, iconType) - { + initialize: function(topicId, iconType) { $assert(topicId, 'topicId can not be null'); $assert(iconType, 'iconType can not be null'); this._selectedObjectsIds = topicId; this._iconType = iconType; }, - execute: function(commandContext) - { + execute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { var iconImg = topic.addIcon(this._iconType, commandContext._designer); @@ -36,8 +33,7 @@ mindplot.commands.AddIconToTopicCommand = new Class( }.bind(this); updated.delay(0); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { topic.removeIcon(this._iconModel); diff --git a/mindplot/src/main/javascript/commands/AddLinkToTopicCommand.js b/mindplot/src/main/javascript/commands/AddLinkToTopicCommand.js index 408cd233..5d2f881f 100644 --- a/mindplot/src/main/javascript/commands/AddLinkToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddLinkToTopicCommand.js @@ -1,42 +1,38 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.AddLinkToTopicCommand =new Class( -{ +mindplot.commands.AddLinkToTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicId,url) - { + initialize: function(topicId, url) { $assert(topicId, 'topicId can not be null'); this._selectedObjectsIds = topicId; this._url = url; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { + execute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { - topic.addLink(this._url,commandContext._designer); + topic.addLink(this._url, commandContext._designer); topic.updateNode(); }.bind(this); updated.delay(0); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { topic.removeLink(); diff --git a/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js b/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js index 05bfe16b..b685ccac 100644 --- a/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js @@ -1,42 +1,38 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.AddNoteToTopicCommand = new Class( -{ +mindplot.commands.AddNoteToTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicId,text) - { + initialize: function(topicId, text) { $assert(topicId, 'topicId can not be null'); this._selectedObjectsIds = topicId; this._text = text; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { + execute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { - topic.addNote(this._text,commandContext._designer); + topic.addNote(this._text, commandContext._designer); topic.updateNode(); }.bind(this); updated.delay(0); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { topic.removeNote(); diff --git a/mindplot/src/main/javascript/commands/AddRelationshipCommand.js b/mindplot/src/main/javascript/commands/AddRelationshipCommand.js index 6b37b6c7..b5c637ba 100644 --- a/mindplot/src/main/javascript/commands/AddRelationshipCommand.js +++ b/mindplot/src/main/javascript/commands/AddRelationshipCommand.js @@ -1,40 +1,36 @@ /* -* 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. -*/ -mindplot.commands.AddRelationshipCommand = new Class( -{ + * 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. + */ +mindplot.commands.AddRelationshipCommand = new Class({ Extends:mindplot.Command, - initialize: function(model, mindmap) - { + initialize: function(model, mindmap) { $assert(model, 'Relationship model can not be null'); this._model = model; this._mindmap = mindmap; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { + execute: function(commandContext) { var relationship = commandContext.createRelationship(this._model); // Finally, focus ... var designer = commandContext._designer; designer.onObjectFocusEvent.attempt(relationship, designer); relationship.setOnFocus(true); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var relationship = commandContext.removeRelationship(this._model); this._mindmap.removeRelationship(this._model); } diff --git a/mindplot/src/main/javascript/commands/AddTopicCommand.js b/mindplot/src/main/javascript/commands/AddTopicCommand.js index 8c6877cc..b2b34e70 100644 --- a/mindplot/src/main/javascript/commands/AddTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddTopicCommand.js @@ -1,69 +1,67 @@ /* -* 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. -*/ + * 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. + */ mindplot.commands.AddTopicCommand = new Class( -{ - Extends:mindplot.Command, - initialize: function(model, parentTopicId, animated) { - $assert(model, 'Model can not be null'); - this._model = model; - this._parentId = parentTopicId; - this._id = mindplot.Command._nextUUID(); - this._animated = $defined(animated)?animated:false; - }, - execute: function(commandContext) - { - // Add a new topic ... + Extends:mindplot.Command, + initialize: function(model, parentTopicId, animated) { + $assert(model, 'Model can not be null'); + this._model = model; + this._parentId = parentTopicId; + this._id = mindplot.Command._nextUUID(); + this._animated = $defined(animated) ? animated : false; + }, - var topic = commandContext.createTopic(this._model, !this._animated); + execute: function(commandContext) { - // Connect to topic ... - if ($defined(this._parentId)) - { - var parentTopic = commandContext.findTopics(this._parentId)[0]; - commandContext.connect(topic, parentTopic, !this._animated); + // Add a new topic ... + var topic = commandContext.createTopic(this._model, !this._animated); + + // Connect to topic ... + if ($defined(this._parentId)) { + var parentTopic = commandContext.findTopics(this._parentId)[0]; + commandContext.connect(topic, parentTopic, !this._animated); + } + + var doneFn = function() { + // Finally, focus ... + var designer = commandContext._designer; + designer.onObjectFocusEvent(topic); + topic.setOnFocus(true); + }; + + if (this._animated) { + core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], true, doneFn); + } else + doneFn.attempt(); + }, + + undoExecute: function(commandContext) { + // Finally, delete the topic from the workspace ... + var topicId = this._model.getId(); + var topic = commandContext.findTopics(topicId)[0]; + var doneFn = function() { + commandContext.deleteTopic(topic); + }; + if (this._animated) { + core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], false, doneFn); + } + else + doneFn.attempt(); } - - var doneFn = function(){ - // Finally, focus ... - var designer = commandContext._designer; - designer.onObjectFocusEvent.attempt(topic, designer); - topic.setOnFocus(true); - }; - - if(this._animated){ - core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()],true,doneFn); - } else - doneFn.attempt(); - }, - undoExecute: function(commandContext) - { - // Finally, delete the topic from the workspace ... - var topicId = this._model.getId(); - var topic = commandContext.findTopics(topicId)[0]; - var doneFn = function(){ - commandContext.deleteTopic(topic); - }; - if(this._animated){ - core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()],false, doneFn); - } - else - doneFn.attempt(); - } -}); \ No newline at end of file + }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/ChangeIconFromTopicCommand.js b/mindplot/src/main/javascript/commands/ChangeIconFromTopicCommand.js deleted file mode 100644 index 4b7ae24f..00000000 --- a/mindplot/src/main/javascript/commands/ChangeIconFromTopicCommand.js +++ /dev/null @@ -1,49 +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. -*/ - -mindplot.commands.ChangeIconFromTopicCommand = new Class( -{ - Extends:mindplot.Command, - initialize: function(topicId, iconId, iconType) - { - $assert(topicId, 'topicId can not be null'); - $assert(iconId, 'iconId can not be null'); - $assert(iconType, 'iconType can not be null'); - this._selectedObjectsIds = topicId; - this._iconModel = iconId; - this._iconType = iconType; - }, - execute: function(commandContext) - { - var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; - var updated = function() { - topic.removeIcon(this._iconModel); - topic.updateNode(); - }.bind(this); - updated.delay(0); - }, - undoExecute: function(commandContext) - { - var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; - var updated = function() { - topic.addIcon(this._iconModel, commandContext._designer); - topic.updateNode(); - }.bind(this); - updated.delay(0); - } -}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/DeleteTopicCommand.js b/mindplot/src/main/javascript/commands/DeleteTopicCommand.js index 6a7a3f33..9db432e4 100644 --- a/mindplot/src/main/javascript/commands/DeleteTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DeleteTopicCommand.js @@ -1,26 +1,24 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.DeleteTopicCommand = new Class( -{ +mindplot.commands.DeleteTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicsIds) - { + initialize: function(topicsIds) { $assert(topicsIds, "topicsIds must be defined"); this._selectedObjectsIds = topicsIds; this._deletedTopicModels = []; @@ -28,18 +26,16 @@ mindplot.commands.DeleteTopicCommand = new Class( this._deletedRelationships = []; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { + execute: function(commandContext) { var topics = commandContext.findTopics(this._selectedObjectsIds.nodes); - if(topics.length>0){ - topics.forEach( - function(topic, index) - { + if (topics.length > 0) { + topics.forEach( + function(topic, index) { var model = topic.getModel().clone(); - //delete relationships + //delete relationships var relationships = topic.getRelationships(); - while(relationships.length>0){ + while (relationships.length > 0) { var relationship = relationships[0]; this._deletedRelationships.push(relationship.getModel().clone()); commandContext.removeRelationship(relationship.getModel()); @@ -50,8 +46,7 @@ mindplot.commands.DeleteTopicCommand = new Class( // Is connected?. var outTopic = topic.getOutgoingConnectedTopic(); var outTopicId = null; - if (outTopic != null) - { + if (outTopic != null) { outTopicId = outTopic.getId(); } this._parentTopicIds.push(outTopicId); @@ -60,41 +55,39 @@ mindplot.commands.DeleteTopicCommand = new Class( commandContext.deleteTopic(topic); }.bind(this) - ); } + ); + } var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines); - if(lines.length>0){ - lines.forEach(function(line,index){ - if(line.isInWorkspace()){ + if (lines.length > 0) { + lines.forEach(function(line, index) { + if (line.isInWorkspace()) { this._deletedRelationships.push(line.getModel().clone()); - commandContext.removeRelationship(line.getModel()); + commandContext.removeRelationship(line.getModel()); } }.bind(this)); } }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var topics = commandContext.findTopics(this._selectedObjectsIds); var parent = commandContext.findTopics(this._parentTopicIds); this._deletedTopicModels.forEach( - function(model, index) - { - var topic = commandContext.createTopic(model); + function(model, index) { + var topic = commandContext.createTopic(model); - // Was the topic connected? - var parentTopic = parent[index]; - if (parentTopic != null) - { - commandContext.connect(topic, parentTopic); - } + // Was the topic connected? + var parentTopic = parent[index]; + if (parentTopic != null) { + commandContext.connect(topic, parentTopic); + } - }.bind(this) - ); + }.bind(this) + ); this._deletedRelationships.forEach( - function(relationship, index){ - commandContext.createRelationship(relationship); - }.bind(this)); + function(relationship, index) { + commandContext.createRelationship(relationship); + }.bind(this)); this._deletedTopicModels = []; this._parentTopicIds = []; diff --git a/mindplot/src/main/javascript/commands/DragTopicCommand.js b/mindplot/src/main/javascript/commands/DragTopicCommand.js index 984614dc..fcaf6093 100644 --- a/mindplot/src/main/javascript/commands/DragTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DragTopicCommand.js @@ -1,35 +1,35 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.DragTopicCommand = new Class( -{ +mindplot.commands.DragTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicId) - { - $assert(topicId, "topicId must be defined"); - this._selectedObjectsIds = topicId; - this._parentTopic = null; - this._position = null; - this._order = null; + initialize: function(topicIds, position, order, parentTopic) { + $assert(topicIds, "topicIds must be defined"); + + this._selectedObjectsIds = topicIds; + if ($defined(parentTopic)) + this._parentId = parentTopic.getId(); + + this._position = position; + this._order = order; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { + execute: function(commandContext) { var topic = commandContext.findTopics([this._selectedObjectsIds])[0]; @@ -39,70 +39,51 @@ mindplot.commands.DragTopicCommand = new Class( var origPosition = null; // if (topic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE && origParentTopic != null && origParentTopic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE) // { - // In this case, topics are positioned using order ... - origOrder = topic.getOrder(); + // In this case, topics are positioned using order ... + origOrder = topic.getOrder(); // } else // { - origPosition = topic.getPosition().clone(); + origPosition = topic.getPosition().clone(); // } // Disconnect topic .. - if ($defined(origParentTopic)) - { + if ($defined(origParentTopic)) { commandContext.disconnect(topic); } // Set topic order ... - if (this._order != null) - { + if (this._order != null) { topic.setOrder(this._order); - } else if (this._position != null) - { + } else if (this._position != null) { // Set position ... topic.setPosition(this._position); - } else - { + } else { $assert("Illegal commnad state exception."); } this._order = origOrder; this._position = origPosition; // Finally, connect topic ... - if ($defined(this._parentId)) - { + if ($defined(this._parentId)) { var parentTopic = commandContext.findTopics([this._parentId])[0]; commandContext.connect(topic, parentTopic); } // Backup old parent id ... this._parentId = null; - if ($defined(origParentTopic)) - { + if ($defined(origParentTopic)) { this._parentId = origParentTopic.getId(); } }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { this.execute(commandContext); var selectedRelationships = commandContext.getSelectedRelationshipLines(); - selectedRelationships.forEach(function(relationshipLine,index){ + selectedRelationships.forEach(function(relationshipLine) { relationshipLine.redraw(); }); - }, - setPosition: function(point) - { - this._position = point; - }, - setParetTopic: function(topic) { - this._parentId = topic.getId(); - - }, - setOrder: function(order) - { - this._order = order } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js index 6b01287b..f9cba3dc 100644 --- a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js +++ b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js @@ -1,66 +1,57 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.GenericFunctionCommand =new Class( -{ +mindplot.commands.GenericFunctionCommand = new Class({ Extends:mindplot.Command, - initialize: function(commandFunc,value,topicsIds) - { + initialize: function(commandFunc, topicsIds,value) { $assert(commandFunc, "commandFunc must be defined"); $assert(topicsIds, "topicsIds must be defined"); + this._value = value; this._selectedObjectsIds = topicsIds; this._commandFunc = commandFunc; this._oldValues = []; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) - { - if (!this.applied) - { + execute: function(commandContext) { + if (!this.applied) { var topics = commandContext.findTopics(this._selectedObjectsIds); - topics.forEach(function(topic) - { + topics.forEach(function(topic) { var oldValue = this._commandFunc(topic, this._value); this._oldValues.push(oldValue); }.bind(this)); this.applied = true; - } else - { + } else { throw "Command can not be applied two times in a row."; } }, - undoExecute: function(commandContext) - { - if (this.applied) - { + undoExecute: function(commandContext) { + if (this.applied) { var topics = commandContext.findTopics(this._selectedObjectsIds); - topics.forEach(function(topic,index) - { + topics.forEach(function(topic, index) { this._commandFunc(topic, this._oldValues[index]); }.bind(this)); this.applied = false; this._oldValues = []; - } else - { + } else { throw "undo can not be applied."; } } diff --git a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js index a5be49c8..ee11efc5 100644 --- a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js +++ b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js @@ -1,33 +1,32 @@ /* -* 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. -*/ -mindplot.commands.MoveControlPointCommand = new Class( -{ + * 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. + */ +mindplot.commands.MoveControlPointCommand = new Class({ Extends:mindplot.Command, - initialize: function(ctrlPointController, point) - { + initialize: function(ctrlPointController, point) { $assert(ctrlPointController, 'line can not be null'); + $assert(point, 'point can not be null'); + this._ctrlPointControler = ctrlPointController; this._line = ctrlPointController._line; - var model = this._line.getModel(); this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone(); - this._oldControlPoint= this._ctrlPointControler.getOriginalCtrlPoint(point).clone(); + this._oldControlPoint = this._ctrlPointControler.getOriginalCtrlPoint(point).clone(); this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone(); - switch (point){ + switch (point) { case 0: this._wasCustom = this._line.getLine().isSrcControlPointCustom(); this._endPoint = this._line.getLine().getFrom().clone(); @@ -40,10 +39,9 @@ mindplot.commands.MoveControlPointCommand = new Class( this._id = mindplot.Command._nextUUID(); this._point = point; }, - execute: function(commandContext) - { + execute: function(commandContext) { var model = this._line.getModel(); - switch (this._point){ + switch (this._point) { case 0: model.setSrcCtrlPoint(this._controlPoint.clone()); this._line.setFrom(this._endPoint.x, this._endPoint.y); @@ -58,36 +56,35 @@ mindplot.commands.MoveControlPointCommand = new Class( this._line.setDestControlPoint(this._controlPoint.clone()); break; } - if(this._line.isOnFocus()){ + if (this._line.isOnFocus()) { this._line._refreshSelectedShape(); this._ctrlPointControler.setLine(this._line); } this._line.getLine().updateLine(this._point); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var line = this._line; var model = line.getModel(); - switch (this._point){ + switch (this._point) { case 0: - if($defined(this._oldControlPoint)){ + if ($defined(this._oldControlPoint)) { line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y); model.setSrcCtrlPoint(this._oldControlPoint.clone()); line.setSrcControlPoint(this._oldControlPoint.clone()); line.setIsSrcControlPointCustom(this._wasCustom); } - break; + break; case 1: - if($defined(this._oldControlPoint)){ + if ($defined(this._oldControlPoint)) { line.setTo(this._originalEndPoint.x, this._originalEndPoint.y); model.setDestCtrlPoint(this._oldControlPoint.clone()); line.setDestControlPoint(this._oldControlPoint.clone()); line.setIsDestControlPointCustom(this._wasCustom); } - break; + break; } this._line.getLine().updateLine(this._point); - if(this._line.isOnFocus()){ + if (this._line.isOnFocus()) { this._ctrlPointControler.setLine(line); line._refreshSelectedShape(); } diff --git a/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js index 344c7fa7..a265c8ce 100644 --- a/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js @@ -16,8 +16,7 @@ * limitations under the License. */ -mindplot.commands.RemoveIconFromTopicCommand = new Class( -{ +mindplot.commands.RemoveIconFromTopicCommand = new Class({ Extends:mindplot.Command, initialize: function(topicId, iconModel) { diff --git a/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js index 71e9cad0..2289ac30 100644 --- a/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js @@ -1,31 +1,28 @@ /* -* 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. -*/ + * 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. + */ -mindplot.commands.RemoveLinkFromTopicCommand =new Class( -{ +mindplot.commands.RemoveLinkFromTopicCommand = new Class({ Extends:mindplot.Command, - initialize: function(topicId) - { + initialize: function(topicId) { $assert(topicId, 'topicId can not be null'); this._selectedObjectsIds = topicId; }, - execute: function(commandContext) - { + execute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; this._url = topic._link.getUrl(); var updated = function() { @@ -33,11 +30,10 @@ mindplot.commands.RemoveLinkFromTopicCommand =new Class( }.bind(this); updated.delay(0); }, - undoExecute: function(commandContext) - { + undoExecute: function(commandContext) { var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var updated = function() { - topic.addLink(this._url,commandContext._designer); + topic.addLink(this._url, commandContext._designer); topic.updateNode(); }.bind(this); updated.delay(0); diff --git a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js index 8594719d..0840d903 100644 --- a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js @@ -16,8 +16,7 @@ * limitations under the License. */ -mindplot.commands.RemoveNoteFromTopicCommand = new Class( -{ +mindplot.commands.RemoveNoteFromTopicCommand = new Class({ Extends:mindplot.Command, initialize: function(topicId) { 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/mindplot/src/main/javascript/header.js b/mindplot/src/main/javascript/header.js index 81710eeb..28cb8e70 100644 --- a/mindplot/src/main/javascript/header.js +++ b/mindplot/src/main/javascript/header.js @@ -25,4 +25,5 @@ var mindplot = {}; mindplot.util = {}; mindplot.commands = {}; -mindplot.layout = {}; \ No newline at end of file +mindplot.layout = {}; +mindplot.widget = {}; \ No newline at end of file diff --git a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js b/mindplot/src/main/javascript/layout/OriginalLayoutManager.js index 55dceef0..fb08b1bd 100644 --- a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js +++ b/mindplot/src/main/javascript/layout/OriginalLayoutManager.js @@ -24,12 +24,13 @@ mindplot.layout.OriginalLayoutManager = new Class({ initialize:function(designer, options) { this.parent(designer, options); this._dragTopicPositioner = new mindplot.DragTopicPositioner(this); - // Init dragger manager. + + // Init drag manager. var workSpace = this.getDesigner().getWorkSpace(); this._dragger = this._buildDragManager(workSpace); // Add shapes to speed up the loading process ... - mindplot.DragTopic.initialize(workSpace); + mindplot.DragTopic.init(workSpace); }, prepareNode:function(node, children) { // Sort children by order to solve adding order in for OriginalLayoutManager... @@ -62,15 +63,19 @@ mindplot.layout.OriginalLayoutManager = new Class({ nodesByOrder = null; return node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE ? result : children; }, + _nodeResizeEvent:function(node) { }, + _nodeRepositionateEvent:function(node) { this.getTopicBoardForTopic(node).repositionate(); }, + getDragTopicPositioner : function() { return this._dragTopicPositioner; }, + _buildDragManager: function(workspace) { // Init dragger manager. var dragger = new mindplot.DragManager(workspace); @@ -115,11 +120,12 @@ mindplot.layout.OriginalLayoutManager = new Class({ return dragger; }, + registerListenersOnNode : function(topic) { // Register node listeners ... var designer = this.getDesigner(); topic.addEventListener('onfocus', function(event) { - designer.onObjectFocusEvent.attempt([topic, event], designer); + designer.onObjectFocusEvent(topic, event); }); // Add drag behaviour ... @@ -136,12 +142,15 @@ mindplot.layout.OriginalLayoutManager = new Class({ } }, + _createMainTopicBoard:function(node) { return new mindplot.MainTopicBoard(node, this); }, + _createCentralTopicBoard:function(node) { return new mindplot.CentralTopicBoard(node, this); }, + getClassName:function() { return mindplot.layout.OriginalLayoutManager.NAME; } diff --git a/mindplot/src/main/javascript/layout/boards/Board.js b/mindplot/src/main/javascript/layout/boards/Board.js index 0848db7f..86ccdb9f 100644 --- a/mindplot/src/main/javascript/layout/boards/Board.js +++ b/mindplot/src/main/javascript/layout/boards/Board.js @@ -1,7 +1,7 @@ mindplot.layout.boards = {}; mindplot.layout.boards.Board = new Class({ - + Implements: [Events,Options], options: { }, @@ -31,6 +31,3 @@ mindplot.layout.boards.Board = new Class({ }); mindplot.layout.boards.Board.NAME = "Board"; - -mindplot.layout.boards.Board.implement(new Events); -mindplot.layout.boards.Board.implement(new Options); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/FontFamilyPanel.js b/mindplot/src/main/javascript/widget/FontFamilyPanel.js new file mode 100644 index 00000000..9d5f5421 --- /dev/null +++ b/mindplot/src/main/javascript/widget/FontFamilyPanel.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +mindplot.widget.FontFamilyPanel = new Class({ + Extends : mindplot.widget.ToolbarPanel, + initialize : function(buttonId, model) { + this.parent(buttonId, model); + }, + + buildPanel: function() { + + var content = new Element("div", {'class':'toolbarPanel','id':'fontFamilyPanel'}); + content.innerHTML = '' + + '' + + '
Arial
' + + '
Tahoma
' + + '
Verdana
'; + + return content; + + } +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/FontSizePanel.js b/mindplot/src/main/javascript/widget/FontSizePanel.js new file mode 100644 index 00000000..34b30120 --- /dev/null +++ b/mindplot/src/main/javascript/widget/FontSizePanel.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +mindplot.widget.FontSizePanel = new Class({ + Extends : mindplot.widget.ToolbarPanel, + initialize : function(buttonId, model) { + this.parent(buttonId, model); + }, + + buildPanel: function() { + + var content = new Element("div", {'class':'toolbarPanel','id':'fontSizePanel'}); + content.innerHTML = '' + + '
Small
' + + '
Normal
' + + '
Large
' + + '
Huge
'; + + return content; + + } +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/IconPanel.js b/mindplot/src/main/javascript/widget/IconPanel.js new file mode 100644 index 00000000..24195717 --- /dev/null +++ b/mindplot/src/main/javascript/widget/IconPanel.js @@ -0,0 +1,141 @@ +/* + * 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. + */ + +mindplot.widget.IconPanel = new Class({ + Implements:[Options,Events], + options:{ + width:253, + initialWidth:0, + height:200, + panel:null, + onStart:Class.empty, + state:'close' + }, + + initialize:function(buttonId, model) { + this._buttonId = buttonId; + this._model = model; + + this.options.content = this._build(); + this.init(); + + }, + + init:function() { + var panel = new Element('div'); + var buttonElem = $(this._buttonId); + + var coord = buttonElem.getCoordinates(); + var top = buttonElem.getTop() + coord.height + 2; + var left = buttonElem.getLeft(); + + panel.setStyles({ + width:this.options.initialWidth, + height:0,position:'absolute', + top:top, + left:left, + background:'#e5e5e5', + border:'1px solid #BBB4D6', + zIndex:20, + overflow:'hidden'} + ); + + this.options.panel = panel; + this.options.content.inject(panel); + + this.options.content.addEvent('click', function() { + this.hide(); + }.bind(this)); + + panel.setStyle('opacity', 0); + panel.inject($(document.body)); + this.registerOpenPanel(); + }, + + show:function() { + this.fireEvent("show"); + if (this.options.state == 'close') { + if (!$defined(this.options.panel)) { + this.init(); + } + + var panel = this.options.panel; + panel.setStyles({ + border: '1px solid #636163', + opacity:100, + height:this.options.height, + width:this.options.width + }); + this.fireEvent('onStart'); + this.registerClosePanel(); + this.options.state = 'open'; + + } + }, + + hide:function() { + if (this.options.state == 'open') { + // Magic, disappear effect ;) + this.options.panel.setStyles({border: '1px solid transparent', opacity:0}); + this.registerOpenPanel(); + this.options.state = 'close'; + } + }, + + registerOpenPanel:function() { + $(this._buttonId).removeEvents('click'); + $(this._buttonId).addEvent('click', function() { + this.show(); + }.bind(this)); + }, + + registerClosePanel:function() { + $(this._buttonId).removeEvents('click'); + $(this._buttonId).addEvent('click', function() { + this.hide(); + }.bind(this)); + } , + + _build : function() { + var content = new Element('div').setStyles({width:253,height:200,padding:5}); + var count = 0; + for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i = i + 1) { + var familyIcons = mindplot.ImageIcon.prototype.ICON_FAMILIES[i].icons; + for (var j = 0; j < familyIcons.length; j = j + 1) { + // Separate icons by line ... + var familyContent; + if ((count % 12) == 0) { + familyContent = new Element('div').inject(content); + } + + var iconId = familyIcons[j]; + var img = new Element('img').setStyles({width:16,height:16,padding:"0px 2px"}).inject(familyContent); + img.id = iconId; + img.src = mindplot.ImageIcon.prototype._getImageUrl(iconId); + + img.addEvent('click', function() { + this._model.setValue(img.id); + }.bind(this)); + + count = count + 1; + } + } + return content; + } + +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js new file mode 100644 index 00000000..8205d1a6 --- /dev/null +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -0,0 +1,150 @@ +/* + * 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. + */ + +mindplot.widget.Menu = new Class({ + initialize : function(designer) { + this._designer = designer; + this._toolbarElems = []; + this._colorPickers = []; + + var fontFamilyModel = { + getValue: function() { + var nodes = designer.getSelectedNodes(); + var length = nodes.length; + if (length == 1) { + return nodes[0].getFontFamily(); + } + }, + + setValue: function(value) { + designer.setFont2SelectedNode(value); + + } + }; + var fontFamilyPanel = new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel); + fontFamilyPanel.addEvent('show',function(){this.clear()}.bind(this)); + this._toolbarElems.push(fontFamilyPanel); + + var fontSizeModel = { + getValue: function() { + var nodes = designer.getSelectedNodes(); + var length = nodes.length; + if (length == 1) { + return nodes[0].getFontSize(); + } + }, + setValue: function(value) { + designer.setFontSize2SelectedNode(value); + } + }; + var fontSizePanel = new mindplot.widget.FontSizePanel("fontSize", fontSizeModel); + fontSizePanel.addEvent('show',function(){this.clear()}.bind(this)); + this._toolbarElems.push(fontSizePanel); + + var topicShapeModel = { + getValue: function() { + var nodes = designer.getSelectedNodes(); + var length = nodes.length; + if (length == 1) { + return nodes[0].getShapeType(); + } + }, + setValue: function(value) { + designer.setShape2SelectedNode(value); + } + }; + var topicShapePanel = new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel); + topicShapePanel.addEvent('show',function(){this.clear()}.bind(this)); + this._toolbarElems.push(topicShapePanel); + + // Create icon panel dialog ... + var topicIconModel = { + getValue: function() { + return null; + }, + setValue: function(value) { + designer.addIconType2SelectedNode(value); + } + }; + var iconPanel = new mindplot.widget.IconPanel('topicIcon', topicIconModel); + iconPanel.addEvent('show',function(){this.clear()}.bind(this)); + this._toolbarElems.push(iconPanel); + + + var topicColorPicker = new MooRainbow('topicColor', { + id: 'topicColor', + imgPath: '../images/', + startColor: [255, 255, 255], + onInit: function() { + this.clear(); + }.bind(this), + + onChange: function(color) { + designer.setBackColor2SelectedNode(color.hex); + }, + onComplete: function() { + this.clear(); + }.bind(this) + }); + this._colorPickers.push(topicColorPicker); + + var borderColorPicker = new MooRainbow('topicBorder', { + id: 'topicBorder', + imgPath: '../images/', + startColor: [255, 255, 255], + onInit: function() { + this.clear(); + }.bind(this), + onChange: function(color) { + designer.setBorderColor2SelectedNode(color.hex); + }, + onComplete: function() { + this.clear(); + }.bind(this) + + }); + this._colorPickers.push(borderColorPicker); + + var fontColorPicker = new MooRainbow('fontColor', { + id: 'fontColor', + imgPath: '../images/', + startColor: [255, 255, 255], + onInit: function() { + this.clear(); + }.bind(this), + onChange: function(color) { + designer.setFontColor2SelectedNode(color.hex); + }, + onComplete: function() { + this.clear(); + }.bind(this) + }); + this._colorPickers.push(fontColorPicker); + }, + + clear : function() { + this._toolbarElems.forEach(function(elem) { + elem.hide(); + }); + + this._colorPickers.forEach(function(elem) { + $clear(elem); + elem.hide(); + }); + } +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/ToolbarPanel.js b/mindplot/src/main/javascript/widget/ToolbarPanel.js new file mode 100644 index 00000000..17df4b6d --- /dev/null +++ b/mindplot/src/main/javascript/widget/ToolbarPanel.js @@ -0,0 +1,89 @@ +/* + * 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. + */ + +mindplot.widget.ToolbarPanel = new Class({ + Implements:[Events], + initialize : function(buttonId, model) { + $assert(buttonId, "buttonId can not be null"); + $assert(model, "model can not be null"); + this._model = model; + this._panelId = this.initPanel(buttonId); + }, + + buildPanel : function() { + throw "Method must be implemented"; + }.protect(), + + initPanel: function (buttonId) { + $assert(buttonId, "buttonId can not be null"); + + var panelElem = this.buildPanel(); + var buttonElem = $(buttonId); + + // Add panel content .. + panelElem.setStyle('display', 'none'); + panelElem.inject(buttonElem); + + // Register on toolbar elements ... + var menuElems = panelElem.getElements('div'); + menuElems.forEach(function(elem) { + elem.addEvent('click', function() { + var value = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id; + this._model.setValue(value); + this.hide(); + }.bind(this)); + }.bind(this)); + + // Font family event handling .... + buttonElem.addEvent('click', function() { + + // Is the panel being displayed ? + if (this.isVisible()) { + this.hide(); + } else { + this.show(); + } + + }.bind(this)); + return panelElem.id; + }, + + show : function() { + this.fireEvent('show'); + + var menuElems = $(this._panelId).getElements('div'); + var value = this._model.getValue(); + menuElems.forEach(function(elem) { + var elemValue = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id; + if (elemValue == value) + elem.className = "toolbarPanelLinkSelectedLink"; + else + elem.className = "toolbarPanelLink"; + }); + $(this._panelId).setStyle('display', 'block'); + + }, + + hide : function() { + $(this._panelId).setStyle('display', 'none'); + }, + + isVisible : function() { + return $(this._panelId).getStyle('display') == 'block'; + } +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/widget/TopicShapePanel.js b/mindplot/src/main/javascript/widget/TopicShapePanel.js new file mode 100644 index 00000000..c693d6e4 --- /dev/null +++ b/mindplot/src/main/javascript/widget/TopicShapePanel.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +mindplot.widget.TopicShapePanel = new Class({ + Extends : mindplot.widget.ToolbarPanel, + initialize : function(buttonId, model) { + this.parent(buttonId, model); + }, + + buildPanel: function() { + + var content = new Element("div", {'class':'toolbarPanel','id':'topicShapePanel'}); + content.innerHTML = '' + + '
Rectangle
' + + '
Rounded Rectangle
' + + '
Line
' + + ''; + + return content; + + } +}); \ No newline at end of file diff --git a/wise-doc/src/main/webapp/css/editor.css b/wise-doc/src/main/webapp/css/editor.css index d0d55023..28ae4ea8 100644 --- a/wise-doc/src/main/webapp/css/editor.css +++ b/wise-doc/src/main/webapp/css/editor.css @@ -24,7 +24,7 @@ html { top: 30px; } -#waitingContainer,#errorContainer { +#waitingContainer, #errorContainer { position: relative; top: 80px; height: 120px; /*background: whitesmoke;*/ @@ -33,7 +33,7 @@ html { padding: 15px; width: 100%; border: 1px solid; - border-color:#a9a9a9; + border-color: #a9a9a9; } @@ -62,7 +62,7 @@ html { vertical-align: text-bottom; height: 30px; float: right; - padding-left:120px; + padding-left: 120px; } #waitingContainer .loadingIcon { @@ -123,7 +123,7 @@ html { color: #ffffff; border-bottom: 2px solid black; position: absolute; - top: 35px; + top: 0; } div#toolbar .buttonContainer { @@ -134,9 +134,8 @@ div#toolbar .buttonContainer { .buttonContainer fieldset { border: 1px solid #BBB4D6; - padding: 2px; - margin: 1px; - padding-bottom: 4px; + padding: 2px 2px 4px; + margin: 8px 1px 1px; } .buttonContainer legend { @@ -158,6 +157,11 @@ div#toolbar .button { margin: 0 2px 2px 2px; cursor: pointer; text-align: center; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -o-user-select: none; + user-select: none; } div#toolbar .comboButton { @@ -190,7 +194,7 @@ div#toolbar .toolbarLabel { top: 55%; text-align: center; width: 34px; - height: 36px; + height: 10px; font-size: 10px; } @@ -209,15 +213,15 @@ div#file, div#zoom, div#node, div#font, div#share { } div#zoom { - left: 229px; + left: 84px; } div#node { - left: 311px; + left: 165px; } div#font { - left: 679px; /*left:581px;*/ + left: 532px; /*left:581px;*/ } div#share { @@ -250,15 +254,15 @@ div#redoEdition { #export { background: url(../images/file_export.png) no-repeat center top; - position:relative; + position: relative; } #exportAnchor { - position:absolute; - width:100%; - height:100%; - top:0; - left:0; + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; } div#zoomIn { @@ -380,7 +384,13 @@ div#fontColor { display: none; position: absolute; z-index: 4; - top: 71px; + top: 53px; + text-align: left; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -o-user-select: none; + user-select: none; } div.toolbarPanelLink { @@ -547,7 +557,7 @@ div#tabs { div.tabContent { clear: left; width: 100%; - height: 63px; + height: 50px; border-bottom: 1px solid #bbb4d6; border-top: 1px solid #bbb4d6; background: #E5E5E5; @@ -608,7 +618,7 @@ ol#toc span { #mindplot { position: relative; - top: 103px; + top: 53px; left: 0; width: 100%; border: 0; @@ -722,21 +732,21 @@ div#small_error_icon { } div#toolbar .topicRelation { - width:56px; + width: 56px; background: url(../images/topic_relationship.png) no-repeat center top; z-index: 4; } div#toolbar .topicRelation:hover { - width:56px; + width: 56px; background: url(../images/topic_relationship.png) no-repeat center top; z-index: 4; } -div#toolbar .relationshiplabel{ - width:56px; +div#toolbar .relationshiplabel { + width: 56px; } .nicEdit-main { - outline:none; + outline: none; } \ No newline at end of file diff --git a/wise-doc/src/main/webapp/html/collab.html b/wise-doc/src/main/webapp/html/collab.html new file mode 100644 index 00000000..b4e47abb --- /dev/null +++ b/wise-doc/src/main/webapp/html/collab.html @@ -0,0 +1,47 @@ + + + + + +Este es este no ? + + + \ No newline at end of file diff --git a/wise-doc/src/main/webapp/html/editor.html b/wise-doc/src/main/webapp/html/editor.html index 872eb0bb..47c80791 100644 --- a/wise-doc/src/main/webapp/html/editor.html +++ b/wise-doc/src/main/webapp/html/editor.html @@ -13,6 +13,8 @@ + + @@ -24,6 +26,7 @@ +
-
- - - - -
- -
- - - - -
- -
- - - - - -
-
-
-
-
- - SYMB_FILE - -
-
-

- SYMB_SAVE -

-
+
+
+
+
+
+

Undo

+
+
+
+
+

Redo

+
+
+
-
-
-

- SYMB_CLOSE -

-
+
+
+
+
+

In

+
+
+
+
+

Out

+
+
+
-
-
-

- SYMB_UNDO -

-
+
+
+
+
+

Shape

+
+
+
+
+

Add

+
+
+
+
+

Delete

+
+
+
+
+

Border

+
+
+
+
+

Color

+
+
+
+
+

Icon

+
+
+
+
+

Note

+
+
+ +
+
+

Relationship

+
+
+
-
-
-

- SYMB_REDO -

-
+
+
+
+
+

Style

+
+
+
+
+

Size

+
+
+
+
+

Bold

+
+
+
+
+

Italic

+
+
+
+
+

Color

+
+
+
- -
-
-

- SYMB_PRINT -

-
-
- -
-
-

- SYMB_EXPORT -

-
- - -
-
-
-
-
- - SYMB_ZOOM - -
-
-

- SYMB_IN -

-
-
-
-
-

- SYMB_OUT -

-
-
-
-
-
-
- - SYMB_TOPIC - -
-
-

- SYMB_SHAPE -

-
-
-
-
-

- SYMB_ADD -

-
-
-
-
-

- SYMB_DELETE -

-
-
-
-
-

- SYMB_BORDER -

-
-
-
-
-

- SYMB_COLOR -

-
-
-
-
-

- SYMB_ICON -

-
-
-
-
-

- SYMB_NOTE -

-
-
- -
-
-

- SYMB_TOPIC_RELATIONSHIP -

-
-
-
-
-
-
- - SYMB_FONT - -
-
-

- SYMB_TYPE -

-
-
-
-
-

- SYMB_SIZE -

-
-
-
-
-

- SYMB_BOLD -

-
-
-
-
-

- SYMB_ITALIC -

-
-
-
-
-

- SYMB_COLOR -

-
-
-
-
-
- -
- - SYMB_COLLABORATION - -
-
-

- SYMB_TAG -

-
-
-
-
-

- SYMB_SHARE -

-
-
-
-
-

- SYMB_PUBLISH -

-
-
-
-
-

- SYMB_HISTORY -

-
-
-
-
-
+
diff --git a/wise-doc/src/main/webapp/images/bin.png b/wise-doc/src/main/webapp/images/bin.png new file mode 100644 index 00000000..ebad933c Binary files /dev/null and b/wise-doc/src/main/webapp/images/bin.png differ diff --git a/wise-doc/src/main/webapp/js/editor.js b/wise-doc/src/main/webapp/js/editor.js index da059278..9c0aa37e 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("../js/mindplot.svg.js"); - var designer = null; // CSS helper functions @@ -180,12 +177,11 @@ function afterMindpotLibraryLoading() { }); } - var iconChooser = buildIconChooser(); -// iconPanel = new IconPanel({button:$('topicIcon'), onStart:cleanScreenEvent, content:iconChooser}); - // Register Events ... - $(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer)); - $("ffoxWorkarroundInput").addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer)); - // + // Register Key Events ... + $(document).addEvent('keydown', designer.keyEventHandler.bind(designer)); + $("ffoxWorkarroundInput").addEvent('keydown', designer.keyEventHandler.bind(designer)); + + // Register toolbar events ... $('zoomIn').addEvent('click', function(event) { designer.zoomIn(); }); @@ -202,7 +198,7 @@ function afterMindpotLibraryLoading() { designer.redo(); }); - designer.addEventListener("change", function(event) { + designer.addEventListener("modelUpdate", function(event) { if (event.undoSteps > 0) { $("undoEdition").setStyle("background-image", "url(../images/file_undo.png)"); } else { @@ -222,42 +218,10 @@ function afterMindpotLibraryLoading() { }); $('deleteTopic').addEvent('click', function(event) { - var topics = designer.getSelectedNodes(); designer.deleteCurrentNode(); }); - var context = this; - /*var colorPicker1 = new MooRainbow('topicColor', { - id: 'topicColor', - imgPath: '../images/', - startColor: [255, 255, 255], - onInit: function(color) { - cleanScreenEvent.bind(context).attempt(); - setCurrentColorPicker.attempt(colorPicker1, context); - }, - onChange: function(color) { - designer.setBackColor2SelectedNode(color.hex); - }, - onComplete: function(color) { - removeCurrentColorPicker.attempt(colorPicker1, context); - } - }); - var colorPicker2 = new MooRainbow('topicBorder', { - id: 'topicBorder', - imgPath: '../images/', - startColor: [255, 255, 255], - onInit: function(color) { - cleanScreenEvent.bind(context).attempt(); - setCurrentColorPicker.attempt(colorPicker2, context); - }, - onChange: function(color) { - designer.setBorderColor2SelectedNode(color.hex); - }, - onComplete: function(color) { - removeCurrentColorPicker.attempt(colorPicker2, context); - } - });*/ - $('topicLink').addEvent('click', function(event) { + $('topicLink').addEvent('click', function() { designer.addLink2SelectedNode(); }); @@ -266,73 +230,32 @@ function afterMindpotLibraryLoading() { designer.addRelationShip2SelectedNode(event); }); - $('topicNote').addEvent('click', function(event) { + $('topicNote').addEvent('click', function() { designer.addNote2SelectedNode(); }); - - $('fontBold').addEvent('click', function(event) { + $('fontBold').addEvent('click', function() { designer.setWeight2SelectedNode(); }); - $('fontItalic').addEvent('click', function(event) { + $('fontItalic').addEvent('click', function() { designer.setStyle2SelectedNode(); }); - /*var colorPicker3 = new MooRainbow('fontColor', { - id: 'fontColor', - imgPath: '../images/', - startColor: [255, 255, 255], - onInit: function(color) { - cleanScreenEvent.bind(context).attempt(); - setCurrentColorPicker.attempt(colorPicker3, context); - }, - onChange: function(color) { - designer.setFontColor2SelectedNode(color.hex); - }, - onComplete: function(color) { - removeCurrentColorPicker.attempt(colorPicker3, context); - } - });*/ - - // Save event handler .... - var saveButton = $('saveButton'); - saveButton.addEvent('click', function(event) { - - - saveButton.setStyle('cursor', 'wait'); - var saveFunc = function() { - designer.save(function() { - var monitor = core.Monitor.getInstance(); - monitor.logMessage('Save completed successfully'); - saveButton.setStyle('cursor', 'pointer'); - }, true); - } - saveFunc.delay(1); - - }); - - var discardButton = $('discardButton'); - discardButton.addEvent('click', function(event) { - - displayLoading(); - window.document.location = "mymaps.htm"; - }); - // To prevent the user from leaving the page with changes ... - window.onbeforeunload = function confirmExit() { + window.onbeforeunload = function () { if (designer.needsSave()) { designer.save(null, false) } - } + }; + var menu = new mindplot.widget.Menu(designer); - // Build panels ... - fontFamilyPanel(); - shapeTypePanel(); - fontSizePanel(); + // If a node has focus, focus can be move to another node using the keys. + designer._cleanScreen = function(){menu.clear()}; - // If not problem has occured, I close the dialog ... + + // If not problem has arisen, close the dialog ... var closeDialog = function() { if (!window.hasUnexpectedErrors) { @@ -341,44 +264,6 @@ function afterMindpotLibraryLoading() { }.delay(500); } -function buildIconChooser() { - var content = new Element('div').setStyles({width:253,height:200,padding:5}); - var count = 0; - for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i = i + 1) { - var familyIcons = mindplot.ImageIcon.prototype.ICON_FAMILIES[i].icons; - for (var j = 0; j < familyIcons.length; j = j + 1) { - // Separate icons by line ... - var familyContent; - if ((count % 12) == 0) { - familyContent = new Element('div').inject(content); - } - - - var iconId = familyIcons[j]; - var img = new Element('img').setStyles({width:16,height:16,padding:"0px 2px"}).inject(familyContent); - img.id = iconId; - img.src = mindplot.ImageIcon.prototype._getImageUrl(iconId); - img.addEvent('click', function(event, id) { - designer.addImage2SelectedNode(this.id); - }.bindWithEvent(img)); - count = count + 1; - } - - } - - return content; -} - - - -function setCurrentColorPicker(colorPicker) { - this.currentColorPicker = colorPicker; -} - -function removeCurrentColorPicker(colorPicker) { - $clear(this.currentColorPicker); -} - function buildMindmapDesigner() { // Initialize message logger ... // var monitor = new core.Monitor($('msgLoggerContainer'), $('msgLogger')); @@ -391,7 +276,7 @@ function buildMindmapDesigner() { var screenHeight = window.getHeight(); // header - footer - screenHeight = screenHeight - 90 - 61; + screenHeight = screenHeight - 115; // body margin ... editorProperties.width = screenWidth; @@ -407,143 +292,80 @@ function buildMindmapDesigner() { function buildStandaloneMindmapDesigner(){ designer.loadFromXML(mapId, mapXml); - - // If a node has focus, focus can be move to another node using the keys. - designer._cleanScreen = cleanScreenEvent.bind(this); } function buildCollaborativeMindmapDesigner(){ if($wise_collaborationManager.isCollaborativeFrameworkReady()){ designer.loadFromCollaborativeModel($wise_collaborationManager); - // If a node has focus, focus can be move to another node using the keys. - designer._cleanScreen = cleanScreenEvent.bind(this); }else{ $wise_collaborationManager.setWiseReady(true); } } -function createColorPalette(container, onSelectFunction, event) { - cleanScreenEvent(); - _colorPalette = new core.ColorPicker(); - _colorPalette.onSelect = function(color) { - onSelectFunction.call(this, color); - cleanScreenEvent(); - }; +//######################### 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) { - // dojo.event.kwConnect({srcObj: this._colorPalette,srcFunc:"onColorSelect",targetObj:this._colorPalette, targetFunc:"onSelect", once:true}); - var mouseCoords = core.Utils.getMousePosition(event); - var colorPaletteElement = $("colorPalette"); - colorPaletteElement.setStyle('left', (mouseCoords.x - 80) + "px"); - colorPaletteElement.setStyle('display', "block"); -} -; + // Collect JS Urls ... + var concatRoot = responseXML.getElementsByTagName('concat'); + var fileSetArray = Array.filter(concatRoot[0].childNodes, function(elem) { + return elem.nodeType == Node.ELEMENT_NODE + }); -function cleanScreenEvent() { - /*if (this.currentColorPicker) { - this.currentColorPicker.hide(); - }*/ - $("fontFamilyPanel").setStyle('display', "none"); - $("fontSizePanel").setStyle('display', "none"); - $("topicShapePanel").setStyle('display', "none"); -// iconPanel.close(); -} + 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('/')))); + } + ); -function fontFamilyPanel() { - var supportedFonts = ['times','arial','tahoma','verdana']; - var updateFunction = function(value) { - value = value.charAt(0).toUpperCase() + value.substring(1, value.length); - designer.setFont2SelectedNode(value); - }; + // Load all JS dynamically .... + jsUrls = jsUrls.reverse(); - var onFocusValue = function(selectedNode) { - return selectedNode.getFontFamily(); - }; + 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) + } + }); + } + } - buildPanel('fontFamily', 'fontFamilyPanel', supportedFonts, updateFunction, onFocusValue); -} - -function shapeTypePanel() { - var shapeTypePanel = ['rectagle','rounded_rectagle','line','elipse']; - var updateFunction = function(value) { - designer.setShape2SelectedNode(value.replace('_', ' ')); - }; - - var onFocusValue = function(selectedNode) { - - return selectedNode.getShapeType().replace(' ', '_'); - }; - - buildPanel('topicShape', 'topicShapePanel', shapeTypePanel, updateFunction, onFocusValue); -} - -function fontSizePanel() { - var shapeTypePanel = ['small','normal','large','huge']; - var map = {small:'6',normal:'8',large:'10',huge:'15'}; - var updateFunction = function(value) { - var nodes = designer.getSelectedNodes(); - var value = map[value]; - designer.setFontSize2SelectedNode(value); - }; - - var onFocusValue = function(selectedNode) { - var fontSize = selectedNode.getFontSize(); - var result = ""; - if (fontSize <= 6) { - result = 'small'; - } else if (fontSize <= 8) { - result = 'normal'; - } else if (fontSize <= 10) { - result = 'large'; - } else if (fontSize >= 15) { - result = 'huge'; + jsRecLoad(jsUrls); + }, + onFailure: function() { + console.log('Sorry, your request failed :('); } - return result; - }; - buildPanel('fontSize', 'fontSizePanel', shapeTypePanel, updateFunction, onFocusValue); -} - -function buildPanel(buttonElemId, elemLinksContainer, elemLinkIds, updateFunction, onFocusValue) { - // Font family event handling .... - $(buttonElemId).addEvent('click', function(event) { - var container = $(elemLinksContainer); - var isRendered = container.getStyle('display') == 'block'; - cleanScreenEvent(); - - // Restore default css. - for (var i = 0; i < elemLinkIds.length; i++) { - var elementId = elemLinkIds[i]; - $(elementId).className = 'toolbarPanelLink'; - } - - // Select current element ... - var nodes = designer.getSelectedNodes(); - var lenght = nodes.length; - if (lenght == 1) { - var selectedNode = nodes[0]; - var selectedElementId = onFocusValue(selectedNode); - selectedElementId = selectedElementId.toLowerCase(); - var selectedElement = $(selectedElementId); - selectedElement.className = 'toolbarPanelLinkSelectedLink'; - } - - container.setStyle('display', 'block'); - - var mouseCoords = core.Utils.getMousePosition(event); - if (!isRendered) { - container.setStyle('left', (mouseCoords.x - 10) + "px"); - } - }); + request.send(); - var fontOnClick = function(event) { - var value = this.getAttribute('id'); - updateFunction(value); - cleanScreenEvent(); - }; +} - // Register event listeners on elements ... - for (var i = 0; i < elemLinkIds.length; i++) { - var elementId = elemLinkIds[i]; - $(elementId).addEvent('click', fontOnClick.bind($(elementId))); - } +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='" - (end) - - Returns: - email=bob@bob.com&zipCode=90210 - */ - - toQueryString: function() { - var queryString = []; - this.getFormElements().each(function(el) { - var name = el.name; - var value = el.getValue(); - if (value === false || !name || el.disabled) return; - var qs = function(val) { - queryString.push(name + '=' + encodeURIComponent(val)); - }; - if ($type(value) == 'array') value.each(qs); - else qs(value); - }); - return queryString.join('&'); - } - -}); - -/* -Script: Element.Dimensions.js - Contains Element prototypes to deal with Element size and position in space. - -Note: - The functions in this script require n XHTML doctype. - -License: - MIT-style license. -*/ - -/* -Class: Element - Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>. -*/ - -Element.extend({ - -/* - Property: scrollTo - Scrolls the element to the specified coordinated (if the element has an overflow) - - Arguments: - x - the x coordinate - y - the y coordinate - - Example: - >$('myElement').scrollTo(0, 100) - */ - - scrollTo: function(x, y) { - this.scrollLeft = x; - this.scrollTop = y; - }, - -/* - Property: getSize - Return an Object representing the size/scroll values of the element. - - Example: - (start code) - $('myElement').getSize(); - (end) - - Returns: - (start code) - { - 'scroll': {'x': 100, 'y': 100}, - 'size': {'x': 200, 'y': 400}, - 'scrollSize': {'x': 300, 'y': 500} - } - (end) - */ - - getSize: function() { - return { - 'scroll': {'x': this.scrollLeft, 'y': this.scrollTop}, - 'size': {'x': this.offsetWidth, 'y': this.offsetHeight}, - 'scrollSize': {'x': this.scrollWidth, 'y': this.scrollHeight} - }; - }, - -/* - Property: getPosition - Returns the real offsets of the element. - - Arguments: - overflown - optional, an array of nested scrolling containers for scroll offset calculation, use this if your element is inside any element containing scrollbars - - Example: - >$('element').getPosition(); - - Returns: - >{x: 100, y:500}; - */ - - getPosition: function(overflown) { - overflown = overflown || []; - var el = this, left = 0, top = 0; - do { - left += el.offsetLeft || 0; - top += el.offsetTop || 0; - el = el.offsetParent; - } while (el); - overflown.each(function(element) { - left -= element.scrollLeft || 0; - top -= element.scrollTop || 0; - }); - return {'x': left, 'y': top}; - }, - -/* - Property: getTop - Returns the distance from the top of the window to the Element. - - Arguments: - overflown - optional, an array of nested scrolling containers, see Element::getPosition - */ - - getTop: function(overflown) { - return this.getPosition(overflown).y; - }, - -/* - Property: getLeft - Returns the distance from the left of the window to the Element. - - Arguments: - overflown - optional, an array of nested scrolling containers, see Element::getPosition - */ - - getLeft: function(overflown) { - return this.getPosition(overflown).x; - }, - -/* - Property: getCoordinates - Returns an object with width, height, left, right, top, and bottom, representing the values of the Element - - Arguments: - overflown - optional, an array of nested scrolling containers, see Element::getPosition - - Example: - (start code) - var myValues = $('myElement').getCoordinates(); - (end) - - Returns: - (start code) - { - width: 200, - height: 300, - left: 100, - top: 50, - right: 300, - bottom: 350 - } - (end) - */ - - getCoordinates: function(overflown) { - var position = this.getPosition(overflown); - var obj = { - 'width': this.offsetWidth, - 'height': this.offsetHeight, - 'left': position.x, - 'top': position.y - }; - obj.right = obj.left + obj.width; - obj.bottom = obj.top + obj.height; - return obj; - } - -}); - -/* -Script: Window.DomReady.js - Contains the custom event domready, for window. - -License: - MIT-style license. -*/ - -/* Section: Custom Events */ - -/* -Event: domready - executes a function when the dom tree is loaded, without waiting for images. Only works when called from window. - -Credits: - (c) Dean Edwards/Matthias Miller/John Resig, remastered for MooTools. - -Arguments: - fn - the function to execute when the DOM is ready - -Example: - > window.addEvent('domready', function(){ - > alert('the dom is ready'); - > }); -*/ - -Element.Events.domready = { - - add: function(fn) { - if (window.loaded) { - fn.call(this); - return; - } - var domReady = function() { - if (window.loaded) return; - window.loaded = true; - window.timer = $clear(window.timer); - this.fireEvent('domready'); - }.bind(this); - if (document.readyState && window.webkit) { - window.timer = function() { - if (['loaded','complete'].contains(document.readyState)) domReady(); - }.periodical(50); - } else if (document.readyState && window.ie) { - if (!$('ie_ready')) { - var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)'; - document.write(' - (end) - */ - - send: function(options) { - return new Ajax(this.getProperty('action'), $merge({data: this.toQueryString()}, options, {method: 'post'})).request(); - } - -}); - -/* -Script: Cookie.js - A cookie reader/creator - -Credits: - based on the functions by Peter-Paul Koch (http://quirksmode.org) -*/ - -/* -Class: Cookie - Class for creating, getting, and removing cookies. -*/ - -var Cookie = new Abstract({ - - options: { - domain: false, - path: false, - duration: false, - secure: false - }, - -/* - Property: set - Sets a cookie in the browser. - - Arguments: - key - the key (name) for the cookie - value - the value to set, cannot contain semicolons - options - an object representing the Cookie options. See Options below. Default values are stored in Cookie.options. - - Options: - domain - the domain the Cookie belongs to. If you want to share the cookie with pages located on a different domain, you have to set this value. Defaults to the current domain. - path - the path the Cookie belongs to. If you want to share the cookie with pages located in a different path, you have to set this value, for example to "/" to share the cookie with all pages on the domain. Defaults to the current path. - duration - the duration of the Cookie before it expires, in days. - If set to false or 0, the cookie will be a session cookie that expires when the browser is closed. This is default. - secure - Stored cookie information can be accessed only from a secure environment. - - Returns: - An object with the options, the key and the value. You can give it as first parameter to Cookie.remove. - - Example: - >Cookie.set('username', 'Harald'); // session cookie (duration is false), or ... - >Cookie.set('username', 'JackBauer', {duration: 1}); // save this for 1 day - - */ - - set: function(key, value, options) { - options = $merge(this.options, options); - value = encodeURIComponent(value); - if (options.domain) value += '; domain=' + options.domain; - if (options.path) value += '; path=' + options.path; - if (options.duration) { - var date = new Date(); - date.setTime(date.getTime() + options.duration * 24 * 60 * 60 * 1000); - value += '; expires=' + date.toGMTString(); - } - if (options.secure) value += '; secure'; - document.cookie = key + '=' + value; - return $extend(options, {'key': key, 'value': value}); - }, - -/* - Property: get - Gets the value of a cookie. - - Arguments: - key - the name of the cookie you wish to retrieve. - - Returns: - The cookie string value, or false if not found. - - Example: - >Cookie.get("username") //returns JackBauer - */ - - get: function(key) { - var value = document.cookie.match('(?:^|;)\\s*' + key.escapeRegExp() + '=([^;]*)'); - return value ? decodeURIComponent(value[1]) : false; - }, - -/* - Property: remove - Removes a cookie from the browser. - - Arguments: - cookie - the name of the cookie to remove or a previous cookie (for domains) - options - optional. you can also pass the domain and path here. Same as options in - - Examples: - >Cookie.remove('username') //bye-bye JackBauer, cya in 24 hours - > - >var myCookie = Cookie.set('username', 'Aaron', {domain: 'mootools.net'}); // Cookie.set returns an object with all values need to remove the cookie - >Cookie.remove(myCookie); - */ - - remove: function(cookie, options) { - if ($type(cookie) == 'object') this.set(cookie.key, '', $merge(cookie, {duration: -1})); - else this.set(cookie, '', $merge(options, {duration: -1})); - } - -}); - -/* -Script: Json.js - Simple Json parser and Stringyfier, See: - -License: - MIT-style license. -*/ - -/* -Class: Json - Simple Json parser and Stringyfier, See: -*/ - -var Json = { - -/* - Property: toString - Converts an object to a string, to be passed in server-side scripts as a parameter. Although its not normal usage for this class, this method can also be used to convert functions and arrays to strings. - - Arguments: - obj - the object to convert to string - - Returns: - A json string - - Example: - (start code) - Json.toString({apple: 'red', lemon: 'yellow'}); '{"apple":"red","lemon":"yellow"}' - (end) - */ - - toString: function(obj) { - switch ($type(obj)) { - case 'string': - return '"' + obj.replace(/(["\\])/g, '\\$1') + '"'; - case 'array': - return '[' + obj.map(Json.toString).join(',') + ']'; - case 'object': - var string = []; - for (var property in obj) string.push(Json.toString(property) + ':' + Json.toString(obj[property])); - return '{' + string.join(',') + '}'; - case 'number': - if (isFinite(obj)) break; - case false: - return 'null'; - } - return String(obj); - }, - -/* - Property: evaluate - converts a json string to an javascript Object. - - Arguments: - str - the string to evaluate. if its not a string, it returns false. - secure - optionally, performs syntax check on json string. Defaults to false. - - Credits: - Json test regexp is by Douglas Crockford . - - Example: - >var myObject = Json.evaluate('{"apple":"red","lemon":"yellow"}'); - >//myObject will become {apple: 'red', lemon: 'yellow'} - */ - - evaluate: function(str, secure) { - return (($type(str) != 'string') || (secure && !str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/))) ? null : eval('(' + str + ')'); - } - -}; - -/* -Script: Json.Remote.js - Contains . - -License: - MIT-style license. -*/ - -/* -Class: Json.Remote - Wrapped XHR with automated sending and receiving of Javascript Objects in Json Format. - Inherits methods, properties, options and events from . - -Arguments: - url - the url you want to send your object to. - options - see options - -Example: - this code will send user information based on name/last name - (start code) - var jSonRequest = new Json.Remote("http://site.com/tellMeAge.php", {onComplete: function(person){ - alert(person.age); //is 25 years - alert(person.height); //is 170 cm - alert(person.weight); //is 120 kg - }}).send({'name': 'John', 'lastName': 'Doe'}); - (end) -*/ - -Json.Remote = XHR.extend({ - - initialize: function(url, options) { - this.url = url; - this.addEvent('onSuccess', this.onComplete); - this.parent(options); - this.setHeader('X-Request', 'JSON'); - }, - - send: function(obj) { - return this.parent(this.url, 'json=' + Json.toString(obj)); - }, - - onComplete: function() { - this.fireEvent('onComplete', [Json.evaluate(this.response.text, this.options.secure)]); - } - -}); - -/* -Script: Assets.js - provides dynamic loading for images, css and javascript files. - -License: - MIT-style license. -*/ - -var Asset = new Abstract({ - -/* - Property: javascript - Injects a javascript file in the page. - - Arguments: - source - the path of the javascript file - properties - some additional attributes you might want to add to the script element - - Example: - > new Asset.javascript('/scripts/myScript.js', {id: 'myScript'}); - */ - - javascript: function(source, properties) { - properties = $merge({ - 'onload': Class.empty - }, properties); - var script = new Element('script', {'src': source}).addEvents({ - 'load': properties.onload, - 'readystatechange': function() { - if (this.readyState == 'complete') this.fireEvent('load'); - } - }); - delete properties.onload; - return script.setProperties(properties).inject(document.head); - }, - -/* - Property: css - Injects a css file in the page. - - Arguments: - source - the path of the css file - properties - some additional attributes you might want to add to the link element - - Example: - > new Asset.css('/css/myStyle.css', {id: 'myStyle', title: 'myStyle'}); - */ - - css: function(source, properties) { - return new Element('link', $merge({ - 'rel': 'stylesheet', 'media': 'screen', 'type': 'text/css', 'href': source - }, properties)).inject(document.head); - }, - -/* - Property: image - Preloads an image and returns the img element. does not inject it to the page. - - Arguments: - source - the path of the image file - properties - some additional attributes you might want to add to the img element - - Example: - > new Asset.image('/images/myImage.png', {id: 'myImage', title: 'myImage', onload: myFunction}); - - Returns: - the img element. you can inject it anywhere you want with // - */ - - image: function(source, properties) { - properties = $merge({ - 'onload': Class.empty, - 'onabort': Class.empty, - 'onerror': Class.empty - }, properties); - var image = new Image(); - image.src = source; - var element = new Element('img', {'src': source}); - ['load', 'abort', 'error'].each(function(type) { - var event = properties['on' + type]; - delete properties['on' + type]; - element.addEvent(type, function() { - this.removeEvent(type, arguments.callee); - event.call(this); - }); - }); - if (image.width && image.height) element.fireEvent('load', element, 1); - return element.setProperties(properties); - }, - -/* - Property: images - Preloads an array of images (as strings) and returns an array of img elements. does not inject them to the page. - - Arguments: - sources - array, the paths of the image files - options - object, see below - - Options: - onComplete - a function to execute when all image files are loaded in the browser's cache - onProgress - a function to execute when one image file is loaded in the browser's cache - - Example: - (start code) - new Asset.images(['/images/myImage.png', '/images/myImage2.gif'], { - onComplete: function(){ - alert('all images loaded!'); - } - }); - (end) - - Returns: - the img elements as $$. you can inject them anywhere you want with // - */ - - images: function(sources, options) { - options = $merge({ - onComplete: Class.empty, - onProgress: Class.empty - }, options); - if (!sources.push) sources = [sources]; - var images = []; - var counter = 0; - sources.each(function(source) { - var img = new Asset.image(source, { - 'onload': function() { - options.onProgress.call(this, counter); - counter++; - if (counter == sources.length) options.onComplete(); - } - }); - images.push(img); - }); - return new Elements(images); - } - -}); - -/* -Script: Hash.js - Contains the class Hash. - -License: - MIT-style license. -*/ - -/* -Class: Hash - It wraps an object that it uses internally as a map. The user must use set(), get(), and remove() to add/change, retrieve and remove values, it must not access the internal object directly. null/undefined values are allowed. - -Note: - Each hash instance has the length property. - -Arguments: - obj - an object to convert into a Hash instance. - -Example: - (start code) - var hash = new Hash({a: 'hi', b: 'world', c: 'howdy'}); - hash.remove('b'); // b is removed. - hash.set('c', 'hello'); - hash.get('c'); // returns 'hello' - hash.length // returns 2 (a and c) - (end) -*/ - -var Hash = new Class({ - - length: 0, - - initialize: function(object) { - this.obj = object || {}; - this.setLength(); - }, - -/* - Property: get - Retrieves a value from the hash. - - Arguments: - key - The key - - Returns: - The value - */ - - get: function(key) { - return (this.hasKey(key)) ? this.obj[key] : null; - }, - -/* - Property: hasKey - Check the presence of a specified key-value pair in the hash. - - Arguments: - key - The key - - Returns: - True if the Hash contains a value for the specified key, otherwise false - */ - - hasKey: function(key) { - return (key in this.obj); - }, - -/* - Property: set - Adds a key-value pair to the hash or replaces a previous value associated with the key. - - Arguments: - key - The key - value - The value - */ - - set: function(key, value) { - if (!this.hasKey(key)) this.length++; - this.obj[key] = value; - return this; - }, - - setLength: function() { - this.length = 0; - for (var p in this.obj) this.length++; - return this; - }, - -/* - Property: remove - Removes a key-value pair from the hash. - - Arguments: - key - The key - */ - - remove: function(key) { - if (this.hasKey(key)) { - delete this.obj[key]; - this.length--; - } - return this; - }, - -/* - Property: each - Calls a function for each key-value pair. The first argument passed to the function will be the value, the second one will be the key, like $each. - - Arguments: - fn - The function to call for each key-value pair - bind - Optional, the object that will be referred to as "this" in the function - */ - - each: function(fn, bind) { - $each(this.obj, fn, bind); - }, - -/* - Property: extend - Extends the current hash with an object containing key-value pairs. Values for duplicate keys will be replaced by the new ones. - - Arguments: - obj - An object containing key-value pairs - */ - - extend: function(obj) { - $extend(this.obj, obj); - return this.setLength(); - }, - -/* - Property: merge - Merges the current hash with multiple objects. - */ - - merge: function() { - this.obj = $merge.apply(null, [this.obj].extend(arguments)); - return this.setLength(); - }, - -/* - Property: empty - Empties all hash values properties and values. - */ - - empty: function() { - this.obj = {}; - this.length = 0; - return this; - }, - -/* - Property: keys - Returns an array containing all the keys, in the same order as the values returned by . - - Returns: - An array containing all the keys of the hash - */ - - keys: function() { - var keys = []; - for (var property in this.obj) keys.push(property); - return keys; - }, - -/* - Property: values - Returns an array containing all the values, in the same order as the keys returned by . - - Returns: - An array containing all the values of the hash - */ - - values: function() { - var values = []; - for (var property in this.obj) values.push(this.obj[property]); - return values; - } - -}); - -/* Section: Utility Functions */ - -/* -Function: $H - Shortcut to create a Hash from an Object. -*/ - -function $H(obj) { - return new Hash(obj); -} -; - -/* -Script: Hash.Cookie.js - Stores and loads an Hash as a cookie using Json format. -*/ - -/* -Class: Hash.Cookie - Inherits all the methods from , additional methods are save and load. - Hash json string has a limit of 4kb (4096byte), so be careful with your Hash size. - Creating a new instance automatically loads the data from the Cookie into the Hash. - If the Hash is emptied, the cookie is also removed. - -Arguments: - name - the key (name) for the cookie - options - options are identical to and are simply passed along to it. - In addition, it has the autoSave option, to save the cookie at every operation. defaults to true. - -Example: - (start code) - var fruits = new Hash.Cookie('myCookieName', {duration: 3600}); - fruits.extend({ - 'lemon': 'yellow', - 'apple': 'red' - }); - fruits.set('melon', 'green'); - fruits.get('lemon'); // yellow - - // ... on another page ... values load automatically - - var fruits = new Hash.Cookie('myCookieName', {duration: 365}); - fruits.get('melon'); // green - - fruits.erase(); // delete cookie - (end) -*/ - -Hash.Cookie = Hash.extend({ - - initialize: function(name, options) { - this.name = name; - this.options = $extend({'autoSave': true}, options || {}); - this.load(); - }, - -/* - Property: save - Saves the Hash to the cookie. If the hash is empty, removes the cookie. - - Returns: - Returns false when the JSON string cookie is too long (4kb), otherwise true. - - Example: - (start code) - var login = new Hash.Cookie('userstatus', {autoSave: false}); - - login.extend({ - 'username': 'John', - 'credentials': [4, 7, 9] - }); - login.set('last_message', 'User logged in!'); - - login.save(); // finally save the Hash - (end) - */ - - save: function() { - if (this.length == 0) { - Cookie.remove(this.name, this.options); - return true; - } - var str = Json.toString(this.obj); - if (str.length > 4096) return false; //cookie would be truncated! - Cookie.set(this.name, str, this.options); - return true; - }, - -/* - Property: load - Loads the cookie and assigns it to the Hash. - */ - - load: function() { - this.obj = Json.evaluate(Cookie.get(this.name), true) || {}; - this.setLength(); - } - -}); - -Hash.Cookie.Methods = {}; -['extend', 'set', 'merge', 'empty', 'remove'].each(function(method) { - Hash.Cookie.Methods[method] = function() { - Hash.prototype[method].apply(this, arguments); - if (this.options.autoSave) this.save(); - return this; - }; -}); -Hash.Cookie.implement(Hash.Cookie.Methods); - -/* -Script: Color.js - Contains the Color class. - -License: - MIT-style license. -*/ - -/* -Class: Color - Creates a new Color Object, which is an array with some color specific methods. -Arguments: - color - the hex, the RGB array or the HSB array of the color to create. For HSB colors, you need to specify the second argument. - type - a string representing the type of the color to create. needs to be specified if you intend to create the color with HSB values, or an array of HEX values. Can be 'rgb', 'hsb' or 'hex'. - -Example: - (start code) - var black = new Color('#000'); - var purple = new Color([255,0,255]); - // mix black with white and purple, each time at 10% of the new color - var darkpurple = black.mix('#fff', purple, 10); - $('myDiv').setStyle('background-color', darkpurple); - (end) -*/ - -var Color = new Class({ - - initialize: function(color, type) { - type = type || (color.push ? 'rgb' : 'hex'); - var rgb, hsb; - switch (type) { - case 'rgb': - rgb = color; - hsb = rgb.rgbToHsb(); - break; - case 'hsb': - rgb = color.hsbToRgb(); - hsb = color; - break; - default: - rgb = color.hexToRgb(true); - hsb = rgb.rgbToHsb(); - } - rgb.hsb = hsb; - rgb.hex = rgb.rgbToHex(); - return $extend(rgb, Color.prototype); - }, - -/* - Property: mix - Mixes two or more colors with the Color. - - Arguments: - color - a color to mix. you can use as arguments how many colors as you want to mix with the original one. - alpha - if you use a number as the last argument, it will be threated as the amount of the color to mix. - */ - - mix: function() { - var colors = $A(arguments); - var alpha = ($type(colors[colors.length - 1]) == 'number') ? colors.pop() : 50; - var rgb = this.copy(); - colors.each(function(color) { - color = new Color(color); - for (var i = 0; i < 3; i++) rgb[i] = Math.round((rgb[i] / 100 * (100 - alpha)) + (color[i] / 100 * alpha)); - }); - return new Color(rgb, 'rgb'); - }, - -/* - Property: invert - Inverts the Color. - */ - - invert: function() { - return new Color(this.map(function(value) { - return 255 - value; - })); - }, - -/* - Property: setHue - Modifies the hue of the Color, and returns a new one. - - Arguments: - value - the hue to set - */ - - setHue: function(value) { - return new Color([value, this.hsb[1], this.hsb[2]], 'hsb'); - }, - -/* - Property: setSaturation - Changes the saturation of the Color, and returns a new one. - - Arguments: - percent - the percentage of the saturation to set - */ - - setSaturation: function(percent) { - return new Color([this.hsb[0], percent, this.hsb[2]], 'hsb'); - }, - -/* - Property: setBrightness - Changes the brightness of the Color, and returns a new one. - - Arguments: - percent - the percentage of the brightness to set - */ - - setBrightness: function(percent) { - return new Color([this.hsb[0], this.hsb[1], percent], 'hsb'); - } - -}); - -/* Section: Utility Functions */ - -/* -Function: $RGB - Shortcut to create a new color, based on red, green, blue values. - -Arguments: - r - (integer) red value (0-255) - g - (integer) green value (0-255) - b - (integer) blue value (0-255) - -*/ - -function $RGB(r, g, b) { - return new Color([r, g, b], 'rgb'); -} -; - -/* -Function: $HSB - Shortcut to create a new color, based on hue, saturation, brightness values. - -Arguments: - h - (integer) hue value (0-100) - s - (integer) saturation value (0-100) - b - (integer) brightness value (0-100) -*/ - -function $HSB(h, s, b) { - return new Color([h, s, b], 'hsb'); -} -; - -/* -Class: Array - A collection of The Array Object prototype methods. -*/ - -Array.extend({ - -/* - Property: rgbToHsb - Converts a RGB array to an HSB array. - - Returns: - the HSB array. - */ - - rgbToHsb: function() { - var red = this[0], green = this[1], blue = this[2]; - var hue, saturation, brightness; - var max = Math.max(red, green, blue), min = Math.min(red, green, blue); - var delta = max - min; - brightness = max / 255; - saturation = (max != 0) ? delta / max : 0; - if (saturation == 0) { - hue = 0; - } else { - var rr = (max - red) / delta; - var gr = (max - green) / delta; - var br = (max - blue) / delta; - if (red == max) hue = br - gr; - else if (green == max) hue = 2 + rr - br; - else hue = 4 + gr - rr; - hue /= 6; - if (hue < 0) hue++; - } - return [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100)]; - }, - -/* - Property: hsbToRgb - Converts an HSB array to an RGB array. - - Returns: - the RGB array. - */ - - hsbToRgb: function() { - var br = Math.round(this[2] / 100 * 255); - if (this[1] == 0) { - return [br, br, br]; - } else { - var hue = this[0] % 360; - var f = hue % 60; - var p = Math.round((this[2] * (100 - this[1])) / 10000 * 255); - var q = Math.round((this[2] * (6000 - this[1] * f)) / 600000 * 255); - var t = Math.round((this[2] * (6000 - this[1] * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: return [br, t, p]; - case 1: return [q, br, p]; - case 2: return [p, br, t]; - case 3: return [p, q, br]; - case 4: return [t, p, br]; - case 5: return [br, p, q]; - } - } - return false; - } - -}); - -/* -Script: Scroller.js - Contains the . - -License: - MIT-style license. -*/ - -/* -Class: Scroller - The Scroller is a class to scroll any element with an overflow (including the window) when the mouse cursor reaches certain buondaries of that element. - You must call its start method to start listening to mouse movements. - -Note: - The Scroller requires an XHTML doctype. - -Arguments: - element - required, the element to scroll. - options - optional, see options below, and options. - -Options: - area - integer, the necessary boundaries to make the element scroll. - velocity - integer, velocity ratio, the modifier for the window scrolling speed. - -Events: - onChange - optionally, when the mouse reaches some boundaries, you can choose to alter some other values, instead of the scrolling offsets. - Automatically passes as parameters x and y values. -*/ - -var Scroller = new Class({ - - options: { - area: 20, - velocity: 1, - onChange: function(x, y) { - this.element.scrollTo(x, y); - } - }, - - initialize: function(element, options) { - this.setOptions(options); - this.element = $(element); - this.mousemover = ([window, document].contains(element)) ? $(document.body) : this.element; - }, - -/* - Property: start - The scroller starts listening to mouse movements. - */ - - start: function() { - this.coord = this.getCoords.bindWithEvent(this); - this.mousemover.addListener('mousemove', this.coord); - }, - -/* - Property: stop - The scroller stops listening to mouse movements. - */ - - stop: function() { - this.mousemover.removeListener('mousemove', this.coord); - this.timer = $clear(this.timer); - }, - - getCoords: function(event) { - this.page = (this.element == window) ? event.client : event.page; - if (!this.timer) this.timer = this.scroll.periodical(50, this); - }, - - scroll: function() { - var el = this.element.getSize(); - var pos = this.element.getPosition(); - - var change = {'x': 0, 'y': 0}; - for (var z in this.page) { - if (this.page[z] < (this.options.area + pos[z]) && el.scroll[z] != 0) - change[z] = (this.page[z] - this.options.area - pos[z]) * this.options.velocity; - else if (this.page[z] + this.options.area > (el.size[z] + pos[z]) && el.scroll[z] + el.size[z] != el.scrollSize[z]) - change[z] = (this.page[z] - el.size[z] + this.options.area - pos[z]) * this.options.velocity; - } - if (change.y || change.x) this.fireEvent('onChange', [el.scroll.x + change.x, el.scroll.y + change.y]); - } - -}); - -Scroller.implement(new Events, new Options); - -/* -Script: Slider.js - Contains - -License: - MIT-style license. -*/ - -/* -Class: Slider - Creates a slider with two elements: a knob and a container. Returns the values. - -Note: - The Slider requires an XHTML doctype. - -Arguments: - element - the knob container - knob - the handle - options - see Options below - -Options: - steps - the number of steps for your slider. - mode - either 'horizontal' or 'vertical'. defaults to horizontal. - offset - relative offset for knob position. default to 0. - -Events: - onChange - a function to fire when the value changes. - onComplete - a function to fire when you're done dragging. - onTick - optionally, you can alter the onTick behavior, for example displaying an effect of the knob moving to the desired position. - Passes as parameter the new position. -*/ - -var Slider = new Class({ - - options: { - onChange: Class.empty, - onComplete: Class.empty, - onTick: function(pos) { - this.knob.setStyle(this.p, pos); - }, - mode: 'horizontal', - steps: 100, - offset: 0 - }, - - initialize: function(el, knob, options) { - this.element = $(el); - this.knob = $(knob); - this.setOptions(options); - this.previousChange = -1; - this.previousEnd = -1; - this.step = -1; - this.element.addEvent('mousedown', this.clickedElement.bindWithEvent(this)); - var mod, offset; - switch (this.options.mode) { - case 'horizontal': - this.z = 'x'; - this.p = 'left'; - mod = {'x': 'left', 'y': false}; - offset = 'offsetWidth'; - break; - case 'vertical': - this.z = 'y'; - this.p = 'top'; - mod = {'x': false, 'y': 'top'}; - offset = 'offsetHeight'; - } - this.max = this.element[offset] - this.knob[offset] + (this.options.offset * 2); - this.half = this.knob[offset] / 2; - this.getPos = this.element['get' + this.p.capitalize()].bind(this.element); - this.knob.setStyle('position', 'relative').setStyle(this.p, - this.options.offset); - var lim = {}; - lim[this.z] = [- this.options.offset, this.max - this.options.offset]; - this.drag = new Drag.Base(this.knob, { - limit: lim, - modifiers: mod, - snap: 0, - onStart: function() { - this.draggedKnob(); - }.bind(this), - onDrag: function() { - this.draggedKnob(); - }.bind(this), - onComplete: function() { - this.draggedKnob(); - this.end(); - }.bind(this) - }); - if (this.options.initialize) this.options.initialize.call(this); - }, - -/* - Property: set - The slider will get the step you pass. - - Arguments: - step - one integer - */ - - set: function(step) { - this.step = step.limit(0, this.options.steps); - this.checkStep(); - this.end(); - this.fireEvent('onTick', this.toPosition(this.step)); - return this; - }, - - clickedElement: function(event) { - var position = event.page[this.z] - this.getPos() - this.half; - position = position.limit(-this.options.offset, this.max - this.options.offset); - this.step = this.toStep(position); - this.checkStep(); - this.end(); - this.fireEvent('onTick', position); - }, - - draggedKnob: function() { - this.step = this.toStep(this.drag.value.now[this.z]); - this.checkStep(); - }, - - checkStep: function() { - if (this.previousChange != this.step) { - this.previousChange = this.step; - this.fireEvent('onChange', this.step); - } - }, - - end: function() { - if (this.previousEnd !== this.step) { - this.previousEnd = this.step; - this.fireEvent('onComplete', this.step + ''); - } - }, - - toStep: function(position) { - return Math.round((position + this.options.offset) / this.max * this.options.steps); - }, - - toPosition: function(step) { - return this.max * step / this.options.steps; - } - -}); - -Slider.implement(new Events); -Slider.implement(new Options); - -/* -Script: SmoothScroll.js - Contains - -License: - MIT-style license. -*/ - -/* -Class: SmoothScroll - Auto targets all the anchors in a page and display a smooth scrolling effect upon clicking them. - Inherits methods, properties, options and events from . - -Note: - SmoothScroll requires an XHTML doctype. - -Arguments: - options - the Fx.Scroll options (see: ) plus links, a collection of elements you want your smoothscroll on. Defaults to document.links. - -Example: - >new SmoothScroll(); -*/ - -var SmoothScroll = Fx.Scroll.extend({ - - initialize: function(options) { - this.parent(window, options); - this.links = (this.options.links) ? $$(this.options.links) : $$(document.links); - var location = window.location.href.match(/^[^#]*/)[0] + '#'; - this.links.each(function(link) { - if (link.href.indexOf(location) != 0) return; - var anchor = link.href.substr(location.length); - if (anchor && $(anchor)) this.useLink(link, anchor); - }, this); - if (!window.webkit419) this.addEvent('onComplete', function() { - window.location.hash = this.anchor; - }); - }, - - useLink: function(link, anchor) { - link.addEvent('click', function(event) { - this.anchor = anchor; - this.toElement(anchor); - event.stop(); - }.bindWithEvent(this)); - } - -}); - -/* -Script: Sortables.js - Contains Class. - -License: - MIT-style license. -*/ - -/* -Class: Sortables - Creates an interface for and drop, resorting of a list. - -Note: - The Sortables require an XHTML doctype. - -Arguments: - list - required, the list that will become sortable. - options - an Object, see options below. - -Options: - handles - a collection of elements to be used for drag handles. defaults to the elements. - -Events: - onStart - function executed when the item starts dragging - onComplete - function executed when the item ends dragging -*/ - -var Sortables = new Class({ - - options: { - handles: false, - onStart: Class.empty, - onComplete: Class.empty, - ghost: true, - snap: 3, - onDragStart: function(element, ghost) { - ghost.setStyle('opacity', 0.7); - element.setStyle('opacity', 0.7); - }, - onDragComplete: function(element, ghost) { - element.setStyle('opacity', 1); - ghost.remove(); - this.trash.remove(); - } - }, - - initialize: function(list, options) { - this.setOptions(options); - this.list = $(list); - this.elements = this.list.getChildren(); - this.handles = (this.options.handles) ? $$(this.options.handles) : this.elements; - this.bound = { - 'start': [], - 'moveGhost': this.moveGhost.bindWithEvent(this) - }; - for (var i = 0, l = this.handles.length; i < l; i++) { - this.bound.start[i] = this.start.bindWithEvent(this, this.elements[i]); - } - this.attach(); - if (this.options.initialize) this.options.initialize.call(this); - this.bound.move = this.move.bindWithEvent(this); - this.bound.end = this.end.bind(this); - }, - - attach: function() { - this.handles.each(function(handle, i) { - handle.addEvent('mousedown', this.bound.start[i]); - }, this); - }, - - detach: function() { - this.handles.each(function(handle, i) { - handle.removeEvent('mousedown', this.bound.start[i]); - }, this); - }, - - start: function(event, el) { - this.active = el; - this.coordinates = this.list.getCoordinates(); - if (this.options.ghost) { - var position = el.getPosition(); - this.offset = event.page.y - position.y; - this.trash = new Element('div').inject(document.body); - this.ghost = el.clone().inject(this.trash).setStyles({ - 'position': 'absolute', - 'left': position.x, - 'top': event.page.y - this.offset - }); - document.addListener('mousemove', this.bound.moveGhost); - this.fireEvent('onDragStart', [el, this.ghost]); - } - document.addListener('mousemove', this.bound.move); - document.addListener('mouseup', this.bound.end); - this.fireEvent('onStart', el); - event.stop(); - }, - - moveGhost: function(event) { - var value = event.page.y - this.offset; - value = value.limit(this.coordinates.top, this.coordinates.bottom - this.ghost.offsetHeight); - this.ghost.setStyle('top', value); - event.stop(); - }, - - move: function(event) { - var now = event.page.y; - this.previous = this.previous || now; - var up = ((this.previous - now) > 0); - var prev = this.active.getPrevious(); - var next = this.active.getNext(); - if (prev && up && now < prev.getCoordinates().bottom) this.active.injectBefore(prev); - if (next && !up && now > next.getCoordinates().top) this.active.injectAfter(next); - this.previous = now; - }, - - serialize: function(converter) { - return this.list.getChildren().map(converter || function(el) { - return this.elements.indexOf(el); - }, this); - }, - - end: function() { - this.previous = null; - document.removeListener('mousemove', this.bound.move); - document.removeListener('mouseup', this.bound.end); - if (this.options.ghost) { - document.removeListener('mousemove', this.bound.moveGhost); - this.fireEvent('onDragComplete', [this.active, this.ghost]); - } - this.fireEvent('onComplete', this.active); - } - -}); - -Sortables.implement(new Events, new Options); - -/* -Script: Tips.js - Tooltips, BubbleTips, whatever they are, they will appear on mouseover - -License: - MIT-style license. - -Credits: - The idea behind Tips.js is based on Bubble Tooltips () by Alessandro Fulcitiniti -*/ - -/* -Class: Tips - Display a tip on any element with a title and/or href. - -Note: - Tips requires an XHTML doctype. - -Arguments: - elements - a collection of elements to apply the tooltips to on mouseover. - options - an object. See options Below. - -Options: - maxTitleChars - the maximum number of characters to display in the title of the tip. defaults to 30. - showDelay - the delay the onShow method is called. (defaults to 100 ms) - hideDelay - the delay the onHide method is called. (defaults to 100 ms) - - className - the prefix for your tooltip classNames. defaults to 'tool'. - - the whole tooltip will have as classname: tool-tip - - the title will have as classname: tool-title - - the text will have as classname: tool-text - - offsets - the distance of your tooltip from the mouse. an Object with x/y properties. - fixed - if set to true, the toolTip will not follow the mouse. - -Events: - onShow - optionally you can alter the default onShow behaviour with this option (like displaying a fade in effect); - onHide - optionally you can alter the default onHide behaviour with this option (like displaying a fade out effect); - -Example: - (start code) - - - (end) - -Note: - The title of the element will always be used as the tooltip body. If you put :: on your title, the text before :: will become the tooltip title. -*/ - -var Tips = new Class({ - - options: { - onShow: function(tip) { - tip.setStyle('visibility', 'visible'); - }, - onHide: function(tip) { - tip.setStyle('visibility', 'hidden'); - }, - maxTitleChars: 30, - showDelay: 100, - hideDelay: 100, - className: 'tool', - offsets: {'x': 16, 'y': 16}, - fixed: false - }, - - initialize: function(elements, options) { - this.setOptions(options); - this.toolTip = new Element('div', { - 'class': this.options.className + '-tip', - 'styles': { - 'position': 'absolute', - 'top': '0', - 'left': '0', - 'visibility': 'hidden' - } - }).inject(document.body); - this.wrapper = new Element('div').inject(this.toolTip); - $$(elements).each(this.build, this); - if (this.options.initialize) this.options.initialize.call(this); - }, - - build: function(el) { - el.$tmp.myTitle = (el.href && el.getTag() == 'a') ? el.href.replace('http://', '') : (el.rel || false); - if (el.title) { - var dual = el.title.split('::'); - if (dual.length > 1) { - el.$tmp.myTitle = dual[0].trim(); - el.$tmp.myText = dual[1].trim(); - } else { - el.$tmp.myText = el.title; - } - el.removeAttribute('title'); - } else { - el.$tmp.myText = false; - } - if (el.$tmp.myTitle && el.$tmp.myTitle.length > this.options.maxTitleChars) el.$tmp.myTitle = el.$tmp.myTitle.substr(0, this.options.maxTitleChars - 1) + "…"; - el.addEvent('mouseenter', function(event) { - this.start(el); - if (!this.options.fixed) this.locate(event); - else this.position(el); - }.bind(this)); - if (!this.options.fixed) el.addEvent('mousemove', this.locate.bindWithEvent(this)); - var end = this.end.bind(this); - el.addEvent('mouseleave', end); - el.addEvent('trash', end); - }, - - start: function(el) { - this.wrapper.empty(); - if (el.$tmp.myTitle) { - this.title = new Element('span').inject(new Element('div', {'class': this.options.className + '-title'}).inject(this.wrapper)).setHTML(el.$tmp.myTitle); - } - if (el.$tmp.myText) { - this.text = new Element('span').inject(new Element('div', {'class': this.options.className + '-text'}).inject(this.wrapper)).setHTML(el.$tmp.myText); - } - $clear(this.timer); - this.timer = this.show.delay(this.options.showDelay, this); - }, - - end: function(event) { - $clear(this.timer); - this.timer = this.hide.delay(this.options.hideDelay, this); - }, - - position: function(element) { - var pos = element.getPosition(); - this.toolTip.setStyles({ - 'left': pos.x + this.options.offsets.x, - 'top': pos.y + this.options.offsets.y - }); - }, - - locate: function(event) { - var win = {'x': window.getWidth(), 'y': window.getHeight()}; - var scroll = {'x': window.getScrollLeft(), 'y': window.getScrollTop()}; - var tip = {'x': this.toolTip.offsetWidth, 'y': this.toolTip.offsetHeight}; - var prop = {'x': 'left', 'y': 'top'}; - for (var z in prop) { - var pos = event.page[z] + this.options.offsets[z]; - if ((pos + tip[z] - scroll[z]) > win[z]) pos = event.page[z] - this.options.offsets[z] - tip[z]; - this.toolTip.setStyle(prop[z], pos); - } - ; - }, - - show: function() { - if (this.options.timeout) this.timer = this.hide.delay(this.options.timeout, this); - this.fireEvent('onShow', [this.toolTip]); - }, - - hide: function() { - this.fireEvent('onHide', [this.toolTip]); - } - -}); - -Tips.implement(new Events, new Options); - -/* -Script: Group.js - For Grouping Classes or Elements Events. The Event added to the Group will fire when all of the events of the items of the group are fired. - -License: - MIT-style license. -*/ - -/* -Class: Group - An "Utility" Class. - -Arguments: - List of Class instances - -Example: - (start code) - xhr1 = new Ajax('data.js', {evalScript: true}); - xhr2 = new Ajax('abstraction.js', {evalScript: true}); - xhr3 = new Ajax('template.js', {evalScript: true}); - - var group = new Group(xhr1, xhr2, xhr3); - group.addEvent('onComplete', function(){ - alert('All Scripts loaded'); - }); - - xhr1.request(); - xhr2.request(); - xhr3.request(); - (end) - -*/ - -var Group = new Class({ - - initialize: function() { - this.instances = $A(arguments); - this.events = {}; - this.checker = {}; - }, - -/* - Property: addEvent - adds an event to the stack of events of the Class instances. - - Arguments: - type - string; the event name (e.g. 'onComplete') - fn - function to execute when all instances fired this event - */ - - addEvent: function(type, fn) { - this.checker[type] = this.checker[type] || {}; - this.events[type] = this.events[type] || []; - if (this.events[type].contains(fn)) return false; - else this.events[type].push(fn); - this.instances.each(function(instance, i) { - instance.addEvent(type, this.check.bind(this, [type, instance, i])); - }, this); - return this; - }, - - check: function(type, instance, i) { - this.checker[type][i] = true; - var every = this.instances.every(function(current, j) { - return this.checker[type][j] || false; - }, this); - if (!every) return; - this.checker[type] = {}; - this.events[type].each(function(event) { - event.call(this, this.instances, instance); - }, this); - } - -}); - -/* -Script: Accordion.js - Contains - -License: - MIT-style license. -*/ - -/* -Class: Accordion - The Accordion class creates a group of elements that are toggled when their handles are clicked. When one elements toggles in, the others toggles back. - Inherits methods, properties, options and events from . - -Note: - The Accordion requires an XHTML doctype. - -Arguments: - togglers - required, a collection of elements, the elements handlers that will be clickable. - elements - required, a collection of elements the transitions will be applied to. - options - optional, see options below, and options and events. - -Options: - show - integer, the Index of the element to show at start. - display - integer, the Index of the element to show at start (with a transition). defaults to 0. - fixedHeight - integer, if you want the elements to have a fixed height. defaults to false. - fixedWidth - integer, if you want the elements to have a fixed width. defaults to false. - height - boolean, will add a height transition to the accordion if true. defaults to true. - opacity - boolean, will add an opacity transition to the accordion if true. defaults to true. - width - boolean, will add a width transition to the accordion if true. defaults to false, css mastery is required to make this work! - alwaysHide - boolean, will allow to hide all elements if true, instead of always keeping one element shown. defaults to false. - -Events: - onActive - function to execute when an element starts to show - onBackground - function to execute when an element starts to hide -*/ - -var Accordion = Fx.Elements.extend({ - - options: { - onActive: Class.empty, - onBackground: Class.empty, - display: 0, - show: false, - height: true, - width: false, - opacity: true, - fixedHeight: false, - fixedWidth: false, - wait: false, - alwaysHide: false - }, - - initialize: function() { - var options, togglers, elements, container; - $each(arguments, function(argument, i) { - switch ($type(argument)) { - case 'object': options = argument; break; - case 'element': container = $(argument); break; - default: - var temp = $$(argument); - if (!togglers) togglers = temp; - else elements = temp; - } - }); - this.togglers = togglers || []; - this.elements = elements || []; - this.container = $(container); - this.setOptions(options); - this.previous = -1; - if (this.options.alwaysHide) this.options.wait = true; - if ($defined(this.options.show)) { - this.options.display = false; - this.previous = this.options.show; - } - if (this.options.start) { - this.options.display = false; - this.options.show = false; - } - this.effects = {}; - if (this.options.opacity) this.effects.opacity = 'fullOpacity'; - if (this.options.width) this.effects.width = this.options.fixedWidth ? 'fullWidth' : 'offsetWidth'; - if (this.options.height) this.effects.height = this.options.fixedHeight ? 'fullHeight' : 'scrollHeight'; - for (var i = 0, l = this.togglers.length; i < l; i++) this.addSection(this.togglers[i], this.elements[i]); - this.elements.each(function(el, i) { - if (this.options.show === i) { - this.fireEvent('onActive', [this.togglers[i], el]); - } else { - for (var fx in this.effects) el.setStyle(fx, 0); - } - }, this); - this.parent(this.elements); - if ($defined(this.options.display)) this.display(this.options.display); - }, - -/* - Property: addSection - Dynamically adds a new section into the accordion at the specified position. - - Arguments: - toggler - (dom element) the element that toggles the accordion section open. - element - (dom element) the element that stretches open when the toggler is clicked. - pos - (integer) the index where these objects are to be inserted within the accordion. - */ - - addSection: function(toggler, element, pos) { - toggler = $(toggler); - element = $(element); - var test = this.togglers.contains(toggler); - var len = this.togglers.length; - this.togglers.include(toggler); - this.elements.include(element); - if (len && (!test || pos)) { - pos = $pick(pos, len - 1); - toggler.injectBefore(this.togglers[pos]); - element.injectAfter(toggler); - } else if (this.container && !test) { - toggler.inject(this.container); - element.inject(this.container); - } - var idx = this.togglers.indexOf(toggler); - toggler.addEvent('click', this.display.bind(this, idx)); - if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'}); - if (this.options.width) element.setStyles({'padding-left': 0, 'border-left': 'none', 'padding-right': 0, 'border-right': 'none'}); - element.fullOpacity = 1; - if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth; - if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight; - element.setStyle('overflow', 'hidden'); - if (!test) { - for (var fx in this.effects) element.setStyle(fx, 0); - } - return this; - }, - -/* - Property: display - Shows a specific section and hides all others. Useful when triggering an accordion from outside. - - Arguments: - index - integer, the index of the item to show, or the actual element to show. - */ - - display: function(index) { - index = ($type(index) == 'element') ? this.elements.indexOf(index) : index; - if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this; - this.previous = index; - var obj = {}; - this.elements.each(function(el, i) { - obj[i] = {}; - var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0)); - this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[i], el]); - for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]]; - }, this); - return this.start(obj); - }, - - showThisHideOpen: function(index) { - return this.display(index); - } - -}); - -Fx.Accordion = Accordion;