From 1970607caedcccacabf3b627999b1b641eeb06dd Mon Sep 17 00:00:00 2001 From: "mozilla%kewis.ch" Date: Wed, 16 Jul 2008 20:35:16 +0000 Subject: [PATCH] Fix bug 426153 - Add link to event page in event editing dialog. r=berend,ui-r=christian --- .../base/content/calendar-dialog-utils.js | 49 +++++++++++++++++++ .../base/content/calendar-summary-dialog.js | 9 +--- .../base/content/calendar-summary-dialog.xul | 21 ++++---- .../pinstripe/calendar-event-dialog.css | 4 ++ .../winstripe/calendar-event-dialog.css | 4 ++ .../prototypes/sun-calendar-event-dialog.dtd | 4 ++ .../wcap/sun-calendar-event-dialog.js | 17 +++++++ .../wcap/sun-calendar-event-dialog.xul | 23 +++++++++ .../gdata/components/calGoogleUtils.js | 9 +++- 9 files changed, 120 insertions(+), 20 deletions(-) diff --git a/calendar/base/content/calendar-dialog-utils.js b/calendar/base/content/calendar-dialog-utils.js index 4fece2b68e9..21ac9235b50 100644 --- a/calendar/base/content/calendar-dialog-utils.js +++ b/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/calendar/base/content/calendar-summary-dialog.js b/calendar/base/content/calendar-summary-dialog.js index 385d16144d9..c0e93cfd943 100644 --- a/calendar/base/content/calendar-summary-dialog.js +++ b/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/calendar/base/content/calendar-summary-dialog.xul b/calendar/base/content/calendar-summary-dialog.xul index 67712cf7de1..cad1854c44c 100644 --- a/calendar/base/content/calendar-summary-dialog.xul +++ b/calendar/base/content/calendar-summary-dialog.xul @@ -71,6 +71,8 @@ src="chrome://calendar/content/calendar-dialog-utils.js"/>