diff --git a/mozilla/calendar/base/content/calendar-dialog-utils.js b/mozilla/calendar/base/content/calendar-dialog-utils.js index 4fece2b68e9..21ac9235b50 100644 --- a/mozilla/calendar/base/content/calendar-dialog-utils.js +++ b/mozilla/calendar/base/content/calendar-dialog-utils.js @@ -782,3 +782,52 @@ function commonUpdateReminder() { updateReminderDetails(); } + +function updateLink() { + var itemUrlString = (window.calendarItem || window.item).getProperty("URL"); + var linkCommand = document.getElementById("cmd_toggle_link"); + + function hideOrShow(aBool, aDisable) { + setElementValue("event-grid-link-row", !aBool && "true", "hidden"); + var separator = document.getElementById("event-grid-link-separator"); + if (separator) { + // The separator is not there in the summary dialog + setElementValue("event-grid-link-separator", !aBool && "true", "hidden"); + } + + if (linkCommand) { + setElementValue(linkCommand, aDisable && "true", "disabled"); + } + } + + if (linkCommand && linkCommand.getAttribute("checked") != "true") { + hideOrShow(false, false); + } else if (itemUrlString && itemUrlString.length) { + var handler, uri; + try { + uri = makeURL(itemUrlString); + handler = getIOService().getProtocolHandler(uri.scheme); + } catch (e) { + // No protocol handler for the given protocol, or invalid uri + hideOrShow(false, true); + return; + } + + if (handler && handler instanceof Components.interfaces.nsIExternalProtocolHandler) { + // Only show if there is an external app for this scheme + hideOrShow(handler.externalAppExistsForScheme(uri.scheme)); + } else { + // Internal protocol handler, show it + hideOrShow(true); + } + + + setTimeout(function() { + // HACK the url-link doesn't crop when setting the value in onLoad + setElementValue("url-link", itemUrlString); + setElementValue("url-link", itemUrlString, "href"); + }, 0); + } else { + hideOrShow(false, true); + } +} diff --git a/mozilla/calendar/base/content/calendar-summary-dialog.js b/mozilla/calendar/base/content/calendar-summary-dialog.js index 385d16144d9..c0e93cfd943 100644 --- a/mozilla/calendar/base/content/calendar-summary-dialog.js +++ b/mozilla/calendar/base/content/calendar-summary-dialog.js @@ -99,6 +99,7 @@ function onLoad() { updateRepeatDetails(); updateAttendees(); + updateLink(); var location = item.getProperty("LOCATION"); if (location && location.length) { @@ -154,14 +155,6 @@ function onLoad() { } } - if (item.hasProperty("URL")) { - var url = item.getProperty("URL"); - if (url && url.length) { - document.getElementById("item-link-box").removeAttribute("hidden"); - document.getElementById("item-link").value = url; - } - } - document.title = item.title; // If this item is read only we remove the 'cancel' button as users diff --git a/mozilla/calendar/base/content/calendar-summary-dialog.xul b/mozilla/calendar/base/content/calendar-summary-dialog.xul index 67712cf7de1..cad1854c44c 100644 --- a/mozilla/calendar/base/content/calendar-summary-dialog.xul +++ b/mozilla/calendar/base/content/calendar-summary-dialog.xul @@ -71,6 +71,8 @@ src="chrome://calendar/content/calendar-dialog-utils.js"/>