Skip to content

Commit 86ad680

Browse files
committedSep 12, 2015
avoid JQuery duplication
1 parent 90e2e87 commit 86ad680

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed
 

‎listings/book.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
<%block name="extra_head">
88
${parent.extra_head()}
9-
<script src="/assets/js/jquery.min.js"></script>
10-
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
119
<link href='https://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
1210
<style>
1311
.smallcaps {
@@ -81,6 +79,10 @@
8179
</div>
8280
</div>
8381
</article>
82+
</%block>
83+
84+
<%block name="extra_js">
85+
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
8486
<script>
8587
$('#scrolling-cont').flowtype({
8688
minimum: 500,

‎listings/book2.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
<%block name="extra_head">
88
${parent.extra_head()}
9-
<script src="/assets/js/jquery.min.js"></script>
10-
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
119
<link href='https://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
1210
<style>
1311
.smallcaps {
@@ -81,6 +79,10 @@
8179
</div>
8280
</div>
8381
</article>
82+
</%block>
83+
84+
<%block name="extra_js">
85+
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
8486
<script>
8587
$('#scrolling-cont').flowtype({
8688
minimum: 500,

‎stories/creating-a-custom-page.rst

+20-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,26 @@ per line. We *could* tweak that using CSS font sizes, but let's go crazy and use
114114

115115
Why FlowType.JS? It dynamically adjust the font size so that columns always have the right font size for
116116
their width. That's just nice. To do that, we need to add JQuery and run a little JS in a ``<script>``
117-
tag at the end of the template.
117+
tag at the end of the page.
118+
119+
For that, the template offers the ``extra_js`` block. Since the bootstrap3 theme we are using already
120+
loads JQuery, there is no need to do that, so it's just a matter of loading FlowType.JS and
121+
initializing it:
122+
123+
.. code:: javascript+mako
124+
125+
<%block name="extra_js">
126+
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
127+
<script>
128+
$('#scrolling-cont').flowtype({
129+
minimum: 500,
130+
maximum: 1200,
131+
minFont: 20,
132+
maxFont: 40,
133+
fontRatio: 50
134+
});
135+
</script>
136+
</%block>
118137

119138
Figures: figures and multicolumn layout don't go along very well, they may even get split between columns!
120139
The easiest solution is to make them fit in a "page", so, some more CSS for that.

‎templates/book.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
<%block name="extra_head">
88
${parent.extra_head()}
9-
<script src="/assets/js/jquery.min.js"></script>
10-
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
119
<link href='https://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
1210
<style>
1311
.smallcaps {
@@ -81,6 +79,10 @@
8179
</div>
8280
</div>
8381
</article>
82+
</%block>
83+
84+
<%block name="extra_js">
85+
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
8486
<script>
8587
$('#scrolling-cont').flowtype({
8688
minimum: 500,

‎templates/book2.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
<%block name="extra_head">
88
${parent.extra_head()}
9-
<script src="/assets/js/jquery.min.js"></script>
10-
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
119
<link href='https://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
1210
<style>
1311
.smallcaps {
@@ -81,6 +79,10 @@
8179
</div>
8280
</div>
8381
</article>
82+
</%block>
83+
84+
<%block name="extra_js">
85+
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
8486
<script>
8587
$('#scrolling-cont').flowtype({
8688
minimum: 500,

0 commit comments

Comments
 (0)
Please sign in to comment.