зеркало из https://github.com/mozilla/pjs.git
Adding in files for new multiple calendar.
This commit is contained in:
Родитель
87c980029c
Коммит
3d2c99f4ae
|
@ -0,0 +1,244 @@
|
|||
/* ***** 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
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* 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
|
||||
* OEone Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Mike Potter <mikep@oeone.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"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function calendarManager( CalendarWindow )
|
||||
{
|
||||
this.parent = CalendarWindow;
|
||||
|
||||
this.calendars = new Array();
|
||||
|
||||
this.getAllCalendars();
|
||||
|
||||
for( var i = 0; i < this.calendars.length; i++ )
|
||||
{
|
||||
this.addCalendarToListBox( this.calendars[i] );
|
||||
}
|
||||
|
||||
//if the calendars are being used, add them.
|
||||
this.addActiveCalendars();
|
||||
}
|
||||
|
||||
|
||||
calendarManager.prototype.addActiveCalendars = function()
|
||||
{
|
||||
for( var i = 1; i < this.calendars.length; i++ )
|
||||
{
|
||||
if( this.calendars[i].active === true )
|
||||
{
|
||||
this.addCalendar( this.calendars[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Launch the new calendar file dialog
|
||||
*/
|
||||
calendarManager.prototype.launchAddCalendarDialog = function( )
|
||||
{
|
||||
// set up a bunch of args to pass to the dialog
|
||||
var CalendarObject = new Object();
|
||||
CalendarObject.name = "";
|
||||
CalendarObject.path = "";
|
||||
|
||||
var args = new Object();
|
||||
args.mode = "new";
|
||||
|
||||
var thisManager = this;
|
||||
|
||||
var callback = function( CalendarObject ) { thisManager.addServerDialogResponse( CalendarObject ) };
|
||||
|
||||
args.onOk = callback;
|
||||
args.CalendarObject = CalendarObject;
|
||||
|
||||
// open the dialog modally
|
||||
openDialog("chrome://calendar/content/calendarServerDialog.xul", "caAddServer", "chrome,modal", args );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Called when OK is clicked in the new server dialog.
|
||||
*/
|
||||
calendarManager.prototype.addServerDialogResponse = function( CalendarObject )
|
||||
{
|
||||
var CurrentNumberOfServers = this.calendars.length;
|
||||
|
||||
//add the information to the preferences.
|
||||
this.parent.calendarPreferences.calendarPref.setCharPref( "server"+CurrentNumberOfServers+".name", CalendarObject.name );
|
||||
this.parent.calendarPreferences.calendarPref.setCharPref( "server"+CurrentNumberOfServers+".path", CalendarObject.path );
|
||||
this.parent.calendarPreferences.calendarPref.setBoolPref( "server"+CurrentNumberOfServers+".active", true );
|
||||
this.parent.calendarPreferences.calendarPref.setIntPref( "servers.count", CurrentNumberOfServers );
|
||||
|
||||
//add this to the global calendars array
|
||||
this.calendars[ this.calendars.length ] = CalendarObject;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Add the calendar so it is included in searches
|
||||
*/
|
||||
calendarManager.prototype.addCalendar = function( CalendarObject )
|
||||
{
|
||||
this.parent.eventSource.gICalLib.addCalendar( CalendarObject.path );
|
||||
|
||||
this.parent.calendarPreferences.calendarPref.setBoolPref( "server"+this.getCalendarIndex( CalendarObject )+".active", true );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Remove the calendar, so it doesn't get included in searches
|
||||
*/
|
||||
calendarManager.prototype.removeCalendar = function( CalendarObject )
|
||||
{
|
||||
this.parent.eventSource.gICalLib.removeCalendar( CalendarObject.path );
|
||||
|
||||
this.parent.calendarPreferences.calendarPref.setBoolPref( "server"+this.getCalendarIndex( CalendarObject )+".active", false );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Delete the calendar. Remove the file, it won't be used any longer.
|
||||
*/
|
||||
calendarManager.prototype.deleteCalendar = function( CalendarObject )
|
||||
{
|
||||
this.removeCalendar( CalendarObject );
|
||||
|
||||
//TODO: remove it from the array
|
||||
|
||||
//TODO: remove it from the prefs
|
||||
|
||||
//TODO: remove the file completely
|
||||
}
|
||||
|
||||
|
||||
calendarManager.prototype.getAllCalendars = function()
|
||||
{
|
||||
var profileComponent = Components.classes["@mozilla.org/profile/manager;1"].createInstance();
|
||||
|
||||
var profileInternal = profileComponent.QueryInterface(Components.interfaces.nsIProfileInternal);
|
||||
|
||||
var profileFile = profileInternal.getProfileDir(profileInternal.currentProfile);
|
||||
|
||||
profileFile.append("CalendarDataFile.ics");
|
||||
|
||||
//the root calendar is not stored in the prefs file.
|
||||
var thisCalendar = new Object;
|
||||
thisCalendar.name = "Default";
|
||||
thisCalendar.path = profileFile.path;
|
||||
thisCalendar.active = true;
|
||||
|
||||
this.calendars[ this.calendars.length ] = thisCalendar;
|
||||
|
||||
//go through the prefs file, calendars are stored in there.
|
||||
var NumberOfCalendars = this.parent.calendarPreferences.arrayOfPrefs.numberofservers;
|
||||
|
||||
//don't count the default server, so this starts at 1
|
||||
for( var i = 1; i < NumberOfCalendars; i++ )
|
||||
{
|
||||
thisCalendar = new Object();
|
||||
|
||||
try {
|
||||
|
||||
thisCalendar.name = this.parent.calendarPreferences.calendarPref.getCharPref( "server"+i+".name" );
|
||||
|
||||
thisCalendar.path = this.parent.calendarPreferences.calendarPref.getCharPref( "server"+i+".path" );
|
||||
|
||||
thisCalendar.active = this.parent.calendarPreferences.calendarPref.getBoolPref( "server"+i+".active" );
|
||||
|
||||
this.calendars[ this.calendars.length ] = thisCalendar;
|
||||
}
|
||||
catch ( e )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
calendarManager.prototype.addCalendarToListBox = function( CalendarObject )
|
||||
{
|
||||
var calendarListItem = document.createElement( "listitem" );
|
||||
calendarListItem.setAttribute( "id", "calendar-list-item" );
|
||||
calendarListItem.setAttribute( "onclick", "removeCalendar( event );" );
|
||||
calendarListItem.calendarObject = CalendarObject;
|
||||
|
||||
var ListCell = document.createElement( "listcell" );
|
||||
var CheckBox = document.createElement( "checkbox" );
|
||||
CheckBox.setAttribute( "checked", CalendarObject.active );
|
||||
ListCell.appendChild( CheckBox );
|
||||
calendarListItem.appendChild( ListCell );
|
||||
|
||||
ListCell = document.createElement( "listcell" );
|
||||
ListCell.setAttribute( "flex", "1" );
|
||||
ListCell.setAttribute( "label", CalendarObject.name );
|
||||
calendarListItem.appendChild( ListCell );
|
||||
|
||||
calendarListItem.setAttribute( "calendarPath", CalendarObject.path );
|
||||
|
||||
document.getElementById( "list-calendars-listbox" ).appendChild( calendarListItem );
|
||||
}
|
||||
|
||||
|
||||
calendarManager.prototype.getCalendarIndex = function( CalendarObject )
|
||||
{
|
||||
for( var i = 0; i < this.calendars.length; i++ )
|
||||
{
|
||||
if( this.calendars[i] === CalendarObject )
|
||||
{
|
||||
return( i );
|
||||
}
|
||||
}
|
||||
return( false );
|
||||
}
|
||||
|
||||
function removeCalendar( event )
|
||||
{
|
||||
var ThisCheckbox = event.currentTarget.getElementsByTagName( "checkbox" );
|
||||
|
||||
ThisCheckbox[0].checked = !ThisCheckbox[0].checked;
|
||||
|
||||
if( ThisCheckbox[0].checked == true )
|
||||
gCalendarWindow.calendarManager.addCalendar( event.currentTarget.calendarObject );
|
||||
else
|
||||
gCalendarWindow.calendarManager.removeCalendar( event.currentTarget.calendarObject );
|
||||
|
||||
//refresh the views
|
||||
var eventTable = gEventSource.getCurrentEvents();
|
||||
|
||||
refreshEventTree( eventTable );
|
||||
|
||||
gCalendarWindow.currentView.refreshEvents();
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
/* ***** 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
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* OEone Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@oeone.com>
|
||||
* Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
* ArentJan Banck <ajbanck@planet.nl>
|
||||
*
|
||||
* 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"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
|
||||
/***** calendar/calendarEventDialog.js
|
||||
* AUTHOR
|
||||
* Garth Smedley
|
||||
* REQUIRED INCLUDES
|
||||
* <script type="application/x-javascript" src="chrome://calendar/content/dateUtils.js"/>
|
||||
* <script type="application/x-javascript" src="chrome://calendar/content/calendarEvent.js"/>
|
||||
*
|
||||
* NOTES
|
||||
* Code for the calendar's new/edit event dialog.
|
||||
*
|
||||
* Invoke this dialog to create a new event as follows:
|
||||
|
||||
var args = new Object();
|
||||
args.mode = "new"; // "new" or "edit"
|
||||
args.onOk = <function>; // funtion to call when OK is clicked
|
||||
args.calendarEvent = calendarEvent; // newly creatd calendar event to be editted
|
||||
|
||||
calendar.openDialog("caNewEvent", "chrome://calendar/content/calendarEventDialog.xul", true, args );
|
||||
*
|
||||
* Invoke this dialog to edit an existing event as follows:
|
||||
*
|
||||
var args = new Object();
|
||||
args.mode = "edit"; // "new" or "edit"
|
||||
args.onOk = <function>; // funtion to call when OK is clicked
|
||||
args.calendarEvent = calendarEvent; // javascript object containin the event to be editted
|
||||
|
||||
* When the user clicks OK the onOk function will be called with a calendar event object.
|
||||
*
|
||||
*
|
||||
* IMPLEMENTATION NOTES
|
||||
**********
|
||||
*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* W I N D O W V A R I A B L E S
|
||||
*/
|
||||
|
||||
|
||||
var gCalendarObject; // event being edited
|
||||
var gOnOkFunction; // function to be called when user clicks OK
|
||||
|
||||
var gMode = ''; //what mode are we in? new or edit...
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* W I N D O W F U N C T I O N S
|
||||
*/
|
||||
|
||||
/**
|
||||
* Called when the dialog is loaded.
|
||||
*/
|
||||
|
||||
function loadCalendarServerDialog()
|
||||
{
|
||||
// Get arguments, see description at top of file
|
||||
|
||||
var args = window.arguments[0];
|
||||
|
||||
gMode = args.mode;
|
||||
|
||||
gOnOkFunction = args.onOk;
|
||||
gCalendarObject = args.CalendarObject;
|
||||
|
||||
// mode is "new or "edit" - show proper header
|
||||
var titleDataItem = null;
|
||||
|
||||
if( "new" == args.mode )
|
||||
{
|
||||
titleDataItem = document.getElementById( "data-event-title-new" );
|
||||
}
|
||||
else
|
||||
{
|
||||
titleDataItem = document.getElementById( "data-event-title-edit" );
|
||||
}
|
||||
|
||||
// set up OK, Cancel
|
||||
doSetOKCancel( onOKCommand, 0 );
|
||||
|
||||
// start focus on title
|
||||
|
||||
var firstFocus = document.getElementById( "server-name-textbox" );
|
||||
firstFocus.focus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called when the OK button is clicked.
|
||||
*/
|
||||
|
||||
function onOKCommand()
|
||||
{
|
||||
gCalendarObject.name = document.getElementById( "server-name-textbox" ).value;
|
||||
|
||||
gCalendarObject.path = document.getElementById( "server-path-textbox" ).value;
|
||||
|
||||
//TODO: check that the gCalendarObject.path is actually a file, if its not, create it.
|
||||
|
||||
// call caller's on OK function
|
||||
gOnOkFunction( gCalendarObject );
|
||||
|
||||
// tell standard dialog stuff to close the dialog
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function launchFilePicker()
|
||||
{
|
||||
// No show the 'Save As' dialog and ask for a filename to save to
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
|
||||
// caller can force disable of sand box, even if ON globally
|
||||
|
||||
fp.init(window, "Save As", nsIFilePicker.modeSave);
|
||||
|
||||
var ServerName = document.getElementById( "server-name-textbox" ).value;
|
||||
|
||||
if( ServerName == "" )
|
||||
fp.defaultString = "MozillaCalendarFile.ics";
|
||||
else
|
||||
fp.defaultString = "MozillaCalendar"+ServerName+".ics";
|
||||
|
||||
fp.defaultExtension = "ics";
|
||||
|
||||
const filterCalendar = "Calendar Files";
|
||||
const extensionCalendar = ".ics";
|
||||
fp.appendFilter( filterCalendar, "*" + extensionCalendar );
|
||||
|
||||
fp.show();
|
||||
|
||||
if (fp.file && fp.file.path.length > 0)
|
||||
{
|
||||
document.getElementById( "server-path-textbox" ).value = fp.file.path;
|
||||
|
||||
gCalendarObject.path = fp.file.path;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- ***** 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
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is OEone Calendar Code, released October 31st, 2001.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- OEone Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2001
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s): Mike Potter <mikep@oeone.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"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!-- CSS File with all styles specific to the dialog -->
|
||||
<?xml-stylesheet href="chrome://calendar/skin/dialogOverlay.css" type="text/css"?>
|
||||
|
||||
<!-- DTD File with all strings specific to the calendar -->
|
||||
<!DOCTYPE window
|
||||
[
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
|
||||
]>
|
||||
|
||||
|
||||
<window
|
||||
id="calendar-new-serverwindow"
|
||||
title="Calendar Server"
|
||||
onload="loadCalendarServerDialog()"
|
||||
persist="screenX screenY"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#">
|
||||
|
||||
|
||||
<!-- Javascript includes -->
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendarServerDialog.js"/>
|
||||
|
||||
<!-- Data used in JS from dtd -->
|
||||
|
||||
<dataset>
|
||||
<data id="data-event-title-new" value="&event.title.new;" />
|
||||
<data id="data-event-title-edit" value="&event.title.edit;" />
|
||||
</dataset>
|
||||
|
||||
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<!-- The dialog -->
|
||||
|
||||
<!-- dialog-box: from dialogOverlay.xul -->
|
||||
|
||||
<vbox id="dialog-box" flex="1">
|
||||
|
||||
<!-- standard-dialog-content: from dialogOverlay.xul -->
|
||||
|
||||
<vbox id="standard-dialog-content" flex="1">
|
||||
|
||||
<description>Name:</description>
|
||||
<textbox id="server-name-textbox"/>
|
||||
<description>File Location: </description>
|
||||
<textbox id="server-path-textbox"/>
|
||||
<button oncommand="launchFilePicker()" label="Browse..."/>
|
||||
|
||||
</vbox> <!-- standard-dialog-content -->
|
||||
|
||||
|
||||
<!-- Bottom Box -->
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
</vbox> <!-- dialog-box -->
|
||||
|
||||
</window>
|
|
@ -0,0 +1,181 @@
|
|||
/* ***** 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
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* OEone Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@oeone.com>
|
||||
* Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
* ArentJan Banck <ajbanck@planet.nl>
|
||||
*
|
||||
* 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"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
|
||||
/***** calendar/calendarEventDialog.js
|
||||
* AUTHOR
|
||||
* Garth Smedley
|
||||
* REQUIRED INCLUDES
|
||||
* <script type="application/x-javascript" src="chrome://calendar/content/dateUtils.js"/>
|
||||
* <script type="application/x-javascript" src="chrome://calendar/content/calendarEvent.js"/>
|
||||
*
|
||||
* NOTES
|
||||
* Code for the calendar's new/edit event dialog.
|
||||
*
|
||||
* Invoke this dialog to create a new event as follows:
|
||||
|
||||
var args = new Object();
|
||||
args.mode = "new"; // "new" or "edit"
|
||||
args.onOk = <function>; // funtion to call when OK is clicked
|
||||
args.calendarEvent = calendarEvent; // newly creatd calendar event to be editted
|
||||
|
||||
calendar.openDialog("caNewEvent", "chrome://calendar/content/calendarEventDialog.xul", true, args );
|
||||
*
|
||||
* Invoke this dialog to edit an existing event as follows:
|
||||
*
|
||||
var args = new Object();
|
||||
args.mode = "edit"; // "new" or "edit"
|
||||
args.onOk = <function>; // funtion to call when OK is clicked
|
||||
args.calendarEvent = calendarEvent; // javascript object containin the event to be editted
|
||||
|
||||
* When the user clicks OK the onOk function will be called with a calendar event object.
|
||||
*
|
||||
*
|
||||
* IMPLEMENTATION NOTES
|
||||
**********
|
||||
*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* W I N D O W V A R I A B L E S
|
||||
*/
|
||||
|
||||
|
||||
var gCalendarObject; // event being edited
|
||||
var gOnOkFunction; // function to be called when user clicks OK
|
||||
|
||||
var gMode = ''; //what mode are we in? new or edit...
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* W I N D O W F U N C T I O N S
|
||||
*/
|
||||
|
||||
/**
|
||||
* Called when the dialog is loaded.
|
||||
*/
|
||||
|
||||
function loadCalendarServerDialog()
|
||||
{
|
||||
// Get arguments, see description at top of file
|
||||
|
||||
var args = window.arguments[0];
|
||||
|
||||
gMode = args.mode;
|
||||
|
||||
gOnOkFunction = args.onOk;
|
||||
gCalendarObject = args.CalendarObject;
|
||||
|
||||
// mode is "new or "edit" - show proper header
|
||||
var titleDataItem = null;
|
||||
|
||||
if( "new" == args.mode )
|
||||
{
|
||||
titleDataItem = document.getElementById( "data-event-title-new" );
|
||||
}
|
||||
else
|
||||
{
|
||||
titleDataItem = document.getElementById( "data-event-title-edit" );
|
||||
}
|
||||
|
||||
// set up OK, Cancel
|
||||
doSetOKCancel( onOKCommand, 0 );
|
||||
|
||||
// start focus on title
|
||||
|
||||
var firstFocus = document.getElementById( "server-name-textbox" );
|
||||
firstFocus.focus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called when the OK button is clicked.
|
||||
*/
|
||||
|
||||
function onOKCommand()
|
||||
{
|
||||
gCalendarObject.name = document.getElementById( "server-name-textbox" ).value;
|
||||
|
||||
gCalendarObject.path = document.getElementById( "server-path-textbox" ).value;
|
||||
|
||||
//TODO: check that the gCalendarObject.path is actually a file, if its not, create it.
|
||||
|
||||
// call caller's on OK function
|
||||
gOnOkFunction( gCalendarObject );
|
||||
|
||||
// tell standard dialog stuff to close the dialog
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function launchFilePicker()
|
||||
{
|
||||
// No show the 'Save As' dialog and ask for a filename to save to
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
|
||||
// caller can force disable of sand box, even if ON globally
|
||||
|
||||
fp.init(window, "Save As", nsIFilePicker.modeSave);
|
||||
|
||||
var ServerName = document.getElementById( "server-name-textbox" ).value;
|
||||
|
||||
if( ServerName == "" )
|
||||
fp.defaultString = "MozillaCalendarFile.ics";
|
||||
else
|
||||
fp.defaultString = "MozillaCalendar"+ServerName+".ics";
|
||||
|
||||
fp.defaultExtension = "ics";
|
||||
|
||||
const filterCalendar = "Calendar Files";
|
||||
const extensionCalendar = ".ics";
|
||||
fp.appendFilter( filterCalendar, "*" + extensionCalendar );
|
||||
|
||||
fp.show();
|
||||
|
||||
if (fp.file && fp.file.path.length > 0)
|
||||
{
|
||||
document.getElementById( "server-path-textbox" ).value = fp.file.path;
|
||||
|
||||
gCalendarObject.path = fp.file.path;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- ***** 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
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is OEone Calendar Code, released October 31st, 2001.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- OEone Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2001
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s): Mike Potter <mikep@oeone.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"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!-- CSS File with all styles specific to the dialog -->
|
||||
<?xml-stylesheet href="chrome://calendar/skin/dialogOverlay.css" type="text/css"?>
|
||||
|
||||
<!-- DTD File with all strings specific to the calendar -->
|
||||
<!DOCTYPE window
|
||||
[
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
|
||||
]>
|
||||
|
||||
|
||||
<window
|
||||
id="calendar-new-serverwindow"
|
||||
title="Calendar Server"
|
||||
onload="loadCalendarServerDialog()"
|
||||
persist="screenX screenY"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#">
|
||||
|
||||
|
||||
<!-- Javascript includes -->
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendarServerDialog.js"/>
|
||||
|
||||
<!-- Data used in JS from dtd -->
|
||||
|
||||
<dataset>
|
||||
<data id="data-event-title-new" value="&event.title.new;" />
|
||||
<data id="data-event-title-edit" value="&event.title.edit;" />
|
||||
</dataset>
|
||||
|
||||
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<!-- The dialog -->
|
||||
|
||||
<!-- dialog-box: from dialogOverlay.xul -->
|
||||
|
||||
<vbox id="dialog-box" flex="1">
|
||||
|
||||
<!-- standard-dialog-content: from dialogOverlay.xul -->
|
||||
|
||||
<vbox id="standard-dialog-content" flex="1">
|
||||
|
||||
<description>Name:</description>
|
||||
<textbox id="server-name-textbox"/>
|
||||
<description>File Location: </description>
|
||||
<textbox id="server-path-textbox"/>
|
||||
<button oncommand="launchFilePicker()" label="Browse..."/>
|
||||
|
||||
</vbox> <!-- standard-dialog-content -->
|
||||
|
||||
|
||||
<!-- Bottom Box -->
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
</vbox> <!-- dialog-box -->
|
||||
|
||||
</window>
|
|
@ -14,12 +14,15 @@ calendar.jar:
|
|||
content/calendar/calendarEventDialogAttachFile.js (content/calendarEventDialogAttachFile.js)
|
||||
content/calendar/calendarImportExport.js (content/calendarImportExport.js)
|
||||
content/calendar/calendarMail.js (content/calendarMail.js)
|
||||
content/calendar/calendarManager.js (content/calendarManager.js)
|
||||
content/calendar/calendarMenuOverlay.xul (content/calendarMenuOverlay.xul)
|
||||
content/calendar/calendarMonthView.js (content/calendarMonthView.js)
|
||||
content/calendar/calendarMonthView.xul (content/calendarMonthView.xul)
|
||||
content/calendar/calendarOverlay.js (content/calendarOverlay.js)
|
||||
content/calendar/calendarOverlay.xul (content/calendarOverlay.xul)
|
||||
content/calendar/calendarSelection.js (content/calendarSelection.js)
|
||||
content/calendar/calendarServerDialog.js (content/calendarServerDialog.js)
|
||||
content/calendar/calendarServerDialog.xul (content/calendarServerDialog.xul)
|
||||
content/calendar/calendarToDoDialog.js (content/calendarToDoDialog.js)
|
||||
content/calendar/calendarToDoDialog.xul (content/calendarToDoDialog.xul)
|
||||
content/calendar/calendarWeekView.js (content/calendarWeekView.js)
|
||||
|
|
Загрузка…
Ссылка в новой задаче