@@ -16,6 +16,10 @@ require({
16
16
} , {
17
17
name : 'Source' ,
18
18
location : '.'
19
+ } , {
20
+ name : 'CesiumUnminified' ,
21
+ location : '../Build/CesiumUnminified' ,
22
+ main : 'Cesium'
19
23
} , {
20
24
name : 'CodeMirror' ,
21
25
location : '../ThirdParty/codemirror-4.6'
@@ -43,6 +47,10 @@ require({
43
47
'dojo/query' ,
44
48
'dojo/when' ,
45
49
'Sandcastle/LinkButton' ,
50
+ 'Source/Core/defined' ,
51
+ 'Source/Core/getBaseUri' ,
52
+ 'Source/Core/loadJsonp' ,
53
+ 'Source/Core/loadWithXhr' ,
46
54
'Source/Cesium' ,
47
55
'CodeMirror/addon/hint/show-hint' ,
48
56
'CodeMirror/addon/hint/javascript-hint' ,
@@ -86,11 +94,18 @@ require({
86
94
query ,
87
95
when ,
88
96
LinkButton ,
89
- Cesium ) {
97
+ defined ,
98
+ getBaseUri ,
99
+ loadJsonp ,
100
+ loadWithXhr ,
101
+ Cesium
102
+ ) {
90
103
'use strict' ;
91
104
92
105
//In order for CodeMirror auto-complete to work, Cesium needs to be defined as a global.
93
- window . Cesium = Cesium ;
106
+ if ( ! defined ( window . Cesium ) ) {
107
+ window . Cesium = Cesium ;
108
+ }
94
109
95
110
parser . parse ( ) ;
96
111
@@ -214,7 +229,7 @@ require({
214
229
}
215
230
216
231
function openDocTab ( title , link ) {
217
- if ( ! Cesium . defined ( docTabs [ title ] ) ) {
232
+ if ( ! defined ( docTabs [ title ] ) ) {
218
233
docTabs [ title ] = new ContentPane ( {
219
234
title : title ,
220
235
focused : true ,
@@ -271,7 +286,7 @@ require({
271
286
272
287
function onCursorActivity ( ) {
273
288
docNode . style . left = '-999px' ;
274
- if ( Cesium . defined ( docTimer ) ) {
289
+ if ( defined ( docTimer ) ) {
275
290
window . clearTimeout ( docTimer ) ;
276
291
}
277
292
docTimer = window . setTimeout ( showDocPopup , 500 ) ;
@@ -295,7 +310,7 @@ require({
295
310
}
296
311
297
312
function closeGalleryTooltip ( ) {
298
- if ( Cesium . defined ( activeGalleryTooltipDemo ) ) {
313
+ if ( defined ( activeGalleryTooltipDemo ) ) {
299
314
popup . close ( demoTooltips [ activeGalleryTooltipDemo . name ] ) ;
300
315
activeGalleryTooltipDemo = undefined ;
301
316
}
@@ -312,7 +327,7 @@ require({
312
327
suffix = 'searchDemo' ;
313
328
}
314
329
315
- if ( Cesium . defined ( activeGalleryTooltipDemo ) ) {
330
+ if ( defined ( activeGalleryTooltipDemo ) ) {
316
331
popup . open ( {
317
332
popup : demoTooltips [ activeGalleryTooltipDemo . name ] ,
318
333
around : dom . byId ( activeGalleryTooltipDemo . name + suffix ) ,
@@ -324,7 +339,7 @@ require({
324
339
function scheduleGalleryTooltip ( demo ) {
325
340
if ( demo !== activeGalleryTooltipDemo ) {
326
341
activeGalleryTooltipDemo = demo ;
327
- if ( Cesium . defined ( galleryTooltipTimer ) ) {
342
+ if ( defined ( galleryTooltipTimer ) ) {
328
343
window . clearTimeout ( galleryTooltipTimer ) ;
329
344
}
330
345
galleryTooltipTimer = window . setTimeout ( openGalleryTooltip , 220 ) ;
@@ -372,7 +387,7 @@ require({
372
387
var hints = JSHINT . errors ;
373
388
for ( i = 0 , len = hints . length ; i < len ; ++ i ) {
374
389
var hint = hints [ i ] ;
375
- if ( hint !== null && Cesium . defined ( hint . reason ) && hint . line > 0 ) {
390
+ if ( hint !== null && defined ( hint . reason ) && hint . line > 0 ) {
376
391
line = jsEditor . setGutterMarker ( scriptLineToEditorLine ( hint . line ) , 'hintGutter' , makeLineLabel ( hint . reason , 'hintMarker' ) ) ;
377
392
jsEditor . addLineClass ( line , 'text' , 'hintLine' ) ;
378
393
errorLines . push ( line ) ;
@@ -383,22 +398,22 @@ require({
383
398
}
384
399
385
400
function scheduleHint ( ) {
386
- if ( Cesium . defined ( hintTimer ) ) {
401
+ if ( defined ( hintTimer ) ) {
387
402
window . clearTimeout ( hintTimer ) ;
388
403
}
389
404
hintTimer = setTimeout ( clearErrorsAddHints , 550 ) ;
390
405
highlightRun ( ) ;
391
406
}
392
407
393
408
function scheduleHintNoChange ( ) {
394
- if ( Cesium . defined ( hintTimer ) ) {
409
+ if ( defined ( hintTimer ) ) {
395
410
window . clearTimeout ( hintTimer ) ;
396
411
}
397
412
hintTimer = setTimeout ( clearErrorsAddHints , 550 ) ;
398
413
}
399
414
400
415
function scrollToLine ( lineNumber ) {
401
- if ( Cesium . defined ( lineNumber ) ) {
416
+ if ( defined ( lineNumber ) ) {
402
417
jsEditor . setCursor ( lineNumber ) ;
403
418
// set selection twice in order to force the editor to scroll
404
419
// to this location if the cursor is already there
@@ -457,13 +472,13 @@ require({
457
472
function registerScroll ( demoContainer ) {
458
473
if ( document . onmousewheel !== undefined ) {
459
474
demoContainer . addEventListener ( 'mousewheel' , function ( e ) {
460
- if ( Cesium . defined ( e . wheelDelta ) && e . wheelDelta ) {
475
+ if ( defined ( e . wheelDelta ) && e . wheelDelta ) {
461
476
demoContainer . scrollLeft -= e . wheelDelta * 70 / 120 ;
462
477
}
463
478
} , false ) ;
464
479
} else {
465
480
demoContainer . addEventListener ( 'DOMMouseScroll' , function ( e ) {
466
- if ( Cesium . defined ( e . detail ) && e . detail ) {
481
+ if ( defined ( e . detail ) && e . detail ) {
467
482
demoContainer . scrollLeft += e . detail * 70 / 3 ;
468
483
}
469
484
} , false ) ;
@@ -662,7 +677,7 @@ require({
662
677
function loadBucket ( bucketName ) {
663
678
if ( local . bucketName !== bucketName ) {
664
679
local . bucketName = bucketName ;
665
- if ( Cesium . defined ( bucketTypes [ bucketName ] ) ) {
680
+ if ( defined ( bucketTypes [ bucketName ] ) ) {
666
681
local . headers = bucketTypes [ bucketName ] ;
667
682
} else {
668
683
local . headers = '<html><head></head><body data-sandcastle-bucket-loaded="no">' ;
@@ -686,13 +701,13 @@ require({
686
701
var gistId = ioQuery . queryToObject ( window . location . search . substring ( 1 ) ) . gist ;
687
702
if ( window . location . search ) {
688
703
queryObject = ioQuery . queryToObject ( window . location . search . substring ( 1 ) ) ;
689
- if ( Cesium . defined ( gistId ) ) {
704
+ if ( defined ( gistId ) ) {
690
705
queryObject . gistId = gistId ;
691
706
}
692
707
} else {
693
708
queryObject . src = 'Hello World.html' ;
694
709
queryObject . label = 'Showcases' ;
695
- if ( Cesium . defined ( gistId ) ) {
710
+ if ( defined ( gistId ) ) {
696
711
queryObject . gistId = gistId ;
697
712
}
698
713
}
@@ -731,13 +746,13 @@ require({
731
746
var scriptCode = scriptMatch [ 1 ] ;
732
747
demoCode = scriptCode . replace ( / \s / g, '' ) ;
733
748
734
- if ( Cesium . defined ( queryObject . gistId ) ) {
735
- Cesium . loadJsonp ( 'https://api.github.com/gists/' + queryObject . gistId + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60' )
749
+ if ( defined ( queryObject . gistId ) ) {
750
+ loadJsonp ( 'https://api.github.com/gists/' + queryObject . gistId + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60' )
736
751
. then ( function ( data ) {
737
752
var files = data . data . files ;
738
753
var code = files [ 'Cesium-Sandcastle.js' ] . content ;
739
754
var htmlFile = files [ 'Cesium-Sandcastle.html' ] ;
740
- var html = Cesium . defined ( htmlFile ) ? htmlFile . content : defaultHtml ; // Use the default html for old gists
755
+ var html = defined ( htmlFile ) ? htmlFile . content : defaultHtml ; // Use the default html for old gists
741
756
jsEditor . setValue ( code ) ;
742
757
htmlEditor . setValue ( html ) ;
743
758
demoCode = code . replace ( / \s / g, '' ) ;
@@ -746,7 +761,7 @@ require({
746
761
gistHtml = html ;
747
762
previousCode = code ;
748
763
previousHtml = html ;
749
- sandcastleUrl = Cesium . getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId ;
764
+ sandcastleUrl = getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId ;
750
765
CodeMirror . commands . runCesium ( jsEditor ) ;
751
766
clearRun ( ) ;
752
767
} ) . otherwise ( function ( error ) {
@@ -813,14 +828,14 @@ require({
813
828
appendConsole ( 'consoleLog' , 'Unable to load demo named ' + queryObject . src . replace ( '.html' , '' ) + '. Redirecting to HelloWorld.\n' , true ) ;
814
829
}
815
830
}
816
- } else if ( Cesium . defined ( e . data . log ) ) {
831
+ } else if ( defined ( e . data . log ) ) {
817
832
// Console log messages from the iframe display in Sandcastle.
818
833
appendConsole ( 'consoleLog' , e . data . log , false ) ;
819
- } else if ( Cesium . defined ( e . data . error ) ) {
834
+ } else if ( defined ( e . data . error ) ) {
820
835
// Console error messages from the iframe display in Sandcastle
821
836
var errorMsg = e . data . error ;
822
837
var lineNumber = e . data . lineNumber ;
823
- if ( Cesium . defined ( lineNumber ) ) {
838
+ if ( defined ( lineNumber ) ) {
824
839
errorMsg += ' (on line ' ;
825
840
826
841
if ( e . data . url ) {
@@ -835,10 +850,10 @@ require({
835
850
}
836
851
}
837
852
appendConsole ( 'consoleError' , errorMsg , true ) ;
838
- } else if ( Cesium . defined ( e . data . warn ) ) {
853
+ } else if ( defined ( e . data . warn ) ) {
839
854
// Console warning messages from the iframe display in Sandcastle.
840
855
appendConsole ( 'consoleWarn' , e . data . warn , true ) ;
841
- } else if ( Cesium . defined ( e . data . highlight ) ) {
856
+ } else if ( defined ( e . data . highlight ) ) {
842
857
// Hovering objects in the embedded Cesium window.
843
858
highlightLine ( e . data . highlight ) ;
844
859
}
@@ -925,12 +940,12 @@ require({
925
940
}
926
941
}
927
942
} ;
928
- return Cesium . loadWithXhr ( {
943
+ return loadWithXhr ( {
929
944
url : 'https://api.github.com/gists' ,
930
945
data : JSON . stringify ( data ) ,
931
946
method : 'POST'
932
947
} ) . then ( function ( content ) {
933
- sandcastleUrl = Cesium . getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + JSON . parse ( content ) . id ;
948
+ sandcastleUrl = getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + JSON . parse ( content ) . id ;
934
949
textArea . value = sandcastleUrl ;
935
950
textArea . select ( ) ;
936
951
} ) . otherwise ( function ( error ) {
@@ -946,7 +961,7 @@ require({
946
961
if ( gistIndex !== - 1 ) {
947
962
gistId = gistId . substring ( gistIndex + gistParameter . length ) ;
948
963
}
949
- window . location . href = Cesium . getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId ;
964
+ window . location . href = getBaseUri ( window . location . href ) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId ;
950
965
} ) ;
951
966
952
967
registry . byId ( 'buttonNew' ) . on ( 'click' , function ( ) {
@@ -1093,15 +1108,15 @@ require({
1093
1108
demo . label = labels ? labels : '' ;
1094
1109
1095
1110
// Select the demo to load upon opening based on the query parameter.
1096
- if ( Cesium . defined ( queryObject . src ) ) {
1111
+ if ( defined ( queryObject . src ) ) {
1097
1112
var gistDemo = {
1098
1113
name : 'Gist Import' ,
1099
1114
code : demo . code ,
1100
1115
description : 'Code imported from GitHub Gist'
1101
1116
} ;
1102
1117
if ( demo . name === queryObject . src . replace ( '.html' , '' ) ) {
1103
1118
loadFromGallery ( demo ) . then ( function ( ) {
1104
- if ( Cesium . defined ( queryObject . gistId ) ) {
1119
+ if ( defined ( queryObject . gistId ) ) {
1105
1120
window . history . replaceState ( gistDemo , gistDemo . name , '?src=Hello World.html&label=' + queryObject . label + '&gist=' + queryObject . gistId ) ;
1106
1121
document . title = 'Gist Import - Cesium Sandcastle' ;
1107
1122
} else {
@@ -1126,7 +1141,7 @@ require({
1126
1141
1127
1142
var loading = true ;
1128
1143
function setSubtab ( tabName ) {
1129
- currentTab = Cesium . defined ( tabName ) && ! loading ? tabName : queryObject . label ;
1144
+ currentTab = defined ( tabName ) && ! loading ? tabName : queryObject . label ;
1130
1145
queryObject . label = tabName ;
1131
1146
loading = false ;
1132
1147
}
@@ -1178,7 +1193,7 @@ require({
1178
1193
1179
1194
function createGalleryButton ( demo , tabName ) {
1180
1195
var imgSrc = 'templates/Gallery_tile.jpg' ;
1181
- if ( Cesium . defined ( demo . img ) ) {
1196
+ if ( defined ( demo . img ) ) {
1182
1197
imgSrc = 'gallery/' + demo . img ;
1183
1198
}
1184
1199
@@ -1231,7 +1246,7 @@ require({
1231
1246
}
1232
1247
1233
1248
var promise ;
1234
- if ( ! Cesium . defined ( gallery_demos ) ) {
1249
+ if ( ! defined ( gallery_demos ) ) {
1235
1250
galleryErrorMsg . textContent = 'No demos found, please run the build script.' ;
1236
1251
galleryErrorMsg . style . display = 'inline-block' ;
1237
1252
} else {
0 commit comments