mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-05 15:59:45 +00:00
Fixing bug 167166, problem with selection after adding event.
This commit is contained in:
parent
2cdbfcf83a
commit
ebc6f0f413
@ -54,49 +54,7 @@ function calendarUnifinderInit( )
|
|||||||
{
|
{
|
||||||
onSelectionChanged : function( EventSelectionArray )
|
onSelectionChanged : function( EventSelectionArray )
|
||||||
{
|
{
|
||||||
//dump( "\nCALENDAR unifinder.js->on selection changed" );
|
selectSelectedEventsInTree( EventSelectionArray );
|
||||||
var SearchTree = document.getElementById( UnifinderTreeName );
|
|
||||||
|
|
||||||
/* The following is a brutal hack, caused by
|
|
||||||
http://lxr.mozilla.org/mozilla1.0/source/layout/xul/base/src/tree/src/nsTreeSelection.cpp#555
|
|
||||||
and described in bug 168211
|
|
||||||
http://bugzilla.mozilla.org/show_bug.cgi?id=168211
|
|
||||||
Do NOT remove anything in the next 3 lines, or the selection in the tree will not work.
|
|
||||||
*/
|
|
||||||
|
|
||||||
SearchTree.treeBoxObject.selection.selectEventsSuppressed = true;
|
|
||||||
SearchTree.onselect = null;
|
|
||||||
SearchTree.removeEventListener( "select", unifinderOnSelect, true );
|
|
||||||
|
|
||||||
if( EventSelectionArray.length > 1 )
|
|
||||||
{
|
|
||||||
/* selecting all events is taken care of in the selectAllEvents in calendar.js
|
|
||||||
** Other than that, there's no other way to get in here. */
|
|
||||||
if( gSelectAll === true )
|
|
||||||
{
|
|
||||||
SearchTree.treeBoxObject.selection.selectAll( );
|
|
||||||
|
|
||||||
gSelectAll = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( EventSelectionArray.length == 1 )
|
|
||||||
{
|
|
||||||
var RowToScrollTo = SearchTree.eventView.getRowOfCalendarEvent( EventSelectionArray[0] );
|
|
||||||
|
|
||||||
if( RowToScrollTo != "null" )
|
|
||||||
{
|
|
||||||
SearchTree.treeBoxObject.selection.clearSelection( );
|
|
||||||
|
|
||||||
SearchTree.treeBoxObject.ensureRowIsVisible( RowToScrollTo );
|
|
||||||
|
|
||||||
SearchTree.treeBoxObject.selection.timedSelect( RowToScrollTo, 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SearchTree.treeBoxObject.selection.clearSelection( );
|
|
||||||
|
|
||||||
/* This needs to be in a setTimeout */
|
|
||||||
setTimeout( "resetAllowSelection()", 1 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +74,57 @@ function resetAllowSelection()
|
|||||||
SearchTree.addEventListener( "select", unifinderOnSelect, true );
|
SearchTree.addEventListener( "select", unifinderOnSelect, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function selectSelectedEventsInTree( EventsToSelect )
|
||||||
|
{
|
||||||
|
if( EventsToSelect === false )
|
||||||
|
EventsToSelect = gCalendarWindow.EventSelection.selectedEvents;
|
||||||
|
|
||||||
|
//dump( "\nCALENDAR unifinder.js->on selection changed" );
|
||||||
|
var SearchTree = document.getElementById( UnifinderTreeName );
|
||||||
|
|
||||||
|
/* The following is a brutal hack, caused by
|
||||||
|
http://lxr.mozilla.org/mozilla1.0/source/layout/xul/base/src/tree/src/nsTreeSelection.cpp#555
|
||||||
|
and described in bug 168211
|
||||||
|
http://bugzilla.mozilla.org/show_bug.cgi?id=168211
|
||||||
|
Do NOT remove anything in the next 3 lines, or the selection in the tree will not work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SearchTree.treeBoxObject.selection.selectEventsSuppressed = true;
|
||||||
|
SearchTree.onselect = null;
|
||||||
|
SearchTree.removeEventListener( "select", unifinderOnSelect, true );
|
||||||
|
|
||||||
|
if( EventsToSelect.length > 1 )
|
||||||
|
{
|
||||||
|
/* selecting all events is taken care of in the selectAllEvents in calendar.js
|
||||||
|
** Other than that, there's no other way to get in here. */
|
||||||
|
if( gSelectAll === true )
|
||||||
|
{
|
||||||
|
SearchTree.treeBoxObject.selection.selectAll( );
|
||||||
|
|
||||||
|
gSelectAll = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( EventsToSelect.length == 1 )
|
||||||
|
{
|
||||||
|
var RowToScrollTo = SearchTree.eventView.getRowOfCalendarEvent( EventsToSelect[0] );
|
||||||
|
|
||||||
|
if( RowToScrollTo != "null" )
|
||||||
|
{
|
||||||
|
SearchTree.treeBoxObject.selection.clearSelection( );
|
||||||
|
|
||||||
|
SearchTree.treeBoxObject.ensureRowIsVisible( RowToScrollTo );
|
||||||
|
|
||||||
|
SearchTree.treeBoxObject.selection.timedSelect( RowToScrollTo, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SearchTree.treeBoxObject.selection.clearSelection( );
|
||||||
|
|
||||||
|
/* This needs to be in a setTimeout */
|
||||||
|
setTimeout( "resetAllowSelection()", 1 );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observer for the calendar event data source. This keeps the unifinder
|
* Observer for the calendar event data source. This keeps the unifinder
|
||||||
* display up to date when the calendar event data is changed
|
* display up to date when the calendar event data is changed
|
||||||
@ -719,6 +728,9 @@ function refreshEventTree( eventArray )
|
|||||||
document.getElementById(UnifinderTreeName).view = new treeView( eventArray );
|
document.getElementById(UnifinderTreeName).view = new treeView( eventArray );
|
||||||
|
|
||||||
document.getElementById( UnifinderTreeName ).eventView = new calendarEventView( eventArray );
|
document.getElementById( UnifinderTreeName ).eventView = new calendarEventView( eventArray );
|
||||||
|
|
||||||
|
//select selected events in the tree.
|
||||||
|
selectSelectedEventsInTree( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusFirstItemIfNoSelection()
|
function focusFirstItemIfNoSelection()
|
||||||
|
Loading…
Reference in New Issue
Block a user