@@ -28,11 +28,11 @@ require({
28
28
location : '../Apps/Sandcastle/ThirdParty'
29
29
} ]
30
30
} , [
31
+ 'CodeMirror/lib/codemirror' ,
31
32
'dijit/Dialog' ,
32
33
'dijit/form/Button' ,
33
34
'dijit/form/Form' ,
34
35
'dijit/form/Textarea' ,
35
- 'CodeMirror/lib/codemirror' ,
36
36
'dijit/layout/ContentPane' ,
37
37
'dijit/popup' ,
38
38
'dijit/registry' ,
@@ -51,8 +51,6 @@ require({
51
51
'dojo/when' ,
52
52
'Sandcastle/LinkButton' ,
53
53
'Source/Cesium' ,
54
- 'Source/Core/defined' ,
55
- 'Source/Core/Resource' ,
56
54
'ThirdParty/clipboard.min' ,
57
55
'ThirdParty/pako.min' ,
58
56
'CodeMirror/addon/hint/show-hint' ,
@@ -75,11 +73,11 @@ require({
75
73
'dijit/ToolbarSeparator' ,
76
74
'dojo/domReady!'
77
75
] , function (
76
+ CodeMirror ,
78
77
Dialog ,
79
78
Button ,
80
79
Form ,
81
80
TextArea ,
82
- CodeMirror ,
83
81
ContentPane ,
84
82
popup ,
85
83
registry ,
@@ -98,16 +96,17 @@ require({
98
96
when ,
99
97
LinkButton ,
100
98
Cesium ,
101
- defined ,
102
- Resource ,
103
99
ClipboardJS ,
104
100
pako ) {
105
101
'use strict' ;
106
102
// attach clipboard handling to our Copy button
107
103
var clipboardjs = new ClipboardJS ( '.copyButton' ) ;
108
104
109
- //In order for CodeMirror auto-complete to work, Cesium needs to be defined as a global.
110
- if ( ! defined ( window . Cesium ) ) {
105
+ if ( typeof Cesium !== 'object' ) {
106
+ //For built sandcastle
107
+ Cesium = window . Cesium ;
108
+ } else if ( typeof window . Cesium === 'undefined' ) {
109
+ //In order for CodeMirror auto-complete to work, Cesium needs to be defined as a global.
111
110
window . Cesium = Cesium ;
112
111
}
113
112
@@ -229,7 +228,7 @@ require({
229
228
}
230
229
231
230
function openDocTab ( title , link ) {
232
- if ( ! defined ( docTabs [ title ] ) ) {
231
+ if ( ! Cesium . defined ( docTabs [ title ] ) ) {
233
232
docTabs [ title ] = new ContentPane ( {
234
233
title : title ,
235
234
focused : true ,
@@ -286,7 +285,7 @@ require({
286
285
287
286
function onCursorActivity ( ) {
288
287
docNode . style . left = '-999px' ;
289
- if ( defined ( docTimer ) ) {
288
+ if ( Cesium . defined ( docTimer ) ) {
290
289
window . clearTimeout ( docTimer ) ;
291
290
}
292
291
docTimer = window . setTimeout ( showDocPopup , 500 ) ;
@@ -296,21 +295,21 @@ require({
296
295
var element = document . createElement ( 'abbr' ) ;
297
296
element . className = className ;
298
297
switch ( className ) {
299
- case 'hintMarker' :
300
- element . innerHTML = '▲' ;
301
- break ;
302
- case 'errorMarker' :
303
- element . innerHTML = '×' ;
304
- break ;
305
- default :
306
- element . innerHTML = '▶' ;
298
+ case 'hintMarker' :
299
+ element . innerHTML = '▲' ;
300
+ break ;
301
+ case 'errorMarker' :
302
+ element . innerHTML = '×' ;
303
+ break ;
304
+ default :
305
+ element . innerHTML = '▶' ;
307
306
}
308
307
element . title = msg ;
309
308
return element ;
310
309
}
311
310
312
311
function closeGalleryTooltip ( ) {
313
- if ( defined ( activeGalleryTooltipDemo ) ) {
312
+ if ( Cesium . defined ( activeGalleryTooltipDemo ) ) {
314
313
popup . close ( demoTooltips [ activeGalleryTooltipDemo . name ] ) ;
315
314
activeGalleryTooltipDemo = undefined ;
316
315
}
@@ -327,7 +326,7 @@ require({
327
326
suffix = 'searchDemo' ;
328
327
}
329
328
330
- if ( defined ( activeGalleryTooltipDemo ) ) {
329
+ if ( Cesium . defined ( activeGalleryTooltipDemo ) ) {
331
330
popup . open ( {
332
331
popup : demoTooltips [ activeGalleryTooltipDemo . name ] ,
333
332
around : dom . byId ( activeGalleryTooltipDemo . name + suffix ) ,
@@ -339,7 +338,7 @@ require({
339
338
function scheduleGalleryTooltip ( demo ) {
340
339
if ( demo !== activeGalleryTooltipDemo ) {
341
340
activeGalleryTooltipDemo = demo ;
342
- if ( defined ( galleryTooltipTimer ) ) {
341
+ if ( Cesium . defined ( galleryTooltipTimer ) ) {
343
342
window . clearTimeout ( galleryTooltipTimer ) ;
344
343
}
345
344
galleryTooltipTimer = window . setTimeout ( openGalleryTooltip , 220 ) ;
@@ -387,7 +386,7 @@ require({
387
386
var hints = JSHINT . errors ;
388
387
for ( i = 0 , len = hints . length ; i < len ; ++ i ) {
389
388
var hint = hints [ i ] ;
390
- if ( hint !== null && defined ( hint . reason ) && hint . line > 0 ) {
389
+ if ( hint !== null && Cesium . defined ( hint . reason ) && hint . line > 0 ) {
391
390
line = jsEditor . setGutterMarker ( scriptLineToEditorLine ( hint . line ) , 'hintGutter' , makeLineLabel ( hint . reason , 'hintMarker' ) ) ;
392
391
jsEditor . addLineClass ( line , 'text' , 'hintLine' ) ;
393
392
errorLines . push ( line ) ;
@@ -398,22 +397,22 @@ require({
398
397
}
399
398
400
399
function scheduleHint ( ) {
401
- if ( defined ( hintTimer ) ) {
400
+ if ( Cesium . defined ( hintTimer ) ) {
402
401
window . clearTimeout ( hintTimer ) ;
403
402
}
404
403
hintTimer = setTimeout ( clearErrorsAddHints , 550 ) ;
405
404
highlightRun ( ) ;
406
405
}
407
406
408
407
function scheduleHintNoChange ( ) {
409
- if ( defined ( hintTimer ) ) {
408
+ if ( Cesium . defined ( hintTimer ) ) {
410
409
window . clearTimeout ( hintTimer ) ;
411
410
}
412
411
hintTimer = setTimeout ( clearErrorsAddHints , 550 ) ;
413
412
}
414
413
415
414
function scrollToLine ( lineNumber ) {
416
- if ( defined ( lineNumber ) ) {
415
+ if ( Cesium . defined ( lineNumber ) ) {
417
416
jsEditor . setCursor ( lineNumber ) ;
418
417
// set selection twice in order to force the editor to scroll
419
418
// to this location if the cursor is already there
@@ -472,13 +471,13 @@ require({
472
471
function registerScroll ( demoContainer ) {
473
472
if ( document . onmousewheel !== undefined ) {
474
473
demoContainer . addEventListener ( 'mousewheel' , function ( e ) {
475
- if ( defined ( e . wheelDelta ) && e . wheelDelta ) {
474
+ if ( Cesium . defined ( e . wheelDelta ) && e . wheelDelta ) {
476
475
demoContainer . scrollLeft -= e . wheelDelta * 70 / 120 ;
477
476
}
478
477
} , false ) ;
479
478
} else {
480
479
demoContainer . addEventListener ( 'DOMMouseScroll' , function ( e ) {
481
- if ( defined ( e . detail ) && e . detail ) {
480
+ if ( Cesium . defined ( e . detail ) && e . detail ) {
482
481
demoContainer . scrollLeft += e . detail * 70 / 3 ;
483
482
}
484
483
} , false ) ;
@@ -662,7 +661,7 @@ require({
662
661
function loadBucket ( bucketName ) {
663
662
if ( local . bucketName !== bucketName ) {
664
663
local . bucketName = bucketName ;
665
- if ( defined ( bucketTypes [ bucketName ] ) ) {
664
+ if ( Cesium . defined ( bucketTypes [ bucketName ] ) ) {
666
665
local . headers = bucketTypes [ bucketName ] ;
667
666
} else {
668
667
local . headers = '<html><head></head><body data-sandcastle-bucket-loaded="no">' ;
@@ -686,10 +685,10 @@ require({
686
685
if ( window . location . search ) {
687
686
queryObject = ioQuery . queryToObject ( window . location . search . substring ( 1 ) ) ;
688
687
}
689
- if ( ! defined ( queryObject . src ) ) {
688
+ if ( ! Cesium . defined ( queryObject . src ) ) {
690
689
queryObject . src = defaultDemo + '.html' ;
691
690
}
692
- if ( ! defined ( queryObject . label ) ) {
691
+ if ( ! Cesium . defined ( queryObject . label ) ) {
693
692
queryObject . label = defaultLabel ;
694
693
}
695
694
@@ -718,19 +717,19 @@ require({
718
717
}
719
718
720
719
var json , code , html ;
721
- if ( defined ( queryObject . gist ) ) {
722
- Resource . fetchJsonp ( 'https://api.github.com/gists/' + queryObject . gist + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60' )
720
+ if ( Cesium . defined ( queryObject . gist ) ) {
721
+ Cesium . Resource . fetchJsonp ( 'https://api.github.com/gists/' + queryObject . gist + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60' )
723
722
. then ( function ( data ) {
724
723
var files = data . data . files ;
725
724
var code = files [ 'Cesium-Sandcastle.js' ] . content ;
726
725
var htmlFile = files [ 'Cesium-Sandcastle.html' ] ;
727
- var html = defined ( htmlFile ) ? htmlFile . content : defaultHtml ; // Use the default html for old gists
726
+ var html = Cesium . defined ( htmlFile ) ? htmlFile . content : defaultHtml ; // Use the default html for old gists
728
727
applyLoadedDemo ( code , html ) ;
729
728
} ) . otherwise ( function ( error ) {
730
- appendConsole ( 'consoleError' , 'Unable to GET from GitHub API. This could be due to too many request, try again in an hour or copy and paste the code from the gist: https://gist.github.com/' + queryObject . gist , true ) ;
731
- console . log ( error ) ;
732
- } ) ;
733
- } else if ( defined ( queryObject . code ) ) {
729
+ appendConsole ( 'consoleError' , 'Unable to GET from GitHub API. This could be due to too many request, try again in an hour or copy and paste the code from the gist: https://gist.github.com/' + queryObject . gist , true ) ;
730
+ console . log ( error ) ;
731
+ } ) ;
732
+ } else if ( Cesium . defined ( queryObject . code ) ) {
734
733
//The code query parameter is a Base64 encoded JSON string with `code` and `html` properties.
735
734
json = JSON . parse ( window . atob ( queryObject . code ) ) ;
736
735
code = json . code ;
@@ -812,14 +811,14 @@ require({
812
811
appendConsole ( 'consoleLog' , 'Unable to load demo named ' + queryObject . src . replace ( '.html' , '' ) + '. Redirecting to HelloWorld.\n' , true ) ;
813
812
}
814
813
}
815
- } else if ( defined ( e . data . log ) ) {
814
+ } else if ( Cesium . defined ( e . data . log ) ) {
816
815
// Console log messages from the iframe display in Sandcastle.
817
816
appendConsole ( 'consoleLog' , e . data . log , false ) ;
818
- } else if ( defined ( e . data . error ) ) {
817
+ } else if ( Cesium . defined ( e . data . error ) ) {
819
818
// Console error messages from the iframe display in Sandcastle
820
819
var errorMsg = e . data . error ;
821
820
var lineNumber = e . data . lineNumber ;
822
- if ( defined ( lineNumber ) ) {
821
+ if ( Cesium . defined ( lineNumber ) ) {
823
822
errorMsg += ' (on line ' ;
824
823
825
824
if ( e . data . url ) {
@@ -834,10 +833,10 @@ require({
834
833
}
835
834
}
836
835
appendConsole ( 'consoleError' , errorMsg , true ) ;
837
- } else if ( defined ( e . data . warn ) ) {
836
+ } else if ( Cesium . defined ( e . data . warn ) ) {
838
837
// Console warning messages from the iframe display in Sandcastle.
839
838
appendConsole ( 'consoleWarn' , e . data . warn , true ) ;
840
- } else if ( defined ( e . data . highlight ) ) {
839
+ } else if ( Cesium . defined ( e . data . highlight ) ) {
841
840
// Hovering objects in the embedded Cesium window.
842
841
highlightLine ( e . data . highlight ) ;
843
842
}
@@ -1084,11 +1083,11 @@ require({
1084
1083
}
1085
1084
1086
1085
// Select the demo to load upon opening based on the query parameter.
1087
- if ( defined ( queryObject . src ) ) {
1086
+ if ( Cesium . defined ( queryObject . src ) ) {
1088
1087
if ( demo . name === queryObject . src . replace ( '.html' , '' ) ) {
1089
1088
loadFromGallery ( demo ) . then ( function ( ) {
1090
1089
window . history . replaceState ( demo , demo . name , getPushStateUrl ( demo ) ) ;
1091
- if ( defined ( queryObject . gist ) ) {
1090
+ if ( Cesium . defined ( queryObject . gist ) ) {
1092
1091
document . title = 'Gist Import - Cesium Sandcastle' ;
1093
1092
} else {
1094
1093
document . title = demo . name + ' - Cesium Sandcastle' ;
@@ -1111,7 +1110,7 @@ require({
1111
1110
1112
1111
var loading = true ;
1113
1112
function setSubtab ( tabName ) {
1114
- currentTab = defined ( tabName ) && ! loading ? tabName : queryObject . label ;
1113
+ currentTab = Cesium . defined ( tabName ) && ! loading ? tabName : queryObject . label ;
1115
1114
queryObject . label = tabName ;
1116
1115
loading = false ;
1117
1116
}
@@ -1163,7 +1162,7 @@ require({
1163
1162
1164
1163
function createGalleryButton ( demo , tabName ) {
1165
1164
var imgSrc = 'templates/Gallery_tile.jpg' ;
1166
- if ( defined ( demo . img ) ) {
1165
+ if ( Cesium . defined ( demo . img ) ) {
1167
1166
imgSrc = 'gallery/' + demo . img ;
1168
1167
}
1169
1168
@@ -1215,7 +1214,7 @@ require({
1215
1214
}
1216
1215
1217
1216
var promise ;
1218
- if ( ! defined ( gallery_demos ) ) {
1217
+ if ( ! Cesium . defined ( gallery_demos ) ) {
1219
1218
galleryErrorMsg . textContent = 'No demos found, please run the build script.' ;
1220
1219
galleryErrorMsg . style . display = 'inline-block' ;
1221
1220
} else {
0 commit comments