Text editor works based on absolute position.

This commit is contained in:
Paulo Veiga 2011-08-23 14:25:49 -03:00
parent f036a7684e
commit fb39e32b33
15 changed files with 351 additions and 1420 deletions

View File

@ -19,7 +19,8 @@ $assert = function(assert, message) {
} catch(e) { } catch(e) {
stack = e; stack = e;
} }
wLogger.error(message + "," + stack); console.log(message + "," + stack);
// wLogger.error(message + "," + stack);
// core.Logger.logError(message + "," + stack); // core.Logger.logError(message + "," + stack);
} }

View File

@ -16,68 +16,68 @@
* limitations under the License. * limitations under the License.
*/ */
// Init default logger level ... //// Init default logger level ...
var wLogger = new Log4js.getLogger("WiseMapping"); //var wLogger = new Log4js.getLogger("WiseMapping");
wLogger.setLevel(Log4js.Level.ALL); //wLogger.setLevel(Log4js.Level.ALL);
//wLogger.addAppender(new Log4js.BrowserConsoleAppender()); ////wLogger.addAppender(new Log4js.BrowserConsoleAppender());
//
// Is logger service available ? //// Is logger service available ?
if ($defined(window.LoggerService)) //if ($defined(window.LoggerService))
{ //{
Log4js.WiseServerAppender = function() // Log4js.WiseServerAppender = function()
{ // {
this.layout = new Log4js.SimpleLayout(); // this.layout = new Log4js.SimpleLayout();
}; // };
//
Log4js.WiseServerAppender.prototype = Log4js.extend(new Log4js.Appender(), { // Log4js.WiseServerAppender.prototype = Log4js.extend(new Log4js.Appender(), {
/** // /**
* @see Log4js.Appender#doAppend // * @see Log4js.Appender#doAppend
*/ // */
doAppend: function(loggingEvent) { // doAppend: function(loggingEvent) {
try { // try {
var message = this.layout.format(loggingEvent); // var message = this.layout.format(loggingEvent);
var level = this.levelCode(loggingEvent); // var level = this.levelCode(loggingEvent);
//
window.LoggerService.logError(level, message); // window.LoggerService.logError(level, message);
//
} catch (e) { // } catch (e) {
alert(e); // alert(e);
} // }
}, // },
//
/** // /**
* toString // * toString
*/ // */
toString: function() { // toString: function() {
return "Log4js.WiseServerAppender"; // return "Log4js.WiseServerAppender";
}, // },
//
levelCode: function(loggingEvent) // levelCode: function(loggingEvent)
{ // {
var retval; // var retval;
switch (loggingEvent.level) { // switch (loggingEvent.level) {
case Log4js.Level.FATAL: // case Log4js.Level.FATAL:
retval = 3; // retval = 3;
break; // break;
case Log4js.Level.ERROR: // case Log4js.Level.ERROR:
retval = 3; // retval = 3;
break; // break;
case Log4js.Level.WARN: // case Log4js.Level.WARN:
retval = 2; // retval = 2;
break; // break;
default: // default:
retval = 1; // retval = 1;
break; // break;
} // }
//
return retval; // return retval;
} // }
}); // });
//
wLogger.addAppender(new Log4js.WiseServerAppender()); // wLogger.addAppender(new Log4js.WiseServerAppender());
//
} //}
//
//// Handle error events ... //// Handle error events ...
//window.onerror = function(sMsg, sUrl, sLine) //window.onerror = function(sMsg, sUrl, sLine)

View File

@ -38,6 +38,10 @@ mindplot.Icon = new Class({
getSize : function() { getSize : function() {
return this._image.getSize(); return this._image.getSize();
},
getPosition : function() {
return this._image.getPosition();
} }
}); });

View File

