From b53027ed27f0b1233523752e52b668540730a807 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Wed, 14 Jul 2010 23:53:52 -0700 Subject: Ugly click-event test so chat images can be middle-clicked in Chrome --- static/js/pichat.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'static/js') diff --git a/static/js/pichat.js b/static/js/pichat.js index 026f7c2..323e05b 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -95,6 +95,18 @@ function annoyingCaps(text){ return chunks.join(" ") } +var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; +function imgClickHandler() { + // Ugly hack. Don't open new links in chat, only in logs. + // Ugly hack mkII: ensure middle-click opens images in new tab + // c.f. http://code.google.com/p/chromium/issues/detail?id=255 + if (is_chrome && event.button != 0) { + event.stopPropagation(); + } else { + return $('#chatrap').length == 0; + } +} + // durty hack to use a global to check this... but otherwise i'd have to rewrite the String.replace function? :/ var LastMsgContainsImage = false function linkReplace(url) { @@ -104,14 +116,12 @@ function linkReplace(url) { else linkUrl = 'http://' + url; - // Ugly hack. Don't open new links in chat, only in logs. - var shouldOpen = $('#chatrap').length == 0; var uri = parseUri(url) var type = getUriType(uri) if (type == 'image') { LastMsgContainsImage = true; - return ""; + return ""; } else if (type == 'youtube') { Youtube.startAnimation(); return "" + -- cgit v1.2.3-70-g09d2