From 8b392a9fa0a84e72af8c5b162b79d690446227ee Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Mon, 29 Sep 2014 12:48:14 -0700 Subject: [PATCH] Fix text selection --- client/js/shout.js | 19 ++++++++++++++++--- package.json | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/js/shout.js b/client/js/shout.js index 101868b..e860d03 100644 --- a/client/js/shout.js +++ b/client/js/shout.js @@ -386,7 +386,20 @@ $(function() { }); }); - chat.on("click", ".messages", focus); + chat.on("click", ".messages", function() { + setTimeout(function() { + var text = ""; + if (window.getSelection) { + text = window.getSelection().toString(); + } else if (document.selection && document.selection.type != "Control") { + text = document.selection.createRange().text; + } + if (!text) { + focus(); + } + }, 2); + }); + $(window).on("focus", focus); function focus() { @@ -641,13 +654,13 @@ $(function() { var direction = keys.split("+").pop(); switch (direction) { case "up": - // Wrap around! + // Loop var upTarget = (channels.length + (index - 1 + channels.length)) % channels.length; channels.eq(upTarget).click(); break; case "down": - // Wrap aroud! + // Loop var downTarget = (channels.length + (index + 1 + channels.length)) % channels.length; channels.eq(downTarget).click(); break; diff --git a/package.json b/package.json index c650901..35b5d17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "The self-hosted web IRC client", - "version": "0.38.7", + "version": "0.38.8", "author": "Mattias Erming", "preferGlobal": true, "bin": {