@ -17,122 +17,149 @@
*/ */
mindplot.ImageIcon = new Class({ mindplot.ImageIcon = new Class({
Extends:mindplot.Icon, Extends:mindplot.Icon,
initialize:function(iconModel, topic, designer) { initialize:function(topic, iconModel) {
$assert(iconModel, 'iconModel can not be null'); $assert(iconModel, 'iconModel can not be null');
$assert(topic, 'topic can not be null'); $assert(topic, 'topic can not be null');
$assert(designer, 'designer can not be null');
this._topic = topic; this._topic = topic;
this._iconModel = iconModel; this._iconModel = iconModel;
this._designer = designer;
// Build graph image representation ... // @Todo: Read only must be a property ...
var iconType = iconModel.getIconType(); this._readOnly = designer._readOnly;
var imgUrl = this._getImageUrl(iconType);
this.parent(imgUrl); // Build graph image representation ...
var iconType = iconModel.getIconType();
var imgUrl = this._getImageUrl(iconType);
this.parent(imgUrl);
//Remove //Remove
var divContainer = designer.getWorkSpace().getScreenManager().getContainer(); if (!this._readOnly) {
var tip = mindplot.Tip.getInstance(divContainer);
var container = new Element('div'); var deleteTip = new mindplot.ImageIcon.DeleteTip(this._topic.getId(), this);
var removeImage = new Element('img');
removeImage.src = "../images/bin.png";
removeImage.inject(container);
if (!$defined(designer._readOnly) || ($defined(designer._readOnly) && !designer._readOnly)) { //Icon
var image = this.getImage();
image.addEvent('click', function() {
removeImage.addEvent('click', function() { var iconType = iconModel.getIconType();
var actionDispatcher = mindplot.ActionDispatcher.getInstance(); var newIconType = this._getNextFamilyIconId(iconType);
actionDispatcher.removeIconFromTopic(this._topic.getId(), iconModel); iconModel.setIconType(newIconType);
tip.forceClose();
});
//Icon var imgUrl = this._getImageUrl(newIconType);
var image = this.getImage(); this._image.setHref(imgUrl);
image.addEvent('click', function() {
var iconType = iconModel.getIconType(); }.bind(this));
var newIconType = this._getNextFamilyIconId(iconType);
iconModel.setIconType(newIconType);
var imgUrl = this._getImageUrl(newIconType); image.addEvent('mouseover', function(event) {
this._image.setHref(imgUrl); deleteTip.show();
});
}.bind(this));
image.addEvent('mouseover', function(event) {
tip.open(event, container, this);
}.bind(this));
image.addEvent('mouseout', function(event) {
tip.close(event);
});
image.addEvent('mousemove', function(event) {
tip.updatePosition(event);
});
}
},
_getImageUrl : function(iconId) {
return "../icons/" + iconId + ".png";
},
getModel : function() {
return this._iconModel;
},
_getNextFamilyIconId : function(iconId) {
var familyIcons = this._getFamilyIcons(iconId);
$assert(familyIcons != null, "Family Icon not found!");
var result = null;
for (var i = 0; i < familyIcons.length && result == null; i++) {
if (familyIcons[i] == iconId) {
//Is last one?
if (i == (familyIcons.length - 1)) {
result = familyIcons[0];
} else {
result = familyIcons[i + 1];
}
break;
}
}
return result;
},
_getFamilyIcons : function(iconId) {
$assert(iconId != null, "id must not be null");
$assert(iconId.indexOf("_") != -1, "Invalid icon id (it must contain '_')");
var result = null;
for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i++) {
var family = mindplot.ImageIcon.prototype.ICON_FAMILIES[i];
var iconFamilyId = iconId.substr(0, iconId.indexOf("_"));
if (family.id == iconFamilyId) {
result = family.icons;
break;
}
}
return result;
},
getId : function() {
return this._iconType;
},
getUiId : function() {
return this._uiId;
} }
},
_getImageUrl : function(iconId) {
return "../icons/" + iconId + ".png";
},
getModel : function() {
return this._iconModel;
},
_getNextFamilyIconId : function(iconId) {
var familyIcons = this._getFamilyIcons(iconId);
$assert(familyIcons != null, "Family Icon not found!");
var result = null;
for (var i = 0; i < familyIcons.length && result == null; i++) {
if (familyIcons[i] == iconId) {
//Is last one?
if (i == (familyIcons.length - 1)) {
result = familyIcons[0];
} else {
result = familyIcons[i + 1];
}
break;
}
}
return result;
},
_getFamilyIcons : function(iconId) {
$assert(iconId != null, "id must not be null");
$assert(iconId.indexOf("_") != -1, "Invalid icon id (it must contain '_')");
var result = null;
for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i++) {
var family = mindplot.ImageIcon.prototype.ICON_FAMILIES[i];
var iconFamilyId = iconId.substr(0, iconId.indexOf("_"));
if (family.id == iconFamilyId) {
result = family.icons;
break;
}
}
return result;
},
getId : function() {
return this._iconType;
},
getUiId : function() {
return this._uiId;
} }
);
});
mindplot.ImageIcon.DeleteTip = new Class({
initialize : function(topicId, icon) {
$assert(topicId, "topicId can not be null");
$assert(icon, "iconModel can not be null");
this._icon = icon;
this._topicId = topicId;
this._registerEvents();
},
_registerEvents : function() {
this._containerElem = this._buildHtml();
this._containerElem.inject($(document.body));
this._containerElem.addEvent('click', function() {
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
actionDispatcher.removeIconFromTopic(this._topicId, this._icon._iconModel);
this.close();
}.bind(this));
},
show : function() {
this._icon._image.positionRelativeTo(this._containerElem, {
position: 'upperRight',
offset: {x:10,y:-10}
});
this._icon._image.setStroke(1,'dash','red');
},
close : function() {
this._containerElem.dispose();
},
_buildHtml : function() {
var result = new Element('div');
result.setStyles({
zIndex: "8",
width:"10px",
height:"10px",
'background-color':'red'}
);
return result;
}
});
mindplot.ImageIcon.prototype.ICON_FAMILIES = [ mindplot.ImageIcon.prototype.ICON_FAMILIES = [

View File

@ -39,7 +39,7 @@ mindplot.MindmapDesigner = new Class({
// Init Screen manager.. // Init Screen manager..
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement); var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom); this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
this._readOnly = profile.readOnly; this._readOnly = profile.readOnly ? true : false;
// Init layout managers ... // Init layout managers ...
this._topics = []; this._topics = [];
@ -112,6 +112,17 @@ mindplot.MindmapDesigner = new Class({
this._actionDispatcher.addTopic(model, centralTopicId, true); this._actionDispatcher.addTopic(model, centralTopicId, true);
} }
}.bind(this)); }.bind(this));
$(document).addEvent('mousewheel', function(event) {
if (event.wheel > 0) {
this.zoomIn(1.05);
}
else {
this.zoomOut(1.05);
}
}.bind(this));
}, },
_getTopics : function() { _getTopics : function() {
@ -201,8 +212,11 @@ mindplot.MindmapDesigner = new Class({
}, },
zoomOut : function() { zoomOut : function(factor) {
var scale = this._zoom * 1.2; if (!factor)
factor = 1.2;
var scale = this._zoom * factor;
if (scale <= 4) { if (scale <= 4) {
this._zoom = scale; this._zoom = scale;
this._workspace.setZoom(this._zoom); this._workspace.setZoom(this._zoom);
@ -227,8 +241,11 @@ mindplot.MindmapDesigner = new Class({
}); });
}, },
zoomIn : function() { zoomIn : function(factor) {
var scale = this._zoom / 1.2; if (!factor)
factor = 1.2;
var scale = this._zoom / factor;
if (scale >= 0.3) { if (scale >= 0.3) {
this._zoom = scale; this._zoom = scale;
this._workspace.setZoom(this._zoom); this._workspace.setZoom(this._zoom);
@ -640,7 +657,7 @@ mindplot.MindmapDesigner = new Class({
}, },
changeFontColor : function(color) { changeFontColor : function(color) {
$assert(color,"color can not be null"); $assert(color, "color can not be null");
var validSelectedObjects = this._getValidSelectedObjectsIds(); var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes; var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0) { if (topicsIds.length > 0) {

View File

@ -37,7 +37,7 @@ mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHa
if (response.msgCode != "OK") if (response.msgCode != "OK")
{ {
monitor.logError("Save could not be completed. Please,try again in a couple of minutes."); monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
wLogger.error(response.msgDetails); // wLogger.error(response.msgDetails);
} else } else
{ {
// Execute on success handler ... // Execute on success handler ...
@ -50,7 +50,7 @@ mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHa
errorHandler:function(message) { errorHandler:function(message) {
var monitor = core.Monitor.getInstance(); var monitor = core.Monitor.getInstance();
monitor.logError("Save could not be completed. Please,try again in a couple of minutes."); monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
wLogger.error(message); // wLogger.error(message);
}, },
verb:"POST", verb:"POST",
async: false async: false
@ -82,7 +82,7 @@ mindplot.PersistanceManager.load = function(mapId)
var msg = response.msgDetails; var msg = response.msgDetails;
var monitor = core.Monitor.getInstance(); var monitor = core.Monitor.getInstance();
monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes."); monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
wLogger.error(msg); // wLogger.error(msg);
} }
}, },
verb:"GET", verb:"GET",
@ -90,7 +90,7 @@ mindplot.PersistanceManager.load = function(mapId)
errorHandler:function(msg) { errorHandler:function(msg) {
var monitor = core.Monitor.getInstance(); var monitor = core.Monitor.getInstance();
monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes."); monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
wLogger.error(msg); // wLogger.error(msg);
} }
}); });

View File

@ -29,12 +29,11 @@ mindplot.TextEditor = new Class({
position:"absolute", position:"absolute",
display: "none", display: "none",
zIndex: "8", zIndex: "8",
top: 0,
left:0,
width:"500px", width:"500px",
height:"100px"} height:"100px"}
); );
var inputContainer = new Element('div'); var inputContainer = new Element('div');
inputContainer.setStyles({ inputContainer.setStyles({
border:"none", border:"none",
@ -45,7 +44,7 @@ mindplot.TextEditor = new Class({
var inputText = new Element('input', {type:"text",tabindex:'-1', value:""}); var inputText = new Element('input', {type:"text",tabindex:'-1', value:""});
inputText.setStyles({ inputText.setStyles({
border:"none", border:"none",
background:"red" background:"transparent"
}); });
inputText.inject(inputContainer); inputText.inject(inputContainer);
@ -58,6 +57,7 @@ mindplot.TextEditor = new Class({
spanElem.setStyle('nowrap', 'nowrap'); spanElem.setStyle('nowrap', 'nowrap');
spanElem.inject(spanContainer); spanElem.inject(spanContainer);
return result; return result;
}, },
@ -117,8 +117,7 @@ mindplot.TextEditor = new Class({
if (!this.isVisible()) { if (!this.isVisible()) {
//Create editor ui //Create editor ui
var editorElem = this._buildEditor(); var editorElem = this._buildEditor();
// @Todo: What element associate ? editorElem.inject($(document.body));
editorElem.inject($('mindplot'));
this._divElem = editorElem; this._divElem = editorElem;
this._registerEvents(editorElem); this._registerEvents(editorElem);
@ -146,36 +145,18 @@ mindplot.TextEditor = new Class({
// Set editor's initial size // Set editor's initial size
var displayFunc = function() { var displayFunc = function() {
var textShape = topic.getTextShape();
var scale = web2d.peer.utils.TransformUtil.workoutScale(textShape._peer);
var screenPosition = mindplot.util.Converter.topicToScreenPosition(topic);
var textWidth = textShape.getWidth();
var textHeight = textShape.getHeight();
var iconGroup = topic.getIconGroup();
var iconGroupSize;
if ($defined(iconGroup)) {
iconGroupSize = topic.getIconGroup().getSize();
}
else {
iconGroupSize = {width:0, height:0};
}
var position = {x:0,y:0};
position.x = screenPosition.x - ((textWidth * scale.width) / 2) + (((iconGroupSize.width) * scale.width) / 2);
var fixError = 1;
position.y = screenPosition.y - ((textHeight * scale.height) / 2) - fixError;
var elemSize = topic.getSize();
// Position the editor and set the size... // Position the editor and set the size...
this._setEditorSize(elemSize.width, elemSize.height, scale); var textShape = this._topic.getTextShape();
this._setPosition(position.x, position.y, scale); textShape.positionRelativeTo(this._divElem, {
position: {x: 'left',y:'top'},
// Make the editor visible .... edge: {x: 'left', y: 'top'}
});
this._divElem.setStyle('display', 'block'); this._divElem.setStyle('display', 'block');
// Set size ...
var elemSize = topic.getSize();
this._setEditorSize(elemSize.width, elemSize.height);
var inputElem = this._getInputElem(); var inputElem = this._getInputElem();
inputElem.focus(); inputElem.focus();
this._changeCursor(inputElem, $defined(defaultText)); this._changeCursor(inputElem, $defined(defaultText));
@ -232,7 +213,9 @@ mindplot.TextEditor = new Class({
return this._divElem.getElement('span'); return this._divElem.getElement('span');
}, },
_setEditorSize : function (width, height, scale) { _setEditorSize : function (width, height) {
var textShape = this._topic.getTextShape();
var scale = web2d.peer.utils.TransformUtil.workoutScale(textShape._peer);
this._size = {width:width * scale.width, height:height * scale.height}; this._size = {width:width * scale.width, height:height * scale.height};
this._divElem.style.width = this._size.width * 2 + "px"; this._divElem.style.width = this._size.width * 2 + "px";
this._divElem.style.height = this._size.height + "px"; this._divElem.style.height = this._size.height + "px";
@ -275,8 +258,6 @@ mindplot.TextEditor = new Class({
// Remove it form the screen ... // Remove it form the screen ...
this._divElem.dispose(); this._divElem.dispose();
this._divElem = null; this._divElem = null;
console.log("closing ....");
} }
} }
}); });

View File

@ -267,7 +267,7 @@ mindplot.Topic = new Class({
for (var i = 0; i < icons.length; i++) { for (var i = 0; i < icons.length; i++) {
// Update model identifier ... // Update model identifier ...
var iconModel = icons[i]; var iconModel = icons[i];
var icon = new mindplot.ImageIcon(iconModel, this, designer); var icon = new mindplot.ImageIcon(this, iconModel);
result.addIcon(icon); result.addIcon(icon);
} }
@ -311,7 +311,7 @@ mindplot.Topic = new Class({
this._hasNote = true; this._hasNote = true;
}, },
addIcon : function(iconType, designer) { addIcon : function(iconType) {
var iconGroup = this.getOrBuildIconGroup(); var iconGroup = this.getOrBuildIconGroup();
var model = this.getModel(); var model = this.getModel();
@ -319,7 +319,7 @@ mindplot.Topic = new Class({
var iconModel = model.createIcon(iconType); var iconModel = model.createIcon(iconType);
model.addIcon(iconModel); model.addIcon(iconModel);
var imageIcon = new mindplot.ImageIcon(iconModel, this, designer); var imageIcon = new mindplot.ImageIcon(this, iconModel);
iconGroup.addIcon(imageIcon); iconGroup.addIcon(imageIcon);
return imageIcon; return imageIcon;

View File

@ -32,8 +32,10 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
}else{ }else{
var text = this._brixModel.get("text"); var text = this._brixModel.get("text");
this.setText(text, false); this.setText(text, false);
var position = this._brixModel.get("position"); var position = this._brixModel.get("position");
this.setPosition(position.get("x"),position.get("y"), false); this.setPosition(position.get("x"),position.get("y"), false);
var children = this._brixModel.get("children"); var children = this._brixModel.get("children");
for(var i=0; i<children.size(); i++){ for(var i=0; i<children.size(); i++){
var bChild = children.get(i); var bChild = children.get(i);

View File

@ -24,6 +24,7 @@ mindplot.commands.AddIconToTopicCommand = new Class({
this._selectedObjectsIds = topicId; this._selectedObjectsIds = topicId;
this._iconType = iconType; this._iconType = iconType;
}, },
execute: function(commandContext) { execute: function(commandContext) {
var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() { var updated = function() {
@ -33,6 +34,7 @@ mindplot.commands.AddIconToTopicCommand = new Class({
}.bind(this); }.bind(this);
updated.delay(0); updated.delay(0);
}, },
undoExecute: function(commandContext) { undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._selectedObjectsIds)[0]; var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() { var updated = function() {

View File

@ -1,88 +1,81 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
web2d.Element = function(peer, attributes) web2d.Element = function(peer, attributes) {
{
this._peer = peer; this._peer = peer;
if (peer == null) if (peer == null) {
{
throw "Element peer can not be null"; throw "Element peer can not be null";
} }
this._dispatcherByEventType = new Hash({}); this._dispatcherByEventType = new Hash({});
if ($defined(attributes)) if ($defined(attributes)) {
{
this._initialize(attributes); this._initialize(attributes);
} }
}; };
web2d.Element.prototype._SIGNATURE_MULTIPLE_ARGUMENTS = -1; web2d.Element.prototype._SIGNATURE_MULTIPLE_ARGUMENTS = -1;
web2d.Element.prototype._initialize = function(attributes) web2d.Element.prototype._initialize = function(attributes) {
{
var batchExecute = {}; var batchExecute = {};
// Collect arguments ... // Collect arguments ...
for (var key in attributes) for (var key in attributes) {
{
var funcName = this._attributeNameToFuncName(key, 'set'); var funcName = this._attributeNameToFuncName(key, 'set');
var funcArgs = batchExecute[funcName]; var funcArgs = batchExecute[funcName];
if (!$defined(funcArgs)) if (!$defined(funcArgs)) {
{
funcArgs = []; funcArgs = [];
} }
var signature = this._propertyNameToSignature[key]; var signature = this._propertyNameToSignature[key];
var argPositions = signature[1]; var argPositions = signature[1];
if (argPositions != this._SIGNATURE_MULTIPLE_ARGUMENTS) if (argPositions != this._SIGNATURE_MULTIPLE_ARGUMENTS) {
{
funcArgs[argPositions] = attributes[key]; funcArgs[argPositions] = attributes[key];
} else } else {
{
funcArgs = attributes[key].split(' '); funcArgs = attributes[key].split(' ');
} }
batchExecute[funcName] = funcArgs; batchExecute[funcName] = funcArgs;
} }
// Call functions ... // Call functions ...
for (var key in batchExecute) for (var key in batchExecute) {
{
var func = this[key]; var func = this[key];
if (!$defined(func)) if (!$defined(func)) {
{
throw "Could not find function: " + key; throw "Could not find function: " + key;
} }
func.apply(this, batchExecute[key]); func.apply(this, batchExecute[key]);
} }
}; };
web2d.Element.prototype.setSize = function(width, height) web2d.Element.prototype.setSize = function(width, height) {
{
this._peer.setSize(width, height); this._peer.setSize(width, height);
}; };
web2d.Element.prototype.setPosition = function(cx, cy) web2d.Element.prototype.setPosition = function(cx, cy) {
{
this._peer.setPosition(cx, cy); this._peer.setPosition(cx, cy);
}; };
web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mouseout","mouseover","mousedown","mouseup"]; web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mouseout","mouseover","mousedown","mouseup"];
web2d.Element.prototype.positionRelativeTo = function(elem, options) {
this._peer.positionRelativeTo(elem, options);
};
/** /**
* Allows the registration of event listeners on the event target. * Allows the registration of event listeners on the event target.
* type * type
@ -93,16 +86,13 @@ web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mous
* The following events types are supported: * The following events types are supported:
* *
*/ */
web2d.Element.prototype.addEvent = function(type, listener) web2d.Element.prototype.addEvent = function(type, listener) {
{ if (!this._supportedEvents.include(type)) {
if (!this._supportedEvents.include(type))
{
throw "Unsupported event type: " + type; throw "Unsupported event type: " + type;
} }
// Concat previous event listeners for a given type. // Concat previous event listeners for a given type.
if (!this._dispatcherByEventType[type]) if (!this._dispatcherByEventType[type]) {
{
this._dispatcherByEventType[type] = new web2d.EventDispatcher(this); this._dispatcherByEventType[type] = new web2d.EventDispatcher(this);
var eventListener = this._dispatcherByEventType[type].eventListener; var eventListener = this._dispatcherByEventType[type].eventListener;
@ -122,18 +112,15 @@ web2d.Element.prototype.addEvent = function(type, listener)
* The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs. * The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
* This interace will be invoked passing an event as argument and the 'this' referece in the function will be the element. * This interace will be invoked passing an event as argument and the 'this' referece in the function will be the element.
*/ */
web2d.Element.prototype.removeEvent = function(type, listener) web2d.Element.prototype.removeEvent = function(type, listener) {
{
var dispatcher = this._dispatcherByEventType[type]; var dispatcher = this._dispatcherByEventType[type];
if (dispatcher == null) if (dispatcher == null) {
{
throw "There is no listener previously registered"; throw "There is no listener previously registered";
} }
var result = dispatcher.removeListener(type, listener); var result = dispatcher.removeListener(type, listener);
// If there is not listeners, EventDispatcher must be removed. // If there is not listeners, EventDispatcher must be removed.
if (dispatcher.getListenersCount() <= 0) if (dispatcher.getListenersCount() <= 0) {
{
this._peer.removeEvent(type, dispatcher.eventListener); this._peer.removeEvent(type, dispatcher.eventListener);
this._dispatcherByEventType[type] = null; this._dispatcherByEventType[type] = null;
} }
@ -143,16 +130,14 @@ web2d.Element.prototype.removeEvent = function(type, listener)
* /* * /*
* Returns element type name. * Returns element type name.
*/ */
web2d.Element.prototype.getType = function() web2d.Element.prototype.getType = function() {
{
throw "Not implemeneted yet. This method must be implemented by all the inherited objects."; throw "Not implemeneted yet. This method must be implemented by all the inherited objects.";
}; };
/** /**
* Todo: Doc * Todo: Doc
*/ */
web2d.Element.prototype.getFill = function() web2d.Element.prototype.getFill = function() {
{
return this._peer.getFill(); return this._peer.getFill();
}; };
@ -161,27 +146,23 @@ web2d.Element.prototype.getFill = function()
* color: Fill color * color: Fill color
* opacity: Opacity of the fill. It must be less than 1. * opacity: Opacity of the fill. It must be less than 1.
*/ */
web2d.Element.prototype.setFill = function(color, opacity) web2d.Element.prototype.setFill = function(color, opacity) {
{
this._peer.setFill(color, opacity); this._peer.setFill(color, opacity);
}; };
web2d.Element.prototype.getPosition = function() web2d.Element.prototype.getPosition = function() {
{
return this._peer.getPosition(); return this._peer.getPosition();
}; };
/* /*
* Defines the element stroke properties. * Defines the element stroke properties.
* width: stroke width * width: stroke width
* style: "solid|dot|dash|dashdot|longdash". * style: "solid|dot|dash|dashdot|longdash".
* color: stroke color * color: stroke color
* opacity: stroke visibility * opacity: stroke visibility
*/ */
web2d.Element.prototype.setStroke = function(width, style, color, opacity) web2d.Element.prototype.setStroke = function(width, style, color, opacity) {
{ if (style != null && style != undefined && style != 'dash' && style != 'dot' && style != 'solid' && style != 'longdash' && style != "dashdot") {
if (style != null && style != undefined && style != 'dash' && style != 'dot' && style != 'solid' && style != 'longdash' && style != "dashdot")
{
throw "Unsupported stroke style: '" + style + "'"; throw "Unsupported stroke style: '" + style + "'";
} }
this._peer.setStroke(width, style, color, opacity); this._peer.setStroke(width, style, color, opacity);
@ -220,11 +201,9 @@ web2d.Element.prototype._propertyNameToSignature =
opacity:['opacity',0] opacity:['opacity',0]
}; };
web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix) web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix) {
{
var signature = this._propertyNameToSignature[attributeKey]; var signature = this._propertyNameToSignature[attributeKey];
if (!$defined(signature)) if (!$defined(signature)) {
{
throw "Unsupported attribute: " + attributeKey; throw "Unsupported attribute: " + attributeKey;
} }
@ -238,68 +217,57 @@ web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix
* key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle, strokeColor, strokeOpacity, * key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle, strokeColor, strokeOpacity,
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY * fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY
*/ */
web2d.Element.prototype.setAttribute = function(key, value) web2d.Element.prototype.setAttribute = function(key, value) {
{
var funcName = this._attributeNameToFuncName(key, 'set'); var funcName = this._attributeNameToFuncName(key, 'set');
var signature = this._propertyNameToSignature[key]; var signature = this._propertyNameToSignature[key];
if (signature == null) if (signature == null) {
{
throw "Could not find the signature for:" + key; throw "Could not find the signature for:" + key;
} }
// Parse arguments .. // Parse arguments ..
var argPositions = signature[1]; var argPositions = signature[1];
var args = []; var args = [];
if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) {
{
args[argPositions] = value; args[argPositions] = value;
} }
else if (typeof value == "array") else if (typeof value == "array") {
{
args = value; args = value;
} else } else {
{
var strValue = String(value); var strValue = String(value);
args = strValue.split(' '); args = strValue.split(' ');
} }
// Look up method ... // Look up method ...
var setter = this[funcName]; var setter = this[funcName];
if (setter == null) if (setter == null) {
{
throw "Could not find the function name:" + funcName; throw "Could not find the function name:" + funcName;
} }
setter.apply(this, args); setter.apply(this, args);
}; };
web2d.Element.prototype.getAttribute = function(key) web2d.Element.prototype.getAttribute = function(key) {
{
var funcName = this._attributeNameToFuncName(key, 'get'); var funcName = this._attributeNameToFuncName(key, 'get');
var signature = this._propertyNameToSignature[key]; var signature = this._propertyNameToSignature[key];
if (signature == null) if (signature == null) {
{
throw "Could not find the signature for:" + key; throw "Could not find the signature for:" + key;
} }
var getter = this[funcName]; var getter = this[funcName];
if (getter == null) if (getter == null) {
{
throw "Could not find the function name:" + funcName; throw "Could not find the function name:" + funcName;
} }
var getterResult = getter.apply(this, []); var getterResult = getter.apply(this, []);
var attibuteName = signature[2]; var attibuteName = signature[2];
if (!$defined(attibuteName)) if (!$defined(attibuteName)) {
{
throw "Could not find attribute mapping for:" + key; throw "Could not find attribute mapping for:" + key;
} }
var result = getterResult[attibuteName]; var result = getterResult[attibuteName];
if (!$defined(result)) if (!$defined(result)) {
{
throw "Could not find attribute with name:" + attibuteName; throw "Could not find attribute with name:" + attibuteName;
} }
@ -312,50 +280,43 @@ web2d.Element.prototype.getAttribute = function(key)
* Parameters: * Parameters:
* opacity: A value between 0 and 1. * opacity: A value between 0 and 1.
*/ */
web2d.Element.prototype.setOpacity = function(opacity) web2d.Element.prototype.setOpacity = function(opacity) {
{
this._peer.setStroke(null, null, null, opacity); this._peer.setStroke(null, null, null, opacity);
this._peer.setFill(null, opacity); this._peer.setFill(null, opacity);
}; };
web2d.Element.prototype.setVisibility = function(isVisible) web2d.Element.prototype.setVisibility = function(isVisible) {
{
this._peer.setVisibility(isVisible); this._peer.setVisibility(isVisible);
}; };
web2d.Element.prototype.isVisible = function() web2d.Element.prototype.isVisible = function() {
{
return this._peer.isVisible(); return this._peer.isVisible();
}; };
/** /**
* Move the element to the front * Move the element to the front
*/ */
web2d.Element.prototype.moveToFront = function() web2d.Element.prototype.moveToFront = function() {
{
this._peer.moveToFront(); this._peer.moveToFront();
}; };
/** /**
* Move the element to the back * Move the element to the back
*/ */
web2d.Element.prototype.moveToBack = function() web2d.Element.prototype.moveToBack = function() {
{
this._peer.moveToBack(); this._peer.moveToBack();
}; };
web2d.Element.prototype.getStroke = function() web2d.Element.prototype.getStroke = function() {
{
return this._peer.getStroke(); return this._peer.getStroke();
}; };
web2d.Element.prototype.setCursor = function(type) web2d.Element.prototype.setCursor = function(type) {
{
this._peer.setCursor(type); this._peer.setCursor(type);
}; };
web2d.Element.prototype.getParent = function(){ web2d.Element.prototype.getParent = function() {
return this._peer.getParent(); return this._peer.getParent();
} }

View File

@ -1,43 +1,38 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
web2d.Image = function(attributes) web2d.Image = function(attributes) {
{
var peer = web2d.peer.Toolkit.createImage(); var peer = web2d.peer.Toolkit.createImage();
web2d.Element.call(this, peer, attributes); web2d.Element.call(this, peer, attributes);
}; };
objects.extend(web2d.Image, web2d.Element); objects.extend(web2d.Image, web2d.Element);
web2d.Image.prototype.getType = function() web2d.Image.prototype.getType = function() {
{
return "Image"; return "Image";
}; };
web2d.Image.prototype.setHref = function(href) web2d.Image.prototype.setHref = function(href) {
{
this._peer.setHref(href); this._peer.setHref(href);
}; };
web2d.Image.prototype.getHref = function() web2d.Image.prototype.getHref = function() {
{
return this._peer.getHref(); return this._peer.getHref();
}; };
web2d.Image.prototype.getSize = function() web2d.Image.prototype.getSize = function() {
{
return this._peer.getSize(); return this._peer.getSize();
}; };

View File

@ -207,6 +207,13 @@ web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) {
return listeners; return listeners;
}; };
web2d.peer.svg.ElementPeer.prototype.positionRelativeTo = function(elem, options) {
options = !$defined(options) ? {} : options;
options['relativeTo'] = $(this._native);
elem.position(options);
};
/** /**
* Move element to the front * Move element to the front
*/ */

View File

@ -24,7 +24,7 @@
<!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>--> <!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>-->
<script type='text/javascript' src='../js/core.js'></script> <script type='text/javascript' src='/core-js/target/classes/core.js'></script>
<script type="text/javascript"> <script type="text/javascript">
//Google-Brix framework load callback function //Google-Brix framework load callback function
collabOnLoad = function() { collabOnLoad = function() {
@ -200,7 +200,7 @@
<div id="mindplot"></div> <div id="mindplot"></div>
<div id="footerEditor"> <div id="footerEditor">
<div style="position:absolute; top:0px; width:100%"> <div style="position:absolute; top:0; width:100%">
<a href="http://www.wisemapping.com/"> <a href="http://www.wisemapping.com/">
<div id="logo"></div> <div id="logo"></div>
</a> </a>

File diff suppressed because it is too large Load Diff