Skip to content

Commit fd3acf4

Browse files
author
jordanmccullough
committed
Deprecate SnapSVG need, using Markdown embeds
Dispensing with all SVG injection and JavaScript needs in favor of Markdown image syntax and direct SVG embedding.
1 parent e17f8ec commit fd3acf4

File tree

1 file changed

+1
-82
lines changed

1 file changed

+1
-82
lines changed

_javascript/curriculum.js

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ $(function(){
22

33
buildToc();
44

5-
// SnapSVG
6-
// Run once at startup to inject all SVGs
7-
loadAllSvg();
8-
95
function buildToc(){
106
var headings = $("h3"),
117
toc = $("#toc-list");
@@ -35,85 +31,8 @@ $(function(){
3531
// $(headings[h].parentElement).prepend(hiddenTitle);
3632

3733
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;
6634

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(/in-out/)){
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' });
10336
}
10437
}
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-
}
11938
});

0 commit comments

Comments
 (0)