diff --git a/chrome/content/calendar-summary-dialog.js b/chrome/content/calendar-summary-dialog.js index cf171530..fce55a3b 100644 --- a/chrome/content/calendar-summary-dialog.js +++ b/chrome/content/calendar-summary-dialog.js @@ -321,6 +321,92 @@ try{ } } }, + + hrefAndLinkNodeForClickEvent: function _hrefAndLinkNodeForClickEvent(event) + { + var href = ""; + var isKeyCommand = (event.type == "command"); + var linkNode = isKeyCommand ? this._document.commandDispatcher.focusedElement + : event.originalTarget; + + while (linkNode instanceof Element) { + if (linkNode instanceof HTMLAnchorElement || + linkNode instanceof HTMLAreaElement || + linkNode instanceof HTMLLinkElement) { + href = linkNode.href; + if (href) + break; + } + // Try MathML href + else if (linkNode.namespaceURI == "http://www.w3.org/1998/Math/MathML" && + linkNode.hasAttribute("href")) { + href = linkNode.getAttribute("href"); + href = makeURLAbsolute(linkNode.baseURI, href); + break; + } + // Try simple XLink + else if (linkNode.hasAttributeNS("http://www.w3.org/1999/xlink", "href")) { + href = linkNode.getAttributeNS("http://www.w3.org/1999/xlink", "href"); + href = makeURLAbsolute(linkNode.baseURI, href); + break; + } + linkNode = linkNode.parentNode; + } + + return href ? {href: href, linkNode: linkNode} : null; + }, + + onClick: function _onClick(event) + { + // Following is copied from mailWindow.js script for emails. + var ceParams = this.hrefAndLinkNodeForClickEvent(event); + if (!ceParams && !event.button) { + var target = event.target; + // is this an image that we might want to scale? + if (target instanceof Components.interfaces.nsIImageLoadingContent) { + // make sure it loaded successfully + var req = target.getRequest(Components.interfaces.nsIImageLoadingContent.CURRENT_REQUEST); + if (!req || req.imageStatus & Components.interfaces.imgIRequest.STATUS_ERROR) + return true; + // is it an inline attachment? + if (/^moz-attached-image/.test(target.className)) { + if (target.hasAttribute("isshrunk")) + { + // currently shrunk to fit, so unshrink it + target.removeAttribute("isshrunk"); + target.removeAttribute("shrinktofit"); + target.setAttribute("overflowing", "true"); + } + else if (target.hasAttribute("overflowing")) + { + // user wants to shrink now + target.setAttribute("isshrunk", "true"); + target.setAttribute("shrinktofit", "true"); + target.removeAttribute("overflowing"); + } + } + } + return true; + } + var href = ceParams.href; + + try { + var extProtService = Cc["@mozilla.org/uriloader/external-protocol-service;1"].getService(); + extProtService = extProtService.QueryInterface(Ci.nsIExternalProtocolService); + var scheme = href.substring(0, href.indexOf(":")); + if (extProtService.isExposedProtocol(scheme)) { + var ioService = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService); + extProtService.loadUrl(ioService.newURI(href, null, null)); + } + } + catch (ex) { + alert("Do not know how to handle this reference:"+href); + } + + event.preventDefault(); + return true; + }, } //this._window.addEventListener("load", exchWebService.forewardEvent2.onLoad, false); diff --git a/chrome/content/calendar-summary-dialog.xul b/chrome/content/calendar-summary-dialog.xul index 1b70d4b0..cc596c3a 100644 --- a/chrome/content/calendar-summary-dialog.xul +++ b/chrome/content/calendar-summary-dialog.xul @@ -52,7 +52,12 @@