more work on new/edit event dialog.
more of the todo/task controls are wired in and working.
r=pavlov@pavlov.net
This commit is contained in:
mattwillis%gmail.com 2007-12-21 16:35:23 +00:00
Родитель 7de8b6aa55
Коммит 4e83c30b2c
1 изменённых файлов: 145 добавлений и 45 удалений

Просмотреть файл

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -11,6 +12,14 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Calendar code.
*
* The Initial Developer of the Original Code is Eric Belhaire.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Matthew Willis <mattwillis@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -25,6 +34,7 @@
*
* ***** END LICENSE BLOCK ***** */
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
function toOpenWindowByType( inType, uri )
@ -103,64 +113,154 @@ function launchBrowser( UrlToGoTo )
//window.open( UrlToGoTo, "calendar-opened-window" );
}
function goToggleToolbar( id, elementID )
{
var toolbar = document.getElementById(id);
var element = document.getElementById(elementID);
if (toolbar) {
var isHidden = toolbar.hidden;
toolbar.hidden = !isHidden;
document.persist(id, 'hidden');
if (element) {
element.setAttribute("checked", isHidden ? "true" : "false");
document.persist(elementID, 'checked');
var toolbar = document.getElementById(id);
var element = document.getElementById(elementID);
if (toolbar) {
var isHidden = toolbar.hidden;
toolbar.hidden = !isHidden;
document.persist(id, 'hidden');
if (element) {
element.setAttribute("checked", isHidden ? "true" : "false");
document.persist(elementID, 'checked');
}
}
}
}
function openExtensions(aOpenMode)
{
const EMTYPE = "Extension:Manager";
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var needToOpen = true;
var windowType = EMTYPE + "-" + aOpenMode;
var windows = wm.getEnumerator(windowType);
while (windows.hasMoreElements()) {
var theEM = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal);
if (theEM.document.documentElement.getAttribute("windowtype") == windowType) {
theEM.focus();
needToOpen = false;
break;
}
}
const EMTYPE = "Extension:Manager";
if (needToOpen) {
const EMURL = "chrome://mozapps/content/extensions/extensions.xul?type=" + aOpenMode;
const EMFEATURES = "chrome,dialog=no,resizable";
window.openDialog(EMURL, "", EMFEATURES);
}
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var needToOpen = true;
var windowType = EMTYPE + "-" + aOpenMode;
var windows = wm.getEnumerator(windowType);
while (windows.hasMoreElements()) {
var theEM = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal);
if (theEM.document.documentElement.getAttribute("windowtype") == windowType) {
theEM.focus();
needToOpen = false;
break;
}
}
if (needToOpen) {
const EMURL = "chrome://mozapps/content/extensions/extensions.xul?type=" + aOpenMode;
const EMFEATURES = "chrome,dialog=no,resizable";
window.openDialog(EMURL, "", EMFEATURES);
}
}
function showElement( elementId )
{
try {
dump("showElement: showing "+elementId+"\n");
document.getElementById( elementId ).removeAttribute( "hidden" );
}
catch (e) {
dump("showElement: Couldn't remove hidden attribute from "+elementId+"\n");
}
try {
debug("showElement: showing " + elementId );
document.getElementById( elementId ).removeAttribute( "hidden" );
} catch (e) {
dump("showElement: Couldn't remove hidden attribute from " + elementId + "\n");
}
}
function hideElement( elementId )
{
try {
dump("hideElement: hiding "+elementId+"\n");
document.getElementById( elementId ).setAttribute( "hidden", "true" );
}
catch (e) {
dump("hideElement: Couldn't set hidden attribute on "+elementId+"\n");
}
try {
debug("hideElement: hiding " + elementId );
document.getElementById( elementId ).setAttribute( "hidden", "true" );
} catch (e) {
dump("hideElement: Couldn't set hidden attribute on " + elementId + "\n");
}
}
function enableElement( elementId )
{
try {
debug("enableElement: enabling " + elementId );
//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 {
debug("disableElement: disabling " + elementId );
document.getElementById( elementId ).setAttribute( "disabled", "true" );
} catch (e) {
dump("disableElement: Couldn't set disabled attribute to true on " + elementId + "\n");
}
}
function processEnableCheckbox( checkboxId, elementId )
{
if( document.getElementById( checkboxId ).checked )
enableElement( elementId );
else
disableElement( elementId );
}
/*
* Update plural singular menu items
*/
function updateMenuPlural( 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 = "labelplural"
else
newLabelNumber = "labelsingular"
// 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;
}
}
function debug( text )
{
if( gDebugEnabled )
dump( text + "\n");
}