# HG changeset patch # User ymh # Date 1360582775 -3600 # Node ID 17ff0be41a5b802c230f4e6a5d9c4d1c87c7b21a # Parent 43c35d6ca3f00401f3197701d0fad09844468e26# Parent bb63da14423953b348140c42460d8a46fc20de02 Merge with bb63da14423953b348140c42460d8a46fc20de02 diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/css/renkan.css --- a/client/css/renkan.css Mon Feb 11 10:34:23 2013 +0100 +++ b/client/css/renkan.css Mon Feb 11 12:39:35 2013 +0100 @@ -193,12 +193,12 @@ font-size: 16px; font-weight: bold; } -.Rk-Editor p { +.Rk-Editor p, .Rk-Editor-p { margin: 5px 0; font-size: 12px; } .Rk-Editor label { - display: inline-block; width: 70px; + float: left; width: 70px; } a.Rk-Edit-Goto { @@ -223,7 +223,32 @@ } .Rk-UserColor { - display: inline-block; width: 1em; height: 1em; border: 1px solid #666666; margin: -2px 2px; + display: inline-block; width: 12px; height: 12px; border: 1px solid #666666; margin: -2px 2px; +} + +.Rk-Edit-Color { + display: inline-block; width: 10px; height: 10px; border: 2px solid #333333; margin: -2px 2px; +} + +.Rk-Edit-ColorTip { + display: block; width: 3px; height: 3px; background: #fff; margin: 7px 0 0 7px; cursor: pointer; +} + +.Rk-Edit-ColorPicker-Wrapper { + display: inline-block; position: relative; +} + +.Rk-Edit-ColorPicker { + position: absolute; top: -2px; left: 15px; width: 96px; height: 96px; border: 1px solid #CCCCCC; + padding: 5px 4px 4px 5px; background: #ffffff; border-radius: 5px; display: none; +} + +.Rk-Edit-ColorPicker-Text { + color: #303080; font-weight: bold; +} + +.Rk-Edit-ColorPicker li { + float: left; width: 11px; height: 11px; margin: 0 1px 1px 0; cursor: pointer; } .Rk-ZoomButtons { diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/data/test-data.json --- a/client/data/test-data.json Mon Feb 11 10:34:23 2013 +0100 +++ b/client/data/test-data.json Mon Feb 11 12:39:35 2013 +0100 @@ -1,8 +1,8 @@ { "users": [ { - "_id": "u-anonymous", - "title": "anonymous", + "_id": "u-iri", + "title": "IRI", "uri": "", "description": "", "color": "#dd00dd" @@ -284,7 +284,7 @@ "description": "", "from": "node-2012-08-22-b778a9fc31296d6b-000a", "to": "node-2012-08-22-9da6eef6c6391d05-000b", - "created_by": "u-anonymous" + "created_by": "u-iri" }, { "_id": "edge-2012-09-06-70cc0c2d5e1112d3-0002", "title": "tool used", @@ -292,7 +292,7 @@ "description": "", "from": "node-2012-08-22-5b349e49066c1b01-0001", "to": "node-2012-08-22-b778a9fc31296d6b-000a", - "created_by": "u-anonymous" + "created_by": "u-iri" } ] } \ No newline at end of file diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/main.js --- a/client/js/main.js Mon Feb 11 10:34:23 2013 +0100 +++ b/client/js/main.js Mon Feb 11 12:39:35 2013 +0100 @@ -26,6 +26,8 @@ Rkns._ = _; +Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc", "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc", "#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc", "#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc", "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe", "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe", "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe", "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"]; + Rkns._BaseBin = function(_renkan, _opts) { if (typeof _renkan !== "undefined") { this.renkan = _renkan; diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/models.js --- a/client/js/models.js Mon Feb 11 10:34:23 2013 +0100 +++ b/client/js/models.js Mon Feb 11 12:39:35 2013 +0100 @@ -88,6 +88,7 @@ description: this.get("description"), position: this.get("position"), image: this.get("image"), + color: this.get("color"), created_by: this.get("created_by") ? this.get("created_by").get("_id") : null }; }, @@ -128,6 +129,7 @@ description: this.get("description"), from: this.get("from") ? this.get("from").get("_id") : null, to: this.get("to") ? this.get("to").get("_id") : null, + color: this.get("color"), created_by: this.get("created_by") ? this.get("created_by").get("_id") : null }; }, diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/paper-renderer.js --- a/client/js/paper-renderer.js Mon Feb 11 10:34:23 2013 +0100 +++ b/client/js/paper-renderer.js Mon Feb 11 12:39:35 2013 +0100 @@ -20,7 +20,14 @@ _EDITOR_GRADIENT : new paper.Gradient(['#f0f0f0', '#d0d0d0']), _CLICKMODE_ADDNODE : 1, _CLICKMODE_STARTEDGE : 2, - _CLICKMODE_ENDEDGE : 3 + _CLICKMODE_ENDEDGE : 3, + _USER_PLACEHOLDER : { + color: "#000000", + title: "(unknown user)", + get: function(attr) { + return this[attr] || false; + } + } } Rkns.Renderer.Utils = { @@ -236,6 +243,7 @@ this.circle = new paper.Path.Circle([0, 0], Rkns.Renderer._NODE_RADIUS); this.circle.fillColor = '#ffffff'; this.circle.__representation = this; + this.circle.strokeWidth = 2; this.title = new paper.PointText([0,0]); this.title.characterStyle = { fontSize: Rkns.Renderer._NODE_FONT_SIZE, @@ -256,7 +264,7 @@ this.circle.position = this.paper_coords; this.title.content = this.model.get("title"); this.title.position = this.paper_coords.add([0, Rkns.Renderer._NODE_RADIUS + 1.5 *Rkns.Renderer._NODE_FONT_SIZE]); - this.circle.strokeColor = this.model.get("created_by").get("color"); + this.circle.strokeColor = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"); this.edit_button.moveTo(this.paper_coords); this.remove_button.moveTo(this.paper_coords); this.link_button.moveTo(this.paper_coords); @@ -317,7 +325,7 @@ } Rkns.Renderer.Node.prototype.select = function() { - this.circle.strokeWidth = 3; + this.circle.strokeWidth = 4; this.edit_button.show(); this.remove_button.show(); this.link_button.show(); @@ -335,7 +343,7 @@ this.edit_button.hide(); this.remove_button.hide(); this.link_button.hide(); - this.circle.strokeWidth = 1; + this.circle.strokeWidth = 2; Rkns.$('.Rk-Bin-Item').removeClass("selected"); } } @@ -387,6 +395,7 @@ this.line = new paper.Path(); this.line.add([0,0],[0,0],[0,0]); this.line.__representation = this; + this.line.strokeWidth = 2; this.arrow = new paper.Path(); this.arrow.add([0,0],[Rkns.Renderer._ARROW_LENGTH,Rkns.Renderer._ARROW_WIDTH / 2],[0,Rkns.Renderer._ARROW_WIDTH]); this.arrow.__representation = this; @@ -416,7 +425,7 @@ _p1b = _p1a.add(_delta), /* to differentiate inbound and outbound links */ _a = _v.angle, _handle = _v.divide(3), - _color = this.model.get("created_by").get("color"); + _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color");; this.paper_coords = _p0b.add(_p1b).divide(2); this.line.strokeColor = _color; this.line.segments[0].point = _p0a; @@ -450,7 +459,7 @@ } Rkns.Renderer.Edge.prototype.select = function() { - this.line.strokeWidth = 3; + this.line.strokeWidth = 4; this.edit_button.show(); this.remove_button.show(); } @@ -459,7 +468,7 @@ if (!_newTarget || _newTarget.edge_representation !== this) { this.edit_button.hide(); this.remove_button.hide(); - this.line.strokeWidth = 1; + this.line.strokeWidth = 2; } } @@ -498,7 +507,7 @@ this.renderer.edge_layer.activate(); this.type = "temp-edge"; - var _color = this.project.get("users").get(this.renderer.renkan.current_user).get("color"); + var _color = this.project.get("users").get(this.renderer.renkan.current_user).get("color") || "#000000"; this.line = new paper.Path(); this.line.strokeColor = _color; this.line.add([0,0],[0,0]); @@ -590,12 +599,15 @@ + '

