| author | ymh <ymh.work@gmail.com> |
| Sat, 26 Apr 2014 21:24:28 +0200 | |
| changeset 278 | b45dda454dd6 |
| parent 277 | 1a54f4e626df |
| child 281 | 9ff388c9bc8d |
| permissions | -rw-r--r-- |
| 187 | 1 |
/* paper-renderer.js */ |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2 |
"use strict"; |
| 187 | 3 |
|
| 195 | 4 |
(function(root) {
|
5 |
||
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
6 |
var Rkns = root.Rkns, |
| 195 | 7 |
_ = Rkns._, |
8 |
$ = Rkns.$; |
|
| 187 | 9 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
10 |
/* Rkns.Renderer Object */ |
| 199 | 11 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
12 |
/* This object contains constants, utility functions and classes for Renkan's Graph Manipulation GUI */ |
| 199 | 13 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
14 |
var Renderer = Rkns.Renderer = {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
15 |
/* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */ |
| 187 | 16 |
_MIN_DRAG_DISTANCE = 2, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
17 |
/* Distance between the inner and outer radius of buttons that appear when hovering on a node */ |
| 187 | 18 |
_NODE_BUTTON_WIDTH = 40, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
19 |
|
| 187 | 20 |
_EDGE_BUTTON_INNER = 2, |
21 |
_EDGE_BUTTON_OUTER = 40, |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
22 |
/* Constants used to know if a specific action is to be performed when clicking on the canvas */ |
| 187 | 23 |
_CLICKMODE_ADDNODE = 1, |
24 |
_CLICKMODE_STARTEDGE = 2, |
|
25 |
_CLICKMODE_ENDEDGE = 3, |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
26 |
/* Node size step: Used to calculate the size change when clicking the +/- buttons */ |
| 187 | 27 |
_NODE_SIZE_STEP = Math.LN2/4, |
28 |
_MIN_SCALE = 1/20, |
|
29 |
_MAX_SCALE = 20, |
|
30 |
_MOUSEMOVE_RATE = 80, |
|
31 |
_DOUBLETAP_DELAY = 800, |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
32 |
/* Maximum distance in pixels (squared, to reduce calculations) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
33 |
* between two taps when double-tapping on a touch terminal */ |
| 187 | 34 |
_DOUBLETAP_DISTANCE = 20*20, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
35 |
/* A placeholder so a default colour is displayed when a node has a null value for its user property */ |
| 187 | 36 |
_USER_PLACEHOLDER = function(_renkan) {
|
| 160 | 37 |
return {
|
38 |
color: _renkan.options.default_user_color, |
|
39 |
title: _renkan.translate("(unknown user)"),
|
|
40 |
get: function(attr) {
|
|
41 |
return this[attr] || false; |
|
42 |
} |
|
|
170
603ffa4c6fa5
correct ";" and "," in javascripts
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
43 |
}; |
| 70 | 44 |
}, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
45 |
/* The code for the "Drag and Add Bookmarklet", slightly minified and with whitespaces removed, though |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
46 |
* it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
47 |
*/ |
| 187 | 48 |
_BOOKMARKLET_CODE = function(_renkan) {
|
| 160 | 49 |
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;\">"
|
50 |
+ _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")
|
|
|
170
603ffa4c6fa5
correct ";" and "," in javascripts
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
51 |
+ "</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);})();";
|
| 159 | 52 |
}, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
53 |
/* Shortens text to the required length then adds ellipsis */ |
| 187 | 54 |
shortenText = function(_text, _maxlength) {
|
| 160 | 55 |
return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text); |
56 |
}, |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
57 |
/* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
58 |
* Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */ |
| 187 | 59 |
drawEditBox = function(_options, _coords, _path, _xmargin, _selector) {
|
| 160 | 60 |
_selector.css({
|
|
211
d87f6bdee43d
upgrade libs + add no minified versions of libs + improve build + allow disabling zoom on scroll
ymh <ymh.work@gmail.com>
parents:
207
diff
changeset
|
61 |
width: ( _options.tooltip_width - 2* _options.tooltip_padding ) |
|
170
603ffa4c6fa5
correct ";" and "," in javascripts
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
62 |
}); |
|
120
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
63 |
var _height = _selector.outerHeight() + 2* _options.tooltip_padding, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
64 |
_isLeft = (_coords.x < paper.view.center.x ? 1 : -1), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
65 |
_left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
66 |
_right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
67 |
_top = _coords.y - _height / 2; |
| 163 | 68 |
if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
|
69 |
_top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height; |
|
70 |
} |
|
|
120
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
71 |
if (_top < _options.tooltip_margin) {
|
|
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
72 |
_top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 ); |
| 5 | 73 |
} |
74 |
var _bottom = _top + _height; |
|
75 |
_path.segments[0].point |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
76 |
= _path.segments[7].point |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
77 |
= _coords.add([_isLeft * _xmargin, 0]); |
| 5 | 78 |
_path.segments[1].point.x |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
79 |
= _path.segments[2].point.x |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
80 |
= _path.segments[5].point.x |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
81 |
= _path.segments[6].point.x |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
82 |
= _left; |
| 5 | 83 |
_path.segments[3].point.x |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
84 |
= _path.segments[4].point.x |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
85 |
= _right; |
| 5 | 86 |
_path.segments[2].point.y |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
87 |
= _path.segments[3].point.y |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
88 |
= _top; |
| 5 | 89 |
_path.segments[4].point.y |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
90 |
= _path.segments[5].point.y |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
91 |
= _bottom; |
|
120
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
92 |
_path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2; |
|
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
93 |
_path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2; |
| 28 | 94 |
_path.closed = true; |
|
120
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
95 |
_path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]); |
| 28 | 96 |
_selector.css({
|
|
120
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
97 |
left: (_options.tooltip_padding + Math.min(_left, _right)), |
|
112a82ddd7e5
Settings transferred from paper-renderer.js to defaults.js
veltr
parents:
119
diff
changeset
|
98 |
top: (_options.tooltip_padding + _top) |
| 28 | 99 |
}); |
| 153 | 100 |
return _path; |
| 187 | 101 |
}; |
| 5 | 102 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
103 |
/* Rkns.Renderer._BaseRepresentation Class */ |
| 199 | 104 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
105 |
/* In Renkan, a "Representation" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
106 |
* models (written with Backbone.js) and the view (written with Paper.js) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
107 |
* Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/ |
| 199 | 108 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
109 |
var _BaseRepresentation = Renderer._BaseRepresentation = function(_renderer, _model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
110 |
if (typeof _renderer !== "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
111 |
this.renderer = _renderer; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
112 |
this.renkan = _renderer.renkan; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
113 |
this.project = _renderer.renkan.project; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
114 |
this.options = _renderer.renkan.options; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
115 |
this.model = _model; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
116 |
if (this.model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
117 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
118 |
this._changeBinding = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
119 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
120 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
121 |
this._removeBinding = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
122 |
_renderer.removeRepresentation(_this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
123 |
_(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
124 |
_renderer.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
125 |
}).defer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
126 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
127 |
this._selectBinding = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
128 |
_this.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
129 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
130 |
this._unselectBinding = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
131 |
_this.unselect(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
132 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
133 |
this.model.on("change", this._changeBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
134 |
this.model.on("remove", this._removeBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
135 |
this.model.on("select", this._selectBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
136 |
this.model.on("unselect", this._unselectBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
137 |
} |
| 187 | 138 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
139 |
}; |
| 5 | 140 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
141 |
/* Rkns.Renderer._BaseRepresentation Methods */ |
| 132 | 142 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
143 |
_(_BaseRepresentation.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
144 |
_super: function(_func) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
145 |
return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
146 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
147 |
redraw: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
148 |
moveTo: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
149 |
show: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
150 |
hide: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
151 |
select: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
152 |
if (this.model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
153 |
this.model.trigger("selected");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
154 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
155 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
156 |
unselect: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
157 |
if (this.model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
158 |
this.model.trigger("unselected");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
159 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
160 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
161 |
highlight: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
162 |
unhighlight: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
163 |
mousedown: function() {},
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
164 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
165 |
if (this.model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
166 |
this.model.trigger("clicked");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
167 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
168 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
169 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
170 |
if (this.model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
171 |
this.model.off("change", this._changeBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
172 |
this.model.off("remove", this._removeBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
173 |
this.model.off("select", this._selectBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
174 |
this.model.off("unselect", this._unselectBinding );
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
175 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
176 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
177 |
}); |
| 132 | 178 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
179 |
/* End of Rkns.Renderer._BaseRepresentation Class */ |
| 199 | 180 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
181 |
/* Rkns.Renderer._BaseButton Class */ |
| 199 | 182 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
183 |
/* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */ |
| 132 | 184 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
185 |
var _BaseButton = Renderer._BaseButton = Rkns.Utils.inherit(_BaseRepresentation); |
| 1 | 186 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
187 |
_(_BaseButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
188 |
moveTo: function(_pos) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
189 |
this.sector.moveTo(_pos); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
190 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
191 |
show: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
192 |
this.sector.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
193 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
194 |
hide: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
195 |
this.sector.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
196 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
197 |
select: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
198 |
this.sector.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
199 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
200 |
unselect: function(_newTarget) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
201 |
this.sector.unselect(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
202 |
if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
203 |
this.source_representation.unselect(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
204 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
205 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
206 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
207 |
this.sector.destroy(); |
| 160 | 208 |
} |
|
170
603ffa4c6fa5
correct ";" and "," in javascripts
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
209 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
210 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
211 |
/* End of Rkns.Renderer._BaseButton Class */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
212 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
213 |
/* Rkns.Renderer.Node Class */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
214 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
215 |
/* The representation for the node : A circle, with an image inside and a text label underneath. |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
216 |
* The circle and the image are drawn on canvas and managed by Paper.js. |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
217 |
* The text label is an HTML node, managed by jQuery. */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
218 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
219 |
var NodeRepr = Renderer.Node = Rkns.Utils.inherit(_BaseRepresentation); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
220 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
221 |
_(NodeRepr.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
222 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
223 |
this.renderer.node_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
224 |
this.type = "Node"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
225 |
this.circle = new paper.Path.Circle([0, 0], 1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
226 |
this.circle.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
227 |
if (this.options.show_node_circles) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
228 |
this.circle.strokeWidth = this.options.node_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
229 |
this.h_ratio = 1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
230 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
231 |
this.h_ratio = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
232 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
233 |
this.title = $('<div class="Rk-Label">').appendTo(this.renderer.labels_$);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
234 |
if (this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
235 |
this.normal_buttons = [ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
236 |
new NodeEditButton(this.renderer, null), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
237 |
new NodeRemoveButton(this.renderer, null), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
238 |
new NodeLinkButton(this.renderer, null), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
239 |
new NodeEnlargeButton(this.renderer, null), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
240 |
new NodeShrinkButton(this.renderer, null) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
241 |
]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
242 |
this.pending_delete_buttons = [ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
243 |
new NodeRevertButton(this.renderer, null) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
244 |
]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
245 |
this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
246 |
for (var i = 0; i < this.all_buttons.length; i++) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
247 |
this.all_buttons[i].source_representation = this; |
| 195 | 248 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
249 |
this.active_buttons = []; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
250 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
251 |
this.active_buttons = this.all_buttons = []; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
252 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
253 |
this.last_circle_radius = 1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
254 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
255 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
256 |
this.renderer.minimap.node_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
257 |
this.minimap_circle = new paper.Path.Circle([0, 0], 1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
258 |
this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
259 |
this.renderer.minimap.node_group.addChild(this.minimap_circle); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
260 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
261 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
262 |
redraw: function(_dontRedrawEdges) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
263 |
var _model_coords = new paper.Point(this.model.get("position")),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
264 |
_baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * _NODE_SIZE_STEP);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
265 |
if (!this.is_dragging || !this.paper_coords) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
266 |
this.paper_coords = this.renderer.toPaperCoords(_model_coords); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
267 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
268 |
this.circle_radius = _baseRadius * this.renderer.scale; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
269 |
if (this.last_circle_radius !== this.circle_radius) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
270 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
271 |
b.setSectorSize(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
272 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
273 |
this.circle.scale(this.circle_radius / this.last_circle_radius); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
274 |
if (this.node_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
275 |
this.node_image.scale(this.circle_radius / this.last_circle_radius); |
| 195 | 276 |
} |
| 160 | 277 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
278 |
this.circle.position = this.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
279 |
if (this.node_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
280 |
this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
281 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
282 |
this.last_circle_radius = this.circle_radius; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
283 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
284 |
var old_act_btn = this.active_buttons; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
285 |
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
286 |
var opacity = 1; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
287 |
if (this.model.get("delete_scheduled")) {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
288 |
opacity = .5; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
289 |
this.active_buttons = this.pending_delete_buttons; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
290 |
this.circle.dashArray = [2,2]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
291 |
} else {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
292 |
opacity = 1; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
293 |
this.active_buttons = this.normal_buttons; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
294 |
this.circle.dashArray = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
295 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
296 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
297 |
if (this.selected && this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
298 |
if (old_act_btn !== this.active_buttons) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
299 |
old_act_btn.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
300 |
b.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
301 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
302 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
303 |
this.active_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
304 |
b.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
305 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
306 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
307 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
308 |
if (this.node_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
309 |
this.node_image.opacity = this.highlighted ? opacity * .5 : (opacity - .01); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
310 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
311 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
312 |
this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
313 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
314 |
this.circle.opacity = this.options.show_node_circles ? opacity : .01; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
315 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
316 |
var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || "";
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
317 |
_text = shortenText(_text, this.options.node_label_max_length); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
318 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
319 |
if (typeof this.highlighted === "object") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
320 |
this.title.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>')); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
321 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
322 |
this.title.text(_text); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
323 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
324 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
325 |
this.title.css({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
326 |
left: this.paper_coords.x, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
327 |
top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
328 |
opacity: opacity |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
329 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
330 |
var _color = this.model.get("color") || (this.model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
331 |
this.circle.strokeColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
332 |
var _pc = this.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
333 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
334 |
b.moveTo(_pc); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
335 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
336 |
var lastImage = this.img; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
337 |
this.img = this.model.get("image");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
338 |
if (this.img && this.img !== lastImage) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
339 |
this.showImage(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
340 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
341 |
if (this.node_image && !this.img) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
342 |
this.node_image.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
343 |
delete this.node_image; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
344 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
345 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
346 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
347 |
this.minimap_circle.fillColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
348 |
var minipos = this.renderer.toMinimapCoords(_model_coords), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
349 |
miniradius = this.renderer.minimap.scale * _baseRadius, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
350 |
minisize = new paper.Size([miniradius, miniradius]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
351 |
this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
352 |
} |
| 118 | 353 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
354 |
if (!_dontRedrawEdges) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
355 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
356 |
_.each( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
357 |
this.project.get("edges").filter(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
358 |
function (ed) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
359 |
return ((ed.get("to") === _this.model) || (ed.get("from") === _this.model));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
360 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
361 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
362 |
function(edge, index, list) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
363 |
var repr = _this.renderer.getRepresentationByModel(edge); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
364 |
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") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
365 |
repr.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
366 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
367 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
368 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
369 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
370 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
371 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
372 |
showImage: function() {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
373 |
var _image = null; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
374 |
if (typeof this.renderer.image_cache[this.img] === "undefined") {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
375 |
_image = new Image(); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
376 |
this.renderer.image_cache[this.img] = _image; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
377 |
_image.src = this.img; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
378 |
} else {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
379 |
_image = this.renderer.image_cache[this.img]; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
380 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
381 |
if (_image.width) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
382 |
if (this.node_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
383 |
this.node_image.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
384 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
385 |
this.renderer.node_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
386 |
var width = _image.width, |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
387 |
height = _image.height, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
388 |
clipPath = this.model.get("clip_path"),
|
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
389 |
hasClipPath = (typeof clipPath !== "undefined" && clipPath), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
390 |
_clip = null, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
391 |
baseRadius = null, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
392 |
centerPoint = null; |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
393 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
394 |
if (hasClipPath) {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
395 |
_clip = new paper.Path(); |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
396 |
var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [], |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
397 |
lastCoords = [0,0], |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
398 |
minX = Infinity, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
399 |
minY = Infinity, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
400 |
maxX = -Infinity, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
401 |
maxY = -Infinity; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
402 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
403 |
var transformCoords = function(tabc, relative) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
404 |
var newCoords = tabc.slice(1).map(function(v, k) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
405 |
var res = parseFloat(v), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
406 |
isY = k % 2; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
407 |
if (isY) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
408 |
res = ( res - .5 ) * height; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
409 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
410 |
res = ( res - .5 ) * width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
411 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
412 |
if (relative) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
413 |
res += lastCoords[isY]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
414 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
415 |
if (isY) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
416 |
minY = Math.min(minY, res); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
417 |
maxY = Math.max(maxY, res); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
418 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
419 |
minX = Math.min(minX, res); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
420 |
maxX = Math.max(maxX, res); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
421 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
422 |
return res; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
423 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
424 |
lastCoords = newCoords.slice(-2); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
425 |
return newCoords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
426 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
427 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
428 |
instructions.forEach(function(instr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
429 |
var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
430 |
switch(coords[0]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
431 |
case "M": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
432 |
_clip.moveTo(transformCoords(coords)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
433 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
434 |
case "m": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
435 |
_clip.moveTo(transformCoords(coords, true)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
436 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
437 |
case "L": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
438 |
_clip.lineTo(transformCoords(coords)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
439 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
440 |
case "l": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
441 |
_clip.lineTo(transformCoords(coords, true)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
442 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
443 |
case "C": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
444 |
_clip.cubicCurveTo(transformCoords(coords)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
445 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
446 |
case "c": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
447 |
_clip.cubicCurveTo(transformCoords(coords, true)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
448 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
449 |
case "Q": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
450 |
_clip.quadraticCurveTo(transformCoords(coords)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
451 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
452 |
case "q": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
453 |
_clip.quadraticCurveTo(transformCoords(coords, true)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
454 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
455 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
456 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
457 |
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
458 |
baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
459 |
centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
460 |
if (!this.options.show_node_circles) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
461 |
this.h_ratio = (maxY - minY) / (2 * baseRadius); |
| 175 | 462 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
463 |
} else {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
464 |
baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
465 |
centerPoint = new paper.Point(0,0); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
466 |
if (!this.options.show_node_circles) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
467 |
this.h_ratio = height / (2 * baseRadius); |
| 175 | 468 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
469 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
470 |
var _raster = new paper.Raster(_image); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
471 |
_raster.locked = true; // Disable mouse events on icon |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
472 |
if (hasClipPath) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
473 |
_raster = new paper.Group(_clip, _raster); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
474 |
_raster.opacity = .99; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
475 |
/* This is a workaround to allow clipping at group level |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
476 |
* If opacity was set to 1, paper.js would merge all clipping groups in one (known bug). |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
477 |
*/ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
478 |
_raster.clipped = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
479 |
_clip.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
480 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
481 |
if (this.options.clip_node_images) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
482 |
var _circleClip = new paper.Path.Circle(centerPoint, baseRadius); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
483 |
_raster = new paper.Group(_circleClip, _raster); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
484 |
_raster.opacity = .99; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
485 |
_raster.clipped = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
486 |
_circleClip.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
487 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
488 |
this.image_delta = centerPoint.divide(baseRadius); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
489 |
this.node_image = _raster; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
490 |
this.node_image.__representation = _this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
491 |
this.node_image.scale(this.circle_radius / baseRadius); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
492 |
this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
493 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
494 |
this.renderer.throttledPaperDraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
495 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
496 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
497 |
$(_image).on("load", function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
498 |
_this.showImage(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
499 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
500 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
501 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
502 |
paperShift: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
503 |
if (this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
504 |
if (!this.renkan.read_only) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
505 |
this.is_dragging = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
506 |
this.paper_coords = this.paper_coords.add(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
507 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
508 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
509 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
510 |
this.renderer.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
511 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
512 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
513 |
openEditor: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
514 |
this.renderer.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
515 |
var _editor = this.renderer.addRepresentation("NodeEditor",null);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
516 |
_editor.source_representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
517 |
_editor.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
518 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
519 |
select: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
520 |
this.selected = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
521 |
this.circle.strokeWidth = this.options.selected_node_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
522 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
523 |
this.active_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
524 |
b.show(); |
| 175 | 525 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
526 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
527 |
var _uri = this.model.get("uri");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
528 |
if (_uri) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
529 |
$('.Rk-Bin-Item').each(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
530 |
var _el = $(this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
531 |
if (_el.attr("data-uri") == _uri) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
532 |
_el.addClass("selected");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
533 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
534 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
535 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
536 |
if (!this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
537 |
this.openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
538 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
539 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
540 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
541 |
this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
542 |
this.minimap_circle.strokeColor = this.options.minimap_highlight_color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
543 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
544 |
this._super("select");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
545 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
546 |
unselect: function(_newTarget) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
547 |
if (!_newTarget || _newTarget.source_representation !== this) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
548 |
this.selected = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
549 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
550 |
b.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
551 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
552 |
this.circle.strokeWidth = this.options.node_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
553 |
$('.Rk-Bin-Item').removeClass("selected");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
554 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
555 |
this.minimap_circle.strokeColor = undefined; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
556 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
557 |
this._super("unselect");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
558 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
559 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
560 |
highlight: function(textToReplace) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
561 |
var hlvalue = textToReplace || true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
562 |
if (this.highlighted === hlvalue) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
563 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
564 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
565 |
this.highlighted = hlvalue; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
566 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
567 |
this.renderer.throttledPaperDraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
568 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
569 |
unhighlight: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
570 |
if (!this.highlighted) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
571 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
572 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
573 |
this.highlighted = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
574 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
575 |
this.renderer.throttledPaperDraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
576 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
577 |
saveCoords: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
578 |
var _coords = this.renderer.toModelCoords(this.paper_coords), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
579 |
_data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
580 |
position: {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
581 |
x: _coords.x, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
582 |
y: _coords.y |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
583 |
} |
| 199 | 584 |
}; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
585 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
586 |
this.model.set(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
587 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
588 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
589 |
mousedown: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
590 |
if (_isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
591 |
this.renderer.unselectAll(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
592 |
this.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
593 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
594 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
595 |
mouseup: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
596 |
if (this.renderer.is_dragging && this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
597 |
this.saveCoords(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
598 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
599 |
if (!_isTouch && !this.model.get("delete_scheduled")) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
600 |
this.openEditor(); |
| 175 | 601 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
602 |
this.model.trigger("clicked");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
603 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
604 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
605 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
606 |
this.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
607 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
608 |
destroy: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
609 |
this._super("destroy");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
610 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
611 |
b.destroy(); |
| 175 | 612 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
613 |
this.circle.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
614 |
this.title.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
615 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
616 |
this.minimap_circle.remove(); |
| 175 | 617 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
618 |
if (this.node_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
619 |
this.node_image.remove(); |
| 175 | 620 |
} |
621 |
} |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
622 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
623 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
624 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
625 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
626 |
var Edge = Renderer.Edge = Rkns.Utils.inherit(_BaseRepresentation); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
627 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
628 |
_(Edge.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
629 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
630 |
this.renderer.edge_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
631 |
this.type = "Edge"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
632 |
this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
633 |
this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
634 |
this.bundle = this.renderer.addToBundles(this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
635 |
this.line = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
636 |
this.line.add([0,0],[0,0],[0,0]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
637 |
this.line.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
638 |
this.line.strokeWidth = this.options.edge_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
639 |
this.arrow = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
640 |
this.arrow.add( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
641 |
[ 0, 0 ], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
642 |
[ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
643 |
[ 0, this.options.edge_arrow_width ] |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
644 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
645 |
this.arrow.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
646 |
this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
647 |
this.arrow_angle = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
648 |
if (this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
649 |
this.normal_buttons = [ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
650 |
new EdgeEditButton(this.renderer, null), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
651 |
new EdgeRemoveButton(this.renderer, null) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
652 |
]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
653 |
this.pending_delete_buttons = [ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
654 |
new EdgeRevertButton(this.renderer, null) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
655 |
]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
656 |
this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
657 |
for (var i = 0; i < this.all_buttons.length; i++) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
658 |
this.all_buttons[i].source_representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
659 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
660 |
this.active_buttons = []; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
661 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
662 |
this.active_buttons = this.all_buttons = []; |
| 160 | 663 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
664 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
665 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
666 |
this.renderer.minimap.edge_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
667 |
this.minimap_line = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
668 |
this.minimap_line.add([0,0],[0,0]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
669 |
this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
670 |
this.minimap_line.strokeWidth = 1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
671 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
672 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
673 |
redraw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
674 |
var from = this.model.get("from"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
675 |
to = this.model.get("to");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
676 |
if (!from || !to) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
677 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
678 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
679 |
this.from_representation = this.renderer.getRepresentationByModel(from); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
680 |
this.to_representation = this.renderer.getRepresentationByModel(to); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
681 |
if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
682 |
return; |
| 57 | 683 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
684 |
var _p0a = this.from_representation.paper_coords, |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
685 |
_p1a = this.to_representation.paper_coords, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
686 |
_v = _p1a.subtract(_p0a), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
687 |
_r = _v.length, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
688 |
_u = _v.divide(_r), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
689 |
_ortho = new paper.Point([- _u.y, _u.x]), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
690 |
_group_pos = this.bundle.getPosition(this), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
691 |
_delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
692 |
_p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
693 |
_p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
694 |
_a = _v.angle, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
695 |
_textdelta = _ortho.multiply(this.options.edge_label_distance), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
696 |
_handle = _v.divide(3), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
697 |
_color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"),
|
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
698 |
opacity = 1; |
| 4 | 699 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
700 |
if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
701 |
opacity = .5; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
702 |
this.line.dashArray = [2, 2]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
703 |
} else {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
704 |
opacity = 1; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
705 |
this.line.dashArray = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
706 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
707 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
708 |
var old_act_btn = this.active_buttons; |
| 2 | 709 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
710 |
this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
711 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
712 |
if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
713 |
old_act_btn.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
714 |
b.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
715 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
716 |
this.active_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
717 |
b.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
718 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
719 |
} |
| 2 | 720 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
721 |
this.paper_coords = _p0b.add(_p1b).divide(2); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
722 |
this.line.strokeColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
723 |
this.line.opacity = opacity; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
724 |
this.line.segments[0].point = _p0a; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
725 |
this.line.segments[1].point = this.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
726 |
this.line.segments[1].handleIn = _handle.multiply(-1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
727 |
this.line.segments[1].handleOut = _handle; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
728 |
this.line.segments[2].point = _p1a; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
729 |
this.arrow.rotate(_a - this.arrow_angle); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
730 |
this.arrow.fillColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
731 |
this.arrow.opacity = opacity; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
732 |
this.arrow.position = this.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
733 |
this.arrow_angle = _a; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
734 |
if (_a > 90) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
735 |
_a -= 180; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
736 |
_textdelta = _textdelta.multiply(-1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
737 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
738 |
if (_a < -90) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
739 |
_a += 180; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
740 |
_textdelta = _textdelta.multiply(-1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
741 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
742 |
var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || "";
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
743 |
_text = shortenText(_text, this.options.node_label_max_length); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
744 |
this.text.text(_text); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
745 |
var _textpos = this.paper_coords.add(_textdelta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
746 |
this.text.css({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
747 |
left: _textpos.x, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
748 |
top: _textpos.y, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
749 |
transform: "rotate(" + _a + "deg)",
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
750 |
"-moz-transform": "rotate(" + _a + "deg)",
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
751 |
"-webkit-transform": "rotate(" + _a + "deg)",
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
752 |
opacity: opacity |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
753 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
754 |
this.text_angle = _a; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
755 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
756 |
var _pc = this.paper_coords; |
| 161 | 757 |
this.all_buttons.forEach(function(b) {
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
758 |
b.moveTo(_pc); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
759 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
760 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
761 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
762 |
this.minimap_line.strokeColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
763 |
this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
764 |
this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
765 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
766 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
767 |
openEditor: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
768 |
this.renderer.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
769 |
var _editor = this.renderer.addRepresentation("EdgeEditor",null);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
770 |
_editor.source_representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
771 |
_editor.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
772 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
773 |
select: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
774 |
this.selected = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
775 |
this.line.strokeWidth = this.options.selected_edge_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
776 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
777 |
this.active_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
778 |
b.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
779 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
780 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
781 |
if (!this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
782 |
this.openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
783 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
784 |
this._super("select");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
785 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
786 |
unselect: function(_newTarget) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
787 |
if (!_newTarget || _newTarget.source_representation !== this) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
788 |
this.selected = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
789 |
if (this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
790 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
791 |
b.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
792 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
793 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
794 |
this.line.strokeWidth = this.options.edge_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
795 |
this._super("unselect");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
796 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
797 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
798 |
mousedown: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
799 |
if (_isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
800 |
this.renderer.unselectAll(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
801 |
this.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
802 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
803 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
804 |
mouseup: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
805 |
if (!this.renkan.read_only && this.renderer.is_dragging) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
806 |
this.from_representation.saveCoords(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
807 |
this.to_representation.saveCoords(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
808 |
this.from_representation.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
809 |
this.to_representation.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
810 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
811 |
if (!_isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
812 |
this.openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
813 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
814 |
this.model.trigger("clicked");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
815 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
816 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
817 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
818 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
819 |
paperShift: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
820 |
if (this.options.editor_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
821 |
if (!this.options.read_only) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
822 |
this.from_representation.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
823 |
this.to_representation.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
824 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
825 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
826 |
this.renderer.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
827 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
828 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
829 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
830 |
this._super("destroy");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
831 |
this.line.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
832 |
this.arrow.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
833 |
this.text.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
834 |
if (this.renderer.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
835 |
this.minimap_line.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
836 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
837 |
this.all_buttons.forEach(function(b) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
838 |
b.destroy(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
839 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
840 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
841 |
this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {
|
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
842 |
return _this === _edge; |
| 161 | 843 |
}); |
|
114
110f99eb417e
moved options to defaults.js and improved read-only switching
veltr
parents:
113
diff
changeset
|
844 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
845 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
846 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
847 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
848 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
849 |
var TempEdge = Renderer.TempEdge = Rkns.Utils.inherit(_BaseRepresentation); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
850 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
851 |
_(TempEdge.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
852 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
853 |
this.renderer.edge_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
854 |
this.type = "Temp-edge"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
855 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
856 |
var _color = (this.project.get("users").get(this.renkan.current_user) || _USER_PLACEHOLDER(this.renkan)).get("color");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
857 |
this.line = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
858 |
this.line.strokeColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
859 |
this.line.dashArray = [4, 2]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
860 |
this.line.strokeWidth = this.options.selected_edge_stroke_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
861 |
this.line.add([0,0],[0,0]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
862 |
this.line.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
863 |
this.arrow = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
864 |
this.arrow.fillColor = _color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
865 |
this.arrow.add( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
866 |
[ 0, 0 ], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
867 |
[ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
868 |
[ 0, this.options.edge_arrow_width ] |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
869 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
870 |
this.arrow.__representation = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
871 |
this.arrow_angle = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
872 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
873 |
redraw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
874 |
var _p0 = this.from_representation.paper_coords, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
875 |
_p1 = this.end_pos, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
876 |
_a = _p1.subtract(_p0).angle, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
877 |
_c = _p0.add(_p1).divide(2); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
878 |
this.line.segments[0].point = _p0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
879 |
this.line.segments[1].point = _p1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
880 |
this.arrow.rotate(_a - this.arrow_angle); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
881 |
this.arrow.position = _c; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
882 |
this.arrow_angle = _a; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
883 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
884 |
paperShift: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
885 |
if (!this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
886 |
this.renderer.removeRepresentation(_this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
887 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
888 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
889 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
890 |
this.end_pos = this.end_pos.add(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
891 |
var _hitResult = paper.project.hitTest(this.end_pos); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
892 |
this.renderer.findTarget(_hitResult); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
893 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
894 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
895 |
mouseup: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
896 |
var _hitResult = paper.project.hitTest(_event.point), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
897 |
_model = this.from_representation.model, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
898 |
_endDrag = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
899 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
900 |
var _target = _hitResult.item.__representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
901 |
if (_target.type.substr(0,4) === "Node") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
902 |
var _destmodel = _target.model || _target.source_representation.model; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
903 |
if (_model !== _destmodel) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
904 |
var _data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
905 |
id: Rkns.Utils.getUID('edge'),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
906 |
created_by: this.renkan.current_user, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
907 |
from: _model, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
908 |
to: _destmodel |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
909 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
910 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
911 |
this.project.addEdge(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
912 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
913 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
914 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
915 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
916 |
if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
917 |
_endDrag = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
918 |
this.renderer.is_dragging = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
919 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
920 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
921 |
if (_endDrag) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
922 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
923 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
924 |
this.renderer.removeRepresentation(this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
925 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
926 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
927 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
928 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
929 |
this.arrow.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
930 |
this.line.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
931 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
932 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
933 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
934 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
935 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
936 |
var _BaseEditor = Renderer._BaseEditor = Rkns.Utils.inherit(_BaseRepresentation); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
937 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
938 |
_(_BaseEditor.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
939 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
940 |
this.renderer.buttons_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
941 |
this.type = "editor"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
942 |
this.editor_block = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
943 |
var _pts = _(_.range(8)).map(function() {return [0,0];});
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
944 |
this.editor_block.add.apply(this.editor_block, _pts); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
945 |
this.editor_block.strokeWidth = this.options.tooltip_border_width; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
946 |
this.editor_block.strokeColor = this.options.tooltip_border_color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
947 |
this.editor_block.opacity = .8; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
948 |
this.editor_$ = $('<div>')
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
949 |
.appendTo(this.renderer.editor_$) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
950 |
.css({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
951 |
position: "absolute", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
952 |
opacity: .8 |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
953 |
}) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
954 |
.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
955 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
956 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
957 |
this.editor_block.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
958 |
this.editor_$.remove(); |
| 160 | 959 |
} |
| 161 | 960 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
961 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
962 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
963 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
964 |
var NodeEditor = Renderer.NodeEditor = Rkns.Utils.inherit(_BaseEditor); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
965 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
966 |
_(NodeEditor.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
967 |
template: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
968 |
'<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
969 |
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
970 |
+ '<% 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><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
971 |
+ '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
972 |
+ '<% 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><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
973 |
+ '<% 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>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
974 |
+ '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
975 |
+ '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
976 |
+ '<% 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><% }%>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
977 |
+ '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
978 |
+ '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
979 |
+ '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
980 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
981 |
readOnlyTemplate: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
982 |
'<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
983 |
+ '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
984 |
+ '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
985 |
+ '<% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
986 |
+ '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
987 |
+ '<% 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><%- shortenText(node.created_by_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
988 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
989 |
draw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
990 |
var _model = this.source_representation.model, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
991 |
_created_by = _model.get("created_by") || _USER_PLACEHOLDER(this.renkan),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
992 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
993 |
_image_placeholder = this.options.static_url + "img/image-placeholder.png", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
994 |
_size = (_model.get("size") || 0);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
995 |
this.editor_$ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
996 |
.html(_template({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
997 |
node: {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
998 |
has_creator: !!_model.get("created_by"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
999 |
title: _model.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1000 |
uri: _model.get("uri"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1001 |
short_uri: shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1002 |
description: _model.get("description"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1003 |
image: _model.get("image") || "",
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1004 |
image_placeholder: _image_placeholder, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1005 |
color: _model.get("color") || _created_by.get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1006 |
clip_path: _model.get("clip_path") || false,
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1007 |
created_by_color: _created_by.get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1008 |
created_by_title: _created_by.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1009 |
size: (_size > 0 ? "+" : "") + _size |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1010 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1011 |
renkan: this.renkan, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1012 |
options: this.options, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1013 |
shortenText: shortenText |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1014 |
})); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1015 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1016 |
var _this = this, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1017 |
closeEditor = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1018 |
_this.renderer.removeRepresentation(_this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1019 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1020 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1021 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1022 |
this.editor_$.find(".Rk-CloseX").click(closeEditor);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1023 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1024 |
this.editor_$.find(".Rk-Edit-Goto").click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1025 |
if (!_model.get("uri")) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1026 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1027 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1028 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1029 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1030 |
if (this.renderer.isEditable()) {
|
| 5 | 1031 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1032 |
var onFieldChange = _(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1033 |
_(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1034 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1035 |
var _data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1036 |
title: _this.editor_$.find(".Rk-Edit-Title").val()
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1037 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1038 |
if (_this.options.show_node_editor_uri) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1039 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1040 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1041 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1042 |
if (_this.options.show_node_editor_image) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1043 |
_data.image = _this.editor_$.find(".Rk-Edit-Image").val();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1044 |
_this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1045 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1046 |
if (_this.options.show_node_editor_description) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1047 |
_data.description = _this.editor_$.find(".Rk-Edit-Description").val();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1048 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1049 |
_model.set(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1050 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1051 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1052 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1053 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1054 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1055 |
}).defer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1056 |
}).throttle(500); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1057 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1058 |
this.editor_$.on("keyup", function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1059 |
if (_e.keyCode === 27) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1060 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1061 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1062 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1063 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1064 |
this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange);
|
| 4 | 1065 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1066 |
this.editor_$.find(".Rk-Edit-Image-File").change(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1067 |
if (this.files.length) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1068 |
var f = this.files[0], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1069 |
fr = new FileReader(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1070 |
if (f.type.substr(0,5) !== "image") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1071 |
alert(_this.renkan.translate("This file is not an image"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1072 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1073 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1074 |
if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1075 |
alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1076 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1077 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1078 |
fr.onload = function(e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1079 |
_this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1080 |
onFieldChange(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1081 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1082 |
fr.readAsDataURL(f); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1083 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1084 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1085 |
this.editor_$.find(".Rk-Edit-Title")[0].focus();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1086 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1087 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1088 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1089 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1090 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1091 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1092 |
_picker.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1093 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1094 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1095 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1096 |
_picker.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1097 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1098 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1099 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1100 |
_picker.find("li").hover(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1101 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1102 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1103 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1104 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1105 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1106 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1107 |
_this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || _USER_PLACEHOLDER(_this.renkan)).get("color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1108 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1109 |
).click(function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1110 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1111 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1112 |
_model.set("color", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1113 |
_picker.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1114 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1115 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1116 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1117 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1118 |
}); |
| 4 | 1119 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1120 |
var shiftSize = function(n) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1121 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1122 |
var _newsize = n+(_model.get("size") || 0);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1123 |
_this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1124 |
_model.set("size", _newsize);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1125 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1126 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1127 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1128 |
} |
| 160 | 1129 |
}; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1130 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1131 |
this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1132 |
shiftSize(-1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1133 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1134 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1135 |
this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1136 |
shiftSize(1); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1137 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1138 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1139 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1140 |
if (typeof this.source_representation.highlighted === "object") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1141 |
var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1142 |
this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1143 |
if (this.options.show_node_tooltip_description) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1144 |
this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1145 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1146 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1147 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1148 |
this.editor_$.find("img").load(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1149 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1150 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1151 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1152 |
redraw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1153 |
var _coords = this.source_representation.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1154 |
drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1155 |
this.editor_$.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1156 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1157 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1158 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1159 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1160 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1161 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1162 |
var EdgeEditor = Renderer.EdgeEditor = Rkns.Utils.inherit(_BaseEditor); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1163 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1164 |
_(EdgeEditor.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1165 |
template: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1166 |
'<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1167 |
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1168 |
+ '<% 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>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1169 |
+ '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1170 |
+ '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1171 |
+ '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1172 |
+ '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1173 |
+ '<% }) %><% }) %></select></p><% } } %>' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1174 |
+ '<% 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>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1175 |
+ '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1176 |
+ '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1177 |
+ '<% 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><%- shortenText(edge.from_title, 25) %></p>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1178 |
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1179 |
+ '<% 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><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1180 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1181 |
readOnlyTemplate: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1182 |
'<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1183 |
+ '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1184 |
+ '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1185 |
+ '<p><%-edge.description%></p>' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1186 |
+ '<% 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><%- shortenText(edge.from_title, 25) %></p>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1187 |
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1188 |
+ '<% 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><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1189 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1190 |
draw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1191 |
var _model = this.source_representation.model, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1192 |
_from_model = _model.get("from"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1193 |
_to_model = _model.get("to"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1194 |
_created_by = _model.get("created_by") || _USER_PLACEHOLDER(this.renkan),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1195 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1196 |
this.editor_$ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1197 |
.html(_template({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1198 |
edge: {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1199 |
has_creator: !!_model.get("created_by"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1200 |
title: _model.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1201 |
uri: _model.get("uri"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1202 |
short_uri: shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1203 |
description: _model.get("description"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1204 |
color: _model.get("color") || _created_by.get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1205 |
from_title: _from_model.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1206 |
to_title: _to_model.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1207 |
from_color: _from_model.get("color") || (_from_model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1208 |
to_color: _to_model.get("color") || (_to_model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1209 |
created_by_color: _created_by.get("color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1210 |
created_by_title: _created_by.get("title")
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1211 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1212 |
renkan: this.renkan, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1213 |
shortenText: shortenText, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1214 |
options: this.options |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1215 |
})); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1216 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1217 |
var _this = this, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1218 |
closeEditor = function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1219 |
_this.renderer.removeRepresentation(_this); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1220 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1221 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1222 |
this.editor_$.find(".Rk-CloseX").click(closeEditor);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1223 |
this.editor_$.find(".Rk-Edit-Goto").click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1224 |
if (!_model.get("uri")) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1225 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1226 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1227 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1228 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1229 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1230 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1231 |
var onFieldChange = _(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1232 |
_(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1233 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1234 |
var _data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1235 |
title: _this.editor_$.find(".Rk-Edit-Title").val()
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1236 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1237 |
if (_this.options.show_edge_editor_uri) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1238 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1239 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1240 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1241 |
_model.set(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1242 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1243 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1244 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1245 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1246 |
}).defer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1247 |
}).throttle(500); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1248 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1249 |
this.editor_$.on("keyup", function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1250 |
if (_e.keyCode === 27) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1251 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1252 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1253 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1254 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1255 |
this.editor_$.find("input").on("keyup change paste", onFieldChange);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1256 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1257 |
this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1258 |
var e = $(this), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1259 |
v = e.val(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1260 |
if (v) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1261 |
_this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text());
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1262 |
_this.editor_$.find(".Rk-Edit-URI").val(v);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1263 |
onFieldChange(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1264 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1265 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1266 |
this.editor_$.find(".Rk-Edit-Direction").click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1267 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1268 |
_model.set({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1269 |
from: _model.get("to"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1270 |
to: _model.get("from")
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1271 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1272 |
_this.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1273 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1274 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1275 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1276 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1277 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1278 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1279 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1280 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1281 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1282 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1283 |
_picker.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1284 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1285 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1286 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1287 |
_picker.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1288 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1289 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1290 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1291 |
_picker.find("li").hover(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1292 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1293 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1294 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1295 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1296 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1297 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1298 |
_this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || _USER_PLACEHOLDER(_this.renkan)).get("color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1299 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1300 |
).click(function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1301 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1302 |
if (_this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1303 |
_model.set("color", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1304 |
_picker.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1305 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1306 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1307 |
closeEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1308 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1309 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1310 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1311 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1312 |
redraw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1313 |
var _coords = this.source_representation.paper_coords; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1314 |
drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1315 |
this.editor_$.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1316 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1317 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1318 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1319 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1320 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1321 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1322 |
var _NodeButton = Renderer._NodeButton = Rkns.Utils.inherit(_BaseButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1323 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1324 |
_(_NodeButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1325 |
setSectorSize: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1326 |
var sectorInner = this.source_representation.circle_radius; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1327 |
if (sectorInner !== this.lastSectorInner) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1328 |
if (this.sector) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1329 |
this.sector.destroy(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1330 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1331 |
this.sector = this.renderer.drawSector( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1332 |
this, 1 + sectorInner, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1333 |
_NODE_BUTTON_WIDTH + sectorInner, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1334 |
this.startAngle, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1335 |
this.endAngle, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1336 |
1, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1337 |
this.imageName, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1338 |
this.renkan.translate(this.text) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1339 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1340 |
this.lastSectorInner = sectorInner; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1341 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1342 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1343 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1344 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1345 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1346 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1347 |
var NodeEditButton = Renderer.NodeEditButton = Rkns.Utils.inherit(_NodeButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1348 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1349 |
_(NodeEditButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1350 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1351 |
this.type = "Node-edit-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1352 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1353 |
this.startAngle = -135; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1354 |
this.endAngle = -45; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1355 |
this.imageName = "edit"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1356 |
this.text = "Edit"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1357 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1358 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1359 |
if (!this.renderer.is_dragging) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1360 |
this.source_representation.openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1361 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1362 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1363 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1364 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1365 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1366 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1367 |
var NodeRemoveButton = Renderer.NodeRemoveButton = Rkns.Utils.inherit(_NodeButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1368 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1369 |
_(NodeRemoveButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1370 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1371 |
this.type = "Node-remove-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1372 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1373 |
this.startAngle = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1374 |
this.endAngle = 90; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1375 |
this.imageName = "remove"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1376 |
this.text = "Remove"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1377 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1378 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1379 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1380 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1381 |
this.renderer.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1382 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1383 |
if (this.options.element_delete_delay) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1384 |
var delid = Rkns.Utils.getUID("delete");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1385 |
this.renderer.delete_list.push({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1386 |
id: delid, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1387 |
time: new Date().valueOf() + this.options.element_delete_delay |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1388 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1389 |
this.source_representation.model.set("delete_scheduled", delid);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1390 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1391 |
if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1392 |
this.project.removeNode(this.source_representation.model); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1393 |
} |
| 160 | 1394 |
} |
1395 |
} |
|
| 4 | 1396 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1397 |
}); |
| 5 | 1398 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1399 |
/* */ |
| 5 | 1400 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1401 |
var NodeRevertButton = Renderer.NodeRevertButton = Rkns.Utils.inherit(_NodeButton); |
| 5 | 1402 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1403 |
_(NodeRevertButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1404 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1405 |
this.type = "Node-revert-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1406 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1407 |
this.startAngle = -135; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1408 |
this.endAngle = 135; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1409 |
this.imageName = "revert"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1410 |
this.text = "Cancel deletion"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1411 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1412 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1413 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1414 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1415 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1416 |
this.source_representation.model.unset("delete_scheduled");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1417 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1418 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1419 |
}); |
| 159 | 1420 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1421 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1422 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1423 |
var NodeLinkButton = Renderer.NodeLinkButton = Rkns.Utils.inherit(_NodeButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1424 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1425 |
_(NodeLinkButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1426 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1427 |
this.type = "Node-link-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1428 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1429 |
this.startAngle = 90; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1430 |
this.endAngle = 180; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1431 |
this.imageName = "link"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1432 |
this.text = "Link to another node"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1433 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1434 |
mousedown: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1435 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1436 |
var _off = this.renderer.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1437 |
_point = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1438 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1439 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1440 |
]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1441 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1442 |
this.renderer.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1443 |
this.renderer.addTempEdge(this.source_representation, _point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1444 |
} |
| 194 | 1445 |
} |
1446 |
}); |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1447 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1448 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1449 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1450 |
var NodeEnlargeButton = Renderer.NodeEnlargeButton = Rkns.Utils.inherit(_NodeButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1451 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1452 |
_(NodeEnlargeButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1453 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1454 |
this.type = "Node-enlarge-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1455 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1456 |
this.startAngle = -45; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1457 |
this.endAngle = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1458 |
this.imageName = "enlarge"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1459 |
this.text = "Enlarge"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1460 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1461 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1462 |
var _newsize = 1 + (this.source_representation.model.get("size") || 0);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1463 |
this.source_representation.model.set("size", _newsize);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1464 |
this.source_representation.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1465 |
this.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1466 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1467 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1468 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1469 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1470 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1471 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1472 |
var NodeShrinkButton = Renderer.NodeShrinkButton = Rkns.Utils.inherit(_NodeButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1473 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1474 |
_(NodeShrinkButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1475 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1476 |
this.type = "Node-shrink-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1477 |
this.lastSectorInner = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1478 |
this.startAngle = -180; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1479 |
this.endAngle = -135; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1480 |
this.imageName = "shrink"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1481 |
this.text = "Shrink"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1482 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1483 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1484 |
var _newsize = -1 + (this.source_representation.model.get("size") || 0);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1485 |
this.source_representation.model.set("size", _newsize);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1486 |
this.source_representation.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1487 |
this.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1488 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1489 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1490 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1491 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1492 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1493 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1494 |
var EdgeEditButton = Renderer.EdgeEditButton = Rkns.Utils.inherit(_BaseButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1495 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1496 |
_(EdgeEditButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1497 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1498 |
this.type = "Edge-edit-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1499 |
this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1500 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1501 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1502 |
if (!this.renderer.is_dragging) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1503 |
this.source_representation.openEditor(); |
|
114
110f99eb417e
moved options to defaults.js and improved read-only switching
veltr
parents:
113
diff
changeset
|
1504 |
} |
| 194 | 1505 |
} |
1506 |
}); |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1507 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1508 |
/* */ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1509 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1510 |
var EdgeRemoveButton = Renderer.EdgeRemoveButton = Rkns.Utils.inherit(_BaseButton); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1511 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1512 |
_(EdgeRemoveButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1513 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1514 |
this.type = "Edge-remove-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1515 |
this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1516 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1517 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1518 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1519 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1520 |
this.renderer.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1521 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1522 |
if (this.options.element_delete_delay) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1523 |
var delid = Rkns.Utils.getUID("delete");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1524 |
this.renderer.delete_list.push({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1525 |
id: delid, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1526 |
time: new Date().valueOf() + this.options.element_delete_delay |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1527 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1528 |
this.source_representation.model.set("delete_scheduled", delid);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1529 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1530 |
if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1531 |
this.project.removeEdge(this.source_representation.model); |
| 173 | 1532 |
} |
| 160 | 1533 |
} |
| 159 | 1534 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1535 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1536 |
}); |
| 7 | 1537 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1538 |
/* */ |
| 7 | 1539 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1540 |
var EdgeRevertButton = Renderer.EdgeRevertButton = Rkns.Utils.inherit(_BaseButton); |
| 132 | 1541 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1542 |
_(EdgeRevertButton.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1543 |
_init: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1544 |
this.type = "Edge-revert-button"; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1545 |
this.sector = this.renderer.drawSector(this, _EDGE_BUTTON_INNER, _EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1546 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1547 |
mouseup: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1548 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1549 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1550 |
if (this.renderer.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1551 |
this.source_representation.model.unset("delete_scheduled");
|
|
174
756cfa6570d2
Setting element_delete_delay now shows remove confirm dialog
veltr
parents:
173
diff
changeset
|
1552 |
} |
|
756cfa6570d2
Setting element_delete_delay now shows remove confirm dialog
veltr
parents:
173
diff
changeset
|
1553 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1554 |
}); |
| 7 | 1555 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1556 |
/* */ |
| 11 | 1557 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1558 |
var MiniFrame = Renderer.MiniFrame = Rkns.Utils.inherit(_BaseRepresentation); |
| 11 | 1559 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1560 |
_(MiniFrame.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1561 |
paperShift: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1562 |
this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1563 |
this.renderer.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1564 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1565 |
mouseup: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1566 |
this.renderer.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1567 |
this.renderer.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1568 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1569 |
}); |
| 132 | 1570 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1571 |
/* */ |
| 15 | 1572 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1573 |
var Scene = Renderer.Scene = function(_renkan) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1574 |
this.renkan = _renkan; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1575 |
this.$ = $(".Rk-Render");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1576 |
this.representations = []; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1577 |
this.$.html(this.template(_renkan)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1578 |
this.onStatusChange(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1579 |
this.canvas_$ = this.$.find(".Rk-Canvas");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1580 |
this.labels_$ = this.$.find(".Rk-Labels");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1581 |
this.editor_$ = this.$.find(".Rk-Editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1582 |
this.notif_$ = this.$.find(".Rk-Notifications");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1583 |
paper.setup(this.canvas_$[0]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1584 |
this.scale = 1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1585 |
this.initialScale = 1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1586 |
this.offset = paper.view.center; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1587 |
this.totalScroll = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1588 |
this.mouse_down = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1589 |
this.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1590 |
this.selected_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1591 |
this.edge_layer = new paper.Layer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1592 |
this.node_layer = new paper.Layer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1593 |
this.buttons_layer = new paper.Layer(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1594 |
this.delete_list = []; |
| 70 | 1595 |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1596 |
if (_renkan.options.show_minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1597 |
this.minimap = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1598 |
background_layer: new paper.Layer(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1599 |
edge_layer: new paper.Layer(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1600 |
node_layer: new paper.Layer(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1601 |
node_group: new paper.Group(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1602 |
size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height ) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1603 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1604 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1605 |
this.minimap.background_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1606 |
this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1607 |
this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4])); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1608 |
this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1609 |
this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1610 |
this.minimap.rectangle.strokeWidth = 4; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1611 |
this.minimap.offset = new paper.Point(this.minimap.size.divide(2)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1612 |
this.minimap.scale = .1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1613 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1614 |
this.minimap.node_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1615 |
this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1616 |
this.minimap.node_group.addChild(this.minimap.cliprectangle); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1617 |
this.minimap.node_group.clipped = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1618 |
this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1619 |
this.minimap.node_group.addChild(this.minimap.miniframe); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1620 |
this.minimap.miniframe.fillColor = '#c0c0ff'; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1621 |
this.minimap.miniframe.opacity = .3; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1622 |
this.minimap.miniframe.strokeColor = '#000080'; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1623 |
this.minimap.miniframe.strokeWidth = 3; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1624 |
this.minimap.miniframe.__representation = new MiniFrame(this, null); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1625 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1626 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1627 |
this.throttledPaperDraw = _(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1628 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1629 |
}).throttle(100); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1630 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1631 |
this.bundles = []; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1632 |
this.click_mode = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1633 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1634 |
var _this = this, |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1635 |
_allowScroll = true, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1636 |
_originalScale = 1, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1637 |
_zooming = false, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1638 |
_lastTapX = 0, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1639 |
_lastTapY = 0; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1640 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1641 |
this.image_cache = {};
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1642 |
this.icon_cache = {};
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1643 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1644 |
['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1645 |
var img = new Image(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1646 |
img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1647 |
_this.icon_cache[imgname] = img; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1648 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1649 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1650 |
var throttledMouseMove = _.throttle(function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1651 |
_this.onMouseMove(_event, _isTouch); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1652 |
}, _MOUSEMOVE_RATE); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1653 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1654 |
this.canvas_$.on({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1655 |
mousedown: function(_event) {
|
|
211
d87f6bdee43d
upgrade libs + add no minified versions of libs + improve build + allow disabling zoom on scroll
ymh <ymh.work@gmail.com>
parents:
207
diff
changeset
|
1656 |
_event.preventDefault(); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1657 |
_this.onMouseDown(_event, false); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1658 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1659 |
mousemove: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1660 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1661 |
throttledMouseMove(_event, false); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1662 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1663 |
mouseup: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1664 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1665 |
_this.onMouseUp(_event, false); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1666 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1667 |
mousewheel: function(_event, _delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1668 |
if(_renkan.options.zoom_on_scroll) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1669 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1670 |
if (_allowScroll) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1671 |
_this.onScroll(_event, _delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1672 |
} |
|
211
d87f6bdee43d
upgrade libs + add no minified versions of libs + improve build + allow disabling zoom on scroll
ymh <ymh.work@gmail.com>
parents:
207
diff
changeset
|
1673 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1674 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1675 |
touchstart: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1676 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1677 |
var _touches = _event.originalEvent.touches[0]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1678 |
if ( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1679 |
_renkan.options.allow_double_click |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1680 |
&& new Date() - _lastTap < _DOUBLETAP_DELAY |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1681 |
&& ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < _DOUBLETAP_DISTANCE ) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1682 |
) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1683 |
_lastTap = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1684 |
_this.onDoubleClick(_touches); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1685 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1686 |
_lastTap = new Date(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1687 |
_lastTapX = _touches.pageX; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1688 |
_lastTapY = _touches.pageY; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1689 |
_originalScale = _this.scale; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1690 |
_zooming = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1691 |
_this.onMouseDown(_touches, true); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1692 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1693 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1694 |
touchmove: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1695 |
_event.preventDefault(); |
| 160 | 1696 |
_lastTap = 0; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1697 |
if (_event.originalEvent.touches.length == 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1698 |
_this.onMouseMove(_event.originalEvent.touches[0], true); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1699 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1700 |
if (!_zooming) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1701 |
_this.onMouseUp(_event.originalEvent.touches[0], true); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1702 |
_this.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1703 |
_this.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1704 |
_zooming = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1705 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1706 |
if (_event.originalEvent.scale === "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1707 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1708 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1709 |
var _newScale = _event.originalEvent.scale * _originalScale, |
| 160 | 1710 |
_scaleRatio = _newScale / _this.scale, |
1711 |
_newOffset = new paper.Point([ |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1712 |
_this.canvas_$.width(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1713 |
_this.canvas_$.height() |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1714 |
]).multiply( .5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio )); |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
1715 |
_this.setScale(_newScale, _newOffset); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1716 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1717 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1718 |
touchend: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1719 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1720 |
_this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1721 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1722 |
dblclick: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1723 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1724 |
if (_renkan.options.allow_double_click) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1725 |
_this.onDoubleClick(_event); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1726 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1727 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1728 |
mouseleave: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1729 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1730 |
_this.onMouseUp(_event, false); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1731 |
_this.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1732 |
_this.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1733 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1734 |
dragover: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1735 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1736 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1737 |
dragenter: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1738 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1739 |
_allowScroll = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1740 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1741 |
dragleave: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1742 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1743 |
_allowScroll = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1744 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1745 |
drop: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1746 |
_event.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1747 |
_allowScroll = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1748 |
var res = {};
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1749 |
_(_event.originalEvent.dataTransfer.types).each(function(t) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1750 |
try {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1751 |
res[t] = _event.originalEvent.dataTransfer.getData(t); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1752 |
} catch(e) {}
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1753 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1754 |
var text = _event.originalEvent.dataTransfer.getData("Text");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1755 |
if (typeof text === "string") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1756 |
switch(text[0]) {
|
| 160 | 1757 |
case "{":
|
1758 |
case "[": |
|
1759 |
try {
|
|
1760 |
var data = JSON.parse(text); |
|
1761 |
_(res).extend(data); |
|
1762 |
} |
|
1763 |
catch(e) {
|
|
1764 |
if (!res["text/plain"]) {
|
|
1765 |
res["text/plain"] = text; |
|
1766 |
} |
|
1767 |
} |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1768 |
break; |
| 160 | 1769 |
case "<": |
1770 |
if (!res["text/html"]) {
|
|
1771 |
res["text/html"] = text; |
|
1772 |
} |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1773 |
break; |
| 160 | 1774 |
default: |
1775 |
if (!res["text/plain"]) {
|
|
1776 |
res["text/plain"] = text; |
|
1777 |
} |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1778 |
} |
| 160 | 1779 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1780 |
var url = _event.originalEvent.dataTransfer.getData("URL");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1781 |
if (url && !res["text/uri-list"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1782 |
res["text/uri-list"] = url; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1783 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1784 |
_this.dropData(res, _event.originalEvent); |
| 160 | 1785 |
} |
| 190 | 1786 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1787 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1788 |
var bindClick = function(selector, fname) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1789 |
_this.$.find(selector).click(function(evt) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1790 |
_this[fname](evt); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1791 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1792 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1793 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1794 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1795 |
bindClick(".Rk-ZoomOut", "zoomOut");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1796 |
bindClick(".Rk-ZoomIn", "zoomIn");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1797 |
bindClick(".Rk-ZoomFit", "autoScale");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1798 |
this.$.find(".Rk-ZoomSave").click( function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1799 |
_this.renkan.project.set("views", [{id:Rkns.Utils.getUID('view'), zoom_level:_this.scale, offset_x:_this.offset.x, offset_y:_this.offset.y}]); // Save scale
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1800 |
_this.$.find(".Rk-ZoomSetSaved").show();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1801 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1802 |
this.$.find(".Rk-ZoomSetSaved").click( function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1803 |
var view = _this.renkan.project.get("views")[0];
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1804 |
_this.setScale(view.zoom_level, new paper.Point(view.offset_x, view.offset_y)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1805 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1806 |
if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1807 |
this.$.find(".Rk-ZoomSetSaved").show();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1808 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1809 |
this.$.find(".Rk-CurrentUser").mouseenter(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1810 |
function() { _this.$.find(".Rk-UserList").slideDown(); }
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1811 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1812 |
this.$.find(".Rk-Users").mouseleave(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1813 |
function() { _this.$.find(".Rk-UserList").slideUp(); }
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1814 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1815 |
bindClick(".Rk-FullScreen-Button", "fullScreen");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1816 |
bindClick(".Rk-AddNode-Button", "addNodeBtn");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1817 |
bindClick(".Rk-AddEdge-Button", "addEdgeBtn");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1818 |
bindClick(".Rk-Save-Button", "save");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1819 |
bindClick(".Rk-Open-Button", "open");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1820 |
this.$.find(".Rk-Bookmarklet-Button")
|
| 187 | 1821 |
.attr("href","javascript:" + _BOOKMARKLET_CODE(_renkan))
|
| 160 | 1822 |
.click(function(){
|
1823 |
_this.notif_$ |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1824 |
.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."))
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1825 |
.fadeIn() |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1826 |
.delay(5000) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1827 |
.fadeOut(); |
| 160 | 1828 |
return false; |
1829 |
}); |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1830 |
this.$.find(".Rk-TopBar-Button").mouseover(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1831 |
$(this).find(".Rk-TopBar-Tooltip").show();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1832 |
}).mouseout(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1833 |
$(this).find(".Rk-TopBar-Tooltip").hide();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1834 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1835 |
bindClick(".Rk-Fold-Bins", "foldBins");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1836 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1837 |
paper.view.onResize = function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1838 |
// Because of paper bug which does not calculate the good height (and width a fortiori) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1839 |
// We have to update manually the canvas's height |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1840 |
paper.view._viewSize.height = _event.size.height = _this.canvas_$.parent().height(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1841 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1842 |
if (_this.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1843 |
_this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1844 |
_this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4])); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1845 |
_this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size); |
|
62
f9019462465a
Publishing code is now same as Editing code with renkan.read_only = true
veltr
parents:
57
diff
changeset
|
1846 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1847 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1848 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1849 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1850 |
var _thRedraw = _.throttle(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1851 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1852 |
},50); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1853 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1854 |
this.addRepresentations("Node", this.renkan.project.get("nodes"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1855 |
this.addRepresentations("Edge", this.renkan.project.get("edges"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1856 |
this.renkan.project.on("change:title", function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1857 |
_this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1858 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1859 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1860 |
this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1861 |
_renkan.project.set({"title": $(this).val()});
|
| 163 | 1862 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1863 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1864 |
var _thRedrawUsers = _.throttle(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1865 |
_this.redrawUsers(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1866 |
}, 100); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1867 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1868 |
_thRedrawUsers(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1869 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1870 |
this.renkan.project.on("add:users remove:users", _thRedrawUsers);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1871 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1872 |
this.renkan.project.on("add:nodes", function(_node) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1873 |
_this.addRepresentation("Node", _node);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1874 |
_thRedraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1875 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1876 |
this.renkan.project.on("add:edges", function(_edge) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1877 |
_this.addRepresentation("Edge", _edge);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1878 |
_thRedraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1879 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1880 |
this.renkan.project.on("change:title", function(_model, _title) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1881 |
var el = _this.$.find(".Rk-PadTitle");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1882 |
if (el.is("input")) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1883 |
if (el.val() !== _title) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1884 |
el.val(_title); |
| 195 | 1885 |
} |
| 196 | 1886 |
} else {
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1887 |
el.text(_title); |
| 196 | 1888 |
} |
1889 |
}); |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1890 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1891 |
if (_renkan.options.size_bug_fix) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1892 |
var _delay = ( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1893 |
typeof _renkan.options.size_bug_fix === "number" |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1894 |
? _renkan.options.size_bug_fix |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1895 |
: 500 |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1896 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1897 |
window.setTimeout( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1898 |
function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1899 |
_this.fixSize(true); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1900 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1901 |
_delay |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1902 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1903 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1904 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1905 |
if (_renkan.options.force_resize) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1906 |
$(window).resize(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1907 |
_this.fixSize(false); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1908 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1909 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1910 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1911 |
if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1912 |
var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1913 |
$cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1914 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1915 |
$cpwrapper.hover( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1916 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1917 |
if (_this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1918 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1919 |
$cplist.show(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1920 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1921 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1922 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1923 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1924 |
$cplist.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1925 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1926 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1927 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1928 |
$cplist.find("li").mouseenter(
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1929 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1930 |
if (_this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1931 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1932 |
_this.$.find(".Rk-CurrentUser-Color").css("background", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1933 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1934 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1935 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1936 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1937 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1938 |
if (_renkan.options.show_search_field) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1939 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1940 |
var lastval = ''; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1941 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1942 |
this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1943 |
var $this = $(this), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1944 |
val = $this.val(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1945 |
if (val === lastval) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1946 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1947 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1948 |
lastval = val; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1949 |
if (val.length < 2) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1950 |
_renkan.project.get("nodes").each(function(n) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1951 |
_this.getRepresentationByModel(n).unhighlight(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1952 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1953 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1954 |
var rxs = Rkns.Utils.regexpFromTextOrArray(val); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1955 |
_renkan.project.get("nodes").each(function(n) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1956 |
if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1957 |
_this.getRepresentationByModel(n).highlight(rxs); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1958 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1959 |
_this.getRepresentationByModel(n).unhighlight(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1960 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1961 |
}); |
| 161 | 1962 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1963 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1964 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1965 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1966 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1967 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1968 |
window.setInterval(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1969 |
var _now = new Date().valueOf(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1970 |
_this.delete_list.forEach(function(d) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1971 |
if (_now >= d.time) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1972 |
var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id});
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1973 |
if (el) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1974 |
project.removeNode(el); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1975 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1976 |
el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1977 |
if (el) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1978 |
project.removeEdge(el); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1979 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1980 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1981 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1982 |
_this.delete_list = _this.delete_list.filter(function(d) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1983 |
return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1984 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1985 |
}, 500); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1986 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1987 |
if (this.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1988 |
window.setInterval(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1989 |
_this.rescaleMinimap(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1990 |
}, 2000); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1991 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1992 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1993 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1994 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1995 |
_(Scene.prototype).extend({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1996 |
template: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1997 |
'<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1998 |
+ '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
1999 |
+ '<% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2000 |
+ '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2001 |
+ '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2002 |
+ '<%- translate(options.home_button_title) %></div></div></a><% } %>' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2003 |
+ '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2004 |
+ '<% if (options.editor_mode) { %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2005 |
+ '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2006 |
+ '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2007 |
+ '<% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2008 |
+ '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2009 |
+ '<% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2010 |
+ '<% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2011 |
+ '<% if (options.show_bookmarklet) { %><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-Contents">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2012 |
+ '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2013 |
+ '<div class="Rk-TopBar-Separator"></div><% }; if (options.show_search_field) { %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2014 |
+ '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2015 |
+ '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2016 |
+ '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2017 |
+ '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2018 |
+ '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2019 |
+ '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2020 |
+ '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>'
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2021 |
+ '</div></div>' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2022 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2023 |
fixSize: function(_autoscale) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2024 |
var w = this.$.width(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2025 |
h = this.$.height(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2026 |
if (this.renkan.options.show_top_bar) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2027 |
h -= this.$.find(".Rk-TopBar").height();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2028 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2029 |
this.canvas_$.attr({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2030 |
width: w, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2031 |
height: h |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2032 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2033 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2034 |
paper.view.viewSize = new paper.Size([w, h]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2035 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2036 |
if (_autoscale) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2037 |
// If _autoscale, we get the initial view (zoom+offset) set in the project datas. |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2038 |
if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2039 |
this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2040 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2041 |
else{
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2042 |
this.autoScale(); |
| 161 | 2043 |
} |
2044 |
} |
|
| 159 | 2045 |
}, |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2046 |
drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2047 |
var _options = this.renkan.options, |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2048 |
_startRads = _startAngle * Math.PI / 180, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2049 |
_endRads = _endAngle * Math.PI / 180, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2050 |
_img = this.icon_cache[_imgname], |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2051 |
_startdx = - Math.sin(_startRads), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2052 |
_startdy = Math.cos(_startRads), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2053 |
_startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2054 |
_startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2055 |
_startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2056 |
_startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2057 |
_enddx = - Math.sin(_endRads), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2058 |
_enddy = Math.cos(_endRads), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2059 |
_endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2060 |
_endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2061 |
_endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2062 |
_endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2063 |
_centerR = (_inR + _outR)/2, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2064 |
_centerRads = (_startRads + _endRads) / 2, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2065 |
_centerX = Math.cos(_centerRads) * _centerR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2066 |
_centerY = Math.sin(_centerRads) * _centerR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2067 |
_centerXIn = Math.cos(_centerRads) * _inR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2068 |
_centerXOut = Math.cos(_centerRads) * _outR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2069 |
_centerYIn = Math.sin(_centerRads) * _inR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2070 |
_centerYOut = Math.sin(_centerRads) * _outR, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2071 |
_textX = Math.cos(_centerRads) * (_outR + 3), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2072 |
_textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2073 |
this.buttons_layer.activate(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2074 |
var _path = new paper.Path(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2075 |
_path.add([_startXIn, _startYIn]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2076 |
_path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2077 |
_path.lineTo([_endXOut, _endYOut]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2078 |
_path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2079 |
_path.fillColor = _options.buttons_background; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2080 |
_path.opacity = .5; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2081 |
_path.closed = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2082 |
_path.__representation = _repr; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2083 |
var _text = new paper.PointText(_textX,_textY); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2084 |
_text.characterStyle = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2085 |
fontSize: _options.buttons_label_font_size, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2086 |
fillColor: _options.buttons_label_color |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2087 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2088 |
if (_textX > 2) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2089 |
_text.paragraphStyle.justification = 'left'; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2090 |
} else if (_textX < -2) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2091 |
_text.paragraphStyle.justification = 'right'; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2092 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2093 |
_text.paragraphStyle.justification = 'center'; |
| 159 | 2094 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2095 |
_text.visible = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2096 |
var _visible = false, |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2097 |
_restPos = new paper.Point(-200, -200), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2098 |
_grp = new paper.Group([_path, _text]), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2099 |
_delta = _grp.position, |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2100 |
_imgdelta = new paper.Point([_centerX, _centerY]), |
|
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2101 |
_currentPos = new paper.Point(0,0); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2102 |
_text.content = _caption; |
| 159 | 2103 |
_grp.visible = false; |
2104 |
_grp.position = _restPos; |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2105 |
var _res = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2106 |
show: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2107 |
_visible = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2108 |
_grp.position = _currentPos.add(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2109 |
_grp.visible = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2110 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2111 |
moveTo: function(_point) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2112 |
_currentPos = _point; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2113 |
if (_visible) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2114 |
_grp.position = _point.add(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2115 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2116 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2117 |
hide: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2118 |
_visible = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2119 |
_grp.visible = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2120 |
_grp.position = _restPos; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2121 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2122 |
select: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2123 |
_path.opacity = .8; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2124 |
_text.visible = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2125 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2126 |
unselect: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2127 |
_path.opacity = .5; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2128 |
_text.visible = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2129 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2130 |
destroy: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2131 |
_grp.remove(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2132 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2133 |
}; |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2134 |
var showImage = function() {
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2135 |
var _raster = new paper.Raster(_img); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2136 |
_raster.position = _imgdelta.add(_grp.position).subtract(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2137 |
_raster.locked = true; // Disable mouse events on icon |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2138 |
_grp.addChild(_raster); |
|
278
b45dda454dd6
remove as much warnings as possible.
ymh <ymh.work@gmail.com>
parents:
277
diff
changeset
|
2139 |
}; |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2140 |
if (_img.width) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2141 |
showImage(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2142 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2143 |
$(_img).on("load",showImage);
|
| 31 | 2144 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2145 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2146 |
return _res; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2147 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2148 |
addToBundles: function(_edgeRepr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2149 |
var _bundle = _(this.bundles).find(function(_bundle) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2150 |
return ( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2151 |
( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2152 |
|| ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation ) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2153 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2154 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2155 |
if (typeof _bundle !== "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2156 |
_bundle.edges.push(_edgeRepr); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2157 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2158 |
_bundle = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2159 |
from: _edgeRepr.from_representation, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2160 |
to: _edgeRepr.to_representation, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2161 |
edges: [ _edgeRepr ], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2162 |
getPosition: function(_er) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2163 |
var _dir = (_er.from_representation === this.from) ? 1 : -1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2164 |
return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 ); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2165 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2166 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2167 |
this.bundles.push(_bundle); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2168 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2169 |
return _bundle; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2170 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2171 |
isEditable: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2172 |
return (this.renkan.options.editor_mode && !this.renkan.read_only); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2173 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2174 |
onStatusChange: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2175 |
var savebtn = this.$.find(".Rk-Save-Button"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2176 |
tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2177 |
if (this.renkan.read_only) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2178 |
savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2179 |
tip.text(this.renkan.translate("Connection lost"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2180 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2181 |
if (this.renkan.options.snapshot_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2182 |
savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2183 |
tip.text(this.renkan.translate("Save Project"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2184 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2185 |
savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2186 |
tip.text(this.renkan.translate("Auto-save enabled"));
|
| 198 | 2187 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2188 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2189 |
this.redrawUsers(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2190 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2191 |
setScale: function(_newScale, _offset) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2192 |
if ((_newScale/this.initialScale) > _MIN_SCALE && (_newScale/this.initialScale) < _MAX_SCALE) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2193 |
this.scale = _newScale; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2194 |
if (_offset) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2195 |
this.offset = _offset; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2196 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2197 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2198 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2199 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2200 |
autoScale: function(force_view) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2201 |
var nodes = this.renkan.project.get("nodes");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2202 |
if (nodes.length > 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2203 |
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2204 |
_yy = nodes.map(function(_node) { return _node.get("position").y; }),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2205 |
_minx = Math.min.apply(Math, _xx), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2206 |
_miny = Math.min.apply(Math, _yy), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2207 |
_maxx = Math.max.apply(Math, _xx), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2208 |
_maxy = Math.max.apply(Math, _yy); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2209 |
var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2210 |
this.initialScale = _scale; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2211 |
// Override calculated scale if asked |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2212 |
if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset_x)>0 && parseFloat(force_view.offset_y)>0){
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2213 |
this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset_x), parseFloat(force_view.offset_y))); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2214 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2215 |
else{
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2216 |
this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); |
| 198 | 2217 |
} |
| 195 | 2218 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2219 |
if (nodes.length === 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2220 |
this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2221 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2222 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2223 |
redrawMiniframe: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2224 |
var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2225 |
bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2226 |
this.minimap.miniframe.fitBounds(topleft, bottomright); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2227 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2228 |
rescaleMinimap: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2229 |
var nodes = this.renkan.project.get("nodes");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2230 |
if (nodes.length > 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2231 |
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2232 |
_yy = nodes.map(function(_node) { return _node.get("position").y; }),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2233 |
_minx = Math.min.apply(Math, _xx), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2234 |
_miny = Math.min.apply(Math, _yy), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2235 |
_maxx = Math.max.apply(Math, _xx), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2236 |
_maxy = Math.max.apply(Math, _yy); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2237 |
var _scale = Math.min( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2238 |
this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2239 |
this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2240 |
( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2241 |
( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2242 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2243 |
this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2244 |
this.minimap.scale = _scale; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2245 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2246 |
if (nodes.length === 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2247 |
this.minimap.scale = .1; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2248 |
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));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2249 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2250 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2251 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2252 |
toPaperCoords: function(_point) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2253 |
return _point.multiply(this.scale).add(this.offset); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2254 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2255 |
toMinimapCoords: function(_point) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2256 |
return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2257 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2258 |
toModelCoords: function(_point) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2259 |
return _point.subtract(this.offset).divide(this.scale); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2260 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2261 |
addRepresentation: function(_type, _model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2262 |
var _repr = new Renderer[_type](this, _model); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2263 |
this.representations.push(_repr); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2264 |
return _repr; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2265 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2266 |
addRepresentations: function(_type, _collection) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2267 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2268 |
_collection.forEach(function(_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2269 |
_this.addRepresentation(_type, _model); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2270 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2271 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2272 |
userTemplate: _.template( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2273 |
'<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>' |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2274 |
), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2275 |
redrawUsers: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2276 |
if (!this.renkan.options.show_user_list) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2277 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2278 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2279 |
var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2280 |
ulistHtml = '', |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2281 |
$userpanel = this.$.find(".Rk-Users"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2282 |
$name = $userpanel.find(".Rk-CurrentUser-Name"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2283 |
$cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2284 |
$colorsquare = $userpanel.find(".Rk-CurrentUser-Color"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2285 |
_this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2286 |
$name.off("click").text(this.renkan.translate("<unknown user>"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2287 |
$cpitems.off("mouseleave click");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2288 |
allUsers.forEach(function(_user) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2289 |
if (_user.get("_id") === _this.renkan.current_user) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2290 |
$name.text(_user.get("title"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2291 |
$colorsquare.css("background", _user.get("color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2292 |
if (_this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2293 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2294 |
if (_this.renkan.options.user_name_editable) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2295 |
$name.click(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2296 |
var $this = $(this), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2297 |
$input = $('<input>').val(_user.get("title")).blur(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2298 |
_user.set("title", $(this).val());
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2299 |
_this.redrawUsers(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2300 |
_this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2301 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2302 |
$this.empty().html($input); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2303 |
$input.select(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2304 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2305 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2306 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2307 |
if (_this.renkan.options.user_color_editable) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2308 |
$cpitems.click( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2309 |
function(_e) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2310 |
_e.preventDefault(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2311 |
if (_this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2312 |
_user.set("color", $(this).attr("data-color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2313 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2314 |
$(this).parent().hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2315 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2316 |
).mouseleave(function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2317 |
$colorsquare.css("background", _user.get("color"));
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2318 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2319 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2320 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2321 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2322 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2323 |
ulistHtml += _this.userTemplate({
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2324 |
name: _user.get("title"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2325 |
background: _user.get("color")
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2326 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2327 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2328 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2329 |
$userpanel.find(".Rk-UserList").html(ulistHtml);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2330 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2331 |
removeRepresentation: function(_representation) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2332 |
_representation.destroy(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2333 |
this.representations = _(this.representations).reject( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2334 |
function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2335 |
return _repr == _representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2336 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2337 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2338 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2339 |
getRepresentationByModel: function(_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2340 |
if (!_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2341 |
return undefined; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2342 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2343 |
return _(this.representations).find(function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2344 |
return _repr.model === _model; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2345 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2346 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2347 |
removeRepresentationsOfType: function(_type) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2348 |
var _representations = _(this.representations).filter(function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2349 |
return _repr.type == _type; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2350 |
}), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2351 |
_this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2352 |
_(_representations).each(function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2353 |
_this.removeRepresentation(_repr); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2354 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2355 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2356 |
highlightModel: function(_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2357 |
var _repr = this.getRepresentationByModel(_model); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2358 |
if (_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2359 |
_repr.highlight(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2360 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2361 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2362 |
unhighlightAll: function(_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2363 |
_(this.representations).each(function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2364 |
_repr.unhighlight(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2365 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2366 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2367 |
unselectAll: function(_model) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2368 |
_(this.representations).each(function(_repr) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2369 |
_repr.unselect(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2370 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2371 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2372 |
redraw: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2373 |
_(this.representations).each(function(_representation) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2374 |
_representation.redraw(true); |
| 195 | 2375 |
}); |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2376 |
if (this.minimap) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2377 |
this.redrawMiniframe(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2378 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2379 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2380 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2381 |
addTempEdge: function(_from, _point) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2382 |
var _tmpEdge = this.addRepresentation("TempEdge",null);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2383 |
_tmpEdge.end_pos = _point; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2384 |
_tmpEdge.from_representation = _from; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2385 |
_tmpEdge.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2386 |
this.click_target = _tmpEdge; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2387 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2388 |
findTarget: function(_hitResult) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2389 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2390 |
var _newTarget = _hitResult.item.__representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2391 |
if (this.selected_target !== _hitResult.item.__representation) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2392 |
if (this.selected_target) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2393 |
this.selected_target.unselect(_newTarget); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2394 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2395 |
_newTarget.select(this.selected_target); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2396 |
this.selected_target = _newTarget; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2397 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2398 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2399 |
if (this.selected_target) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2400 |
this.selected_target.unselect(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2401 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2402 |
this.selected_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2403 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2404 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2405 |
paperShift: function(_delta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2406 |
this.offset = this.offset.add(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2407 |
this.redraw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2408 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2409 |
onMouseMove: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2410 |
var _off = this.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2411 |
_point = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2412 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2413 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2414 |
]), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2415 |
_delta = _point.subtract(this.last_point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2416 |
this.last_point = _point; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2417 |
if (!this.is_dragging && this.mouse_down && _delta.length > _MIN_DRAG_DISTANCE) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2418 |
this.is_dragging = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2419 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2420 |
var _hitResult = paper.project.hitTest(_point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2421 |
if (this.is_dragging) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2422 |
if (this.click_target && typeof this.click_target.paperShift === "function") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2423 |
this.click_target.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2424 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2425 |
this.paperShift(_delta); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2426 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2427 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2428 |
this.findTarget(_hitResult); |
| 4 | 2429 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2430 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2431 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2432 |
onMouseDown: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2433 |
var _off = this.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2434 |
_point = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2435 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2436 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2437 |
]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2438 |
this.last_point = _point; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2439 |
this.mouse_down = true; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2440 |
if (!this.click_target || this.click_target.type !== "Temp-edge") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2441 |
this.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2442 |
this.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2443 |
var _hitResult = paper.project.hitTest(_point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2444 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2445 |
this.click_target = _hitResult.item.__representation; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2446 |
this.click_target.mousedown(_event, _isTouch); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2447 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2448 |
this.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2449 |
if (this.isEditable() && this.click_mode === _CLICKMODE_ADDNODE) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2450 |
var _coords = this.toModelCoords(_point), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2451 |
_data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2452 |
id: Rkns.Utils.getUID('node'),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2453 |
created_by: this.renkan.current_user, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2454 |
position: {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2455 |
x: _coords.x, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2456 |
y: _coords.y |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2457 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2458 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2459 |
_node = this.renkan.project.addNode(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2460 |
this.getRepresentationByModel(_node).openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2461 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2462 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2463 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2464 |
if (this.click_mode) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2465 |
if (this.isEditable() && this.click_mode === _CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2466 |
this.removeRepresentationsOfType("editor");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2467 |
this.addTempEdge(this.click_target, _point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2468 |
this.click_mode = _CLICKMODE_ENDEDGE; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2469 |
this.notif_$.fadeOut(function() {
|
| 277 | 2470 |
$(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn();
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2471 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2472 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2473 |
this.notif_$.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2474 |
this.click_mode = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2475 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2476 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2477 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2478 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2479 |
onMouseUp: function(_event, _isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2480 |
this.mouse_down = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2481 |
if (this.click_target) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2482 |
var _off = this.canvas_$.offset(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2483 |
this.click_target.mouseup( |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2484 |
{
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2485 |
point: new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2486 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2487 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2488 |
]) |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2489 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2490 |
_isTouch |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2491 |
); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2492 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2493 |
this.click_target = null; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2494 |
this.is_dragging = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2495 |
if (_isTouch) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2496 |
this.unselectAll(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2497 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2498 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2499 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2500 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2501 |
onScroll: function(_event, _scrolldelta) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2502 |
this.totalScroll += _scrolldelta; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2503 |
if (Math.abs(this.totalScroll) >= 1) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2504 |
var _off = this.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2505 |
_delta = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2506 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2507 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2508 |
]).subtract(this.offset).multiply( Math.SQRT2 - 1 ); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2509 |
if (this.totalScroll > 0) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2510 |
this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) ); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2511 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2512 |
this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2))); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2513 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2514 |
this.totalScroll = 0; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2515 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2516 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2517 |
onDoubleClick: function(_event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2518 |
if (!this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2519 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2520 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2521 |
var _off = this.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2522 |
_point = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2523 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2524 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2525 |
]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2526 |
var _hitResult = paper.project.hitTest(_point); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2527 |
if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) {
|
| 153 | 2528 |
var _coords = this.toModelCoords(_point), |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2529 |
_data = {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2530 |
id: Rkns.Utils.getUID('node'),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2531 |
created_by: this.renkan.current_user, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2532 |
position: {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2533 |
x: _coords.x, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2534 |
y: _coords.y |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2535 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2536 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2537 |
_node = this.renkan.project.addNode(_data); |
|
36
d249d36ecc37
Add Edge button, French translation and various bugfixes
veltr
parents:
35
diff
changeset
|
2538 |
this.getRepresentationByModel(_node).openEditor(); |
|
d249d36ecc37
Add Edge button, French translation and various bugfixes
veltr
parents:
35
diff
changeset
|
2539 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2540 |
paper.view.draw(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2541 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2542 |
defaultDropHandler: function(_data) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2543 |
var newNode = {};
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2544 |
switch(_data["text/x-iri-specific-site"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2545 |
case "twitter": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2546 |
var snippet = $('<div>').html(_data["text/x-iri-selected-html"]),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2547 |
tweetdiv = snippet.find(".tweet");
|
| 277 | 2548 |
newNode.title = this.renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2549 |
newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2550 |
newNode.image = tweetdiv.find(".avatar").attr("src");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2551 |
newNode.description = tweetdiv.find(".js-tweet-text:first").text();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2552 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2553 |
case "google": |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2554 |
var snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2555 |
newNode.title = snippet.find("h3:first").text().trim();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2556 |
newNode.uri = snippet.find("h3 a").attr("href");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2557 |
newNode.description = snippet.find(".st:first").text().trim();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2558 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2559 |
case undefined: |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2560 |
default: |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2561 |
if (_data["text/x-iri-source-uri"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2562 |
newNode.uri = _data["text/x-iri-source-uri"]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2563 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2564 |
if (_data["text/plain"] || _data["text/x-iri-selected-text"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2565 |
newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2566 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2567 |
if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2568 |
var snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2569 |
var _svgimgs = snippet.find("image");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2570 |
if (_svgimgs.length) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2571 |
newNode.image = _svgimgs.attr("xlink:href");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2572 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2573 |
var _svgpaths = snippet.find("path");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2574 |
if (_svgpaths.length) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2575 |
newNode.clipPath = _svgpaths.attr("d");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2576 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2577 |
var _imgs = snippet.find("img");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2578 |
if (_imgs.length) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2579 |
newNode.image = _imgs[0].src; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2580 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2581 |
var _as = snippet.find("a");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2582 |
if (_as.length) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2583 |
newNode.uri = _as[0].href; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2584 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2585 |
newNode.title = snippet.find("[title]").attr("title") || newNode.title;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2586 |
newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2587 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2588 |
if (_data["text/uri-list"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2589 |
newNode.uri = _data["text/uri-list"]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2590 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2591 |
if (_data["text/x-moz-url"] && !newNode.title) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2592 |
newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2593 |
if (newNode.title === newNode.uri) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2594 |
newNode.title = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2595 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2596 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2597 |
if (_data["text/x-iri-source-title"] && !newNode.title) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2598 |
newNode.title = _data["text/x-iri-source-title"]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2599 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2600 |
if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2601 |
var snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2602 |
newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2603 |
newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2604 |
newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2605 |
newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2606 |
newNode.clipPath = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.clipPath;
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2607 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2608 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2609 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2610 |
if(typeof this.renkan.options.drop_enhancer === "function"){
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2611 |
newNode = this.renkan.options.drop_enhancer(newNode, _data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2612 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2613 |
return newNode; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2614 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2615 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2616 |
dropData: function(_data, _event) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2617 |
if (!this.isEditable()) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2618 |
return; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2619 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2620 |
if (_data["text/json"] || _data["application/json"]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2621 |
try {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2622 |
var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2623 |
_(_data).extend(jsondata); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2624 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2625 |
catch(e) {}
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2626 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2627 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2628 |
var newNode = (typeof this.renkan.options.drop_handler === "undefined")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2629 |
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2630 |
if (!newNode.title) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2631 |
newNode.title = this.renkan.translate("Dragged resource");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2632 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2633 |
var fields = ["title", "description", "uri", "image"]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2634 |
for (var i = 0; i < fields.length; i++) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2635 |
var f = fields[i]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2636 |
if (_data["text/x-iri-" + f] || _data[f]) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2637 |
newNode[f] = _data["text/x-iri-" + f] || _data[f]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2638 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2639 |
if (newNode[f] === "none" || newNode[f] === "null") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2640 |
newNode[f] = undefined; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2641 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2642 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2643 |
var _off = this.canvas_$.offset(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2644 |
_point = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2645 |
_event.pageX - _off.left, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2646 |
_event.pageY - _off.top |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2647 |
]), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2648 |
_coords = this.toModelCoords(_point), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2649 |
_nodedata = {
|
| 23 | 2650 |
id: Rkns.Utils.getUID('node'),
|
2651 |
created_by: this.renkan.current_user, |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2652 |
uri: newNode.uri || "", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2653 |
title: newNode.title || "", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2654 |
description: newNode.description || "", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2655 |
image: newNode.image || "", |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2656 |
color: newNode.color || undefined, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2657 |
clip_path: newNode.clipPath || undefined, |
| 8 | 2658 |
position: {
|
2659 |
x: _coords.x, |
|
2660 |
y: _coords.y |
|
2661 |
} |
|
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2662 |
}; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2663 |
var _node = this.renkan.project.addNode(_nodedata), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2664 |
_repr = this.getRepresentationByModel(_node); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2665 |
if (_event.type === "drop") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2666 |
_repr.openEditor(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2667 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2668 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2669 |
fullScreen: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2670 |
var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2671 |
_el = this.renkan.$[0], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2672 |
_requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"], |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2673 |
_cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"]; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2674 |
if (_isFull) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2675 |
for (var i = 0; i < _cancelMethods.length; i++) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2676 |
if (typeof document[_cancelMethods[i]] === "function") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2677 |
document[_cancelMethods[i]](); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2678 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2679 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2680 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2681 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2682 |
for (var i = 0; i < _requestMethods.length; i++) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2683 |
if (typeof _el[_requestMethods[i]] === "function") {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2684 |
_el[_requestMethods[i]](); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2685 |
break; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2686 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2687 |
} |
| 155 | 2688 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2689 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2690 |
zoomOut: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2691 |
var _newScale = this.scale * Math.SQRT1_2, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2692 |
_offset = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2693 |
this.canvas_$.width(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2694 |
this.canvas_$.height() |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2695 |
]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 )); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2696 |
this.setScale( _newScale, _offset ); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2697 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2698 |
zoomIn: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2699 |
var _newScale = this.scale * Math.SQRT2, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2700 |
_offset = new paper.Point([ |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2701 |
this.canvas_$.width(), |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2702 |
this.canvas_$.height() |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2703 |
]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 )); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2704 |
this.setScale( _newScale, _offset ); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2705 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2706 |
addNodeBtn: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2707 |
if (this.click_mode === _CLICKMODE_ADDNODE) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2708 |
this.click_mode = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2709 |
this.notif_$.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2710 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2711 |
this.click_mode = _CLICKMODE_ADDNODE; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2712 |
this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn();
|
| 190 | 2713 |
} |
|
276
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2714 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2715 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2716 |
addEdgeBtn: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2717 |
if (this.click_mode === _CLICKMODE_STARTEDGE || this.click_mode === _CLICKMODE_ENDEDGE) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2718 |
this.click_mode = false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2719 |
this.notif_$.hide(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2720 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2721 |
this.click_mode = _CLICKMODE_STARTEDGE; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2722 |
this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn();
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2723 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2724 |
return false; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2725 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2726 |
foldBins: function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2727 |
var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2728 |
bins = this.renkan.$.find(".Rk-Bins");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2729 |
if (bins.offset().left < 0) {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2730 |
bins.animate({left: 0},250);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2731 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2732 |
this.$.animate({left: 300},250,function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2733 |
var w = _this.$.width(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2734 |
paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2735 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2736 |
foldBinsButton.html("«");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2737 |
} else {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2738 |
bins.animate({left: -300},250);
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2739 |
var _this = this; |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2740 |
this.$.animate({left: 0},250,function() {
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2741 |
var w = _this.$.width(); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2742 |
paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2743 |
}); |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2744 |
foldBinsButton.html("»");
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2745 |
} |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2746 |
}, |
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2747 |
save: function() { },
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2748 |
open: function() { }
|
|
900467290a0a
Correct drag and drop problem on renkan
ymh <ymh.work@gmail.com>
parents:
273
diff
changeset
|
2749 |
}); |
| 195 | 2750 |
})(window); |
| 187 | 2751 |
|
2752 |
/* END paper-renderer.js */ |