зеркало из https://github.com/mozilla/pjs.git
Fixing up JS warnings, as per bug 162166.
This commit is contained in:
Родитель
372655b4aa
Коммит
fee2c2673b
|
@ -78,7 +78,7 @@ h1 {
|
|||
|
||||
<td id="mozver">
|
||||
<h1>
|
||||
<a id="mozlink" href="http://www.mozilla.org/projects/calendar/" target="_new">Mozilla Calendar 2002112114-cal</a>
|
||||
<a id="mozlink" href="http://www.mozilla.org/projects/calendar/" target="_new">Mozilla Calendar 2002112213-cal</a>
|
||||
</h1>
|
||||
<script type="application/x-javascript">
|
||||
// using try..catch to handle empty useragents and other cases where the regex fails to apply
|
||||
|
|
|
@ -457,12 +457,14 @@ var gNewDateVariable = null;
|
|||
|
||||
function newEventCommand( event )
|
||||
{
|
||||
var startDate;
|
||||
|
||||
if( gNewDateVariable != null )
|
||||
{
|
||||
var startDate = gNewDateVariable;
|
||||
startDate = gNewDateVariable;
|
||||
}
|
||||
else
|
||||
var startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
|
||||
var Minutes = Math.ceil( startDate.getMinutes() / 5 ) * 5 ;
|
||||
|
||||
|
@ -768,6 +770,8 @@ function deleteEventCommand( DoNotConfirm )
|
|||
|
||||
gICalLib.batchMode = true;
|
||||
|
||||
var ThisItem;
|
||||
|
||||
if( !DoNotConfirm )
|
||||
{
|
||||
if( confirm( "Are you sure you want to delete all selected events?" ) )
|
||||
|
@ -776,7 +780,7 @@ function deleteEventCommand( DoNotConfirm )
|
|||
|
||||
while( SelectedItems.length )
|
||||
{
|
||||
var ThisItem = SelectedItems.pop();
|
||||
ThisItem = SelectedItems.pop();
|
||||
|
||||
gICalLib.deleteEvent( ThisItem.id );
|
||||
}
|
||||
|
@ -788,7 +792,7 @@ function deleteEventCommand( DoNotConfirm )
|
|||
|
||||
while( SelectedItems.length )
|
||||
{
|
||||
var ThisItem = SelectedItems.pop();
|
||||
ThisItem = SelectedItems.pop();
|
||||
|
||||
gICalLib.deleteEvent( ThisItem.id );
|
||||
}
|
||||
|
@ -897,16 +901,16 @@ function getPreviewTextForRepeatingEvent( calendarEventDisplay )
|
|||
|
||||
if( calendarEventDisplay.recur == true )
|
||||
{
|
||||
var DateHtml = document.createElement( "description" );
|
||||
var DateText = document.createTextNode( "This is a repeating event." );
|
||||
DateHtml = document.createElement( "description" );
|
||||
DateText = document.createTextNode( "This is a repeating event." );
|
||||
DateHtml.appendChild( DateText );
|
||||
HolderBox.appendChild( DateHtml );
|
||||
}
|
||||
else
|
||||
{
|
||||
var DateHtml = document.createElement( "description" );
|
||||
var startDate = new Date( calendarEventDisplay.event.end.getTime() );
|
||||
var DateText = document.createTextNode( "End: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
|
||||
DateHtml = document.createElement( "description" );
|
||||
startDate = new Date( calendarEventDisplay.event.end.getTime() );
|
||||
DateText = document.createTextNode( "End: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
|
||||
DateHtml.appendChild( DateText );
|
||||
HolderBox.appendChild( DateHtml );
|
||||
}
|
||||
|
|
|
@ -1,289 +0,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 Mozilla Calendar code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* ArentJan Banck <ajbanck@planet.nl>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): 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 ***** */
|
||||
|
||||
/***** calendarClipboard
|
||||
*
|
||||
* NOTES
|
||||
* TODO items
|
||||
* - Add a clipboard listener, to enable/disable menu-items depending if
|
||||
* valid clipboard data is available.
|
||||
*
|
||||
******/
|
||||
|
||||
|
||||
function getClipboard()
|
||||
{
|
||||
const kClipboardContractID = "@mozilla.org/widget/clipboard;1";
|
||||
const kClipboardIID = Components.interfaces.nsIClipboard;
|
||||
return Components.classes[kClipboardContractID].getService(kClipboardIID);
|
||||
}
|
||||
|
||||
|
||||
function createTransferable()
|
||||
{
|
||||
const kTransferableContractID = "@mozilla.org/widget/transferable;1";
|
||||
const kTransferableIID = Components.interfaces.nsITransferable
|
||||
return Components.classes[kTransferableContractID].createInstance(kTransferableIID);
|
||||
}
|
||||
|
||||
|
||||
function createSupportsArray()
|
||||
{
|
||||
const kSuppArrayContractID = "@mozilla.org/supports-array;1";
|
||||
const kSuppArrayIID = Components.interfaces.nsISupportsArray;
|
||||
return Components.classes[kSuppArrayContractID].createInstance(kSuppArrayIID);
|
||||
}
|
||||
|
||||
|
||||
// Should we use (wide)String only, or no (wide)Strings for compatibility?
|
||||
function createSupportsCString()
|
||||
{
|
||||
const kSuppStringContractID = "@mozilla.org/supports-cstring;1";
|
||||
const kSuppStringIID = Components.interfaces.nsISupportsCString;
|
||||
return Components.classes[kSuppStringContractID].createInstance(kSuppStringIID);
|
||||
}
|
||||
|
||||
|
||||
function createSupportsString()
|
||||
{
|
||||
const kSuppStringContractID = "@mozilla.org/supports-string;1";
|
||||
const kSuppStringIID = Components.interfaces.nsISupportsString;
|
||||
return Components.classes[kSuppStringContractID].createInstance(kSuppStringIID);
|
||||
}
|
||||
|
||||
|
||||
function createSupportsWString()
|
||||
{
|
||||
const kSuppStringContractID = "@mozilla.org/supports-wstring;1";
|
||||
const kSuppStringIID = Components.interfaces.nsISupportsWString;
|
||||
return Components.classes[kSuppStringContractID].createInstance(kSuppStringIID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the clipboard has items that can be pasted into Calendar.
|
||||
* This must be of type "text/calendar" or "text/unicode"
|
||||
*/
|
||||
|
||||
function canPaste()
|
||||
{
|
||||
const kClipboardIID = Components.interfaces.nsIClipboard;
|
||||
|
||||
var clipboard = getClipboard();
|
||||
var flavourArray = createSupportsArray();
|
||||
var flavours = ["text/calendar", "text/unicode"];
|
||||
|
||||
for (var i = 0; i < flavours.length; ++i)
|
||||
{
|
||||
const kSuppString = createSupportsCString();
|
||||
kSuppString.data = flavours[i];
|
||||
flavourArray.AppendElement(kSuppString);
|
||||
}
|
||||
|
||||
return clipboard.hasDataMatchingFlavors(flavourArray, kClipboardIID.kGlobalClipboard);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy iCalendar data to the Clipboard, and delete the selected events.
|
||||
* Does not use eventarray parameter, because DeletCcommand delete selected events.
|
||||
*/
|
||||
|
||||
function cutToClipboard( /* calendarEventArray */)
|
||||
{
|
||||
// if( !calendarEventArray)
|
||||
var calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
|
||||
|
||||
if( copyToClipboard( calendarEventArray ) )
|
||||
{
|
||||
deleteEventCommand( true ); // deletes all selected events without prompting.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy iCalendar data to the Clipboard. The data is copied to three types:
|
||||
* 1) text/calendar. Found that name somewhere in mail code. not used outside
|
||||
* Calendar as far as I know, so this can be customized for internal use.
|
||||
* 2) text/unicode. Plaintext iCalendar data, tested on Windows for Outlook 2000
|
||||
* and Lotus Organizer.
|
||||
* 3) text/html. Not for parsing, only pretty looking calendar data.
|
||||
*
|
||||
**/
|
||||
|
||||
function copyToClipboard( calendarEventArray )
|
||||
{
|
||||
if( !calendarEventArray)
|
||||
{
|
||||
var calendarEventArray = new Array();
|
||||
calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
|
||||
}
|
||||
|
||||
if(calendarEventArray.length == 0)
|
||||
alert("No events selected");
|
||||
|
||||
var calendarEvent;
|
||||
var sTextiCalendar = eventArrayToICalString( calendarEventArray );
|
||||
var sTextiCalendarExport = eventArrayToICalString( calendarEventArray, true );
|
||||
var sTextHTML = eventArrayToHTML( calendarEventArray );
|
||||
|
||||
// 1. get the clipboard service
|
||||
var clipboard = getClipboard();
|
||||
|
||||
// 2. create the transferable
|
||||
var trans = createTransferable();
|
||||
|
||||
if ( trans && clipboard) {
|
||||
|
||||
// 3. register the data flavors
|
||||
trans.addDataFlavor("text/calendar");
|
||||
trans.addDataFlavor("text/unicode");
|
||||
trans.addDataFlavor("text/html");
|
||||
|
||||
// 4. create the data objects
|
||||
var icalWrapper = createSupportsString();
|
||||
var textWrapper = createSupportsString();
|
||||
var htmlWrapper = createSupportsString();
|
||||
|
||||
if ( icalWrapper && textWrapper && htmlWrapper ) {
|
||||
// get the data
|
||||
icalWrapper.data = sTextiCalendar; // plainTextRepresentation;
|
||||
textWrapper.data = sTextiCalendarExport; // plainTextRepresentation;
|
||||
htmlWrapper.data = sTextHTML; // htmlRepresentation;
|
||||
|
||||
// 5. add data objects to transferable
|
||||
// Both Outlook 2000 client and Lotus Organizer use text/unicode when pasting iCalendar data
|
||||
trans.setTransferData ( "text/calendar", icalWrapper, icalWrapper.data.length*2 ); // double byte data
|
||||
trans.setTransferData ( "text/unicode", textWrapper, textWrapper.data.length*2 );
|
||||
trans.setTransferData ( "text/html", htmlWrapper, htmlWrapper.data.length*2 );
|
||||
|
||||
clipboard.setData( trans, null, Components.interfaces.nsIClipboard.kGlobalClipboard );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Paste iCalendar events from the clipboard,
|
||||
* or paste clipboard text into description of new event
|
||||
*/
|
||||
|
||||
function pasteFromClipboard()
|
||||
{
|
||||
const kClipboardIID = Components.interfaces.nsIClipboard;
|
||||
|
||||
if( canPaste() ) {
|
||||
// 1. get the clipboard service
|
||||
var clipboard = getClipboard();
|
||||
|
||||
// 2. create the transferable
|
||||
var trans = createTransferable();
|
||||
|
||||
if ( trans && clipboard) {
|
||||
|
||||
// 3. register the data flavors you want, highest fidelity first!
|
||||
trans.addDataFlavor("text/calendar");
|
||||
trans.addDataFlavor("text/unicode");
|
||||
|
||||
// 4. get transferable from clipboard
|
||||
clipboard.getData ( trans, kClipboardIID.kGlobalClipboard);
|
||||
|
||||
// 5. ask transferable for the best flavor. Need to create new JS
|
||||
// objects for the out params.
|
||||
var flavour = { };
|
||||
var data = { };
|
||||
var length = { };
|
||||
trans.getAnyTransferData(flavour, data, length);
|
||||
data = data.value.QueryInterface(Components.interfaces.nsISupportsString).data;
|
||||
//DEBUG alert("clipboard type: " + flavour.value);
|
||||
var calendarEventArray;
|
||||
var startDate;
|
||||
|
||||
switch (flavour.value) {
|
||||
case "text/calendar":
|
||||
|
||||
calendarEventArray = parseIcalData( data );
|
||||
|
||||
//change the date of all the events to now
|
||||
startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
|
||||
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
|
||||
for( var i = 0; i < calendarEventArray.length; i++ )
|
||||
{
|
||||
calendarEventArray[i].start.setTime( startDate );
|
||||
calendarEventArray[i].end.setTime( endDateTime );
|
||||
}
|
||||
addEventsToCalendar( calendarEventArray );
|
||||
break;
|
||||
case "text/unicode":
|
||||
if ( data.indexOf("BEGIN:VEVENT") == -1 )
|
||||
{
|
||||
// no iCalendar data, paste clipboard text into description of new event
|
||||
calendarEvent = createEvent();
|
||||
initCalendarEvent( calendarEvent );
|
||||
calendarEvent.description = data;
|
||||
editNewEvent( calendarEvent );
|
||||
}
|
||||
else
|
||||
{
|
||||
calendarEventArray = parseIcalData( data );
|
||||
//change the date of all the events to now
|
||||
startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
|
||||
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
|
||||
for( var i = 0; i < calendarEventArray.length; i++ )
|
||||
{
|
||||
calendarEventArray[i].start.setTime( startDate );
|
||||
calendarEventArray[i].end.setTime( endDateTime );
|
||||
}
|
||||
|
||||
addEventsToCalendar( calendarEventArray );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
alert("Unknown clipboard type: " + flavour.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alert( "No iCalendar or text on the clipboard." );
|
||||
}
|
|
@ -1,596 +0,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): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@oeone.com>
|
||||
* Karl Guertin <grayrest@grayrest.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 ***** */
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* DayView Class subclass of CalendarView
|
||||
*
|
||||
* Calendar day view class
|
||||
*
|
||||
* PROPERTIES
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Make DayView inherit from CalendarView
|
||||
|
||||
DayView.prototype = new CalendarView();
|
||||
DayView.prototype.constructor = DayView;
|
||||
|
||||
/**
|
||||
* DayView Constructor.
|
||||
*
|
||||
* PARAMETERS
|
||||
* calendarWindow - the owning instance of CalendarWindow.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function DayView( calendarWindow )
|
||||
{
|
||||
// call super
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
//set the time on the left hand side labels
|
||||
//need to do this in JavaScript to preserve formatting
|
||||
for( var i = 0; i < 24; i++ )
|
||||
{
|
||||
/*
|
||||
** FOR SOME REASON, THIS IS NOT WORKING FOR MIDNIGHT
|
||||
*/
|
||||
var TimeToFormat = new Date();
|
||||
|
||||
TimeToFormat.setHours( i );
|
||||
|
||||
TimeToFormat.setMinutes( "0" );
|
||||
|
||||
var FormattedTime = calendarWindow.dateFormater.getFormatedTime( TimeToFormat );
|
||||
|
||||
var Label = document.getElementById( "day-view-hour-"+i );
|
||||
|
||||
Label.setAttribute( "value", FormattedTime );
|
||||
}
|
||||
|
||||
var dayViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function dv_EventSelectionObserver_OnSelectionChanged( EventSelectionArray )
|
||||
{
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
gCalendarWindow.dayView.selectBoxForEvent( EventSelectionArray[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( dayViewEventSelectionObserver );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the events for the current month
|
||||
*
|
||||
*/
|
||||
|
||||
DayView.prototype.refreshEvents = function dayview_refreshEvents( )
|
||||
{
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
|
||||
// remove old event boxes
|
||||
|
||||
var eventBoxList = document.getElementsByAttribute( "eventbox", "dayview" );
|
||||
|
||||
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
||||
{
|
||||
var eventBox = eventBoxList[ eventBoxIndex ];
|
||||
|
||||
eventBox.parentNode.removeChild( eventBox );
|
||||
}
|
||||
|
||||
//get the all day box.
|
||||
|
||||
var AllDayBox = document.getElementById( "all-day-content-box" );
|
||||
AllDayBox.setAttribute( "collapsed", "true" );
|
||||
|
||||
//remove all the text from the all day content box.
|
||||
|
||||
while( AllDayBox.hasChildNodes() )
|
||||
{
|
||||
AllDayBox.removeChild( AllDayBox.firstChild );
|
||||
}
|
||||
|
||||
//shrink the day's content box.
|
||||
|
||||
document.getElementById( "day-view-content-box" ).removeAttribute( "allday" );
|
||||
|
||||
//make the text node that will contain the text for the all day box.
|
||||
var calendarStringBundle = srGetStrBundle("chrome://calendar/locale/calendar.properties");
|
||||
|
||||
HtmlNode = document.createElement( "description" );
|
||||
HtmlNode.setAttribute( "class", "all-day-content-box-text-title" );
|
||||
TextNode = document.createTextNode( calendarStringBundle.GetStringFromName( "AllDayEvents" ) );
|
||||
HtmlNode.appendChild( TextNode );
|
||||
document.getElementById( "all-day-content-box" ).appendChild( HtmlNode );
|
||||
|
||||
// get the events for the day and loop through them
|
||||
|
||||
var dayEventList = this.calendarWindow.eventSource.getEventsForDay( this.calendarWindow.getSelectedDate() );
|
||||
|
||||
//refresh the array and the current spot.
|
||||
var LowestStartHour = getIntPref( this.calendarWindow.calendarPreferences.calendarPref, "event.defaultstarthour", 8 );
|
||||
var HighestEndHour = getIntPref( this.calendarWindow.calendarPreferences.calendarPref, "event.defaultendhour", 17 );;
|
||||
for ( var i = 0; i < dayEventList.length; i++ )
|
||||
{
|
||||
dayEventList[i].OtherSpotArray = new Array('0');
|
||||
dayEventList[i].CurrentSpot = 0;
|
||||
dayEventList[i].NumberOfSameTimeEvents = 0;
|
||||
if( dayEventList[i].event.allDay != true )
|
||||
{
|
||||
var ThisLowestStartHour = new Date( dayEventList[0].displayDate.getTime() );
|
||||
if( ThisLowestStartHour.getHours() < LowestStartHour )
|
||||
LowestStartHour = ThisLowestStartHour.getHours();
|
||||
|
||||
var EndDate = new Date( dayEventList[i].event.end.getTime() );
|
||||
if( EndDate.getHours() > HighestEndHour )
|
||||
HighestEndHour = EndDate;
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < 24; i++ )
|
||||
{
|
||||
document.getElementById( "day-tree-item-"+i ).removeAttribute( "collapsed" );
|
||||
}
|
||||
|
||||
//alert( "LowestStartHour is "+LowestStartHour );
|
||||
for( i = 0; i < LowestStartHour; i++ )
|
||||
{
|
||||
document.getElementById( "day-tree-item-"+i ).setAttribute( "collapsed", "true" );
|
||||
}
|
||||
|
||||
for( i = ( HighestEndHour + 1 ); i < 24; i++ )
|
||||
{
|
||||
document.getElementById( "day-tree-item-"+i ).setAttribute( "collapsed", "true" );
|
||||
}
|
||||
|
||||
for ( i = 0; i < dayEventList.length; i++ )
|
||||
{
|
||||
var calendarEventDisplay = dayEventList[i];
|
||||
|
||||
//check to make sure that the event is not an all day event...
|
||||
if ( calendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
//see if there's another event at the same start time.
|
||||
|
||||
for ( j = 0; j < dayEventList.length; j++ )
|
||||
{
|
||||
thisCalendarEventDisplay = dayEventList[j];
|
||||
|
||||
//if this event overlaps with another event...
|
||||
if ( ( ( thisCalendarEventDisplay.displayDate >= calendarEventDisplay.displayDate &&
|
||||
thisCalendarEventDisplay.displayDate.getTime() < calendarEventDisplay.event.end.getTime() ) ||
|
||||
( calendarEventDisplay.displayDate >= thisCalendarEventDisplay.displayDate &&
|
||||
calendarEventDisplay.displayDate.getTime() < thisCalendarEventDisplay.event.end.getTime() ) ) &&
|
||||
calendarEventDisplay.event.id != thisCalendarEventDisplay.event.id &&
|
||||
thisCalendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
//get the spot that this event will go in.
|
||||
var ThisSpot = thisCalendarEventDisplay.CurrentSpot;
|
||||
|
||||
calendarEventDisplay.OtherSpotArray.push( ThisSpot );
|
||||
ThisSpot++;
|
||||
|
||||
if ( ThisSpot > calendarEventDisplay.CurrentSpot )
|
||||
{
|
||||
calendarEventDisplay.CurrentSpot = ThisSpot;
|
||||
}
|
||||
}
|
||||
}
|
||||
SortedOtherSpotArray = new Array();
|
||||
SortedOtherSpotArray = calendarEventDisplay.OtherSpotArray.sort( this.calendarWindow.compareNumbers );
|
||||
LowestNumber = this.calendarWindow.getLowestElementNotInArray( SortedOtherSpotArray );
|
||||
|
||||
//this is the actual spot (0 -> n) that the event will go in on the day view.
|
||||
calendarEventDisplay.CurrentSpot = LowestNumber;
|
||||
calendarEventDisplay.NumberOfSameTimeEvents = SortedOtherSpotArray.length;
|
||||
}
|
||||
}
|
||||
|
||||
for ( var eventIndex = 0; eventIndex < dayEventList.length; ++eventIndex )
|
||||
{
|
||||
calendarEventDisplay = dayEventList[ eventIndex ];
|
||||
|
||||
//if its an all day event, don't show it in the hours stack.
|
||||
if ( calendarEventDisplay.event.allDay == true )
|
||||
{
|
||||
// build up the text to show for this event
|
||||
|
||||
var eventText = calendarEventDisplay.event.title;
|
||||
|
||||
if( calendarEventDisplay.event.location )
|
||||
{
|
||||
eventText += " " + calendarEventDisplay.event.location;
|
||||
}
|
||||
|
||||
if( calendarEventDisplay.event.description )
|
||||
{
|
||||
eventText += " " + calendarEventDisplay.event.description;
|
||||
}
|
||||
|
||||
//show the all day box
|
||||
AllDayBox.removeAttribute( "collapsed" );
|
||||
|
||||
//shrink the day's content box.
|
||||
document.getElementById( "day-view-content-box" ).setAttribute( "allday", "true" );
|
||||
|
||||
//note the use of the AllDayText Attribute.
|
||||
//This is used to remove the text when the day is changed.
|
||||
|
||||
newTextNode = document.createElement( "label" );
|
||||
newTextNode.setAttribute( "value", eventText );
|
||||
newTextNode.calendarEventDisplay = calendarEventDisplay;
|
||||
newTextNode.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
newTextNode.setAttribute( "onclick", "dayEventItemClick( this, event )" );
|
||||
newTextNode.setAttribute( "ondblclick", "dayEventItemDoubleClick( this, event )" );
|
||||
newTextNode.setAttribute( "tooltip", "eventTooltip" );
|
||||
newTextNode.setAttribute( "AllDayText", "true" );
|
||||
|
||||
newImage = document.createElement("image");
|
||||
newImage.setAttribute( "class", "all-day-event-class" );
|
||||
newImage.calendarEventDisplay = calendarEventDisplay;
|
||||
newImage.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
newImage.setAttribute( "onclick", "dayEventItemClick( this, event )" );
|
||||
newImage.setAttribute( "ondblclick", "dayEventItemDoubleClick( this, event )" );
|
||||
newImage.setAttribute( "tooltip", "eventTooltip" );
|
||||
//newImage.setAttribute( "AllDayText", "true" );
|
||||
|
||||
AllDayBox.appendChild( newImage );
|
||||
AllDayBox.appendChild( newTextNode );
|
||||
}
|
||||
else
|
||||
{
|
||||
eventBox = this.createEventBox( calendarEventDisplay );
|
||||
|
||||
//add the box to the stack.
|
||||
document.getElementById( "day-view-content-board" ).appendChild( eventBox );
|
||||
}
|
||||
|
||||
// select the hour of the selected item, if there is an item whose date matches
|
||||
|
||||
// mark the box as selected, if the event is
|
||||
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* This creates an event box for the day view
|
||||
*/
|
||||
DayView.prototype.createEventBox = function dayview_createEventBox( calendarEventDisplay )
|
||||
{
|
||||
var eventStartDate = calendarEventDisplay.displayDate;
|
||||
var eventEndDate = calendarEventDisplay.displayEndDate;
|
||||
var startHour = eventStartDate.getHours();
|
||||
var startMinutes = eventStartDate.getMinutes();
|
||||
|
||||
var eventEndDateTime = new Date( 2000, 1, 1, eventEndDate.getHours(), eventEndDate.getMinutes(), 0 );
|
||||
var eventStartDateTime = new Date( 2000, 1, 1, eventStartDate.getHours(), eventStartDate.getMinutes(), 0 );
|
||||
|
||||
var eventDuration = new Date( eventEndDateTime - eventStartDateTime );
|
||||
|
||||
var hourDuration = eventDuration / (3600000);
|
||||
|
||||
var eventBox = document.createElement( "vbox" );
|
||||
|
||||
var boxHeight = document.getElementById( "day-tree-item-"+startHour ).boxObject.height;
|
||||
var topHeight = document.getElementById( "day-tree-item-"+startHour ).boxObject.y - document.getElementById( "day-tree-item-"+startHour ).parentNode.boxObject.y;
|
||||
var boxWidth = document.getElementById( "day-tree-item-"+startHour ).boxObject.width;
|
||||
|
||||
var topHeight = eval( topHeight + ( ( startMinutes/60 ) * boxHeight ) );
|
||||
topHeight = Math.round( topHeight ) - 2;
|
||||
eventBox.setAttribute( "top", topHeight );
|
||||
|
||||
eventBox.setAttribute( "height", Math.round( ( hourDuration*boxHeight ) + 1 ) );
|
||||
|
||||
var width = Math.round( ( boxWidth-kDayViewHourLeftStart ) / calendarEventDisplay.NumberOfSameTimeEvents );
|
||||
eventBox.setAttribute( "width", width );
|
||||
|
||||
var left = eval( ( ( calendarEventDisplay.CurrentSpot - 1 ) * width ) + kDayViewHourLeftStart );
|
||||
left = left - ( calendarEventDisplay.CurrentSpot - 1 );
|
||||
eventBox.setAttribute( "left", Math.round( left ) );
|
||||
|
||||
//if you change this class, you have to change calendarViewDNDObserver in calendarDragDrop.js
|
||||
eventBox.setAttribute( "class", "day-view-event-class" );
|
||||
eventBox.setAttribute( "flex", "1" );
|
||||
eventBox.setAttribute( "eventbox", "dayview" );
|
||||
eventBox.setAttribute( "onclick", "dayEventItemClick( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "dayEventItemDoubleClick( this, event )" );
|
||||
// dragdrop events
|
||||
eventBox.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,calendarViewDNDObserver);" );
|
||||
eventBox.setAttribute( "ondragover", "nsDragAndDrop.dragOver(event,calendarViewDNDObserver)" );
|
||||
eventBox.setAttribute( "ondragdrop", "nsDragAndDrop.drop(event,calendarViewDNDObserver)" );
|
||||
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "eventTooltip" );
|
||||
eventBox.setAttribute( "name", "day-view-event-box-"+calendarEventDisplay.event.id );
|
||||
if( calendarEventDisplay.event.categories && calendarEventDisplay.event.categories != "" )
|
||||
{
|
||||
eventBox.setAttribute( calendarEventDisplay.event.categories, "true" );
|
||||
}
|
||||
|
||||
var eventHTMLElement = document.createElement( "label" );
|
||||
eventHTMLElement.setAttribute( "value", calendarEventDisplay.event.title );
|
||||
eventHTMLElement.setAttribute( "flex", "1" );
|
||||
eventHTMLElement.setAttribute( "crop", "end" );
|
||||
eventBox.appendChild( eventHTMLElement );
|
||||
|
||||
/*
|
||||
if( calendarEventDisplay.event.description != "" )
|
||||
{
|
||||
var eventHTMLElement2 = document.createElement( "description" );
|
||||
eventHTMLElement2.setAttribute( "value", calendarEventDisplay.event.description );
|
||||
eventHTMLElement2.setAttribute( "flex", "1" );
|
||||
eventHTMLElement2.setAttribute( "crop", "end" );
|
||||
eventBox.appendChild( eventHTMLElement2 );
|
||||
}
|
||||
*/
|
||||
// add a property to the event box that holds the calendarEvent that the
|
||||
// box represents
|
||||
|
||||
eventBox.calendarEventDisplay = calendarEventDisplay;
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
||||
|
||||
return( eventBox );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches from a different view
|
||||
*/
|
||||
|
||||
DayView.prototype.switchFrom = function dayview_switchFrom( )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches to the day view
|
||||
*/
|
||||
|
||||
DayView.prototype.switchTo = function dayview_switchTo( )
|
||||
{
|
||||
// disable/enable view switching buttons
|
||||
|
||||
var weekViewButton = document.getElementById( "week_view_command" );
|
||||
var monthViewButton = document.getElementById( "month_view_command" );
|
||||
var dayViewButton = document.getElementById( "day_view_command" );
|
||||
|
||||
monthViewButton.removeAttribute( "disabled" );
|
||||
weekViewButton.removeAttribute( "disabled" );
|
||||
dayViewButton.setAttribute( "disabled", "true" );
|
||||
|
||||
// switch views in the deck
|
||||
|
||||
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
||||
calendarDeckItem.selectedIndex = 2;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the display, but not the events
|
||||
*/
|
||||
|
||||
DayView.prototype.refreshDisplay = function dayview_refreshDisplay( )
|
||||
{
|
||||
// update the title
|
||||
var dayName = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() );
|
||||
if (this.calendarWindow.getSelectedDate().getDay() < 2)
|
||||
{
|
||||
if (this.calendarWindow.getSelectedDate().getDay() == 0)
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 6 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 2 );
|
||||
}
|
||||
if (this.calendarWindow.getSelectedDate().getDay() > 4)
|
||||
{
|
||||
if (this.calendarWindow.getSelectedDate().getDay() == 6)
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 6);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 2);
|
||||
}
|
||||
var monthName = this.calendarWindow.dateFormater.getMonthName( this.calendarWindow.getSelectedDate().getMonth() );
|
||||
|
||||
var dateString = monthName + " " + this.calendarWindow.getSelectedDate().getDate() + " " + this.calendarWindow.getSelectedDate().getFullYear();
|
||||
|
||||
var dayTextItemPrev2 = document.getElementById( "-2-day-title" );
|
||||
var dayTextItemPrev1 = document.getElementById( "-1-day-title" );
|
||||
var dayTextItem = document.getElementById( "0-day-title" );
|
||||
var dayTextItemNext1 = document.getElementById( "1-day-title" );
|
||||
var dayTextItemNext2 = document.getElementById( "2-day-title" );
|
||||
var daySpecificTextItem = document.getElementById( "0-day-specific-title" );
|
||||
dayTextItemPrev2.setAttribute( "value" , dayNamePrev2 );
|
||||
dayTextItemPrev1.setAttribute( "value" , dayNamePrev1 );
|
||||
dayTextItem.setAttribute( "value" , dayName );
|
||||
dayTextItemNext1.setAttribute( "value" , dayNameNext1 );
|
||||
dayTextItemNext2.setAttribute( "value" , dayNameNext2 );
|
||||
daySpecificTextItem.setAttribute( "value" , dateString );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
* and we want to know what the default start date should be for the event.
|
||||
*/
|
||||
|
||||
DayView.prototype.getNewEventDate = function dayview_getNewEventDate( )
|
||||
{
|
||||
var start = new Date( this.calendarWindow.getSelectedDate() );
|
||||
|
||||
start.setHours( start.getHours() );
|
||||
start.setMinutes( Math.ceil( start.getMinutes() / 5 ) * 5 );
|
||||
start.setSeconds( 0 );
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the next day.
|
||||
*/
|
||||
|
||||
DayView.prototype.goToNext = function dayview_goToNext(goDays)
|
||||
{
|
||||
if (goDays)
|
||||
{
|
||||
var nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + goDays );
|
||||
this.goToDay( nextDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
var nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + 1 );
|
||||
this.goToDay( nextDay );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the previous day.
|
||||
*/
|
||||
|
||||
DayView.prototype.goToPrevious = function dayview_goToPrevious( goDays )
|
||||
{
|
||||
if (goDays)
|
||||
{
|
||||
var prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - goDays );
|
||||
this.goToDay( prevDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
var prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - 1 );
|
||||
this.goToDay( prevDay );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DayView.prototype.selectBoxForEvent = function dayview_selectBoxForEvent( calendarEvent )
|
||||
{
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* clear the selected event by taking off the selected attribute.
|
||||
*/
|
||||
DayView.prototype.clearSelectedEvent = function dayview_clearSelectedEvent( )
|
||||
{
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DayView.prototype.clearSelectedDate = function dayview_clearSelectedDate( )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DayView.prototype.getVisibleEvent = function dayview_getVisibleEvent( calendarEvent )
|
||||
{
|
||||
eventBox = document.getElementById( "day-view-event-box-"+calendarEvent.id );
|
||||
if ( eventBox )
|
||||
{
|
||||
return eventBox;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is needed because it may be called after the end of each day.
|
||||
*/
|
||||
|
||||
DayView.prototype.hiliteTodaysDate = function dayview_hiliteTodaysDate( )
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -1,327 +0,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 Mozilla Calendar code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* ArentJan Banck <ajbanck@planet.nl>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): 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 ***** */
|
||||
|
||||
// TODO move nsIDragService definition
|
||||
//const nsIDragService = Components.interfaces.nsIDragService;
|
||||
|
||||
// function to select whatever what is clicked to start dragging, Mozilla doesn't do this
|
||||
function calendarViewClick ( aEvent ) {
|
||||
if(aEvent.target.className == "day-view-hour-box-class")
|
||||
dayViewHourClick( aEvent );
|
||||
|
||||
if(aEvent.target.className == "day-view-event-class")
|
||||
dayEventItemClick( aEvent.target, aEvent );
|
||||
|
||||
if (gCalendarWindow.currentView == gCalendarWindow.weekView)
|
||||
;//weekViewHourClick( aEvent );
|
||||
}
|
||||
|
||||
//var startDateIndex;
|
||||
|
||||
var calendarViewDNDObserver = {
|
||||
|
||||
getSupportedFlavours : function () {
|
||||
var flavourSet = new FlavourSet();
|
||||
flavourSet.appendFlavour("text/unicode");
|
||||
flavourSet.appendFlavour("text/calendar");
|
||||
flavourSet.appendFlavour("text/calendar-interval");
|
||||
flavourSet.appendFlavour("text/x-moz-message-or-folder");
|
||||
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
||||
return flavourSet;
|
||||
},
|
||||
|
||||
|
||||
onDragStart: function (aEvent, aXferData, aDragAction){
|
||||
// select clicked object, Mozilla doens't do this.
|
||||
calendarViewClick( aEvent );
|
||||
|
||||
// aEvent.currentTarget;
|
||||
if( aEvent.target.localName == "splitter" || aEvent.target.localName == "menu")
|
||||
throw Components.results.NS_OK; // not a draggable item
|
||||
|
||||
if(aEvent.target.className == "day-view-event-class" ||
|
||||
aEvent.target.className == "week-view-event-label-class")
|
||||
{
|
||||
// We are going to drag an event
|
||||
var dragEvents = gCalendarWindow.EventSelection.selectedEvents;
|
||||
aXferData.data= new TransferData();
|
||||
aXferData.data.addDataForFlavour("text/calendar", eventArrayToICalString( dragEvents ) );
|
||||
aXferData.data.addDataForFlavour("text/unicode", eventArrayToICalString( dragEvents, true ) );
|
||||
//if (aEvent.ctrlKey) {
|
||||
// action.action = nsIDragService.DRAGDROP_ACTION_COPY ;
|
||||
//}
|
||||
aEvent.preventBubble();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dragging on the calendar canvas to select an event period
|
||||
// var newDate = gHeaderDateItemArray[dayIndex].getAttribute( "date" );
|
||||
|
||||
var gStartDate = new Date( gCalendarWindow.getSelectedDate() );
|
||||
this.startDateIndex = aEvent.target.getAttribute( "day" );
|
||||
|
||||
gStartDate.setHours( aEvent.target.getAttribute( "hour" ) );
|
||||
gStartDate.setMinutes( 0 );
|
||||
gStartDate.setSeconds( 0 );
|
||||
|
||||
aXferData.data=new TransferData();
|
||||
aXferData.data.addDataForFlavour("text/calendar-interval", gStartDate.getTime() );
|
||||
|
||||
// aDragAction.action = nsIDragService.DRAGDROP_ACTION_MOVE;
|
||||
aEvent.preventBubble();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onDragOver: function (aEvent, aFlavour, aDragSession)
|
||||
{
|
||||
if (aDragSession.isDataFlavorSupported("text/calendar-interval"))
|
||||
{
|
||||
// multiday events not supported. In week view, do not allow more than one day in selection
|
||||
if (gCalendarWindow.currentView == gCalendarWindow.weekView )
|
||||
{
|
||||
if (aEvent.target.getAttribute( "day" ) != this.startDateIndex)
|
||||
{
|
||||
aDragSession.canDrop = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if (aDragSession.isDataFlavorSupported("text/calendar-interval"))
|
||||
aEvent.target.setAttribute( "draggedover", "true" );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onDrop: function (aEvent, aXferData, aDragSession)
|
||||
{
|
||||
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
trans.addDataFlavor("text/calendar");
|
||||
trans.addDataFlavor("text/calendar-interval");
|
||||
trans.addDataFlavor("text/x-moz-message-or-folder");
|
||||
trans.addDataFlavor("text/x-moz-url");
|
||||
trans.addDataFlavor("application/x-moz-file");
|
||||
trans.addDataFlavor("text/unicode");
|
||||
|
||||
aDragSession.getData (trans, i);
|
||||
|
||||
var dataObj = new Object();
|
||||
var bestFlavor = new Object();
|
||||
var len = new Object();
|
||||
trans.getAnyTransferData(bestFlavor, dataObj, len);
|
||||
|
||||
switch (bestFlavor.value)
|
||||
{
|
||||
case "text/calendar": // A calendar object is dropped. ical text data.
|
||||
if (dataObj)
|
||||
// XXX For MOZILLA10 1.0 this is nsISupportWString
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
|
||||
|
||||
var dropEvent = createEvent();
|
||||
var newEventId = dropEvent.id; // can be used when copying to new event
|
||||
|
||||
// XXX TODO: Check if there is a function in calendarImportExport to do this
|
||||
icalStr = dataObj.data.substring(0, len.value);
|
||||
i = icalStr.indexOf("BEGIN:VEVENT");
|
||||
j = icalStr.indexOf("END:VEVENT") + 10;
|
||||
eventData = icalStr.substring(i, j);
|
||||
dropEvent.parseIcalString( eventData );
|
||||
|
||||
// calculate new start/end time for droplocation
|
||||
// use the minutes from the event, and change the hour to the hour dropped in
|
||||
var gDropzoneStartTime = new Date( dropEvent.start.getTime() );
|
||||
gDropzoneStartTime.setHours( aEvent.target.getAttribute( "hour" ) );
|
||||
var draggedTime = gDropzoneStartTime - dropEvent.start ;
|
||||
var eventDuration = dropEvent.end.getTime() - dropEvent.start.getTime();
|
||||
|
||||
if(aDragSession.dragAction == nsIDragService.DRAGDROP_ACTION_MOVE)
|
||||
{
|
||||
var calendarEvent = gICalLib.fetchEvent( dropEvent.id );
|
||||
|
||||
if( calendarEvent != null )
|
||||
{
|
||||
calendarEvent.start.setTime(gDropzoneStartTime.getTime() );
|
||||
calendarEvent.end.setTime ( calendarEvent.start.getTime() + eventDuration );
|
||||
|
||||
gICalLib.modifyEvent( calendarEvent );
|
||||
}
|
||||
else
|
||||
alert(" Event with id: " + dropEvent.id + " not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a copy of the dragged event on the droplocation
|
||||
dropEvent.id = newEventId;
|
||||
// XXX TODO Check if stamp/DTSTAMP is correclty set to current time
|
||||
dropEvent.start.setTime(gDropzoneStartTime.getTime() );
|
||||
dropEvent.end.setTime ( dropEvent.start.getTime() + eventDuration );
|
||||
|
||||
editNewEvent( dropEvent );
|
||||
}
|
||||
break;
|
||||
|
||||
case "text/calendar-interval": // A start time is dragged as start of an event duration
|
||||
// no copy for interval drag
|
||||
// if (dragSession.dragAction == nsIDragService.DRAGDROP_ACTION_COPY)
|
||||
// return false;
|
||||
if (dataObj)
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
|
||||
var dragTime = dataObj.data.substring(0, len.value);
|
||||
|
||||
gStartDate = new Date( );
|
||||
gStartDate.setTime( dragTime );
|
||||
gEndDate = new Date( gStartDate.getTime() );
|
||||
gEndDate.setHours( aEvent.target.getAttribute( "hour" ) );
|
||||
if( gEndDate.getTime() < gStartDate.getTime() )
|
||||
{
|
||||
var Temp = gEndDate;
|
||||
gEndDate = gStartDate;
|
||||
gStartDate = Temp;
|
||||
}
|
||||
newEvent( gStartDate, gEndDate );
|
||||
break;
|
||||
|
||||
case "text/x-moz-url":
|
||||
var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
|
||||
if (!url)
|
||||
return;
|
||||
alert(url);
|
||||
|
||||
break;
|
||||
|
||||
case "text/unicode": // text, create new event with text as description
|
||||
if (dataObj)
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsWString);
|
||||
|
||||
// calculate star and and time's for new event, default event lenght is 1 hour
|
||||
var gStartDate = new Date( gCalendarWindow.getSelectedDate() );
|
||||
gStartDate.setHours( aEvent.target.getAttribute( "hour" ) );
|
||||
gStartDate.setMinutes( 0 );
|
||||
gStartDate.setSeconds( 0 );
|
||||
gEndDate = new Date( gStartDate.getTime() );
|
||||
gEndDate.setHours(gStartDate.getHours() + 1);
|
||||
|
||||
newEvent = createEvent();
|
||||
newEvent.start.setTime( gStartDate );
|
||||
newEvent.end.setTime( gEndDate );
|
||||
newEvent.description = dataObj.data.substring(0, len.value);
|
||||
editNewEvent( newEvent );
|
||||
break;
|
||||
|
||||
case "text/x-moz-message-or-folder": // Mozilla mail, work in progress
|
||||
try {
|
||||
if (dataObj)
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
|
||||
// pull the URL out of the data object
|
||||
|
||||
// sourceDocument nul if from other app
|
||||
|
||||
var sourceUri = dataObj.data.substring(0, len.value);
|
||||
|
||||
if (! sourceUri)
|
||||
break;
|
||||
|
||||
alert("import not implemented " + sourceUri);
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
sourceResource = RDF.GetResource(sourceUri, true);
|
||||
var folder = sourceResource.QueryInterface(Components.interfaces.nsIFolder);
|
||||
if (folder)
|
||||
dragFolder = true;
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
sourceResource = null;
|
||||
var isServer = GetFolderAttribute(folderTree, targetResource, "IsServer");
|
||||
if (isServer == "true")
|
||||
{
|
||||
debugDump("***isServer == true\n");
|
||||
return false;
|
||||
}
|
||||
// canFileMessages checks no select, and acl, for imap.
|
||||
var canFileMessages = GetFolderAttribute(folderTree, targetResource, "CanFileMessages");
|
||||
if (canFileMessages != "true")
|
||||
{
|
||||
debugDump("***canFileMessages == false\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
var hdr = messenger.messageServiceFromURI(sourceUri).messageURIToMsgHdr(sourceUri);
|
||||
alert(hdr);
|
||||
if (hdr.folder == targetFolder)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch(ex) {
|
||||
alert(ex.message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "application/x-moz-file": // file from OS, we expect it to be iCalendar data
|
||||
try {
|
||||
var fileObj = dataObj.value.QueryInterface(Components.interfaces.nsIFile);
|
||||
var aDataStream = readDataFromFile( fileObj.path );
|
||||
var calendarEventArray = parseIcalData( aDataStream );
|
||||
// TODO Move to calendarImportExport to have the option to turn off dialogs
|
||||
addEventsToCalendar( calendarEventArray );
|
||||
}
|
||||
catch(ex) {
|
||||
alert(ex.message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
var allDraggedElements = document.getElementsByAttribute( "draggedover", "true" );
|
||||
for( var i = 0; i < allDraggedElements.length; i++ )
|
||||
{
|
||||
allDraggedElements[i].removeAttribute( "draggedover" );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onDragExit: function (aEvent, aDragSession)
|
||||
{
|
||||
// nothing, doesn't fire for cancel? needed for interval-drag cleanup
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -555,6 +555,8 @@ function getNextOrPreviousRecurrence( calendarEvent )
|
|||
{
|
||||
var isValid = false;
|
||||
|
||||
var eventStartDate;
|
||||
|
||||
if( calendarEvent.recur )
|
||||
{
|
||||
var now = new Date();
|
||||
|
@ -565,19 +567,19 @@ function getNextOrPreviousRecurrence( calendarEvent )
|
|||
|
||||
if( isValid )
|
||||
{
|
||||
var eventStartDate = new Date( result.value );
|
||||
eventStartDate = new Date( result.value );
|
||||
}
|
||||
else
|
||||
{
|
||||
isValid = calendarEvent.getPreviousOccurrence( now.getTime(), result );
|
||||
|
||||
var eventStartDate = new Date( result.value );
|
||||
eventStartDate = new Date( result.value );
|
||||
}
|
||||
}
|
||||
|
||||
if( !isValid )
|
||||
{
|
||||
var eventStartDate = new Date( calendarEvent.start.getTime() );
|
||||
eventStartDate = new Date( calendarEvent.start.getTime() );
|
||||
}
|
||||
|
||||
return eventStartDate;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -202,10 +202,12 @@ function sendEvent()
|
|||
}
|
||||
}
|
||||
|
||||
var EmailSubject;
|
||||
|
||||
if( gCalendarWindow.EventSelection.selectedEvents.length == 1 )
|
||||
var EmailSubject = Event.title;
|
||||
EmailSubject = Event.title;
|
||||
else
|
||||
var EmailSubject = emailStringBundle.GetStringFromName( "EmailSubject" );
|
||||
EmailSubject = emailStringBundle.GetStringFromName( "EmailSubject" );
|
||||
|
||||
saveCalendarObject(CalendarDataFilePath, CalendarText);
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ function calendarManager( CalendarWindow )
|
|||
this.rootContainer = this.rdf.addRootSeq( "urn:calendarcontainer" );
|
||||
|
||||
//add the default calendar
|
||||
var profileFile = this.getProfileDirectory();
|
||||
profileFile = this.getProfileDirectory();
|
||||
profileFile.append("Calendar");
|
||||
profileFile.append("CalendarDataFile.ics");
|
||||
|
||||
|
@ -201,10 +201,12 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
|
|||
node.setAttribute("http://home.netscape.com/NC-rdf#serverNumber", this.rootContainer.getSubNodes().length);
|
||||
node.setAttribute("http://home.netscape.com/NC-rdf#name", CalendarObject.name);
|
||||
|
||||
var profileFile;
|
||||
|
||||
if( CalendarObject.path == "" )
|
||||
{
|
||||
//they didn't set a path in the box, that's OK, its not required.
|
||||
var profileFile = this.getProfileDirectory();
|
||||
profileFile = this.getProfileDirectory();
|
||||
profileFile.append("Calendar");
|
||||
profileFile.append("CalendarDataFile"+this.rootContainer.getSubNodes().length+".ics");
|
||||
CalendarObject.path = profileFile.path;
|
||||
|
@ -214,7 +216,7 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
|
|||
|
||||
if( CalendarObject.path.indexOf( "http://" ) != -1 )
|
||||
{
|
||||
var profileFile = this.getProfileDirectory();
|
||||
profileFile = this.getProfileDirectory();
|
||||
profileFile.append( "Calendar" );
|
||||
profileFile.append("RemoteCalendar"+this.rootContainer.getSubNodes().length+".ics");
|
||||
|
||||
|
@ -504,6 +506,7 @@ calendarManager.prototype.getRemoteCalendarText = function calMan_getRemoteCalen
|
|||
{
|
||||
onResponse( result );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -604,12 +607,12 @@ calendarManager.prototype.getAndConvertAllOldCalendars = function calMan_getAllC
|
|||
|
||||
this.rdf.flush();
|
||||
//if the file CalendarDataFile.ics exists in the users profile directory, move it to Calendar/CalendarDataFile.ics
|
||||
var newCalendarFile = this.getProfileDirectory();
|
||||
newCalendarFile = this.getProfileDirectory();
|
||||
newCalendarFile.append( "Calendar" );
|
||||
newCalendarFile.append( "RemoteCalendar"+this.rootContainer.getSubNodes().length+".ics" );
|
||||
|
||||
var oldCalendarDataFile = new File( thisCalendar.path );
|
||||
var newCalendarDataFile = new File( newCalendarFile.path );
|
||||
oldCalendarDataFile = new File( thisCalendar.path );
|
||||
newCalendarDataFile = new File( newCalendarFile.path );
|
||||
|
||||
if( oldCalendarDataFile.exists() && thisCalendar.remote == true )
|
||||
{
|
||||
|
|
|
@ -1,929 +0,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): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Karl Guertin <grayrest@grayrest.com>
|
||||
* Colin Phillips <colinp@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 ***** */
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* MonthView Class subclass of CalendarView
|
||||
*
|
||||
* Calendar month view class
|
||||
*
|
||||
* PROPERTIES
|
||||
* selectedEventBox - Events are displayed in dynamically created event boxes
|
||||
* this is the selected box, or null
|
||||
*
|
||||
* showingLastDay - When the user changes to a new month we select
|
||||
* the same day in the new month that was selected in the original month. If the
|
||||
* new month does not have that day ( i.e. 31 was selected and the new month has
|
||||
* only 30 days ) we move the selection to the last day. When this happens we turn on
|
||||
* the 'showingLastDay' flag. Now we will always select the last day when the month
|
||||
* is changed so that if they go back to the original month, 31 is selected again.
|
||||
* 'showingLastDay' is turned off when the user selects a new day or changes the view.
|
||||
*
|
||||
*
|
||||
* dayNumberItemArray - An array [ 0 to 41 ] of text boxes that hold the day numbers in the month view.
|
||||
* We set the value attribute to the day number, or "" for boxes that are not in the month.
|
||||
* In the XUL they have id's of the form month-week-<row_number>-day-<column_number>
|
||||
* where row_number is 1 - 6 and column_number is 1 - 7.
|
||||
*
|
||||
* dayBoxItemArray - An array [ 0 to 41 ] of boxes, one for each day in the month view. These boxes
|
||||
* are selected when a day is selected. They contain a dayNumberItem and event boxes.
|
||||
* In the XUL they have id's of the form month-week-<row_number>-day-<column_number>-box
|
||||
* where row_number is 1 - 6 and column_number is 1 - 7.
|
||||
*
|
||||
* dayBoxItemByDateArray - This array is reconstructed whenever the month changes ( and probably more
|
||||
* often than that ) It contains day box items, just like the dayBoxItemArray above,
|
||||
* except this array contains only those boxes that belong to the current month
|
||||
* and is indexed by date. So for a 30 day month that starts on a Wednesday,
|
||||
* dayBoxItemByDateArray[0] === dayBoxItemArray[3] and
|
||||
* dayBoxItemByDateArray[29] === dayBoxItemArray[36]
|
||||
*
|
||||
* kungFooDeathGripOnEventBoxes - This is to keep the event box javascript objects around so when we get
|
||||
* them back they still have the calendar event property on them.
|
||||
*
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
* Events are displayed in dynamically created event boxes. these boxes have a property added to them
|
||||
* called "calendarEvent" which contains the event represented by the box.
|
||||
*
|
||||
* There is one day box item for every day box in the month grid. These have an attribute
|
||||
* called "empty" which is set to "true", like so:
|
||||
*
|
||||
* dayBoxItem.setAttribute( "empty" , "true" );
|
||||
*
|
||||
* when the day box is not in the month. This allows the display to be controlled from css.
|
||||
*
|
||||
* The day boxes also have a couple of properties added to them:
|
||||
*
|
||||
* dayBoxItem.dayNumber - null when day is not in month.
|
||||
* - the date, 1 to 31, otherwise,
|
||||
*
|
||||
* dayBoxItem.numEvents - The number of events for the day, used to limit the number displayed
|
||||
* since there is only room for 3.
|
||||
*
|
||||
*/
|
||||
|
||||
// Make MonthView inherit from CalendarView
|
||||
|
||||
MonthView.prototype = new CalendarView();
|
||||
MonthView.prototype.constructor = MonthView;
|
||||
|
||||
|
||||
/**
|
||||
* MonthView Constructor.
|
||||
*
|
||||
* PARAMETERS
|
||||
* calendarWindow - the owning instance of CalendarWindow.
|
||||
*
|
||||
*/
|
||||
|
||||
function MonthView( calendarWindow )
|
||||
{
|
||||
// call the super constructor
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
this.numberOfEventsToShow = false;
|
||||
|
||||
var monthViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
|
||||
dump( "\nIn Month view, on selection changed");
|
||||
if( EventSelectionArray.length > 0 )
|
||||
{
|
||||
//if there are selected events.
|
||||
|
||||
//for some reason, this function causes the tree to go into a select / unselect loop
|
||||
//putting it in a settimeout fixes this.
|
||||
setTimeout( "gCalendarWindow.monthView.clearSelectedDate();", 1 );
|
||||
|
||||
gCalendarWindow.monthView.clearSelectedBoxes();
|
||||
|
||||
//dump( "\nIn Month view, eventSelectionArray.length is "+EventSelectionArray.length );
|
||||
var i = 0;
|
||||
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
//dump( "\nin Month view, going to try and get the event boxes with name 'month-view-event-box-"+EventSelectionArray[i].id+"'" );
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+EventSelectionArray[i].id );
|
||||
//dump( "\nIn Month view, found "+EventBoxes.length+" matches for the selected event." );
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
//dump( "\nAll Done in Selection for Month View" );
|
||||
}
|
||||
else
|
||||
{
|
||||
//select the proper day
|
||||
gCalendarWindow.monthView.hiliteSelectedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( monthViewEventSelectionObserver );
|
||||
|
||||
this.showingLastDay = false;
|
||||
|
||||
// set up month day box's and day number text items, see notes above
|
||||
|
||||
this.dayNumberItemArray = new Array();
|
||||
this.dayBoxItemArray = new Array();
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
this.dayBoxItemByDateArray = new Array();
|
||||
|
||||
var dayItemIndex = 0;
|
||||
|
||||
for( var weekIndex = 1; weekIndex <= 6; ++weekIndex )
|
||||
{
|
||||
for( var dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
// add the day text item to an array[0..41]
|
||||
|
||||
var dayNumberItem = document.getElementById( "month-week-" + weekIndex + "-day-" + dayIndex );
|
||||
this.dayNumberItemArray[ dayItemIndex ] = dayNumberItem;
|
||||
|
||||
// add the day box to an array[0..41]
|
||||
|
||||
var dayBoxItem = document.getElementById( "month-week-" + weekIndex + "-day-" + dayIndex + "-box" );
|
||||
this.dayBoxItemArray[ dayItemIndex ] = dayBoxItem;
|
||||
|
||||
// set on click of day boxes
|
||||
|
||||
dayBoxItem.setAttribute( "onclick", "gCalendarWindow.monthView.clickDay( event )" );
|
||||
dayBoxItem.setAttribute( "oncontextmenu", "gCalendarWindow.monthView.contextClickDay( event )" );
|
||||
|
||||
//set the drop
|
||||
dayBoxItem.setAttribute( "ondragdrop", "nsDragAndDrop.drop(event,monthViewEventDragAndDropObserver)" );
|
||||
dayBoxItem.setAttribute( "ondragover", "nsDragAndDrop.dragOver(event,monthViewEventDragAndDropObserver)" );
|
||||
|
||||
//set the double click of day boxes
|
||||
dayBoxItem.setAttribute( "ondblclick", "gCalendarWindow.monthView.doubleClickDay( event )" );
|
||||
|
||||
// array index
|
||||
|
||||
++dayItemIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the events for the current month
|
||||
*
|
||||
* We create XUL boxes dynamically and insert them into the XUL.
|
||||
* To refresh the display we remove all the old boxes and make new ones.
|
||||
*/
|
||||
MonthView.prototype.refreshEvents = function monthView_refreshEvents( )
|
||||
{
|
||||
// get this month's events and display them
|
||||
var monthEventList = this.calendarWindow.eventSource.getEventsForMonth( this.calendarWindow.getSelectedDate() );
|
||||
|
||||
// remove old event boxes
|
||||
var eventBoxList = document.getElementsByAttribute( "eventbox", "monthview" );
|
||||
|
||||
var eventBox = null;
|
||||
|
||||
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
||||
{
|
||||
eventBox = eventBoxList[ eventBoxIndex ];
|
||||
eventBox.parentNode.removeChild( eventBox );
|
||||
}
|
||||
|
||||
// clear calendarEvent counts, we only display 3 events per day
|
||||
// count them by adding a property to the dayItem, which is zeroed here
|
||||
for( var dayItemIndex = 0; dayItemIndex < this.dayBoxItemArray.length; ++dayItemIndex )
|
||||
{
|
||||
var dayItem = this.dayBoxItemArray[ dayItemIndex ];
|
||||
dayItem.numEvents = 0;
|
||||
}
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
|
||||
// add each calendarEvent
|
||||
for( var eventIndex = 0; eventIndex < monthEventList.length; ++eventIndex )
|
||||
{
|
||||
var calendarEventDisplay = monthEventList[ eventIndex ];
|
||||
|
||||
var eventDate = new Date( calendarEventDisplay.displayDate );
|
||||
// get the day box for the calendarEvent's day
|
||||
var eventDayInMonth = eventDate.getDate();
|
||||
|
||||
var dayBoxItem = this.dayBoxItemByDateArray[ eventDayInMonth ];
|
||||
|
||||
if( !dayBoxItem )
|
||||
break;
|
||||
|
||||
// Display no more than three, show dots for the events > 3
|
||||
|
||||
dayBoxItem.numEvents += 1;
|
||||
|
||||
if( this.numberOfEventsToShow == false && dayBoxItem.numEvents > 1 )
|
||||
{
|
||||
this.setNumberOfEventsToShow();
|
||||
}
|
||||
|
||||
if( dayBoxItem.numEvents == 1 || dayBoxItem.numEvents < this.numberOfEventsToShow )
|
||||
{
|
||||
// Make a box item to hold the event
|
||||
eventBox = document.createElement( "box" );
|
||||
eventBox.setAttribute( "id", "month-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "name", "month-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "event"+calendarEventDisplay.event.id, true );
|
||||
eventBox.setAttribute( "class", "month-day-event-box-class" );
|
||||
if( calendarEventDisplay.event.categories && calendarEventDisplay.event.categories != "" )
|
||||
{
|
||||
eventBox.setAttribute( calendarEventDisplay.event.categories, "true" );
|
||||
}
|
||||
|
||||
eventBox.setAttribute( "eventbox", "monthview" );
|
||||
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "eventTooltip" );
|
||||
eventBox.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,monthViewEventDragAndDropObserver);" );
|
||||
// add a property to the event box that holds the calendarEvent that the
|
||||
// box represents
|
||||
|
||||
eventBox.calendarEventDisplay = calendarEventDisplay;
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
||||
|
||||
// Make a text item to show the event title
|
||||
|
||||
var eventBoxText = document.createElement( "label" );
|
||||
eventBoxText.setAttribute( "crop", "end" );
|
||||
eventBoxText.setAttribute( "class", "month-day-event-text-class" );
|
||||
eventBoxText.setAttribute( "value", calendarEventDisplay.event.title );
|
||||
//you need this flex in order for text to crop
|
||||
eventBoxText.setAttribute( "flex", "1" );
|
||||
eventBoxText.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,monthViewEventDragAndDropObserver);" );
|
||||
|
||||
// add the text to the event box and the event box to the day box
|
||||
|
||||
eventBox.appendChild( eventBoxText );
|
||||
|
||||
dayBoxItem.appendChild( eventBox );
|
||||
}
|
||||
else
|
||||
{
|
||||
//if there is not a box to hold the little dots for this day...
|
||||
if ( !document.getElementById( "dotboxholder"+calendarEventDisplay.event.start.day ) )
|
||||
{
|
||||
//make one
|
||||
dotBoxHolder = document.createElement( "hbox" );
|
||||
dotBoxHolder.setAttribute( "id", "dotboxholder"+calendarEventDisplay.event.start.day );
|
||||
dotBoxHolder.setAttribute( "eventbox", "monthview" );
|
||||
|
||||
//add the box to the day.
|
||||
dayBoxItem.appendChild( dotBoxHolder );
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, get the box
|
||||
dotBoxHolder = document.getElementById( "dotboxholder"+calendarEventDisplay.event.start.day );
|
||||
}
|
||||
|
||||
if( dotBoxHolder.childNodes.length < kMAX_NUMBER_OF_DOTS_IN_MONTH_VIEW )
|
||||
{
|
||||
eventDotBox = document.createElement( "box" );
|
||||
eventDotBox.setAttribute( "eventbox", "monthview" );
|
||||
|
||||
//show a dot representing an event.
|
||||
|
||||
//NOTE: This variable is named eventBox because it needs the same name as
|
||||
// the regular boxes, for the next part of the function!
|
||||
eventBox = document.createElement( "image" );
|
||||
eventBox.setAttribute( "class", "month-view-event-dot-class" );
|
||||
eventBox.setAttribute( "id", "month-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "name", "month-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.calendarEventDisplay = calendarEventDisplay;
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "tooltip", "eventTimeViewTooltip" );
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
||||
|
||||
//add the dot to the extra box.
|
||||
eventDotBox.appendChild( eventBox );
|
||||
dotBoxHolder.appendChild( eventDotBox );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// mark the box as selected, if the event is
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches to a different view
|
||||
*/
|
||||
|
||||
MonthView.prototype.switchFrom = function monthView_switchFrom( )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches to the month view
|
||||
*/
|
||||
|
||||
MonthView.prototype.switchTo = function monthView_switchTo( )
|
||||
{
|
||||
// see showingLastDay notes above
|
||||
|
||||
this.showingLastDay = false;
|
||||
|
||||
// disable/enable view switching buttons
|
||||
|
||||
var weekViewButton = document.getElementById( "week_view_command" );
|
||||
var monthViewButton = document.getElementById( "month_view_command" );
|
||||
var dayViewButton = document.getElementById( "day_view_command" );
|
||||
|
||||
monthViewButton.setAttribute( "disabled", "true" );
|
||||
weekViewButton.removeAttribute( "disabled" );
|
||||
dayViewButton.removeAttribute( "disabled" );
|
||||
|
||||
// switch views in the deck
|
||||
|
||||
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
||||
calendarDeckItem.selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the display, but not the events
|
||||
*/
|
||||
|
||||
MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
||||
{
|
||||
// set the month/year in the header
|
||||
|
||||
var selectedDate = this.calendarWindow.getSelectedDate();
|
||||
var newMonth = selectedDate.getMonth();
|
||||
var newYear = selectedDate.getFullYear();
|
||||
var titleMonthArray = new Array();
|
||||
var titleYearArray = new Array();
|
||||
var toDebug = "";
|
||||
for (var i=-2; i < 3; i++){
|
||||
titleMonthArray[i] = newMonth + i;
|
||||
titleMonthArray[i] = (titleMonthArray[i] >= 0)? titleMonthArray[i] % 12 : titleMonthArray[i] + 12;
|
||||
titleMonthArray[i] = this.calendarWindow.dateFormater.getMonthName( titleMonthArray[i] );
|
||||
var idName = i + "-month-title";
|
||||
document.getElementById( idName ).setAttribute( "value" , titleMonthArray[i] );
|
||||
}
|
||||
document.getElementById( "0-year-title" ).setAttribute( "value" , newYear );
|
||||
|
||||
var Offset = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "week.start", 0 );
|
||||
|
||||
NewArrayOfDayNames = new Array();
|
||||
|
||||
for( i = 0; i < ArrayOfDayNames.length; i++ )
|
||||
{
|
||||
NewArrayOfDayNames[i] = ArrayOfDayNames[i];
|
||||
}
|
||||
|
||||
for( i = 0; i < Offset; i++ )
|
||||
{
|
||||
var FirstElement = NewArrayOfDayNames.shift();
|
||||
|
||||
NewArrayOfDayNames.push( FirstElement );
|
||||
}
|
||||
|
||||
//set the day names
|
||||
for( i = 1; i <= 7; i++ )
|
||||
{
|
||||
document.getElementById( "month-view-header-day-"+i ).value = NewArrayOfDayNames[ (i-1) ];
|
||||
}
|
||||
|
||||
|
||||
// Write in all the day numbers and create the dayBoxItemByDateArray, see notes above
|
||||
|
||||
// figure out first and last days of the month
|
||||
|
||||
var firstDate = new Date( newYear, newMonth, 1 );
|
||||
var firstDayOfWeek = firstDate.getDay() - Offset;
|
||||
if( firstDayOfWeek < 0 )
|
||||
firstDayOfWeek+=7;
|
||||
|
||||
var lastDayOfMonth = DateUtils.getLastDayOfMonth( newYear, newMonth );
|
||||
|
||||
// prepare the dayBoxItemByDateArray, we will be filling this in
|
||||
|
||||
this.dayBoxItemByDateArray = new Array();
|
||||
|
||||
// loop through all the day boxes
|
||||
|
||||
var dayNumber = 1;
|
||||
|
||||
for( var dayIndex = 0; dayIndex < this.dayNumberItemArray.length; ++dayIndex )
|
||||
{
|
||||
var dayNumberItem = this.dayNumberItemArray[ dayIndex ];
|
||||
var dayBoxItem = this.dayBoxItemArray[ dayIndex ];
|
||||
|
||||
if( dayIndex < firstDayOfWeek || dayNumber > lastDayOfMonth )
|
||||
{
|
||||
// this day box is NOT in the month,
|
||||
dayBoxItem.dayNumber = null;
|
||||
|
||||
dayBoxItem.setAttribute( "empty" , "true" );
|
||||
dayBoxItem.removeAttribute( "weekend" );
|
||||
|
||||
if( dayIndex < firstDayOfWeek )
|
||||
{
|
||||
var thisDate = new Date( newYear, newMonth, 1-(firstDayOfWeek - dayIndex ) );
|
||||
|
||||
dayBoxItem.date = thisDate;
|
||||
|
||||
dayNumberItem.setAttribute( "value" , thisDate.getDate() );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var thisDate = new Date( newYear, newMonth, lastDayOfMonth+( dayIndex - lastDayOfMonth - firstDayOfWeek + 1 ) );
|
||||
|
||||
dayBoxItem.date = thisDate;
|
||||
dayBoxItem.setAttribute( "date", thisDate );
|
||||
|
||||
dayNumberItem.setAttribute( "value" , thisDate.getDate() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dayNumberItem.setAttribute( "value" , dayNumber );
|
||||
|
||||
dayBoxItem.removeAttribute( "empty" );
|
||||
var thisDate = new Date( newYear, newMonth, dayNumber );
|
||||
if( thisDate.getDay() == 0 | thisDate.getDay() == 6 )
|
||||
{
|
||||
dayBoxItem.setAttribute( "weekend", "true" );
|
||||
}
|
||||
else
|
||||
dayBoxItem.removeAttribute( "weekend" );
|
||||
|
||||
dayBoxItem.dayNumber = dayNumber;
|
||||
|
||||
this.dayBoxItemByDateArray[ dayNumber ] = dayBoxItem;
|
||||
++dayNumber;
|
||||
}
|
||||
}
|
||||
|
||||
// if we aren't showing an event, highlite the selected date.
|
||||
if ( this.calendarWindow.EventSelection.selectedEvents.length < 1 )
|
||||
{
|
||||
this.hiliteSelectedDate( );
|
||||
}
|
||||
|
||||
//always highlight today's date.
|
||||
this.hiliteTodaysDate( );
|
||||
}
|
||||
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* Mark the selected date, also unmark the old selection if there was one
|
||||
*/
|
||||
|
||||
MonthView.prototype.hiliteSelectedDate = function monthView_hiliteSelectedDate( )
|
||||
{
|
||||
// Clear the old selection if there was one
|
||||
|
||||
this.clearSelectedDate();
|
||||
|
||||
this.clearSelectedBoxes();
|
||||
|
||||
// Set the background for selection
|
||||
|
||||
var ThisBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
||||
|
||||
if( ThisBox )
|
||||
ThisBox.setAttribute( "monthselected" , "true" );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
*/
|
||||
|
||||
MonthView.prototype.clearSelectedDate = function monthView_clearSelectedDate( )
|
||||
{
|
||||
var SelectedBoxes = document.getElementsByAttribute( "monthselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
SelectedBoxes[i].removeAttribute( "monthselected" );
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
*/
|
||||
|
||||
MonthView.prototype.clearSelectedBoxes = function monthView_clearSelectedBoxes( )
|
||||
{
|
||||
var SelectedBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
SelectedBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* Mark today as selected, also unmark the old today if there was one.
|
||||
*/
|
||||
|
||||
MonthView.prototype.hiliteTodaysDate = function monthView_hiliteTodaysDate( )
|
||||
{
|
||||
var Month = this.calendarWindow.getSelectedDate().getMonth();
|
||||
|
||||
var Year = this.calendarWindow.getSelectedDate().getFullYear();
|
||||
|
||||
// Clear the old selection if there was one
|
||||
var TodayBox = document.getElementsByAttribute( "today", "true" );
|
||||
|
||||
for( i = 0; i < TodayBox.length; i++ )
|
||||
{
|
||||
TodayBox[i].removeAttribute( "today" );
|
||||
}
|
||||
|
||||
//highlight today.
|
||||
var Today = new Date( );
|
||||
if ( Year == Today.getFullYear() && Month == Today.getMonth() )
|
||||
{
|
||||
var ThisBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
||||
if( ThisBox )
|
||||
ThisBox.setAttribute( "today", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
* and we want to know what the default start date should be for the event.
|
||||
*/
|
||||
|
||||
MonthView.prototype.getNewEventDate = function monthView_getNewEventDate( )
|
||||
{
|
||||
// use the selected year, month and day
|
||||
// and the current hours and minutes
|
||||
|
||||
var now = new Date();
|
||||
var start = new Date( this.calendarWindow.getSelectedDate() );
|
||||
|
||||
start.setHours( now.getHours() );
|
||||
start.setMinutes( Math.ceil( now.getMinutes() / 5 ) * 5 );
|
||||
start.setSeconds( 0 );
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Moves goMonths months in the future, goes to next month if no argument.
|
||||
*/
|
||||
|
||||
MonthView.prototype.goToNext = function monthView_goToNext( goMonths )
|
||||
{
|
||||
if(goMonths){
|
||||
var nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + goMonths, 1 );
|
||||
this.adjustNewMonth( nextMonth );
|
||||
this.goToDay( nextMonth );
|
||||
}else{
|
||||
var nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + 1, 1 );
|
||||
this.adjustNewMonth( nextMonth );
|
||||
this.goToDay( nextMonth );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Goes goMonths months into the past, goes to the previous month if no argument.
|
||||
*/
|
||||
|
||||
MonthView.prototype.goToPrevious = function monthView_goToPrevious( goMonths )
|
||||
{
|
||||
if(goMonths){
|
||||
var prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - goMonths, 1 );
|
||||
this.adjustNewMonth( prevMonth );
|
||||
this.goToDay( prevMonth );
|
||||
}else{
|
||||
var prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - 1, 1 );
|
||||
this.adjustNewMonth( prevMonth );
|
||||
this.goToDay( prevMonth );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* Helper function for goToNext and goToPrevious
|
||||
*
|
||||
* When the user changes to a new month the new month may not have the selected day in it.
|
||||
* ( i.e. 31 was selected and the new month has only 30 days ).
|
||||
* In that case our addition, or subtraction, in goToNext or goToPrevious will cause the
|
||||
* date to jump a month. ( Say the date starts at May 31, we add 1 to the month, Now the
|
||||
* date would be June 31, but the Date object knows there is no June 31, so it sets itself
|
||||
* to July 1. )
|
||||
*
|
||||
* In goToNext or goToPrevious we set the date to be 1, so the month will be correct. Here
|
||||
* we set the date to be the selected date, making adjustments if the selected date is not in the month.
|
||||
*/
|
||||
|
||||
MonthView.prototype.adjustNewMonth = function monthView_adjustNewMonth( newMonth )
|
||||
{
|
||||
// Don't let a date beyond the end of the month make us jump
|
||||
// too many or too few months
|
||||
|
||||
var lastDayOfMonth = DateUtils.getLastDayOfMonth( newMonth.getFullYear(), newMonth.getMonth() );
|
||||
|
||||
if( this.calendarWindow.selectedDate.getDate() > lastDayOfMonth )
|
||||
{
|
||||
// The selected date is NOT in the month
|
||||
// set it to the last day of the month and turn on showingLastDay, see notes in MonthView class
|
||||
|
||||
newMonth.setDate( lastDayOfMonth )
|
||||
|
||||
this.showingLastDay = true;
|
||||
}
|
||||
else if( this.showingLastDay )
|
||||
{
|
||||
// showingLastDay is on so select the last day of the month, see notes in MonthView class
|
||||
|
||||
newMonth.setDate( lastDayOfMonth )
|
||||
}
|
||||
else
|
||||
{
|
||||
// date is NOT beyond the last.
|
||||
|
||||
newMonth.setDate( this.calendarWindow.selectedDate.getDate() )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** PUBLIC -- monthview only
|
||||
*
|
||||
* Called when a day box item is single clicked
|
||||
*/
|
||||
|
||||
MonthView.prototype.clickDay = function monthView_clickDay( event )
|
||||
{
|
||||
if( event.button > 0 )
|
||||
return;
|
||||
|
||||
var dayBoxItem = event.currentTarget;
|
||||
|
||||
if( dayBoxItem.dayNumber != null && event.detail == 1 )
|
||||
{
|
||||
// turn off showingLastDay - see notes in MonthView class
|
||||
this.showingLastDay = false;
|
||||
|
||||
// change the selected date and redraw it
|
||||
var newDate = this.calendarWindow.getSelectedDate();
|
||||
|
||||
newDate.setDate( dayBoxItem.dayNumber );
|
||||
|
||||
this.calendarWindow.setSelectedDate( newDate );
|
||||
|
||||
//changing the selection will redraw the day as selected (colored blue) in the month view.
|
||||
//therefor, this has to happen after setSelectedDate
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC -- monthview only
|
||||
*
|
||||
* Called when a day box item is single clicked
|
||||
*/
|
||||
MonthView.prototype.contextClickDay = function monthView_contextClickDay( event )
|
||||
{
|
||||
var dayBoxItem = event.currentTarget;
|
||||
|
||||
if( dayBoxItem.dayNumber != null )
|
||||
{
|
||||
// turn off showingLastDay - see notes in MonthView class
|
||||
|
||||
this.showingLastDay = false;
|
||||
|
||||
// change the selected date and redraw it
|
||||
|
||||
gNewDateVariable = gCalendarWindow.getSelectedDate();
|
||||
|
||||
gNewDateVariable.setDate( dayBoxItem.dayNumber );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Don't forget that clickDay gets called before double click day gets called
|
||||
*/
|
||||
|
||||
MonthView.prototype.doubleClickDay = function monthView_doubleClickDay( event )
|
||||
{
|
||||
if( event.button > 0 )
|
||||
return;
|
||||
|
||||
if ( event.currentTarget.dayNumber != null )
|
||||
{
|
||||
// change the selected date and redraw it
|
||||
|
||||
var startDate = this.getNewEventDate();
|
||||
|
||||
newEvent( startDate, false );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newEvent( dayBoxItem.date, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MonthView.prototype.clearSelectedEvent = function monthView_clearSelectedEvent( )
|
||||
{
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MonthView.prototype.getVisibleEvent = function monthView_getVisibleEvent( calendarEvent )
|
||||
{
|
||||
var eventBox = document.getElementById( "month-view-event-box-"+calendarEvent.id );
|
||||
|
||||
if ( eventBox )
|
||||
{
|
||||
return eventBox;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
MonthView.prototype.selectBoxForEvent = function monthView_selectBoxForEvent( calendarEvent )
|
||||
{
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
/*Just calls setCalendarSize, it's here so it can be implemented on the other two views without difficulty.*/
|
||||
MonthView.prototype.doResize = function monthView_doResize( )
|
||||
{
|
||||
this.setCalendarSize(this.getViewHeight());
|
||||
|
||||
this.setNumberOfEventsToShow();
|
||||
}
|
||||
|
||||
/*Takes in a height, sets the calendar's container box to that height, the grid expands and contracts to fit it.*/
|
||||
MonthView.prototype.setCalendarSize = function monthView_setCalendarSize( height )
|
||||
{
|
||||
var offset = document.defaultView.getComputedStyle(document.getElementById("month-controls-box"), "").getPropertyValue("height");
|
||||
offset = parseInt( offset );
|
||||
height = (height-offset)+"px";
|
||||
document.getElementById( "month-content-box" ).setAttribute( "height", height );
|
||||
}
|
||||
|
||||
/*returns the height of the current view in pixels*/
|
||||
MonthView.prototype.getViewHeight = function monthView_getViewHeight( )
|
||||
{
|
||||
toReturn = document.defaultView.getComputedStyle(document.getElementById("month-view-box"), "").getPropertyValue("height");
|
||||
toReturn = parseInt( toReturn ); //strip off the px at the end
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
MonthView.prototype.setNumberOfEventsToShow = function monthView_getNumberOfEventsToShow( )
|
||||
{
|
||||
//get the style height of the month view box.
|
||||
var MonthViewBoxHeight = document.defaultView.getComputedStyle(document.getElementById("month-week-4-day-4-box"), "").getPropertyValue("height");
|
||||
MonthViewBoxHeight = parseInt( MonthViewBoxHeight ); //strip off the px at the end
|
||||
|
||||
//get the height of an event box.
|
||||
var Element = document.getElementsByAttribute( "eventbox", "monthview" )[0];
|
||||
if( !Element )
|
||||
return;
|
||||
|
||||
var EventBoxHeight = document.defaultView.getComputedStyle( Element, "" ).getPropertyValue( "height" );
|
||||
EventBoxHeight = parseInt( EventBoxHeight ); //strip off the px at the end
|
||||
|
||||
//calculate the number of events to show.
|
||||
dump( "\n\n"+( MonthViewBoxHeight - EventBoxHeight ) / EventBoxHeight );
|
||||
dump( "\n"+MonthViewBoxHeight );
|
||||
dump( "\n"+EventBoxHeight );
|
||||
this.numberOfEventsToShow = parseInt( ( MonthViewBoxHeight - EventBoxHeight ) / EventBoxHeight );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
drag and drop stuff
|
||||
*/
|
||||
gEventBeingDragged = false;
|
||||
gBoxBeingDroppedOn = false;
|
||||
|
||||
var monthViewEventDragAndDropObserver = {
|
||||
onDragStart: function (evt, transferData, action){
|
||||
if( evt.target.calendarEventDisplay )
|
||||
gEventBeingDragged = evt.target.calendarEventDisplay.event;
|
||||
else if( evt.target.parentNode.calendarEventDisplay )
|
||||
gEventBeingDragged = evt.target.parentNode.calendarEventDisplay.event;
|
||||
|
||||
//dump( "\nEvent being dragged is "+gEventBeingDragged );
|
||||
transferData.data=new TransferData();
|
||||
transferData.data.addDataForFlavour("text/unicode",0);
|
||||
},
|
||||
getSupportedFlavours : function () {
|
||||
var weekflavours = new FlavourSet();
|
||||
weekflavours.appendFlavour("text/unicode");
|
||||
return weekflavours;
|
||||
},
|
||||
onDragOver: function (evt,flavour,session){
|
||||
//dump( "on dragged over "+evt.target.getAttribute( "id" )+"\n" );
|
||||
gBoxBeingDroppedOn = document.getElementById( evt.target.getAttribute( "id" ) );
|
||||
//dump( evt.target.getAttribute( "id" ) );
|
||||
},
|
||||
onDrop: function (evt,dropdata,session){
|
||||
//get the date of the current event box.
|
||||
//dump( "\n\nDROP EVNET->\n"+gEventBeingDragged.start );
|
||||
var newDay = gBoxBeingDroppedOn.dayNumber;
|
||||
if( newDay == null )
|
||||
return;
|
||||
|
||||
var OldStartDate = new Date( gEventBeingDragged.start.getTime() );
|
||||
var newStartDate = new Date( OldStartDate.getTime() );
|
||||
newStartDate.setDate( newDay );
|
||||
|
||||
var Difference = newStartDate.getTime() - OldStartDate.getTime();
|
||||
var oldEndDate = new Date( gEventBeingDragged.end.getTime() );
|
||||
var newEndDate = oldEndDate.getTime() + Difference;
|
||||
|
||||
gEventBeingDragged.start.setTime( newStartDate.getTime() );
|
||||
gEventBeingDragged.end.setTime( newEndDate );
|
||||
|
||||
//edit the event being dragged to change its start and end date
|
||||
//don't change the start and end time though.
|
||||
gICalLib.modifyEvent( gEventBeingDragged, gEventBeingDragged.parent.server );
|
||||
|
||||
//refresh the view
|
||||
}
|
||||
};
|
|
@ -1,287 +0,0 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001-2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Original code:
|
||||
// http://lxr.mozilla.org/mozilla/source/editor/ui/composer/content/publish.js
|
||||
// TODO Implement uploadfile with:
|
||||
//void setUploadFile(in nsIFile file, in string contentType, in long contentLength);
|
||||
|
||||
var gPublishHandler = null;
|
||||
|
||||
|
||||
/* Create an instance of the given ContractID, with given interface */
|
||||
function createInstance(contractId, intf) {
|
||||
return Components.classes[contractId].createInstance(Components.interfaces[intf]);
|
||||
}
|
||||
|
||||
|
||||
var gPublishIOService;
|
||||
function GetIOService()
|
||||
{
|
||||
if (gPublishIOService)
|
||||
return gPublishIOService;
|
||||
|
||||
gPublishIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
if (!gPublishIOService)
|
||||
dump("failed to get io service\n");
|
||||
|
||||
return gPublishIOService;
|
||||
}
|
||||
|
||||
|
||||
function calendarPublish(aDataString, newLocation, fileName, login, password, contentType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var protocolChannel = get_destination_channel(newLocation, fileName, login, password);
|
||||
if (!protocolChannel)
|
||||
{
|
||||
dump("failed to get a destination channel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
output_string_to_channel(protocolChannel, aDataString, contentType);
|
||||
protocolChannel.asyncOpen(gPublishingListener, null);
|
||||
dump("done\n");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert("an error occurred: " + e + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// XXX WARNING: I DIDN'T TEST THIS!!!!!
|
||||
function calendarUploadFile(aSourceFilename, newLocation, fileName, login, password, contentType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var protocolChannel = get_destination_channel(newLocation, fileName, login, password);
|
||||
|
||||
if (!protocolChannel)
|
||||
{
|
||||
dump("failed to get a destination channel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//void setUploadFile(in nsIFile file, in string contentType, in long contentLength);
|
||||
|
||||
output_file_to_channel(protocolChannel, aSourceFilename, contentType);
|
||||
protocolChannel.asyncOpen(gPublishingListener, null);
|
||||
dump("done\n");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert("an error occurred: " + e + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function output_string_to_channel( aChannel, aDataString, contentType )
|
||||
{
|
||||
var uploadChannel = aChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
|
||||
var postStream = createInstance('@mozilla.org/io/string-input-stream;1', 'nsIStringInputStream');
|
||||
|
||||
postStream.setData(aDataString, aDataString.length);
|
||||
uploadChannel.setUploadStream(postStream, contentType, -1);
|
||||
}
|
||||
|
||||
|
||||
function output_file_to_channel( aChannel, aFilePath, contentType )
|
||||
{
|
||||
var uploadChannel = aChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
|
||||
var file = createInstance('@mozilla.org/file/local;1', 'nsILocalFile');
|
||||
|
||||
file.initWithPath( aFilePath );
|
||||
uploadChannel.setUploadFile(file, contentType, -1);
|
||||
}
|
||||
|
||||
|
||||
// this function takes a login and password and adds them to the destination url
|
||||
function get_destination_channel(destinationDirectoryLocation, fileName, login, password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ioService = GetIOService();
|
||||
if (!ioService)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create a channel for the destination location
|
||||
var fullurl = destinationDirectoryLocation + fileName;
|
||||
destChannel = create_channel_from_url(ioService, fullurl, login, password);
|
||||
if (!destChannel)
|
||||
{
|
||||
dump("can't create dest channel\n");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
dump("about to set callbacks\n");
|
||||
destChannel.notificationCallbacks = window.docshell; // docshell
|
||||
dump("notification callbacks set\n");
|
||||
}
|
||||
catch(e) {dump(e+"\n");}
|
||||
|
||||
try {
|
||||
var httpChannel = destChannel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
}
|
||||
catch( e )
|
||||
{
|
||||
//alert( e );
|
||||
}
|
||||
|
||||
if (httpChannel)
|
||||
{
|
||||
dump("http channel found\n");
|
||||
return httpChannel;
|
||||
}
|
||||
var ftpChannel = destChannel.QueryInterface(Components.interfaces.nsIFTPChannel);
|
||||
if (ftpChannel) dump("ftp channel found\n");
|
||||
if (ftpChannel)
|
||||
return ftpChannel;
|
||||
|
||||
var httpsChannel = destChannel.QueryInterface(Components.interfaces.nsIHttpsChannel);
|
||||
if (httpsChannel) dump("https channel found\n");
|
||||
if (httpsChannel)
|
||||
return httpsChannel;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this function takes a full url, creates an nsIURI, and then creates a channel from that nsIURI
|
||||
function create_channel_from_url(ioService, aURL, aLogin, aPassword)
|
||||
{
|
||||
try
|
||||
{
|
||||
var nsiuri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
|
||||
if (!nsiuri)
|
||||
return null;
|
||||
nsiuri.spec = aURL;
|
||||
if (aLogin)
|
||||
{
|
||||
nsiuri.username = aLogin;
|
||||
if (aPassword)
|
||||
nsiuri.password = aPassword;
|
||||
}
|
||||
return ioService.newChannelFromURI(nsiuri);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert(e+"\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function PublishCopyFile(srcDirectoryLocation, destinationDirectoryLocation, fileName, aLogin, aPassword)
|
||||
{
|
||||
// append '/' if it's not there; inputs should be directories so should end in '/'
|
||||
if ( srcDirectoryLocation.charAt(srcDirectoryLocation.length-1) != '/' )
|
||||
srcDirectoryLocation = srcDirectoryLocation + '/';
|
||||
if ( destinationDirectoryLocation.charAt(destinationDirectoryLocation.length-1) != '/' )
|
||||
destinationDirectoryLocation = destinationDirectoryLocation + '/';
|
||||
|
||||
try
|
||||
{
|
||||
// grab an io service
|
||||
var ioService = GetIOService();
|
||||
if (!ioService)
|
||||
return;
|
||||
|
||||
// create a channel for the source location
|
||||
srcChannel = create_channel_from_url(ioService, srcDirectoryLocation + fileName, null, null);
|
||||
if (!srcChannel)
|
||||
{
|
||||
dump("can't create src channel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// create a channel for the destination location
|
||||
var ftpChannel = get_destination_channel(destinationDirectoryLocation, fileName, aLogin, aPassword);
|
||||
if (!ftpChannel)
|
||||
{
|
||||
dump("failed to get ftp channel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ftpChannel.open();
|
||||
protocolChannel.uploadStream = srcChannel.open();
|
||||
protocolChannel.asyncOpen(null, null);
|
||||
dump("done\n");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
dump("an error occurred: " + e + "\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var gPublishingListener =
|
||||
{
|
||||
QueryInterface: function(aIId, instance)
|
||||
{
|
||||
if (aIId.equals(Components.interfaces.nsIStreamListener))
|
||||
return this;
|
||||
if (aIId.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
dump("QueryInterface " + aIId + "\n");
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
onStartRequest: function(request, ctxt)
|
||||
{
|
||||
dump("onStartRequest status = " + request.status + "\n");
|
||||
},
|
||||
|
||||
onStopRequest: function(request, ctxt, status, errorMsg)
|
||||
{
|
||||
dump("onStopRequest status = " + request.status + " " + errorMsg + "\n");
|
||||
},
|
||||
|
||||
onDataAvailable: function(request, ctxt, inStream, sourceOffset, count)
|
||||
{
|
||||
dump("onDataAvailable status = " + request.status + " " + count + "\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,727 +0,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): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@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 ***** */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* WeekView Class subclass of CalendarView
|
||||
*
|
||||
* Calendar week view class :TODO: display of events has not been started
|
||||
*
|
||||
* PROPERTIES
|
||||
* gHeaderDateItemArray - Array of text boxes used to display the dates of the currently displayed
|
||||
* week.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Make WeekView inherit from CalendarView
|
||||
|
||||
WeekView.prototype = new CalendarView();
|
||||
WeekView.prototype.constructor = WeekView;
|
||||
|
||||
/**
|
||||
* WeekView Constructor.
|
||||
*
|
||||
* PARAMETERS
|
||||
* calendarWindow - the owning instance of CalendarWindow.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function WeekView( calendarWindow )
|
||||
{
|
||||
// call super
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
//set the time on the left hand side labels
|
||||
//need to do this in JavaScript to preserve formatting
|
||||
for( var i = 0; i < 24; i++ )
|
||||
{
|
||||
/*
|
||||
** FOR SOME REASON, THIS IS NOT WORKING FOR MIDNIGHT
|
||||
*/
|
||||
var TimeToFormat = new Date();
|
||||
|
||||
TimeToFormat.setHours( i );
|
||||
|
||||
TimeToFormat.setMinutes( "0" );
|
||||
|
||||
var FormattedTime = calendarWindow.dateFormater.getFormatedTime( TimeToFormat );
|
||||
|
||||
var Label = document.getElementById( "week-view-hour-"+i );
|
||||
|
||||
Label.setAttribute( "value", FormattedTime );
|
||||
}
|
||||
|
||||
// get week view header items
|
||||
|
||||
gHeaderDateItemArray = new Array();
|
||||
|
||||
for( var dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
var headerDateItem = document.getElementById( "week-header-date-" + dayIndex );
|
||||
|
||||
gHeaderDateItemArray[ dayIndex ] = headerDateItem;
|
||||
}
|
||||
|
||||
var weekViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
gCalendarWindow.weekView.selectBoxForEvent( EventSelectionArray[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( weekViewEventSelectionObserver );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the events for the current week
|
||||
*/
|
||||
|
||||
WeekView.prototype.refreshEvents = function( )
|
||||
{
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
|
||||
var eventBoxList = document.getElementsByAttribute( "eventbox", "weekview" );
|
||||
|
||||
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
||||
{
|
||||
var eventBox = eventBoxList[ eventBoxIndex ];
|
||||
|
||||
eventBox.parentNode.removeChild( eventBox );
|
||||
}
|
||||
|
||||
for( var dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
var headerDateItem = document.getElementById( "week-header-date-" + dayIndex );
|
||||
|
||||
headerDateItem.numEvents = 0;
|
||||
}
|
||||
|
||||
//get the all day box.
|
||||
|
||||
var AllDayBox = document.getElementById( "week-view-all-day-content-box" );
|
||||
AllDayBox.setAttribute( "collapsed", "true" );
|
||||
|
||||
//expand the day's content box by setting allday to false..
|
||||
|
||||
document.getElementById( "week-view-content-box" ).removeAttribute( "allday" );
|
||||
|
||||
//START FOR LOOP FOR DAYS--->
|
||||
for ( dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
|
||||
//make the text node that will contain the text for the all day box.
|
||||
|
||||
var TextNode = document.getElementById( "all-day-content-box-text-week-"+dayIndex );
|
||||
|
||||
// get the events for the day and loop through them
|
||||
dayToGet = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
|
||||
|
||||
var dayEventList = new Array();
|
||||
|
||||
dayEventList = this.calendarWindow.eventSource.getEventsForDay( dayToGet );
|
||||
|
||||
//refresh the array and the current spot.
|
||||
|
||||
for ( i = 0; i < dayEventList.length; i++ )
|
||||
{
|
||||
dayEventList[i].OtherSpotArray = new Array('0');
|
||||
dayEventList[i].CurrentSpot = 0;
|
||||
dayEventList[i].NumberOfSameTimeEvents = 0;
|
||||
}
|
||||
|
||||
for ( i = 0; i < dayEventList.length; i++ )
|
||||
{
|
||||
var ThisSpot = 0;
|
||||
|
||||
var calendarEventDisplay = dayEventList[i];
|
||||
|
||||
//check to make sure that the event is not an all day event...
|
||||
|
||||
if ( calendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
//see if there's another event at the same start time.
|
||||
|
||||
for ( j = 0; j < dayEventList.length; j++ )
|
||||
{
|
||||
thisCalendarEventDisplay = dayEventList[j];
|
||||
|
||||
//if this event overlaps with another event...
|
||||
if ( ( ( thisCalendarEventDisplay.displayDate >= calendarEventDisplay.displayDate &&
|
||||
thisCalendarEventDisplay.displayDate.getTime() < calendarEventDisplay.event.end.getTime() ) ||
|
||||
( calendarEventDisplay.displayDate >= thisCalendarEventDisplay.displayDate &&
|
||||
calendarEventDisplay.displayDate.getTime() < thisCalendarEventDisplay.event.end.getTime() ) ) &&
|
||||
calendarEventDisplay.event.id != thisCalendarEventDisplay.event.id &&
|
||||
thisCalendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
//get the spot that this event will go in.
|
||||
var ThisSpot = thisCalendarEventDisplay.CurrentSpot;
|
||||
|
||||
calendarEventDisplay.OtherSpotArray.push( ThisSpot );
|
||||
ThisSpot++;
|
||||
|
||||
if ( ThisSpot > calendarEventDisplay.CurrentSpot )
|
||||
{
|
||||
calendarEventDisplay.CurrentSpot = ThisSpot;
|
||||
}
|
||||
}
|
||||
}
|
||||
SortedOtherSpotArray = new Array();
|
||||
//the sort must use the global variable gCalendarWindow, not this.calendarWindow
|
||||
SortedOtherSpotArray = calendarEventDisplay.OtherSpotArray.sort( gCalendarWindow.compareNumbers);
|
||||
LowestNumber = this.calendarWindow.getLowestElementNotInArray( SortedOtherSpotArray );
|
||||
|
||||
//this is the actual spot (0 -> n) that the event will go in on the day view.
|
||||
calendarEventDisplay.CurrentSpot = LowestNumber;
|
||||
if ( SortedOtherSpotArray.length > 4 )
|
||||
{
|
||||
calendarEventDisplay.NumberOfSameTimeEvents = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
calendarEventDisplay.NumberOfSameTimeEvents = SortedOtherSpotArray.length;
|
||||
}
|
||||
|
||||
dayEventList[i] = calendarEventDisplay;
|
||||
}
|
||||
|
||||
}
|
||||
var ThisDayAllDayBox = document.getElementById( "all-day-content-box-week-"+dayIndex );
|
||||
|
||||
while ( ThisDayAllDayBox.hasChildNodes() )
|
||||
{
|
||||
ThisDayAllDayBox.removeChild( ThisDayAllDayBox.firstChild );
|
||||
}
|
||||
|
||||
for ( var eventIndex = 0; eventIndex < dayEventList.length; ++eventIndex )
|
||||
{
|
||||
calendarEventDisplay = dayEventList[ eventIndex ];
|
||||
|
||||
// get the day box for the calendarEvent's day
|
||||
|
||||
var eventDayInMonth = calendarEventDisplay.event.start.day;
|
||||
|
||||
var weekBoxItem = gHeaderDateItemArray[ dayIndex ];
|
||||
|
||||
// Display no more than three, show dots for the events > 3
|
||||
|
||||
if ( calendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
weekBoxItem.numEvents += 1;
|
||||
}
|
||||
|
||||
//if its an all day event, don't show it in the hours bulletin board.
|
||||
|
||||
if ( calendarEventDisplay.event.allDay == true )
|
||||
{
|
||||
// build up the text to show for this event
|
||||
|
||||
var eventText = calendarEventDisplay.event.title;
|
||||
|
||||
if( calendarEventDisplay.event.location )
|
||||
{
|
||||
eventText += " " + calendarEventDisplay.event.location;
|
||||
}
|
||||
|
||||
if( calendarEventDisplay.event.description )
|
||||
{
|
||||
eventText += " " + calendarEventDisplay.event.description;
|
||||
}
|
||||
|
||||
//show the all day box
|
||||
AllDayBox.removeAttribute( "collapsed" );
|
||||
|
||||
//shrink the day's content box.
|
||||
document.getElementById( "week-view-content-box" ).setAttribute( "allday", "true" );
|
||||
|
||||
//note the use of the WeekViewAllDayText Attribute.
|
||||
//This is used to remove the text when the day is changed.
|
||||
|
||||
newHTMLNode = document.createElement( "label" );
|
||||
newHTMLNode.setAttribute( "crop", "end" );
|
||||
newHTMLNode.setAttribute( "flex", "1" );
|
||||
newHTMLNode.setAttribute( "value", eventText );
|
||||
newHTMLNode.setAttribute( "WeekViewAllDayText", "true" );
|
||||
newHTMLNode.calendarEventDisplay = calendarEventDisplay;
|
||||
newHTMLNode.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
newHTMLNode.setAttribute( "onclick", "weekEventItemClick( this, event )" );
|
||||
newHTMLNode.setAttribute( "ondblclick", "weekEventItemDoubleClick( this, event )" );
|
||||
newHTMLNode.setAttribute( "tooltip", "eventTooltip" );
|
||||
|
||||
newImage = document.createElement("image");
|
||||
newImage.setAttribute( "class", "all-day-event-class" );
|
||||
newImage.setAttribute( "WeekViewAllDayText", "true" );
|
||||
newImage.calendarEventDisplay = calendarEventDisplay;
|
||||
newImage.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
newImage.setAttribute( "onclick", "weekEventItemClick( this, event )" );
|
||||
newImage.setAttribute( "ondblclick", "weekEventItemDoubleClick( this, event )" );
|
||||
newImage.setAttribute( "tooltip", "eventTooltip" );
|
||||
|
||||
ThisDayAllDayBox.appendChild( newImage );
|
||||
ThisDayAllDayBox.appendChild( newHTMLNode );
|
||||
}
|
||||
else if ( calendarEventDisplay.CurrentSpot <= 4 )
|
||||
{
|
||||
eventBox = this.createEventBox( calendarEventDisplay, dayIndex );
|
||||
|
||||
//add the box to the bulletin board.
|
||||
document.getElementById( "week-view-content-board" ).appendChild( eventBox );
|
||||
}
|
||||
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//--> END THE FOR LOOP FOR THE WEEK VIEW
|
||||
}
|
||||
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* This creates an event box for the day view
|
||||
*/
|
||||
WeekView.prototype.createEventBox = function ( calendarEventDisplay, dayIndex )
|
||||
{
|
||||
|
||||
// build up the text to show for this event
|
||||
|
||||
var eventText = calendarEventDisplay.event.title;
|
||||
|
||||
var eventStartDate = calendarEventDisplay.displayDate;
|
||||
var startHour = eventStartDate.getHours();
|
||||
var startMinutes = eventStartDate.getMinutes();
|
||||
|
||||
var eventEndDateTime = new Date( 2000, 1, 1, calendarEventDisplay.event.end.hour, calendarEventDisplay.event.end.minute, 0 );
|
||||
var eventStartDateTime = new Date( 2000, 1, 1, eventStartDate.getHours(), eventStartDate.getMinutes(), 0 );
|
||||
|
||||
var eventDuration = new Date( eventEndDateTime - eventStartDateTime );
|
||||
|
||||
var hourDuration = eventDuration / (3600000);
|
||||
|
||||
var eventBox = document.createElement( "vbox" );
|
||||
|
||||
eventBox.calendarEventDisplay = calendarEventDisplay;
|
||||
|
||||
var totalWeekWidth = parseFloat(document.defaultView.getComputedStyle(document.getElementById("week-view-content-holder"), "").getPropertyValue("width")) + 1;
|
||||
var boxLeftOffset = Math.ceil(parseFloat(document.defaultView.getComputedStyle(document.getElementById("week-tree-hour-0"), "").getPropertyValue("width")));
|
||||
var boxWidth = (totalWeekWidth - boxLeftOffset)/ kDaysInWeek;
|
||||
var Height = ( hourDuration * kWeekViewHourHeight ) + 1;
|
||||
var Width = Math.floor( boxWidth / calendarEventDisplay.NumberOfSameTimeEvents ) + 1;
|
||||
eventBox.setAttribute( "height", Height );
|
||||
eventBox.setAttribute( "width", Width );
|
||||
|
||||
top = eval( ( startHour*kWeekViewHourHeight ) + ( ( startMinutes/60 ) * kWeekViewHourHeight ) - kWeekViewHourHeightDifference );
|
||||
eventBox.setAttribute( "top", top );
|
||||
|
||||
left = eval( boxLeftOffset + ( boxWidth * ( dayIndex - 1 ) ) + ( ( calendarEventDisplay.CurrentSpot - 1 ) * eventBox.getAttribute( "width" ) ) ) ;
|
||||
eventBox.setAttribute( "left", left );
|
||||
|
||||
eventBox.setAttribute( "class", "week-view-event-class" );
|
||||
eventBox.setAttribute( "eventbox", "weekview" );
|
||||
eventBox.setAttribute( "onclick", "weekEventItemClick( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "weekEventItemDoubleClick( this, event )" );
|
||||
eventBox.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,calendarViewDNDObserver);" );
|
||||
eventBox.setAttribute( "ondragover", "nsDragAndDrop.dragOver(event,calendarViewDNDObserver)" );
|
||||
eventBox.setAttribute( "ondragdrop", "nsDragAndDrop.drop(event,calendarViewDNDObserver)" );
|
||||
eventBox.setAttribute( "id", "week-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "name", "week-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "eventTooltip" );
|
||||
if( calendarEventDisplay.event.categories && calendarEventDisplay.event.categories != "" )
|
||||
{
|
||||
eventBox.setAttribute( calendarEventDisplay.event.categories, "true" );
|
||||
}
|
||||
|
||||
/*
|
||||
** The event description. This doesn't go multi line, but does crop properly.
|
||||
*/
|
||||
var eventDescriptionElement = document.createElement( "label" );
|
||||
eventDescriptionElement.calendarEventDisplay = calendarEventDisplay;
|
||||
eventDescriptionElement.setAttribute( "class", "week-view-event-label-class" );
|
||||
eventDescriptionElement.setAttribute( "value", eventText );
|
||||
eventDescriptionElement.setAttribute( "flex", "1" );
|
||||
var DescriptionText = document.createTextNode( " " );
|
||||
eventDescriptionElement.appendChild( DescriptionText );
|
||||
eventDescriptionElement.setAttribute( "style", "height: "+Height+";" );
|
||||
eventDescriptionElement.setAttribute( "crop", "end" );
|
||||
eventDescriptionElement.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,calendarViewDNDObserver);" );
|
||||
eventDescriptionElement.setAttribute( "ondragover", "nsDragAndDrop.dragOver(event,calendarViewDNDObserver)" );
|
||||
eventDescriptionElement.setAttribute( "ondragdrop", "nsDragAndDrop.drop(event,calendarViewDNDObserver)" );
|
||||
|
||||
eventBox.appendChild( eventDescriptionElement );
|
||||
|
||||
|
||||
// add a property to the event box that holds the calendarEvent that the
|
||||
// box represents
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
||||
|
||||
return( eventBox );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches to a different view
|
||||
*/
|
||||
|
||||
WeekView.prototype.switchFrom = function( )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Called when the user switches to the week view
|
||||
*/
|
||||
|
||||
WeekView.prototype.switchTo = function( )
|
||||
{
|
||||
// disable/enable view switching buttons
|
||||
|
||||
var weekViewButton = document.getElementById( "week_view_command" );
|
||||
var monthViewButton = document.getElementById( "month_view_command" );
|
||||
var dayViewButton = document.getElementById( "day_view_command" );
|
||||
|
||||
monthViewButton.removeAttribute( "disabled" );
|
||||
weekViewButton.setAttribute( "disabled", "true" );
|
||||
dayViewButton.removeAttribute( "disabled" );
|
||||
|
||||
// switch views in the deck
|
||||
|
||||
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
||||
calendarDeckItem.selectedIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Redraw the display, but not the events
|
||||
*/
|
||||
|
||||
WeekView.prototype.refreshDisplay = function( )
|
||||
{
|
||||
|
||||
// Set the from-to title string, based on the selected date
|
||||
var Offset = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "week.start", 0 );
|
||||
|
||||
var viewDay = this.calendarWindow.getSelectedDate().getDay();
|
||||
var viewDayOfMonth = this.calendarWindow.getSelectedDate().getDate();
|
||||
var viewMonth = this.calendarWindow.getSelectedDate().getMonth();
|
||||
var viewYear = this.calendarWindow.getSelectedDate().getFullYear();
|
||||
|
||||
viewDay -= Offset;
|
||||
|
||||
if( viewDay < 0 )
|
||||
viewDay += 7;
|
||||
|
||||
NewArrayOfDayNames = new Array();
|
||||
|
||||
/*
|
||||
Set the header information for the week view
|
||||
*/
|
||||
for( i = 0; i < ArrayOfDayNames.length; i++ )
|
||||
{
|
||||
NewArrayOfDayNames[i] = ArrayOfDayNames[i];
|
||||
}
|
||||
|
||||
for( i = 0; i < Offset; i++ )
|
||||
{
|
||||
var FirstElement = NewArrayOfDayNames.shift();
|
||||
|
||||
NewArrayOfDayNames.push( FirstElement );
|
||||
}
|
||||
|
||||
var dateOfLastDayInWeek = viewDayOfMonth + ( 6 - viewDay );
|
||||
|
||||
var dateOfFirstDayInWeek = viewDayOfMonth - viewDay;
|
||||
|
||||
var firstDayOfWeek = new Date( viewYear, viewMonth, dateOfFirstDayInWeek );
|
||||
var lastDayOfWeek = new Date( viewYear, viewMonth, dateOfLastDayInWeek );
|
||||
|
||||
var firstDayMonthName = this.calendarWindow.dateFormater.getMonthName( firstDayOfWeek.getMonth() );
|
||||
var lastDayMonthName = this.calendarWindow.dateFormater.getMonthName( lastDayOfWeek.getMonth() );
|
||||
|
||||
var weekNumber = this.getWeekNumber();
|
||||
|
||||
var dateString = "Week "+weekNumber+ ": "+firstDayMonthName + " " + firstDayOfWeek.getDate() + " - " +
|
||||
lastDayMonthName + " " + lastDayOfWeek.getDate();
|
||||
|
||||
var weekTextItem = document.getElementById( "week-title-text" );
|
||||
weekTextItem.setAttribute( "value" , dateString );
|
||||
|
||||
/* done setting the header information */
|
||||
|
||||
/* Fix the day names because users can choose which day the week starts on */
|
||||
var weekDate = new Date( viewYear, viewMonth, dateOfFirstDayInWeek );
|
||||
|
||||
for( var dayIndex = 1; dayIndex < 8; ++dayIndex )
|
||||
{
|
||||
var dateOfDay = weekDate.getDate();
|
||||
|
||||
var headerDateItem = document.getElementById( "week-header-date-"+dayIndex );
|
||||
headerDateItem.setAttribute( "value" , dateOfDay );
|
||||
headerDateItem.setAttribute( "date", weekDate );
|
||||
headerDateItem.numEvents = 0;
|
||||
|
||||
document.getElementById( "week-header-date-text-"+dayIndex ).setAttribute( "value", NewArrayOfDayNames[dayIndex-1] );
|
||||
|
||||
var arrayOfBoxes = new Array();
|
||||
|
||||
if( weekDate.getDay() == 0 || weekDate.getDay() == 6 )
|
||||
{
|
||||
/* its a weekend */
|
||||
arrayOfBoxes = document.getElementsByAttribute( "day", dayIndex );
|
||||
|
||||
for( i = 0; i < arrayOfBoxes.length; i++ )
|
||||
{
|
||||
arrayOfBoxes[i].setAttribute( "weekend", "true" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* its not a weekend */
|
||||
arrayOfBoxes = document.getElementsByAttribute( "day", dayIndex );
|
||||
|
||||
for( i = 0; i < arrayOfBoxes.length; i++ )
|
||||
{
|
||||
arrayOfBoxes[i].removeAttribute( "weekend" );
|
||||
}
|
||||
}
|
||||
|
||||
// advance to next day
|
||||
|
||||
weekDate.setDate( dateOfDay + 1 );
|
||||
}
|
||||
|
||||
this.hiliteTodaysDate( );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
* and we want to know what the default start date should be for the event.
|
||||
*/
|
||||
|
||||
WeekView.prototype.getNewEventDate = function( )
|
||||
{
|
||||
return this.calendarWindow.getSelectedDate();
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the next week.
|
||||
*/
|
||||
|
||||
WeekView.prototype.goToNext = function()
|
||||
{
|
||||
var nextWeek = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + 7 );
|
||||
|
||||
this.goToDay( nextWeek );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the previous week.
|
||||
*/
|
||||
|
||||
WeekView.prototype.goToPrevious = function()
|
||||
{
|
||||
var prevWeek = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - 7 );
|
||||
|
||||
this.goToDay( prevWeek );
|
||||
}
|
||||
|
||||
|
||||
WeekView.prototype.selectBoxForEvent = function( calendarEvent )
|
||||
{
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
WeekView.prototype.getVisibleEvent = function( calendarEvent )
|
||||
{
|
||||
eventBox = document.getElementById( "week-view-event-box-"+calendarEvent.id );
|
||||
if ( eventBox )
|
||||
{
|
||||
return eventBox;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* Mark today as selected, also unmark the old today if there was one.
|
||||
*/
|
||||
|
||||
WeekView.prototype.hiliteTodaysDate = function( )
|
||||
{
|
||||
//clear out the old today boxes.
|
||||
var OldTodayArray = document.getElementsByAttribute( "today", "true" );
|
||||
for ( i = 0; i < OldTodayArray.length; i++ )
|
||||
{
|
||||
OldTodayArray[i].removeAttribute( "today" );
|
||||
}
|
||||
|
||||
|
||||
// get the events for the day and loop through them
|
||||
var FirstDay = new Date( gHeaderDateItemArray[1].getAttribute( "date" ) );
|
||||
var LastDay = new Date( gHeaderDateItemArray[7].getAttribute( "date" ) );
|
||||
LastDay.setHours( 23 );
|
||||
LastDay.setMinutes( 59 );
|
||||
LastDay.setSeconds( 59 );
|
||||
var Today = new Date();
|
||||
|
||||
if ( Today.getTime() > FirstDay.getTime() && Today.getTime() < LastDay.getTime() )
|
||||
{
|
||||
//today is visible, get the day index for today
|
||||
for ( dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
ThisDate = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
|
||||
if ( ThisDate.getFullYear() == Today.getFullYear()
|
||||
&& ThisDate.getMonth() == Today.getMonth()
|
||||
&& ThisDate.getDay() == Today.getDay() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//dayIndex now contains the box numbers that we need.
|
||||
for ( i = 0; i < 24; i++ )
|
||||
{
|
||||
document.getElementById( "week-tree-day-"+(dayIndex-1)+"-item-"+i ).setAttribute( "today", "true" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* clear the selected event by taking off the selected attribute.
|
||||
*/
|
||||
WeekView.prototype.clearSelectedEvent = function( )
|
||||
{
|
||||
//Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
* and we want to know what the default start date should be for the event.
|
||||
*/
|
||||
|
||||
WeekView.prototype.getNewEventDate = function( )
|
||||
{
|
||||
var start = new Date( this.calendarWindow.getSelectedDate() );
|
||||
|
||||
start.setHours( start.getHours() );
|
||||
start.setMinutes( Math.ceil( start.getMinutes() / 5 ) * 5 );
|
||||
start.setSeconds( 0 );
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
*/
|
||||
|
||||
WeekView.prototype.clearSelectedDate = function( )
|
||||
{
|
||||
if ( this.selectedBox )
|
||||
{
|
||||
this.selectedBox.removeAttribute( "eventselected" );
|
||||
this.selectedBox = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WeekView.prototype.getWeekNumber = function()
|
||||
{
|
||||
var today = new Date( this.calendarWindow.getSelectedDate() );
|
||||
Year = today.getYear() + 1900;
|
||||
Month = today.getMonth();
|
||||
Day = today.getDate();
|
||||
now = new Date(Year,Month,Day+1);
|
||||
now = now.getTime();
|
||||
var Firstday = new Date( this.calendarWindow.getSelectedDate() );
|
||||
Firstday.setYear(Year);
|
||||
Firstday.setMonth(0);
|
||||
Firstday.setDate(1);
|
||||
then = new Date(Year,0,1);
|
||||
then = then.getTime();
|
||||
var Compensation = Firstday.getDay();
|
||||
if (Compensation > 3) Compensation -= 4;
|
||||
else Compensation += 3;
|
||||
NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7);
|
||||
return NumberOfWeek;
|
||||
}
|
|
@ -358,7 +358,9 @@ CalendarWindow.prototype.setSelectedDate = function calWin_setSelectedDate( date
|
|||
|
||||
this.selectedDate = new Date( date );
|
||||
|
||||
if( document.getElementById( "event-filter-menulist" ).selectedItem.value == "current" )
|
||||
/* on some machines, we need to check for .selectedItem first */
|
||||
if( document.getElementById( "event-filter-menulist" ).selectedItem &&
|
||||
document.getElementById( "event-filter-menulist" ).selectedItem.value == "current" )
|
||||
{
|
||||
//redraw the top tree
|
||||
setTimeout( "refreshEventTree( getAndSetEventTable() );", 150 );
|
||||
|
@ -463,7 +465,7 @@ CalendarWindow.prototype.getLowestElementNotInArray = function calWin_getLowestE
|
|||
//CAUTION: Watch the scope here. This function is called from inside a nested for loop.
|
||||
//You can't have the index variable named anything that is used in those for loops.
|
||||
|
||||
for ( Mike = 0; Mike < InputArray.length; Mike++ )
|
||||
for ( var Mike = 0; Mike < InputArray.length; Mike++ )
|
||||
{
|
||||
|
||||
if ( InputArray[Mike] > Temp )
|
||||
|
|
|
@ -148,7 +148,7 @@ function copyToClipboard( calendarEventArray )
|
|||
{
|
||||
if( !calendarEventArray)
|
||||
{
|
||||
var calendarEventArray = new Array();
|
||||
var calendarEventArray = new Array( 0 );
|
||||
calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
|
||||
}
|
||||
|
||||
|
@ -195,6 +195,7 @@ function copyToClipboard( calendarEventArray )
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,6 +234,8 @@ function pasteFromClipboard()
|
|||
//DEBUG alert("clipboard type: " + flavour.value);
|
||||
var calendarEventArray;
|
||||
var startDate;
|
||||
var endDateTime;
|
||||
var MinutesToAddOn;
|
||||
|
||||
switch (flavour.value) {
|
||||
case "text/calendar":
|
||||
|
@ -241,9 +244,9 @@ function pasteFromClipboard()
|
|||
|
||||
//change the date of all the events to now
|
||||
startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
|
||||
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
|
||||
for( var i = 0; i < calendarEventArray.length; i++ )
|
||||
{
|
||||
|
@ -266,11 +269,11 @@ function pasteFromClipboard()
|
|||
calendarEventArray = parseIcalData( data );
|
||||
//change the date of all the events to now
|
||||
startDate = gCalendarWindow.currentView.getNewEventDate();
|
||||
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
|
||||
|
||||
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
||||
|
||||
for( var i = 0; i < calendarEventArray.length; i++ )
|
||||
for( i = 0; i < calendarEventArray.length; i++ )
|
||||
{
|
||||
calendarEventArray[i].start.setTime( startDate );
|
||||
calendarEventArray[i].end.setTime( endDateTime );
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -42,7 +42,7 @@
|
|||
if (val) this.value = val;
|
||||
else this.value = new Date();
|
||||
|
||||
var val = this.getAttribute("ondatepick");
|
||||
val = this.getAttribute("ondatepick");
|
||||
dump( "\ncallback is "+val );
|
||||
if (val) this.callback = new Function( val );
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ DayView.prototype.refreshEvents = function dayview_refreshEvents( )
|
|||
//make the text node that will contain the text for the all day box.
|
||||
var calendarStringBundle = srGetStrBundle("chrome://calendar/locale/calendar.properties");
|
||||
|
||||
HtmlNode = document.createElement( "description" );
|
||||
var HtmlNode = document.createElement( "description" );
|
||||
HtmlNode.setAttribute( "class", "all-day-content-box-text-title" );
|
||||
TextNode = document.createTextNode( calendarStringBundle.GetStringFromName( "AllDayEvents" ) );
|
||||
var TextNode = document.createTextNode( calendarStringBundle.GetStringFromName( "AllDayEvents" ) );
|
||||
HtmlNode.appendChild( TextNode );
|
||||
document.getElementById( "all-day-content-box" ).appendChild( HtmlNode );
|
||||
|
||||
|
@ -327,7 +327,7 @@ DayView.prototype.createEventBox = function dayview_createEventBox( calendarEven
|
|||
var topHeight = document.getElementById( "day-tree-item-"+startHour ).boxObject.y - document.getElementById( "day-tree-item-"+startHour ).parentNode.boxObject.y;
|
||||
var boxWidth = document.getElementById( "day-tree-item-"+startHour ).boxObject.width;
|
||||
|
||||
var topHeight = eval( topHeight + ( ( startMinutes/60 ) * boxHeight ) );
|
||||
topHeight = eval( topHeight + ( ( startMinutes/60 ) * boxHeight ) );
|
||||
topHeight = Math.round( topHeight ) - 2;
|
||||
eventBox.setAttribute( "top", topHeight );
|
||||
|
||||
|
@ -429,42 +429,49 @@ DayView.prototype.switchTo = function dayview_switchTo( )
|
|||
DayView.prototype.refreshDisplay = function dayview_refreshDisplay( )
|
||||
{
|
||||
// update the title
|
||||
var dayNamePrev1;
|
||||
var dayNamePrev2;
|
||||
|
||||
var dayName = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() );
|
||||
if (this.calendarWindow.getSelectedDate().getDay() < 2)
|
||||
{
|
||||
if (this.calendarWindow.getSelectedDate().getDay() == 0)
|
||||
if (this.calendarWindow.getSelectedDate().getDay() == 0)
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 6 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 6 );
|
||||
dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 5 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
var dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 2 );
|
||||
dayNamePrev1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 1 );
|
||||
dayNamePrev2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 2 );
|
||||
}
|
||||
if (this.calendarWindow.getSelectedDate().getDay() > 4)
|
||||
|
||||
var dayNameNext1;
|
||||
var dayNameNext2;
|
||||
|
||||
if (this.calendarWindow.getSelectedDate().getDay() > 4)
|
||||
{
|
||||
if (this.calendarWindow.getSelectedDate().getDay() == 6)
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 6);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 6);
|
||||
dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() - 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
var dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 2);
|
||||
dayNameNext1 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 1);
|
||||
dayNameNext2 = this.calendarWindow.dateFormater.getDayName( this.calendarWindow.getSelectedDate().getDay() + 2);
|
||||
}
|
||||
var monthName = this.calendarWindow.dateFormater.getMonthName( this.calendarWindow.getSelectedDate().getMonth() );
|
||||
|
||||
|
@ -510,14 +517,16 @@ DayView.prototype.getNewEventDate = function dayview_getNewEventDate( )
|
|||
|
||||
DayView.prototype.goToNext = function dayview_goToNext(goDays)
|
||||
{
|
||||
var nextDay;
|
||||
|
||||
if (goDays)
|
||||
{
|
||||
var nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + goDays );
|
||||
nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + goDays );
|
||||
this.goToDay( nextDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
var nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + 1 );
|
||||
nextDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() + 1 );
|
||||
this.goToDay( nextDay );
|
||||
}
|
||||
}
|
||||
|
@ -530,14 +539,16 @@ DayView.prototype.goToNext = function dayview_goToNext(goDays)
|
|||
|
||||
DayView.prototype.goToPrevious = function dayview_goToPrevious( goDays )
|
||||
{
|
||||
var prevDay;
|
||||
|
||||
if (goDays)
|
||||
{
|
||||
var prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - goDays );
|
||||
prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - goDays );
|
||||
this.goToDay( prevDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
var prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - 1 );
|
||||
prevDay = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth(), this.calendarWindow.selectedDate.getDate() - 1 );
|
||||
this.goToDay( prevDay );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ var calendarViewDNDObserver = {
|
|||
},
|
||||
|
||||
|
||||
onDragOver: function (aEvent, aFlavour, aDragSession)
|
||||
onDragOver: function calendarViewOnDragOver(aEvent, aFlavour, aDragSession)
|
||||
{
|
||||
if (aDragSession.isDataFlavorSupported("text/calendar-interval"))
|
||||
{
|
||||
|
@ -123,6 +123,7 @@ var calendarViewDNDObserver = {
|
|||
// if (aDragSession.isDataFlavorSupported("text/calendar-interval"))
|
||||
aEvent.target.setAttribute( "draggedover", "true" );
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ function loadCalendarEventDialog()
|
|||
while( oldMenulist.hasChildNodes() )
|
||||
oldMenulist.removeChild( oldMenulist.lastChild );
|
||||
|
||||
for (var i = 0; i < categoriesList.length ; i++)
|
||||
for (i = 0; i < categoriesList.length ; i++)
|
||||
{
|
||||
document.getElementById( "categories-field" ).appendItem(categoriesList[i], categoriesList[i]);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ function loadEventsFromFile()
|
|||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
|
||||
fp.init(window, "Open", nsIFilePicker.modeOpenMultiple);
|
||||
fp.defaultExtension = "ics";
|
||||
|
||||
|
@ -122,40 +121,39 @@ function loadEventsFromFile()
|
|||
var filesToAppend = fp.files;
|
||||
|
||||
if (filesToAppend && filesToAppend.hasMoreElements())
|
||||
{
|
||||
{
|
||||
var calendarEventArray = new Array();
|
||||
var duplicateEventArray = new Array();
|
||||
var currentFile;
|
||||
var aDataStream;
|
||||
var i;
|
||||
var tempEventArray;
|
||||
|
||||
while (filesToAppend.hasMoreElements())
|
||||
{
|
||||
{
|
||||
currentFile = filesToAppend.getNext().QueryInterface(Components.interfaces.nsILocalFile);
|
||||
aDataStream = readDataFromFile( currentFile.path, "UTF-8" );
|
||||
|
||||
switch (fp.filterIndex) {
|
||||
case 0 : // ics
|
||||
var tempEventArray = parseIcalData( aDataStream );
|
||||
tempEventArray = parseIcalData( aDataStream );
|
||||
for (i=0; i < tempEventArray.length; i++)
|
||||
calendarEventArray[calendarEventArray.length] = tempEventArray[i];
|
||||
break;
|
||||
case 1 : // xcs
|
||||
var tempEventArray = parseXCSData( aDataStream );
|
||||
tempEventArray = parseXCSData( aDataStream );
|
||||
for (i=0; i < tempEventArray.length; i++)
|
||||
calendarEventArray[calendarEventArray.length] = tempEventArray[i];
|
||||
break;
|
||||
case 2: // csv
|
||||
var ret = parseOutlookCSVData( aDataStream, dupResult.discard, dupResult.prompt );
|
||||
for (i=0; i < ret.calendarEventArray.length; i++)
|
||||
calendarEventArray[calendarEventArray.length] = ret.calendarEventArray[i];
|
||||
calendarEventArray[calendarEventArray.length] = ret.calendarEventArray[i];
|
||||
for (i=0; i < ret.calendarDuplicateArray.length; i++)
|
||||
duplicateEventArray[duplicateEventArray.length] = ret.calendarDuplicateArray[i];
|
||||
duplicateEventArray[duplicateEventArray.length] = ret.calendarDuplicateArray[i];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If there are no events to import, let the user know
|
||||
//
|
||||
|
@ -180,20 +178,20 @@ function loadEventsFromFile()
|
|||
null,null,null,null, result);
|
||||
|
||||
if(buttonPressed == 0) // YES
|
||||
{
|
||||
{
|
||||
addEventsToCalendar( calendarEventArray );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(buttonPressed == 1) // NO
|
||||
{
|
||||
{
|
||||
addEventsToCalendar( calendarEventArray, true );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(buttonPressed == 2) // CANCEL
|
||||
{
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Depending on how the user chose to deal with duplicates,
|
||||
|
|
|
@ -424,7 +424,7 @@ MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
|||
|
||||
var Offset = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "week.start", 0 );
|
||||
|
||||
NewArrayOfDayNames = new Array();
|
||||
var NewArrayOfDayNames = new Array();
|
||||
|
||||
for( i = 0; i < ArrayOfDayNames.length; i++ )
|
||||
{
|
||||
|
@ -468,7 +468,8 @@ MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
|||
{
|
||||
var dayNumberItem = this.dayNumberItemArray[ dayIndex ];
|
||||
var dayBoxItem = this.dayBoxItemArray[ dayIndex ];
|
||||
|
||||
var thisDate;
|
||||
|
||||
if( dayIndex < firstDayOfWeek || dayNumber > lastDayOfMonth )
|
||||
{
|
||||
// this day box is NOT in the month,
|
||||
|
@ -479,7 +480,7 @@ MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
|||
|
||||
if( dayIndex < firstDayOfWeek )
|
||||
{
|
||||
var thisDate = new Date( newYear, newMonth, 1-(firstDayOfWeek - dayIndex ) );
|
||||
thisDate = new Date( newYear, newMonth, 1-(firstDayOfWeek - dayIndex ) );
|
||||
|
||||
dayBoxItem.date = thisDate;
|
||||
|
||||
|
@ -488,7 +489,7 @@ MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
|||
}
|
||||
else
|
||||
{
|
||||
var thisDate = new Date( newYear, newMonth, lastDayOfMonth+( dayIndex - lastDayOfMonth - firstDayOfWeek + 1 ) );
|
||||
thisDate = new Date( newYear, newMonth, lastDayOfMonth+( dayIndex - lastDayOfMonth - firstDayOfWeek + 1 ) );
|
||||
|
||||
dayBoxItem.date = thisDate;
|
||||
dayBoxItem.setAttribute( "date", thisDate );
|
||||
|
@ -501,7 +502,7 @@ MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
|||
dayNumberItem.setAttribute( "value" , dayNumber );
|
||||
|
||||
dayBoxItem.removeAttribute( "empty" );
|
||||
var thisDate = new Date( newYear, newMonth, dayNumber );
|
||||
thisDate = new Date( newYear, newMonth, dayNumber );
|
||||
if( thisDate.getDay() == 0 | thisDate.getDay() == 6 )
|
||||
{
|
||||
dayBoxItem.setAttribute( "weekend", "true" );
|
||||
|
@ -558,7 +559,7 @@ MonthView.prototype.clearSelectedDate = function monthView_clearSelectedDate( )
|
|||
{
|
||||
var SelectedBoxes = document.getElementsByAttribute( "monthselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
for( var i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
SelectedBoxes[i].removeAttribute( "monthselected" );
|
||||
}
|
||||
|
@ -573,7 +574,7 @@ MonthView.prototype.clearSelectedBoxes = function monthView_clearSelectedBoxes(
|
|||
{
|
||||
var SelectedBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
for( var i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
SelectedBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
|
@ -593,7 +594,7 @@ MonthView.prototype.hiliteTodaysDate = function monthView_hiliteTodaysDate( )
|
|||
// Clear the old selection if there was one
|
||||
var TodayBox = document.getElementsByAttribute( "today", "true" );
|
||||
|
||||
for( i = 0; i < TodayBox.length; i++ )
|
||||
for( var i = 0; i < TodayBox.length; i++ )
|
||||
{
|
||||
TodayBox[i].removeAttribute( "today" );
|
||||
}
|
||||
|
@ -638,12 +639,14 @@ MonthView.prototype.getNewEventDate = function monthView_getNewEventDate( )
|
|||
|
||||
MonthView.prototype.goToNext = function monthView_goToNext( goMonths )
|
||||
{
|
||||
var nextMonth;
|
||||
|
||||
if(goMonths){
|
||||
var nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + goMonths, 1 );
|
||||
nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + goMonths, 1 );
|
||||
this.adjustNewMonth( nextMonth );
|
||||
this.goToDay( nextMonth );
|
||||
}else{
|
||||
var nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + 1, 1 );
|
||||
nextMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() + 1, 1 );
|
||||
this.adjustNewMonth( nextMonth );
|
||||
this.goToDay( nextMonth );
|
||||
}
|
||||
|
@ -657,12 +660,14 @@ MonthView.prototype.goToNext = function monthView_goToNext( goMonths )
|
|||
|
||||
MonthView.prototype.goToPrevious = function monthView_goToPrevious( goMonths )
|
||||
{
|
||||
var prevMonth;
|
||||
|
||||
if(goMonths){
|
||||
var prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - goMonths, 1 );
|
||||
prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - goMonths, 1 );
|
||||
this.adjustNewMonth( prevMonth );
|
||||
this.goToDay( prevMonth );
|
||||
}else{
|
||||
var prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - 1, 1 );
|
||||
prevMonth = new Date( this.calendarWindow.selectedDate.getFullYear(), this.calendarWindow.selectedDate.getMonth() - 1, 1 );
|
||||
this.adjustNewMonth( prevMonth );
|
||||
this.goToDay( prevMonth );
|
||||
}
|
||||
|
@ -847,7 +852,7 @@ MonthView.prototype.setCalendarSize = function monthView_setCalendarSize( height
|
|||
/*returns the height of the current view in pixels*/
|
||||
MonthView.prototype.getViewHeight = function monthView_getViewHeight( )
|
||||
{
|
||||
toReturn = document.defaultView.getComputedStyle(document.getElementById("month-view-box"), "").getPropertyValue("height");
|
||||
var toReturn = document.defaultView.getComputedStyle(document.getElementById("month-view-box"), "").getPropertyValue("height");
|
||||
toReturn = parseInt( toReturn ); //strip off the px at the end
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -878,8 +883,8 @@ MonthView.prototype.setNumberOfEventsToShow = function monthView_getNumberOfEven
|
|||
/*
|
||||
drag and drop stuff
|
||||
*/
|
||||
gEventBeingDragged = false;
|
||||
gBoxBeingDroppedOn = false;
|
||||
var gEventBeingDragged = false;
|
||||
var gBoxBeingDroppedOn = false;
|
||||
|
||||
var monthViewEventDragAndDropObserver = {
|
||||
onDragStart: function (evt, transferData, action){
|
||||
|
|
|
@ -138,7 +138,7 @@ function get_destination_channel(destinationDirectoryLocation, fileName, login,
|
|||
var ioService = GetIOService();
|
||||
if (!ioService)
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// create a channel for the destination location
|
||||
|
@ -147,7 +147,7 @@ function get_destination_channel(destinationDirectoryLocation, fileName, login,
|
|||
if (!destChannel)
|
||||
{
|
||||
dump("can't create dest channel\n");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
dump("about to set callbacks\n");
|
||||
|
|
|
@ -523,8 +523,7 @@ ContactsTree.prototype =
|
|||
onDblClick: function( event )
|
||||
{
|
||||
addSelectedAddressesIntoBucket( DTD_toPrefix, kADDRESS_PREFIX_TO );
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -1499,8 +1498,7 @@ EventContactsTree.prototype =
|
|||
onDblClick: function( event )
|
||||
{
|
||||
addSelectedAddressesIntoInviteBucket( '', '' );
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -407,26 +407,27 @@ function getAndSetEventTable( )
|
|||
var Today = new Date();
|
||||
//do this to allow all day events to show up all day long
|
||||
var StartDate = new Date( Today.getFullYear(), Today.getMonth(), Today.getDate(), 0, 0, 0 );
|
||||
|
||||
var EndDate;
|
||||
|
||||
switch( document.getElementById( "event-filter-menulist" ).selectedItem.value )
|
||||
{
|
||||
case "all":
|
||||
return( gEventSource.getAllEvents() );
|
||||
|
||||
case "today":
|
||||
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 ) - 1 );
|
||||
EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 ) - 1 );
|
||||
return( gEventSource.getEventsForRange( StartDate, EndDate ) );
|
||||
|
||||
case "week":
|
||||
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 8 ) );
|
||||
EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 8 ) );
|
||||
return( gEventSource.getEventsForRange( StartDate, EndDate ) );
|
||||
|
||||
case "2weeks":
|
||||
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 15 ) );
|
||||
EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 15 ) );
|
||||
return( gEventSource.getEventsForRange( StartDate, EndDate ) );
|
||||
|
||||
case "month":
|
||||
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 32 ) );
|
||||
EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 32 ) );
|
||||
return( gEventSource.getEventsForRange( StartDate, EndDate ) );
|
||||
|
||||
case "future":
|
||||
|
@ -435,7 +436,7 @@ function getAndSetEventTable( )
|
|||
case "current":
|
||||
var SelectedDate = gCalendarWindow.getSelectedDate();
|
||||
MidnightSelectedDate = new Date( SelectedDate.getFullYear(), SelectedDate.getMonth(), SelectedDate.getDate(), 0, 0, 0 );
|
||||
var EndDate = new Date( MidnightSelectedDate.getTime() + ( 1000 * 60 * 60 * 24 ) - 1000 );
|
||||
EndDate = new Date( MidnightSelectedDate.getTime() + ( 1000 * 60 * 60 * 24 ) - 1000 );
|
||||
return( gEventSource.getEventsForRange( MidnightSelectedDate, EndDate ) );
|
||||
|
||||
default:
|
||||
|
@ -572,7 +573,13 @@ var treeView =
|
|||
return( calendarStringBundle.GetStringFromName( "Confirmed" ) );
|
||||
case calendarEvent.ICAL_STATUS_CANCELLED:
|
||||
return( calendarStringBundle.GetStringFromName( "Cancelled" ) );
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,14 +591,11 @@ function sortEvents( EventA, EventB )
|
|||
{
|
||||
modifier = -1;
|
||||
}
|
||||
//dump( "\nswitch on treeview.SelectedColumn which is "+treeView.selectedColumn );
|
||||
|
||||
switch(treeView.selectedColumn)
|
||||
{
|
||||
case "unifinder-search-results-tree-col-title":
|
||||
{
|
||||
//dump( "\nreturning "+EventA.title +" > "+EventB.title );
|
||||
return( ((EventA.title > EventB.title) ? 1 : -1) * modifier );
|
||||
}
|
||||
|
||||
case "unifinder-search-results-tree-col-startdate":
|
||||
return( ((EventA.start.getTime() > EventB.start.getTime()) ? 1 : -1) * modifier );
|
||||
|
@ -607,6 +611,9 @@ function sortEvents( EventA, EventB )
|
|||
|
||||
case "unifinder-search-results-tree-col-status":
|
||||
return( ((EventA.status > EventB.status) ? 1 : -1) * modifier );
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,13 +694,15 @@ function focusFirstItemIfNoSelection()
|
|||
|
||||
function getNextOrPreviousRecurrence( calendarEvent )
|
||||
{
|
||||
var isValid;
|
||||
|
||||
if( calendarEvent.recur )
|
||||
{
|
||||
var now = new Date();
|
||||
|
||||
var result = new Object();
|
||||
|
||||
var isValid = calendarEvent.getNextRecurrence( now.getTime(), result );
|
||||
isValid = calendarEvent.getNextRecurrence( now.getTime(), result );
|
||||
|
||||
if( isValid )
|
||||
{
|
||||
|
@ -711,6 +720,7 @@ function getNextOrPreviousRecurrence( calendarEvent )
|
|||
{
|
||||
return( new Date( calendarEvent.start.getTime() ) );
|
||||
}
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ function getToDoFromEvent( event )
|
|||
{
|
||||
return( tree.taskView.getCalendarTaskAtRow( row.value ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSelectedToDo()
|
||||
|
@ -399,7 +400,7 @@ var toDoTreeView =
|
|||
{
|
||||
calendarToDo = gTaskArray[row];
|
||||
if( !calendarToDo )
|
||||
return;
|
||||
return false;
|
||||
|
||||
switch( column )
|
||||
{
|
||||
|
@ -410,10 +411,11 @@ var toDoTreeView =
|
|||
return( " " );
|
||||
|
||||
case "unifinder-todo-tree-col-title":
|
||||
var titleText;
|
||||
if( calendarToDo.title == "" )
|
||||
var titleText = "Untitled";
|
||||
titleText = "Untitled";
|
||||
else
|
||||
var titleText = calendarToDo.title;
|
||||
titleText = calendarToDo.title;
|
||||
return( titleText );
|
||||
case "unifinder-todo-tree-col-startdate":
|
||||
return( formatUnifinderEventDate( new Date( calendarToDo.start.getTime() ) ) );
|
||||
|
@ -425,6 +427,8 @@ var toDoTreeView =
|
|||
return( calendarToDo.percentcomplete );
|
||||
case "unifinder-todo-tree-col-categories":
|
||||
return( calendarToDo.categories );
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -439,29 +443,31 @@ function sortTasks( TaskA, TaskB )
|
|||
|
||||
switch(toDoTreeView.selectedColumn)
|
||||
{
|
||||
case "unifinder-todo-tree-col-completed":
|
||||
return( ((TaskA.completed.getTime() > TaskB.completed.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-priority":
|
||||
return( ((TaskA.priority > TaskB.priority) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-title":
|
||||
return( ((TaskA.title > TaskB.title) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-startdate":
|
||||
return( ((TaskA.start.getTime() > TaskB.start.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-duedate":
|
||||
return( ((TaskA.due.getTime() > TaskB.due.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-completeddate":
|
||||
case "unifinder-todo-tree-col-completed":
|
||||
return( ((TaskA.completed.getTime() > TaskB.completed.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-priority":
|
||||
return( ((TaskA.priority > TaskB.priority) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-percentcomplete":
|
||||
case "unifinder-todo-tree-col-title":
|
||||
return( ((TaskA.title > TaskB.title) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-startdate":
|
||||
return( ((TaskA.start.getTime() > TaskB.start.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-duedate":
|
||||
return( ((TaskA.due.getTime() > TaskB.due.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-completeddate":
|
||||
return( ((TaskA.completed.getTime() > TaskB.completed.getTime()) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-percentcomplete":
|
||||
return( ((TaskA.percentcomplete > TaskB.percentcomplete) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-categories":
|
||||
return( ((TaskA.categories > TaskB.categories) ? 1 : -1) * modifier );
|
||||
|
||||
case "unifinder-todo-tree-col-categories":
|
||||
return( ((TaskA.categories > TaskB.categories) ? 1 : -1) * modifier );
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,7 +537,7 @@ function getTaskTable( )
|
|||
gICalLib.filter.completed.setTime( now );
|
||||
}
|
||||
|
||||
var taskTable = gEventSource.getAllToDos();
|
||||
taskTable = gEventSource.getAllToDos();
|
||||
|
||||
return( taskTable );
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ WeekView.prototype.refreshEvents = function( )
|
|||
var TextNode = document.getElementById( "all-day-content-box-text-week-"+dayIndex );
|
||||
|
||||
// get the events for the day and loop through them
|
||||
dayToGet = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
|
||||
var dayToGet = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
|
||||
|
||||
var dayEventList = new Array();
|
||||
|
||||
|
@ -188,9 +188,9 @@ WeekView.prototype.refreshEvents = function( )
|
|||
{
|
||||
//see if there's another event at the same start time.
|
||||
|
||||
for ( j = 0; j < dayEventList.length; j++ )
|
||||
for ( var j = 0; j < dayEventList.length; j++ )
|
||||
{
|
||||
thisCalendarEventDisplay = dayEventList[j];
|
||||
var thisCalendarEventDisplay = dayEventList[j];
|
||||
|
||||
//if this event overlaps with another event...
|
||||
if ( ( ( thisCalendarEventDisplay.displayDate >= calendarEventDisplay.displayDate &&
|
||||
|
@ -201,7 +201,7 @@ WeekView.prototype.refreshEvents = function( )
|
|||
thisCalendarEventDisplay.event.allDay != true )
|
||||
{
|
||||
//get the spot that this event will go in.
|
||||
var ThisSpot = thisCalendarEventDisplay.CurrentSpot;
|
||||
ThisSpot = thisCalendarEventDisplay.CurrentSpot;
|
||||
|
||||
calendarEventDisplay.OtherSpotArray.push( ThisSpot );
|
||||
ThisSpot++;
|
||||
|
@ -212,10 +212,10 @@ WeekView.prototype.refreshEvents = function( )
|
|||
}
|
||||
}
|
||||
}
|
||||
SortedOtherSpotArray = new Array();
|
||||
var SortedOtherSpotArray = new Array();
|
||||
//the sort must use the global variable gCalendarWindow, not this.calendarWindow
|
||||
SortedOtherSpotArray = calendarEventDisplay.OtherSpotArray.sort( gCalendarWindow.compareNumbers);
|
||||
LowestNumber = this.calendarWindow.getLowestElementNotInArray( SortedOtherSpotArray );
|
||||
var LowestNumber = this.calendarWindow.getLowestElementNotInArray( SortedOtherSpotArray );
|
||||
|
||||
//this is the actual spot (0 -> n) that the event will go in on the day view.
|
||||
calendarEventDisplay.CurrentSpot = LowestNumber;
|
||||
|
@ -359,10 +359,10 @@ WeekView.prototype.createEventBox = function ( calendarEventDisplay, dayIndex )
|
|||
eventBox.setAttribute( "height", Height );
|
||||
eventBox.setAttribute( "width", Width );
|
||||
|
||||
top = eval( ( startHour*kWeekViewHourHeight ) + ( ( startMinutes/60 ) * kWeekViewHourHeight ) - kWeekViewHourHeightDifference );
|
||||
var top = eval( ( startHour*kWeekViewHourHeight ) + ( ( startMinutes/60 ) * kWeekViewHourHeight ) - kWeekViewHourHeightDifference );
|
||||
eventBox.setAttribute( "top", top );
|
||||
|
||||
left = eval( boxLeftOffset + ( boxWidth * ( dayIndex - 1 ) ) + ( ( calendarEventDisplay.CurrentSpot - 1 ) * eventBox.getAttribute( "width" ) ) ) ;
|
||||
var left = eval( boxLeftOffset + ( boxWidth * ( dayIndex - 1 ) ) + ( ( calendarEventDisplay.CurrentSpot - 1 ) * eventBox.getAttribute( "width" ) ) ) ;
|
||||
eventBox.setAttribute( "left", left );
|
||||
|
||||
eventBox.setAttribute( "class", "week-view-event-class" );
|
||||
|
@ -634,8 +634,9 @@ WeekView.prototype.hiliteTodaysDate = function( )
|
|||
|
||||
if ( Today.getTime() > FirstDay.getTime() && Today.getTime() < LastDay.getTime() )
|
||||
{
|
||||
var ThisDate;
|
||||
//today is visible, get the day index for today
|
||||
for ( dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
for ( var dayIndex = 1; dayIndex <= 7; ++dayIndex )
|
||||
{
|
||||
ThisDate = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
|
||||
if ( ThisDate.getFullYear() == Today.getFullYear()
|
||||
|
@ -708,16 +709,16 @@ WeekView.prototype.clearSelectedDate = function( )
|
|||
WeekView.prototype.getWeekNumber = function()
|
||||
{
|
||||
var today = new Date( this.calendarWindow.getSelectedDate() );
|
||||
Year = today.getYear() + 1900;
|
||||
Month = today.getMonth();
|
||||
Day = today.getDate();
|
||||
now = new Date(Year,Month,Day+1);
|
||||
var Year = today.getYear() + 1900;
|
||||
var Month = today.getMonth();
|
||||
var Day = today.getDate();
|
||||
var now = new Date(Year,Month,Day+1);
|
||||
now = now.getTime();
|
||||
var Firstday = new Date( this.calendarWindow.getSelectedDate() );
|
||||
Firstday.setYear(Year);
|
||||
Firstday.setMonth(0);
|
||||
Firstday.setDate(1);
|
||||
then = new Date(Year,0,1);
|
||||
var then = new Date(Year,0,1);
|
||||
then = then.getTime();
|
||||
var Compensation = Firstday.getDay();
|
||||
if (Compensation > 3) Compensation -= 4;
|
||||
|
|
Загрузка…
Ссылка в новой задаче