2001-11-07 23:29:04 +03:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2001-11-07 22:18:46 +03:00
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 23:29:04 +03:00
|
|
|
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
2001-11-07 22:18:46 +03:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* OEone Corporation.
|
2001-11-07 23:29:04 +03:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-11-07 22:18:46 +03:00
|
|
|
*
|
2001-11-07 23:29:04 +03:00
|
|
|
* Contributor(s): Garth Smedley <garths@oeone.com>
|
|
|
|
* Mike Potter <mikep@oeone.com>
|
2002-03-28 18:03:39 +03:00
|
|
|
* Karl Guertin <grayrest@grayrest.com>
|
2002-03-28 22:47:17 +03:00
|
|
|
* Colin Phillips <colinp@oeone.com>
|
2001-11-07 22:18:46 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 23:29:04 +03:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
* 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 );
|
|
|
|
|
2002-09-10 20:59:53 +04:00
|
|
|
this.numberOfEventsToShow = false;
|
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
var monthViewEventSelectionObserver =
|
|
|
|
{
|
|
|
|
onSelectionChanged : function( EventSelectionArray )
|
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
//dump( "\nIn Month view, on selection changed");
|
2002-04-01 23:52:51 +04:00
|
|
|
if( EventSelectionArray.length > 0 )
|
|
|
|
{
|
|
|
|
//if there are selected events.
|
|
|
|
|
|
|
|
gCalendarWindow.monthView.clearSelectedDate();
|
2002-01-30 18:45:39 +03:00
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
gCalendarWindow.monthView.clearSelectedBoxes();
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
//dump( "\nIn Month view, eventSelectionArray.length is "+EventSelectionArray.length );
|
2002-04-08 23:38:55 +04:00
|
|
|
var i = 0;
|
2002-08-28 21:59:40 +04:00
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
for( i = 0; i < EventSelectionArray.length; i++ )
|
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
//dump( "\nin Month view, going to try and get the event boxes with name 'month-view-event-box-"+EventSelectionArray[i].id+"'" );
|
2002-04-01 23:52:51 +04:00
|
|
|
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+EventSelectionArray[i].id );
|
2002-08-23 00:15:15 +04:00
|
|
|
//dump( "\nIn Month view, found "+EventBoxes.length+" matches for the selected event." );
|
2002-04-01 23:52:51 +04:00
|
|
|
for ( j = 0; j < EventBoxes.length; j++ )
|
|
|
|
{
|
|
|
|
EventBoxes[j].setAttribute( "eventselected", "true" );
|
|
|
|
}
|
|
|
|
}
|
2002-08-23 00:15:15 +04:00
|
|
|
//dump( "\nAll Done in Selection for Month View" );
|
2002-04-01 23:52:51 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//select the proper day
|
|
|
|
gCalendarWindow.monthView.hiliteSelectedDate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
calendarWindow.EventSelection.addObserver( monthViewEventSelectionObserver );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
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();
|
2002-06-04 23:01:03 +04:00
|
|
|
this.kungFooDeathGripOnEventBoxes = new Array();
|
|
|
|
this.dayBoxItemByDateArray = new Array();
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2002-09-12 22:47:50 +04:00
|
|
|
dayBoxItem.setAttribute( "onclick", "gCalendarWindow.monthView.clickDay( event )" );
|
2002-09-12 21:13:57 +04:00
|
|
|
|
|
|
|
//set the drop
|
|
|
|
dayBoxItem.setAttribute( "ondragdrop", "nsDragAndDrop.drop(event,monthViewEventDragAndDropObserver)" );
|
|
|
|
dayBoxItem.setAttribute( "ondragover", "nsDragAndDrop.dragOver(event,monthViewEventDragAndDropObserver)" );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
//set the double click of day boxes
|
2002-05-13 23:25:20 +04:00
|
|
|
dayBoxItem.setAttribute( "ondblclick", "gCalendarWindow.monthView.doubleClickDay( event )" );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
*/
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.refreshEvents = function monthView_refreshEvents( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
// get this month's events and display them
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
var monthEventList = this.calendarWindow.eventSource.getEventsForMonth( this.calendarWindow.getSelectedDate() );
|
2002-08-23 20:33:29 +04:00
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// remove old event boxes
|
|
|
|
|
|
|
|
var eventBoxList = document.getElementsByAttribute( "eventbox", "monthview" );
|
|
|
|
|
2002-01-30 18:45:39 +03:00
|
|
|
var eventBox = null;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
eventBox = eventBoxList[ eventBoxIndex ];
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
eventBox.parentNode.removeChild( eventBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear calendarEvent counts, we only display 3 events per day
|
2002-04-03 21:46:49 +04:00
|
|
|
// count them by adding a property to the dayItem, which is zeroed here
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
for( var dayItemIndex = 0; dayItemIndex < this.dayBoxItemArray.length; ++dayItemIndex )
|
|
|
|
{
|
|
|
|
var dayItem = this.dayBoxItemArray[ dayItemIndex ];
|
|
|
|
|
|
|
|
dayItem.numEvents = 0;
|
|
|
|
}
|
|
|
|
|
2002-06-04 23:01:03 +04:00
|
|
|
this.kungFooDeathGripOnEventBoxes = new Array();
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// add each calendarEvent
|
|
|
|
for( var eventIndex = 0; eventIndex < monthEventList.length; ++eventIndex )
|
|
|
|
{
|
2001-12-20 18:53:03 +03:00
|
|
|
var calendarEventDisplay = monthEventList[ eventIndex ];
|
2001-11-07 22:18:46 +03:00
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
var eventDate = calendarEventDisplay.displayDate;
|
2001-11-07 22:18:46 +03:00
|
|
|
// get the day box for the calendarEvent's day
|
|
|
|
var eventDayInMonth = eventDate.getDate();
|
|
|
|
|
|
|
|
var dayBoxItem = this.dayBoxItemByDateArray[ eventDayInMonth ];
|
|
|
|
|
2002-09-06 00:33:48 +04:00
|
|
|
if( !dayBoxItem )
|
|
|
|
break;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// Display no more than three, show dots for the events > 3
|
|
|
|
|
|
|
|
dayBoxItem.numEvents += 1;
|
|
|
|
|
2002-09-10 20:59:53 +04:00
|
|
|
if( this.numberOfEventsToShow == false && dayBoxItem.numEvents > 1 )
|
|
|
|
{
|
|
|
|
this.setNumberOfEventsToShow();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( dayBoxItem.numEvents == 1 || dayBoxItem.numEvents < this.numberOfEventsToShow )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-09-12 21:13:57 +04:00
|
|
|
// Make a box item to hold the event
|
2002-01-30 18:45:39 +03:00
|
|
|
eventBox = document.createElement( "box" );
|
2001-12-20 18:53:03 +03:00
|
|
|
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 );
|
2001-11-07 22:18:46 +03:00
|
|
|
eventBox.setAttribute( "class", "month-day-event-box-class" );
|
2002-08-16 17:46:14 +04:00
|
|
|
if( calendarEventDisplay.event.categories && calendarEventDisplay.event.categories != "" )
|
|
|
|
{
|
|
|
|
eventBox.setAttribute( calendarEventDisplay.event.categories, "true" );
|
|
|
|
}
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
eventBox.setAttribute( "eventbox", "monthview" );
|
2002-09-12 22:47:50 +04:00
|
|
|
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
2001-11-07 22:18:46 +03:00
|
|
|
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
2002-09-05 23:54:24 +04:00
|
|
|
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
2001-12-20 18:53:03 +03:00
|
|
|
eventBox.setAttribute( "tooltip", "savetip" );
|
2002-09-12 21:13:57 +04:00
|
|
|
eventBox.setAttribute( "ondraggesture", "nsDragAndDrop.startDrag(event,monthViewEventDragAndDropObserver);" );
|
2001-11-07 22:18:46 +03:00
|
|
|
// add a property to the event box that holds the calendarEvent that the
|
|
|
|
// box represents
|
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
eventBox.calendarEventDisplay = calendarEventDisplay;
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
|
|
|
|
2002-09-12 21:13:57 +04:00
|
|
|
// 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);" );
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// add the text to the event box and the event box to the day box
|
|
|
|
|
|
|
|
eventBox.appendChild( eventBoxText );
|
2001-12-20 18:53:03 +03:00
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
dayBoxItem.appendChild( eventBox );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//if there is not a box to hold the little dots for this day...
|
2001-12-20 18:53:03 +03:00
|
|
|
if ( !document.getElementById( "dotboxholder"+calendarEventDisplay.event.start.day ) )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
//make one
|
|
|
|
dotBoxHolder = document.createElement( "hbox" );
|
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
dotBoxHolder.setAttribute( "id", "dotboxholder"+calendarEventDisplay.event.start.day );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
dotBoxHolder.setAttribute( "eventbox", "monthview" );
|
|
|
|
|
|
|
|
//add the box to the day.
|
|
|
|
dayBoxItem.appendChild( dotBoxHolder );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//otherwise, get the box
|
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
dotBoxHolder = document.getElementById( "dotboxholder"+calendarEventDisplay.event.start.day );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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" );
|
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
eventBox.setAttribute( "id", "month-view-event-box-"+calendarEventDisplay.event.id );
|
|
|
|
eventBox.setAttribute( "name", "month-view-event-box-"+calendarEventDisplay.event.id );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
2001-12-20 18:53:03 +03:00
|
|
|
eventBox.calendarEventDisplay = calendarEventDisplay;
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
this.kungFooDeathGripOnEventBoxes.push( eventBox );
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
eventBox.setAttribute( "onmouseover", "gCalendarWindow.changeMouseOverInfo( calendarEventDisplay, event )" );
|
2002-09-12 22:47:50 +04:00
|
|
|
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
2001-11-07 22:18:46 +03:00
|
|
|
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
|
|
|
|
|
|
|
eventBox.setAttribute( "tooltip", "savetip" );
|
|
|
|
|
|
|
|
//add the dot to the extra box.
|
|
|
|
eventDotBox.appendChild( eventBox );
|
|
|
|
dotBoxHolder.appendChild( eventDotBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// mark the box as selected, if the event is
|
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
this.selectBoxForEvent( calendarEventDisplay.event );
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PUBLIC
|
|
|
|
*
|
|
|
|
* Called when the user switches to a different view
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.switchFrom = function monthView_switchFrom( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PUBLIC
|
|
|
|
*
|
|
|
|
* Called when the user switches to the month view
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.switchTo = function monthView_switchTo( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
// see showingLastDay notes above
|
|
|
|
|
|
|
|
this.showingLastDay = false;
|
|
|
|
|
|
|
|
// disable/enable view switching buttons
|
|
|
|
|
2002-06-05 23:24:28 +04:00
|
|
|
var weekViewButton = document.getElementById( "week_view_command" );
|
|
|
|
var monthViewButton = document.getElementById( "month_view_command" );
|
|
|
|
var dayViewButton = document.getElementById( "day_view_command" );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
monthViewButton.setAttribute( "disabled", "true" );
|
2002-06-04 21:38:24 +04:00
|
|
|
weekViewButton.removeAttribute( "disabled" );
|
|
|
|
dayViewButton.removeAttribute( "disabled" );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
// switch views in the deck
|
|
|
|
|
|
|
|
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
2002-06-04 23:01:03 +04:00
|
|
|
calendarDeckItem.selectedIndex = 0;
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PUBLIC
|
|
|
|
*
|
|
|
|
* Redraw the display, but not the events
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.refreshDisplay = function monthView_refreshDisplay( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
// set the month/year in the header
|
|
|
|
|
2002-03-28 18:03:39 +03:00
|
|
|
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;
|
2002-04-11 21:03:19 +04:00
|
|
|
titleMonthArray[i] = this.calendarWindow.dateFormater.getMonthName( titleMonthArray[i] );
|
|
|
|
var idName = i + "-month-title";
|
|
|
|
document.getElementById( idName ).setAttribute( "value" , titleMonthArray[i] );
|
2002-03-28 18:03:39 +03:00
|
|
|
}
|
2002-03-28 22:47:17 +03:00
|
|
|
document.getElementById( "0-year-title" ).setAttribute( "value" , newYear );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
2002-09-04 18:43:25 +04:00
|
|
|
var Offset = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "week.start", 0 );
|
2002-04-08 23:38:55 +04:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2002-04-11 21:03:19 +04:00
|
|
|
//set the day names
|
2002-04-08 23:38:55 +04:00
|
|
|
for( i = 1; i <= 7; i++ )
|
|
|
|
{
|
|
|
|
document.getElementById( "month-view-header-day-"+i ).value = NewArrayOfDayNames[ (i-1) ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// 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 );
|
2002-04-08 23:38:55 +04:00
|
|
|
var firstDayOfWeek = firstDate.getDay() - Offset;
|
|
|
|
if( firstDayOfWeek < 0 )
|
|
|
|
firstDayOfWeek+=7;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
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,
|
2002-04-11 21:03:19 +04:00
|
|
|
dayBoxItem.dayNumber = null;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
dayBoxItem.setAttribute( "empty" , "true" );
|
2002-06-04 21:38:24 +04:00
|
|
|
dayBoxItem.removeAttribute( "weekend" );
|
2002-04-11 21:03:19 +04:00
|
|
|
|
|
|
|
if( dayIndex < firstDayOfWeek )
|
|
|
|
{
|
|
|
|
var thisDate = new Date( newYear, newMonth, 1-(firstDayOfWeek - dayIndex ) );
|
|
|
|
|
|
|
|
dayBoxItem.date = thisDate;
|
2002-09-12 21:13:57 +04:00
|
|
|
|
2002-04-11 21:03:19 +04:00
|
|
|
dayNumberItem.setAttribute( "value" , thisDate.getDate() );
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var thisDate = new Date( newYear, newMonth, lastDayOfMonth+( dayIndex - lastDayOfMonth - firstDayOfWeek + 1 ) );
|
|
|
|
|
|
|
|
dayBoxItem.date = thisDate;
|
2002-09-12 21:13:57 +04:00
|
|
|
dayBoxItem.setAttribute( "date", thisDate );
|
2002-04-11 21:03:19 +04:00
|
|
|
|
|
|
|
dayNumberItem.setAttribute( "value" , thisDate.getDate() );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dayNumberItem.setAttribute( "value" , dayNumber );
|
|
|
|
|
2002-06-04 21:38:24 +04:00
|
|
|
dayBoxItem.removeAttribute( "empty" );
|
2002-04-08 23:38:55 +04:00
|
|
|
var thisDate = new Date( newYear, newMonth, dayNumber );
|
|
|
|
if( thisDate.getDay() == 0 | thisDate.getDay() == 6 )
|
|
|
|
{
|
|
|
|
dayBoxItem.setAttribute( "weekend", "true" );
|
|
|
|
}
|
|
|
|
else
|
2002-06-04 21:38:24 +04:00
|
|
|
dayBoxItem.removeAttribute( "weekend" );
|
2002-04-08 23:38:55 +04:00
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
dayBoxItem.dayNumber = dayNumber;
|
|
|
|
|
|
|
|
this.dayBoxItemByDateArray[ dayNumber ] = dayBoxItem;
|
|
|
|
++dayNumber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we aren't showing an event, highlite the selected date.
|
2002-04-01 23:52:51 +04:00
|
|
|
if ( this.calendarWindow.EventSelection.selectedEvents.length < 1 )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
this.hiliteSelectedDate( );
|
|
|
|
}
|
|
|
|
|
|
|
|
//always highlight today's date.
|
|
|
|
this.hiliteTodaysDate( );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PRIVATE
|
|
|
|
*
|
|
|
|
* Mark the selected date, also unmark the old selection if there was one
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.hiliteSelectedDate = function monthView_hiliteSelectedDate( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
// Clear the old selection if there was one
|
2002-01-30 18:45:39 +03:00
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
this.clearSelectedDate();
|
|
|
|
|
|
|
|
this.clearSelectedBoxes();
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
// Set the background for selection
|
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
var ThisBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
|
|
|
|
2002-07-25 21:05:46 +04:00
|
|
|
if( ThisBox )
|
|
|
|
ThisBox.setAttribute( "monthselected" , "true" );
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PUBLIC
|
|
|
|
*
|
|
|
|
* Unmark the selected date if there is one.
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.clearSelectedDate = function monthView_clearSelectedDate( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.clearSelectedBoxes = function monthView_clearSelectedBoxes( )
|
2002-04-01 23:52:51 +04:00
|
|
|
{
|
|
|
|
var SelectedBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
|
|
|
|
|
|
|
for( i = 0; i < SelectedBoxes.length; i++ )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
SelectedBoxes[i].removeAttribute( "eventselected" );
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** PRIVATE
|
|
|
|
*
|
|
|
|
* Mark today as selected, also unmark the old today if there was one.
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.hiliteTodaysDate = function monthView_hiliteTodaysDate( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
var Month = this.calendarWindow.getSelectedDate().getMonth();
|
|
|
|
|
|
|
|
var Year = this.calendarWindow.getSelectedDate().getFullYear();
|
|
|
|
|
|
|
|
// Clear the old selection if there was one
|
2002-04-01 23:52:51 +04:00
|
|
|
var TodayBox = document.getElementsByAttribute( "today", "true" );
|
|
|
|
|
|
|
|
for( i = 0; i < TodayBox.length; i++ )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
TodayBox[i].removeAttribute( "today" );
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//highlight today.
|
|
|
|
var Today = new Date( );
|
|
|
|
if ( Year == Today.getFullYear() && Month == Today.getMonth() )
|
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
var ThisBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
2002-06-04 23:01:03 +04:00
|
|
|
if( ThisBox )
|
|
|
|
ThisBox.setAttribute( "today", "true" );
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.getNewEventDate = function monthView_getNewEventDate( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
*
|
2002-03-28 18:03:39 +03:00
|
|
|
* Moves goMonths months in the future, goes to next month if no argument.
|
2001-11-07 22:18:46 +03:00
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.goToNext = function monthView_goToNext( goMonths )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-03-28 18:03:39 +03:00
|
|
|
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 );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PUBLIC
|
|
|
|
*
|
2002-03-28 18:03:39 +03:00
|
|
|
* Goes goMonths months into the past, goes to the previous month if no argument.
|
2001-11-07 22:18:46 +03:00
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.goToPrevious = function monthView_goToPrevious( goMonths )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-03-28 18:03:39 +03:00
|
|
|
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 );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.adjustNewMonth = function monthView_adjustNewMonth( newMonth )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.clickDay = function monthView_clickDay( event )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-05-13 23:25:20 +04:00
|
|
|
if( event.button > 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
var dayBoxItem = event.currentTarget;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
if( dayBoxItem.dayNumber != null )
|
|
|
|
{
|
|
|
|
// turn off showingLastDay - see notes in MonthView class
|
|
|
|
|
|
|
|
this.showingLastDay = false;
|
|
|
|
|
|
|
|
// change the selected date and redraw it
|
|
|
|
|
|
|
|
this.calendarWindow.selectedDate.setDate( dayBoxItem.dayNumber );
|
2002-09-12 22:47:50 +04:00
|
|
|
|
|
|
|
gCalendarWindow.EventSelection.emptySelection();
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-12 22:47:50 +04:00
|
|
|
/*
|
|
|
|
** Don't forget that clickDay gets called before double click day gets called
|
|
|
|
*/
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.doubleClickDay = function monthView_doubleClickDay( event )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-05-13 23:25:20 +04:00
|
|
|
if( event.button > 0 )
|
|
|
|
return;
|
2002-09-12 22:47:50 +04:00
|
|
|
|
2002-05-13 23:25:20 +04:00
|
|
|
var dayBoxItem = event.currentTarget;
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
if ( dayBoxItem.dayNumber != null )
|
|
|
|
{
|
|
|
|
// change the selected date and redraw it
|
|
|
|
|
|
|
|
var startDate = this.getNewEventDate();
|
|
|
|
|
|
|
|
newEvent( startDate, false );
|
|
|
|
|
|
|
|
}
|
2002-04-11 21:03:19 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
newEvent( dayBoxItem.date, false );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.clearSelectedEvent = function monthView_clearSelectedEvent( )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-04-01 23:52:51 +04:00
|
|
|
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
2001-11-07 22:18:46 +03:00
|
|
|
|
2002-04-01 23:52:51 +04:00
|
|
|
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
|
|
|
{
|
|
|
|
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.getVisibleEvent = function monthView_getVisibleEvent( calendarEvent )
|
2001-11-07 22:18:46 +03:00
|
|
|
{
|
2002-01-31 22:00:00 +03:00
|
|
|
var eventBox = document.getElementById( "month-view-event-box-"+calendarEvent.id );
|
|
|
|
|
2001-11-07 22:18:46 +03:00
|
|
|
if ( eventBox )
|
|
|
|
{
|
|
|
|
return eventBox;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return null;
|
2002-04-01 23:52:51 +04:00
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.selectBoxForEvent = function monthView_selectBoxForEvent( calendarEvent )
|
2002-04-01 23:52:51 +04:00
|
|
|
{
|
|
|
|
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+calendarEvent.id );
|
|
|
|
|
|
|
|
for ( j = 0; j < EventBoxes.length; j++ )
|
|
|
|
{
|
|
|
|
EventBoxes[j].setAttribute( "eventselected", "true" );
|
|
|
|
}
|
2001-11-07 22:18:46 +03:00
|
|
|
}
|
2002-03-28 18:03:39 +03:00
|
|
|
|
|
|
|
/*Just calls setCalendarSize, it's here so it can be implemented on the other two views without difficulty.*/
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.doResize = function monthView_doResize( )
|
2002-08-23 00:15:15 +04:00
|
|
|
{
|
|
|
|
this.setCalendarSize(this.getViewHeight());
|
2002-09-10 20:59:53 +04:00
|
|
|
|
|
|
|
this.setNumberOfEventsToShow();
|
2002-03-28 18:03:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Takes in a height, sets the calendar's container box to that height, the grid expands and contracts to fit it.*/
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.setCalendarSize = function monthView_setCalendarSize( height )
|
2002-08-23 00:15:15 +04:00
|
|
|
{
|
2002-03-28 18:03:39 +03:00
|
|
|
var offset = document.defaultView.getComputedStyle(document.getElementById("month-controls-box"), "").getPropertyValue("height");
|
2002-04-01 23:52:51 +04:00
|
|
|
offset = parseInt( offset );
|
2002-03-28 18:03:39 +03:00
|
|
|
height = (height-offset)+"px";
|
|
|
|
document.getElementById( "month-content-box" ).setAttribute( "height", height );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*returns the height of the current view in pixels*/
|
2002-09-05 23:54:24 +04:00
|
|
|
MonthView.prototype.getViewHeight = function monthView_getViewHeight( )
|
2002-08-23 00:15:15 +04:00
|
|
|
{
|
|
|
|
toReturn = document.defaultView.getComputedStyle(document.getElementById("month-view-box"), "").getPropertyValue("height");
|
2002-04-01 23:52:51 +04:00
|
|
|
toReturn = parseInt( toReturn ); //strip off the px at the end
|
2002-03-28 18:03:39 +03:00
|
|
|
return toReturn;
|
|
|
|
}
|
2002-08-23 00:15:15 +04:00
|
|
|
|
|
|
|
|
2002-09-10 20:59:53 +04:00
|
|
|
MonthView.prototype.setNumberOfEventsToShow = function monthView_getNumberOfEventsToShow( )
|
2002-08-23 00:15:15 +04:00
|
|
|
{
|
|
|
|
//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];
|
2002-09-10 20:59:53 +04:00
|
|
|
if( !Element )
|
|
|
|
return;
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
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 );
|
2002-09-10 20:59:53 +04:00
|
|
|
this.numberOfEventsToShow = parseInt( ( MonthViewBoxHeight - EventBoxHeight ) / EventBoxHeight );
|
2002-08-23 00:15:15 +04:00
|
|
|
}
|
2002-09-12 21:13:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
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;
|
|
|
|
|
|
|
|
gEventBeingDragged.start.day = newDay;
|
|
|
|
gEventBeingDragged.end.day = newDay;
|
|
|
|
|
|
|
|
//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
|
|
|
|
}
|
|
|
|
};
|