summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Ostler <scottbot9000@gmail.com>2010-07-14 23:53:52 -0700
committerScott Ostler <scottbot9000@gmail.com>2010-07-14 23:53:52 -0700
commitb53027ed27f0b1233523752e52b668540730a807 (patch)
treeb308239ef10d9e8b82dcd62ec60a007689b623a0
parent25b66885b8c6b466b111aa0566eb600ce147c04d (diff)
Ugly click-event test so chat images can be middle-clicked in Chrome
-rw-r--r--static/js/pichat.js16
1 files changed, 13 insertions, 3 deletions
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 "<a target='_blank' href='" + linkUrl + "' class='img-wrapper' onclick='return " + shouldOpen + "'><img src='" + linkUrl + "'></a>";
+ return "<a target='_blank' href='" + linkUrl + "' class='img-wrapper' onclick='return imgClickHandler()'><img src='" + linkUrl + "'></a>";
} else if (type == 'youtube') {
Youtube.startAnimation();
return "<a target='_blank' class='youtube' href='" + linkUrl + "'>" +