')
.appendTo(this.renderer.editor_$)
.css({
position: "absolute",
opacity: .8
})
.hide();
-};
-
-Rkns.Renderer._BaseEditor.prototype.destroy = function() {
+},
+destroy: function() {
this.editor_block.remove();
this.editor_$.remove();
-};
+}
+});
/* */
-Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
+var NodeEditor = Renderer.NodeEditor = Rkns.Utils.inherit(_BaseEditor);
-Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template(
+_(NodeEditor.prototype).extend({
+template: _.template(
'
×<%-renkan.translate("Edit Node")%>
'
+ '
'
+ '<% if (options.show_node_editor_uri) { %>
<% } %>'
+ '<% if (options.show_node_editor_description) { %>
<% } %>'
+ '<% if (options.show_node_editor_size) { %>
<%-renkan.translate("Size:")%>-<%-node.size%>+
<% } %>'
- + '<% if (options.show_node_editor_color) { %>
<%-renkan.translate("Node color:")%>'
- + '<% _(Rkns.pickerColors).each(function(c) { %><% }); %>
<%- renkan.translate("Choose color") %> <% } %>'
+ + '<% if (options.show_node_editor_color) { %>
<%-renkan.translate("Node color:")%>'
+ + '<%= renkan.colorPicker %><%- renkan.translate("Choose color") %>
<% } %>'
+ '<% if (options.show_node_editor_image) { %>

'
+ '<% if (node.clip_path) { %>
<% }%>'
+ '
'
+ '
<% } %>'
- + '<% if (options.show_node_editor_creator && node.has_creator) { %>
<%-renkan.translate("Created by:")%> <%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>'
-);
-
-Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template(
+ + '<% if (options.show_node_editor_creator && node.has_creator) { %>
<%-renkan.translate("Created by:")%> <%- shortenText(node.created_by_title, 25) %>
<% } %>'
+),
+readOnlyTemplate: _.template(
'
'
+ '<% if (node.uri && options.show_node_tooltip_uri) { %>
<%-node.short_uri%>
<% } %>'
- + '<% if (options.show_node_tooltip_description) { %>
<%-node.description%>
<% } %>'
+ + '<% if (options.show_node_tooltip_description) { %>
<%-node.description%>
<% } %>'
+ '<% if (node.image && options.show_node_tooltip_image) { %>

