1 import org.codehaus.groovy.grails.plugins.PluginManagerHolder
4 * A taglib to ease the loading of Simile libraries
7 static namespace = 'simile'
10 out.println pluginJS(request?.contextPath, 'ajax/simile-ajax', attrs?.bundle);
13 def timeline = { attrs ->
14 out.println pluginJS(request?.contextPath, 'timeline/timeline', attrs?.bundle);
17 def timelineExt = { attrs ->
18 out.println pluginJS(request?.contextPath, "timeline/ext/${attrs?.name}/${attrs?.name}", attrs?.bundle);
21 def pluginJS(contextPath, lib, bundle) {
22 def p = PluginManagerHolder?.pluginManager.getGrailsPlugin('simile')
23 return "<script type='text/javascript' src='${contextPath}/plugins/${p.name}-${p.version}/js/${lib}-api.js?bundle=${bundle == 'true'}'></script>"
26 def renderTimeline = { attrs ->
28 def timeline = attrs.timeline
30 // figure out our unit type
31 def unitType = Timeline.TYPE_UNITS[timeline.type]
33 if (unitType) { eventSource = "new SimileAjax.EventIndex(${unitType})" }
36 switch (timeline.type) {
37 case Timeline.DEPTH_TYPE: unitObject = ".Depth"; break;
38 case Timeline.GEOCHRONO_TYPE: unitObject = ".Geochrono"; break;
46 var eventSource = new Timeline.DefaultEventSource(${eventSource});
48 var theme = Timeline.ClassicTheme.create();
49 theme.event.bubble.width = 320;
50 theme.event.bubble.height = 220;
52 Timeline${unitObject}.createBandInfo({
53 eventSource: eventSource,
55 intervalUnit: Timeline.${timeline.detailUnit},
56 intervalPixels: ${timeline.detailPixels}
58 Timeline${unitObject}.createBandInfo({
59 eventSource: eventSource,
61 intervalUnit: Timeline.${timeline.overviewUnit},
62 intervalPixels: ${timeline.overviewPixels},
64 convertToBaseUnit: true
67 bandInfos[1].syncWith = 0;
68 bandInfos[1].highlight = true;
70 tl = Timeline.create(document.getElementById("${attrs?.element}"), bandInfos, Timeline.HORIZONTAL${unitType == "" ? "" : ", " + unitType});
71 tl.loadXML("${request?.contextPath}/timeline/eventsXML/${timeline.id}", function(xml, url) {
72 eventSource.loadXML(xml, url);
75 var resizeTimerID = null;
77 if (resizeTimerID == null) {
78 resizeTimerID = window.setTimeout(function() {