--- a/client/js/defaults.js Tue Apr 23 10:38:48 2013 +0200
+++ b/client/js/defaults.js Tue Apr 23 17:08:42 2013 +0200
@@ -25,6 +25,7 @@
default_user_color: "#303030",
size_bug_fix: true,
/* Resize the canvas after load (fixes a bug on iPad and FF Mac) */
+ force_resize: false,
allow_double_click: true,
/* Allows Double Click to create a node on an empty background */
element_delete_delay: 5000,
@@ -87,4 +88,4 @@
tooltip_border_color: "#808080",
tooltip_border_width: 1
-}
+};
--- a/client/js/main.js Tue Apr 23 10:38:48 2013 +0200
+++ b/client/js/main.js Tue Apr 23 17:08:42 2013 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Institut de recherche et d'innovation
+ * Copyright 2012-2013 Institut de recherche et d'innovation
* contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
*
* contact@iri.centrepompidou.fr
@@ -96,12 +96,12 @@
},_opts.auto_refresh)
}
}
-}
+};
Rkns._BaseBin.prototype.destroy = function() {
this.$.detach();
this.renkan.resizeBins();
-}
+};
/* Point of entry */
@@ -253,7 +253,7 @@
this.$.find(".Rk-Bins-Search-Form").submit(function() {
return false
});
-}
+};
Rkns.Renkan.prototype.template = Rkns._.template(
'<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>'
@@ -273,16 +273,16 @@
return Rkns.i18n[this.options.language.substr(0,2)][_text];
}
return _text;
-}
+};
Rkns.Renkan.prototype.onStatusChange = function() {
this.renderer.onStatusChange();
-}
+};
Rkns.Renkan.prototype.setSearchEngine = function(_key) {
this.search_engine = this.search_engines[_key];
this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass());
-}
+};
Rkns.Renkan.prototype.resizeBins = function() {
var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
@@ -292,7 +292,7 @@
this.$.find(".Rk-Bin-Main").css({
height: this.$.find(".Rk-Bins").height() - _d
});
-}
+};
/* Utility functions */
@@ -341,17 +341,18 @@
},
inherit : function(_baseClass, _callbefore) {
- var _class = function() {
+ var _class = function(_arg) {
if (typeof _callbefore === "function") {
_callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
}
_baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
- if (typeof this._init == "function") {
+ if (typeof this._init == "function" && !this._initialized) {
this._init.apply(this, Array.prototype.slice.call(arguments, 0));
+ this._initialized = true;
}
}
- _class.prototype = new _baseClass();
+ Rkns._(_class.prototype).extend(_baseClass.prototype);
return _class;
}
-}
\ No newline at end of file
+};
--- a/client/js/paper-renderer.js Tue Apr 23 10:38:48 2013 +0200
+++ b/client/js/paper-renderer.js Tue Apr 23 17:08:42 2013 +0200
@@ -41,14 +41,13 @@
_left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
_right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
_top = _coords.y - _height / 2;
+ if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
+ _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;
+ }
if (_top < _options.tooltip_margin) {
_top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );
}
var _bottom = _top + _height;
- if (_bottom > (paper.view.size.height - _options.tooltip_margin)) {
- _bottom = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 );
- _top = _bottom - _height;
- }
_path.segments[0].point
= _path.segments[7].point
= _coords.add([_isLeft * _xmargin, 0]);
@@ -96,8 +95,16 @@
_renderer.redraw()
}).defer();
}
+ this._selectBinding = function() {
+ _this.select();
+ }
+ this._unselectBinding = function() {
+ _this.unselect();
+ }
this.model.on("change", this._changeBinding );
this.model.on("remove", this._removeBinding );
+ this.model.on("select", this._selectBinding );
+ this.model.on("unselect", this._unselectBinding );
}
}
}
@@ -114,9 +121,17 @@
Rkns.Renderer._BaseRepresentation.prototype.hide = function() {}
-Rkns.Renderer._BaseRepresentation.prototype.select = function() {}
+Rkns.Renderer._BaseRepresentation.prototype.select = function() {
+ if (this.model) {
+ this.model.trigger("selected");
+ }
+}
-Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {}
+Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {
+ if (this.model) {
+ this.model.trigger("unselected");
+ }
+}
Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {}
@@ -124,12 +139,18 @@
Rkns.Renderer._BaseRepresentation.prototype.mousedown = function() {}
-Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {}
+Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {
+ if (this.model) {
+ this.model.trigger("clicked");
+ }
+}
Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {
if (this.model) {
this.model.off("change", this._changeBinding );
this.model.off("remove", this._removeBinding );
+ this.model.off("select", this._selectBinding );
+ this.model.off("unselect", this._unselectBinding );
}
}
@@ -238,17 +259,21 @@
var old_act_btn = this.active_buttons;
if (this.model.get("delete_scheduled")) {
- var opacity = .33;
+ var opacity = .5;
this.active_buttons = this.pending_delete_buttons;
+ this.circle.dashArray = [2,2];
} else {
var opacity = 1;
this.active_buttons = this.normal_buttons;
+ this.circle.dashArray = null;
}
- if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
- old_act_btn.forEach(function(b) {
- b.hide();
- });
+ if (this.selected && this.renderer.isEditable()) {
+ if (old_act_btn !== this.active_buttons) {
+ old_act_btn.forEach(function(b) {
+ b.hide();
+ });
+ }
this.active_buttons.forEach(function(b) {
b.show();
});
@@ -382,6 +407,7 @@
this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
}
+ this.super("select");
}
Rkns.Renderer.Node.prototype.unselect = function(_newTarget) {
@@ -395,6 +421,7 @@
if (this.renderer.minimap) {
this.minimap_circle.strokeColor = undefined;
}
+ this.super("unselect");
}
}
@@ -443,6 +470,7 @@
if (!_isTouch && !this.model.get("delete_scheduled")) {
this.openEditor();
}
+ this.model.trigger("clicked");
}
this.renderer.click_target = null;
this.renderer.is_dragging = false;
@@ -534,7 +562,13 @@
_handle = _v.divide(3),
_color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
- var opacity = (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) ? .33 : 1;
+ if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
+ var opacity = .5;
+ this.line.dashArray = [2, 2];
+ } else {
+ var opacity = 1;
+ this.line.dashArray = null;
+ }
var old_act_btn = this.active_buttons;
@@ -614,6 +648,7 @@
if (!this.options.editor_mode) {
this.openEditor();
}
+ this.super("select");
}
Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) {
@@ -625,6 +660,7 @@
});
}
this.line.strokeWidth = this.options.edge_stroke_width;
+ this.super("unselect");
}
}
@@ -645,6 +681,7 @@
if (!_isTouch) {
this.openEditor();
}
+ this.model.trigger("clicked");
}
this.renderer.click_target = null;
this.renderer.is_dragging = false;
@@ -771,9 +808,27 @@
Rkns.Renderer._BaseEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
+Rkns.Renderer._BaseEditor.prototype._init = function() {
+ this.renderer.buttons_layer.activate();
+ this.type = "editor";
+ this.editor_block = new paper.Path();
+ var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]});
+ this.editor_block.add.apply(this.editor_block, _pts);
+ this.editor_block.strokeWidth = this.options.tooltip_border_width;
+ this.editor_block.strokeColor = this.options.tooltip_border_color;
+ this.editor_block.opacity = .8;
+ this.editor_$ = Rkns.$('<div>')
+ .appendTo(this.renderer.editor_$)
+ .css({
+ position: "absolute",
+ opacity: .8
+ })
+ .hide();
+}
+
Rkns.Renderer._BaseEditor.prototype.destroy = function() {
this.editor_block.remove();
- this.editor_$.detach();
+ this.editor_$.remove();
}
/* */
@@ -957,24 +1012,6 @@
Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
-Rkns.Renderer.EdgeEditor.prototype._init = function() {
- this.renderer.buttons_layer.activate();
- this.type = "editor";
- this.editor_block = new paper.Path();
- var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]});
- this.editor_block.add.apply(this.editor_block, _pts);
- this.editor_block.strokeWidth = this.options.tooltip_border_width;
- this.editor_block.strokeColor = this.options.tooltip_border_color;
- this.editor_block.opacity = .8;
- this.editor_$ = Rkns.$('<div>')
- .appendTo(this.renderer.editor_$)
- .css({
- position: "absolute",
- opacity: .8
- })
- .hide();
-}
-
Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template(
'<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>'
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>'
@@ -1126,26 +1163,6 @@
/* */
-Rkns.Renderer._BaseEditor.prototype._init = function() {
- this.renderer.buttons_layer.activate();
- this.type = "editor";
- this.editor_block = new paper.Path();
- var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]});
- this.editor_block.add.apply(this.editor_block, _pts);
- this.editor_block.strokeWidth = this.options.tooltip_border_width;
- this.editor_block.strokeColor = this.options.tooltip_border_color;
- this.editor_block.opacity = .8;
- this.editor_$ = Rkns.$('<div>')
- .appendTo(this.renderer.editor_$)
- .css({
- position: "absolute",
- opacity: .8
- })
- .hide();
-}
-
-/* */
-
Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
Rkns.Renderer._NodeButton.prototype.setSectorSize = function() {
@@ -1730,25 +1747,25 @@
});
if (_renkan.options.size_bug_fix) {
+ var _delay = (
+ typeof _renkan.options.size_bug_fix === "number"
+ ? _renkan.options.size_bug_fix
+ : 500
+ );
window.setTimeout(
function() {
- var w = _this.$.width(),
- h = _this.$.height();
- if (_renkan.options.show_top_bar) {
- h -= _this.$.find(".Rk-TopBar").height();
- }
- _this.canvas_$.attr({
- width: w,
- height: h
- });
-
- paper.view.viewSize = new paper.Size([w, h]);
- _this.autoScale();
+ _this.fixSize(true);
},
- 500
+ _delay
);
}
+ if (_renkan.options.force_resize) {
+ $(window).resize(function() {
+ _this.fixSize(false);
+ });
+ }
+
this.redraw();
window.setInterval(function() {
@@ -1798,6 +1815,24 @@
+ '</div></div>'
);
+Rkns.Renderer.Scene.prototype.fixSize = function(_autoscale) {
+ var w = this.$.width(),
+ h = this.$.height();
+ if (this.renkan.options.show_top_bar) {
+ h -= this.$.find(".Rk-TopBar").height();
+ }
+ this.canvas_$.attr({
+ width: w,
+ height: h
+ });
+
+ paper.view.viewSize = new paper.Size([w, h]);
+
+ if (_autoscale) {
+ this.autoScale();
+ }
+}
+
Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
var _options = this.renkan.options,
_startRads = _startAngle * Math.PI / 180,