--- a/client/js/paper-renderer.js Mon Apr 08 01:21:24 2013 +0200
+++ b/client/js/paper-renderer.js Tue Apr 09 16:09:25 2013 +0200
@@ -170,6 +170,7 @@
var _raster = new paper.Raster(_img);
_raster.position = _imgdelta.add(_grp.position).subtract(_delta);
_grp.addChild(_raster);
+ _repr.renderer.throttledPaperDraw();
}
_img.src = _imgsrc;
return _res
@@ -697,11 +698,13 @@
Rkns.Renderer.TempEdge.prototype._init = function() {
this.renderer.edge_layer.activate();
- this.type = "temp-edge";
+ this.type = "Temp-edge";
var _color = (this.project.get("users").get(this.renkan.current_user) || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
this.line = new paper.Path();
this.line.strokeColor = _color;
+ this.line.dashArray = [4, 2];
+ this.line.strokeWidth = this.options.selected_edge_stroke_width;
this.line.add([0,0],[0,0]);
this.line.__representation = this;
this.arrow = new paper.Path();
@@ -745,17 +748,21 @@
_endDrag = true;
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
var _target = _hitResult.item.__representation;
- if (_target.type === "Node" && _model !== _target.model) {
- var _data = {
- id: Rkns.Utils.getUID('edge'),
- created_by: this.renkan.current_user,
- from: _model.get("_id"),
- to: _target.model.get("_id")
- };
- if (this.renderer.isEditable()) {
- this.project.addEdge(_data);
- }
+ if (_target.type.substr(0,4) === "Node") {
+ var _destmodel = _target.model || _target.source_representation.model;
+ if (_model !== _destmodel) {
+ var _data = {
+ id: Rkns.Utils.getUID('edge'),
+ created_by: this.renkan.current_user,
+ from: _model,
+ to: _destmodel
+ };
+ if (this.renderer.isEditable()) {
+ this.project.addEdge(_data);
+ }
+ }
}
+
if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
_endDrag = false;
this.renderer.is_dragging = true;
@@ -874,9 +881,15 @@
}).defer();
}).throttle(500);
- this.editor_$.find("input, textarea").bind("change keyup paste", onFieldChange);
+ this.editor_$.on("keyup", function(_e) {
+ if (_e.keyCode === 27) {
+ closeEditor();
+ }
+ });
- this.editor_$.find(".Rk-Edit-Image-File").bind("change", function() {
+ this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange);
+
+ this.editor_$.find(".Rk-Edit-Image-File").change(function() {
if (this.files.length) {
var f = this.files[0],
fr = new FileReader();
@@ -902,7 +915,7 @@
);
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(this.renkan)).get("color")) }
+ function() { _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color")) }
).click(function() {
if (_this.renderer.isEditable()) {
_model.set("color", $(this).attr("data-color"));
@@ -1049,7 +1062,14 @@
}).defer();
}).throttle(500);
- this.editor_$.find("input").bind("keyup change paste", onFieldChange);
+ this.editor_$.on("keyup", function(_e) {
+ if (_e.keyCode === 27) {
+ closeEditor();
+ }
+ });
+
+ this.editor_$.find("input").on("keyup change paste", onFieldChange);
+
this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
var e = $(this),
v = e.val();
@@ -1130,8 +1150,8 @@
Rkns.Renderer.NodeEditButton.prototype._init = function() {
this.type = "Node-edit-button";
this.lastSectorInner = 0;
- this.startAngle = -225;
- this.endAngle = -135;
+ this.startAngle = -135;
+ this.endAngle = -45;
this.imageFile = 'img/edit.png';
this.text = "Edit";
}
@@ -1149,8 +1169,8 @@
Rkns.Renderer.NodeRemoveButton.prototype._init = function() {
this.type = "Node-remove-button";
this.lastSectorInner = 0;
- this.startAngle = -45;
- this.endAngle = 45;
+ this.startAngle = 90;
+ this.endAngle = 180;
this.imageFile = 'img/remove.png';
this.text = "Remove";
}
@@ -1169,8 +1189,8 @@
Rkns.Renderer.NodeLinkButton.prototype._init = function() {
this.type = "Node-link-button";
this.lastSectorInner = 0;
- this.startAngle = -135;
- this.endAngle = -45;
+ this.startAngle = 0;
+ this.endAngle = 90;
this.imageFile = 'img/link.png';
this.text = "Link to another node";
}
@@ -1182,8 +1202,8 @@
Rkns.Renderer.NodeEnlargeButton.prototype._init = function() {
this.type = "Node-enlarge-button";
this.lastSectorInner = 0;
- this.startAngle = 45;
- this.endAngle = 90;
+ this.startAngle = -45;
+ this.endAngle = 0;
this.imageFile = 'img/enlarge.png';
this.text = "Enlarge";
}
@@ -1203,8 +1223,8 @@
Rkns.Renderer.NodeShrinkButton.prototype._init = function() {
this.type = "Node-shrink-button";
this.lastSectorInner = 0;
- this.startAngle = 90;
- this.endAngle = 135;
+ this.startAngle = -180;
+ this.endAngle = -135;
this.imageFile = 'img/shrink.png';
this.text = "Shrink";
}
@@ -1314,6 +1334,10 @@
this.minimap.miniframe.__representation = new Rkns.Renderer.MiniFrame(this, null);
}
+ this.throttledPaperDraw = Rkns._(function() {
+ paper.view.draw();
+ }).throttle(100);
+
this.bundles = [];
this.click_mode = false;
var _tool = new paper.Tool(),
@@ -1342,21 +1366,17 @@
_this.onDoubleClick(_event);
});
this.canvas_$.on("dragover", function(_event) {
- _event.stopPropagation();
_event.preventDefault();
});
this.canvas_$.on("dragenter", function(_event) {
_allowScroll = false;
- _event.stopPropagation();
_event.preventDefault();
});
this.canvas_$.on("dragleave", function(_event) {
_allowScroll = true;
- _event.stopPropagation();
_event.preventDefault();
});
this.canvas_$.on("drop", function(_event) {
- _event.stopPropagation();
_event.preventDefault();
_allowScroll = true;
if (!_this.isEditable()) {
@@ -1431,9 +1451,15 @@
}
if (res["text/html"] || res["text/x-iri-selected-html"]) {
var snippet = Rkns.$('<div>').html(res["text/html"] || res["text/x-iri-selected-html"]);
- newNode.image = snippet.find("img").attr("src") || '';
- newNode.uri = snippet.find("a").attr("href") || newNode.uri;
- newNode.title = snippet.find("[title]").attr("title");
+ var _imgs = snippet.find("img");
+ if (_imgs.length) {
+ newNode.image = _imgs[0].src;
+ }
+ var _as = snippet.find("a");
+ if (_as.length) {
+ newNode.uri = _as[0].href;
+ }
+ newNode.title = snippet.find("[title]").attr("title") || newNode.title;
newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim();
}
if (res["text/uri-list"]) {
@@ -1900,7 +1926,7 @@
}
Rkns.Renderer.Scene.prototype.onMouseDown = function(_event) {
- if (!this.click_target || this.click_target.type !== "temp-edge") {
+ if (!this.click_target || this.click_target.type !== "Temp-edge") {
this.removeRepresentationsOfType("editor");
this.is_dragging = false;
var _hitResult = paper.project.hitTest(_event.point);