| author | Nicolas Sauret <nicolas.sauret@iri.centrepompidou.fr> |
| Thu, 28 Nov 2013 11:03:05 +0100 | |
| changeset 1011 | 5a8a3d1069e2 |
| parent 898 | 196ce9f8751c |
| child 1198 | ff4b567d51f2 |
| permissions | -rw-r--r-- |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1 |
/* ********************************************************* |
| 898 | 2 |
File generated on Wed May 15 15:42:55 CEST 2013 |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
4 |
start of main.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
5 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
6 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
7 |
/* |
| 898 | 8 |
_____ _ |
9 |
| __ \ | | |
|
10 |
| |__) |___ _ __ | | ____ _ _ __ |
|
11 |
| _ // _ \ '_ \| |/ / _` | '_ \ |
|
12 |
| | \ \ __/ | | | < (_| | | | | |
|
13 |
|_| \_\___|_| |_|_|\_\__,_|_| |_| |
|
14 |
||
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
15 |
* Copyright 2012-2013 Institut de recherche et d'innovation |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
16 |
* contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
17 |
* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
18 |
* contact@iri.centrepompidou.fr |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
19 |
* http://www.iri.centrepompidou.fr |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
20 |
* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
21 |
* This software is a computer program whose purpose is to show and add annotations on a video . |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
22 |
* This software is governed by the CeCILL-C license under French law and |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
23 |
* abiding by the rules of distribution of free software. You can use, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
24 |
* modify and/ or redistribute the software under the terms of the CeCILL-C |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
25 |
* license as circulated by CEA, CNRS and INRIA at the following URL |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
26 |
* "http://www.cecill.info". |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
27 |
* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
28 |
* The fact that you are presently reading this means that you have had |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
29 |
* knowledge of the CeCILL-C license and that you accept its terms. |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
30 |
*/ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
31 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
32 |
/* Declaring the Renkan Namespace Rkns and Default values */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
33 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
34 |
if (typeof Rkns !== "object") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
35 |
Rkns = {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
36 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
37 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
38 |
Rkns.$ = jQuery; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
39 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
40 |
Rkns._ = _; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
41 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
42 |
Rkns.VERSION = '0.2'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
43 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
44 |
Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
45 |
"#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
46 |
"#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
47 |
"#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
48 |
"#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
49 |
"#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
50 |
"#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
51 |
"#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
52 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
53 |
Rkns._BaseBin = function(_renkan, _opts) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
54 |
if (typeof _renkan !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
55 |
this.renkan = _renkan; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
56 |
this.renkan.$.find(".Rk-Bin-Main").hide();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
57 |
this.$ = Rkns.$('<li>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
58 |
.addClass("Rk-Bin")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
59 |
.appendTo(_renkan.$.find(".Rk-Bin-List"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
60 |
this.title_icon_$ = Rkns.$('<span>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
61 |
.addClass("Rk-Bin-Title-Icon")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
62 |
.appendTo(this.$); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
63 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
64 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
65 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
66 |
Rkns.$('<a>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
67 |
.attr({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
68 |
href: "#", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
69 |
title: _renkan.translate("Close bin")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
70 |
}) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
71 |
.addClass("Rk-Bin-Close")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
72 |
.html('×')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
73 |
.appendTo(this.$) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
74 |
.click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
75 |
_this.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
76 |
if (!_renkan.$.find(".Rk-Bin-Main:visible").length) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
77 |
_renkan.$.find(".Rk-Bin-Main:last").slideDown();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
78 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
79 |
_renkan.resizeBins(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
80 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
81 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
82 |
Rkns.$('<a>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
83 |
.attr({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
84 |
href: "#", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
85 |
title: _renkan.translate("Refresh bin")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
86 |
}) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
87 |
.addClass("Rk-Bin-Refresh")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
88 |
.appendTo(this.$) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
89 |
.click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
90 |
_this.refresh(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
91 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
92 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
93 |
this.count_$ = Rkns.$('<div>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
94 |
.addClass("Rk-Bin-Count")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
95 |
.appendTo(this.$); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
96 |
this.title_$ = Rkns.$('<h2>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
97 |
.addClass("Rk-Bin-Title")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
98 |
.appendTo(this.$); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
99 |
this.main_$ = Rkns.$('<div>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
100 |
.addClass("Rk-Bin-Main")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
101 |
.appendTo(this.$) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
102 |
.html('<h4 class="Rk-Bin-Loading">' + _renkan.translate("Loading, please wait") + '</h4>');
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
103 |
this.title_$.html(_opts.title || '(new bin)'); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
104 |
this.renkan.resizeBins(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
105 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
106 |
if (_opts.auto_refresh) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
107 |
window.setInterval(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
108 |
_this.refresh(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
109 |
},_opts.auto_refresh); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
110 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
111 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
112 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
113 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
114 |
Rkns._BaseBin.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
115 |
this.$.detach(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
116 |
this.renkan.resizeBins(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
117 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
118 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
119 |
/* Point of entry */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
120 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
121 |
Rkns.Renkan = function(_opts) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
122 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
123 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
124 |
this.options = _.defaults(_opts, Rkns.defaults); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
125 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
126 |
Rkns._(this.options.property_files).each(function(f) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
127 |
Rkns.$.getJSON(f, function(data) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
128 |
_this.options.properties = _this.options.properties.concat(data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
129 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
130 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
131 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
132 |
this.read_only = this.options.read_only || !this.options.editor_mode; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
133 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
134 |
this.project = new Rkns.Models.Project(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
135 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
136 |
if (typeof this.options.user_id !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
137 |
this.current_user = this.options.user_id; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
138 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
139 |
this.$ = Rkns.$("#" + this.options.container);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
140 |
this.$ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
141 |
.addClass("Rk-Main")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
142 |
.html(this.template(this)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
143 |
this.renderer = new Rkns.Renderer.Scene(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
144 |
this.tabs = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
145 |
this.search_engines = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
146 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
147 |
this.current_user_list = new Rkns.Models.UsersList(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
148 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
149 |
if (!this.options.search.length) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
150 |
this.$.find(".Rk-Web-Search-Form").detach();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
151 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
152 |
var _tmpl = Rkns._.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
153 |
_select = this.$.find(".Rk-Search-List"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
154 |
_input = this.$.find(".Rk-Web-Search-Input"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
155 |
_form = this.$.find(".Rk-Web-Search-Form");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
156 |
Rkns._(this.options.search).each(function(_search, _key) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
157 |
if (Rkns[_search.type] && Rkns[_search.type].Search) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
158 |
_this.search_engines.push(new Rkns[_search.type].Search(_this, _search)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
159 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
160 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
161 |
_select.html( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
162 |
Rkns._(this.search_engines).map(function(_search, _key) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
163 |
return _tmpl({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
164 |
key: _key, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
165 |
title: _search.getSearchTitle(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
166 |
className: _search.getBgClass() |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
167 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
168 |
}).join("")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
169 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
170 |
_select.find("li").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
171 |
var _el = Rkns.$(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
172 |
_this.setSearchEngine(_el.attr("data-key"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
173 |
_form.submit(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
174 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
175 |
_form.submit(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
176 |
if (_input.val()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
177 |
var _search = _this.search_engine; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
178 |
_search.search(_input.val()); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
179 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
180 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
181 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
182 |
this.$.find(".Rk-Search-Current").mouseenter(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
183 |
function() { _select.slideDown(); }
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
184 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
185 |
this.$.find(".Rk-Search-Select").mouseleave(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
186 |
function() { _select.hide(); }
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
187 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
188 |
this.setSearchEngine(0); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
189 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
190 |
Rkns._(this.options.bins).each(function(_bin) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
191 |
if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
192 |
_this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
193 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
194 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
195 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
196 |
var elementDropped = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
197 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
198 |
this.$.find(".Rk-Bins")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
199 |
.on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
200 |
var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
201 |
if (_mainDiv.is(":hidden")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
202 |
_this.$.find(".Rk-Bin-Main").slideUp();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
203 |
_mainDiv.slideDown(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
204 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
205 |
}).on("mouseover", ".Rk-Bin-Item", function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
206 |
var _t = Rkns.$(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
207 |
if (_t && $(_t).attr("data-uri")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
208 |
var _models = _this.project.get("nodes").where({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
209 |
uri: $(_t).attr("data-uri")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
210 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
211 |
Rkns._(_models).each(function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
212 |
_this.renderer.highlightModel(_model); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
213 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
214 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
215 |
}).mouseout(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
216 |
_this.renderer.unhighlightAll(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
217 |
}).on("mousemove", ".Rk-Bin-Item", function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
218 |
try {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
219 |
this.dragDrop(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
220 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
221 |
catch(err) {}
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
222 |
}).on("touchstart", ".Rk-Bin-Item", function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
223 |
elementDropped = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
224 |
}).on("touchmove", ".Rk-Bin-Item", function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
225 |
e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
226 |
var touch = e.originalEvent.changedTouches[0], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
227 |
off = _this.renderer.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
228 |
w = _this.renderer.canvas_$.width(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
229 |
h = _this.renderer.canvas_$.height(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
230 |
if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
231 |
if (elementDropped) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
232 |
_this.renderer.onMouseMove(touch, true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
233 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
234 |
elementDropped = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
235 |
var div = document.createElement('div');
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
236 |
div.appendChild(this.cloneNode(true)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
237 |
_this.renderer.dropData({"text/html": div.innerHTML}, touch);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
238 |
_this.renderer.onMouseDown(touch, true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
239 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
240 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
241 |
}).on("touchend", ".Rk-Bin-Item", function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
242 |
if (elementDropped) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
243 |
_this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
244 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
245 |
elementDropped = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
246 |
}).on("dragstart", ".Rk-Bin-Item", function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
247 |
var div = document.createElement('div');
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
248 |
div.appendChild(this.cloneNode(true)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
249 |
try {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
250 |
e.originalEvent.dataTransfer.setData("text/html",div.innerHTML);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
251 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
252 |
catch(err) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
253 |
e.originalEvent.dataTransfer.setData("text",div.innerHTML);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
254 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
255 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
256 |
Rkns.$(window).resize(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
257 |
_this.resizeBins(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
258 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
259 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
260 |
this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
261 |
var val = Rkns.$(this).val(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
262 |
Rkns._(_this.tabs).each(function(tab) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
263 |
tab.render(val); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
264 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
265 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
266 |
this.$.find(".Rk-Bins-Search-Form").submit(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
267 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
268 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
269 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
270 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
271 |
Rkns.Renkan.prototype.template = Rkns._.template( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
272 |
'<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
273 |
+ '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" />'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
274 |
+ '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
275 |
+ '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
276 |
+ '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
277 |
+ '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
278 |
+ '<ul class="Rk-Bin-List"></ul></div><% } %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
279 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
280 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
281 |
Rkns.Renkan.prototype.translate = function(_text) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
282 |
if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
283 |
return Rkns.i18n[this.options.language][_text]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
284 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
285 |
if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
286 |
return Rkns.i18n[this.options.language.substr(0,2)][_text]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
287 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
288 |
return _text; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
289 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
290 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
291 |
Rkns.Renkan.prototype.onStatusChange = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
292 |
this.renderer.onStatusChange(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
293 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
294 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
295 |
Rkns.Renkan.prototype.setSearchEngine = function(_key) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
296 |
this.search_engine = this.search_engines[_key]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
297 |
this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass());
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
298 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
299 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
300 |
Rkns.Renkan.prototype.resizeBins = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
301 |
var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
302 |
this.$.find(".Rk-Bin-Title:visible").each(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
303 |
_d += Rkns.$(this).outerHeight(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
304 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
305 |
this.$.find(".Rk-Bin-Main").css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
306 |
height: this.$.find(".Rk-Bins").height() - _d
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
307 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
308 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
309 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
310 |
/* Utility functions */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
311 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
312 |
Rkns.Utils = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
313 |
_ID_AUTO_INCREMENT : 0, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
314 |
_ID_BASE : (function(_d) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
315 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
316 |
function pad(n){return n<10 ? '0'+n : n;}
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
317 |
function fillrand(n) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
318 |
var _res = ''; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
319 |
for (var i=0; i<n; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
320 |
_res += Math.floor(16*Math.random()).toString(16); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
321 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
322 |
return _res; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
323 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
324 |
return _d.getUTCFullYear() + '-' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
325 |
+ pad(_d.getUTCMonth()+1) + '-' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
326 |
+ pad(_d.getUTCDate()) + '-' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
327 |
+ fillrand(16); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
328 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
329 |
})(new Date()), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
330 |
getUID : function(_base) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
331 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
332 |
var _n = (++this._ID_AUTO_INCREMENT).toString(16), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
333 |
_base = (typeof _base === "undefined" ? "" : _base + "-" ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
334 |
while (_n.length < 4) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
335 |
_n = '0' + _n; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
336 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
337 |
return _base + this._ID_BASE + '-' + _n; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
338 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
339 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
340 |
getFullURL : function(url) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
341 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
342 |
if(typeof(url) == 'undefined' || url == null ) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
343 |
return ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
344 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
345 |
if(/https?:\/\//.test(url)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
346 |
return url; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
347 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
348 |
var img = new Image(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
349 |
img.src = url; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
350 |
var res = img.src; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
351 |
img.src = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
352 |
return res; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
353 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
354 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
355 |
inherit : function(_baseClass, _callbefore) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
356 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
357 |
var _class = function(_arg) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
358 |
if (typeof _callbefore === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
359 |
_callbefore.apply(this, Array.prototype.slice.call(arguments, 0)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
360 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
361 |
_baseClass.apply(this, Array.prototype.slice.call(arguments, 0)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
362 |
if (typeof this._init == "function" && !this._initialized) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
363 |
this._init.apply(this, Array.prototype.slice.call(arguments, 0)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
364 |
this._initialized = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
365 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
366 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
367 |
Rkns._(_class.prototype).extend(_baseClass.prototype); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
368 |
return _class; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
369 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
370 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
371 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
372 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
373 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
374 |
end of main.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
375 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
376 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
377 |
start of models.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
378 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
379 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
380 |
(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
381 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
382 |
var root = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
383 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
384 |
var Backbone = root.Backbone; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
385 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
386 |
var Models = root.Rkns.Models = {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
387 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
388 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
389 |
Models.getUID = function(obj) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
390 |
var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
391 |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
392 |
return v.toString(16); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
393 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
394 |
return obj.type + "-" + guid; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
395 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
396 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
397 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
398 |
var RenkanModel = Backbone.RelationalModel.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
399 |
idAttribute : "_id", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
400 |
constructor: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
401 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
402 |
if (typeof options !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
403 |
options._id = options._id || options.id || Models.getUID(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
404 |
options.title = options.title || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
405 |
options.description = options.description || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
406 |
options.uri = options.uri || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
407 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
408 |
if(typeof this.prepare === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
409 |
options = this.prepare(options); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
410 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
411 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
412 |
Backbone.RelationalModel.prototype.constructor.call(this, options); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
413 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
414 |
validate: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
415 |
if(!this.type) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
416 |
return "object has no type"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
417 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
418 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
419 |
addReference : function(_options, _propName, _list, _id, _default) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
420 |
var _element = _list.get(_id); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
421 |
if (typeof _element === "undefined" && typeof _default !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
422 |
_options[_propName ] = _default; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
423 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
424 |
else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
425 |
_options[_propName ] = _element; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
426 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
427 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
428 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
429 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
430 |
// USER |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
431 |
var User = Models.User = RenkanModel.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
432 |
type: "user", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
433 |
prepare: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
434 |
options.color = options.color || "#666666"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
435 |
return options; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
436 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
437 |
toJSON: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
438 |
return {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
439 |
_id: this.get("_id"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
440 |
title: this.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
441 |
uri: this.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
442 |
description: this.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
443 |
color: this.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
444 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
445 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
446 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
447 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
448 |
// NODE |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
449 |
var Node = Models.Node = RenkanModel.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
450 |
type: "node", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
451 |
relations: [{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
452 |
type: Backbone.HasOne, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
453 |
key: "created_by", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
454 |
relatedModel: User |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
455 |
}], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
456 |
prepare: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
457 |
project = options.project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
458 |
this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
459 |
options.description = options.description || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
460 |
return options; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
461 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
462 |
toJSON: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
463 |
return {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
464 |
_id: this.get("_id"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
465 |
title: this.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
466 |
uri: this.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
467 |
description: this.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
468 |
position: this.get("position"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
469 |
image: this.get("image"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
470 |
color: this.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
471 |
created_by: this.get("created_by") ? this.get("created_by").get("_id") : null,
|
| 898 | 472 |
size: this.get("size"),
|
473 |
"clip-path": this.get("clip-path")
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
474 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
475 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
476 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
477 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
478 |
// EDGE |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
479 |
var Edge = Models.Edge = RenkanModel.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
480 |
type: "edge", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
481 |
relations: [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
482 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
483 |
type: Backbone.HasOne, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
484 |
key: "created_by", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
485 |
relatedModel: User |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
486 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
487 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
488 |
type: Backbone.HasOne, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
489 |
key: "from", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
490 |
relatedModel: Node |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
491 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
492 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
493 |
type: Backbone.HasOne, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
494 |
key: "to", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
495 |
relatedModel: Node |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
496 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
497 |
], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
498 |
prepare: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
499 |
project = options.project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
500 |
this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
501 |
this.addReference(options, "from", project.get("nodes"), options.from);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
502 |
this.addReference(options, "to", project.get("nodes"), options.to);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
503 |
return options; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
504 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
505 |
toJSON: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
506 |
return {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
507 |
_id: this.get("_id"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
508 |
title: this.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
509 |
uri: this.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
510 |
description: this.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
511 |
from: this.get("from") ? this.get("from").get("_id") : null,
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
512 |
to: this.get("to") ? this.get("to").get("_id") : null,
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
513 |
color: this.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
514 |
created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
515 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
516 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
517 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
518 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
519 |
// PROJECT |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
520 |
var Project = Models.Project = RenkanModel.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
521 |
type: "project", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
522 |
relations: [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
523 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
524 |
type: Backbone.HasMany, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
525 |
key: "users", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
526 |
relatedModel: User, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
527 |
reverseRelation: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
528 |
key: 'project', |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
529 |
includeInJSON: '_id' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
530 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
531 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
532 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
533 |
type: Backbone.HasMany, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
534 |
key: "nodes", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
535 |
relatedModel: Node, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
536 |
reverseRelation: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
537 |
key: 'project', |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
538 |
includeInJSON: '_id' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
539 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
540 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
541 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
542 |
type: Backbone.HasMany, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
543 |
key: "edges", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
544 |
relatedModel: Edge, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
545 |
reverseRelation: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
546 |
key: 'project', |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
547 |
includeInJSON: '_id' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
548 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
549 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
550 |
], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
551 |
addUser: function(_props, _options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
552 |
_props.project = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
553 |
var _user = User.findOrCreate(_props); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
554 |
this.get("users").push(_user, _options);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
555 |
return _user; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
556 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
557 |
addNode: function(_props, _options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
558 |
_props.project = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
559 |
var _node = Node.findOrCreate(_props); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
560 |
this.get("nodes").push(_node, _options);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
561 |
return _node; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
562 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
563 |
addEdge: function(_props, _options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
564 |
_props.project = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
565 |
var _edge = Edge.findOrCreate(_props); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
566 |
this.get("edges").push(_edge, _options);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
567 |
return _edge; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
568 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
569 |
removeNode: function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
570 |
this.get("nodes").remove(_model);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
571 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
572 |
removeEdge: function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
573 |
this.get("edges").remove(_model);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
574 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
575 |
validate: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
576 |
var _project = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
577 |
_(options.users).each(function(_item) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
578 |
_item.project = _project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
579 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
580 |
_(options.nodes).each(function(_item) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
581 |
_item.project = _project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
582 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
583 |
_(options.edges).each(function(_item) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
584 |
_item.project = _project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
585 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
586 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
587 |
// Add event handler to remove edges when a node is removed |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
588 |
initialize: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
589 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
590 |
this.on("remove:nodes", function(_node) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
591 |
_this.get("edges").remove(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
592 |
_this.get("edges").filter(function(_edge) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
593 |
return _edge.get("from") == _node || _edge.get("to") == _node;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
594 |
}) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
595 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
596 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
597 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
598 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
599 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
600 |
var RosterUser = Models.RosterUser = Backbone.Model.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
601 |
type: "roster_user", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
602 |
idAttribute : "_id", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
603 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
604 |
constructor: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
605 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
606 |
if (typeof options !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
607 |
options._id = options._id || options.id || Models.getUID(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
608 |
options.title = options.title || "(untitled " + this.type + ")"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
609 |
options.description = options.description || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
610 |
options.uri = options.uri || ""; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
611 |
options.project = options.project || null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
612 |
options.site_id = options.site_id || 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
613 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
614 |
if(typeof this.prepare === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
615 |
options = this.prepare(options); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
616 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
617 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
618 |
Backbone.Model.prototype.constructor.call(this, options); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
619 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
620 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
621 |
validate: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
622 |
if(!this.type) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
623 |
return "object has no type"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
624 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
625 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
626 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
627 |
prepare: function(options) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
628 |
options.color = options.color || "#666666"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
629 |
return options; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
630 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
631 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
632 |
toJSON: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
633 |
return {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
634 |
_id: this.get("_id"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
635 |
title: this.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
636 |
uri: this.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
637 |
description: this.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
638 |
color: this.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
639 |
project: (this.get("project") != null)?this.get("project").get("id"):null,
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
640 |
site_id: this.get("site_id")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
641 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
642 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
643 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
644 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
645 |
var UsersList = Models.UsersList = Backbone.Collection.extend({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
646 |
model: RosterUser |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
647 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
648 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
649 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
650 |
}).call(window); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
651 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
652 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
653 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
654 |
end of models.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
655 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
656 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
657 |
start of defaults.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
658 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
659 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
660 |
Rkns.defaults = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
661 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
662 |
language: (navigator.language || navigator.userLanguage || "en"), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
663 |
/* GUI Language */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
664 |
container: "renkan", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
665 |
/* GUI Container DOM element ID */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
666 |
search: [], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
667 |
/* List of Search Engines */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
668 |
bins: [], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
669 |
/* List of Bins */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
670 |
static_url: "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
671 |
/* URL for static resources */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
672 |
show_bins: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
673 |
/* Show bins in left column */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
674 |
properties: [], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
675 |
/* Semantic properties for edges */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
676 |
read_only: false, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
677 |
/* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
678 |
editor_mode: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
679 |
/* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
680 |
snapshot_mode: false, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
681 |
/* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
682 |
show_top_bar: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
683 |
/* Show the top bar, (title, buttons, users) */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
684 |
default_user_color: "#303030", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
685 |
size_bug_fix: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
686 |
/* Resize the canvas after load (fixes a bug on iPad and FF Mac) */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
687 |
force_resize: false, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
688 |
allow_double_click: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
689 |
/* Allows Double Click to create a node on an empty background */ |
| 898 | 690 |
element_delete_delay: 0, |
691 |
/* Delay between clicking on the bin on an element and really deleting it |
|
692 |
Set to 0 for delete confirm */ |
|
693 |
autoscale_padding: 50, |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
694 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
695 |
/* MINI-MAP OPTIONS */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
696 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
697 |
show_minimap: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
698 |
/* Show a small map at the bottom right */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
699 |
minimap_width: 160, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
700 |
minimap_height: 120, |
| 898 | 701 |
minimap_padding: 20, |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
702 |
minimap_background_color: "#ffffff", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
703 |
minimap_border_color: "#cccccc", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
704 |
minimap_highlight_color: "#ffff00", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
705 |
minimap_highlight_weight: 5, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
706 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
707 |
/* EDGE/NODE COMMON OPTIONS */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
708 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
709 |
buttons_background: "#202020", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
710 |
buttons_label_color: "#c000c0", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
711 |
buttons_label_font_size: 9, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
712 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
713 |
/* NODE DISPLAY OPTIONS */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
714 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
715 |
show_node_circles: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
716 |
/* Show circles for nodes */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
717 |
clip_node_images: true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
718 |
/* Constraint node images to circles */ |
| 898 | 719 |
node_images_fill_mode: false, |
720 |
/* Set to false for "letterboxing" (height/width of node adapted to show full image) |
|
721 |
Set to true for "crop" (adapted to fill circle) */ |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
722 |
node_size_base: 25, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
723 |
node_stroke_width: 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
724 |
selected_node_stroke_width: 4, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
725 |
node_fill_color: "#ffffff", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
726 |
highlighted_node_fill_color: "#ffff00", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
727 |
node_label_distance: 5, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
728 |
/* Vertical distance between node and label */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
729 |
node_label_max_length: 60, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
730 |
/* Maximum displayed text length */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
731 |
label_untitled_nodes: "(untitled)", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
732 |
/* Label to display on untitled nodes */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
733 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
734 |
/* EDGE DISPLAY OPTIONS */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
735 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
736 |
edge_stroke_width: 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
737 |
selected_edge_stroke_width: 4, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
738 |
edge_label_distance: 0, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
739 |
edge_label_max_length: 20, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
740 |
edge_arrow_length: 18, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
741 |
edge_arrow_width: 12, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
742 |
edge_gap_in_bundles: 12, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
743 |
label_untitled_edges: "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
744 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
745 |
/* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
746 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
747 |
tooltip_width: 275, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
748 |
tooltip_padding: 10, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
749 |
tooltip_margin: 15, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
750 |
tooltip_arrow_length : 20, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
751 |
tooltip_arrow_width : 40, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
752 |
tooltip_top_color: "#f0f0f0", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
753 |
tooltip_bottom_color: "#d0d0d0", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
754 |
tooltip_border_color: "#808080", |
| 898 | 755 |
tooltip_border_width: 1, |
756 |
||
757 |
/* NODE EDITOR OPTIONS */ |
|
758 |
||
759 |
show_node_editor_uri: true, |
|
760 |
show_node_editor_description: true, |
|
761 |
show_node_editor_size: true, |
|
762 |
show_node_editor_color: true, |
|
763 |
show_node_editor_image: true, |
|
764 |
show_node_editor_creator: true, |
|
765 |
||
766 |
/* NODE TOOLTIP OPTIONS */ |
|
767 |
||
768 |
show_node_tooltip_uri: true, |
|
769 |
show_node_tooltip_description: true, |
|
770 |
show_node_tooltip_color: true, |
|
771 |
show_node_tooltip_image: true, |
|
772 |
show_node_tooltip_creator: true, |
|
773 |
||
774 |
/* EDGE EDITOR OPTIONS */ |
|
775 |
||
776 |
show_edge_editor_uri: true, |
|
777 |
show_edge_editor_color: true, |
|
778 |
show_edge_editor_direction: true, |
|
779 |
show_edge_editor_nodes: true, |
|
780 |
show_edge_editor_creator: true, |
|
781 |
||
782 |
/* EDGE TOOLTIP OPTIONS */ |
|
783 |
||
784 |
show_edge_tooltip_uri: true, |
|
785 |
show_edge_tooltip_color: true, |
|
786 |
show_edge_tooltip_nodes: true, |
|
787 |
show_edge_tooltip_creator: true |
|
788 |
||
789 |
/* */ |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
790 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
791 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
792 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
793 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
794 |
end of defaults.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
795 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
796 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
797 |
start of i18n.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
798 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
799 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
800 |
Rkns.i18n = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
801 |
fr: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
802 |
"Edit Node": "Édition d’un nœud", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
803 |
"Edit Edge": "Édition d’un lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
804 |
"Title:": "Titre :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
805 |
"URI:": "URI :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
806 |
"Description:": "Description :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
807 |
"From:": "De :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
808 |
"To:": "Vers :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
809 |
"Image": "Image", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
810 |
"Image URL:": "URL d'Image", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
811 |
"Choose Image File:": "Choisir un fichier image", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
812 |
"Full Screen": "Mode plein écran", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
813 |
"Add Node": "Ajouter un nœud", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
814 |
"Add Edge": "Ajouter un lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
815 |
"Archive Project": "Archiver le projet", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
816 |
"Auto-save enabled": "Enregistrement automatique activé", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
817 |
"Connection lost": "Connexion perdue", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
818 |
"Created by:": "Créé par :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
819 |
"Zoom In": "Agrandir l’échelle", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
820 |
"Zoom Out": "Rapetisser l’échelle", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
821 |
"Edit": "Éditer", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
822 |
"Remove": "Supprimer", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
823 |
"Cancel deletion": "Annuler la suppression", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
824 |
"Link to another node": "Créer un lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
825 |
"Enlarge": "Agrandir", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
826 |
"Shrink": "Rétrécir", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
827 |
"Click on the background canvas to add a node": "Cliquer sur le fond du graphe pour rajouter un nœud", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
828 |
"Click on a first node to start the edge": "Cliquer sur un premier nœud pour commencer le lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
829 |
"Click on a second node to complete the edge": "Cliquer sur un second nœud pour terminer le lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
830 |
"Twitter": "Twitter", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
831 |
"Wikipedia": "Wikipédia", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
832 |
"Wikipedia in ": "Wikipédia en ", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
833 |
"French": "Français", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
834 |
"English": "Anglais", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
835 |
"Japanese": "Japonais", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
836 |
"Untitled project": "Projet sans titre", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
837 |
"Lignes de Temps": "Lignes de Temps", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
838 |
"Loading, please wait": "Chargement en cours, merci de patienter", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
839 |
"Edge color:": "Couleur :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
840 |
"Node color:": "Couleur :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
841 |
"Choose color": "Choisir une couleur", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
842 |
"Change edge direction": "Changer le sens du lien", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
843 |
"Do you really wish to remove node ": "Voulez-vous réellement supprimer le nœud ", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
844 |
"Do you really wish to remove edge ": "Voulez-vous réellement supprimer le lien ", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
845 |
"This file is not an image": "Ce fichier n'est pas une image", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
846 |
"Image size must be under ": "L'image doit peser moins de ", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
847 |
"Size:": "Taille :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
848 |
"KB": "ko", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
849 |
"Choose from vocabulary:": "Choisir dans un vocabulaire :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
850 |
"SKOS Documentation properties": "SKOS: Propriétés documentaires", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
851 |
"has note": "a pour note", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
852 |
"has example": "a pour exemple", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
853 |
"has definition": "a pour définition", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
854 |
"SKOS Semantic relations": "SKOS: Relations sémantiques", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
855 |
"has broader": "a pour concept plus large", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
856 |
"has narrower": "a pour concept plus étroit", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
857 |
"has related": "a pour concept apparenté", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
858 |
"Dublin Core Metadata": "Métadonnées Dublin Core", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
859 |
"has contributor": "a pour contributeur", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
860 |
"covers": "couvre", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
861 |
"created by": "créé par", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
862 |
"has date": "a pour date", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
863 |
"published by": "édité par", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
864 |
"has source": "a pour source", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
865 |
"has subject": "a pour sujet", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
866 |
"Dragged resource": "Ressource glisée-déposée", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
867 |
"Search the Web": "Rechercher en ligne", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
868 |
"Search in Bins": "Rechercher dans les chutiers", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
869 |
"Close bin": "Fermer le chutier", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
870 |
"Refresh bin": "Rafraîchir le chutier", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
871 |
"(untitled)": "(sans titre)", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
872 |
"Select contents:": "Sélectionner des contenus :", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
873 |
"Drag items from this website, drop them in Renkan": "Glissez des éléments de ce site web vers Renkan", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
874 |
"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.": "Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan" |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
875 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
876 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
877 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
878 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
879 |
end of i18n.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
880 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
881 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
882 |
start of paper-renderer.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
883 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
884 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
885 |
Rkns.Renderer = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
886 |
_MIN_DRAG_DISTANCE: 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
887 |
_NODE_BUTTON_WIDTH: 40, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
888 |
_EDGE_BUTTON_INNER: 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
889 |
_EDGE_BUTTON_OUTER: 40, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
890 |
_CLICKMODE_ADDNODE : 1, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
891 |
_CLICKMODE_STARTEDGE : 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
892 |
_CLICKMODE_ENDEDGE : 3, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
893 |
_IMAGE_MAX_KB : 500, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
894 |
_NODE_SIZE_STEP: Math.LN2/4, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
895 |
_MIN_SCALE: 1/20, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
896 |
_MAX_SCALE: 20, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
897 |
_MOUSEMOVE_RATE: 80, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
898 |
_DOUBLETAP_DELAY: 800, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
899 |
_DOUBLETAP_DISTANCE: 20*20, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
900 |
_USER_PLACEHOLDER : function(_renkan) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
901 |
return {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
902 |
color: _renkan.options.default_user_color, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
903 |
title: _renkan.translate("(unknown user)"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
904 |
get: function(attr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
905 |
return this[attr] || false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
906 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
907 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
908 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
909 |
_BOOKMARKLET_CODE: function(_renkan) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
910 |
return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
911 |
+ _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
912 |
+ "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
913 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
914 |
shortenText : function(_text, _maxlength) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
915 |
return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
916 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
917 |
drawEditBox : function(_options, _coords, _path, _xmargin, _selector) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
918 |
_selector.css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
919 |
width: ( _options.tooltip_width - 2* _options.tooltip_padding ), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
920 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
921 |
var _height = _selector.outerHeight() + 2* _options.tooltip_padding, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
922 |
_isLeft = (_coords.x < paper.view.center.x ? 1 : -1), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
923 |
_left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
924 |
_right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
925 |
_top = _coords.y - _height / 2; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
926 |
if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
927 |
_top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
928 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
929 |
if (_top < _options.tooltip_margin) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
930 |
_top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
931 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
932 |
var _bottom = _top + _height; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
933 |
_path.segments[0].point |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
934 |
= _path.segments[7].point |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
935 |
= _coords.add([_isLeft * _xmargin, 0]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
936 |
_path.segments[1].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
937 |
= _path.segments[2].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
938 |
= _path.segments[5].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
939 |
= _path.segments[6].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
940 |
= _left; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
941 |
_path.segments[3].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
942 |
= _path.segments[4].point.x |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
943 |
= _right; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
944 |
_path.segments[2].point.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
945 |
= _path.segments[3].point.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
946 |
= _top; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
947 |
_path.segments[4].point.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
948 |
= _path.segments[5].point.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
949 |
= _bottom; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
950 |
_path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
951 |
_path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
952 |
_path.closed = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
953 |
_path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
954 |
_selector.css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
955 |
left: (_options.tooltip_padding + Math.min(_left, _right)), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
956 |
top: (_options.tooltip_padding + _top) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
957 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
958 |
return _path; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
959 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
960 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
961 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
962 |
Rkns.Renderer._BaseRepresentation = function(_renderer, _model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
963 |
if (typeof _renderer !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
964 |
this.renderer = _renderer; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
965 |
this.renkan = _renderer.renkan; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
966 |
this.project = _renderer.renkan.project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
967 |
this.options = _renderer.renkan.options; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
968 |
this.model = _model; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
969 |
if (this.model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
970 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
971 |
this._changeBinding = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
972 |
_this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
973 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
974 |
this._removeBinding = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
975 |
_renderer.removeRepresentation(_this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
976 |
_(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
977 |
_renderer.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
978 |
}).defer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
979 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
980 |
this._selectBinding = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
981 |
_this.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
982 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
983 |
this._unselectBinding = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
984 |
_this.unselect(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
985 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
986 |
this.model.on("change", this._changeBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
987 |
this.model.on("remove", this._removeBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
988 |
this.model.on("select", this._selectBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
989 |
this.model.on("unselect", this._unselectBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
990 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
991 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
992 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
993 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
994 |
Rkns.Renderer._BaseRepresentation.prototype.super = function(_func) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
995 |
Rkns.Renderer._BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
996 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
997 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
998 |
Rkns.Renderer._BaseRepresentation.prototype.redraw = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
999 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1000 |
Rkns.Renderer._BaseRepresentation.prototype.moveTo = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1001 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1002 |
Rkns.Renderer._BaseRepresentation.prototype.show = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1003 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1004 |
Rkns.Renderer._BaseRepresentation.prototype.hide = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1005 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1006 |
Rkns.Renderer._BaseRepresentation.prototype.select = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1007 |
if (this.model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1008 |
this.model.trigger("selected");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1009 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1010 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1011 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1012 |
Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1013 |
if (this.model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1014 |
this.model.trigger("unselected");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1015 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1016 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1017 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1018 |
Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1019 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1020 |
Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1021 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1022 |
Rkns.Renderer._BaseRepresentation.prototype.mousedown = function() {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1023 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1024 |
Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1025 |
if (this.model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1026 |
this.model.trigger("clicked");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1027 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1028 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1029 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1030 |
Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1031 |
if (this.model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1032 |
this.model.off("change", this._changeBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1033 |
this.model.off("remove", this._removeBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1034 |
this.model.off("select", this._selectBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1035 |
this.model.off("unselect", this._unselectBinding );
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1036 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1037 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1038 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1039 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1040 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1041 |
Rkns.Renderer._BaseButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1042 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1043 |
Rkns.Renderer._BaseButton.prototype.moveTo = function(_pos) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1044 |
this.sector.moveTo(_pos); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1045 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1046 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1047 |
Rkns.Renderer._BaseButton.prototype.show = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1048 |
this.sector.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1049 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1050 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1051 |
Rkns.Renderer._BaseButton.prototype.hide = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1052 |
this.sector.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1053 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1054 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1055 |
Rkns.Renderer._BaseButton.prototype.select = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1056 |
this.sector.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1057 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1058 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1059 |
Rkns.Renderer._BaseButton.prototype.unselect = function(_newTarget) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1060 |
this.sector.unselect(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1061 |
if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1062 |
this.source_representation.unselect(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1063 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1064 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1065 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1066 |
Rkns.Renderer._BaseButton.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1067 |
this.sector.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1068 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1069 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1070 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1071 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1072 |
Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1073 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1074 |
Rkns.Renderer.Node.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1075 |
this.renderer.node_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1076 |
this.type = "Node"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1077 |
this.circle = new paper.Path.Circle([0, 0], 1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1078 |
this.circle.__representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1079 |
if (this.options.show_node_circles) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1080 |
this.circle.strokeWidth = this.options.node_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1081 |
this.h_ratio = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1082 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1083 |
this.h_ratio = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1084 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1085 |
this.title = Rkns.$('<div class="Rk-Label">').appendTo(this.renderer.labels_$);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1086 |
if (this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1087 |
this.normal_buttons = [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1088 |
new Rkns.Renderer.NodeEditButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1089 |
new Rkns.Renderer.NodeRemoveButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1090 |
new Rkns.Renderer.NodeLinkButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1091 |
new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1092 |
new Rkns.Renderer.NodeShrinkButton(this.renderer, null) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1093 |
]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1094 |
this.pending_delete_buttons = [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1095 |
new Rkns.Renderer.NodeRevertButton(this.renderer, null) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1096 |
]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1097 |
this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1098 |
for (var i = 0; i < this.all_buttons.length; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1099 |
this.all_buttons[i].source_representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1100 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1101 |
this.active_buttons = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1102 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1103 |
this.active_buttons = this.all_buttons = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1104 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1105 |
this.last_circle_radius = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1106 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1107 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1108 |
this.renderer.minimap.node_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1109 |
this.minimap_circle = new paper.Path.Circle([0, 0], 1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1110 |
this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1111 |
this.renderer.minimap.node_group.addChild(this.minimap_circle); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1112 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1113 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1114 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1115 |
Rkns.Renderer.Node.prototype.redraw = function(_dontRedrawEdges) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1116 |
var _model_coords = new paper.Point(this.model.get("position")),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1117 |
_baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1118 |
if (!this.is_dragging || !this.paper_coords) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1119 |
this.paper_coords = this.renderer.toPaperCoords(_model_coords); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1120 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1121 |
this.circle_radius = _baseRadius * this.renderer.scale; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1122 |
if (this.last_circle_radius !== this.circle_radius) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1123 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1124 |
b.setSectorSize(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1125 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1126 |
var square = new paper.Size(this.circle_radius, this.circle_radius), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1127 |
topleft = this.paper_coords.subtract(square), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1128 |
bounds = new paper.Rectangle(topleft, square.multiply(2)); |
| 898 | 1129 |
this.circle.scale(this.circle_radius / this.last_circle_radius); |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1130 |
if (this.node_image) {
|
| 898 | 1131 |
this.node_image.scale(this.circle_radius / this.last_circle_radius); |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1132 |
} |
| 898 | 1133 |
} |
1134 |
this.circle.position = this.paper_coords; |
|
1135 |
if (this.node_image) {
|
|
1136 |
this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)); |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1137 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1138 |
this.last_circle_radius = this.circle_radius; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1139 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1140 |
var old_act_btn = this.active_buttons; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1141 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1142 |
if (this.model.get("delete_scheduled")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1143 |
var opacity = .5; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1144 |
this.active_buttons = this.pending_delete_buttons; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1145 |
this.circle.dashArray = [2,2]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1146 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1147 |
var opacity = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1148 |
this.active_buttons = this.normal_buttons; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1149 |
this.circle.dashArray = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1150 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1151 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1152 |
if (this.selected && this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1153 |
if (old_act_btn !== this.active_buttons) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1154 |
old_act_btn.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1155 |
b.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1156 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1157 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1158 |
this.active_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1159 |
b.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1160 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1161 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1162 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1163 |
if (this.node_image) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1164 |
this.node_image.opacity = this.highlighted ? opacity * .5 : (opacity - .01); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1165 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1166 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1167 |
this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1168 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1169 |
this.circle.opacity = this.options.show_node_circles ? opacity : .01; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1170 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1171 |
var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || "";
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1172 |
_text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1173 |
this.title.text(_text); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1174 |
this.title.css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1175 |
left: this.paper_coords.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1176 |
top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1177 |
opacity: opacity |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1178 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1179 |
var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1180 |
this.circle.strokeColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1181 |
var _pc = this.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1182 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1183 |
b.moveTo(_pc); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1184 |
}); |
| 898 | 1185 |
var lastImage = this.img; |
1186 |
this.img = this.model.get("image");
|
|
1187 |
if (this.img && this.img !== lastImage) {
|
|
1188 |
this.showImage(); |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1189 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1190 |
if (this.node_image && !this.img) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1191 |
this.node_image.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1192 |
delete this.node_image; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1193 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1194 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1195 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1196 |
this.minimap_circle.fillColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1197 |
var minipos = this.renderer.toMinimapCoords(_model_coords), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1198 |
miniradius = this.renderer.minimap.scale * _baseRadius, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1199 |
minisize = new paper.Size([miniradius, miniradius]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1200 |
this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1201 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1202 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1203 |
if (!_dontRedrawEdges) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1204 |
Rkns._.each(this.project.get("edges").filter(function (ed) { return ((ed.to === this.model) || (ed.from === this.model));}), function(edge, index, list){
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1205 |
var repr = this.renderer.getRepresentationByModel(edge); |
| 898 | 1206 |
if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1207 |
repr.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1208 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1209 |
}, this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1210 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1211 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1212 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1213 |
|
| 898 | 1214 |
Rkns.Renderer.Node.prototype.showImage = function() {
|
1215 |
if (typeof this.renderer.image_cache[this.img] === "undefined") {
|
|
1216 |
var _image = new Image(); |
|
1217 |
this.renderer.image_cache[this.img] = _image; |
|
1218 |
_image.src = this.img; |
|
1219 |
} else {
|
|
1220 |
var _image = this.renderer.image_cache[this.img]; |
|
1221 |
} |
|
1222 |
if (_image.width) {
|
|
1223 |
if (this.node_image) {
|
|
1224 |
this.node_image.remove(); |
|
1225 |
} |
|
1226 |
this.renderer.node_layer.activate(); |
|
1227 |
var width = _image.width, |
|
1228 |
height = _image.height, |
|
1229 |
clipPath = this.model.get("clip-path"),
|
|
1230 |
hasClipPath = (typeof clipPath !== "undefined" && clipPath); |
|
1231 |
if (hasClipPath) {
|
|
1232 |
var _clip = new paper.Path(), |
|
1233 |
instructions = clipPath.match(/[a-z][^a-z]+/gi) || [], |
|
1234 |
lastCoords = [0,0], |
|
1235 |
minX = Infinity, |
|
1236 |
minY = Infinity, |
|
1237 |
maxX = -Infinity, |
|
1238 |
maxY = -Infinity; |
|
1239 |
||
1240 |
function transformCoords(tabc, relative) {
|
|
1241 |
var newCoords = tabc.slice(1).map(function(v, k) {
|
|
1242 |
var res = parseFloat(v), |
|
1243 |
isY = k % 2; |
|
1244 |
if (isY) {
|
|
1245 |
res = ( res - .5 ) * height; |
|
1246 |
} else {
|
|
1247 |
res = ( res - .5 ) * width; |
|
1248 |
} |
|
1249 |
if (relative) {
|
|
1250 |
res += lastCoords[isY]; |
|
1251 |
} |
|
1252 |
if (isY) {
|
|
1253 |
minY = Math.min(minY, res); |
|
1254 |
maxY = Math.max(maxY, res); |
|
1255 |
} else {
|
|
1256 |
minX = Math.min(minX, res); |
|
1257 |
maxX = Math.max(maxX, res); |
|
1258 |
} |
|
1259 |
return res; |
|
1260 |
}); |
|
1261 |
lastCoords = newCoords.slice(-2); |
|
1262 |
return newCoords; |
|
1263 |
} |
|
1264 |
||
1265 |
instructions.forEach(function(instr) {
|
|
1266 |
var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""]; |
|
1267 |
switch(coords[0]) {
|
|
1268 |
case "M": |
|
1269 |
_clip.moveTo(transformCoords(coords)); |
|
1270 |
break; |
|
1271 |
case "m": |
|
1272 |
_clip.moveTo(transformCoords(coords, true)); |
|
1273 |
break; |
|
1274 |
case "L": |
|
1275 |
_clip.lineTo(transformCoords(coords)); |
|
1276 |
break; |
|
1277 |
case "l": |
|
1278 |
_clip.lineTo(transformCoords(coords, true)); |
|
1279 |
break; |
|
1280 |
case "C": |
|
1281 |
_clip.cubicCurveTo(transformCoords(coords)); |
|
1282 |
break; |
|
1283 |
case "c": |
|
1284 |
_clip.cubicCurveTo(transformCoords(coords, true)); |
|
1285 |
break; |
|
1286 |
case "Q": |
|
1287 |
_clip.quadraticCurveTo(transformCoords(coords)); |
|
1288 |
break; |
|
1289 |
case "q": |
|
1290 |
_clip.quadraticCurveTo(transformCoords(coords, true)); |
|
1291 |
break; |
|
1292 |
} |
|
1293 |
}); |
|
1294 |
||
1295 |
var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2, |
|
1296 |
centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2); |
|
1297 |
if (!this.options.show_node_circles) {
|
|
1298 |
this.h_ratio = (maxY - minY) / (2 * baseRadius); |
|
1299 |
} |
|
1300 |
} else {
|
|
1301 |
var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2, |
|
1302 |
centerPoint = new paper.Point(0,0); |
|
1303 |
if (!this.options.show_node_circles) {
|
|
1304 |
this.h_ratio = height / (2 * baseRadius); |
|
1305 |
} |
|
1306 |
} |
|
1307 |
var _raster = new paper.Raster(_image); |
|
1308 |
if (hasClipPath) {
|
|
1309 |
_raster = new paper.Group(_clip, _raster); |
|
1310 |
_raster.opacity = .99; |
|
1311 |
/* This is a workaround to allow clipping at group level |
|
1312 |
* If opacity was set to 1, paper.js would merge all clipping groups in one (known bug). |
|
1313 |
*/ |
|
1314 |
_raster.clipped = true; |
|
1315 |
_clip.__representation = this; |
|
1316 |
} |
|
1317 |
if (this.options.clip_node_images) {
|
|
1318 |
var _circleClip = new paper.Path.Circle(centerPoint, baseRadius); |
|
1319 |
_raster = new paper.Group(_circleClip, _raster); |
|
1320 |
_raster.opacity = .99; |
|
1321 |
_raster.clipped = true; |
|
1322 |
_circleClip.__representation = this; |
|
1323 |
} |
|
1324 |
this.image_delta = centerPoint.divide(baseRadius); |
|
1325 |
this.node_image = _raster; |
|
1326 |
this.node_image.__representation = _this; |
|
1327 |
this.node_image.scale(this.circle_radius / baseRadius); |
|
1328 |
this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)); |
|
1329 |
this.redraw(); |
|
1330 |
this.renderer.throttledPaperDraw(); |
|
1331 |
} else {
|
|
1332 |
var _this = this; |
|
1333 |
Rkns.$(_image).on("load", function() {
|
|
1334 |
_this.showImage(); |
|
1335 |
}); |
|
1336 |
} |
|
1337 |
} |
|
1338 |
||
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1339 |
Rkns.Renderer.Node.prototype.paperShift = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1340 |
if (this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1341 |
if (!this.renkan.read_only) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1342 |
this.is_dragging = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1343 |
this.paper_coords = this.paper_coords.add(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1344 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1345 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1346 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1347 |
this.renderer.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1348 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1349 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1350 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1351 |
Rkns.Renderer.Node.prototype.openEditor = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1352 |
this.renderer.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1353 |
var _editor = this.renderer.addRepresentation("NodeEditor",null);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1354 |
_editor.source_representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1355 |
_editor.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1356 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1357 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1358 |
Rkns.Renderer.Node.prototype.select = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1359 |
this.selected = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1360 |
this.circle.strokeWidth = this.options.selected_node_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1361 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1362 |
this.active_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1363 |
b.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1364 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1365 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1366 |
var _uri = this.model.get("uri");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1367 |
if (_uri) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1368 |
Rkns.$('.Rk-Bin-Item').each(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1369 |
var _el = Rkns.$(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1370 |
if (_el.attr("data-uri") == _uri) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1371 |
_el.addClass("selected");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1372 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1373 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1374 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1375 |
if (!this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1376 |
this.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1377 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1378 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1379 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1380 |
this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1381 |
this.minimap_circle.strokeColor = this.options.minimap_highlight_color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1382 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1383 |
this.super("select");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1384 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1385 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1386 |
Rkns.Renderer.Node.prototype.unselect = function(_newTarget) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1387 |
if (!_newTarget || _newTarget.source_representation !== this) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1388 |
this.selected = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1389 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1390 |
b.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1391 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1392 |
this.circle.strokeWidth = this.options.node_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1393 |
Rkns.$('.Rk-Bin-Item').removeClass("selected");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1394 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1395 |
this.minimap_circle.strokeColor = undefined; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1396 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1397 |
this.super("unselect");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1398 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1399 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1400 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1401 |
Rkns.Renderer.Node.prototype.highlight = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1402 |
if (this.highlighted) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1403 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1404 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1405 |
this.highlighted = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1406 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1407 |
this.renderer.throttledPaperDraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1408 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1409 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1410 |
Rkns.Renderer.Node.prototype.unhighlight = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1411 |
if (!this.highlighted) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1412 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1413 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1414 |
this.highlighted = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1415 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1416 |
this.renderer.throttledPaperDraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1417 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1418 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1419 |
Rkns.Renderer.Node.prototype.saveCoords = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1420 |
var _coords = this.renderer.toModelCoords(this.paper_coords), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1421 |
_data = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1422 |
position: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1423 |
x: _coords.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1424 |
y: _coords.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1425 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1426 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1427 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1428 |
this.model.set(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1429 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1430 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1431 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1432 |
Rkns.Renderer.Node.prototype.mousedown = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1433 |
if (_isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1434 |
this.renderer.unselectAll(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1435 |
this.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1436 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1437 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1438 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1439 |
Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1440 |
if (this.renderer.is_dragging && this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1441 |
this.saveCoords(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1442 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1443 |
if (!_isTouch && !this.model.get("delete_scheduled")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1444 |
this.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1445 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1446 |
this.model.trigger("clicked");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1447 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1448 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1449 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1450 |
this.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1451 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1452 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1453 |
Rkns.Renderer.Node.prototype.destroy = function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1454 |
this.super("destroy");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1455 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1456 |
b.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1457 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1458 |
this.circle.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1459 |
this.title.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1460 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1461 |
this.minimap_circle.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1462 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1463 |
if (this.node_image) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1464 |
this.node_image.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1465 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1466 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1467 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1468 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1469 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1470 |
Rkns.Renderer.Edge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1471 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1472 |
Rkns.Renderer.Edge.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1473 |
this.renderer.edge_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1474 |
this.type = "Edge"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1475 |
this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1476 |
this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1477 |
this.bundle = this.renderer.addToBundles(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1478 |
this.line = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1479 |
this.line.add([0,0],[0,0],[0,0]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1480 |
this.line.__representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1481 |
this.line.strokeWidth = this.options.edge_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1482 |
this.arrow = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1483 |
this.arrow.add( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1484 |
[ 0, 0 ], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1485 |
[ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1486 |
[ 0, this.options.edge_arrow_width ] |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1487 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1488 |
this.arrow.__representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1489 |
this.text = Rkns.$('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1490 |
this.arrow_angle = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1491 |
if (this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1492 |
this.normal_buttons = [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1493 |
new Rkns.Renderer.EdgeEditButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1494 |
new Rkns.Renderer.EdgeRemoveButton(this.renderer, null), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1495 |
]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1496 |
this.pending_delete_buttons = [ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1497 |
new Rkns.Renderer.EdgeRevertButton(this.renderer, null) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1498 |
]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1499 |
this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1500 |
for (var i = 0; i < this.all_buttons.length; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1501 |
this.all_buttons[i].source_representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1502 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1503 |
this.active_buttons = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1504 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1505 |
this.active_buttons = this.all_buttons = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1506 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1507 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1508 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1509 |
this.renderer.minimap.edge_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1510 |
this.minimap_line = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1511 |
this.minimap_line.add([0,0],[0,0]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1512 |
this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1513 |
this.minimap_line.strokeWidth = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1514 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1515 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1516 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1517 |
Rkns.Renderer.Edge.prototype.redraw = function() {
|
| 898 | 1518 |
var from = this.model.get("from"),
|
1519 |
to = this.model.get("to");
|
|
1520 |
if (!from || !to) {
|
|
1521 |
return; |
|
1522 |
} |
|
1523 |
this.from_representation = this.renderer.getRepresentationByModel(from); |
|
1524 |
this.to_representation = this.renderer.getRepresentationByModel(to); |
|
1525 |
if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1526 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1527 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1528 |
var _p0a = this.from_representation.paper_coords, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1529 |
_p1a = this.to_representation.paper_coords, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1530 |
_v = _p1a.subtract(_p0a), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1531 |
_r = _v.length, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1532 |
_u = _v.divide(_r), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1533 |
_ortho = new paper.Point([- _u.y, _u.x]), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1534 |
_group_pos = this.bundle.getPosition(this), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1535 |
_delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1536 |
_p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1537 |
_p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1538 |
_a = _v.angle, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1539 |
_textdelta = _ortho.multiply(this.options.edge_label_distance), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1540 |
_handle = _v.divide(3), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1541 |
_color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1542 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1543 |
if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1544 |
var opacity = .5; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1545 |
this.line.dashArray = [2, 2]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1546 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1547 |
var opacity = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1548 |
this.line.dashArray = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1549 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1550 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1551 |
var old_act_btn = this.active_buttons; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1552 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1553 |
this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1554 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1555 |
if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1556 |
old_act_btn.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1557 |
b.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1558 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1559 |
this.active_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1560 |
b.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1561 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1562 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1563 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1564 |
this.paper_coords = _p0b.add(_p1b).divide(2); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1565 |
this.line.strokeColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1566 |
this.line.opacity = opacity; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1567 |
this.line.segments[0].point = _p0a; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1568 |
this.line.segments[1].point = this.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1569 |
this.line.segments[1].handleIn = _handle.multiply(-1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1570 |
this.line.segments[1].handleOut = _handle; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1571 |
this.line.segments[2].point = _p1a; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1572 |
this.arrow.rotate(_a - this.arrow_angle); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1573 |
this.arrow.fillColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1574 |
this.arrow.opacity = opacity; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1575 |
this.arrow.position = this.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1576 |
this.arrow_angle = _a; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1577 |
if (_a > 90) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1578 |
_a -= 180; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1579 |
_textdelta = _textdelta.multiply(-1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1580 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1581 |
if (_a < -90) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1582 |
_a += 180; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1583 |
_textdelta = _textdelta.multiply(-1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1584 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1585 |
var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || "";
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1586 |
_text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1587 |
this.text.text(_text); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1588 |
var _textpos = this.paper_coords.add(_textdelta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1589 |
this.text.css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1590 |
left: _textpos.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1591 |
top: _textpos.y, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1592 |
transform: "rotate(" + _a + "deg)",
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1593 |
"-moz-transform": "rotate(" + _a + "deg)",
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1594 |
"-webkit-transform": "rotate(" + _a + "deg)",
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1595 |
opacity: opacity |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1596 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1597 |
this.text_angle = _a; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1598 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1599 |
var _pc = this.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1600 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1601 |
b.moveTo(_pc); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1602 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1603 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1604 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1605 |
this.minimap_line.strokeColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1606 |
this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1607 |
this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1608 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1609 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1610 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1611 |
Rkns.Renderer.Edge.prototype.openEditor = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1612 |
this.renderer.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1613 |
var _editor = this.renderer.addRepresentation("EdgeEditor",null);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1614 |
_editor.source_representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1615 |
_editor.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1616 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1617 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1618 |
Rkns.Renderer.Edge.prototype.select = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1619 |
this.selected = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1620 |
this.line.strokeWidth = this.options.selected_edge_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1621 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1622 |
this.active_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1623 |
b.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1624 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1625 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1626 |
if (!this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1627 |
this.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1628 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1629 |
this.super("select");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1630 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1631 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1632 |
Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1633 |
if (!_newTarget || _newTarget.source_representation !== this) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1634 |
this.selected = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1635 |
if (this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1636 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1637 |
b.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1638 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1639 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1640 |
this.line.strokeWidth = this.options.edge_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1641 |
this.super("unselect");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1642 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1643 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1644 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1645 |
Rkns.Renderer.Edge.prototype.mousedown = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1646 |
if (_isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1647 |
this.renderer.unselectAll(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1648 |
this.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1649 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1650 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1651 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1652 |
Rkns.Renderer.Edge.prototype.mouseup = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1653 |
if (!this.renkan.read_only && this.renderer.is_dragging) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1654 |
this.from_representation.saveCoords(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1655 |
this.to_representation.saveCoords(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1656 |
this.from_representation.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1657 |
this.to_representation.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1658 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1659 |
if (!_isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1660 |
this.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1661 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1662 |
this.model.trigger("clicked");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1663 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1664 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1665 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1666 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1667 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1668 |
Rkns.Renderer.Edge.prototype.paperShift = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1669 |
if (this.options.editor_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1670 |
if (!this.options.read_only) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1671 |
this.from_representation.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1672 |
this.to_representation.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1673 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1674 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1675 |
this.renderer.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1676 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1677 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1678 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1679 |
Rkns.Renderer.Edge.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1680 |
this.super("destroy");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1681 |
this.line.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1682 |
this.arrow.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1683 |
this.text.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1684 |
if (this.renderer.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1685 |
this.minimap_line.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1686 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1687 |
this.all_buttons.forEach(function(b) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1688 |
b.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1689 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1690 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1691 |
this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1692 |
return _edge === _this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1693 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1694 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1695 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1696 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1697 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1698 |
Rkns.Renderer.TempEdge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1699 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1700 |
Rkns.Renderer.TempEdge.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1701 |
this.renderer.edge_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1702 |
this.type = "Temp-edge"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1703 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1704 |
var _color = (this.project.get("users").get(this.renkan.current_user) || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1705 |
this.line = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1706 |
this.line.strokeColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1707 |
this.line.dashArray = [4, 2]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1708 |
this.line.strokeWidth = this.options.selected_edge_stroke_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1709 |
this.line.add([0,0],[0,0]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1710 |
this.line.__representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1711 |
this.arrow = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1712 |
this.arrow.fillColor = _color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1713 |
this.arrow.add( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1714 |
[ 0, 0 ], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1715 |
[ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1716 |
[ 0, this.options.edge_arrow_width ] |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1717 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1718 |
this.arrow.__representation = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1719 |
this.arrow_angle = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1720 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1721 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1722 |
Rkns.Renderer.TempEdge.prototype.redraw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1723 |
var _p0 = this.from_representation.paper_coords, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1724 |
_p1 = this.end_pos, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1725 |
_a = _p1.subtract(_p0).angle, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1726 |
_c = _p0.add(_p1).divide(2); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1727 |
this.line.segments[0].point = _p0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1728 |
this.line.segments[1].point = _p1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1729 |
this.arrow.rotate(_a - this.arrow_angle); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1730 |
this.arrow.position = _c; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1731 |
this.arrow_angle = _a; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1732 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1733 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1734 |
Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1735 |
if (!this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1736 |
this.renderer.removeRepresentation(_this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1737 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1738 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1739 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1740 |
this.end_pos = this.end_pos.add(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1741 |
var _hitResult = paper.project.hitTest(this.end_pos); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1742 |
this.renderer.findTarget(_hitResult); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1743 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1744 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1745 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1746 |
Rkns.Renderer.TempEdge.prototype.mouseup = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1747 |
var _hitResult = paper.project.hitTest(_event.point), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1748 |
_model = this.from_representation.model, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1749 |
_endDrag = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1750 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1751 |
var _target = _hitResult.item.__representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1752 |
if (_target.type.substr(0,4) === "Node") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1753 |
var _destmodel = _target.model || _target.source_representation.model; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1754 |
if (_model !== _destmodel) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1755 |
var _data = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1756 |
id: Rkns.Utils.getUID('edge'),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1757 |
created_by: this.renkan.current_user, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1758 |
from: _model, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1759 |
to: _destmodel |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1760 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1761 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1762 |
this.project.addEdge(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1763 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1764 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1765 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1766 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1767 |
if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1768 |
_endDrag = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1769 |
this.renderer.is_dragging = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1770 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1771 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1772 |
if (_endDrag) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1773 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1774 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1775 |
this.renderer.removeRepresentation(this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1776 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1777 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1778 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1779 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1780 |
Rkns.Renderer.TempEdge.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1781 |
this.arrow.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1782 |
this.line.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1783 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1784 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1785 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1786 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1787 |
Rkns.Renderer._BaseEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1788 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1789 |
Rkns.Renderer._BaseEditor.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1790 |
this.renderer.buttons_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1791 |
this.type = "editor"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1792 |
this.editor_block = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1793 |
var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0];});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1794 |
this.editor_block.add.apply(this.editor_block, _pts); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1795 |
this.editor_block.strokeWidth = this.options.tooltip_border_width; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1796 |
this.editor_block.strokeColor = this.options.tooltip_border_color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1797 |
this.editor_block.opacity = .8; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1798 |
this.editor_$ = Rkns.$('<div>')
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1799 |
.appendTo(this.renderer.editor_$) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1800 |
.css({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1801 |
position: "absolute", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1802 |
opacity: .8 |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1803 |
}) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1804 |
.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1805 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1806 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1807 |
Rkns.Renderer._BaseEditor.prototype.destroy = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1808 |
this.editor_block.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1809 |
this.editor_$.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1810 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1811 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1812 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1813 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1814 |
Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1815 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1816 |
Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1817 |
'<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1818 |
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>'
|
| 898 | 1819 |
+ '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>'
|
1820 |
+ '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>'
|
|
1821 |
+ '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>'
|
|
1822 |
+ '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
|
|
1823 |
+ '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
|
|
1824 |
+ '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />'
|
|
1825 |
+ '<% 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><% }%>'
|
|
1826 |
+ '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>'
|
|
1827 |
+ '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>'
|
|
1828 |
+ '<% 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><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1829 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1830 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1831 |
Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( |
| 898 | 1832 |
'<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>'
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1833 |
+ '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>'
|
| 898 | 1834 |
+ '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>'
|
1835 |
+ '<% if (options.show_node_tooltip_description) { %><p><%-node.description%></p><% } %>'
|
|
1836 |
+ '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>'
|
|
1837 |
+ '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1838 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1839 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1840 |
Rkns.Renderer.NodeEditor.prototype.draw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1841 |
var _model = this.source_representation.model, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1842 |
_created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1843 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1844 |
_image_placeholder = this.options.static_url + "img/image-placeholder.png", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1845 |
_size = (_model.get("size") || 0);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1846 |
this.editor_$ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1847 |
.html(_template({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1848 |
node: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1849 |
has_creator: !!_model.get("created_by"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1850 |
title: _model.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1851 |
uri: _model.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1852 |
short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1853 |
description: _model.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1854 |
image: _model.get("image") || "",
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1855 |
image_placeholder: _image_placeholder, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1856 |
color: _model.get("color") || _created_by.get("color"),
|
| 898 | 1857 |
clip_path: _model.get("clip-path") || false,
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1858 |
created_by_color: _created_by.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1859 |
created_by_title: _created_by.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1860 |
size: (_size > 0 ? "+" : "") + _size |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1861 |
}, |
| 898 | 1862 |
renkan: this.renkan, |
1863 |
options: this.options |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1864 |
})); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1865 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1866 |
var _this = this, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1867 |
closeEditor = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1868 |
_this.renderer.removeRepresentation(_this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1869 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1870 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1871 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1872 |
this.editor_$.find(".Rk-CloseX").click(closeEditor);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1873 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1874 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1875 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1876 |
var onFieldChange = Rkns._(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1877 |
Rkns._(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1878 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1879 |
var _data = {
|
| 898 | 1880 |
title: _this.editor_$.find(".Rk-Edit-Title").val()
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1881 |
}; |
| 898 | 1882 |
if (_this.options.show_node_editor_uri) {
|
1883 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
|
|
1884 |
} |
|
1885 |
if (_this.options.show_node_editor_image) {
|
|
1886 |
_data.image = _this.editor_$.find(".Rk-Edit-Image").val();
|
|
1887 |
_this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
|
|
1888 |
} |
|
1889 |
if (_this.options.show_node_editor_description) {
|
|
1890 |
_data.description = _this.editor_$.find(".Rk-Edit-Description").val();
|
|
1891 |
} |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1892 |
_model.set(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1893 |
_this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1894 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1895 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1896 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1897 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1898 |
}).defer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1899 |
}).throttle(500); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1900 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1901 |
this.editor_$.on("keyup", function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1902 |
if (_e.keyCode === 27) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1903 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1904 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1905 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1906 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1907 |
this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1908 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1909 |
this.editor_$.find(".Rk-Edit-Image-File").change(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1910 |
if (this.files.length) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1911 |
var f = this.files[0], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1912 |
fr = new FileReader(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1913 |
if (f.type.substr(0,5) !== "image") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1914 |
alert(_this.renkan.translate("This file is not an image"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1915 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1916 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1917 |
if (f.size > (Rkns.Renderer._IMAGE_MAX_KB * 1024)) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1918 |
alert(_this.renkan.translate("Image size must be under ")+Rkns.Renderer._IMAGE_MAX_KB+_this.renkan.translate("KB"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1919 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1920 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1921 |
fr.onload = function(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1922 |
_this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1923 |
onFieldChange(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1924 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1925 |
fr.readAsDataURL(f); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1926 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1927 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1928 |
this.editor_$.find(".Rk-Edit-Title")[0].focus();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1929 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1930 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1931 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1932 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1933 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1934 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1935 |
_picker.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1936 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1937 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1938 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1939 |
_picker.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1940 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1941 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1942 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1943 |
_picker.find("li").hover(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1944 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1945 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1946 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1947 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1948 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1949 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1950 |
_this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1951 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1952 |
).click(function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1953 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1954 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1955 |
_model.set("color", $(this).attr("data-color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1956 |
_picker.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1957 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1958 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1959 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1960 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1961 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1962 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1963 |
function shiftSize(n) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1964 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1965 |
var _newsize = n+(_model.get("size") || 0);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1966 |
_this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1967 |
_model.set("size", _newsize);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1968 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1969 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1970 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1971 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1972 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1973 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1974 |
this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1975 |
shiftSize(-1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1976 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1977 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1978 |
this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1979 |
shiftSize(1); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1980 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1981 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1982 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1983 |
this.editor_$.find("img").load(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1984 |
_this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1985 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1986 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1987 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1988 |
Rkns.Renderer.NodeEditor.prototype.redraw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1989 |
var _coords = this.source_representation.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1990 |
Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1991 |
this.editor_$.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1992 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1993 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1994 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1995 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1996 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1997 |
Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1998 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
1999 |
Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2000 |
'<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2001 |
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>'
|
| 898 | 2002 |
+ '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>'
|
2003 |
+ '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">'
|
|
2004 |
+ '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>'
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2005 |
+ '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2006 |
+ '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>'
|
| 898 | 2007 |
+ '<% }) %><% }) %></select></p><% } } %>' |
2008 |
+ '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
|
|
2009 |
+ '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
|
|
2010 |
+ '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>'
|
|
2011 |
+ '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
|
|
2012 |
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p><% } %>'
|
|
2013 |
+ '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2014 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2015 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2016 |
Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template( |
| 898 | 2017 |
'<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>'
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2018 |
+ '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>'
|
| 898 | 2019 |
+ '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>'
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2020 |
+ '<p><%-edge.description%></p>' |
| 898 | 2021 |
+ '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
|
2022 |
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p><% } %>'
|
|
2023 |
+ '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2024 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2025 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2026 |
Rkns.Renderer.EdgeEditor.prototype.draw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2027 |
var _model = this.source_representation.model, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2028 |
_from_model = _model.get("from"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2029 |
_to_model = _model.get("to"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2030 |
_created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2031 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2032 |
this.editor_$ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2033 |
.html(_template({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2034 |
edge: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2035 |
has_creator: !!_model.get("created_by"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2036 |
title: _model.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2037 |
uri: _model.get("uri"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2038 |
short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2039 |
description: _model.get("description"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2040 |
color: _model.get("color") || _created_by.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2041 |
from_title: _from_model.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2042 |
to_title: _to_model.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2043 |
from_color: _from_model.get("color") || (_from_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2044 |
to_color: _to_model.get("color") || (_to_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2045 |
created_by_color: _created_by.get("color"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2046 |
created_by_title: _created_by.get("title")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2047 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2048 |
renkan: this.renkan, |
| 898 | 2049 |
options: this.options, |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2050 |
})); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2051 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2052 |
var _this = this, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2053 |
closeEditor = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2054 |
_this.renderer.removeRepresentation(_this); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2055 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2056 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2057 |
this.editor_$.find(".Rk-CloseX").click(closeEditor);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2058 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2059 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2060 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2061 |
var onFieldChange = Rkns._(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2062 |
Rkns._(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2063 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2064 |
var _data = {
|
| 898 | 2065 |
title: _this.editor_$.find(".Rk-Edit-Title").val()
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2066 |
}; |
| 898 | 2067 |
if (_this.options.show_edge_editor_uri) {
|
2068 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
|
|
2069 |
} |
|
2070 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri);
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2071 |
_model.set(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2072 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2073 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2074 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2075 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2076 |
}).defer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2077 |
}).throttle(500); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2078 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2079 |
this.editor_$.on("keyup", function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2080 |
if (_e.keyCode === 27) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2081 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2082 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2083 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2084 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2085 |
this.editor_$.find("input").on("keyup change paste", onFieldChange);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2086 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2087 |
this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2088 |
var e = $(this), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2089 |
v = e.val(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2090 |
if (v) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2091 |
_this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text());
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2092 |
_this.editor_$.find(".Rk-Edit-URI").val(v);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2093 |
onFieldChange(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2094 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2095 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2096 |
this.editor_$.find(".Rk-Edit-Direction").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2097 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2098 |
_model.set({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2099 |
from: _model.get("to"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2100 |
to: _model.get("from")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2101 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2102 |
_this.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2103 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2104 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2105 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2106 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2107 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2108 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2109 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2110 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2111 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2112 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2113 |
_picker.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2114 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2115 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2116 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2117 |
_picker.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2118 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2119 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2120 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2121 |
_picker.find("li").hover(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2122 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2123 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2124 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2125 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2126 |
function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2127 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2128 |
_this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2129 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2130 |
).click(function(_e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2131 |
_e.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2132 |
if (_this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2133 |
_model.set("color", $(this).attr("data-color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2134 |
_picker.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2135 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2136 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2137 |
closeEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2138 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2139 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2140 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2141 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2142 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2143 |
Rkns.Renderer.EdgeEditor.prototype.redraw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2144 |
var _coords = this.source_representation.paper_coords; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2145 |
Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2146 |
this.editor_$.show(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2147 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2148 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2149 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2150 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2151 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2152 |
Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2153 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2154 |
Rkns.Renderer._NodeButton.prototype.setSectorSize = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2155 |
var sectorInner = this.source_representation.circle_radius; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2156 |
if (sectorInner !== this.lastSectorInner) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2157 |
if (this.sector) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2158 |
this.sector.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2159 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2160 |
this.sector = this.renderer.drawSector( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2161 |
this, 1 + sectorInner, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2162 |
Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2163 |
this.startAngle, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2164 |
this.endAngle, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2165 |
1, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2166 |
this.imageName, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2167 |
this.renkan.translate(this.text) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2168 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2169 |
this.lastSectorInner = sectorInner; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2170 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2171 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2172 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2173 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2174 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2175 |
Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2176 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2177 |
Rkns.Renderer.NodeEditButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2178 |
this.type = "Node-edit-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2179 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2180 |
this.startAngle = -135; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2181 |
this.endAngle = -45; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2182 |
this.imageName = "edit"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2183 |
this.text = "Edit"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2184 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2185 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2186 |
Rkns.Renderer.NodeEditButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2187 |
if (!this.renderer.is_dragging) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2188 |
this.source_representation.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2189 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2190 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2191 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2192 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2193 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2194 |
Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2195 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2196 |
Rkns.Renderer.NodeRemoveButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2197 |
this.type = "Node-remove-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2198 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2199 |
this.startAngle = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2200 |
this.endAngle = 90; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2201 |
this.imageName = "remove"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2202 |
this.text = "Remove"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2203 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2204 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2205 |
Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2206 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2207 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2208 |
this.renderer.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2209 |
if (this.renderer.isEditable()) {
|
| 898 | 2210 |
if (this.options.element_delete_delay) {
|
2211 |
var delid = Rkns.Utils.getUID("delete");
|
|
2212 |
this.renderer.delete_list.push({
|
|
2213 |
id: delid, |
|
2214 |
time: new Date().valueOf() + this.options.element_delete_delay |
|
2215 |
}); |
|
2216 |
this.source_representation.model.set("delete_scheduled", delid);
|
|
2217 |
} else {
|
|
2218 |
if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
|
|
2219 |
this.project.removeNode(this.source_representation.model); |
|
2220 |
} |
|
2221 |
} |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2222 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2223 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2224 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2225 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2226 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2227 |
Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2228 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2229 |
Rkns.Renderer.NodeRevertButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2230 |
this.type = "Node-revert-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2231 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2232 |
this.startAngle = -135; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2233 |
this.endAngle = 135; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2234 |
this.imageName = "revert"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2235 |
this.text = "Cancel deletion"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2236 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2237 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2238 |
Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2239 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2240 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2241 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2242 |
this.source_representation.model.unset("delete_scheduled");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2243 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2244 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2245 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2246 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2247 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2248 |
Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2249 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2250 |
Rkns.Renderer.NodeLinkButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2251 |
this.type = "Node-link-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2252 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2253 |
this.startAngle = 90; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2254 |
this.endAngle = 180; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2255 |
this.imageName = "link"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2256 |
this.text = "Link to another node"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2257 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2258 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2259 |
Rkns.Renderer.NodeLinkButton.prototype.mousedown = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2260 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2261 |
var _off = this.renderer.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2262 |
_point = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2263 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2264 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2265 |
]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2266 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2267 |
this.renderer.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2268 |
this.renderer.addTempEdge(this.source_representation, _point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2269 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2270 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2271 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2272 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2273 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2274 |
Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2275 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2276 |
Rkns.Renderer.NodeEnlargeButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2277 |
this.type = "Node-enlarge-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2278 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2279 |
this.startAngle = -45; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2280 |
this.endAngle = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2281 |
this.imageName = "enlarge"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2282 |
this.text = "Enlarge"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2283 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2284 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2285 |
Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2286 |
var _newsize = 1 + (this.source_representation.model.get("size") || 0);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2287 |
this.source_representation.model.set("size", _newsize);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2288 |
this.source_representation.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2289 |
this.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2290 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2291 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2292 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2293 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2294 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2295 |
Rkns.Renderer.NodeShrinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2296 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2297 |
Rkns.Renderer.NodeShrinkButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2298 |
this.type = "Node-shrink-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2299 |
this.lastSectorInner = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2300 |
this.startAngle = -180; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2301 |
this.endAngle = -135; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2302 |
this.imageName = "shrink"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2303 |
this.text = "Shrink"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2304 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2305 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2306 |
Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2307 |
var _newsize = -1 + (this.source_representation.model.get("size") || 0);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2308 |
this.source_representation.model.set("size", _newsize);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2309 |
this.source_representation.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2310 |
this.select(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2311 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2312 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2313 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2314 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2315 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2316 |
Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2317 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2318 |
Rkns.Renderer.EdgeEditButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2319 |
this.type = "Edge-edit-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2320 |
this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2321 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2322 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2323 |
Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2324 |
if (!this.renderer.is_dragging) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2325 |
this.source_representation.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2326 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2327 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2328 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2329 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2330 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2331 |
Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2332 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2333 |
Rkns.Renderer.EdgeRemoveButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2334 |
this.type = "Edge-remove-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2335 |
this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2336 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2337 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2338 |
Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2339 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2340 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2341 |
this.renderer.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2342 |
if (this.renderer.isEditable()) {
|
| 898 | 2343 |
if (this.options.element_delete_delay) {
|
2344 |
var delid = Rkns.Utils.getUID("delete");
|
|
2345 |
this.renderer.delete_list.push({
|
|
2346 |
id: delid, |
|
2347 |
time: new Date().valueOf() + this.options.element_delete_delay |
|
2348 |
}); |
|
2349 |
this.source_representation.model.set("delete_scheduled", delid);
|
|
2350 |
} else {
|
|
2351 |
if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
|
|
2352 |
this.project.removeEdge(this.source_representation.model); |
|
2353 |
} |
|
2354 |
} |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2355 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2356 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2357 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2358 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2359 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2360 |
Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2361 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2362 |
Rkns.Renderer.EdgeRevertButton.prototype._init = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2363 |
this.type = "Edge-revert-button"; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2364 |
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"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2365 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2366 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2367 |
Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2368 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2369 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2370 |
if (this.renderer.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2371 |
this.source_representation.model.unset("delete_scheduled");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2372 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2373 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2374 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2375 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2376 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2377 |
Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2378 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2379 |
Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2380 |
this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2381 |
this.renderer.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2382 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2383 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2384 |
Rkns.Renderer.MiniFrame.prototype.mouseup = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2385 |
this.renderer.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2386 |
this.renderer.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2387 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2388 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2389 |
/* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2390 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2391 |
Rkns.Renderer.Scene = function(_renkan) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2392 |
this.renkan = _renkan; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2393 |
this.$ = Rkns.$(".Rk-Render");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2394 |
this.representations = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2395 |
this.$.html(this.template(_renkan)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2396 |
this.onStatusChange(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2397 |
this.canvas_$ = this.$.find(".Rk-Canvas");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2398 |
this.labels_$ = this.$.find(".Rk-Labels");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2399 |
this.editor_$ = this.$.find(".Rk-Editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2400 |
this.notif_$ = this.$.find(".Rk-Notifications");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2401 |
paper.setup(this.canvas_$[0]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2402 |
this.scale = 1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2403 |
this.offset = paper.view.center; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2404 |
this.totalScroll = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2405 |
this.mouse_down = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2406 |
this.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2407 |
this.selected_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2408 |
this.edge_layer = new paper.Layer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2409 |
this.node_layer = new paper.Layer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2410 |
this.buttons_layer = new paper.Layer(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2411 |
this.delete_list = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2412 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2413 |
if (_renkan.options.show_minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2414 |
this.minimap = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2415 |
background_layer: new paper.Layer(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2416 |
edge_layer: new paper.Layer(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2417 |
node_layer: new paper.Layer(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2418 |
node_group: new paper.Group(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2419 |
size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height ) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2420 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2421 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2422 |
this.minimap.background_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2423 |
this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2424 |
this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4])); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2425 |
this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2426 |
this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2427 |
this.minimap.rectangle.strokeWidth = 4; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2428 |
this.minimap.offset = new paper.Point(this.minimap.size.divide(2)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2429 |
this.minimap.scale = .1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2430 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2431 |
this.minimap.node_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2432 |
this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2433 |
this.minimap.node_group.addChild(this.minimap.cliprectangle); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2434 |
this.minimap.node_group.clipped = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2435 |
this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2436 |
this.minimap.node_group.addChild(this.minimap.miniframe); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2437 |
this.minimap.miniframe.fillColor = '#c0c0ff'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2438 |
this.minimap.miniframe.opacity = .3; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2439 |
this.minimap.miniframe.strokeColor = '#000080'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2440 |
this.minimap.miniframe.strokeWidth = 3; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2441 |
this.minimap.miniframe.__representation = new Rkns.Renderer.MiniFrame(this, null); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2442 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2443 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2444 |
this.throttledPaperDraw = Rkns._(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2445 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2446 |
}).throttle(100); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2447 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2448 |
this.bundles = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2449 |
this.click_mode = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2450 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2451 |
var _this = this, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2452 |
_allowScroll = true, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2453 |
_originalScale, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2454 |
_zooming = false, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2455 |
_lastTapDate, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2456 |
_lastTapX, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2457 |
_lastTapY; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2458 |
|
| 898 | 2459 |
this.image_cache = {};
|
2460 |
this.icon_cache = {};
|
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2461 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2462 |
['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2463 |
var img = new Image(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2464 |
img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; |
| 898 | 2465 |
_this.icon_cache[imgname] = img; |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2466 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2467 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2468 |
var throttledMouseMove = _.throttle(function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2469 |
_this.onMouseMove(_event, _isTouch); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2470 |
}, Rkns.Renderer._MOUSEMOVE_RATE); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2471 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2472 |
this.canvas_$.on({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2473 |
mousedown: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2474 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2475 |
_this.onMouseDown(_event, false); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2476 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2477 |
mousemove: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2478 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2479 |
throttledMouseMove(_event, false); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2480 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2481 |
mouseup: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2482 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2483 |
_this.onMouseUp(_event, false); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2484 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2485 |
mousewheel: function(_event, _delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2486 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2487 |
if (_allowScroll) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2488 |
_this.onScroll(_event, _delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2489 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2490 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2491 |
touchstart: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2492 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2493 |
var _touches = _event.originalEvent.touches[0]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2494 |
if ( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2495 |
_renkan.options.allow_double_click |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2496 |
&& new Date() - _lastTap < Rkns.Renderer._DOUBLETAP_DELAY |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2497 |
&& ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Rkns.Renderer._DOUBLETAP_DISTANCE ) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2498 |
) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2499 |
_lastTap = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2500 |
_this.onDoubleClick(_touches); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2501 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2502 |
_lastTap = new Date(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2503 |
_lastTapX = _touches.pageX; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2504 |
_lastTapY = _touches.pageY; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2505 |
_originalScale = _this.scale; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2506 |
_zooming = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2507 |
_this.onMouseDown(_touches, true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2508 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2509 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2510 |
touchmove: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2511 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2512 |
_lastTap = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2513 |
if (_event.originalEvent.touches.length == 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2514 |
_this.onMouseMove(_event.originalEvent.touches[0], true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2515 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2516 |
if (!_zooming) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2517 |
_this.onMouseUp(_event.originalEvent.touches[0], true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2518 |
_this.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2519 |
_this.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2520 |
_zooming = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2521 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2522 |
if (_event.originalEvent.scale === "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2523 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2524 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2525 |
var _newScale = _event.originalEvent.scale * _originalScale, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2526 |
_scaleRatio = _newScale / _this.scale, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2527 |
_newOffset = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2528 |
_this.canvas_$.width(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2529 |
_this.canvas_$.height() |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2530 |
]).multiply( .5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio )); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2531 |
_this.setScale(_newScale, _this.offset); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2532 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2533 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2534 |
touchend: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2535 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2536 |
_this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2537 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2538 |
dblclick: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2539 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2540 |
if (_renkan.options.allow_double_click) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2541 |
_this.onDoubleClick(_event); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2542 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2543 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2544 |
mouseleave: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2545 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2546 |
_this.onMouseUp(_event, false); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2547 |
_this.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2548 |
_this.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2549 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2550 |
dragover: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2551 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2552 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2553 |
dragenter: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2554 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2555 |
_allowScroll = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2556 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2557 |
dragleave: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2558 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2559 |
_allowScroll = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2560 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2561 |
drop: function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2562 |
_event.preventDefault(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2563 |
_allowScroll = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2564 |
var res = {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2565 |
Rkns._(_event.originalEvent.dataTransfer.types).each(function(t) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2566 |
try {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2567 |
res[t] = _event.originalEvent.dataTransfer.getData(t); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2568 |
} catch(e) {}
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2569 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2570 |
var text = _event.originalEvent.dataTransfer.getData("Text");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2571 |
if (typeof text === "string") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2572 |
switch(text[0]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2573 |
case "{":
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2574 |
case "[": |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2575 |
try {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2576 |
var data = JSON.parse(text); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2577 |
_(res).extend(data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2578 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2579 |
catch(e) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2580 |
if (!res["text/plain"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2581 |
res["text/plain"] = text; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2582 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2583 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2584 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2585 |
case "<": |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2586 |
if (!res["text/html"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2587 |
res["text/html"] = text; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2588 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2589 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2590 |
default: |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2591 |
if (!res["text/plain"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2592 |
res["text/plain"] = text; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2593 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2594 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2595 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2596 |
var url = _event.originalEvent.dataTransfer.getData("URL");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2597 |
if (url && !res["text/uri-list"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2598 |
res["text/uri-list"] = url; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2599 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2600 |
_this.dropData(res, _event.originalEvent); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2601 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2602 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2603 |
this.editor_$.find(".Rk-ZoomOut").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2604 |
var _newScale = _this.scale * Math.SQRT1_2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2605 |
_offset = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2606 |
_this.canvas_$.width(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2607 |
_this.canvas_$.height() |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2608 |
]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(_this.offset.multiply( Math.SQRT1_2 )); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2609 |
_this.setScale( _newScale, _offset ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2610 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2611 |
this.editor_$.find(".Rk-ZoomIn").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2612 |
var _newScale = _this.scale * Math.SQRT2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2613 |
_offset = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2614 |
_this.canvas_$.width(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2615 |
_this.canvas_$.height() |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2616 |
]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 )); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2617 |
_this.setScale( _newScale, _offset ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2618 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2619 |
this.$.find(".Rk-CurrentUser").mouseenter(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2620 |
function() { _this.$.find(".Rk-UserList").slideDown(); }
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2621 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2622 |
this.$.find(".Rk-Users").mouseleave(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2623 |
function() { _this.$.find(".Rk-UserList").slideUp(); }
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2624 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2625 |
this.$.find(".Rk-FullScreen-Button").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2626 |
var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2627 |
_el = _this.renkan.$[0], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2628 |
_requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2629 |
_cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2630 |
if (_isFull) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2631 |
for (var i = 0; i < _cancelMethods.length; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2632 |
if (typeof document[_cancelMethods[i]] === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2633 |
document[_cancelMethods[i]](); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2634 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2635 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2636 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2637 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2638 |
for (var i = 0; i < _requestMethods.length; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2639 |
if (typeof _el[_requestMethods[i]] === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2640 |
_el[_requestMethods[i]](); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2641 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2642 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2643 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2644 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2645 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2646 |
this.$.find(".Rk-AddNode-Button").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2647 |
if (_this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2648 |
_this.click_mode = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2649 |
_this.notif_$.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2650 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2651 |
_this.click_mode = Rkns.Renderer._CLICKMODE_ADDNODE; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2652 |
_this.notif_$.text(_renkan.translate("Click on the background canvas to add a node")).fadeIn();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2653 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2654 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2655 |
this.$.find(".Rk-AddEdge-Button").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2656 |
if (_this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE || _this.click_mode === Rkns.Renderer._CLICKMODE_ENDEDGE) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2657 |
_this.click_mode = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2658 |
_this.notif_$.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2659 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2660 |
_this.click_mode = Rkns.Renderer._CLICKMODE_STARTEDGE; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2661 |
_this.notif_$.text(_renkan.translate("Click on a first node to start the edge")).fadeIn();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2662 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2663 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2664 |
this.$.find(".Rk-Bookmarklet-Button")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2665 |
.attr("href","javascript:" + Rkns.Renderer._BOOKMARKLET_CODE(_renkan))
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2666 |
.click(function(){
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2667 |
_this.notif_$ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2668 |
.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."))
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2669 |
.fadeIn() |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2670 |
.delay(5000) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2671 |
.fadeOut(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2672 |
return false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2673 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2674 |
this.$.find(".Rk-TopBar-Button").mouseover(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2675 |
Rkns.$(this).find(".Rk-TopBar-Tooltip").show();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2676 |
}).mouseout(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2677 |
Rkns.$(this).find(".Rk-TopBar-Tooltip").hide();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2678 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2679 |
this.$.find(".Rk-Fold-Bins").click(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2680 |
var bins = _renkan.$.find(".Rk-Bins");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2681 |
if (bins.offset().left < 0) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2682 |
bins.animate({left: 0},250);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2683 |
_this.$.animate({left: 300},250,function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2684 |
var w = _this.$.width(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2685 |
paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2686 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2687 |
$(this).html("«");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2688 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2689 |
bins.animate({left: -300},250);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2690 |
_this.$.animate({left: 0},250,function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2691 |
var w = _this.$.width(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2692 |
paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2693 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2694 |
$(this).html("»");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2695 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2696 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2697 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2698 |
paper.view.onResize = function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2699 |
_this.offset = _this.offset.add(_event.delta.divide(2)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2700 |
if (_this.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2701 |
_this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2702 |
_this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4])); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2703 |
_this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2704 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2705 |
_this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2706 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2707 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2708 |
var _thRedraw = Rkns._.throttle(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2709 |
_this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2710 |
},50); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2711 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2712 |
this.addRepresentations("Node", this.renkan.project.get("nodes"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2713 |
this.addRepresentations("Edge", this.renkan.project.get("edges"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2714 |
this.renkan.project.on("change:title", function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2715 |
_this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2716 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2717 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2718 |
this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2719 |
_renkan.project.set({"title": $(this).val()});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2720 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2721 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2722 |
this.renkan.project.get("users").each(function(_user) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2723 |
_this.addUser(_user); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2724 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2725 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2726 |
this.renkan.project.on("add:users", function(_user) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2727 |
_this.addUser(_user); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2728 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2729 |
this.renkan.project.on("add:nodes", function(_node) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2730 |
_this.addRepresentation("Node", _node);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2731 |
_thRedraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2732 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2733 |
this.renkan.project.on("add:edges", function(_edge) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2734 |
_this.addRepresentation("Edge", _edge);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2735 |
_thRedraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2736 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2737 |
this.renkan.project.on("change:title", function(_model, _title) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2738 |
var el = _this.$.find(".Rk-PadTitle");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2739 |
if (el.is("input")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2740 |
if (el.val() !== _title) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2741 |
el.val(_title); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2742 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2743 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2744 |
el.text(_title); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2745 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2746 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2747 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2748 |
if (_renkan.options.size_bug_fix) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2749 |
var _delay = ( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2750 |
typeof _renkan.options.size_bug_fix === "number" |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2751 |
? _renkan.options.size_bug_fix |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2752 |
: 500 |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2753 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2754 |
window.setTimeout( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2755 |
function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2756 |
_this.fixSize(true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2757 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2758 |
_delay |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2759 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2760 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2761 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2762 |
if (_renkan.options.force_resize) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2763 |
$(window).resize(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2764 |
_this.fixSize(false); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2765 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2766 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2767 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2768 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2769 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2770 |
window.setInterval(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2771 |
var _now = new Date().valueOf(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2772 |
_this.delete_list.forEach(function(d) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2773 |
if (_now >= d.time) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2774 |
var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2775 |
if (el) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2776 |
project.removeNode(el); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2777 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2778 |
el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2779 |
if (el) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2780 |
project.removeEdge(el); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2781 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2782 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2783 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2784 |
_this.delete_list = _this.delete_list.filter(function(d) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2785 |
return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2786 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2787 |
}, 500); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2788 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2789 |
if (this.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2790 |
window.setInterval(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2791 |
_this.rescaleMinimap(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2792 |
}, 2000); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2793 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2794 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2795 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2796 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2797 |
Rkns.Renderer.Scene.prototype.template = Rkns._.template( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2798 |
'<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2799 |
+ '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2800 |
+ '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2801 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2802 |
+ '<% if (options.editor_mode) { %>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2803 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2804 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2805 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2806 |
+ '<div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents">' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2807 |
+ '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2808 |
+ '<div class="Rk-TopBar-Separator"></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2809 |
+ '<% } %></div><% } %>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2810 |
+ '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2811 |
+ '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Editor"><div class="Rk-Notifications"></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2812 |
+ '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2813 |
+ '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div></div>'
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2814 |
+ '</div></div>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2815 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2816 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2817 |
Rkns.Renderer.Scene.prototype.fixSize = function(_autoscale) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2818 |
var w = this.$.width(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2819 |
h = this.$.height(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2820 |
if (this.renkan.options.show_top_bar) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2821 |
h -= this.$.find(".Rk-TopBar").height();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2822 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2823 |
this.canvas_$.attr({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2824 |
width: w, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2825 |
height: h |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2826 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2827 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2828 |
paper.view.viewSize = new paper.Size([w, h]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2829 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2830 |
if (_autoscale) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2831 |
this.autoScale(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2832 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2833 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2834 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2835 |
Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2836 |
var _options = this.renkan.options, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2837 |
_startRads = _startAngle * Math.PI / 180, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2838 |
_endRads = _endAngle * Math.PI / 180, |
| 898 | 2839 |
_img = this.icon_cache[_imgname], |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2840 |
_span = _endRads - _startRads, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2841 |
_startdx = - Math.sin(_startRads), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2842 |
_startdy = Math.cos(_startRads), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2843 |
_startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2844 |
_startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2845 |
_startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2846 |
_startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2847 |
_enddx = - Math.sin(_endRads), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2848 |
_enddy = Math.cos(_endRads), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2849 |
_endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2850 |
_endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2851 |
_endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2852 |
_endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2853 |
_centerR = (_inR + _outR)/2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2854 |
_centerRads = (_startRads + _endRads) / 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2855 |
_centerX = Math.cos(_centerRads) * _centerR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2856 |
_centerY = Math.sin(_centerRads) * _centerR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2857 |
_centerXIn = Math.cos(_centerRads) * _inR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2858 |
_centerXOut = Math.cos(_centerRads) * _outR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2859 |
_centerYIn = Math.sin(_centerRads) * _inR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2860 |
_centerYOut = Math.sin(_centerRads) * _outR, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2861 |
_textX = Math.cos(_centerRads) * (_outR + 3), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2862 |
_textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2863 |
_segments = []; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2864 |
this.buttons_layer.activate(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2865 |
var _path = new paper.Path(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2866 |
_path.add([_startXIn, _startYIn]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2867 |
_path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2868 |
_path.lineTo([_endXOut, _endYOut]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2869 |
_path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2870 |
_path.fillColor = _options.buttons_background; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2871 |
_path.opacity = .5; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2872 |
_path.closed = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2873 |
_path.__representation = _repr; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2874 |
var _text = new paper.PointText(_textX,_textY); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2875 |
_text.characterStyle = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2876 |
fontSize: _options.buttons_label_font_size, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2877 |
fillColor: _options.buttons_label_color |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2878 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2879 |
if (_textX > 2) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2880 |
_text.paragraphStyle.justification = 'left'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2881 |
} else if (_textX < -2) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2882 |
_text.paragraphStyle.justification = 'right'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2883 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2884 |
_text.paragraphStyle.justification = 'center'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2885 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2886 |
_text.visible = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2887 |
var _visible = false, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2888 |
_restPos = new paper.Point(-200, -200), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2889 |
_grp = new paper.Group([_path, _text]), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2890 |
_delta = _grp.position, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2891 |
_imgdelta = new paper.Point([_centerX, _centerY]), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2892 |
_currentPos = new paper.Point(0,0); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2893 |
_text.content = _caption; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2894 |
_grp.visible = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2895 |
_grp.position = _restPos; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2896 |
var _res = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2897 |
show: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2898 |
_visible = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2899 |
_grp.position = _currentPos.add(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2900 |
_grp.visible = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2901 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2902 |
moveTo: function(_point) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2903 |
_currentPos = _point; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2904 |
if (_visible) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2905 |
_grp.position = _point.add(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2906 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2907 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2908 |
hide: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2909 |
_visible = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2910 |
_grp.visible = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2911 |
_grp.position = _restPos; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2912 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2913 |
select: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2914 |
_path.opacity = .8; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2915 |
_text.visible = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2916 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2917 |
unselect: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2918 |
_path.opacity = .5; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2919 |
_text.visible = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2920 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2921 |
destroy: function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2922 |
_grp.remove(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2923 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2924 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2925 |
function showImage() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2926 |
var _raster = new paper.Raster(_img); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2927 |
_raster.position = _imgdelta.add(_grp.position).subtract(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2928 |
_grp.addChild(_raster); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2929 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2930 |
if (_img.width) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2931 |
showImage(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2932 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2933 |
Rkns.$(_img).on("load",showImage);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2934 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2935 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2936 |
return _res; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2937 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2938 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2939 |
Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2940 |
var _bundle = Rkns._(this.bundles).find(function(_bundle) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2941 |
return ( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2942 |
( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2943 |
|| ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation ) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2944 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2945 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2946 |
if (typeof _bundle !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2947 |
_bundle.edges.push(_edgeRepr); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2948 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2949 |
_bundle = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2950 |
from: _edgeRepr.from_representation, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2951 |
to: _edgeRepr.to_representation, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2952 |
edges: [ _edgeRepr ], |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2953 |
getPosition: function(_er) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2954 |
var _dir = (_er.from_representation === this.from) ? 1 : -1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2955 |
return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2956 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2957 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2958 |
this.bundles.push(_bundle); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2959 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2960 |
return _bundle; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2961 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2962 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2963 |
Rkns.Renderer.Scene.prototype.isEditable = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2964 |
return (this.renkan.options.editor_mode && !this.renkan.read_only); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2965 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2966 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2967 |
Rkns.Renderer.Scene.prototype.onStatusChange = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2968 |
var savebtn = this.$.find(".Rk-Save-Button"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2969 |
tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2970 |
if (this.renkan.read_only) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2971 |
savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2972 |
tip.text(this.renkan.translate("Connection lost"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2973 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2974 |
if (this.renkan.options.snapshot_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2975 |
savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2976 |
tip.text(this.renkan.translate("Archive Project"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2977 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2978 |
savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2979 |
tip.text(this.renkan.translate("Auto-save enabled"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2980 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2981 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2982 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2983 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2984 |
Rkns.Renderer.Scene.prototype.setScale = function(_newScale, _offset) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2985 |
if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2986 |
this.scale = _newScale; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2987 |
if (_offset) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2988 |
this.offset = _offset; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2989 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2990 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2991 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2992 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2993 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2994 |
Rkns.Renderer.Scene.prototype.autoScale = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2995 |
var nodes = this.renkan.project.get("nodes");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2996 |
if (nodes.length > 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2997 |
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2998 |
_yy = nodes.map(function(_node) { return _node.get("position").y; }),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
2999 |
_minx = Math.min.apply(Math, _xx), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3000 |
_miny = Math.min.apply(Math, _yy), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3001 |
_maxx = Math.max.apply(Math, _xx), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3002 |
_maxy = Math.max.apply(Math, _yy); |
| 898 | 3003 |
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))); |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3004 |
this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3005 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3006 |
if (nodes.length === 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3007 |
this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3008 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3009 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3010 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3011 |
Rkns.Renderer.Scene.prototype.redrawMiniframe = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3012 |
var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3013 |
bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3014 |
this.minimap.miniframe.fitBounds(topleft, bottomright); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3015 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3016 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3017 |
Rkns.Renderer.Scene.prototype.rescaleMinimap = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3018 |
var nodes = this.renkan.project.get("nodes");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3019 |
if (nodes.length > 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3020 |
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3021 |
_yy = nodes.map(function(_node) { return _node.get("position").y; }),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3022 |
_minx = Math.min.apply(Math, _xx), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3023 |
_miny = Math.min.apply(Math, _yy), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3024 |
_maxx = Math.max.apply(Math, _xx), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3025 |
_maxy = Math.max.apply(Math, _yy); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3026 |
var _scale = Math.min( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3027 |
this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3028 |
this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height, |
| 898 | 3029 |
( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx), |
3030 |
( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny) |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3031 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3032 |
this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3033 |
this.minimap.scale = _scale; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3034 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3035 |
if (nodes.length === 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3036 |
this.minimap.scale = .1; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3037 |
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));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3038 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3039 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3040 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3041 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3042 |
Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3043 |
return _point.multiply(this.scale).add(this.offset); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3044 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3045 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3046 |
Rkns.Renderer.Scene.prototype.toMinimapCoords = function(_point) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3047 |
return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3048 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3049 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3050 |
Rkns.Renderer.Scene.prototype.toModelCoords = function(_point) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3051 |
return _point.subtract(this.offset).divide(this.scale); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3052 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3053 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3054 |
Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3055 |
var _repr = new Rkns.Renderer[_type](this, _model); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3056 |
this.representations.push(_repr); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3057 |
return _repr; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3058 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3059 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3060 |
Rkns.Renderer.Scene.prototype.addRepresentations = function(_type, _collection) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3061 |
var _this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3062 |
_collection.forEach(function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3063 |
_this.addRepresentation(_type, _model); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3064 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3065 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3066 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3067 |
Rkns.Renderer.Scene.prototype.userTemplate = Rkns._.template( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3068 |
'<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>' |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3069 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3070 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3071 |
Rkns.Renderer.Scene.prototype.addUser = function(_user) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3072 |
if (_user.get("_id") === this.renkan.current_user) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3073 |
this.$.find(".Rk-CurrentUser-Name").text(_user.get("title"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3074 |
this.$.find(".Rk-CurrentUser-Color").css("background", _user.get("color"));
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3075 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3076 |
this.$.find(".Rk-UserList").append(
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3077 |
Rkns.$( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3078 |
this.userTemplate({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3079 |
name: _user.get("title"),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3080 |
background: _user.get("color")
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3081 |
}) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3082 |
) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3083 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3084 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3085 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3086 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3087 |
Rkns.Renderer.Scene.prototype.removeRepresentation = function(_representation) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3088 |
_representation.destroy(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3089 |
this.representations = Rkns._(this.representations).reject( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3090 |
function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3091 |
return _repr == _representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3092 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3093 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3094 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3095 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3096 |
Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) {
|
| 898 | 3097 |
if (!_model) {
|
3098 |
return undefined; |
|
3099 |
} |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3100 |
return Rkns._(this.representations).find(function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3101 |
return _repr.model === _model; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3102 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3103 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3104 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3105 |
Rkns.Renderer.Scene.prototype.removeRepresentationsOfType = function(_type) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3106 |
var _representations = Rkns._(this.representations).filter(function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3107 |
return _repr.type == _type; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3108 |
}), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3109 |
_this = this; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3110 |
Rkns._(_representations).each(function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3111 |
_this.removeRepresentation(_repr); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3112 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3113 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3114 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3115 |
Rkns.Renderer.Scene.prototype.highlightModel = function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3116 |
var _repr = this.getRepresentationByModel(_model); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3117 |
if (_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3118 |
_repr.highlight(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3119 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3120 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3121 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3122 |
Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3123 |
Rkns._(this.representations).each(function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3124 |
_repr.unhighlight(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3125 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3126 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3127 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3128 |
Rkns.Renderer.Scene.prototype.unselectAll = function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3129 |
Rkns._(this.representations).each(function(_repr) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3130 |
_repr.unselect(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3131 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3132 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3133 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3134 |
Rkns.Renderer.Scene.prototype.redraw = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3135 |
Rkns._(this.representations).each(function(_representation) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3136 |
_representation.redraw(true); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3137 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3138 |
if (this.minimap) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3139 |
this.redrawMiniframe(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3140 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3141 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3142 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3143 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3144 |
Rkns.Renderer.Scene.prototype.addTempEdge = function(_from, _point) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3145 |
var _tmpEdge = this.addRepresentation("TempEdge",null);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3146 |
_tmpEdge.end_pos = _point; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3147 |
_tmpEdge.from_representation = _from; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3148 |
_tmpEdge.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3149 |
this.click_target = _tmpEdge; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3150 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3151 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3152 |
Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3153 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3154 |
var _newTarget = _hitResult.item.__representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3155 |
if (this.selected_target !== _hitResult.item.__representation) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3156 |
if (this.selected_target) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3157 |
this.selected_target.unselect(_newTarget); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3158 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3159 |
_newTarget.select(this.selected_target); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3160 |
this.selected_target = _newTarget; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3161 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3162 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3163 |
if (this.selected_target) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3164 |
this.selected_target.unselect(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3165 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3166 |
this.selected_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3167 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3168 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3169 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3170 |
Rkns.Renderer.Scene.prototype.paperShift = function(_delta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3171 |
this.offset = this.offset.add(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3172 |
this.redraw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3173 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3174 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3175 |
Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3176 |
var _off = this.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3177 |
_point = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3178 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3179 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3180 |
]), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3181 |
_delta = _point.subtract(this.last_point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3182 |
this.last_point = _point; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3183 |
if (!this.is_dragging && this.mouse_down && _delta.length > Rkns.Renderer._MIN_DRAG_DISTANCE) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3184 |
this.is_dragging = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3185 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3186 |
var _hitResult = paper.project.hitTest(_point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3187 |
if (this.is_dragging) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3188 |
if (this.click_target && typeof this.click_target.paperShift === "function") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3189 |
this.click_target.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3190 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3191 |
this.paperShift(_delta); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3192 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3193 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3194 |
this.findTarget(_hitResult); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3195 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3196 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3197 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3198 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3199 |
Rkns.Renderer.Scene.prototype.onMouseDown = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3200 |
var _off = this.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3201 |
_point = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3202 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3203 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3204 |
]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3205 |
this.last_point = _point; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3206 |
this.mouse_down = true; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3207 |
if (!this.click_target || this.click_target.type !== "Temp-edge") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3208 |
this.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3209 |
this.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3210 |
var _hitResult = paper.project.hitTest(_point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3211 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3212 |
this.click_target = _hitResult.item.__representation; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3213 |
this.click_target.mousedown(_event, _isTouch); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3214 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3215 |
this.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3216 |
if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3217 |
var _coords = this.toModelCoords(_point), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3218 |
_data = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3219 |
id: Rkns.Utils.getUID('node'),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3220 |
created_by: this.renkan.current_user, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3221 |
position: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3222 |
x: _coords.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3223 |
y: _coords.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3224 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3225 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3226 |
_node = this.renkan.project.addNode(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3227 |
this.getRepresentationByModel(_node).openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3228 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3229 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3230 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3231 |
if (this.click_mode) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3232 |
if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3233 |
this.removeRepresentationsOfType("editor");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3234 |
this.addTempEdge(this.click_target, _point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3235 |
this.click_mode = Rkns.Renderer._CLICKMODE_ENDEDGE; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3236 |
this.notif_$.fadeOut(function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3237 |
Rkns.$(this).html(_renkan.translate("Click on a second node to complete the edge")).fadeIn();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3238 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3239 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3240 |
this.notif_$.hide(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3241 |
this.click_mode = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3242 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3243 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3244 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3245 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3246 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3247 |
Rkns.Renderer.Scene.prototype.onMouseUp = function(_event, _isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3248 |
this.mouse_down = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3249 |
if (this.click_target) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3250 |
var _off = this.canvas_$.offset(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3251 |
this.click_target.mouseup( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3252 |
{
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3253 |
point: new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3254 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3255 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3256 |
]) |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3257 |
}, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3258 |
_isTouch |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3259 |
); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3260 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3261 |
this.click_target = null; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3262 |
this.is_dragging = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3263 |
if (_isTouch) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3264 |
this.unselectAll(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3265 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3266 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3267 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3268 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3269 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3270 |
Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3271 |
this.totalScroll += _scrolldelta; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3272 |
if (Math.abs(this.totalScroll) >= 1) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3273 |
var _off = this.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3274 |
_delta = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3275 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3276 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3277 |
]).subtract(this.offset).multiply( Math.SQRT2 - 1 ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3278 |
if (this.totalScroll > 0) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3279 |
this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) ); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3280 |
} else {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3281 |
this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2))); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3282 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3283 |
this.totalScroll = 0; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3284 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3285 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3286 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3287 |
Rkns.Renderer.Scene.prototype.onDoubleClick = function(_event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3288 |
if (!this.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3289 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3290 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3291 |
var _off = this.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3292 |
_point = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3293 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3294 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3295 |
]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3296 |
var _hitResult = paper.project.hitTest(_point); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3297 |
if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3298 |
var _coords = this.toModelCoords(_point), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3299 |
_data = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3300 |
id: Rkns.Utils.getUID('node'),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3301 |
created_by: this.renkan.current_user, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3302 |
position: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3303 |
x: _coords.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3304 |
y: _coords.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3305 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3306 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3307 |
_node = this.renkan.project.addNode(_data); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3308 |
this.getRepresentationByModel(_node).openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3309 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3310 |
paper.view.draw(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3311 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3312 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3313 |
Rkns.Renderer.Scene.prototype.dropData = function(_data, _event) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3314 |
if (!this.isEditable()) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3315 |
return; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3316 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3317 |
if (_data["text/json"] || _data["application/json"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3318 |
try {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3319 |
var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3320 |
_(_data).extend(jsondata); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3321 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3322 |
catch(e) {}
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3323 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3324 |
var newNode = {};
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3325 |
switch(_data["text/x-iri-specific-site"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3326 |
case "twitter": |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3327 |
var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3328 |
tweetdiv = snippet.find(".tweet");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3329 |
newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3330 |
newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3331 |
newNode.image = tweetdiv.find(".avatar").attr("src");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3332 |
newNode.description = tweetdiv.find(".js-tweet-text:first").text();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3333 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3334 |
case "google": |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3335 |
var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]);
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3336 |
newNode.title = snippet.find("h3:first").text().trim();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3337 |
newNode.uri = snippet.find("h3 a").attr("href");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3338 |
newNode.description = snippet.find(".st:first").text().trim();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3339 |
break; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3340 |
case undefined: |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3341 |
default: |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3342 |
if (_data["text/x-iri-source-uri"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3343 |
newNode.uri = _data["text/x-iri-source-uri"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3344 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3345 |
if (_data["text/plain"] || _data["text/x-iri-selected-text"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3346 |
newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3347 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3348 |
if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3349 |
var snippet = Rkns.$('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
|
| 898 | 3350 |
var _svgimgs = snippet.find("image");
|
3351 |
if (_svgimgs.length) {
|
|
3352 |
newNode.image = _svgimgs.attr("xlink:href");
|
|
3353 |
} |
|
3354 |
var _svgpaths = snippet.find("path");
|
|
3355 |
if (_svgpaths.length) {
|
|
3356 |
newNode.clipPath = _svgpaths.attr("d");
|
|
3357 |
} |
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3358 |
var _imgs = snippet.find("img");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3359 |
if (_imgs.length) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3360 |
newNode.image = _imgs[0].src; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3361 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3362 |
var _as = snippet.find("a");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3363 |
if (_as.length) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3364 |
newNode.uri = _as[0].href; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3365 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3366 |
newNode.title = snippet.find("[title]").attr("title") || newNode.title;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3367 |
newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3368 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3369 |
if (_data["text/uri-list"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3370 |
newNode.uri = _data["text/uri-list"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3371 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3372 |
if (_data["text/x-moz-url"] && !newNode.title) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3373 |
newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim();
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3374 |
if (newNode.title === newNode.uri) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3375 |
newNode.title = false; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3376 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3377 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3378 |
if (_data["text/x-iri-source-title"] && !newNode.title) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3379 |
newNode.title = _data["text/x-iri-source-title"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3380 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3381 |
if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3382 |
newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3383 |
newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3384 |
newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3385 |
newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
|
| 898 | 3386 |
newNode.description = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.description;
|
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3387 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3388 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3389 |
if (!newNode.title) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3390 |
newNode.title = this.renkan.translate("Dragged resource");
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3391 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3392 |
var fields = ["title", "description", "uri", "image"]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3393 |
for (var i = 0; i < fields.length; i++) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3394 |
var f = fields[i]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3395 |
if (_data["text/x-iri-" + f] || _data[f]) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3396 |
newNode[f] = _data["text/x-iri-" + f] || _data[f]; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3397 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3398 |
if (newNode[f] === "none" || newNode[f] === "null") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3399 |
newNode[f] = undefined; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3400 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3401 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3402 |
var _off = this.canvas_$.offset(), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3403 |
_point = new paper.Point([ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3404 |
_event.pageX - _off.left, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3405 |
_event.pageY - _off.top |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3406 |
]), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3407 |
_coords = this.toModelCoords(_point), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3408 |
_nodedata = {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3409 |
id: Rkns.Utils.getUID('node'),
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3410 |
created_by: this.renkan.current_user, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3411 |
uri: newNode.uri || "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3412 |
title: newNode.title || "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3413 |
description: newNode.description || "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3414 |
image: newNode.image || "", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3415 |
color: newNode.color || undefined, |
| 898 | 3416 |
"clip-path": newNode.clipPath || undefined, |
|
872
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3417 |
position: {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3418 |
x: _coords.x, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3419 |
y: _coords.y |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3420 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3421 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3422 |
var _node = this.renkan.project.addNode(_nodedata), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3423 |
_repr = this.getRepresentationByModel(_node); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3424 |
if (_event.type === "drop") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3425 |
_repr.openEditor(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3426 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3427 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3428 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3429 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3430 |
end of paper-renderer.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3431 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3432 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3433 |
start of full-json.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3434 |
********************************************************* */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3435 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3436 |
/* Saves the Full JSON at each modification */ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3437 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3438 |
Rkns.jsonIO = function(_renkan, _opts) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3439 |
var _proj = _renkan.project; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3440 |
if (typeof _opts.http_method == "undefined") {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3441 |
_opts.http_method = 'PUT'; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3442 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3443 |
var _load = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3444 |
Rkns.$.getJSON(_opts.url, function(_data) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3445 |
_proj.set(_data, {validate: true});
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3446 |
_renkan.renderer.autoScale(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3447 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3448 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3449 |
var _save = function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3450 |
var _data = _proj.toJSON(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3451 |
if (!_renkan.read_only) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3452 |
Rkns.$.ajax({
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3453 |
type: _opts.http_method, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3454 |
url: _opts.url, |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3455 |
contentType: "application/json", |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3456 |
data: JSON.stringify(_data), |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3457 |
success: function(data, textStatus, jqXHR) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3458 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3459 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3460 |
} |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3461 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3462 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3463 |
var _thrSave = Rkns._.throttle( |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3464 |
function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3465 |
setTimeout(_save, 100); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3466 |
}, 1000); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3467 |
_proj.on("add:nodes add:edges add:users", function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3468 |
_model.on("change remove", function(_model) {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3469 |
_thrSave(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3470 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3471 |
_thrSave(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3472 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3473 |
_proj.on("change", function() {
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3474 |
_thrSave(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3475 |
}); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3476 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3477 |
_load(); |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3478 |
}; |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3479 |
|
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3480 |
/* ********************************************************* |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3481 |
end of full-json.js |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3482 |
************************************************************ |
|
6b7c534792b7
Updated Metadataplayer for Renkan
Raphael Velt <raph.velt@gmail.com>
parents:
diff
changeset
|
3483 |
*/ |