241 function() { _this.$.find(".Rk-UserList").slideUp(); } |
241 function() { _this.$.find(".Rk-UserList").slideUp(); } |
242 ); |
242 ); |
243 |
243 |
244 if (Screenfull.enabled){ |
244 if (Screenfull.enabled){ |
245 bindClick(".Rk-FullScreen-Button", "fullScreen"); |
245 bindClick(".Rk-FullScreen-Button", "fullScreen"); |
|
246 |
|
247 document.addEventListener(Screenfull.raw.fullscreenchange, function () { |
|
248 var widthAft = _this.$.width(); |
|
249 var heightAft = _this.$.height(); |
|
250 |
|
251 if (_this.renkan.options.show_top_bar) { |
|
252 heightAft -= _this.$.find(".Rk-TopBar").height(); |
|
253 } |
|
254 if (_this.renkan.options.show_bins && (this.renkan.$.find(".Rk-Bins").position().left > 0)) { |
|
255 widthAft -= this.renkan.$.find(".Rk-Bins").width(); |
|
256 } |
|
257 |
|
258 paper.view.viewSize = new paper.Size([widthAft, heightAft]); |
|
259 |
|
260 _this.resize(_this.currentWidth, widthAft, _this.currentHeight, heightAft); |
|
261 |
|
262 _this.currentWidth = widthAft; |
|
263 _this.currentHeight = heightAft; |
|
264 |
|
265 paper.view.onResize = function(_event) { |
|
266 var newWidth = _event.size._width, |
|
267 newHeight = _event.size._height; |
|
268 var prevHeight = newHeight - _event.delta.height, |
|
269 prevWidth = newWidth - _event.delta.width; |
|
270 |
|
271 _this.resize(prevWidth, newWidth, prevHeight, newHeight); |
|
272 }; |
|
273 }); |
246 } else { |
274 } else { |
247 this.$.find(".Rk-FullScreen-Button").addClass("disabled"); |
275 this.$.find(".Rk-FullScreen-Button").addClass("disabled"); |
248 this.$.find(".Rk-FullScreen-Button .Rk-TopBar-Tooltip-Contents").html(this.renkan.translate("Fullscreen not supported by your browser")); |
276 this.$.find(".Rk-FullScreen-Button .Rk-TopBar-Tooltip-Contents").html(this.renkan.translate("Fullscreen not supported by your browser")); |
249 } |
277 } |
250 |
278 |
269 }).mouseout(function() { |
297 }).mouseout(function() { |
270 $(this).find(".Rk-TopBar-Tooltip").hide(); |
298 $(this).find(".Rk-TopBar-Tooltip").hide(); |
271 }); |
299 }); |
272 bindClick(".Rk-Fold-Bins", "foldBins"); |
300 bindClick(".Rk-Fold-Bins", "foldBins"); |
273 |
301 |
274 paper.view.onResize = function(_event) { |
302 paper.view.on("resize", function(_event) { |
275 var _ratio, |
303 var newWidth = _event.size._width, |
276 newWidth = _event.size._width, |
|
277 newHeight = _event.size._height; |
304 newHeight = _event.size._height; |
|
305 var prevHeight = newHeight - _event.delta.height, |
|
306 prevWidth = newWidth - _event.delta.width; |
278 |
307 |
279 if (_this.minimap) { |
308 _this.resize(prevWidth, newWidth, prevHeight, newHeight); |
280 _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size); |
309 }); |
281 _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4])); |
|
282 _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size); |
|
283 } |
|
284 |
|
285 var ratioH = newHeight/(newHeight-_event.delta.height), |
|
286 ratioW = newWidth/(newWidth-_event.delta.width); |
|
287 if (newHeight < newWidth) { |
|
288 _ratio = ratioH; |
|
289 } else { |
|
290 _ratio = ratioW; |
|
291 } |
|
292 _this.view.resizeZoom(_event.delta.width, _event.delta.height, _ratio); |
|
293 |
|
294 _this.redraw(); |
|
295 |
|
296 }; |
|
297 |
310 |
298 var _thRedraw = _.throttle(function() { |
311 var _thRedraw = _.throttle(function() { |
299 _this.redraw(); |
312 _this.redraw(); |
300 },50); |
313 },50); |
301 |
314 |
814 if (this.minimap && typeof this.view !== 'undefined') { |
827 if (this.minimap && typeof this.view !== 'undefined') { |
815 this.redrawMiniframe(); |
828 this.redrawMiniframe(); |
816 } |
829 } |
817 paper.view.draw(); |
830 paper.view.draw(); |
818 }, |
831 }, |
|
832 resize: function(prevWidth, newWidth, prevHeight, newHeight){ |
|
833 var _ratio; |
|
834 |
|
835 if (this.minimap) { |
|
836 this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size); |
|
837 this.minimap.rectangle.fitBounds(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4])); |
|
838 this.minimap.cliprectangle.fitBounds(this.minimap.topleft, this.minimap.size); |
|
839 } |
|
840 |
|
841 var ratioH = newHeight/prevHeight, |
|
842 ratioW = newWidth/prevWidth; |
|
843 if (newHeight < newWidth) { |
|
844 _ratio = ratioH; |
|
845 } else { |
|
846 _ratio = ratioW; |
|
847 } |
|
848 this.view.resizeZoom(newWidth - prevWidth, newHeight - prevHeight, _ratio); |
|
849 |
|
850 this.redraw(); |
|
851 }, |
819 addTempEdge: function(_from, _point) { |
852 addTempEdge: function(_from, _point) { |
820 var _tmpEdge = this.addRepresentation("TempEdge",null); |
853 var _tmpEdge = this.addRepresentation("TempEdge",null); |
821 _tmpEdge.end_pos = _point; |
854 _tmpEdge.end_pos = _point; |
822 _tmpEdge.from_representation = _from; |
855 _tmpEdge.from_representation = _from; |
823 _tmpEdge.redraw(); |
856 _tmpEdge.redraw(); |
1108 if (_event.type === "drop") { |
1141 if (_event.type === "drop") { |
1109 _repr.openEditor(); |
1142 _repr.openEditor(); |
1110 } |
1143 } |
1111 }, |
1144 }, |
1112 fullScreen: function() { |
1145 fullScreen: function() { |
|
1146 this.currentWidth = this.$.width(); |
|
1147 this.currentHeight = this.$.height(); |
|
1148 |
1113 var _el = this.renkan.$[0]; |
1149 var _el = this.renkan.$[0]; |
1114 |
1150 paper.view.off("resize"); |
1115 if (Screenfull.isFullscreen) { |
1151 Screenfull.toggle(_el); |
1116 Screenfull.exit(_el); |
|
1117 |
|
1118 var widthAft = this.$.width(); |
|
1119 var heightAft = this.$.height(); |
|
1120 |
|
1121 if (this.renkan.options.show_top_bar) { |
|
1122 heightAft -= this.$.find(".Rk-TopBar").height(); |
|
1123 } |
|
1124 if (this.renkan.options.show_bins && (this.renkan.$.find(".Rk-Bins").position().left > 0)) { |
|
1125 widthAft -= this.renkan.$.find(".Rk-Bins").width(); |
|
1126 } |
|
1127 |
|
1128 paper.view.viewSize = new paper.Size([widthAft, heightAft]); |
|
1129 |
|
1130 } else { |
|
1131 Screenfull.request(_el); |
|
1132 |
|
1133 this.redraw(); |
|
1134 } |
|
1135 }, |
1152 }, |
1136 addNodeBtn: function() { |
1153 addNodeBtn: function() { |
1137 if (this.click_mode === Utils._CLICKMODE_ADDNODE) { |
1154 if (this.click_mode === Utils._CLICKMODE_ADDNODE) { |
1138 this.click_mode = false; |
1155 this.click_mode = false; |
1139 this.notif_$.hide(); |
1156 this.notif_$.hide(); |