diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-07-15 02:56:03 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-07-15 02:56:03 -0400 |
| commit | 08e20557015168d35fda101b98696f022f38945a (patch) | |
| tree | 384a7f0318e78046ee481b43d640492234d760a8 | |
| parent | 73fb35c1c5d548d3294d1c63bcefeb3688b7800a (diff) | |
| parent | b53027ed27f0b1233523752e52b668540730a807 (diff) | |
Merge branch 'master' of /pichat/repo
| -rw-r--r-- | static/js/pichat.js | 16 |
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 + "'>" + |
