Improve URL handling in popup of events

pull/17/head
Francis Lachapelle 2014-02-10 21:49:49 -05:00
parent b91032db8e
commit fcfd8be771
3 changed files with 37 additions and 33 deletions

View File

@ -1239,7 +1239,6 @@ function loadMessage(msguid) {
}
}
configureLoadImagesButton();
configureSignatureFlagImage();
@ -1330,22 +1329,7 @@ function configureLinksInMessage() {
if (!$(document.body).hasClassName("popup"))
mailContentDiv.observe("contextmenu", onMessageContentMenu);
var anchors = messageDiv.getElementsByTagName('a');
for (var i = 0; i < anchors.length; i++) {
var anchor = $(anchors[i]);
if (!anchor.href && anchor.readAttribute("moz-do-not-send")) {
anchor.writeAttribute("moz-do-not-send", false);
anchor.removeClassName("moz-txt-link-abbreviated");
anchor.href = "mailto:" + anchors[i].innerHTML;
}
if (anchor.href.substring(0,7) == "mailto:") {
anchor.observe("click", onEmailTo);
anchor.observe("contextmenu", onEmailAddressClick);
anchor.writeAttribute("moz-do-not-send", false);
}
else if (!anchor.id)
anchor.observe("click", onMessageAnchorClick);
}
configureLinks(messageDiv);
var attachmentsMenu = $("attachmentsMenu");
if (attachmentsMenu) {
@ -1595,12 +1579,6 @@ function onEmailAddressClick(event) {
return false;
}
function onMessageAnchorClick(event) {
if (this.href)
window.open(this.href);
preventDefault(event);
}
function onImageClick(event) {
popupMenu(event, 'imageMenu', this);
preventDefault(event);
@ -1803,16 +1781,6 @@ function newContactFromEmail(event) {
return false; /* stop following the link */
}
function onEmailTo(event) {
var s = this.innerHTML.strip();
if (!/@/.test(s)) {
s += ' <' + this.href.substr(7) + '>';
}
openMailTo(s);
Event.stop(event);
return false;
}
function newEmailTo(sender) {
return openMailTo(document.menuTarget.innerHTML);
}

View File

@ -817,6 +817,7 @@ function onViewEventCallback(http) {
div.setStyle({ left: left + "px", top: top + "px" });
div.show();
configureLinks(div);
}
}
else {

View File

@ -334,6 +334,16 @@ function openMailTo(senderMailTo) {
return false; /* stop following the link */
}
function onEmailTo(event) {
var s = this.innerHTML.strip();
if (!/@/.test(s)) {
s += ' <' + this.href.substr(7) + '>';
}
openMailTo(s);
Event.stop(event);
return false;
}
function deleteDraft(url) {
/* this is called by UIxMailEditor with window.opener */
new Ajax.Request(url, {
@ -1763,6 +1773,31 @@ function configureLinkBanner() {
}
}
function configureLinks(element) {
var onAnchorClick = function (event) {
if (this.href)
window.open(this.href);
preventDefault(event);
};
var anchors = element.getElementsByTagName('a');
for (var i = 0; i < anchors.length; i++) {
var anchor = $(anchors[i]);
if (!anchor.href && anchor.readAttribute("moz-do-not-send")) {
anchor.writeAttribute("moz-do-not-send", false);
anchor.removeClassName("moz-txt-link-abbreviated");
anchor.href = "mailto:" + anchors[i].innerHTML;
}
if (anchor.href.substring(0,7) == "mailto:") {
anchor.observe("click", onEmailTo);
if (typeof onEmailAddressClick == 'function')
anchor.observe("contextmenu", onEmailAddressClick);
anchor.writeAttribute("moz-do-not-send", false);
}
else if (!anchor.id)
anchor.observe("click", onAnchorClick);
}
}
function CurrentModule() {
var module = null;
if (ApplicationBaseURL) {