Skip to content

Commit b7fb1ab

Browse files
committed
Strip out unnecessary languages at compile time, improve JS / loading
1 parent f338a74 commit b7fb1ab

19 files changed

+697
-423
lines changed

_app/main.js

+3-39
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ App.Views = {};
348348
// create the TOC
349349
this.scrollContent = document.getElementsByTagName('body')[0];
350350

351-
this.toggleCommonLangBlocks();
352351

353352
// add toggles to code blocks if necessary
354353
if (this.platform === "ios" || this.platform === "osx" || this.platform === "macos") {
@@ -376,7 +375,7 @@ App.Views = {};
376375
// calculate final position of headers for the TOC once
377376
// the DOM is loaded (including images)
378377
$(window).on('load', function() {
379-
this.toc.updateHeights();
378+
this.toc && this.toc.updateHeights();
380379
}.bind(this));
381380

382381
$(function() {
@@ -406,41 +405,6 @@ App.Views = {};
406405
this.mobileToc.getElementsByTagName('option')[0].setAttribute('selected', true);
407406
},
408407

409-
// in "common" sections, there's a code block for every platform,
410-
// this hides all but the current one
411-
toggleCommonLangBlocks: function() {
412-
$('.common-lang-block').hide();
413-
switch (this.platform) {
414-
case 'ios':
415-
case 'osx':
416-
case 'macos':
417-
$('.common-lang-block.objectivec').show();
418-
$('.common-lang-block.swift').show();
419-
break;
420-
case 'android':
421-
$('.common-lang-block.java').show();
422-
break;
423-
case 'dotnet':
424-
case 'unity':
425-
$('.common-lang-block.cs').show();
426-
break;
427-
case 'php':
428-
$('.common-lang-block.php').show();
429-
break;
430-
case 'rest':
431-
$('.common-lang-block.bash').show();
432-
$('.common-lang-block.python').show();
433-
break;
434-
case 'arduino':
435-
$('.common-lang-block.cpp').show();
436-
break;
437-
case 'cloudcode':
438-
case 'js':
439-
default:
440-
$('.common-lang-block.js').show();
441-
}
442-
},
443-
444408
setupServerFieldCustomization: function setupServerFieldCustomization() {
445409

446410
if(!document.getElementById('parse-server-custom-url')) {
@@ -592,15 +556,15 @@ App.Views = {};
592556
// we recalculate the header heights for the TOC
593557
// highlighting when the height of the content changes
594558
handleToggleChange: function() {
595-
this.toc.updateHeights();
559+
this.toc && this.toc.updateHeights();
596560
},
597561

598562
handleSelectChange: function(e) {
599563
location.href = this.mobileToc.selectedOptions[0].getAttribute('data-anchor');
600564
},
601565

602566
handleWindowResize: function(e) {
603-
this.toc.updateHeights();
567+
this.toc && this.toc.updateHeights();
604568
}
605569
};
606570

0 commit comments

Comments
 (0)