-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSandcastle-header.js
82 lines (75 loc) · 2.96 KB
/
Sandcastle-header.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(function() {
"use strict";
var defaultAction;
var bucket = window.location.href;
var pos = bucket.lastIndexOf('/');
if (pos > 0 && pos < (bucket.length - 1)) {
bucket = bucket.substring(pos + 1);
}
window.Sandcastle = {
bucket : bucket,
declare : function() {
},
highlight : function() {
},
registered : [],
finishedLoading : function() {
window.Sandcastle.reset();
if(defaultAction) {
window.Sandcastle.highlight(defaultAction);
defaultAction();
defaultAction = undefined;
}
document.body.className = document.body.className.replace(/(?:\s|^)sandcastle-loading(?:\s|$)/, ' ');
},
addToolbarButton : function(text, onclick, toolbarID) {
window.Sandcastle.declare(onclick);
var button = document.createElement('button');
button.type = 'button';
button.className = 'cesium-button';
button.onclick = function() {
window.Sandcastle.reset();
window.Sandcastle.highlight(onclick);
onclick();
};
button.textContent = text;
document.getElementById(toolbarID || 'toolbar').appendChild(button);
},
addDefaultToolbarButton : function(text, onclick, toolbarID) {
window.Sandcastle.addToolbarButton(text, onclick, toolbarID);
defaultAction = onclick;
},
addDefaultToolbarMenu : function(options, toolbarID) {
window.Sandcastle.addToolbarMenu(options, toolbarID);
defaultAction = options[0].onselect;
},
addToolbarMenu : function(options, toolbarID) {
var menu = document.createElement('select');
menu.className = 'cesium-button';
menu.onchange = function() {
window.Sandcastle.reset();
var item = options[menu.selectedIndex];
if (item && typeof item.onselect === 'function') {
item.onselect();
}
};
document.getElementById(toolbarID || 'toolbar').appendChild(menu);
if (!defaultAction && typeof options[0].onselect === 'function') {
defaultAction = options[0].onselect;
}
for (var i = 0, len = options.length; i < len; ++i) {
var option = document.createElement('option');
option.textContent = options[i].text;
option.value = options[i].value;
menu.appendChild(option);
}
},
reset : function() {
}
};
if (window.location.protocol === 'file:') {
if (window.confirm("You must host this app on a web server.\nSee contributor's guide for more info?")) {
window.location = 'https://github.com/AnalyticalGraphicsInc/cesium/wiki/Contributor%27s-Guide';
}
}
}());