Bug 346762 - Lightning shouldn't include applicationUtils.js, p=me and jminta, r=mickey

git-svn-id: svn://10.0.0.236/trunk@228947 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugzilla%babylonsounds.com
2007-06-28 19:39:18 +00:00
parent 8577d03449
commit 3d38069af2
10 changed files with 218 additions and 232 deletions

View File

@@ -65,7 +65,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/calendar-event-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<!-- Used for the button to show/hide details -->
<script type="application/x-javascript">

View File

@@ -842,3 +842,220 @@ function isSunbird()
return appInfo.ID == kSUNBIRD_UID;
}
function showElement(elementId)
{
try {
document.getElementById(elementId).removeAttribute("hidden");
} catch (e) {
dump("showElement: Couldn't remove hidden attribute from " + elementId + "\n");
}
}
function hideElement(elementId)
{
try {
document.getElementById(elementId).setAttribute("hidden", "true");
} catch (e) {
dump("hideElement: Couldn't set hidden attribute on " + elementId + "\n");
}
}
function enableElement(elementId)
{
try {
//document.getElementById(elementId).setAttribute("disabled", "false");
// call remove attribute beacuse some widget code checks for the presense of a
// disabled attribute, not the value.
document.getElementById(elementId).removeAttribute("disabled");
} catch (e) {
dump("enableElement: Couldn't remove disabled attribute on " + elementId + "\n");
}
}
function disableElement(elementId)
{
try {
document.getElementById(elementId).setAttribute( "disabled", "true");
} catch (e) {
dump("disableElement: Couldn't set disabled attribute to true on " +
elementId + "\n");
}
}
/**
* Helper function for filling the form,
* Set the value of a property of a XUL element
*
* PARAMETERS
* elementId - ID of XUL element to set
* newValue - value to set property to ( if undefined no change is made )
* propertyName - OPTIONAL name of property to set, default is "value",
* use "checked" for radios & checkboxes, "data" for
* drop-downs
*/
function setElementValue(elementId, newValue, propertyName)
{
var undefined;
if (newValue !== undefined) {
var field = document.getElementById(elementId);
if (newValue === false) {
try {
field.removeAttribute(propertyName);
} catch (e) {
dump("setFieldValue: field.removeAttribute couldn't remove " +
propertyName + " from " + elementId + " e: " + e + "\n");
}
} else if (propertyName) {
try {
field.setAttribute(propertyName, newValue);
} catch (e) {
dump("setFieldValue: field.setAttribute couldn't set " +
propertyName + " from " + elementId + " to " + newValue +
" e: " + e + "\n");
}
} else {
field.value = newValue;
}
}
}
/**
* Helper function for getting data from the form,
* Get the value of a property of a XUL element
*
* PARAMETERS
* elementId - ID of XUL element to get from
* propertyName - OPTIONAL name of property to set, default is "value",
* use "checked" for radios & checkboxes, "data" for
* drop-downs
* RETURN
* newValue - value of property
*/
function getElementValue(elementId, propertyName)
{
var field = document.getElementById(elementId);
if (propertyName) {
return field[propertyName];
}
return field.value;
}
function processEnableCheckbox(checkboxId, elementId)
{
if (document.getElementById(checkboxId).checked) {
enableElement(elementId);
} else {
disableElement(elementId);
}
}
/*
* Enable/disable button if there are children in a listbox
*/
function updateListboxDeleteButton(listboxId, buttonId)
{
if (document.getElementById(listboxId).getRowCount() > 0) {
enableElement(buttonId);
} else {
disableElement(buttonId);
}
}
/*
* Update plural singular menu items
*/
function updateMenuLabels(lengthFieldId, menuId )
{
var field = document.getElementById(lengthFieldId);
var menu = document.getElementById(menuId);
// figure out whether we should use singular or plural
var length = field.value;
var newLabelNumber;
// XXX This assumes that "0 days, minutes, etc." is plural in other languages.
if ( (Number(length) == 0) || (Number(length) > 1) ) {
newLabelNumber = "label2"
} else {
newLabelNumber = "label1"
}
// see what we currently show and change it if required
var oldLabelNumber = menu.getAttribute("labelnumber");
if (newLabelNumber != oldLabelNumber) {
// remember what we are showing now
menu.setAttribute("labelnumber", newLabelNumber);
// update the menu items
var items = menu.getElementsByTagName("menuitem");
for(var i = 0; i < items.length; ++i) {
var menuItem = items[i];
var newLabel = menuItem.getAttribute(newLabelNumber);
menuItem.label = newLabel;
menuItem.setAttribute("label", newLabel);
}
// force the menu selection to redraw
var saveSelectedIndex = menu.selectedIndex;
menu.selectedIndex = -1;
menu.selectedIndex = saveSelectedIndex;
}
}
/** Select value in menuList. Throws string if no such value. **/
function menuListSelectItem(menuListId, value)
{
var menuList = document.getElementById(menuListId);
var index = menuListIndexOf(menuList, value);
if (index != -1) {
menuList.selectedIndex = index;
} else {
throw "menuListSelectItem: No such Element: "+value;
}
}
/** Find index of menuitem with the given value, or return -1 if not found. **/
function menuListIndexOf(menuList, value)
{
var items = menuList.menupopup.childNodes;
var index = -1;
for (var i = 0; i < items.length; i++) {
var element = items[i];
if (element.nodeName == "menuitem") {
index++;
}
if (element.getAttribute("value") == value) {
return index;
}
}
return -1; // not found
}
function hasPositiveIntegerValue(elementId)
{
var value = document.getElementById(elementId).value;
if (value && (parseInt(value) == value) && value > 0) {
return true;
}
return false;
}