<% } %>'
- + '<% if (node.has_creator && options.show_node_tooltip_creator) { %>
<%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>'
-);
-
-Rkns.Renderer.NodeEditor.prototype.draw = function() {
+ + '<% if (node.has_creator && options.show_node_tooltip_creator) { %>
<%-renkan.translate("Created by:")%><%- shortenText(node.created_by_title, 25) %>
<% } %>'
+),
+draw: function() {
var _model = this.source_representation.model,
- _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan),
+ _created_by = _model.get("created_by") || _USER_PLACEHOLDER(this.renkan),
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),
_image_placeholder = this.options.static_url + "img/image-placeholder.png",
_size = (_model.get("size") || 0);
@@ -1849,7 +1974,7 @@
has_creator: !!_model.get("created_by"),
title: _model.get("title"),
uri: _model.get("uri"),
- short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
+ short_uri: shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
description: _model.get("description"),
image: _model.get("image") || "",
image_placeholder: _image_placeholder,
@@ -1860,7 +1985,8 @@
size: (_size > 0 ? "+" : "") + _size
},
renkan: this.renkan,
- options: this.options
+ options: this.options,
+ shortenText: shortenText
}));
this.redraw();
var _this = this,
@@ -1871,16 +1997,23 @@
this.editor_$.find(".Rk-CloseX").click(closeEditor);
+ this.editor_$.find(".Rk-Edit-Goto").click(function() {
+ if (!_model.get("uri")) {
+ return false;
+ }
+ });
+
if (this.renderer.isEditable()) {
- var onFieldChange = Rkns._(function() {
- Rkns._(function() {
+ var onFieldChange = _(function() {
+ _(function() {
if (_this.renderer.isEditable()) {
var _data = {
title: _this.editor_$.find(".Rk-Edit-Title").val()
};
if (_this.options.show_node_editor_uri) {
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
+ _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
}
if (_this.options.show_node_editor_image) {
_data.image = _this.editor_$.find(".Rk-Edit-Image").val();
@@ -1914,8 +2047,8 @@
alert(_this.renkan.translate("This file is not an image"));
return;
}
- if (f.size > (Rkns.Renderer._IMAGE_MAX_KB * 1024)) {
- alert(_this.renkan.translate("Image size must be under ")+Rkns.Renderer._IMAGE_MAX_KB+_this.renkan.translate("KB"));
+ if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
+ alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
return;
}
fr.onload = function(e) {
@@ -1947,7 +2080,7 @@
},
function(_e) {
_e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
+ _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || _USER_PLACEHOLDER(_this.renkan)).get("color"));
}
).click(function(_e) {
_e.preventDefault();
@@ -1960,7 +2093,7 @@
}
});
- function shiftSize(n) {
+ var shiftSize = function(n) {
if (_this.renderer.isEditable()) {
var _newsize = n+(_model.get("size") || 0);
_this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
@@ -1969,7 +2102,7 @@
} else {
closeEditor();
}
- }
+ };
this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
shiftSize(-1);
@@ -1979,24 +2112,33 @@
shiftSize(1);
return false;
});
+ } else {
+ if (typeof this.source_representation.highlighted === "object") {
+ var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'
$1');
+ this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
+ if (this.options.show_node_tooltip_description) {
+ this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'
$1'));
+ }
+ }
}
this.editor_$.find("img").load(function() {
_this.redraw();
});
-};
-
-Rkns.Renderer.NodeEditor.prototype.redraw = function() {
+},
+redraw: function() {
var _coords = this.source_representation.paper_coords;
- Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$);
+ drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$);
this.editor_$.show();
paper.view.draw();
-};
+}
+});
/* */
-Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
+var EdgeEditor = Renderer.EdgeEditor = Rkns.Utils.inherit(_BaseEditor);
-Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template(
+_(EdgeEditor.prototype).extend({
+template: _.template(
'
×<%-renkan.translate("Edit Edge")%>
'
+ '
'
+ '<% if (options.show_edge_editor_uri) { %>
'
@@ -2005,29 +2147,27 @@
+ '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %>
'
+ '<% }) %><% }) %><% } } %>'
- + '<% if (options.show_edge_editor_color) { %>
<%-renkan.translate("Edge color:")%>'
- + '<% _(Rkns.pickerColors).each(function(c) { %><% }); %>
<%- renkan.translate("Choose color") %> <% } %>'
+ + '<% if (options.show_edge_editor_color) { %>
<%-renkan.translate("Edge color:")%>'
+ + '<%= renkan.colorPicker %><%- renkan.translate("Choose color") %>
<% } %>'
+ '<% if (options.show_edge_editor_direction) { %>
<%- renkan.translate("Change edge direction") %>
<% } %>'
- + '<% if (options.show_edge_editor_nodes) { %>
<%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>
'
- + '
<%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>
<% } %>'
- + '<% if (options.show_edge_editor_creator && edge.has_creator) { %>
<%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>
<% } %>'
-);
-
-Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template(
+ + '<% if (options.show_edge_editor_nodes) { %>
<%-renkan.translate("From:")%><%- shortenText(edge.from_title, 25) %>
'
+ + '
<%-renkan.translate("To:")%><%- shortenText(edge.to_title, 25) %>
<% } %>'
+ + '<% if (options.show_edge_editor_creator && edge.has_creator) { %>
<%-renkan.translate("Created by:")%><%- shortenText(edge.created_by_title, 25) %>
<% } %>'
+),
+readOnlyTemplate: _.template(
'
'
+ '<% if (options.show_edge_tooltip_uri && edge.uri) { %>
<%-edge.short_uri%>
<% } %>'
+ '
<%-edge.description%>
'
- + '<% if (options.show_edge_tooltip_nodes) { %>
<%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>
'
- + '
<%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>
<% } %>'
- + '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %>
<%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>
<% } %>'
-);
-
-Rkns.Renderer.EdgeEditor.prototype.draw = function() {
+ + '<% if (options.show_edge_tooltip_nodes) { %>
<%-renkan.translate("From:")%><%- shortenText(edge.from_title, 25) %>
'
+ + '
<%-renkan.translate("To:")%><%- shortenText(edge.to_title, 25) %>
<% } %>'
+ + '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %>
<%-renkan.translate("Created by:")%><%- shortenText(edge.created_by_title, 25) %>
<% } %>'
+),
+draw: function() {
var _model = this.source_representation.model,
_from_model = _model.get("from"),
_to_model = _model.get("to"),
- _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan),
+ _created_by = _model.get("created_by") || _USER_PLACEHOLDER(this.renkan),
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);
this.editor_$
.html(_template({
@@ -2035,18 +2175,19 @@
has_creator: !!_model.get("created_by"),
title: _model.get("title"),
uri: _model.get("uri"),
- short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
+ short_uri: shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
description: _model.get("description"),
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(this.renkan)).get("color"),
- to_color: _to_model.get("color") || (_to_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"),
+ from_color: _from_model.get("color") || (_from_model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"),
+ to_color: _to_model.get("color") || (_to_model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"),
created_by_color: _created_by.get("color"),
created_by_title: _created_by.get("title")
},
renkan: this.renkan,
- options: this.options,
+ shortenText: shortenText,
+ options: this.options
}));
this.redraw();
var _this = this,
@@ -2055,11 +2196,16 @@
paper.view.draw();
};
this.editor_$.find(".Rk-CloseX").click(closeEditor);
+ this.editor_$.find(".Rk-Edit-Goto").click(function() {
+ if (!_model.get("uri")) {
+ return false;
+ }
+ });
if (this.renderer.isEditable()) {
- var onFieldChange = Rkns._(function() {
- Rkns._(function() {
+ var onFieldChange = _(function() {
+ _(function() {
if (_this.renderer.isEditable()) {
var _data = {
title: _this.editor_$.find(".Rk-Edit-Title").val()
@@ -2067,7 +2213,7 @@
if (_this.options.show_edge_editor_uri) {
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
}
- _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri);
+ _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
_model.set(_data);
paper.view.draw();
} else {
@@ -2125,7 +2271,7 @@
},
function(_e) {
_e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
+ _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || _USER_PLACEHOLDER(_this.renkan)).get("color"));
}
).click(function(_e) {
_e.preventDefault();
@@ -2138,20 +2284,21 @@
}
});
}
-};
-
-Rkns.Renderer.EdgeEditor.prototype.redraw = function() {
+},
+redraw: function() {
var _coords = this.source_representation.paper_coords;
- Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
+ drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
this.editor_$.show();
paper.view.draw();
-};
+}
+});
/* */
-Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
+var _NodeButton = Renderer._NodeButton = Rkns.Utils.inherit(_BaseButton);
-Rkns.Renderer._NodeButton.prototype.setSectorSize = function() {
+_(_NodeButton.prototype).extend({
+setSectorSize: function() {
var sectorInner = this.source_representation.circle_radius;
if (sectorInner !== this.lastSectorInner) {
if (this.sector) {
@@ -2159,7 +2306,7 @@
}
this.sector = this.renderer.drawSector(
this, 1 + sectorInner,
- Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner,
+ _NODE_BUTTON_WIDTH + sectorInner,
this.startAngle,
this.endAngle,
1,
@@ -2168,41 +2315,43 @@
);
this.lastSectorInner = sectorInner;
}
-};
+}
+});
/* */
-Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeEditButton = Renderer.NodeEditButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeEditButton.prototype._init = function() {
+_(NodeEditButton.prototype).extend({
+_init: function() {
this.type = "Node-edit-button";
this.lastSectorInner = 0;
this.startAngle = -135;
this.endAngle = -45;
this.imageName = "edit";
this.text = "Edit";
-};
-
-Rkns.Renderer.NodeEditButton.prototype.mouseup = function() {
+},
+mouseup: function() {
if (!this.renderer.is_dragging) {
this.source_representation.openEditor();
}
-};
+}
+});
/* */
-Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeRemoveButton = Renderer.NodeRemoveButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeRemoveButton.prototype._init = function() {
+_(NodeRemoveButton.prototype).extend({
+_init: function() {
this.type = "Node-remove-button";
this.lastSectorInner = 0;
this.startAngle = 0;
this.endAngle = 90;
this.imageName = "remove";
this.text = "Remove";
-};
-
-Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() {
+},
+mouseup: function() {
this.renderer.click_target = null;
this.renderer.is_dragging = false;
this.renderer.removeRepresentationsOfType("editor");
@@ -2220,43 +2369,45 @@
}
}
}
-};
+}
+});
/* */
-Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeRevertButton = Renderer.NodeRevertButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeRevertButton.prototype._init = function() {
+_(NodeRevertButton.prototype).extend({
+_init: function() {
this.type = "Node-revert-button";
this.lastSectorInner = 0;
this.startAngle = -135;
this.endAngle = 135;
this.imageName = "revert";
this.text = "Cancel deletion";
-};
-
-Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() {
+},
+mouseup: function() {
this.renderer.click_target = null;
this.renderer.is_dragging = false;
if (this.renderer.isEditable()) {
this.source_representation.model.unset("delete_scheduled");
}
-};
+}
+});
/* */
-Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeLinkButton = Renderer.NodeLinkButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeLinkButton.prototype._init = function() {
+_(NodeLinkButton.prototype).extend({
+_init: function() {
this.type = "Node-link-button";
this.lastSectorInner = 0;
this.startAngle = 90;
this.endAngle = 180;
this.imageName = "link";
this.text = "Link to another node";
-};
-
-Rkns.Renderer.NodeLinkButton.prototype.mousedown = function(_event, _isTouch) {
+},
+mousedown: function(_event, _isTouch) {
if (this.renderer.isEditable()) {
var _off = this.renderer.canvas_$.offset(),
_point = new paper.Point([
@@ -2267,75 +2418,79 @@
this.renderer.removeRepresentationsOfType("editor");
this.renderer.addTempEdge(this.source_representation, _point);
}
-};
+}
+});
/* */
-Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeEnlargeButton = Renderer.NodeEnlargeButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeEnlargeButton.prototype._init = function() {
+_(NodeEnlargeButton.prototype).extend({
+_init: function() {
this.type = "Node-enlarge-button";
this.lastSectorInner = 0;
this.startAngle = -45;
this.endAngle = 0;
this.imageName = "enlarge";
this.text = "Enlarge";
-};
-
-Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() {
+},
+mouseup: function() {
var _newsize = 1 + (this.source_representation.model.get("size") || 0);
this.source_representation.model.set("size", _newsize);
this.source_representation.select();
this.select();
paper.view.draw();
-};
+}
+});
/* */
-Rkns.Renderer.NodeShrinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
+var NodeShrinkButton = Renderer.NodeShrinkButton = Rkns.Utils.inherit(_NodeButton);
-Rkns.Renderer.NodeShrinkButton.prototype._init = function() {
+_(NodeShrinkButton.prototype).extend({
+_init: function() {
this.type = "Node-shrink-button";
this.lastSectorInner = 0;
this.startAngle = -180;
this.endAngle = -135;
this.imageName = "shrink";
this.text = "Shrink";
-};
-
-Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() {
+},
+mouseup: function() {
var _newsize = -1 + (this.source_representation.model.get("size") || 0);
this.source_representation.model.set("size", _newsize);
this.source_representation.select();
this.select();
paper.view.draw();
-};
+}
+});
/* */
-Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
+var EdgeEditButton = Renderer.EdgeEditButton = Rkns.Utils.inherit(_BaseButton);
-Rkns.Renderer.EdgeEditButton.prototype._init = function() {
+_(EdgeEditButton.prototype).extend({
+_init: function() {
this.type = "Edge-edit-button";
- this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
-};
-
-Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() {
+ this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
+},
+mouseup: function() {
if (!this.renderer.is_dragging) {
this.source_representation.openEditor();
}
-};
+}
+});
/* */
-Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
+var EdgeRemoveButton = Renderer.EdgeRemoveButton = Rkns.Utils.inherit(_BaseButton);
-Rkns.Renderer.EdgeRemoveButton.prototype._init = function() {
+_(EdgeRemoveButton.prototype).extend({
+_init: function() {
this.type = "Edge-remove-button";
- this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
-};
-
-Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() {
+ this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
+},
+mouseup: function() {
this.renderer.click_target = null;
this.renderer.is_dragging = false;
this.renderer.removeRepresentationsOfType("editor");
@@ -2353,44 +2508,47 @@
}
}
}
-};
+}
+});
/* */
-Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
+var EdgeRevertButton = Renderer.EdgeRevertButton = Rkns.Utils.inherit(_BaseButton);
-Rkns.Renderer.EdgeRevertButton.prototype._init = function() {
+_(EdgeRevertButton.prototype).extend({
+_init: function() {
this.type = "Edge-revert-button";
- this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
-};
-
-Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() {
+ this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
+},
+mouseup: function() {
this.renderer.click_target = null;
this.renderer.is_dragging = false;
if (this.renderer.isEditable()) {
this.source_representation.model.unset("delete_scheduled");
}
-};
+}
+});
/* */
-Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
+var MiniFrame = Renderer.MiniFrame = Rkns.Utils.inherit(_BaseRepresentation);
-Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) {
+_(MiniFrame.prototype).extend({
+paperShift: function(_delta) {
this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
this.renderer.redraw();
-};
-
-Rkns.Renderer.MiniFrame.prototype.mouseup = function(_delta) {
+},
+mouseup: function(_delta) {
this.renderer.click_target = null;
this.renderer.is_dragging = false;
-};
+}
+});
/* */
-Rkns.Renderer.Scene = function(_renkan) {
+var Scene = Renderer.Scene = function(_renkan) {
this.renkan = _renkan;
- this.$ = Rkns.$(".Rk-Render");
+ this.$ = $(".Rk-Render");
this.representations = [];
this.$.html(this.template(_renkan));
this.onStatusChange();
@@ -2400,6 +2558,7 @@
this.notif_$ = this.$.find(".Rk-Notifications");
paper.setup(this.canvas_$[0]);
this.scale = 1;
+ this.initialScale = 1;
this.offset = paper.view.center;
this.totalScroll = 0;
this.mouse_down = false;
@@ -2438,10 +2597,10 @@
this.minimap.miniframe.opacity = .3;
this.minimap.miniframe.strokeColor = '#000080';
this.minimap.miniframe.strokeWidth = 3;
- this.minimap.miniframe.__representation = new Rkns.Renderer.MiniFrame(this, null);
+ this.minimap.miniframe.__representation = new MiniFrame(this, null);
}
- this.throttledPaperDraw = Rkns._(function() {
+ this.throttledPaperDraw = _(function() {
paper.view.draw();
}).throttle(100);
@@ -2467,8 +2626,8 @@
var throttledMouseMove = _.throttle(function(_event, _isTouch) {
_this.onMouseMove(_event, _isTouch);
- }, Rkns.Renderer._MOUSEMOVE_RATE);
-
+ }, _MOUSEMOVE_RATE);
+
this.canvas_$.on({
mousedown: function(_event) {
_event.preventDefault();
@@ -2493,8 +2652,8 @@
var _touches = _event.originalEvent.touches[0];
if (
_renkan.options.allow_double_click
- && new Date() - _lastTap < Rkns.Renderer._DOUBLETAP_DELAY
- && ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Rkns.Renderer._DOUBLETAP_DISTANCE )
+ && new Date() - _lastTap < _DOUBLETAP_DELAY
+ && ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < _DOUBLETAP_DISTANCE )
) {
_lastTap = 0;
_this.onDoubleClick(_touches);
@@ -2562,7 +2721,7 @@
_event.preventDefault();
_allowScroll = true;
var res = {};
- Rkns._(_event.originalEvent.dataTransfer.types).each(function(t) {
+ _(_event.originalEvent.dataTransfer.types).each(function(t) {
try {
res[t] = _event.originalEvent.dataTransfer.getData(t);
} catch(e) {}
@@ -2600,69 +2759,29 @@
_this.dropData(res, _event.originalEvent);
}
});
- this.editor_$.find(".Rk-ZoomOut").click(function() {
- var _newScale = _this.scale * Math.SQRT1_2,
- _offset = new paper.Point([
- _this.canvas_$.width(),
- _this.canvas_$.height()
- ]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(_this.offset.multiply( Math.SQRT1_2 ));
- _this.setScale( _newScale, _offset );
- });
- this.editor_$.find(".Rk-ZoomIn").click(function() {
- var _newScale = _this.scale * Math.SQRT2,
- _offset = new paper.Point([
- _this.canvas_$.width(),
- _this.canvas_$.height()
- ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 ));
- _this.setScale( _newScale, _offset );
- });
+
+ var bindClick = function(selector, fname) {
+ _this.$.find(selector).click(function(evt) {
+ _this[fname](evt);
+ return false;
+ });
+ };
+
+ bindClick(".Rk-ZoomOut", "zoomOut");
+ bindClick(".Rk-ZoomIn", "zoomIn");
this.$.find(".Rk-CurrentUser").mouseenter(
function() { _this.$.find(".Rk-UserList").slideDown(); }
);
this.$.find(".Rk-Users").mouseleave(
function() { _this.$.find(".Rk-UserList").slideUp(); }
);
- this.$.find(".Rk-FullScreen-Button").click(function() {
- var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
- _el = _this.renkan.$[0],
- _requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
- _cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];
- if (_isFull) {
- for (var i = 0; i < _cancelMethods.length; i++) {
- if (typeof document[_cancelMethods[i]] === "function") {
- document[_cancelMethods[i]]();
- break;
- }
- }
- } else {
- for (var i = 0; i < _requestMethods.length; i++) {
- if (typeof _el[_requestMethods[i]] === "function") {
- _el[_requestMethods[i]]();
- break;
- }
- }
- }
- });
- this.$.find(".Rk-AddNode-Button").click(function() {
- if (_this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) {
- _this.click_mode = false;
- _this.notif_$.hide();
- } else {
- _this.click_mode = Rkns.Renderer._CLICKMODE_ADDNODE;
- _this.notif_$.text(_renkan.translate("Click on the background canvas to add a node")).fadeIn();
- }
- });
- this.$.find(".Rk-AddEdge-Button").click(function() {
- if (_this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE || _this.click_mode === Rkns.Renderer._CLICKMODE_ENDEDGE) {
- _this.click_mode = false;
- _this.notif_$.hide();
- } else {
- _this.click_mode = Rkns.Renderer._CLICKMODE_STARTEDGE;
- _this.notif_$.text(_renkan.translate("Click on a first node to start the edge")).fadeIn();
- }
- });
+ bindClick(".Rk-FullScreen-Button", "fullScreen");
+ bindClick(".Rk-AddNode-Button", "addNodeBtn");
+ bindClick(".Rk-AddEdge-Button", "addEdgeBtn");
+ bindClick(".Rk-Save-Button", "save");
+ bindClick(".Rk-Open-Button", "open");
this.$.find(".Rk-Bookmarklet-Button")
- .attr("href","javascript:" + Rkns.Renderer._BOOKMARKLET_CODE(_renkan))
+ .attr("href","javascript:" + _BOOKMARKLET_CODE(_renkan))
.click(function(){
_this.notif_$
.text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan."))
@@ -2672,28 +2791,11 @@
return false;
});
this.$.find(".Rk-TopBar-Button").mouseover(function() {
- Rkns.$(this).find(".Rk-TopBar-Tooltip").show();
+ $(this).find(".Rk-TopBar-Tooltip").show();
}).mouseout(function() {
- Rkns.$(this).find(".Rk-TopBar-Tooltip").hide();
+ $(this).find(".Rk-TopBar-Tooltip").hide();
});
- this.$.find(".Rk-Fold-Bins").click(function() {
- var bins = _renkan.$.find(".Rk-Bins");
- if (bins.offset().left < 0) {
- bins.animate({left: 0},250);
- _this.$.animate({left: 300},250,function() {
- var w = _this.$.width();
- paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
- });
- $(this).html("«");
- } else {
- bins.animate({left: -300},250);
- _this.$.animate({left: 0},250,function() {
- var w = _this.$.width();
- paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
- });
- $(this).html("»");
- }
- });
+ bindClick(".Rk-Fold-Bins", "foldBins");
paper.view.onResize = function(_event) {
_this.offset = _this.offset.add(_event.delta.divide(2));
@@ -2705,7 +2807,7 @@
_this.redraw();
};
- var _thRedraw = Rkns._.throttle(function() {
+ var _thRedraw = _.throttle(function() {
_this.redraw();
},50);
@@ -2719,13 +2821,14 @@
_renkan.project.set({"title": $(this).val()});
});
- this.renkan.project.get("users").each(function(_user) {
- _this.addUser(_user);
- });
+ var _thRedrawUsers = _.throttle(function() {
+ _this.redrawUsers();
+ }, 100);
- this.renkan.project.on("add:users", function(_user) {
- _this.addUser(_user);
- });
+ _thRedrawUsers();
+
+ this.renkan.project.on("add:users remove:users", _thRedrawUsers);
+
this.renkan.project.on("add:nodes", function(_node) {
_this.addRepresentation("Node", _node);
_thRedraw();
@@ -2765,6 +2868,61 @@
});
}
+ if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {
+ var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),
+ $cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker");
+
+ $cpwrapper.hover(
+ function(_e) {
+ if (_this.isEditable()) {
+ _e.preventDefault();
+ $cplist.show();
+ }
+ },
+ function(_e) {
+ _e.preventDefault();
+ $cplist.hide();
+ }
+ );
+
+ $cplist.find("li").mouseenter(
+ function(_e) {
+ if (_this.isEditable()) {
+ _e.preventDefault();
+ _this.$.find(".Rk-CurrentUser-Color").css("background", $(this).attr("data-color"));
+ }
+ }
+ );
+ }
+
+ if (_renkan.options.show_search_field) {
+
+ var lastval = '';
+
+ this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() {
+ var $this = $(this),
+ val = $this.val();
+ if (val === lastval) {
+ return;
+ }
+ lastval = val;
+ if (val.length < 2) {
+ _renkan.project.get("nodes").each(function(n) {
+ _this.getRepresentationByModel(n).unhighlight();
+ });
+ } else {
+ var rxs = Rkns.Utils.regexpFromTextOrArray(val);
+ _renkan.project.get("nodes").each(function(n) {
+ if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) {
+ _this.getRepresentationByModel(n).highlight(rxs);
+ } else {
+ _this.getRepresentationByModel(n).unhighlight();
+ }
+ });
+ }
+ });
+ }
+
this.redraw();
window.setInterval(function() {
@@ -2794,27 +2952,33 @@
};
-Rkns.Renderer.Scene.prototype.template = Rkns._.template(
+_(Scene.prototype).extend({
+template: _.template(
'<% if (options.show_top_bar) { %>
<% if (!options.editor_mode) { %>
<%- project.get("title") || translate("Untitled project")%>
'
+ '<% } else { %>
" placeholder="<%-translate("Untitled project")%>" /><% } %>'
- + '
'
- + '
'
+ + '<% if (options.show_user_list) { %>
<% if (options.user_color_editable) { %><% } %>'
+ + '<% if (options.user_color_editable) { print(colorPicker) } %>
<unknown user><% } %>'
+ + '<% if (options.home_button_url) {%>
<% } %>'
+ + '<% if (options.show_fullscreen_button) { %>
<% } %>'
+ '<% if (options.editor_mode) { %>'
- + '
'
- + '
'
- + '
'
- + '
'
- + '
'
- + '<% } %>
<% } %>'
+ + '<% if (options.show_addnode_button) { %>
<% } %>'
+ + '<% if (options.show_addedge_button) { %>
<% } %>'
+ + '<% if (options.show_save_button) { %>
<% } %>'
+ + '<% if (options.show_open_button) { %>
<% } %>'
+ + '<% if (options.show_bookmarklet) { %>
<% } %>'
+ + '
<% }; if (options.show_search_field) { %>'
+ + '
<% } %>
'
- + '
'
+ + '
'
+ '<% if (options.show_bins) { %>
«
<% } %>'
+ '
'
+ '
'
-);
-
-Rkns.Renderer.Scene.prototype.fixSize = function(_autoscale) {
+),
+fixSize: function(_autoscale) {
var w = this.$.width(),
h = this.$.height();
if (this.renkan.options.show_top_bar) {
@@ -2830,9 +2994,8 @@
if (_autoscale) {
this.autoScale();
}
-};
-
-Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
+},
+drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
var _options = this.renkan.options,
_startRads = _startAngle * Math.PI / 180,
_endRads = _endAngle * Math.PI / 180,
@@ -2930,14 +3093,13 @@
if (_img.width) {
showImage();
} else {
- Rkns.$(_img).on("load",showImage);
+ $(_img).on("load",showImage);
}
return _res;
-};
-
-Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) {
- var _bundle = Rkns._(this.bundles).find(function(_bundle) {
+},
+addToBundles: function(_edgeRepr) {
+ var _bundle = _(this.bundles).find(function(_bundle) {
return (
( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation )
|| ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
@@ -2952,19 +3114,17 @@
edges: [ _edgeRepr ],
getPosition: function(_er) {
var _dir = (_er.from_representation === this.from) ? 1 : -1;
- return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
+ return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
}
};
this.bundles.push(_bundle);
}
return _bundle;
-};
-
-Rkns.Renderer.Scene.prototype.isEditable = function() {
+},
+isEditable: function() {
return (this.renkan.options.editor_mode && !this.renkan.read_only);
-};
-
-Rkns.Renderer.Scene.prototype.onStatusChange = function() {
+},
+onStatusChange: function() {
var savebtn = this.$.find(".Rk-Save-Button"),
tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
if (this.renkan.read_only) {
@@ -2973,25 +3133,24 @@
} else {
if (this.renkan.options.snapshot_mode) {
savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
- tip.text(this.renkan.translate("Archive Project"));
+ tip.text(this.renkan.translate("Save Project"));
} else {
savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
tip.text(this.renkan.translate("Auto-save enabled"));
}
}
-};
-
-Rkns.Renderer.Scene.prototype.setScale = function(_newScale, _offset) {
- if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) {
+ this.redrawUsers();
+},
+setScale: function(_newScale, _offset) {
+ if ((_newScale/this.initialScale) > _MIN_SCALE && (_newScale/this.initialScale) < _MAX_SCALE) {
this.scale = _newScale;
if (_offset) {
this.offset = _offset;
}
this.redraw();
}
-};
-
-Rkns.Renderer.Scene.prototype.autoScale = function() {
+},
+autoScale: function() {
var nodes = this.renkan.project.get("nodes");
if (nodes.length > 1) {
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
@@ -3000,21 +3159,20 @@
_miny = Math.min.apply(Math, _yy),
_maxx = Math.max.apply(Math, _xx),
_maxy = Math.max.apply(Math, _yy);
- var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)));
+ var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));
+ this.initialScale = _scale;
this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
}
if (nodes.length === 1) {
this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
}
-};
-
-Rkns.Renderer.Scene.prototype.redrawMiniframe = function() {
+},
+redrawMiniframe: function() {
var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
this.minimap.miniframe.fitBounds(topleft, bottomright);
-};
-
-Rkns.Renderer.Scene.prototype.rescaleMinimap = function() {
+},
+rescaleMinimap: function() {
var nodes = this.renkan.project.get("nodes");
if (nodes.length > 1) {
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
@@ -3037,119 +3195,145 @@
this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
}
this.redraw();
-};
-
-Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {
+},
+toPaperCoords: function(_point) {
return _point.multiply(this.scale).add(this.offset);
-};
-
-Rkns.Renderer.Scene.prototype.toMinimapCoords = function(_point) {
+},
+toMinimapCoords: function(_point) {
return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
-};
-
-Rkns.Renderer.Scene.prototype.toModelCoords = function(_point) {
+},
+toModelCoords: function(_point) {
return _point.subtract(this.offset).divide(this.scale);
-};
-
-Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) {
- var _repr = new Rkns.Renderer[_type](this, _model);
+},
+addRepresentation: function(_type, _model) {
+ var _repr = new Renderer[_type](this, _model);
this.representations.push(_repr);
return _repr;
-};
-
-Rkns.Renderer.Scene.prototype.addRepresentations = function(_type, _collection) {
+},
+addRepresentations: function(_type, _collection) {
var _this = this;
_collection.forEach(function(_model) {
_this.addRepresentation(_type, _model);
});
-};
-
-Rkns.Renderer.Scene.prototype.userTemplate = Rkns._.template(
+},
+userTemplate: _.template(
'
<%=name%>'
-);
-
-Rkns.Renderer.Scene.prototype.addUser = function(_user) {
- if (_user.get("_id") === this.renkan.current_user) {
- this.$.find(".Rk-CurrentUser-Name").text(_user.get("title"));
- this.$.find(".Rk-CurrentUser-Color").css("background", _user.get("color"));
- } else {
- this.$.find(".Rk-UserList").append(
- Rkns.$(
- this.userTemplate({
- name: _user.get("title"),
- background: _user.get("color")
- })
- )
- );
+),
+redrawUsers: function() {
+ if (!this.renkan.options.show_user_list) {
+ return;
}
-};
-
-Rkns.Renderer.Scene.prototype.removeRepresentation = function(_representation) {
+ var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []),
+ ulistHtml = '',
+ $userpanel = this.$.find(".Rk-Users"),
+ $name = $userpanel.find(".Rk-CurrentUser-Name"),
+ $cpwrapper = $userpanel.find(".Rk-Edit-ColorPicker-Wrapper"),
+ $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"),
+ $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"),
+ _this = this;
+ $name.off("click").text(this.renkan.translate("
"));
+ $cpitems.off("mouseleave click");
+ allUsers.forEach(function(_user) {
+ if (_user.get("_id") === _this.renkan.current_user) {
+ $name.text(_user.get("title"));
+ $colorsquare.css("background", _user.get("color"));
+ if (_this.isEditable()) {
+
+ if (_this.renkan.options.user_name_editable) {
+ $name.click(function() {
+ var $this = $(this),
+ $input = $('').val(_user.get("title")).blur(function() {
+ _user.set("title", $(this).val());
+ _this.redrawUsers();
+ _this.redraw();
+ });
+ $this.empty().html($input);
+ $input.select();
+ });
+ }
+
+ if (_this.renkan.options.user_color_editable) {
+ $cpitems.click(
+ function(_e) {
+ _e.preventDefault();
+ if (_this.isEditable()) {
+ _user.set("color", $(this).attr("data-color"));
+ }
+ $(this).parent().hide();
+ }
+ ).mouseleave(function() {
+ $colorsquare.css("background", _user.get("color"));
+ });
+ }
+ }
+
+ } else {
+ ulistHtml += _this.userTemplate({
+ name: _user.get("title"),
+ background: _user.get("color")
+ });
+ }
+ });
+ $userpanel.find(".Rk-UserList").html(ulistHtml);
+},
+removeRepresentation: function(_representation) {
_representation.destroy();
- this.representations = Rkns._(this.representations).reject(
+ this.representations = _(this.representations).reject(
function(_repr) {
return _repr == _representation;
}
);
-};
-
-Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) {
+},
+getRepresentationByModel: function(_model) {
if (!_model) {
return undefined;
}
- return Rkns._(this.representations).find(function(_repr) {
+ return _(this.representations).find(function(_repr) {
return _repr.model === _model;
});
-};
-
-Rkns.Renderer.Scene.prototype.removeRepresentationsOfType = function(_type) {
- var _representations = Rkns._(this.representations).filter(function(_repr) {
+},
+removeRepresentationsOfType: function(_type) {
+ var _representations = _(this.representations).filter(function(_repr) {
return _repr.type == _type;
}),
_this = this;
- Rkns._(_representations).each(function(_repr) {
+ _(_representations).each(function(_repr) {
_this.removeRepresentation(_repr);
});
-};
-
-Rkns.Renderer.Scene.prototype.highlightModel = function(_model) {
+},
+highlightModel: function(_model) {
var _repr = this.getRepresentationByModel(_model);
if (_repr) {
_repr.highlight();
}
-};
-
-Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) {
- Rkns._(this.representations).each(function(_repr) {
+},
+unhighlightAll: function(_model) {
+ _(this.representations).each(function(_repr) {
_repr.unhighlight();
});
-};
-
-Rkns.Renderer.Scene.prototype.unselectAll = function(_model) {
- Rkns._(this.representations).each(function(_repr) {
+},
+unselectAll: function(_model) {
+ _(this.representations).each(function(_repr) {
_repr.unselect();
});
-};
-
-Rkns.Renderer.Scene.prototype.redraw = function() {
- Rkns._(this.representations).each(function(_representation) {
+},
+redraw: function() {
+ _(this.representations).each(function(_representation) {
_representation.redraw(true);
});
if (this.minimap) {
this.redrawMiniframe();
}
paper.view.draw();
-};
-
-Rkns.Renderer.Scene.prototype.addTempEdge = function(_from, _point) {
+},
+addTempEdge: function(_from, _point) {
var _tmpEdge = this.addRepresentation("TempEdge",null);
_tmpEdge.end_pos = _point;
_tmpEdge.from_representation = _from;
_tmpEdge.redraw();
this.click_target = _tmpEdge;
-};
-
-Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) {
+},
+findTarget: function(_hitResult) {
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
var _newTarget = _hitResult.item.__representation;
if (this.selected_target !== _hitResult.item.__representation) {
@@ -3165,14 +3349,12 @@
}
this.selected_target = null;
}
-};
-
-Rkns.Renderer.Scene.prototype.paperShift = function(_delta) {
+},
+paperShift: function(_delta) {
this.offset = this.offset.add(_delta);
this.redraw();
-};
-
-Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) {
+},
+onMouseMove: function(_event) {
var _off = this.canvas_$.offset(),
_point = new paper.Point([
_event.pageX - _off.left,
@@ -3180,7 +3362,7 @@
]),
_delta = _point.subtract(this.last_point);
this.last_point = _point;
- if (!this.is_dragging && this.mouse_down && _delta.length > Rkns.Renderer._MIN_DRAG_DISTANCE) {
+ if (!this.is_dragging && this.mouse_down && _delta.length > _MIN_DRAG_DISTANCE) {
this.is_dragging = true;
}
var _hitResult = paper.project.hitTest(_point);
@@ -3194,9 +3376,8 @@
this.findTarget(_hitResult);
}
paper.view.draw();
-};
-
-Rkns.Renderer.Scene.prototype.onMouseDown = function(_event, _isTouch) {
+},
+onMouseDown: function(_event, _isTouch) {
var _off = this.canvas_$.offset(),
_point = new paper.Point([
_event.pageX - _off.left,
@@ -3213,7 +3394,7 @@
this.click_target.mousedown(_event, _isTouch);
} else {
this.click_target = null;
- if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) {
+ if (this.isEditable() && this.click_mode === _CLICKMODE_ADDNODE) {
var _coords = this.toModelCoords(_point),
_data = {
id: Rkns.Utils.getUID('node'),
@@ -3229,12 +3410,12 @@
}
}
if (this.click_mode) {
- if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
+ if (this.isEditable() && this.click_mode === _CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
this.removeRepresentationsOfType("editor");
this.addTempEdge(this.click_target, _point);
- this.click_mode = Rkns.Renderer._CLICKMODE_ENDEDGE;
+ this.click_mode = _CLICKMODE_ENDEDGE;
this.notif_$.fadeOut(function() {
- Rkns.$(this).html(_renkan.translate("Click on a second node to complete the edge")).fadeIn();
+ $(this).html(_renkan.translate("Click on a second node to complete the edge")).fadeIn();
});
} else {
this.notif_$.hide();
@@ -3242,9 +3423,8 @@
}
}
paper.view.draw();
-};
-
-Rkns.Renderer.Scene.prototype.onMouseUp = function(_event, _isTouch) {
+},
+onMouseUp: function(_event, _isTouch) {
this.mouse_down = false;
if (this.click_target) {
var _off = this.canvas_$.offset();
@@ -3265,9 +3445,8 @@
}
}
paper.view.draw();
-};
-
-Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) {
+},
+onScroll: function(_event, _scrolldelta) {
this.totalScroll += _scrolldelta;
if (Math.abs(this.totalScroll) >= 1) {
var _off = this.canvas_$.offset(),
@@ -3282,9 +3461,8 @@
}
this.totalScroll = 0;
}
-};
-
-Rkns.Renderer.Scene.prototype.onDoubleClick = function(_event) {
+},
+onDoubleClick: function(_event) {
if (!this.isEditable()) {
return;
}
@@ -3303,14 +3481,13 @@
x: _coords.x,
y: _coords.y
}
- };
+ },
_node = this.renkan.project.addNode(_data);
- this.getRepresentationByModel(_node).openEditor();
+ this.getRepresentationByModel(_node).openEditor();
}
paper.view.draw();
-};
-
-Rkns.Renderer.Scene.prototype.dropData = function(_data, _event) {
+},
+dropData: function(_data, _event) {
if (!this.isEditable()) {
return;
}
@@ -3324,7 +3501,7 @@
var newNode = {};
switch(_data["text/x-iri-specific-site"]) {
case "twitter":
- var snippet = Rkns.$('').html(_data["text/x-iri-selected-html"]),
+ var snippet = $('
').html(_data["text/x-iri-selected-html"]),
tweetdiv = snippet.find(".tweet");
newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
@@ -3332,7 +3509,7 @@
newNode.description = tweetdiv.find(".js-tweet-text:first").text();
break;
case "google":
- var snippet = Rkns.$('
').html(_data["text/x-iri-selected-html"]);
+ var snippet = $('
').html(_data["text/x-iri-selected-html"]);
newNode.title = snippet.find("h3:first").text().trim();
newNode.uri = snippet.find("h3 a").attr("href");
newNode.description = snippet.find(".st:first").text().trim();
@@ -3346,7 +3523,7 @@
newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim();
}
if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
- var snippet = Rkns.$('
').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
+ var snippet = $('
').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
var _svgimgs = snippet.find("image");
if (_svgimgs.length) {
newNode.image = _svgimgs.attr("xlink:href");
@@ -3424,15 +3601,91 @@
if (_event.type === "drop") {
_repr.openEditor();
}
-};
+},
+fullScreen: function() {
+ var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
+ _el = this.renkan.$[0],
+ _requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
+ _cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];
+ if (_isFull) {
+ for (var i = 0; i < _cancelMethods.length; i++) {
+ if (typeof document[_cancelMethods[i]] === "function") {
+ document[_cancelMethods[i]]();
+ break;
+ }
+ }
+ } else {
+ for (var i = 0; i < _requestMethods.length; i++) {
+ if (typeof _el[_requestMethods[i]] === "function") {
+ _el[_requestMethods[i]]();
+ break;
+ }
+ }
+ }
+},
+zoomOut: function() {
+ var _newScale = this.scale * Math.SQRT1_2,
+ _offset = new paper.Point([
+ this.canvas_$.width(),
+ this.canvas_$.height()
+ ]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));
+ this.setScale( _newScale, _offset );
+},
+zoomIn: function() {
+ var _newScale = this.scale * Math.SQRT2,
+ _offset = new paper.Point([
+ this.canvas_$.width(),
+ this.canvas_$.height()
+ ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));
+ this.setScale( _newScale, _offset );
+},
+addNodeBtn: function() {
+ if (this.click_mode === _CLICKMODE_ADDNODE) {
+ this.click_mode = false;
+ this.notif_$.hide();
+ } else {
+ this.click_mode = _CLICKMODE_ADDNODE;
+ this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn();
+ }
+ return false;
+},
+addEdgeBtn: function() {
+ if (this.click_mode === _CLICKMODE_STARTEDGE || this.click_mode === _CLICKMODE_ENDEDGE) {
+ this.click_mode = false;
+ this.notif_$.hide();
+ } else {
+ this.click_mode = _CLICKMODE_STARTEDGE;
+ this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn();
+ }
+ return false;
+},
+foldBins: function() {
+ var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
+ bins = this.renkan.$.find(".Rk-Bins");
+ if (bins.offset().left < 0) {
+ bins.animate({left: 0},250);
+ var _this = this;
+ this.$.animate({left: 300},250,function() {
+ var w = _this.$.width();
+ paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
+ });
+ foldBinsButton.html("«");
+ } else {
+ bins.animate({left: -300},250);
+ var _this = this;
+ this.$.animate({left: 0},250,function() {
+ var w = _this.$.width();
+ paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
+ });
+ foldBinsButton.html("»");
+ }
+},
+save: function() { },
+open: function() { }
+});
+})(window);
- /* *********************************************************
- end of paper-renderer.js
- ************************************************************
- ************************************************************
- start of full-json.js
- ********************************************************* */
-
+/* END paper-renderer.js */
/* Saves the Full JSON at each modification */
Rkns.jsonIO = function(_renkan, _opts) {
@@ -3476,8 +3729,467 @@
_load();
};
+(function(Rkns) {
+"use strict";
- /* *********************************************************
- end of full-json.js
- ************************************************************
- */
+var _ = Rkns._;
+
+var Ldt = Rkns.Ldt = {};
+
+var Bin = Ldt.Bin = function(_renkan, _opts) {
+ if (_opts.ldt_type) {
+ var resclass = Ldt[_opts.ldt_type+"Bin"];
+ if (resclass) {
+ return new resclass(_renkan, _opts);
+ }
+ }
+ console.error("No such LDT Bin Type");
+};
+
+var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+ProjectBin.prototype.tagTemplate = _.template(
+ '
'
+ + '
<%=htitle%>
'
+);
+
+ProjectBin.prototype.annotationTemplate = _.template(
+ '
'
+ + '
<%=htitle%>
<%=hdescription%>
Start: <%=start%>, End: <%=end%>, Duration: <%=duration%>
'
+);
+
+ProjectBin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.proj_id = _opts.project_id;
+ this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
+ this.title_$.html(_opts.title);
+ this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
+ this.refresh();
+};
+
+ProjectBin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ function highlight(_text) {
+ var _e = _(_text).escape();
+ return search.isempty ? _e : search.replace(_e, "
$1");
+ }
+ function convertTC(_ms) {
+ function pad(_n) {
+ var _res = _n.toString();
+ while (_res.length < 2) {
+ _res = '0' + _res;
+ }
+ return _res;
+ }
+ var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
+ _hours = Math.floor(_totalSeconds / 3600),
+ _minutes = (Math.floor(_totalSeconds / 60) % 60),
+ _seconds = _totalSeconds % 60,
+ _res = '';
+ if (_hours) {
+ _res += pad(_hours) + ':';
+ }
+ _res += pad(_minutes) + ':' + pad(_seconds);
+ return _res;
+ }
+
+ var _html = '
Tags
',
+ _projtitle = this.data.meta["dc:title"],
+ _this = this,
+ count = 0;
+ _this.title_$.text('LDT Project: "' + _projtitle + '"');
+ _(_this.data.tags).map(function(_tag) {
+ var _title = _tag.meta["dc:title"];
+ if (!search.isempty && !search.test(_title)) {
+ return;
+ }
+ count++;
+ _html += _this.tagTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ encodedtitle : encodeURIComponent(_title),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _html += '
Annotations
';
+ _(_this.data.annotations).map(function(_annotation) {
+ var _description = _annotation.content.description,
+ _title = _annotation.content.title.replace(_description,"");
+ if (!search.isempty && !search.test(_title) && !search.test(_description)) {
+ return;
+ }
+ count++;
+ var _duration = _annotation.end - _annotation.begin,
+ _img = (
+ (_annotation.content && _annotation.content.img && _annotation.content.img.src)
+ ? _annotation.content.img.src
+ : ( _duration ? _this.renkan.options.static_url+"img/ldt-segment.png" : _this.renkan.options.static_url+"img/ldt-point.png" )
+ );
+ _html += _this.annotationTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ description: _description,
+ hdescription: highlight(_description),
+ start: convertTC(_annotation.begin),
+ end: convertTC(_annotation.end),
+ duration: convertTC(_duration),
+ mediaid: _annotation.media,
+ annotationid: _annotation.id,
+ image: _img,
+ static_url: _this.renkan.options.static_url
+ });
+ });
+
+ this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+ProjectBin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
+
+var Search = Ldt.Search = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.lang = _opts.lang || "en";
+};
+
+Search.prototype.getBgClass = function() {
+ return "Rk-Ldt-Icon";
+};
+
+Search.prototype.getSearchTitle = function() {
+ return this.renkan.translate("Lignes de Temps");
+};
+
+Search.prototype.search = function(_q) {
+ this.renkan.tabs.push(
+ new ResultsBin(this.renkan, {
+ search: _q
+ })
+ );
+};
+
+var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+ResultsBin.prototype.segmentTemplate = _.template(
+ '
'
+ + '
<%=htitle%>
<%=hdescription%>
Start: <%=start%>, End: <%=end%>, Duration: <%=duration%>
'
+);
+
+ResultsBin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
+ this.max_results = _opts.max_results || 50;
+ this.search = _opts.search;
+ this.title_$.html('Lignes de Temps: "' + _opts.search + '"');
+ this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
+ this.refresh();
+};
+
+ResultsBin.prototype.render = function(searchbase) {
+ if (!this.data) {
+ return;
+ }
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
+ function highlight(_text) {
+ return highlightrx.replace(_(_text).escape(), "
$1");
+ }
+ function convertTC(_ms) {
+ function pad(_n) {
+ var _res = _n.toString();
+ while (_res.length < 2) {
+ _res = '0' + _res;
+ }
+ return _res;
+ }
+ var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
+ _hours = Math.floor(_totalSeconds / 3600),
+ _minutes = (Math.floor(_totalSeconds / 60) % 60),
+ _seconds = _totalSeconds % 60,
+ _res = '';
+ if (_hours) {
+ _res += pad(_hours) + ':';
+ }
+ _res += pad(_minutes) + ':' + pad(_seconds);
+ return _res;
+ }
+
+ var _html = '',
+ _this = this,
+ count = 0;
+ _(this.data.objects).each(function(_segment) {
+ var _description = _segment.abstract,
+ _title = _segment.title;
+ if (!search.isempty && !search.test(_title) && !search.test(_description)) {
+ return;
+ }
+ count++;
+ var _duration = _segment.duration,
+ _begin = _segment.start_ts,
+ _end = + _segment.duration + _begin,
+ _img = (
+ _duration
+ ? _this.renkan.options.static_url + "img/ldt-segment.png"
+ : _this.renkan.options.static_url + "img/ldt-point.png"
+ );
+ _html += _this.segmentTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ description: _description,
+ hdescription: highlight(_description),
+ start: convertTC(_begin),
+ end: convertTC(_end),
+ duration: convertTC(_duration),
+ mediaid: _segment.iri_id,
+ //projectid: _segment.project_id,
+ //cuttingid: _segment.cutting_id,
+ annotationid: _segment.element_id,
+ image: _img
+ });
+ });
+
+ this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+ResultsBin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',
+ data: {
+ format: "jsonp",
+ q: this.search,
+ limit: this.max_results
+ },
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
+
+})(window.Rkns);
+Rkns.ResourceList = {};
+
+Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+Rkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(
+ '
" data-description="<%-description%>" '
+ + '<% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> >'
+ + '<% if (image) { %>
<% } %>'
+ + '<% if (description) { %><%=hdescription%>
<% } %><% if (image) { %><% } %>'
+);
+
+Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.title_$.html(_opts.title);
+ if (_opts.list) {
+ this.data = _opts.list;
+ }
+ this.refresh();
+};
+
+Rkns.ResourceList.Bin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ function highlight(_text) {
+ var _e = _(_text).escape();
+ return search.isempty ? _e : search.replace(_e, "
$1");
+ }
+ var _html = "",
+ _this = this,
+ count = 0;
+ Rkns._(this.data).each(function(_item) {
+ if (typeof _item === "string") {
+ if (/^(https?:\/\/|www)/.test(_item)) {
+ var _element = { url: _item };
+ } else {
+ var _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() },
+ _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);
+ if (_match) {
+ _element.url = _match[0];
+ }
+ if (_element.title.length > 80) {
+ _element.description = _element.title;
+ _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…');
+ }
+ }
+ } else {
+ var _element = _item;
+ }
+ var title = _element.title || (_element.url || "").replace(/^https?:\/\/(www\.)?/,'').replace(/^(.{40}).+$/,'$1…'),
+ url = _element.url || "",
+ description = _element.description || "",
+ image = _element.image || "";
+ if (url && !/^https?:\/\//.test(url)) {
+ url = 'http://' + url;
+ }
+ if (!search.isempty && !search.test(title) && !search.test(description)) {
+ return;
+ }
+ count++;
+ _html += _this.resultTemplate({
+ url: url,
+ title: title,
+ htitle: highlight(title),
+ image: image,
+ description: description,
+ hdescription: highlight(description),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+Rkns.ResourceList.Bin.prototype.refresh = function() {
+ if (this.data) {
+ this.render();
+ }
+};Rkns.Wikipedia = {
+};
+
+Rkns.Wikipedia.Search = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.lang = _opts.lang || "en";
+};
+
+Rkns.Wikipedia.Search.prototype.getBgClass = function() {
+ return "Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-" + this.lang;
+};
+
+Rkns.Wikipedia.Search.prototype.getSearchTitle = function() {
+ var langs = {
+ "fr": "French",
+ "en": "English",
+ "ja": "Japanese"
+ };
+ if (langs[this.lang]) {
+ return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]);
+ } else {
+ return this.renkan.translate("Wikipedia") + " [" + this.lang + "]";
+ }
+};
+
+Rkns.Wikipedia.Search.prototype.search = function(_q) {
+ this.renkan.tabs.push(
+ new Rkns.Wikipedia.Bin(this.renkan, {
+ lang: this.lang,
+ search: _q
+ })
+ );
+};
+
+Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+Rkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(
+ '
" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>">'
+ + '
'
+ + '
<%=hdescription%>
'
+);
+
+Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.search = _opts.search;
+ this.lang = _opts.lang || "en";
+ this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);
+ this.title_$.html(this.search).addClass("Rk-Wikipedia-Title");
+ this.refresh();
+};
+
+Rkns.Wikipedia.Bin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
+ function highlight(_text) {
+ return highlightrx.replace(_(_text).escape(), "
$1");
+ }
+ var _html = "",
+ _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,"_")),
+ description = Rkns.$('
').html(_result.snippet).text();
+ if (!search.isempty && !search.test(title) && !search.test(description)) {
+ return;
+ }
+ count++;
+ _html += _this.resultTemplate({
+ url: url,
+ title: title,
+ htitle: highlight(title),
+ description: description,
+ hdescription: highlight(description),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+Rkns.Wikipedia.Bin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: "http://" + _this.lang + ".wikipedia.org/w/api.php?action=query&list=search&srsearch=" + encodeURIComponent(this.search) + "&format=json",
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
\ No newline at end of file