- Read only mode remove actions over topic icons

- Fix other JS Injection issues.
This commit is contained in:
Paulo Gustavo Veiga 2012-08-29 20:17:35 -03:00
parent 96de014d52
commit 592886519e
8 changed files with 135 additions and 131 deletions

View File

@ -17,12 +17,12 @@
*/
mindplot.IconGroup = new Class({
initialize : function(topicId, iconSize) {
initialize:function (topicId, iconSize) {
$assert($defined(topicId), "topicId can not be null");
$assert($defined(iconSize), "iconSize can not be null");
this._icons = [];
this._group = new web2d.Group({width: 0, height:iconSize,x: 0, y:0, coordSizeWidth:0,coordSizeHeight:100});
this._group = new web2d.Group({width:0, height:iconSize, x:0, y:0, coordSizeWidth:0, coordSizeHeight:100});
this._removeTip = new mindplot.IconGroup.RemoveTip(this._group, topicId);
this.seIconSize(iconSize, iconSize);
@ -30,28 +30,28 @@ mindplot.IconGroup = new Class({
},
setPosition : function(x, y) {
setPosition:function (x, y) {
this._group.setPosition(x, y);
},
getPosition : function() {
getPosition:function () {
return this._group.getPosition();
},
getNativeElement : function() {
getNativeElement:function () {
return this._group;
},
getSize : function() {
getSize:function () {
return this._group.getSize();
},
seIconSize : function(width, height) {
this._iconSize = {width:width,height:height};
seIconSize:function (width, height) {
this._iconSize = {width:width, height:height};
this._resize(this._icons.length);
},
addIcon : function(icon, remove) {
addIcon:function (icon, remove) {
$defined(icon, "icon is not defined");
icon.setGroup(this);
@ -70,9 +70,9 @@ mindplot.IconGroup = new Class({
}
},
_findIconFromModel : function(iconModel) {
_findIconFromModel:function (iconModel) {
var result = null;
this._icons.each(function(icon) {
this._icons.each(function (icon) {
var elModel = icon.getModel();
if (elModel.getId() == iconModel.getId()) {
result = icon;
@ -86,14 +86,14 @@ mindplot.IconGroup = new Class({
return result;
},
removeIconByModel : function(featureModel) {
removeIconByModel:function (featureModel) {
$assert(featureModel, "featureModel can not be null");
var icon = this._findIconFromModel(featureModel);
this._removeIcon(icon);
},
_removeIcon : function(icon) {
_removeIcon:function (icon) {
$assert(icon, "icon can not be null");
this._removeTip.close(0);
@ -103,36 +103,36 @@ mindplot.IconGroup = new Class({
this._resize(this._icons.length);
// Add all again ...
this._icons.each(function(elem, i) {
this._icons.each(function (elem, i) {
this._positionIcon(elem, i);
}.bind(this));
},
moveToFront : function() {
moveToFront:function () {
this._group.moveToFront();
},
_registerListeners : function() {
this._group.addEvent('click', function(event) {
_registerListeners:function () {
this._group.addEvent('click', function (event) {
// Avoid node creation ...
event.stopPropagation();
});
this._group.addEvent('dblclick', function(event) {
this._group.addEvent('dblclick', function (event) {
event.stopPropagation();
});
},
_resize : function(iconsLength) {
_resize:function (iconsLength) {
this._group.setSize(iconsLength * this._iconSize.width, this._iconSize.height);
var iconSize = mindplot.Icon.SIZE + (mindplot.IconGroup.ICON_PADDING * 2);
this._group.setCoordSize(iconsLength * iconSize, iconSize);
},
_positionIcon : function(icon, order) {
_positionIcon:function (icon, order) {
var iconSize = mindplot.Icon.SIZE + (mindplot.IconGroup.ICON_PADDING * 2);
icon.getImage().setPosition(iconSize * order + mindplot.IconGroup.ICON_PADDING, mindplot.IconGroup.ICON_PADDING);
@ -141,13 +141,13 @@ mindplot.IconGroup = new Class({
mindplot.IconGroup.ICON_PADDING = 5;
mindplot.IconGroup.RemoveTip = new Class({
initialize : function(container) {
initialize:function (container) {
$assert(container, "group can not be null");
this._fadeElem = container;
},
show : function(topicId, icon) {
show:function (topicId, icon) {
$assert(icon, 'icon can not be null');
// Nothing to do ...
@ -162,15 +162,15 @@ mindplot.IconGroup.RemoveTip = new Class({
// Register events ...
var widget = this._buildWeb2d();
widget.addEvent('click', function() {
widget.addEvent('click', function () {
icon.remove();
});
widget.addEvent('mouseover', function() {
widget.addEvent('mouseover', function () {
this.show(topicId, icon);
}.bind(this));
widget.addEvent('mouseout', function() {
widget.addEvent('mouseout', function () {
this.hide();
}.bind(this));
@ -186,11 +186,11 @@ mindplot.IconGroup.RemoveTip = new Class({
}
},
hide : function() {
hide:function () {
this.close(200);
},
close : function(delay) {
close:function (delay) {
// This is not ok, trying to close the same dialog twice ?
if (this._closeTimeoutId) {
@ -199,7 +199,7 @@ mindplot.IconGroup.RemoveTip = new Class({
if (this._activeIcon) {
var widget = this._widget;
var close = function() {
var close = function () {
this._activeIcon = null;
this._fadeElem.removeChild(widget);
@ -218,19 +218,19 @@ mindplot.IconGroup.RemoveTip = new Class({
}
},
_buildWeb2d : function() {
_buildWeb2d:function () {
var result = new web2d.Group({
width: 10,
width:10,
height:10,
x: 0,
x:0,
y:0,
coordSizeWidth:10,
coordSizeHeight:10
});
var outerRect = new web2d.Rect(0, {
x: 0,
y: 0,
x:0,
y:0,
width:10,
height:10,
stroke:'0',
@ -240,8 +240,8 @@ mindplot.IconGroup.RemoveTip = new Class({
outerRect.setCursor('pointer');
var innerRect = new web2d.Rect(0, {
x: 1,
y: 1,
x:1,
y:1,
width:8,
height:8,
stroke:'1 solid white',
@ -260,10 +260,10 @@ mindplot.IconGroup.RemoveTip = new Class({
result.appendChild(line2);
// Some events ...
result.addEvent('mouseover', function() {
result.addEvent('mouseover', function () {
innerRect.setFill('#CC0033');
});
result.addEvent('mouseout', function() {
result.addEvent('mouseout', function () {
innerRect.setFill('gray');
});
@ -271,14 +271,14 @@ mindplot.IconGroup.RemoveTip = new Class({
return result;
},
decorate : function(topicId, icon) {
decorate:function (topicId, icon) {
if (!icon.__remove) {
icon.addEvent('mouseover', function() {
icon.addEvent('mouseover', function () {
this.show(topicId, icon);
}.bind(this));
icon.addEvent('mouseout', function() {
icon.addEvent('mouseout', function () {
this.hide();
}.bind(this));
icon.__remove = true;

View File

@ -18,27 +18,23 @@
mindplot.ImageIcon = new Class({
Extends:mindplot.Icon,
initialize:function(topic, iconModel) {
initialize:function (topic, iconModel, readOnly) {
$assert(iconModel, 'iconModel can not be null');
$assert(topic, 'topic can not be null');
this._topicId = topic.getId();
this._featureModel = iconModel;
// @Todo: Read only must be a property ...
this._readOnly = designer._readOnly;
// Build graph image representation ...
var iconType = iconModel.getIconType();
var imgUrl = this._getImageUrl(iconType);
this.parent(imgUrl);
//Remove
if (!this._readOnly) {
if (!readOnly) {
//Icon
var image = this.getImage();
image.addEvent('click', function() {
image.addEvent('click', function () {
var iconType = iconModel.getIconType();
var newIconType = this._getNextFamilyIconId(iconType);
@ -52,15 +48,15 @@ mindplot.ImageIcon = new Class({
}
},
_getImageUrl : function(iconId) {
_getImageUrl:function (iconId) {
return "icons/" + iconId + ".png";
},
getModel : function() {
getModel:function () {
return this._featureModel;
},
_getNextFamilyIconId : function(iconId) {
_getNextFamilyIconId:function (iconId) {
var familyIcons = this._getFamilyIcons(iconId);
$assert(familyIcons != null, "Family Icon not found!");
@ -81,7 +77,7 @@ mindplot.ImageIcon = new Class({
return result;
},
_getFamilyIcons : function(iconId) {
_getFamilyIcons:function (iconId) {
$assert(iconId != null, "id must not be null");
$assert(iconId.indexOf("_") != -1, "Invalid icon id (it must contain '_')");
@ -98,7 +94,7 @@ mindplot.ImageIcon = new Class({
return result;
},
remove : function() {
remove:function () {
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
var featureId = this._featureModel.getId();
var topicId = this._topicId;
@ -108,29 +104,29 @@ mindplot.ImageIcon = new Class({
mindplot.ImageIcon.prototype.ICON_FAMILIES = [
{"id": "face", "icons" : ["face_plain","face_sad","face_crying","face_smile","face_surprise","face_wink"]},
{"id": "funy", "icons" : ["funy_angel","funy_devilish","funy_glasses","funy_grin","funy_kiss","funy_monkey"]},
{"id": "conn", "icons" : ["conn_connect","conn_disconnect"]},
{"id": "sport", "icons" : ["sport_basketball","sport_football","sport_golf","sport_raquet","sport_shuttlecock","sport_soccer","sport_tennis"]},
{"id": "bulb", "icons" : ["bulb_light_on","bulb_light_off"]},
{"id": "thumb", "icons" : ["thumb_thumb_up","thumb_thumb_down"]},
{"id": "tick", "icons" : ["tick_tick","tick_cross"]},
{"id": "onoff", "icons" : ["onoff_clock","onoff_clock_red","onoff_add","onoff_delete","onoff_status_offline","onoff_status_online"]},
{"id": "money", "icons" : ["money_money","money_dollar","money_euro","money_pound","money_yen","money_coins","money_ruby"]},
{"id": "time", "icons" : ["time_calendar","time_clock","time_hourglass"]},
{"id": "chart", "icons" : ["chart_bar","chart_line","chart_curve","chart_pie","chart_organisation"]},
{"id": "sign", "icons" : ["sign_warning","sign_info","sign_stop","sign_help","sign_cancel"]},
{"id": "hard", "icons" : ["hard_cd","hard_computer","hard_controller","hard_driver_disk","hard_ipod","hard_keyboard","hard_mouse","hard_printer"]},
{"id": "soft", "icons" : ["soft_bug","soft_cursor","soft_database_table","soft_database","soft_feed","soft_folder_explore","soft_rss","soft_penguin"]},
{"id": "arrow", "icons" : ["arrow_up","arrow_down","arrow_left","arrow_right"]},
{"id": "arrowc", "icons" : ["arrowc_rotate_anticlockwise","arrowc_rotate_clockwise","arrowc_turn_left","arrowc_turn_right"]},
{"id": "people", "icons" : ["people_group","people_male1","people_male2","people_female1","people_female2"]},
{"id": "mail", "icons" : ["mail_envelop","mail_mailbox","mail_edit","mail_list"]},
{"id": "flag", "icons" : ["flag_blue","flag_green","flag_orange","flag_pink","flag_purple","flag_yellow"]},
{"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"]},
{"id": "weather", "icons" : ["weather_clear-night","weather_clear","weather_few-clouds-night","weather_few-clouds","weather_overcast","weather_severe-alert","weather_showers-scattered","weather_showers","weather_snow","weather_storm"]}
{"id":"face", "icons":["face_plain", "face_sad", "face_crying", "face_smile", "face_surprise", "face_wink"]},
{"id":"funy", "icons":["funy_angel", "funy_devilish", "funy_glasses", "funy_grin", "funy_kiss", "funy_monkey"]},
{"id":"conn", "icons":["conn_connect", "conn_disconnect"]},
{"id":"sport", "icons":["sport_basketball", "sport_football", "sport_golf", "sport_raquet", "sport_shuttlecock", "sport_soccer", "sport_tennis"]},
{"id":"bulb", "icons":["bulb_light_on", "bulb_light_off"]},
{"id":"thumb", "icons":["thumb_thumb_up", "thumb_thumb_down"]},
{"id":"tick", "icons":["tick_tick", "tick_cross"]},
{"id":"onoff", "icons":["onoff_clock", "onoff_clock_red", "onoff_add", "onoff_delete", "onoff_status_offline", "onoff_status_online"]},
{"id":"money", "icons":["money_money", "money_dollar", "money_euro", "money_pound", "money_yen", "money_coins", "money_ruby"]},
{"id":"time", "icons":["time_calendar", "time_clock", "time_hourglass"]},
{"id":"chart", "icons":["chart_bar", "chart_line", "chart_curve", "chart_pie", "chart_organisation"]},
{"id":"sign", "icons":["sign_warning", "sign_info", "sign_stop", "sign_help", "sign_cancel"]},
{"id":"hard", "icons":["hard_cd", "hard_computer", "hard_controller", "hard_driver_disk", "hard_ipod", "hard_keyboard", "hard_mouse", "hard_printer"]},
{"id":"soft", "icons":["soft_bug", "soft_cursor", "soft_database_table", "soft_database", "soft_feed", "soft_folder_explore", "soft_rss", "soft_penguin"]},
{"id":"arrow", "icons":["arrow_up", "arrow_down", "arrow_left", "arrow_right"]},
{"id":"arrowc", "icons":["arrowc_rotate_anticlockwise", "arrowc_rotate_clockwise", "arrowc_turn_left", "arrowc_turn_right"]},
{"id":"people", "icons":["people_group", "people_male1", "people_male2", "people_female1", "people_female2"]},
{"id":"mail", "icons":["mail_envelop", "mail_mailbox", "mail_edit", "mail_list"]},
{"id":"flag", "icons":["flag_blue", "flag_green", "flag_orange", "flag_pink", "flag_purple", "flag_yellow"]},
{"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"]},
{"id":"weather", "icons":["weather_clear-night", "weather_clear", "weather_few-clouds-night", "weather_few-clouds", "weather_overcast", "weather_severe-alert", "weather_showers-scattered", "weather_showers", "weather_snow", "weather_storm"]}
];

View File

@ -18,32 +18,34 @@
mindplot.LinkIcon = new Class({
Extends: mindplot.Icon,
initialize : function(topic, linkModel) {
Extends:mindplot.Icon,
initialize:function (topic, linkModel, readOnly) {
$assert(topic, 'topic can not be null');
$assert(linkModel, 'linkModel can not be null');
this.parent(mindplot.LinkIcon.IMAGE_URL);
this._linksModel = linkModel;
this._topic = topic;
this._readOnly = readOnly;
this._registerEvents();
},
_registerEvents : function() {
_registerEvents:function () {
this._image.setCursor('pointer');
// Add on click event to open the editor ...
this.addEvent('click', function(event) {
this._topic.showLinkEditor();
event.stopPropagation();
}.bind(this));
if (!this._readOnly) {
// Add on click event to open the editor ...
this.addEvent('click', function (event) {
this._topic.showLinkEditor();
event.stopPropagation();
}.bind(this));
}
this._tip = new mindplot.widget.LinkIconTooltip(this);
},
getModel : function() {
getModel:function () {
return this._linksModel;
}
});

View File

@ -17,29 +17,33 @@
*/
mindplot.NoteIcon = new Class({
Extends: mindplot.Icon,
initialize : function(topic, noteModel) {
Extends:mindplot.Icon,
initialize:function (topic, noteModel, readOnly) {
$assert(topic, 'topic can not be null');
this.parent(mindplot.NoteIcon.IMAGE_URL);
this._linksModel = noteModel;
this._topic = topic;
this._readOnly = readOnly;
this._registerEvents();
},
_registerEvents : function() {
_registerEvents:function () {
this._image.setCursor('pointer');
// Add on click event to open the editor ...
this.addEvent('click', function(event) {
this._topic.showNoteEditor();
event.stopPropagation();
}.bind(this));
if (!this._readOnly) {
// Add on click event to open the editor ...
this.addEvent('click', function (event) {
this._topic.showNoteEditor();
event.stopPropagation();
}.bind(this));
}
this._tip = new mindplot.widget.FloatingTip(this.getImage()._peer._native, {
// Content can also be a function of the target element!
content: function() {
content:function () {
var result = new Element('div');
result.setStyles({padding:'5px'});
@ -48,14 +52,14 @@ mindplot.NoteIcon = new Class({
'font-weight':'bold',
color:'black',
'padding-bottom':'5px',
width: '100px'
width:'100px'
});
title.inject(result);
var text = new Element('div', {text:this._linksModel.getText()});
text.setStyles({
'white-space': 'pre-wrap',
'word-wrap': 'break-word'
'white-space':'pre-wrap',
'word-wrap':'break-word'
}
);
text.inject(result);
@ -63,17 +67,17 @@ mindplot.NoteIcon = new Class({
return result;
}.bind(this),
html: true,
position: 'bottom',
arrowOffset : 10,
center: true,
arrowSize: 15,
offset : {x:10,y:20},
html:true,
position:'bottom',
arrowOffset:10,
center:true,
arrowSize:15,
offset:{x:10, y:20},
className:'notesTip'
});
},
getModel : function() {
getModel:function () {
return this._linksModel;
}
});

View File

@ -267,8 +267,8 @@ mindplot.Topic = new Class({
var featuresModel = model.getFeatures();
for (var i = 0; i < featuresModel.length; i++) {
var featureModel = featuresModel[i];
var icon = mindplot.TopicFeature.createIcon(this, featureModel);
result.addIcon(icon, featureModel.getType() == "icon"); // @Todo: Remove hack ...
var icon = mindplot.TopicFeature.createIcon(this, featureModel, this.isReadOnly());
result.addIcon(icon, featureModel.getType() == mindplot.TopicFeature.Icon.id && !this.isReadOnly());
}
return result;
@ -284,8 +284,8 @@ mindplot.Topic = new Class({
var feature = model.createFeature(type, attributes);
model.addFeature(feature);
var result = mindplot.TopicFeature.createIcon(this, feature);
iconGroup.addIcon(result, type == "icon"); // @Todo: Remove hack ...
var result = mindplot.TopicFeature.createIcon(this, feature, this.isReadOnly());
iconGroup.addIcon(result, type == mindplot.TopicFeature.Icon.id && !this.isReadOnly());
this._adjustShapes();
return result;
@ -669,6 +669,7 @@ mindplot.Topic = new Class({
showNoteEditor:function () {
var topicId = this.getId();
var model = this.getModel();
var editorModel = {

View File

@ -17,51 +17,51 @@
*/
mindplot.TopicFeature = {
Icon: {
Icon:{
id:mindplot.model.IconModel.FEATURE_TYPE,
model: mindplot.model.IconModel,
icon : mindplot.ImageIcon
model:mindplot.model.IconModel,
icon:mindplot.ImageIcon
},
Link: {
id: mindplot.model.LinkModel.FEATURE_TYPE,
model: mindplot.model.LinkModel,
icon : mindplot.LinkIcon
Link:{
id:mindplot.model.LinkModel.FEATURE_TYPE,
model:mindplot.model.LinkModel,
icon:mindplot.LinkIcon
},
Note: {
id: mindplot.model.NoteModel.FEATURE_TYPE,
model: mindplot.model.NoteModel,
icon : mindplot.NoteIcon
Note:{
id:mindplot.model.NoteModel.FEATURE_TYPE,
model:mindplot.model.NoteModel,
icon:mindplot.NoteIcon
},
isSupported : function(id) {
return mindplot.TopicFeature._featuresMetadataById.some(function(elem) {
isSupported:function (id) {
return mindplot.TopicFeature._featuresMetadataById.some(function (elem) {
return elem.id == id;
});
},
createModel : function(id, attributes) {
createModel:function (id, attributes) {
$assert(id, 'type can not be null');
$assert(attributes, 'attributes can not be null');
var model = mindplot.TopicFeature._featuresMetadataById.filter(function(elem) {
var model = mindplot.TopicFeature._featuresMetadataById.filter(function (elem) {
return elem.id == id;
})[0].model;
return new model(attributes);
},
createIcon : function(topic, model) {
createIcon:function (topic, model, readOnly) {
$assert(topic, 'topic can not be null');
$assert(model, 'model can not be null');
var icon = mindplot.TopicFeature._featuresMetadataById.filter(function(elem) {
var icon = mindplot.TopicFeature._featuresMetadataById.filter(function (elem) {
return elem.id == model.getType();
})[0].icon;
return new icon(topic, model);
return new icon(topic, model, readOnly);
}
};
mindplot.TopicFeature._featuresMetadataById = [mindplot.TopicFeature.Icon,mindplot.TopicFeature.Link,mindplot.TopicFeature.Note];
mindplot.TopicFeature._featuresMetadataById = [mindplot.TopicFeature.Icon, mindplot.TopicFeature.Link, mindplot.TopicFeature.Note];

View File

@ -12,7 +12,7 @@
<html>
<head>
<base href="${baseURL}/">
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
<title><spring:message code="SITE.TITLE"/> - <c:out value="${mindmap.title}"/></title>
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
@ -73,14 +73,15 @@
</c:if>
<c:if test="${memoryPersistence}">
<span><a href="c/keyboard" id="keyboardShortcuts"><spring:message code="SHORTCUTS"/></a></span> |
<span><a href="c/user/registration" title="<spring:message code="REGISTER"/>"><spring:message code="REGISTER"/></a></span>
<span><a href="c/user/registration" title="<spring:message code="REGISTER"/>"><spring:message
code="REGISTER"/></a></span>
</c:if>
</div>
<a href="c/maps/">
<div id="headerLogo"></div>
</a>
<div id="headerMapTitle"><spring:message code="NAME"/>: <span>${mindmap.title}</span></div>
<div id="headerMapTitle"><spring:message code="NAME"/>: <span><c:out value="${mindmap.title}"/></span></div>
</div>
<%@ include file="/jsp/mindmapEditorToolbar.jsf" %>
</div>

View File

@ -58,7 +58,7 @@
bUseRendered:false,
mDataProp:"title",
fnRender:function (obj) {
return $('<a href="c/maps/' + obj.aData.id + '/edit"></a>').text(obj.aData.title).html();
return '<a href="c/maps/' + obj.aData.id + '/edit">' + $('<span></span>').text(obj.aData.title).html() + '</a>';
}
},
{