Mercurial > hg > extraction-interface
comparison geotemco/js/Build/Loader/TimeplotLoader.js @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b12c99b7c3f0 |
---|---|
1 /* | |
2 * TimeplotLoader.js | |
3 * | |
4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 3 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
19 * MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
23 * Timeplot Script Loader | |
24 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de) | |
25 * @release 1.0 | |
26 * @release date: 2012-07-27 | |
27 * @version date: 2012-07-27 | |
28 */ | |
29 TimeplotLoader = { | |
30 | |
31 load : function(urlPrefix, callback) { | |
32 | |
33 JQuery_urlPrefix = urlPrefix + 'jquery/'; | |
34 SimileAjax_urlPrefix = urlPrefix + 'simile/ajax/'; | |
35 Timeline_urlPrefix = urlPrefix + 'simile/timeline/'; | |
36 Timeplot_urlPrefix = urlPrefix + 'simile/timeplot/'; | |
37 TimeplotLoader.callback = callback; | |
38 TimeplotLoader.loadSimileAjax(); | |
39 | |
40 }, | |
41 | |
42 loadSimileAjax : function() { | |
43 | |
44 if ( typeof window.SimileAjax == "undefined") { | |
45 window.SimileAjax = { | |
46 loadingScriptsCount : 0, | |
47 error : null, | |
48 params : { | |
49 bundle : "true" | |
50 } | |
51 }; | |
52 SimileAjax.Platform = new Object(); | |
53 SimileAjax.includeCssFile = function(doc, url) { | |
54 var link = doc.createElement("link"); | |
55 link.setAttribute("rel", "stylesheet"); | |
56 link.setAttribute("type", "text/css"); | |
57 link.setAttribute("href", url); | |
58 doc.getElementsByTagName("head")[0].appendChild(link); | |
59 }; | |
60 SimileAjax.urlPrefix = SimileAjax_urlPrefix; | |
61 var jsFiles = [{ | |
62 url : SimileAjax.urlPrefix + "simile-ajax-bundle.js", | |
63 test : "SimileAjax.XmlHttp._forceXML" | |
64 }]; | |
65 (new DynaJsLoader()).loadScripts(jsFiles, TimeplotLoader.loadTimeline); | |
66 SimileAjax.includeCssFile(document, SimileAjax.urlPrefix + "styles/" + "graphics.css"); | |
67 } else { | |
68 TimeplotLoader.loadTimeline(); | |
69 } | |
70 | |
71 }, | |
72 | |
73 loadTimeline : function() { | |
74 | |
75 SimileAjax.History.enabled = false; | |
76 | |
77 if ( typeof window.Timeline == "undefined") { | |
78 window.Timeline = new Object(); | |
79 Timeline.urlPrefix = Timeline_urlPrefix; | |
80 window.Timeline.DateTime = window.SimileAjax.DateTime; | |
81 // for backward compatibility | |
82 var jsFiles = [{ | |
83 url : Timeline.urlPrefix + "timeline-bundle.js", | |
84 test : "Timeline.NativeDateUnit.change" | |
85 }, { | |
86 url : Timeline.urlPrefix + "scripts/l10n/en/" + "timeline.js" | |
87 }, { | |
88 url : Timeline.urlPrefix + "scripts/l10n/en/" + "labellers.js" | |
89 }]; | |
90 (new DynaJsLoader()).loadScripts(jsFiles, TimeplotLoader.loadTimeplot); | |
91 SimileAjax.includeCssFile(document, Timeline.urlPrefix + "timeline-bundle.css"); | |
92 } else { | |
93 TimeplotLoader.loadTimeplot(); | |
94 } | |
95 | |
96 }, | |
97 | |
98 loadTimeplot : function() { | |
99 | |
100 if ( typeof window.Timeplot == "undefined") { | |
101 window.Timeplot = { | |
102 params : { | |
103 bundle : true, | |
104 autoCreate : true | |
105 }, | |
106 namespace : "http://simile.mit.edu/2007/06/timeplot#", | |
107 importers : {} | |
108 }; | |
109 Timeplot.urlPrefix = Timeplot_urlPrefix; | |
110 var jsFiles = []; | |
111 var canvas = document.createElement("canvas"); | |
112 if (!canvas.getContext) { | |
113 jsFiles.push({ | |
114 url : Timeplot.urlPrefix + "lib/excanvas.js", | |
115 test : canvas.getContext | |
116 }); | |
117 } | |
118 jsFiles.push({ | |
119 url : Timeplot.urlPrefix + "timeplot-bundle.js", | |
120 test : "Timeplot.Processor.prototype.removeListener" | |
121 }); | |
122 (new DynaJsLoader()).loadScripts(jsFiles, TimeplotLoader.callback); | |
123 SimileAjax.includeCssFile(document, Timeplot.urlPrefix + "timeplot-bundle.css"); | |
124 } else if (callback) { | |
125 callback(); | |
126 } | |
127 | |
128 } | |
129 }; |