general question on Exhibit view functions

27 views
Skip to first unread message

John Callahan

unread,
Apr 13, 2009, 1:30:38 AM4/13/09
to simile-...@googlegroups.com
This is related to a previous question I posted about adding a class to
selected events albeit with more specific questions...


1) Both the Timeline and Map views have initialization function
parameters, namely timelineConfig and mapConstructor, respectively.
These functions seem to run only once when the view is being initialized
and NOT run when filters/facets are applied. Is that true? and... Do
other Exhibit views (Thumbnail, Tile, Timeplot...) have similar functions?


2) The Map view has a reconstructor function
(Exhibit.MapView.prototype._reconstruct) that runs with every
filter/facet selection. Do other Exhibit views (Thumbnail, Tile,
Timeplot...) have similar functions? If so, could I define a custom
function and make a call to that function within the reconstructors?


3) Is there a core function run for every filter/facet selection? If
so, could I add in there a call to a custom function I write? (This
could be treated as a standard callback function for selection.)


Thanks!

- John

**************************************************
John Callahan
Geospatial Application Developer
Delaware Geological Survey, University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584
Email: john.c...@udel.edu
http://www.dgs.udel.edu
**************************************************


David Huynh

unread,
Apr 14, 2009, 1:04:57 AM4/14/09
to simile-...@googlegroups.com
John Callahan wrote:
> This is related to a previous question I posted about adding a class to
> selected events albeit with more specific questions...
>
>
> 1) Both the Timeline and Map views have initialization function
> parameters, namely timelineConfig and mapConstructor, respectively.
> These functions seem to run only once when the view is being initialized
> and NOT run when filters/facets are applied. Is that true? and... Do
> other Exhibit views (Thumbnail, Tile, Timeplot...) have similar functions?
>
Only the more complicated views like timeline, map, and timeplot have
those *constructor functions. The simpler views don't because there's no
external widget to construct.

> 2) The Map view has a reconstructor function
> (Exhibit.MapView.prototype._reconstruct) that runs with every
> filter/facet selection. Do other Exhibit views (Thumbnail, Tile,
> Timeplot...) have similar functions? If so, could I define a custom
> function and make a call to that function within the reconstructors?
>

With Javascript, you can override pretty much anything. What matters is
how much code you need to add. For a well-written view, its code is
broken down into many little functions and you can override just a few
to get what you want. If instead the view has only a few large
functions, then you'd need to duplicate a lot more code to introduce
just a few minor changes. I know this isn't ideal, but just take a look
at the Javascript code of the view you want to tweak. Whatever code you
add after including Exhibit's code will override Exhibit's code. So, if
say you want to override this function in the tabular view

Exhibit.TabularView.prototype._createSortFunction

you just need to add

<script>
Exhibit.TabularView.prototype._createSortFunction =
function(items, expression, ascending) {
// your own implementation here
};
</script>

after including exhibit-api.js.

> 3) Is there a core function run for every filter/facet selection? If
> so, could I add in there a call to a custom function I write? (This
> could be treated as a standard callback function for selection.)
>

You'd either add a listener to the default collection:

exhibit.getDefaultCollection().addListener({
onItemsChanged: function() {
// do something
}
});

or you can catch those events by overriding the facet implementation.
For example, the list facet is implemented here


http://api.simile-widgets.org/exhibit/2.2.0/scripts/ui/facets/list-facet.js

and you will need to override this function

Exhibit.ListFacet.prototype.applyRestrictions

David

Reply all
Reply to author
Forward
0 new messages