View File

@@ -31,7 +31,6 @@ lightning-en-US.jar:
locale/en-US/lightning/sun-lightning.dtd (/calendar/locales/en-US/chrome/prototypes/sun-lightning.dtd)
calendar.jar:
* content/calendar/applicationUtil.js (/calendar/resources/content/applicationUtil.js)
content/calendar/calendarProperties.xul (/calendar/resources/content/calendarProperties.xul)
content/calendar/calendarProperties.js (/calendar/resources/content/calendarProperties.js)
content/calendar/calendarCreation.xul (/calendar/resources/content/calendarCreation.xul)

View File

@@ -64,7 +64,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-attendees.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<attendees-page id="attendees-page" range="16" flex="1"/>

View File

@@ -63,7 +63,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-recurrence.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<recurrence-page id="recurrence-page" flex="1" orient="vertical"/>

View File

@@ -63,7 +63,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-reminder.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<!-- Listbox with custom reminders -->
<grid flex="1">

View File

@@ -62,7 +62,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-timezone.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<hbox align="center">
<spacer flex="1"/>

View File

@@ -77,8 +77,6 @@
src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript"
src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript"
src="chrome://calendar/content/applicationUtil.js"/>
<script type="application/x-javascript"
src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript"

View File

@@ -74,18 +74,6 @@ function toJavaScriptConsole()
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
}
#ifndef MOZ_SUNBIRD
function toMessengerWindow()
{
toOpenWindowByType("mail:3pane", "chrome://messenger/content/messenger.xul");
}
function toAddressBook()
{
toOpenWindowByType("mail:addressbook", "chrome://messenger/content/addressbook/addressbook.xul");
}
#endif
function launchBrowser(UrlToGoTo)
{
if (!UrlToGoTo) {
@@ -183,217 +171,6 @@ function goOpenAddons()
window.openDialog(EMURL, "", EMFEATURES);
}
function showElement(elementId)
{
try {
document.getElementById(elementId).removeAttribute("hidden");
} catch (e) {
dump("showElement: Couldn't remove hidden attribute from " + elementId + "\n");
}
}
function hideElement(elementId)
{
try {
document.getElementById(elementId).setAttribute("hidden", "true");
} catch (e) {
dump("hideElement: Couldn't set hidden attribute on " + elementId + "\n");
}
}
function enableElement(elementId)
{
try {
//document.getElementById(elementId).setAttribute("disabled", "false");
// call remove attribute beacuse some widget code checks for the presense of a
// disabled attribute, not the value.
document.getElementById(elementId).removeAttribute("disabled");
} catch (e) {
dump("enableElement: Couldn't remove disabled attribute on " + elementId + "\n");
}
}
function disableElement(elementId)
{
try {
document.getElementById(elementId).setAttribute( "disabled", "true");
} catch (e) {
dump("disableElement: Couldn't set disabled attribute to true on " +
elementId + "\n");
}
}
/**
* Helper function for filling the form,
* Set the value of a property of a XUL element
*
* PARAMETERS
* elementId - ID of XUL element to set
* newValue - value to set property to ( if undefined no change is made )
* propertyName - OPTIONAL name of property to set, default is "value",
* use "checked" for radios & checkboxes, "data" for
* drop-downs
*/
function setElementValue(elementId, newValue, propertyName)
{
var undefined;
if (newValue !== undefined) {
var field = document.getElementById(elementId);
if (newValue === false) {
try {
field.removeAttribute(propertyName);
} catch (e) {
dump("setFieldValue: field.removeAttribute couldn't remove " +
propertyName + " from " + elementId + " e: " + e + "\n");
}
} else if (propertyName) {
try {
field.setAttribute(propertyName, newValue);
} catch (e) {
dump("setFieldValue: field.setAttribute couldn't set " +
propertyName + " from " + elementId + " to " + newValue +
" e: " + e + "\n");
}
} else {
field.value = newValue;
}
}
}
/**
* Helper function for getting data from the form,
* Get the value of a property of a XUL element
*
* PARAMETERS
* elementId - ID of XUL element to get from
* propertyName - OPTIONAL name of property to set, default is "value",
* use "checked" for radios & checkboxes, "data" for
* drop-downs
* RETURN
* newValue - value of property
*/
function getElementValue(elementId, propertyName)
{
var field = document.getElementById(elementId);
if (propertyName)
return field[propertyName];
return field.value;
}
function processEnableCheckbox(checkboxId, elementId)
{
if (document.getElementById(checkboxId).checked)
enableElement(elementId);
else
disableElement(elementId);
}
/*
* Enable/disable button if there are children in a listbox
*/
function updateListboxDeleteButton(listboxId, buttonId)
{
if ( document.getElementById(listboxId).getRowCount() > 0 )
enableElement(buttonId);
else
disableElement(buttonId);
}
/*
* Update plural singular menu items
*/
function updateMenuLabels(lengthFieldId, menuId )
{
var field = document.getElementById(lengthFieldId);
var menu = document.getElementById(menuId);
// figure out whether we should use singular or plural
var length = field.value;
var newLabelNumber;
// XXX This assumes that "0 days, minutes, etc." is plural in other languages.
if ( ( Number(length) == 0 ) || ( Number(length) > 1 ) )
newLabelNumber = "label2"
else
newLabelNumber = "label1"
// see what we currently show and change it if required
var oldLabelNumber = menu.getAttribute("labelnumber");
if ( newLabelNumber != oldLabelNumber ) {
// remember what we are showing now
menu.setAttribute("labelnumber", newLabelNumber);
// update the menu items
var items = menu.getElementsByTagName("menuitem");
for( var i = 0; i < items.length; ++i ) {
var menuItem = items[i];
var newLabel = menuItem.getAttribute(newLabelNumber);
menuItem.label = newLabel;
menuItem.setAttribute("label", newLabel);
}
// force the menu selection to redraw
var saveSelectedIndex = menu.selectedIndex;
menu.selectedIndex = -1;
menu.selectedIndex = saveSelectedIndex;
}
}
/** Select value in menuList. Throws string if no such value. **/
function menuListSelectItem(menuListId, value)
{
var menuList = document.getElementById(menuListId);
var index = menuListIndexOf(menuList, value);
if (index != -1) {
menuList.selectedIndex = index;
} else {
throw "menuListSelectItem: No such Element: "+value;
}
}
/** Find index of menuitem with the given value, or return -1 if not found. **/
function menuListIndexOf(menuList, value)
{
var items = menuList.menupopup.childNodes;
var index = -1;
for ( var i = 0; i < items.length; i++ ) {
var element = items[i];
if (element.nodeName == "menuitem")
index++;
if (element.getAttribute("value") == value)
return index;
}
return -1; // not found
}
function hasPositiveIntegerValue(elementId)
{
var value = document.getElementById(elementId).value;
if (value && (parseInt(value) == value) && value > 0)
return true;
return false;
}
/**
* We recreate the View > Toolbars menu each time it is opened to include any
* user-created toolbars.

View File

@@ -2,7 +2,7 @@
calendar.jar:
% content calendar %content/calendar/
* content/calendar/applicationUtil.js (content/applicationUtil.js)
content/calendar/applicationUtil.js (content/applicationUtil.js)
content/calendar/attachFile.js (content/attachFile.js)
* content/calendar/calendar.js (content/calendar.js)
content/calendar/calendarManagement.js (content/calendarManagement.js)