@@ -2,10 +2,6 @@ $(function(){
2
2
3
3
buildToc ( ) ;
4
4
5
- // SnapSVG
6
- // Run once at startup to inject all SVGs
7
- loadAllSvg ( ) ;
8
-
9
5
function buildToc ( ) {
10
6
var headings = $ ( "h3" ) ,
11
7
toc = $ ( "#toc-list" ) ;
@@ -35,85 +31,8 @@ $(function(){
35
31
// $(headings[h].parentElement).prepend(hiddenTitle);
36
32
37
33
headings [ h ] . parentElement . setAttribute ( "id" , headingSep ) ;
38
-
39
- $ ( '.curriculum' ) . scrollspy ( { target : '#toc' } ) ;
40
- }
41
- }
42
-
43
- function loadAllSvg ( ) {
44
- var els = document . getElementsByTagName ( "svg" ) ,
45
- elCount = 0 ;
46
-
47
- for ( elCount = 0 ; elCount < els . length ; elCount ++ ) {
48
- injectSvg ( els [ elCount ] ) ;
49
- }
50
- }
51
-
52
- function injectSvg ( canvasTarget ) {
53
- if ( canvasTarget ) {
54
- Snap . load (
55
- canvasTarget . getAttribute ( "data-path" ) ,
56
- function ( frag ) {
57
- sCanvas = Snap ( "#" + canvasTarget . getAttribute ( "id" ) ) ;
58
- fCanvas = Snap ( ) ;
59
- sCanvas . clear ( ) ;
60
-
61
- //Determine if grouped build-steps present
62
- var buildStepBase = frag . select ( "#base" ) ;
63
- buildStepGroups = frag . selectAll ( "[id^=step-]" ) ,
64
- buildStepCount = buildStepGroups . length ,
65
- buildStep = 0 ;
66
34
67
- //Setup the container canvas boundary sizing
68
- setCanvasBBox ( frag , canvasTarget ) ;
69
-
70
- // Show the first build step when available
71
- // Otherwise just show entire graphic
72
- if ( buildStepCount > 0 ) {
73
- // Include the non-fragment base layout/visuals
74
- fCanvas . append ( buildStepBase ) ;
75
- // fCanvas.append(buildStepGroups[buildStep]);
76
-
77
- for ( ; buildStep < buildStepCount ; buildStep ++ ) {
78
-
79
- // Supports fragment in-out transitions by
80
- // wrapping in a group and applying a second
81
- // fragment class
82
- if ( buildStepGroups [ buildStep ] . node . id . match ( / i n - o u t / ) ) {
83
- var tG = fCanvas . g ( buildStepGroups [ buildStep ] ) ;
84
- buildStepGroups [ buildStep ] . attr ( "class" , "fragment fade-out" ) ;
85
- tG . attr ( "class" , "fragment" ) ;
86
- fCanvas . append ( tG ) ;
87
- }
88
- else {
89
- buildStepGroups [ buildStep ] . attr ( "class" , "fragment" ) ;
90
- fCanvas . append ( buildStepGroups [ buildStep ] ) ;
91
- }
92
- }
93
- } else {
94
- //No "steps" to build out, ensure boundary guide
95
- //is not rendered
96
- frag . select ( "#boundary" ) . remove ( ) ;
97
- fCanvas . append ( frag ) ;
98
- }
99
-
100
- sCanvas . append ( fCanvas ) ;
101
- }
102
- ) ;
35
+ $ ( '.curriculum' ) . scrollspy ( { target : '#toc' } ) ;
103
36
}
104
37
}
105
-
106
- function setCanvasBBox ( canvas , target ) {
107
- var boundary ,
108
- maxWidth ,
109
- maxHeight ;
110
-
111
- boundary = canvas . select ( "#boundary" ) . select ( ":first-child" ) . getBBox ( ) ;
112
- maxWidth = Math . ceil ( boundary . width ) ;
113
- maxHeight = Math . ceil ( boundary . height ) ;
114
-
115
- target . setAttribute ( "height" , ( ( ( maxHeight / maxWidth ) * 100 ) + "%" ) ) ;
116
- target . setAttribute ( "viewBox" , "0 0 " + maxWidth + " " + maxHeight ) ;
117
- return canvas ;
118
- }
119
38
} ) ;
0 commit comments