about summary refs log tree commit diff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-24 17:05:44 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-24 17:05:44 +0100
commit80cefd5b3cd9c8efa435f684a33fe1562696b74a (patch)
treedd3eab3219fb7c4757c8d67ae5178b43f8ec075b /app/assets/javascripts
parentb06a375ee49e80279b1a9529d1ca892548e55fc7 (diff)
Fix #204, fix #515 - URL truncating is now a style so copypasting is not
affected, replaced onClick handler with onMouseUp/Down to detect text
selection not trigger onClick handler then
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/components/components/status_content.jsx27
1 files changed, 25 insertions, 2 deletions
diff --git a/app/assets/javascripts/components/components/status_content.jsx b/app/assets/javascripts/components/components/status_content.jsx
index f2c88cee0..68224b7ba 100644
--- a/app/assets/javascripts/components/components/status_content.jsx
+++ b/app/assets/javascripts/components/components/status_content.jsx
@@ -56,12 +56,35 @@ const StatusContent = React.createClass({
     e.stopPropagation();
   },
 
+  handleMouseDown (e) {
+    this.startXY = [e.clientX, e.clientY];
+  },
+
+  handleMouseUp (e) {
+    const [ startX, startY ] = this.startXY;
+    const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
+
+    if (deltaX + deltaY < 5) {
+      this.props.onClick();
+    }
+
+    this.startXY = null;
+  },
+
   render () {
-    const { status, onClick } = this.props;
+    const { status } = this.props;
 
     const content = { __html: emojify(status.get('content')) };
 
-    return <div className='status__content' style={{ cursor: 'pointer' }} dangerouslySetInnerHTML={content} onClick={onClick} />;
+    return (
+      <div
+        className='status__content'
+        style={{ cursor: 'pointer' }}
+        dangerouslySetInnerHTML={content}
+        onMouseDown={this.handleMouseDown}
+        onMouseUp={this.handleMouseUp}
+      />
+    );
   },
 
 });