Mercurial > hg > extraction-interface
comparison geotemco/js/Overlayloader/OverlayloaderGui.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 * OverlayloaderGui.js | |
3 * | |
4 * Copyright (c) 2013, Sebastian Kruse. 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 * @class OverlayloaderGui | |
24 * Overlayloader GUI Implementation | |
25 * @author Sebastian Kruse (skruse@mpiwg-berlin.mpg.de) | |
26 * | |
27 * @param {OverlayloaderWidget} parent Overlayloader widget object | |
28 * @param {HTML object} div parent div to append the Overlayloader gui | |
29 * @param {JSON} options Overlayloader configuration | |
30 */ | |
31 function OverlayloaderGui(overlayloader, div, options) { | |
32 | |
33 this.parent = overlayloader; | |
34 var overlayloaderGui = this; | |
35 | |
36 this.overlayloaderContainer = div; | |
37 this.overlayloaderContainer.style.position = 'relative'; | |
38 | |
39 this.loaderTypeSelect = document.createElement("select"); | |
40 div.appendChild(this.loaderTypeSelect); | |
41 | |
42 this.loaders = document.createElement("div"); | |
43 div.appendChild(this.loaders); | |
44 | |
45 this.overlayList = document.createElement("div"); | |
46 div.appendChild(this.overlayList); | |
47 | |
48 $(this.loaderTypeSelect).change(function(){ | |
49 var activeLoader = $(this).val(); | |
50 $(overlayloaderGui.loaders).find("div").each(function(){ | |
51 if ($(this).attr("id") == activeLoader) | |
52 $(this).show(); | |
53 else | |
54 $(this).hide(); | |
55 }); | |
56 }); | |
57 | |
58 this.refreshOverlayList = function(){ | |
59 var overlayloaderGui = this; | |
60 | |
61 $(overlayloaderGui.overlayList).empty(); | |
62 $(this.parent.overlayLoader.overlays).each(function(){ | |
63 var overlay = this; | |
64 $(overlayloaderGui.overlayList).append(overlay.name); | |
65 var link = document.createElement("a"); | |
66 $(link).text("(x)"); | |
67 link.href=""; | |
68 | |
69 $(link).click($.proxy(function(){ | |
70 $(overlay.layers).each(function(){ | |
71 this.map.removeLayer(this.layer); | |
72 }); | |
73 | |
74 var overlays = overlayloaderGui.parent.overlayLoader.overlays; | |
75 | |
76 overlays = $.grep(overlays, function(value) { | |
77 return overlay != value; | |
78 }); | |
79 | |
80 overlayloaderGui.parent.overlayLoader.overlays = overlays; | |
81 | |
82 overlayloaderGui.refreshOverlayList(); | |
83 | |
84 return(false); | |
85 },{overlay:overlay,overlayloaderGui:overlayloaderGui})); | |
86 $(overlayloaderGui.overlayList).append(link); | |
87 }); | |
88 }; | |
89 }; |