client/js/renderer/scene.js
changeset 647 eaaa1efce396
parent 633 fdff56da097d
child 649 2b9c120dba55
--- a/client/js/renderer/scene.js	Tue Oct 04 16:40:25 2016 +0200
+++ b/client/js/renderer/scene.js	Thu Jan 05 16:26:07 2017 +0100
@@ -158,6 +158,10 @@
                 _event.preventDefault();
                 _this.onMouseUp(_event.originalEvent.changedTouches[0], true);
             },
+            click: function(_event) {
+                _event.preventDefault();
+                _this.onClick(_event);
+            },
             dblclick: function(_event) {
                 _event.preventDefault();
                 if (_renkan.options.allow_double_click) {
@@ -1000,6 +1004,28 @@
                 this.totalScroll = 0;
             }
         },
+        onClick: function(_event) {
+            if (!this.isEditable()) {
+                var _off = this.canvas_$.offset(),
+                _point = new paper.Point([
+                                        _event.pageX - _off.left,
+                                        _event.pageY - _off.top
+                                        ]);
+                var _hitResult = paper.project.hitTest(_point);
+                if(!this._open_uri_cb &&
+                    this.renkan.options.simple_click_open_url && 
+                    _hitResult &&
+                    typeof _hitResult.item.__representation !== "undefined" &&
+                    _hitResult.item.__representation.model.get('uri') &&
+                    !this._node_click_open_url
+                ) {
+                    this._node_click_open_url = setTimeout(function() {
+                        window.open(_hitResult.item.__representation.model.get('uri'), '_blank');
+                        this._node_click_open_url = null;
+                    }.bind(this), 200);
+                }
+            }
+        },
         onDoubleClick: function(_event) {
             var _off = this.canvas_$.offset(),
             _point = new paper.Point([
@@ -1009,10 +1035,13 @@
             var _hitResult = paper.project.hitTest(_point);
 
             if (!this.isEditable()) {
-                if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
-                    if (_hitResult.item.__representation.model.get('uri')){
-                        window.open(_hitResult.item.__representation.model.get('uri'), '_blank');
-                    }
+                if (this.renkan.options.double_click_open_url &&
+                    _hitResult &&
+                    typeof _hitResult.item.__representation !== "undefined" &&
+                    _hitResult.item.__representation.model.get('uri') &&
+                    !this._node_click_open_url
+                ) {
+                    window.open(_hitResult.item.__representation.model.get('uri'), '_blank');
                 }
                 return;
             }