' + '

' + '

' + + '
    ' + + '<% print(Rkns.pickerColors.reduce(function(m,c) { return m + "
  • "},"")); %>
Choose color
' + '

' + '

<%=node.created_by_title%>

' ); Rkns.Renderer.NodeEditor.prototype.draw = function() { - var _model = this.node_representation.model; + var _model = this.node_representation.model, + _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER; this.editor_$ .html(this.template({ node: { @@ -603,8 +615,9 @@ uri: _model.get("uri"), description: _model.get("description"), image: _model.get("image") || "", - created_by_color: _model.get("created_by").get("color"), - created_by_title: _model.get("created_by").get("title") + color: _model.get("color") || _created_by.get("color"), + created_by_color: _created_by.get("color"), + created_by_title: _created_by.get("title") }, l10n: this.renderer.renkan.l10n })); @@ -632,6 +645,17 @@ _this.redraw(); }) this.editor_$.find(".Rk-Edit-Title")[0].focus(); + this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( + function() { _this.editor_$.find(".Rk-Edit-ColorPicker").show(); }, + function() { _this.editor_$.find(".Rk-Edit-ColorPicker").hide(); } + ); + this.editor_$.find(".Rk-Edit-ColorPicker li").hover( + function() { _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); }, + function() { _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color")) } + ).click(function() { + _model.set("color", $(this).attr("data-color")); + _this.redraw(); + }); } Rkns.Renderer.NodeEditor.prototype.redraw = function() { @@ -673,25 +697,31 @@ '

×<%=l10n.edit_edge%>

' + '

' + '

' - + '

<%=edge.from_title%>

' - + '

<%=edge.to_title%>

' + + '
    ' + + '<% print(Rkns.pickerColors.reduce(function(m,c) { return m + "
  • "},"")); %>
Choose color
' + + '

<%=edge.from_title%>

' + + '

<%=edge.to_title%>

' + '

<%=edge.created_by_title%>

' ); Rkns.Renderer.EdgeEditor.prototype.draw = function() { - var _model = this.edge_representation.model; + var _model = this.edge_representation.model, + _from_model = _model.get("from"), + _to_model = _model.get("to"), + _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER; this.editor_$ .html(this.template({ edge: { title: _model.get("title"), uri: _model.get("uri"), description: _model.get("description"), - from_title: _model.get("from").get("title"), - to_title: _model.get("to").get("title"), - from_created_by_color: _model.get("from").get("created_by").get("color"), - to_created_by_color: _model.get("to").get("created_by").get("color"), - created_by_color: _model.get("created_by").get("color"), - created_by_title: _model.get("created_by").get("title") + color: _model.get("color") || _created_by.get("color"), + from_title: _from_model.get("title"), + to_title: _to_model.get("title"), + from_color: _from_model.get("color") || (_from_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"), + to_color: _to_model.get("color") || (_to_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"), + created_by_color: _created_by.get("color"), + created_by_title: _created_by.get("title") }, l10n: this.renderer.renkan.l10n })); @@ -710,6 +740,17 @@ _model.set(_data); _this.redraw(); }); + this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( + function() { _this.editor_$.find(".Rk-Edit-ColorPicker").show(); }, + function() { _this.editor_$.find(".Rk-Edit-ColorPicker").hide(); } + ); + this.editor_$.find(".Rk-Edit-ColorPicker li").hover( + function() { _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); }, + function() { _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color")); } + ).click(function() { + _model.set("color", $(this).attr("data-color")); + _this.redraw(); + }); } Rkns.Renderer.EdgeEditor.prototype.redraw = function() { var _coords = this.edge_representation.paper_coords; diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/retrieve-kc.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/retrieve-kc.js Mon Feb 11 12:39:35 2013 +0100 @@ -0,0 +1,52 @@ +/* Imports a KC graph */ + +Rkns.retrieveKC = function(_renkan, _opts) { + if (typeof _opts === "undefined") { + var _opts = {} + } + var _proj = _renkan.project, + _username = _opts.user_name || "Yves-Marie", + _userid = _opts.user_id || "yves-marie.haussonne@centrepompidou.fr", + _usercolor = _opts.user_color || "#800000", + _allid = _opts.all_id || "B0000044", + _projid = _opts.proj || "ozu_silent", + _kcept = _opts.endpoint || "/sites/kcproxy/allRetrieve.jsp" + var _load = function() { + Rkns.$.getJSON(_kcept, + { + all_id: _allid, + proj: _projid, + uid: _userid + }, + function(_data) { + _proj.addUser({ + id: _userid, + color: _usercolor, + title: _username + }); + Rkns._(_data.node).each(function(_node) { + _proj.addNode({ + id: _node.id, + title: _node.name, + description: 'Knowledge concierge node from project "' + _projid + '" belonging to group "' + _node.grp + '"', + position: { + x: _node.x, + y: _node.y + }, + created_by: _userid + }) + }); + Rkns._(_data.edge).each(function(_edge) { + _proj.addEdge({ + id: _edge.asc_id, + from: _edge.id, + to: _edge.to_id, + created_by: _userid, + title: _edge.r_name + }); + }); + _renkan.renderer.autoScale(); + }); + } + _load(); +} diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/save-once.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/save-once.js Mon Feb 11 12:39:35 2013 +0100 @@ -0,0 +1,75 @@ +/* Saves the Full JSON once */ + +Rkns.jsonIO = function(_renkan, _opts) { + var _proj = _renkan.project, + _saveWarn = false, + _onLeave = function() { + return "Project not saved"; + }; + if (typeof _opts.http_method == "undefined") { + _opts.http_method = 'POST'; + } + var _load = function() { + var getdata = {}, + rx = /id=([^&#?=]+)/, + matches = document.location.hash.match(rx); + if (matches) { + getdata.id = matches[1]; + } + Rkns.$.ajax({ + url: _opts.url, + data: getdata, + success: function(_data) { + _proj.set(_data); + _renkan.renderer.autoScale(); + } + }); + } + var _save = function() { + _proj.set("saved_at", new Date()); + var _data = _proj.toJSON(); + Rkns.$.ajax({ + type: _opts.http_method, + url: _opts.url, + contentType: "application/json", + data: JSON.stringify(_data), + success: function(data, textStatus, jqXHR) { + $(window).off("beforeunload", _onLeave); + _saveWarn = false; + document.location.hash = "#id=" + data.id; + $(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut(); + } + }); + } + var _checkLeave = function() { + var title = _proj.get("title"); + if (title && _proj.get("nodes").length) { + $(".Rk-Save-Button").removeClass("disabled"); + } else { + $(".Rk-Save-Button").addClass("disabled"); + } + if (title) { + $(".Rk-PadTitle").css("border-color","#333333"); + } + if (!_saveWarn) { + _saveWarn = true; + $(window).on("beforeunload", _onLeave); + } + } + _load(); + _proj.on("add:nodes add:edges add:users change", function(_model) { + _model.on("change remove", function(_model) { + _checkLeave(); + }); + _checkLeave(); + }); + $(".Rk-Save-Button").click(function() { + if ($(this).hasClass("disabled")) { + if (!_proj.get("title")) { + $(".Rk-PadTitle").css("border-color","#ff0000"); + } + } else { + _save(); + } + }); +} diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/js/wikipedia-bin.js --- a/client/js/wikipedia-bin.js Mon Feb 11 10:34:23 2013 +0100 +++ b/client/js/wikipedia-bin.js Mon Feb 11 12:39:35 2013 +0100 @@ -49,7 +49,8 @@ return _text.replace(_rgxp, "$1"); } var _html = "", - _this = this; + _this = this, + count = 0; Rkns._(this.data.query.search).each(function(_result) { var title = _result.title, url = "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(title.replace(/ /g,"_")), diff -r 43c35d6ca3f0 -r 17ff0be41a5b client/render-test.html --- a/client/render-test.html Mon Feb 11 10:34:23 2013 +0100 +++ b/client/render-test.html Mon Feb 11 12:39:35 2013 +0100 @@ -22,31 +22,11 @@ diff -r 43c35d6ca3f0 -r 17ff0be41a5b crea/buttons.psd Binary file crea/buttons.psd has changed diff -r 43c35d6ca3f0 -r 17ff0be41a5b metadataplayer/renkan.htm --- a/metadataplayer/renkan.htm Mon Feb 11 10:34:23 2013 +0100 +++ b/metadataplayer/renkan.htm Mon Feb 11 12:39:35 2013 +0100 @@ -17,7 +17,6 @@ width: 600px; height: 500px; margin: 5px; - background: #fff; } @@ -33,6 +32,7 @@ IriSP.language = 'fr'; IriSP.widgetsDir = "metadataplayer"; var _metadata = { +// url: 'json/ldt-jwplayer.json', url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/67280b1c-ff30-11e0-a82d-00145ea49a02?callback=?', format: 'ldt' }; @@ -49,6 +49,7 @@ { type: "Controller" }, { type: "Polemic" }, { type: "Segments" }, + { type: "Slice" }, { type: "Arrow", base_height: 4 @@ -58,7 +59,7 @@ { type: "Renkan", container: "RenkanContainer", - data: "json/renkan.json" + data: [ "json/renkan.json", "json/renkan-2.json" ] }, { type: "Mediafragment"} ] @@ -82,7 +83,7 @@ } }; - _myPlayer = new IriSP.Metadataplayer(_config); + var _myPlayer = new IriSP.Metadataplayer(_config); diff -r 43c35d6ca3f0 -r 17ff0be41a5b server/src/main/webapp/static/js/config.js --- a/server/src/main/webapp/static/js/config.js Mon Feb 11 10:34:23 2013 +0100 +++ b/server/src/main/webapp/static/js/config.js Mon Feb 11 12:39:35 2013 +0100 @@ -5,7 +5,7 @@ // Copyright (c) The Dojo Foundation 2011. All Rights Reserved. // var dojoConfig = { - baseUrl: '/renkan', + baseUrl: '/', /* WAS /renkan */ async:true, paths : { coweb : 'lib/coweb',