client/js/renderer/nodeeditor.js
changeset 330 4f92e61f87ba
parent 293 fba23fde14ba
child 331 0628ed75e8d3
--- a/client/js/renderer/nodeeditor.js	Wed Sep 10 16:58:01 2014 +0200
+++ b/client/js/renderer/nodeeditor.js	Thu Sep 11 16:49:45 2014 +0200
@@ -21,7 +21,15 @@
                 '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' +
                 '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' +
                 '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' +
-                '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
+                '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +
+                '<% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available:")%></label><select class="Rk-Edit-Shape">' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option>' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option>' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option>' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="polygon"<% if (node.shape === "polygon") { %> selected<% } %>><%- renkan.translate("Hexagone") %></option>' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="ellipse"<% if (node.shape === "ellipse") { %> selected<% } %>><%- renkan.translate("Ellipse") %></option>' +
+                '<option class="Rk-Edit-Vocabulary-Property" value="star"<% if (node.shape === "star") { %> selected<% } %>><%- renkan.translate("Star") %></option>' +
+                '</select></p><% } %>'
         ),
         readOnlyTemplate: _.template(
                 '<h2><span class="Rk-CloseX">&times;</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' +
@@ -51,7 +59,8 @@
                     clip_path: _model.get("clip_path") || false,
                     created_by_color: _created_by.get("color"),
                     created_by_title: _created_by.get("title"),
-                    size: (_size > 0 ? "+" : "") + _size
+                    size: (_size > 0 ? "+" : "") + _size,
+                    shape: _model.get("shape") || "circle"
                 },
                 renkan: this.renkan,
                 options: this.options,
@@ -78,7 +87,7 @@
                     _(function() {
                         if (_this.renderer.isEditable()) {
                             var _data = {
-                                    title: _this.editor_$.find(".Rk-Edit-Title").val()
+                                title: _this.editor_$.find(".Rk-Edit-Title").val()
                             };
                             if (_this.options.show_node_editor_uri) {
                                 _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
@@ -91,12 +100,15 @@
                             if (_this.options.show_node_editor_description) {
                                 _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
                             }
+                            if (_this.options.change_shapes) {
+                                _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
+                                _data.shape_changed = true;
+                            }
                             _model.set(_data);
                             _this.redraw();
                         } else {
                             closeEditor();
                         }
-
                     }).defer();
                 }).throttle(500);
 
@@ -106,7 +118,7 @@
                     }
                 });
 
-                this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange);
+                this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange);
 
                 this.editor_$.find(".Rk-Edit-Image-File").change(function() {
                     if (this.files.length) {