mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Redoing selection controller. Adding in a new event selection object which controls all the selections, and distributes onSelectionChanged events to observers.
This commit is contained in:
parent
1bc23685d9
commit
7c4a76b714
@ -1,2 +1 @@
|
||||
scp linux/calendar_linux.xpi windows/calendar_windows.xpi
|
||||
mikep@www:/var/www/html/generated/files/
|
||||
scp linux/calendar_linux.xpi windows/calendar_windows.xpi mikep@www:/var/www/html/generated/files/
|
||||
|
@ -145,10 +145,6 @@ function calendarInit()
|
||||
gCalendarWindow.switchToMonthView( );
|
||||
|
||||
update_date( );
|
||||
|
||||
deselectEventInUnifinder();
|
||||
//sizeToContent();
|
||||
//window.resizeTo(1024,708);
|
||||
}
|
||||
|
||||
// Set the date and time on the clock and set up a timeout to refresh the clock when the
|
||||
@ -193,7 +189,6 @@ function prepareChooseDate()
|
||||
datePickerPopup.setAttribute( "value", gCalendarWindow.getSelectedDate() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called on single click in the day view, select an event
|
||||
*
|
||||
@ -204,8 +199,8 @@ function prepareChooseDate()
|
||||
|
||||
function dayEventItemClick( eventBox, event )
|
||||
{
|
||||
gCalendarWindow.dayView.clickEventBox( eventBox, event );
|
||||
|
||||
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
@ -244,8 +239,6 @@ function dayEventItemDoubleClick( eventBox, event )
|
||||
function dayViewHourClick( hourNumber, event )
|
||||
{
|
||||
gCalendarWindow.setSelectedHour( hourNumber );
|
||||
|
||||
deselectEventInUnifinder();
|
||||
}
|
||||
|
||||
|
||||
@ -261,8 +254,6 @@ function dayViewHourDoubleClick( hourNumber, event )
|
||||
|
||||
var startDate = gCalendarWindow.dayView.getNewEventDate();
|
||||
newEvent( startDate );
|
||||
|
||||
deselectEventInUnifinder();
|
||||
}
|
||||
|
||||
|
||||
@ -276,8 +267,8 @@ function dayViewHourDoubleClick( hourNumber, event )
|
||||
|
||||
function weekEventItemClick( eventBox, event )
|
||||
{
|
||||
gCalendarWindow.weekView.clickEventBox( eventBox, event );
|
||||
|
||||
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
@ -320,8 +311,6 @@ function weekViewHourClick( dayIndex, hourNumber, event )
|
||||
gCalendarWindow.setSelectedDate( newDate );
|
||||
|
||||
gCalendarWindow.setSelectedHour( hourNumber );
|
||||
|
||||
deselectEventInUnifinder();
|
||||
}
|
||||
|
||||
|
||||
@ -341,9 +330,6 @@ function weekViewHourDoubleClick( dayIndex, hourNumber, event )
|
||||
|
||||
var startDate = gCalendarWindow.weekView.getNewEventDate();
|
||||
newEvent( startDate );
|
||||
|
||||
deselectEventInUnifinder();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -357,7 +343,12 @@ function weekViewHourDoubleClick( dayIndex, hourNumber, event )
|
||||
|
||||
function monthEventBoxClickEvent( eventBox, event )
|
||||
{
|
||||
gCalendarWindow.monthView.clickEventBox( eventBox, event );
|
||||
gCalendarWindow.MonthView.clickEventBox( eventBox, event );
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -371,8 +362,6 @@ function monthEventBoxClickEvent( eventBox, event )
|
||||
|
||||
function monthEventBoxDoubleClickEvent( eventBox, event )
|
||||
{
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
|
||||
gCalendarWindow.monthView.clearSelectedDate( );
|
||||
|
||||
editEvent( eventBox.calendarEventDisplay.event );
|
||||
@ -385,56 +374,6 @@ function monthEventBoxDoubleClickEvent( eventBox, event )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when an event is clicked on.
|
||||
* Hightlights the event in the unifinder
|
||||
*/
|
||||
|
||||
function selectEventInUnifinder( calendarEvent )
|
||||
{
|
||||
gUnifinderSelection = calendarEvent.id;
|
||||
|
||||
var Tree = document.getElementById( "unifinder-categories-tree" );
|
||||
|
||||
var TreeItem = document.getElementById( "unifinder-treeitem-"+gUnifinderSelection );
|
||||
|
||||
if ( Tree && TreeItem )
|
||||
{
|
||||
Tree.selectItem( TreeItem );
|
||||
|
||||
}
|
||||
|
||||
document.getElementById( "delete_command" ).removeAttribute( "disabled" );
|
||||
|
||||
document.getElementById( "modify_command" ).removeAttribute( "disabled" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a day is clicked on.
|
||||
* deSelects the selected item in the unifinder.
|
||||
*/
|
||||
|
||||
function deselectEventInUnifinder( )
|
||||
{
|
||||
if ( gUnifinderSelection )
|
||||
{
|
||||
var Tree = document.getElementById( "unifinder-categories-tree" );
|
||||
|
||||
var TreeItem = document.getElementById( "unifinder-treeitem-"+gUnifinderSelection );
|
||||
|
||||
if( TreeItem )
|
||||
Tree.removeItemFromSelection( TreeItem );
|
||||
|
||||
gUnifinderSelection = null;
|
||||
}
|
||||
|
||||
document.getElementById( "delete_command" ).setAttribute( "disabled", true );
|
||||
|
||||
document.getElementById( "modify_command" ).setAttribute( "disabled", true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the new event button is clicked
|
||||
*/
|
||||
@ -618,6 +557,8 @@ function CalendarWindow( calendarDataSource )
|
||||
{
|
||||
this.eventSource = calendarDataSource;
|
||||
|
||||
this.EventSelection = new CalendarEventSelection( this );
|
||||
|
||||
this.dateFormater = new DateFormater();
|
||||
|
||||
this.monthView = new MonthView( this );
|
||||
@ -667,7 +608,7 @@ function CalendarWindow( calendarDataSource )
|
||||
if( calendarEvent )
|
||||
{
|
||||
calendarWindow.setSelectedEvent( calendarEvent );
|
||||
calendarWindow.currentView.clearSelectedDate( );
|
||||
|
||||
calendarWindow.currentView.refreshEvents( );
|
||||
}
|
||||
}
|
||||
@ -682,8 +623,6 @@ function CalendarWindow( calendarDataSource )
|
||||
calendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
}
|
||||
calendarWindow.currentView.clearSelectedDate( );
|
||||
|
||||
calendarWindow.currentView.refreshEvents( );
|
||||
}
|
||||
},
|
||||
@ -697,8 +636,6 @@ function CalendarWindow( calendarDataSource )
|
||||
if ( nextEvent )
|
||||
{
|
||||
calendarWindow.setSelectedEvent( nextEvent );
|
||||
|
||||
calendarWindow.currentView.clearSelectedDate( );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -789,7 +726,6 @@ CalendarWindow.prototype.goToToday = function( )
|
||||
|
||||
CalendarWindow.prototype.goToNext = function( value )
|
||||
{
|
||||
this.clearSelectedEvent( );
|
||||
if(value){
|
||||
this.currentView.goToNext( value );
|
||||
}else{
|
||||
@ -805,7 +741,6 @@ CalendarWindow.prototype.goToNext = function( value )
|
||||
|
||||
CalendarWindow.prototype.goToPrevious = function( value )
|
||||
{
|
||||
this.clearSelectedEvent( );
|
||||
if(value){
|
||||
this.currentView.goToPrevious( value );
|
||||
}else{
|
||||
@ -821,8 +756,6 @@ CalendarWindow.prototype.goToPrevious = function( value )
|
||||
|
||||
CalendarWindow.prototype.goToDay = function( newDate )
|
||||
{
|
||||
this.clearSelectedEvent( );
|
||||
|
||||
this.currentView.goToDay( newDate );
|
||||
}
|
||||
|
||||
@ -838,8 +771,7 @@ CalendarWindow.prototype.goToDay = function( newDate )
|
||||
|
||||
CalendarWindow.prototype.setSelectedEvent = function( selectedEvent )
|
||||
{
|
||||
this.selectedEvent = selectedEvent;
|
||||
|
||||
this.EventSelection.replaceSelection( selectedEvent );
|
||||
}
|
||||
|
||||
|
||||
@ -855,30 +787,18 @@ CalendarWindow.prototype.setSelectedEvent = function( selectedEvent )
|
||||
|
||||
CalendarWindow.prototype.clearSelectedEvent = function( unSelectedEvent )
|
||||
{
|
||||
var undefined;
|
||||
var undefined;
|
||||
|
||||
gCalendarWindow.EventSelection.emptySelection( );
|
||||
|
||||
if( unSelectedEvent === undefined ||
|
||||
unSelectedEvent == null ||
|
||||
unSelectedEvent === this.selectedEvent )
|
||||
unSelectedEvent == null )
|
||||
{
|
||||
this.currentView.clearSelectedEvent( );
|
||||
this.selectedEvent = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Returns the selected event, or NULL if none selected
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.getSelectedEvent = function( )
|
||||
{
|
||||
return this.selectedEvent;
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Set the selected date
|
||||
@ -1059,8 +979,6 @@ CalendarView.prototype.superConstructor = CalendarView;
|
||||
|
||||
CalendarView.prototype.goToDay = function( newDate, ShowEvent )
|
||||
{
|
||||
this.clearSelectedEvent ( this.selectedEvent );
|
||||
|
||||
this.calendarWindow.setSelectedDate( newDate );
|
||||
|
||||
this.refresh( ShowEvent )
|
||||
@ -1080,9 +998,3 @@ CalendarView.prototype.refresh = function( ShowEvent )
|
||||
if(this.calendarWindow.currentView.doResize)
|
||||
this.calendarWindow.currentView.doResize();
|
||||
}
|
||||
|
||||
|
||||
function reloadApplication()
|
||||
{
|
||||
gCalendarWindow.currentView.refreshEvents( );
|
||||
}
|
||||
|
@ -107,6 +107,7 @@
|
||||
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendar.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendarEvent.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendarSelection.js"/>
|
||||
|
||||
<!-- Pop up menus -->
|
||||
|
||||
|
@ -42,9 +42,6 @@
|
||||
* Calendar day view class
|
||||
*
|
||||
* PROPERTIES
|
||||
* dayEvents - Event text is displayed in the hour items of the view. The items that currently
|
||||
* have an event are stored here. The hour items have a calendarEvent property
|
||||
* added so we know which event is displayed for the day.
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -71,11 +68,18 @@ function DayView( calendarWindow )
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
this.selectedEventBoxes = new Array();
|
||||
|
||||
// set up dayEvents array
|
||||
this.dayEvents = new Array();
|
||||
|
||||
var dayViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
gCalendarWindow.dayView.selectBoxForEvent( EventSelectionArray[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( dayViewEventSelectionObserver );
|
||||
}
|
||||
|
||||
|
||||
@ -261,16 +265,14 @@ DayView.prototype.refreshEvents = function( )
|
||||
document.getElementById( "day-view-content-board" ).appendChild( eventBox );
|
||||
}
|
||||
|
||||
}
|
||||
// select the hour of the selected item, if there is an item whose date matches
|
||||
|
||||
// select the hour of the selected item, if there is an item whose date matches
|
||||
|
||||
var selectedEvent = this.calendarWindow.getSelectedEvent();
|
||||
|
||||
//if the selected event is today, highlight it. Otherwise, don't highlight anything.
|
||||
if ( selectedEvent )
|
||||
{
|
||||
this.selectEvent( selectedEvent );
|
||||
// mark the box as selected, if the event is
|
||||
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +330,6 @@ DayView.prototype.createEventBox = function ( calendarEventDisplay )
|
||||
eventBox.setAttribute( "ondblclick", "dayEventItemDoubleClick( this, event )" );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.mouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "savetip" );
|
||||
eventBox.setAttribute( "id", "day-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "name", "day-view-event-box-"+calendarEventDisplay.event.id );
|
||||
|
||||
var eventHTMLElement = document.createElement( "description" );
|
||||
@ -382,8 +383,6 @@ DayView.prototype.switchTo = function( )
|
||||
// switch views in the deck
|
||||
|
||||
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
||||
|
||||
|
||||
calendarDeckItem.setAttribute( "selectedIndex", 2 );
|
||||
}
|
||||
|
||||
@ -452,19 +451,6 @@ DayView.prototype.refreshDisplay = function( )
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
DayView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
// :TODO:
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** PUBLIC -- monthview only
|
||||
*
|
||||
* Called when an event box item is single clicked
|
||||
@ -472,22 +458,8 @@ DayView.prototype.deletedSelectedEvent = function( )
|
||||
|
||||
DayView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
// clear the old selected box
|
||||
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", false );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
if( eventBox )
|
||||
{
|
||||
// select the event
|
||||
this.selectEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
}
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
@ -556,50 +528,32 @@ DayView.prototype.goToPrevious = function( goDays )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* select an event.
|
||||
*/
|
||||
DayView.prototype.selectEvent = function( calendarEvent )
|
||||
DayView.prototype.selectBoxForEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
EventBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* clear the selected event by taking off the selected attribute.
|
||||
*/
|
||||
DayView.prototype.clearSelectedEvent = function( )
|
||||
{
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
//Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if there is an event, and if the event is in the current view.
|
||||
//var SelectedBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+Event.id );
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", false );
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,18 +118,41 @@ function MonthView( calendarWindow )
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
// set up, see notes above
|
||||
|
||||
this.selectedEventBoxes = new Array();
|
||||
|
||||
this.selectedEvent = null;
|
||||
var monthViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
if( EventSelectionArray.length > 0 )
|
||||
{
|
||||
//if there are selected events.
|
||||
|
||||
this.selectedTodayBox = null;
|
||||
gCalendarWindow.monthView.clearSelectedDate();
|
||||
|
||||
gCalendarWindow.monthView.clearSelectedBoxes();
|
||||
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+EventSelectionArray[i].id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//select the proper day
|
||||
gCalendarWindow.monthView.hiliteSelectedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( monthViewEventSelectionObserver );
|
||||
|
||||
this.showingLastDay = false;
|
||||
|
||||
this.selectedBox = null;
|
||||
|
||||
// set up month day box's and day number text items, see notes above
|
||||
|
||||
this.dayNumberItemArray = new Array();
|
||||
@ -186,10 +209,9 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
||||
{
|
||||
eventBox = eventBoxList[ eventBoxIndex ];
|
||||
eventBox = eventBoxList[ eventBoxIndex ];
|
||||
|
||||
eventBox.parentNode.removeChild( eventBox );
|
||||
|
||||
}
|
||||
|
||||
// clear calendarEvent counts, we only display 3 events per day
|
||||
@ -202,10 +224,6 @@ MonthView.prototype.refreshEvents = function( )
|
||||
dayItem.numEvents = 0;
|
||||
}
|
||||
|
||||
// remove the old selection
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
// add each calendarEvent
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
@ -243,7 +261,7 @@ MonthView.prototype.refreshEvents = function( )
|
||||
eventBox.setAttribute( "event"+calendarEventDisplay.event.id, true );
|
||||
eventBox.setAttribute( "class", "month-day-event-box-class" );
|
||||
eventBox.setAttribute( "eventbox", "monthview" );
|
||||
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "onclick", "gCalendarWindow.monthView.clickEventBox( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.mouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "savetip" );
|
||||
@ -321,11 +339,9 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
// mark the box as selected, if the event is
|
||||
|
||||
if( this.calendarWindow.getSelectedEvent() === calendarEventDisplay.event )
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
eventBox = gCalendarWindow.currentView.getVisibleEvent( calendarEventDisplay.event );
|
||||
|
||||
gCalendarWindow.currentView.clickEventBox( eventBox );
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,7 +354,7 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
MonthView.prototype.switchFrom = function( )
|
||||
{
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -375,7 +391,7 @@ MonthView.prototype.switchTo = function( )
|
||||
* Redraw the display, but not the events
|
||||
*/
|
||||
|
||||
MonthView.prototype.refreshDisplay = function( ShowEvent )
|
||||
MonthView.prototype.refreshDisplay = function( )
|
||||
{
|
||||
// set the month/year in the header
|
||||
|
||||
@ -442,9 +458,8 @@ MonthView.prototype.refreshDisplay = function( ShowEvent )
|
||||
}
|
||||
|
||||
// if we aren't showing an event, highlite the selected date.
|
||||
if ( !ShowEvent )
|
||||
if ( this.calendarWindow.EventSelection.selectedEvents.length < 1 )
|
||||
{
|
||||
//debug("\n\n-->>>>Im' going to be highlightin the date from refresh display!!!");
|
||||
this.hiliteSelectedDate( );
|
||||
}
|
||||
|
||||
@ -462,16 +477,15 @@ MonthView.prototype.hiliteSelectedDate = function( )
|
||||
{
|
||||
// Clear the old selection if there was one
|
||||
|
||||
if( this.selectedBox )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected" , "false" );
|
||||
this.selectedBox = null;
|
||||
}
|
||||
|
||||
this.clearSelectedDate();
|
||||
|
||||
this.clearSelectedBoxes();
|
||||
|
||||
// Set the background for selection
|
||||
|
||||
this.selectedBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
||||
this.selectedBox.setAttribute( "selected" , "true" );
|
||||
var ThisBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
||||
|
||||
ThisBox.setAttribute( "monthselected" , "true" );
|
||||
}
|
||||
|
||||
|
||||
@ -482,13 +496,30 @@ MonthView.prototype.hiliteSelectedDate = function( )
|
||||
|
||||
MonthView.prototype.clearSelectedDate = function( )
|
||||
{
|
||||
if ( this.selectedBox )
|
||||
var SelectedBoxes = document.getElementsByAttribute( "monthselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected", "false" );
|
||||
this.selectedBox = null;
|
||||
SelectedBoxes[i].removeAttribute( "monthselected" );
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
*/
|
||||
|
||||
MonthView.prototype.clearSelectedBoxes = function( )
|
||||
{
|
||||
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.
|
||||
@ -501,10 +532,11 @@ MonthView.prototype.hiliteTodaysDate = function( )
|
||||
var Year = this.calendarWindow.getSelectedDate().getFullYear();
|
||||
|
||||
// Clear the old selection if there was one
|
||||
if ( this.selectedTodayBox )
|
||||
var TodayBox = document.getElementsByAttribute( "today", "true" );
|
||||
|
||||
for( i = 0; i < TodayBox.length; i++ )
|
||||
{
|
||||
this.selectedTodayBox.setAttribute( "today", "false" );
|
||||
this.selectedTodayBox = null;
|
||||
TodayBox[i].removeAttribute( "today" );
|
||||
}
|
||||
|
||||
//highlight today.
|
||||
@ -512,33 +544,9 @@ MonthView.prototype.hiliteTodaysDate = function( )
|
||||
|
||||
if ( Year == Today.getFullYear() && Month == Today.getMonth() )
|
||||
{
|
||||
this.selectedTodayBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
||||
var ThisBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
||||
|
||||
this.selectedTodayBox.setAttribute( "today", "true" );
|
||||
}
|
||||
else
|
||||
this.selectedTodayBox = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
MonthView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
if( this.selectedEventBoxes.length > 0 )
|
||||
{
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
var calendarEvent = this.selectedEventBoxes[i].calendarEventDisplay.event;
|
||||
|
||||
// tell the event source to delete it, the observers will be called
|
||||
// back into to update the display
|
||||
}
|
||||
this.calendarWindow.eventSource.deleteEvent( calendarEvent );
|
||||
ThisBox.setAttribute( "today", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,9 +676,7 @@ MonthView.prototype.clickDay = function( dayBoxItem )
|
||||
|
||||
this.calendarWindow.selectedDate.setDate( dayBoxItem.dayNumber );
|
||||
|
||||
this.hiliteSelectedDate( );
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
this.calendarWindow.EventSelection.emptySelection();
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,9 +688,7 @@ MonthView.prototype.doubleClickDay = function( dayBoxItem )
|
||||
|
||||
gCalendarWindow.selectedDate.setDate( dayBoxItem.dayNumber );
|
||||
|
||||
this.hiliteSelectedDate( );
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
this.calendarWindow.EventSelection.emptySelection();
|
||||
|
||||
var startDate = this.getNewEventDate();
|
||||
|
||||
@ -701,85 +705,27 @@ MonthView.prototype.doubleClickDay = function( dayBoxItem )
|
||||
|
||||
MonthView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
//deselect the selected day in the month view
|
||||
|
||||
this.clearSelectedDate( );
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
//set the selected date to the start date of this event.
|
||||
if( eventBox)
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
// Do not let the click go through, suppress default selection
|
||||
if ( event )
|
||||
{
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
// clear the old selected box
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
|
||||
// select the event
|
||||
|
||||
this.calendarWindow.setSelectedEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
// mark new box as selected
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+eventBox.calendarEventDisplay.event.id );
|
||||
|
||||
for ( var i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].setAttribute( "selected", "true" );
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = ArrayOfBoxes[i];
|
||||
}
|
||||
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
//select the event in the unifinder
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
MonthView.prototype.selectEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
}
|
||||
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
MonthView.prototype.clearSelectedEvent = function ( )
|
||||
{
|
||||
Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if ( Event && document.getElementById( "month-view-event-box-"+Event.id ) )
|
||||
if ( Event && document.getElementsByAttribute( "name", "month-view-event-box-"+Event.id ).length > 0 )
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
var ArrayOfElements = document.getElementsByAttribute( "id", "month-view-event-box-"+Event.id );
|
||||
for ( var i = 0; i < ArrayOfElements.length; i++ )
|
||||
{
|
||||
ArrayOfElements[i].setAttribute( "selected", false );
|
||||
}
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -793,7 +739,16 @@ MonthView.prototype.getVisibleEvent = function( calendarEvent )
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
MonthView.prototype.selectBoxForEvent = function( 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.*/
|
||||
@ -804,7 +759,7 @@ MonthView.prototype.doResize = function(){
|
||||
/*Takes in a height, sets the calendar's container box to that height, the grid expands and contracts to fit it.*/
|
||||
MonthView.setCalendarSize = function( height ){
|
||||
var offset = document.defaultView.getComputedStyle(document.getElementById("month-controls-box"), "").getPropertyValue("height");
|
||||
offset = offset.substring(0,offset.length-2);
|
||||
offset = parseInt( offset );
|
||||
height = (height-offset)+"px";
|
||||
document.getElementById( "month-content-box" ).setAttribute( "height", height );
|
||||
}
|
||||
@ -812,7 +767,7 @@ MonthView.setCalendarSize = function( height ){
|
||||
/*returns the height of the current view in pixels*/
|
||||
MonthView.getViewHeight = function( ){
|
||||
toReturn = document.defaultView.getComputedStyle(document.getElementById("calendar-top-box"), "").getPropertyValue("height");
|
||||
toReturn = toReturn.substring(0, toReturn.length-2); //strip off the px at the end
|
||||
toReturn = parseInt( toReturn ); //strip off the px at the end
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
156
calendar/resources/content/calendarSelection.js
Normal file
156
calendar/resources/content/calendarSelection.js
Normal file
@ -0,0 +1,156 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* OEone Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Mike Potter <mikep@oeone.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function CalendarEventSelection( CalendarWindow )
|
||||
{
|
||||
this.calendarWindow = CalendarWindow;
|
||||
|
||||
this.selectedEvents = new Array();
|
||||
|
||||
this.observerList = new Array();
|
||||
}
|
||||
|
||||
CalendarEventSelection.prototype.addObserver = function( observer )
|
||||
{
|
||||
if( observer )
|
||||
{
|
||||
// remove it first, that way no observer gets added twice
|
||||
this.removeObserver( observer );
|
||||
|
||||
// add it to the end.
|
||||
this.observerList[ this.observerList.length ] = observer;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* /removeObserver.
|
||||
*
|
||||
* Removes a previously added observer
|
||||
*
|
||||
* PARAMETERS
|
||||
* observer - Observer to remove.
|
||||
*/
|
||||
|
||||
CalendarEventSelection.prototype.removeObserver = function( observer )
|
||||
{
|
||||
for( var index = 0; index < this.observerList.length; ++index )
|
||||
{
|
||||
if( observer === this.observerList[ index ] )
|
||||
{
|
||||
this.observerList.splice( index, 1 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CalendarEventSelection.prototype.addToSelection = function ( Event )
|
||||
{
|
||||
this.selectedEvents[ this.selectedEvents.length ] = Event;
|
||||
|
||||
this.onSelectionChanged();
|
||||
}
|
||||
|
||||
CalendarEventSelection.prototype.replaceSelection = function ( Event )
|
||||
{
|
||||
this.selectedEvents = new Array();
|
||||
|
||||
this.selectedEvents[ this.selectedEvents.length ] = Event;
|
||||
|
||||
this.onSelectionChanged();
|
||||
|
||||
}
|
||||
|
||||
CalendarEventSelection.prototype.emptySelection = function ( Event )
|
||||
{
|
||||
this.selectedEvents = new Array();
|
||||
|
||||
this.onSelectionChanged();
|
||||
|
||||
}
|
||||
|
||||
CalendarEventSelection.prototype.isSelectedEvent = function ( Event )
|
||||
{
|
||||
for( i = 0; i < this.selectedEvents.length; i++ )
|
||||
{
|
||||
if( this.selectedEvents[i] == Event )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* onSelectionChanged.
|
||||
*
|
||||
* Respond to adding a category.
|
||||
*
|
||||
* PARAMETERS
|
||||
* NewCategory - new category that was added
|
||||
*/
|
||||
|
||||
CalendarEventSelection.prototype.onSelectionChanged = function ( )
|
||||
{
|
||||
if( this.selectedEvents.length > 0 )
|
||||
{
|
||||
document.getElementById( "delete_command" ).removeAttribute( "disabled" );
|
||||
|
||||
document.getElementById( "modify_command" ).removeAttribute( "disabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById( "delete_command" ).setAttribute( "disabled", "true" );
|
||||
|
||||
document.getElementById( "modify_command" ).setAttribute( "disabled", "true" );
|
||||
}
|
||||
|
||||
for( var index in this.observerList )
|
||||
{
|
||||
var observer = this.observerList[ index ];
|
||||
|
||||
if( "onSelectionChanged" in observer )
|
||||
{
|
||||
observer.onSelectionChanged( this.selectedEvents );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,14 +75,26 @@ function WeekView( calendarWindow )
|
||||
|
||||
gHeaderDateItemArray = new Array();
|
||||
|
||||
this.selectedEventBoxes = 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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -294,18 +306,15 @@ WeekView.prototype.refreshEvents = function( )
|
||||
//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
|
||||
|
||||
var selectedEvent = this.calendarWindow.getSelectedEvent();
|
||||
|
||||
//if the selected event is today, highlight it. Otherwise, don't highlight anything.
|
||||
if ( selectedEvent )
|
||||
{
|
||||
this.selectEvent( selectedEvent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -466,17 +475,6 @@ WeekView.prototype.refreshDisplay = function( )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
WeekView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
// :TODO:
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
@ -515,6 +513,16 @@ WeekView.prototype.goToPrevious = function()
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
@ -580,22 +588,16 @@ WeekView.prototype.hiliteTodaysDate = function( )
|
||||
*/
|
||||
WeekView.prototype.clearSelectedEvent = function( )
|
||||
{
|
||||
Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if there is an event, and if the event is in the current view.
|
||||
if ( Event && document.getElementsByAttribute( "name", "week-view-event-box-"+Event.id ).length > 0 )
|
||||
{
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", "false" );
|
||||
}
|
||||
//document.getElementById( "week-view-event-box-"+Event.id ).setAttribute( "selected", false );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
//Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -606,44 +608,14 @@ WeekView.prototype.clearSelectedEvent = function( )
|
||||
|
||||
WeekView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
// clear the old selected box
|
||||
|
||||
if( this.selectedEventBoxes.length > 0 )
|
||||
{
|
||||
this.clearSelectedEvent();
|
||||
}
|
||||
|
||||
if( eventBox )
|
||||
{
|
||||
// select the event
|
||||
this.selectEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
//set the selected date to the start date of this event.
|
||||
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
// mark new box as selected
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+eventBox.calendarEventDisplay.event.id );
|
||||
for ( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = ArrayOfBoxes[i];
|
||||
}
|
||||
|
||||
//select the event in the unifinder
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
|
||||
}
|
||||
// Do not let the click go through, suppress default selection
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -665,30 +637,6 @@ WeekView.prototype.getNewEventDate = function( )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* select an event.
|
||||
*/
|
||||
WeekView.prototype.selectEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
}
|
||||
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
@ -698,7 +646,7 @@ WeekView.prototype.clearSelectedDate = function( )
|
||||
{
|
||||
if ( this.selectedBox )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected", "false" );
|
||||
this.selectedBox.removeAttribute( "eventselected" );
|
||||
this.selectedBox = null;
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,6 @@
|
||||
* Calendar day view class
|
||||
*
|
||||
* PROPERTIES
|
||||
* dayEvents - Event text is displayed in the hour items of the view. The items that currently
|
||||
* have an event are stored here. The hour items have a calendarEvent property
|
||||
* added so we know which event is displayed for the day.
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -71,11 +68,18 @@ function DayView( calendarWindow )
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
this.selectedEventBoxes = new Array();
|
||||
|
||||
// set up dayEvents array
|
||||
this.dayEvents = new Array();
|
||||
|
||||
var dayViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
gCalendarWindow.dayView.selectBoxForEvent( EventSelectionArray[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( dayViewEventSelectionObserver );
|
||||
}
|
||||
|
||||
|
||||
@ -261,16 +265,14 @@ DayView.prototype.refreshEvents = function( )
|
||||
document.getElementById( "day-view-content-board" ).appendChild( eventBox );
|
||||
}
|
||||
|
||||
}
|
||||
// select the hour of the selected item, if there is an item whose date matches
|
||||
|
||||
// select the hour of the selected item, if there is an item whose date matches
|
||||
|
||||
var selectedEvent = this.calendarWindow.getSelectedEvent();
|
||||
|
||||
//if the selected event is today, highlight it. Otherwise, don't highlight anything.
|
||||
if ( selectedEvent )
|
||||
{
|
||||
this.selectEvent( selectedEvent );
|
||||
// mark the box as selected, if the event is
|
||||
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +330,6 @@ DayView.prototype.createEventBox = function ( calendarEventDisplay )
|
||||
eventBox.setAttribute( "ondblclick", "dayEventItemDoubleClick( this, event )" );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.mouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "savetip" );
|
||||
eventBox.setAttribute( "id", "day-view-event-box-"+calendarEventDisplay.event.id );
|
||||
eventBox.setAttribute( "name", "day-view-event-box-"+calendarEventDisplay.event.id );
|
||||
|
||||
var eventHTMLElement = document.createElement( "description" );
|
||||
@ -382,8 +383,6 @@ DayView.prototype.switchTo = function( )
|
||||
// switch views in the deck
|
||||
|
||||
var calendarDeckItem = document.getElementById( "calendar-deck" );
|
||||
|
||||
|
||||
calendarDeckItem.setAttribute( "selectedIndex", 2 );
|
||||
}
|
||||
|
||||
@ -452,19 +451,6 @@ DayView.prototype.refreshDisplay = function( )
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
DayView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
// :TODO:
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** PUBLIC -- monthview only
|
||||
*
|
||||
* Called when an event box item is single clicked
|
||||
@ -472,22 +458,8 @@ DayView.prototype.deletedSelectedEvent = function( )
|
||||
|
||||
DayView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
// clear the old selected box
|
||||
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", false );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
if( eventBox )
|
||||
{
|
||||
// select the event
|
||||
this.selectEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
}
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
@ -556,50 +528,32 @@ DayView.prototype.goToPrevious = function( goDays )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* select an event.
|
||||
*/
|
||||
DayView.prototype.selectEvent = function( calendarEvent )
|
||||
DayView.prototype.selectBoxForEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
EventBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* clear the selected event by taking off the selected attribute.
|
||||
*/
|
||||
DayView.prototype.clearSelectedEvent = function( )
|
||||
{
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
//Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if there is an event, and if the event is in the current view.
|
||||
//var SelectedBoxes = document.getElementsByAttribute( "name", "day-view-event-box-"+Event.id );
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", false );
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,18 +118,41 @@ function MonthView( calendarWindow )
|
||||
|
||||
this.superConstructor( calendarWindow );
|
||||
|
||||
// set up, see notes above
|
||||
|
||||
this.selectedEventBoxes = new Array();
|
||||
|
||||
this.selectedEvent = null;
|
||||
var monthViewEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
if( EventSelectionArray.length > 0 )
|
||||
{
|
||||
//if there are selected events.
|
||||
|
||||
this.selectedTodayBox = null;
|
||||
gCalendarWindow.monthView.clearSelectedDate();
|
||||
|
||||
gCalendarWindow.monthView.clearSelectedBoxes();
|
||||
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+EventSelectionArray[i].id );
|
||||
|
||||
for ( j = 0; j < EventBoxes.length; j++ )
|
||||
{
|
||||
EventBoxes[j].setAttribute( "eventselected", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//select the proper day
|
||||
gCalendarWindow.monthView.hiliteSelectedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calendarWindow.EventSelection.addObserver( monthViewEventSelectionObserver );
|
||||
|
||||
this.showingLastDay = false;
|
||||
|
||||
this.selectedBox = null;
|
||||
|
||||
// set up month day box's and day number text items, see notes above
|
||||
|
||||
this.dayNumberItemArray = new Array();
|
||||
@ -186,10 +209,9 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
for( var eventBoxIndex = 0; eventBoxIndex < eventBoxList.length; ++eventBoxIndex )
|
||||
{
|
||||
eventBox = eventBoxList[ eventBoxIndex ];
|
||||
eventBox = eventBoxList[ eventBoxIndex ];
|
||||
|
||||
eventBox.parentNode.removeChild( eventBox );
|
||||
|
||||
}
|
||||
|
||||
// clear calendarEvent counts, we only display 3 events per day
|
||||
@ -202,10 +224,6 @@ MonthView.prototype.refreshEvents = function( )
|
||||
dayItem.numEvents = 0;
|
||||
}
|
||||
|
||||
// remove the old selection
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
// add each calendarEvent
|
||||
|
||||
this.kungFooDeathGripOnEventBoxes = new Array();
|
||||
@ -243,7 +261,7 @@ MonthView.prototype.refreshEvents = function( )
|
||||
eventBox.setAttribute( "event"+calendarEventDisplay.event.id, true );
|
||||
eventBox.setAttribute( "class", "month-day-event-box-class" );
|
||||
eventBox.setAttribute( "eventbox", "monthview" );
|
||||
eventBox.setAttribute( "onclick", "monthEventBoxClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "onclick", "gCalendarWindow.monthView.clickEventBox( this, event )" );
|
||||
eventBox.setAttribute( "ondblclick", "monthEventBoxDoubleClickEvent( this, event )" );
|
||||
eventBox.setAttribute( "onmouseover", "gCalendarWindow.mouseOverInfo( calendarEventDisplay, event )" );
|
||||
eventBox.setAttribute( "tooltip", "savetip" );
|
||||
@ -321,11 +339,9 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
// mark the box as selected, if the event is
|
||||
|
||||
if( this.calendarWindow.getSelectedEvent() === calendarEventDisplay.event )
|
||||
if( this.calendarWindow.EventSelection.isSelectedEvent( calendarEventDisplay.event ) )
|
||||
{
|
||||
eventBox = gCalendarWindow.currentView.getVisibleEvent( calendarEventDisplay.event );
|
||||
|
||||
gCalendarWindow.currentView.clickEventBox( eventBox );
|
||||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,7 +354,7 @@ MonthView.prototype.refreshEvents = function( )
|
||||
|
||||
MonthView.prototype.switchFrom = function( )
|
||||
{
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -375,7 +391,7 @@ MonthView.prototype.switchTo = function( )
|
||||
* Redraw the display, but not the events
|
||||
*/
|
||||
|
||||
MonthView.prototype.refreshDisplay = function( ShowEvent )
|
||||
MonthView.prototype.refreshDisplay = function( )
|
||||
{
|
||||
// set the month/year in the header
|
||||
|
||||
@ -442,9 +458,8 @@ MonthView.prototype.refreshDisplay = function( ShowEvent )
|
||||
}
|
||||
|
||||
// if we aren't showing an event, highlite the selected date.
|
||||
if ( !ShowEvent )
|
||||
if ( this.calendarWindow.EventSelection.selectedEvents.length < 1 )
|
||||
{
|
||||
//debug("\n\n-->>>>Im' going to be highlightin the date from refresh display!!!");
|
||||
this.hiliteSelectedDate( );
|
||||
}
|
||||
|
||||
@ -462,16 +477,15 @@ MonthView.prototype.hiliteSelectedDate = function( )
|
||||
{
|
||||
// Clear the old selection if there was one
|
||||
|
||||
if( this.selectedBox )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected" , "false" );
|
||||
this.selectedBox = null;
|
||||
}
|
||||
|
||||
this.clearSelectedDate();
|
||||
|
||||
this.clearSelectedBoxes();
|
||||
|
||||
// Set the background for selection
|
||||
|
||||
this.selectedBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
||||
this.selectedBox.setAttribute( "selected" , "true" );
|
||||
var ThisBox = this.dayBoxItemByDateArray[ this.calendarWindow.getSelectedDate().getDate() ];
|
||||
|
||||
ThisBox.setAttribute( "monthselected" , "true" );
|
||||
}
|
||||
|
||||
|
||||
@ -482,13 +496,30 @@ MonthView.prototype.hiliteSelectedDate = function( )
|
||||
|
||||
MonthView.prototype.clearSelectedDate = function( )
|
||||
{
|
||||
if ( this.selectedBox )
|
||||
var SelectedBoxes = document.getElementsByAttribute( "monthselected", "true" );
|
||||
|
||||
for( i = 0; i < SelectedBoxes.length; i++ )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected", "false" );
|
||||
this.selectedBox = null;
|
||||
SelectedBoxes[i].removeAttribute( "monthselected" );
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
*/
|
||||
|
||||
MonthView.prototype.clearSelectedBoxes = function( )
|
||||
{
|
||||
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.
|
||||
@ -501,10 +532,11 @@ MonthView.prototype.hiliteTodaysDate = function( )
|
||||
var Year = this.calendarWindow.getSelectedDate().getFullYear();
|
||||
|
||||
// Clear the old selection if there was one
|
||||
if ( this.selectedTodayBox )
|
||||
var TodayBox = document.getElementsByAttribute( "today", "true" );
|
||||
|
||||
for( i = 0; i < TodayBox.length; i++ )
|
||||
{
|
||||
this.selectedTodayBox.setAttribute( "today", "false" );
|
||||
this.selectedTodayBox = null;
|
||||
TodayBox[i].removeAttribute( "today" );
|
||||
}
|
||||
|
||||
//highlight today.
|
||||
@ -512,33 +544,9 @@ MonthView.prototype.hiliteTodaysDate = function( )
|
||||
|
||||
if ( Year == Today.getFullYear() && Month == Today.getMonth() )
|
||||
{
|
||||
this.selectedTodayBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
||||
var ThisBox = this.dayBoxItemByDateArray[ Today.getDate() ];
|
||||
|
||||
this.selectedTodayBox.setAttribute( "today", "true" );
|
||||
}
|
||||
else
|
||||
this.selectedTodayBox = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
MonthView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
if( this.selectedEventBoxes.length > 0 )
|
||||
{
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
var calendarEvent = this.selectedEventBoxes[i].calendarEventDisplay.event;
|
||||
|
||||
// tell the event source to delete it, the observers will be called
|
||||
// back into to update the display
|
||||
}
|
||||
this.calendarWindow.eventSource.deleteEvent( calendarEvent );
|
||||
ThisBox.setAttribute( "today", "true" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,9 +676,7 @@ MonthView.prototype.clickDay = function( dayBoxItem )
|
||||
|
||||
this.calendarWindow.selectedDate.setDate( dayBoxItem.dayNumber );
|
||||
|
||||
this.hiliteSelectedDate( );
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
this.calendarWindow.EventSelection.emptySelection();
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,9 +688,7 @@ MonthView.prototype.doubleClickDay = function( dayBoxItem )
|
||||
|
||||
gCalendarWindow.selectedDate.setDate( dayBoxItem.dayNumber );
|
||||
|
||||
this.hiliteSelectedDate( );
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
this.calendarWindow.EventSelection.emptySelection();
|
||||
|
||||
var startDate = this.getNewEventDate();
|
||||
|
||||
@ -701,85 +705,27 @@ MonthView.prototype.doubleClickDay = function( dayBoxItem )
|
||||
|
||||
MonthView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
//deselect the selected day in the month view
|
||||
|
||||
this.clearSelectedDate( );
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
//set the selected date to the start date of this event.
|
||||
if( eventBox)
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
// Do not let the click go through, suppress default selection
|
||||
if ( event )
|
||||
{
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
// clear the old selected box
|
||||
|
||||
this.clearSelectedEvent( );
|
||||
|
||||
// select the event
|
||||
|
||||
this.calendarWindow.setSelectedEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
// mark new box as selected
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "name", "month-view-event-box-"+eventBox.calendarEventDisplay.event.id );
|
||||
|
||||
for ( var i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].setAttribute( "selected", "true" );
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = ArrayOfBoxes[i];
|
||||
}
|
||||
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
//select the event in the unifinder
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
MonthView.prototype.selectEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
}
|
||||
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
MonthView.prototype.clearSelectedEvent = function ( )
|
||||
{
|
||||
Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if ( Event && document.getElementById( "month-view-event-box-"+Event.id ) )
|
||||
if ( Event && document.getElementsByAttribute( "name", "month-view-event-box-"+Event.id ).length > 0 )
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
var ArrayOfElements = document.getElementsByAttribute( "id", "month-view-event-box-"+Event.id );
|
||||
for ( var i = 0; i < ArrayOfElements.length; i++ )
|
||||
{
|
||||
ArrayOfElements[i].setAttribute( "selected", false );
|
||||
}
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -793,7 +739,16 @@ MonthView.prototype.getVisibleEvent = function( calendarEvent )
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
MonthView.prototype.selectBoxForEvent = function( 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.*/
|
||||
@ -804,7 +759,7 @@ MonthView.prototype.doResize = function(){
|
||||
/*Takes in a height, sets the calendar's container box to that height, the grid expands and contracts to fit it.*/
|
||||
MonthView.setCalendarSize = function( height ){
|
||||
var offset = document.defaultView.getComputedStyle(document.getElementById("month-controls-box"), "").getPropertyValue("height");
|
||||
offset = offset.substring(0,offset.length-2);
|
||||
offset = parseInt( offset );
|
||||
height = (height-offset)+"px";
|
||||
document.getElementById( "month-content-box" ).setAttribute( "height", height );
|
||||
}
|
||||
@ -812,7 +767,7 @@ MonthView.setCalendarSize = function( height ){
|
||||
/*returns the height of the current view in pixels*/
|
||||
MonthView.getViewHeight = function( ){
|
||||
toReturn = document.defaultView.getComputedStyle(document.getElementById("calendar-top-box"), "").getPropertyValue("height");
|
||||
toReturn = toReturn.substring(0, toReturn.length-2); //strip off the px at the end
|
||||
toReturn = parseInt( toReturn ); //strip off the px at the end
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,33 @@
|
||||
* improve this to make it usable in general.
|
||||
*/
|
||||
|
||||
function unifinderInit()
|
||||
function unifinderInit( CalendarWindow )
|
||||
{
|
||||
var unifinderEventSelectionObserver =
|
||||
{
|
||||
onSelectionChanged : function( EventSelectionArray )
|
||||
{
|
||||
var CategoriesTree = document.getElementById( "unifinder-categories-tree" );
|
||||
|
||||
var SearchTree = document.getElementById( "unifinder-search-tree" );
|
||||
|
||||
CategoriesTree.clearSelection();
|
||||
|
||||
if( EventSelectionArray.length > 0 )
|
||||
{
|
||||
for( i = 0; i < EventSelectionArray.length; i++ )
|
||||
{
|
||||
CategoriesTree.addItemToSelection( document.getElementById( "unifinder-treeitem-"+EventSelectionArray[i].id ) );
|
||||
|
||||
CategoriesTree.addItemToSelection( document.getElementById( "search-unifinder-treeitem-"+EventSelectionArray[i].id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gCalendarWindow.EventSelection.addObserver( unifinderEventSelectionObserver );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -70,9 +95,6 @@ var gSearchEventTable = new Array();
|
||||
|
||||
var gDateFormater = new DateFormater();
|
||||
|
||||
var gUnifinderSelection = null;
|
||||
|
||||
|
||||
/**
|
||||
* Observer for the calendar event data source. This keeps the unifinder
|
||||
* display up to date when the calendar event data is changed
|
||||
@ -99,22 +121,17 @@ var unifinderEventDataSourceObserver =
|
||||
if( calendarEvent )
|
||||
{
|
||||
unifinderRefesh();
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
},
|
||||
|
||||
onModifyItem : function( calendarEvent, originalEvent )
|
||||
{
|
||||
unifinderRefesh();
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
},
|
||||
|
||||
onDeleteItem : function( calendarEvent )
|
||||
{
|
||||
unifinderRefesh();
|
||||
|
||||
},
|
||||
|
||||
onAlarm : function( calendarEvent )
|
||||
@ -239,34 +256,18 @@ function unifinderDoubleClickEvent( id )
|
||||
|
||||
function unifinderClickEvent( id, event )
|
||||
{
|
||||
gUnifinderSelection = id;
|
||||
|
||||
var calendarEvent = gICalLib.fetchEvent( id );
|
||||
|
||||
gCalendarWindow.EventSelection.replaceSelection( calendarEvent );
|
||||
|
||||
var eventBox = gCalendarWindow.currentView.getVisibleEvent( calendarEvent );
|
||||
|
||||
if ( eventBox )
|
||||
if ( !eventBox )
|
||||
{
|
||||
//the event box exists, so the event is visible.
|
||||
gCalendarWindow.currentView.clickEventBox( eventBox, event );
|
||||
}
|
||||
else //else we go to the day
|
||||
{
|
||||
gCalendarWindow.currentView.clearSelectedDate( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
var eventStartDate = new Date( calendarEvent.start.getTime() );
|
||||
|
||||
gCalendarWindow.currentView.goToDay( eventStartDate, true);
|
||||
|
||||
eventBox = gCalendarWindow.currentView.getVisibleEvent( calendarEvent );
|
||||
|
||||
gCalendarWindow.currentView.clickEventBox( eventBox, event );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,15 +286,12 @@ function unifinderModifyCommand()
|
||||
}
|
||||
else
|
||||
{
|
||||
if( gUnifinderSelection != null )
|
||||
var calendarEvent = gCalendarWindow.EventSelection.selectedEvents[0];
|
||||
|
||||
if( calendarEvent != null )
|
||||
{
|
||||
var calendarEvent = gICalLib.fetchEvent( gUnifinderSelection );
|
||||
|
||||
if( calendarEvent != null )
|
||||
{
|
||||
editEvent( calendarEvent );
|
||||
}
|
||||
}
|
||||
editEvent( calendarEvent );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,43 +301,42 @@ function unifinderModifyCommand()
|
||||
* This is called from the unifinder's remove command
|
||||
*/
|
||||
|
||||
function unifinderRemoveCommand()
|
||||
function unifinderRemoveCommand( DoNotConfirm )
|
||||
{
|
||||
var SelectedItem = document.getElementById( "unifinder-categories-tree" ).selectedItems[0];
|
||||
|
||||
if( SelectedItem )
|
||||
var SelectedItems = gCalendarWindow.EventSelection.selectedEvents;
|
||||
|
||||
if( SelectedItems.length == 1 )
|
||||
{
|
||||
if ( SelectedItem.getAttribute( "container" ) == "true" )
|
||||
{
|
||||
if ( confirm( "Are you sure you want to delete this category?" ) )
|
||||
{
|
||||
gCategoryManager.deleteCategory( SelectedItem.categoryobject );
|
||||
var calendarEvent = SelectedItems[0];
|
||||
|
||||
if ( calendarEvent.title != "" ) {
|
||||
if( !DoNotConfirm ) {
|
||||
if ( confirm( confirmDeleteEvent+" "+calendarEvent.title+"?" ) ) {
|
||||
gICalLib.deleteEvent( calendarEvent.id );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( gUnifinderSelection != null )
|
||||
{
|
||||
var calendarEvent = gICalLib.fetchEvent( gUnifinderSelection );
|
||||
|
||||
if( calendarEvent != null )
|
||||
{
|
||||
if ( calendarEvent.title != "" )
|
||||
{
|
||||
if ( confirm( confirmDeleteEvent+" "+calendarEvent.title+"?" ) ) {
|
||||
gICalLib.deleteEvent( calendarEvent.id );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( confirm( confirmDeleteUntitledEvent ) ) {
|
||||
gICalLib.deleteEvent( calendarEvent.id );
|
||||
}
|
||||
}
|
||||
if( !DoNotConfirm ) {
|
||||
if ( confirm( confirmDeleteUntitledEvent ) ) {
|
||||
gICalLib.deleteEvent( calendarEvent.id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( SelectedItems.length > 1 )
|
||||
{
|
||||
if( confirm( "Are you sure you want to delete everything?" ) )
|
||||
{
|
||||
while( SelectedItems.length )
|
||||
{
|
||||
var ThisItem = SelectedItems.pop();
|
||||
|
||||
gICalLib.deleteEvent( gICalLib.fetchEvent( ThisItem.calendarEvent.id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -351,7 +348,7 @@ function onUnifinderCategoriesKeyPress(event)
|
||||
{
|
||||
if ((event.keyCode == 8)||(event.keyCode == 46))
|
||||
{
|
||||
unifinderRemoveCommand();
|
||||
unifinderRemoveCommand( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
<tabpanels orient="horizontal" flex="1">
|
||||
<vbox id="unifinder-categories-box" flex="1">
|
||||
<vbox id="unifinder-categories-content-box" flex="1" >
|
||||
<tree id="unifinder-categories-tree" class="unifinder-tree-class" flex="1" onkeypress="onUnifinderCategoriesKeyPress(event)">
|
||||
<tree multiple="true" id="unifinder-categories-tree" class="unifinder-tree-class" flex="1" onkeypress="onUnifinderCategoriesKeyPress(event)">
|
||||
<treechildren id="unifinder-categories-tree-children" flex="1"/>
|
||||
</tree>
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
<vbox flex="1">
|
||||
<unifinder-search-controls keypressfunction="unifinderSearchKeyPress( this, event )" />
|
||||
|
||||
<tree id="unifinder-search-results-tree" class="unifinder-tree-class" flex="1" >
|
||||
<tree multiple="false" id="unifinder-search-results-tree" class="unifinder-tree-class" flex="1" >
|
||||
<treechildren id="unifinder-search-results-tree-children" flex="1"/>
|
||||
</tree>
|
||||
</vbox>
|
||||
|
@ -75,14 +75,26 @@ function WeekView( calendarWindow )
|
||||
|
||||
gHeaderDateItemArray = new Array();
|
||||
|
||||
this.selectedEventBoxes = 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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -294,18 +306,15 @@ WeekView.prototype.refreshEvents = function( )
|
||||
//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
|
||||
|
||||
var selectedEvent = this.calendarWindow.getSelectedEvent();
|
||||
|
||||
//if the selected event is today, highlight it. Otherwise, don't highlight anything.
|
||||
if ( selectedEvent )
|
||||
{
|
||||
this.selectEvent( selectedEvent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -466,17 +475,6 @@ WeekView.prototype.refreshDisplay = function( )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Get the selected event and delete it.
|
||||
*/
|
||||
|
||||
WeekView.prototype.deletedSelectedEvent = function( )
|
||||
{
|
||||
// :TODO:
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* This is called when we are about the make a new event
|
||||
@ -515,6 +513,16 @@ WeekView.prototype.goToPrevious = function()
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
@ -580,22 +588,16 @@ WeekView.prototype.hiliteTodaysDate = function( )
|
||||
*/
|
||||
WeekView.prototype.clearSelectedEvent = function( )
|
||||
{
|
||||
Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
//if there is an event, and if the event is in the current view.
|
||||
if ( Event && document.getElementsByAttribute( "name", "week-view-event-box-"+Event.id ).length > 0 )
|
||||
{
|
||||
for ( i = 0; i < this.selectedEventBoxes.length; i++ )
|
||||
{
|
||||
this.selectedEventBoxes[i].setAttribute( "selected", "false" );
|
||||
}
|
||||
//document.getElementById( "week-view-event-box-"+Event.id ).setAttribute( "selected", false );
|
||||
}
|
||||
|
||||
this.selectedEventBoxes = Array();
|
||||
gCalendarWindow.EventSelection.emptySelection();
|
||||
|
||||
//clear the selection in the unifinder
|
||||
deselectEventInUnifinder( );
|
||||
//Event = gCalendarWindow.getSelectedEvent();
|
||||
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "eventselected", "true" );
|
||||
|
||||
for( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].removeAttribute( "eventselected" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -606,44 +608,14 @@ WeekView.prototype.clearSelectedEvent = function( )
|
||||
|
||||
WeekView.prototype.clickEventBox = function( eventBox, event )
|
||||
{
|
||||
// clear the old selected box
|
||||
|
||||
if( this.selectedEventBoxes.length > 0 )
|
||||
{
|
||||
this.clearSelectedEvent();
|
||||
}
|
||||
|
||||
if( eventBox )
|
||||
{
|
||||
// select the event
|
||||
this.selectEvent( eventBox.calendarEventDisplay.event );
|
||||
|
||||
//set the selected date to the start date of this event.
|
||||
|
||||
this.calendarWindow.selectedDate.setDate( eventBox.calendarEventDisplay.event.start.day );
|
||||
|
||||
// mark new box as selected
|
||||
var ArrayOfBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+eventBox.calendarEventDisplay.event.id );
|
||||
for ( i = 0; i < ArrayOfBoxes.length; i++ )
|
||||
{
|
||||
ArrayOfBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = ArrayOfBoxes[i];
|
||||
}
|
||||
|
||||
//select the event in the unifinder
|
||||
|
||||
selectEventInUnifinder( eventBox.calendarEventDisplay.event );
|
||||
this.calendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
||||
|
||||
|
||||
}
|
||||
// Do not let the click go through, suppress default selection
|
||||
// Do not let the click go through, suppress default selection
|
||||
|
||||
if ( event )
|
||||
{
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -665,30 +637,6 @@ WeekView.prototype.getNewEventDate = function( )
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* select an event.
|
||||
*/
|
||||
WeekView.prototype.selectEvent = function( calendarEvent )
|
||||
{
|
||||
//clear the selected event
|
||||
gCalendarWindow.clearSelectedEvent( );
|
||||
|
||||
gCalendarWindow.setSelectedEvent( calendarEvent );
|
||||
|
||||
var EventBoxes = document.getElementsByAttribute( "name", "week-view-event-box-"+calendarEvent.id );
|
||||
|
||||
for ( i = 0; i < EventBoxes.length; i++ )
|
||||
{
|
||||
EventBoxes[i].setAttribute( "selected", "true" );
|
||||
|
||||
this.selectedEventBoxes[ this.selectedEventBoxes.length ] = EventBoxes[i];
|
||||
}
|
||||
|
||||
|
||||
selectEventInUnifinder( calendarEvent );
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Unmark the selected date if there is one.
|
||||
@ -698,7 +646,7 @@ WeekView.prototype.clearSelectedDate = function( )
|
||||
{
|
||||
if ( this.selectedBox )
|
||||
{
|
||||
this.selectedBox.setAttribute( "selected", "false" );
|
||||
this.selectedBox.removeAttribute( "eventselected" );
|
||||
this.selectedBox = null;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ calendar.jar:
|
||||
content/calendar/calendarMonthView.xul (content/calendarMonthView.xul)
|
||||
content/calendar/calendarOverlay.js (content/calendarOverlay.js)
|
||||
content/calendar/calendarOverlay.xul (content/calendarOverlay.xul)
|
||||
content/calendar/calendarSelection.js (content/calendarSelection.js)
|
||||
content/calendar/calendarWeekView.js (content/calendarWeekView.js)
|
||||
content/calendar/calendarWeekView.xul (content/calendarWeekView.xul)
|
||||
content/calendar/contents.rdf (content/contents.rdf)
|
||||
|
@ -410,7 +410,7 @@ button.calendar-management-button:hover:active
|
||||
border: 2px solid #1D7AB5;
|
||||
}
|
||||
/*the selected day box, since it's last, it has the highest priority*/
|
||||
.month-day-box-class[selected="true"]{
|
||||
.month-day-box-class[monthselected="true"]{
|
||||
background-color: #d5e3f2;
|
||||
}
|
||||
|
||||
@ -453,7 +453,7 @@ button.calendar-management-button:hover:active
|
||||
|
||||
}
|
||||
|
||||
.month-day-event-box-class[selected="true"]
|
||||
.month-day-event-box-class[eventselected="true"]
|
||||
{
|
||||
background-color: #D5E3F2;
|
||||
border-color: #003366;
|
||||
@ -515,7 +515,7 @@ button.calendar-management-button:hover:active
|
||||
list-style-image : url("chrome://calendar/skin/dot.png");
|
||||
}
|
||||
|
||||
.month-view-event-dot-class[selected="true"]
|
||||
.month-view-event-dot-class[eventselected="true"]
|
||||
{
|
||||
list-style-image : url("chrome://calendar/skin/dot_selected.png");
|
||||
}
|
||||
@ -693,7 +693,7 @@ button.calendar-management-button:hover:active
|
||||
background-color : #F9F4FF;
|
||||
}
|
||||
|
||||
.day-view-event-class[selected="true"]
|
||||
.day-view-event-class[eventselected="true"]
|
||||
{
|
||||
background-color : #d5e3f2;
|
||||
border-color : #003366
|
||||
@ -929,7 +929,7 @@ button.calendar-management-button:hover:active
|
||||
min-width : 20px;
|
||||
}
|
||||
|
||||
.week-view-event-class[selected="true"]
|
||||
.week-view-event-class[eventselected="true"]
|
||||
{
|
||||
background-color : #D5E3F2;
|
||||
border : 1px solid #003366;
|
||||
|
Loading…
Reference in New Issue
Block a user