Hi,

It sounds like you're using Exhibit 2? In which case I think you can actually just add your code to the collection's listener queue.

exhibit.getDefaultCollection().addListener({
    "onItemsChanged": function() {
       setTimelineCenterDate()
    }
});

You'll probably want to check if Timeline is currently the view on display before running code that refers to it.

The tricky part with Exhibit 2 is running that at the right time, after the default collection has been created, though if you've figured out a way to listen to facet clicks, perhaps you'll already have an idea of where to insert that into your flow.

On 2012-07-16 06:55 , kasaba wrote:
Hi, fellows

I wrote that code which set center of my timeline bands. If minDate is 1000
and max date is 2000 from filtered data, my logic set center date 1500.

First I added that code as onclick with timeout 2000ms on facet link, but
when some click are done quickly, timeline gets broken.
May be it's problem with the synchronization with the animation of
timeline.

So, do you know where I can invoke my function, so timeline to work properly

My code is:

function setTimelineCenterDate() {
     var arr = exhibit.getDefaultCollection().getRestrictedItems().toArray();
     var min;
     var max;
     if (arr.length > 0) {
         min = exhibit.getDatabase().getObject(arr[0], "creationDate");
         max = min;
         var id;
         var val;
         for ( var i = 1; i < arr.length; i++) {
             val = exhibit.getDatabase().getObject(arr[i], "creationDate");
             if (val < min) {
                 min = val;
             }
             if (val > max) {
                 max = val;
             }
         }
         var intMin = parseInt(min);
         var intMax = parseInt(max);
         var middle = intMin + (intMax - intMin) / 2;
         timelineCenterDate =
Timeline.DateTime.parseGregorianDateTime(middle);
     } else {
         timelineCenterDate = Timeline.DateTime
                 .parseGregorianDateTime(getCurrentDate());
     }
     if (nuxeoTimeline != undefined) {
         setTimelineBandsCenterDate(nuxeoTimeline, timelineCenterDate)
     }
}

function setTimelineBandsCenterDate(nuxeo_timline) {
     nuxeo_timline.getBand(0).setCenterVisibleDate(timelineCenterDate);
     nuxeo_timline.getBand(1).setCenterVisibleDate(timelineCenterDate);
}

Thanks in advance.



--
You received this message because you are subscribed to the Google Groups "SIMILE 
Widgets" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en.

Reply via email to