370 ); |
368 ); |
371 } |
369 } |
372 |
370 |
373 }, |
371 }, |
374 showImage: function() { |
372 showImage: function() { |
|
373 var _image = null; |
375 if (typeof this.renderer.image_cache[this.img] === "undefined") { |
374 if (typeof this.renderer.image_cache[this.img] === "undefined") { |
376 var _image = new Image(); |
375 _image = new Image(); |
377 this.renderer.image_cache[this.img] = _image; |
376 this.renderer.image_cache[this.img] = _image; |
378 _image.src = this.img; |
377 _image.src = this.img; |
379 } else { |
378 } else { |
380 var _image = this.renderer.image_cache[this.img]; |
379 _image = this.renderer.image_cache[this.img]; |
381 } |
380 } |
382 if (_image.width) { |
381 if (_image.width) { |
383 if (this.node_image) { |
382 if (this.node_image) { |
384 this.node_image.remove(); |
383 this.node_image.remove(); |
385 } |
384 } |
386 this.renderer.node_layer.activate(); |
385 this.renderer.node_layer.activate(); |
387 var width = _image.width, |
386 var width = _image.width, |
388 height = _image.height, |
387 height = _image.height, |
389 clipPath = this.model.get("clip_path"), |
388 clipPath = this.model.get("clip_path"), |
390 hasClipPath = (typeof clipPath !== "undefined" && clipPath); |
389 hasClipPath = (typeof clipPath !== "undefined" && clipPath), |
|
390 _clip = null, |
|
391 baseRadius = null, |
|
392 centerPoint = null; |
|
393 |
391 if (hasClipPath) { |
394 if (hasClipPath) { |
392 var _clip = new paper.Path(), |
395 _clip = new paper.Path(); |
393 instructions = clipPath.match(/[a-z][^a-z]+/gi) || [], |
396 var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [], |
394 lastCoords = [0,0], |
397 lastCoords = [0,0], |
395 minX = Infinity, |
398 minX = Infinity, |
396 minY = Infinity, |
399 minY = Infinity, |
397 maxX = -Infinity, |
400 maxX = -Infinity, |
398 maxY = -Infinity; |
401 maxY = -Infinity; |
399 |
402 |
400 var transformCoords = function(tabc, relative) { |
403 var transformCoords = function(tabc, relative) { |
401 var newCoords = tabc.slice(1).map(function(v, k) { |
404 var newCoords = tabc.slice(1).map(function(v, k) { |
402 var res = parseFloat(v), |
405 var res = parseFloat(v), |
403 isY = k % 2; |
406 isY = k % 2; |
450 _clip.quadraticCurveTo(transformCoords(coords, true)); |
453 _clip.quadraticCurveTo(transformCoords(coords, true)); |
451 break; |
454 break; |
452 } |
455 } |
453 }); |
456 }); |
454 |
457 |
455 var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2, |
458 baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2; |
456 centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2); |
459 centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2); |
457 if (!this.options.show_node_circles) { |
460 if (!this.options.show_node_circles) { |
458 this.h_ratio = (maxY - minY) / (2 * baseRadius); |
461 this.h_ratio = (maxY - minY) / (2 * baseRadius); |
459 } |
462 } |
460 } else { |
463 } else { |
461 var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2, |
464 baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2; |
462 centerPoint = new paper.Point(0,0); |
465 centerPoint = new paper.Point(0,0); |
463 if (!this.options.show_node_circles) { |
466 if (!this.options.show_node_circles) { |
464 this.h_ratio = height / (2 * baseRadius); |
467 this.h_ratio = height / (2 * baseRadius); |
465 } |
468 } |
466 } |
469 } |
677 this.to_representation = this.renderer.getRepresentationByModel(to); |
680 this.to_representation = this.renderer.getRepresentationByModel(to); |
678 if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") { |
681 if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") { |
679 return; |
682 return; |
680 } |
683 } |
681 var _p0a = this.from_representation.paper_coords, |
684 var _p0a = this.from_representation.paper_coords, |
682 _p1a = this.to_representation.paper_coords, |
685 _p1a = this.to_representation.paper_coords, |
683 _v = _p1a.subtract(_p0a), |
686 _v = _p1a.subtract(_p0a), |
684 _r = _v.length, |
687 _r = _v.length, |
685 _u = _v.divide(_r), |
688 _u = _v.divide(_r), |
686 _ortho = new paper.Point([- _u.y, _u.x]), |
689 _ortho = new paper.Point([- _u.y, _u.x]), |
687 _group_pos = this.bundle.getPosition(this), |
690 _group_pos = this.bundle.getPosition(this), |
688 _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ), |
691 _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ), |
689 _p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
692 _p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
690 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
693 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
691 _a = _v.angle, |
694 _a = _v.angle, |
692 _textdelta = _ortho.multiply(this.options.edge_label_distance), |
695 _textdelta = _ortho.multiply(this.options.edge_label_distance), |
693 _handle = _v.divide(3), |
696 _handle = _v.divide(3), |
694 _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"); |
697 _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || _USER_PLACEHOLDER(this.renkan)).get("color"), |
|
698 opacity = 1; |
695 |
699 |
696 if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { |
700 if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { |
697 var opacity = .5; |
701 opacity = .5; |
698 this.line.dashArray = [2, 2]; |
702 this.line.dashArray = [2, 2]; |
699 } else { |
703 } else { |
700 var opacity = 1; |
704 opacity = 1; |
701 this.line.dashArray = null; |
705 this.line.dashArray = null; |
702 } |
706 } |
703 |
707 |
704 var old_act_btn = this.active_buttons; |
708 var old_act_btn = this.active_buttons; |
705 |
709 |
1707 _scaleRatio = _newScale / _this.scale, |
1710 _scaleRatio = _newScale / _this.scale, |
1708 _newOffset = new paper.Point([ |
1711 _newOffset = new paper.Point([ |
1709 _this.canvas_$.width(), |
1712 _this.canvas_$.width(), |
1710 _this.canvas_$.height() |
1713 _this.canvas_$.height() |
1711 ]).multiply( .5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio )); |
1714 ]).multiply( .5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio )); |
1712 _this.setScale(_newScale, _this.offset); |
1715 _this.setScale(_newScale, _newOffset); |
1713 } |
1716 } |
1714 }, |
1717 }, |
1715 touchend: function(_event) { |
1718 touchend: function(_event) { |
1716 _event.preventDefault(); |
1719 _event.preventDefault(); |
1717 _this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
1720 _this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
2040 } |
2043 } |
2041 } |
2044 } |
2042 }, |
2045 }, |
2043 drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { |
2046 drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { |
2044 var _options = this.renkan.options, |
2047 var _options = this.renkan.options, |
2045 _startRads = _startAngle * Math.PI / 180, |
2048 _startRads = _startAngle * Math.PI / 180, |
2046 _endRads = _endAngle * Math.PI / 180, |
2049 _endRads = _endAngle * Math.PI / 180, |
2047 _img = this.icon_cache[_imgname], |
2050 _img = this.icon_cache[_imgname], |
2048 _span = _endRads - _startRads, |
2051 _startdx = - Math.sin(_startRads), |
2049 _startdx = - Math.sin(_startRads), |
2052 _startdy = Math.cos(_startRads), |
2050 _startdy = Math.cos(_startRads), |
2053 _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, |
2051 _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, |
2054 _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, |
2052 _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, |
2055 _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, |
2053 _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, |
2056 _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, |
2054 _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, |
2057 _enddx = - Math.sin(_endRads), |
2055 _enddx = - Math.sin(_endRads), |
2058 _enddy = Math.cos(_endRads), |
2056 _enddy = Math.cos(_endRads), |
2059 _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, |
2057 _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, |
2060 _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, |
2058 _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, |
2061 _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, |
2059 _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, |
2062 _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, |
2060 _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, |
2063 _centerR = (_inR + _outR)/2, |
2061 _centerR = (_inR + _outR)/2, |
2064 _centerRads = (_startRads + _endRads) / 2, |
2062 _centerRads = (_startRads + _endRads) / 2, |
2065 _centerX = Math.cos(_centerRads) * _centerR, |
2063 _centerX = Math.cos(_centerRads) * _centerR, |
2066 _centerY = Math.sin(_centerRads) * _centerR, |
2064 _centerY = Math.sin(_centerRads) * _centerR, |
2067 _centerXIn = Math.cos(_centerRads) * _inR, |
2065 _centerXIn = Math.cos(_centerRads) * _inR, |
2068 _centerXOut = Math.cos(_centerRads) * _outR, |
2066 _centerXOut = Math.cos(_centerRads) * _outR, |
2069 _centerYIn = Math.sin(_centerRads) * _inR, |
2067 _centerYIn = Math.sin(_centerRads) * _inR, |
2070 _centerYOut = Math.sin(_centerRads) * _outR, |
2068 _centerYOut = Math.sin(_centerRads) * _outR, |
2071 _textX = Math.cos(_centerRads) * (_outR + 3), |
2069 _textX = Math.cos(_centerRads) * (_outR + 3), |
2072 _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2; |
2070 _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2, |
|
2071 _segments = []; |
|
2072 this.buttons_layer.activate(); |
2073 this.buttons_layer.activate(); |
2073 var _path = new paper.Path(); |
2074 var _path = new paper.Path(); |
2074 _path.add([_startXIn, _startYIn]); |
2075 _path.add([_startXIn, _startYIn]); |
2075 _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); |
2076 _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); |
2076 _path.lineTo([_endXOut, _endYOut]); |
2077 _path.lineTo([_endXOut, _endYOut]); |
2091 } else { |
2092 } else { |
2092 _text.paragraphStyle.justification = 'center'; |
2093 _text.paragraphStyle.justification = 'center'; |
2093 } |
2094 } |
2094 _text.visible = false; |
2095 _text.visible = false; |
2095 var _visible = false, |
2096 var _visible = false, |
2096 _restPos = new paper.Point(-200, -200), |
2097 _restPos = new paper.Point(-200, -200), |
2097 _grp = new paper.Group([_path, _text]), |
2098 _grp = new paper.Group([_path, _text]), |
2098 _delta = _grp.position, |
2099 _delta = _grp.position, |
2099 _imgdelta = new paper.Point([_centerX, _centerY]), |
2100 _imgdelta = new paper.Point([_centerX, _centerY]), |
2100 _currentPos = new paper.Point(0,0); |
2101 _currentPos = new paper.Point(0,0); |
2101 _text.content = _caption; |
2102 _text.content = _caption; |
2102 _grp.visible = false; |
2103 _grp.visible = false; |
2103 _grp.position = _restPos; |
2104 _grp.position = _restPos; |
2104 var _res = { |
2105 var _res = { |
2105 show: function() { |
2106 show: function() { |
2277 } |
2278 } |
2278 var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []), |
2279 var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []), |
2279 ulistHtml = '', |
2280 ulistHtml = '', |
2280 $userpanel = this.$.find(".Rk-Users"), |
2281 $userpanel = this.$.find(".Rk-Users"), |
2281 $name = $userpanel.find(".Rk-CurrentUser-Name"), |
2282 $name = $userpanel.find(".Rk-CurrentUser-Name"), |
2282 $cpwrapper = $userpanel.find(".Rk-Edit-ColorPicker-Wrapper"), |
|
2283 $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"), |
2283 $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"), |
2284 $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"), |
2284 $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"), |
2285 _this = this; |
2285 _this = this; |
2286 $name.off("click").text(this.renkan.translate("<unknown user>")); |
2286 $name.off("click").text(this.renkan.translate("<unknown user>")); |
2287 $cpitems.off("mouseleave click"); |
2287 $cpitems.off("mouseleave click"); |