showoff 0.15.2 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fcc16c52c78d5e9c2d0f6b8fed009584e8b4558
4
- data.tar.gz: 43d18be95f74b4690bb096733d821a87a9e09cb5
3
+ metadata.gz: d1045e98280df58f247a2bd2cbfc6cfd8737edad
4
+ data.tar.gz: 6a2b723b8f401ce9807f27eb0b8b85e6022e5f0e
5
5
  SHA512:
6
- metadata.gz: 9c671f6d44ce601953d7e2a1882535c5d0141459033801a2fbe869a0d1a7998f792e9faa486cdff2d8888575bc53872af56064d667e459952a4fcee2e0240f07
7
- data.tar.gz: 8330b2398adb6bfaf6a51e8358c4f6095bffd489a1e57c825c7e7f4da7199b36900eb83fdb10296f0a6e47b618a808f485b0f09adf6a4ea6a5ef1806b9e06603
6
+ metadata.gz: db4bbe7b17021c6365a15cb3281022a642ae6d2c3fb82749a47a74958bbff4206b1e1b0d3d852989764428dfa259bf3ca360efed48d1efc608e49c98584cb5a8
7
+ data.tar.gz: 951a2673da40ab2cc7b39eebe4708f9646a3dbd040619aa9cffdd3dde0bad37af14ae1f922ae0b78588ebeaf9199ba7f0cd4209f67874d4916fec78c0601aaa7
@@ -1,3 +1,3 @@
1
1
  # No namespace here since ShowOff is a class and I'd have to inherit from
2
2
  # Sinatra::Application (which we don't want to load here)
3
- SHOWOFF_VERSION = '0.15.2'
3
+ SHOWOFF_VERSION = '0.15.3'
@@ -0,0 +1,292 @@
1
+ /*! BigText - v0.1.8 - 2015-04-01
2
+ * https://github.com/zachleat/bigtext
3
+ * Copyright (c) 2015 Zach Leatherman (@zachleat)
4
+ * MIT License */
5
+
6
+ (function(window, $) {
7
+ "use strict";
8
+
9
+ var counter = 0,
10
+ $headCache = $('head'),
11
+ oldBigText = window.BigText,
12
+ oldjQueryMethod = $.fn.bigtext,
13
+ BigText = {
14
+ DEBUG_MODE: false,
15
+ DEFAULT_MIN_FONT_SIZE_PX: null,
16
+ DEFAULT_MAX_FONT_SIZE_PX: 528,
17
+ GLOBAL_STYLE_ID: 'bigtext-style',
18
+ STYLE_ID: 'bigtext-id',
19
+ LINE_CLASS_PREFIX: 'bigtext-line',
20
+ EXEMPT_CLASS: 'bigtext-exempt',
21
+ noConflict: function(restore)
22
+ {
23
+ if(restore) {
24
+ $.fn.bigtext = oldjQueryMethod;
25
+ window.BigText = oldBigText;
26
+ }
27
+ return BigText;
28
+ },
29
+ supports: {
30
+ wholeNumberFontSizeOnly: (function() {
31
+ if( !( 'getComputedStyle' in window ) ) {
32
+ return true;
33
+ }
34
+ var test = $('<div/>').css({
35
+ position: 'absolute',
36
+ 'font-size': '14.1px'
37
+ }).insertBefore( $('script').eq(0) ),
38
+ computedStyle = window.getComputedStyle( test[0], null );
39
+
40
+ var ret = computedStyle && computedStyle.getPropertyValue( 'font-size' ) === '14px';
41
+ test.remove();
42
+ return ret;
43
+ })()
44
+ },
45
+ init: function() {
46
+ if(!$('#'+BigText.GLOBAL_STYLE_ID).length) {
47
+ $headCache.append(BigText.generateStyleTag(BigText.GLOBAL_STYLE_ID, ['.bigtext * { white-space: nowrap; } .bigtext > * { display: block; }',
48
+ '.bigtext .' + BigText.EXEMPT_CLASS + ', .bigtext .' + BigText.EXEMPT_CLASS + ' * { white-space: normal; }']));
49
+ }
50
+ },
51
+ bindResize: function(eventName, resizeFunction) {
52
+ var timeoutId;
53
+ $(window).unbind(eventName).bind(eventName, function() {
54
+ if( timeoutId ) {
55
+ clearTimeout( timeoutId );
56
+ }
57
+ timeoutId = setTimeout( resizeFunction, 100 );
58
+ });
59
+ },
60
+ getStyleId: function(id)
61
+ {
62
+ return BigText.STYLE_ID + '-' + id;
63
+ },
64
+ generateStyleTag: function(id, css)
65
+ {
66
+ return $('<style>' + css.join('\n') + '</style>').attr('id', id);
67
+ },
68
+ clearCss: function(id)
69
+ {
70
+ var styleId = BigText.getStyleId(id);
71
+ $('#' + styleId).remove();
72
+ },
73
+ generateCss: function(id, linesFontSizes, lineWordSpacings, minFontSizes)
74
+ {
75
+ var css = [];
76
+
77
+ BigText.clearCss(id);
78
+
79
+ for(var j=0, k=linesFontSizes.length; j<k; j++) {
80
+ css.push('#' + id + ' .' + BigText.LINE_CLASS_PREFIX + j + ' {' +
81
+ (minFontSizes[j] ? ' white-space: normal;' : '') +
82
+ (linesFontSizes[j] ? ' font-size: ' + linesFontSizes[j] + 'px;' : '') +
83
+ (lineWordSpacings[j] ? ' word-spacing: ' + lineWordSpacings[j] + 'px;' : '') +
84
+ '}');
85
+ }
86
+
87
+ return BigText.generateStyleTag(BigText.getStyleId(id), css);
88
+ },
89
+ jQueryMethod: function(options)
90
+ {
91
+ BigText.init();
92
+
93
+ options = $.extend({
94
+ minfontsize: BigText.DEFAULT_MIN_FONT_SIZE_PX,
95
+ maxfontsize: BigText.DEFAULT_MAX_FONT_SIZE_PX,
96
+ childSelector: '',
97
+ resize: true
98
+ }, options || {});
99
+
100
+ this.each(function()
101
+ {
102
+ var $t = $(this).addClass('bigtext'),
103
+ maxWidth = $t.width(),
104
+ id = $t.attr('id'),
105
+ $children = options.childSelector ? $t.find( options.childSelector ) : $t.children();
106
+
107
+ if(!id) {
108
+ id = 'bigtext-id' + (counter++);
109
+ $t.attr('id', id);
110
+ }
111
+
112
+ if(options.resize) {
113
+ BigText.bindResize('resize.bigtext-event-' + id, function()
114
+ {
115
+ // TODO only call this if the width has changed.
116
+ BigText.jQueryMethod.call($('#' + id), options);
117
+ });
118
+ }
119
+
120
+ BigText.clearCss(id);
121
+
122
+ $children.addClass(function(lineNumber, className)
123
+ {
124
+ // remove existing line classes.
125
+ return [className.replace(new RegExp('\\b' + BigText.LINE_CLASS_PREFIX + '\\d+\\b'), ''),
126
+ BigText.LINE_CLASS_PREFIX + lineNumber].join(' ');
127
+ });
128
+
129
+ var sizes = calculateSizes($t, $children, maxWidth, options.maxfontsize, options.minfontsize);
130
+ $headCache.append(BigText.generateCss(id, sizes.fontSizes, sizes.wordSpacings, sizes.minFontSizes));
131
+ });
132
+
133
+ return this.trigger('bigtext:complete');
134
+ }
135
+ };
136
+
137
+ function testLineDimensions($line, maxWidth, property, size, interval, units, previousWidth)
138
+ {
139
+ var width;
140
+ previousWidth = typeof previousWidth === 'number' ? previousWidth : 0;
141
+ $line.css(property, size + units);
142
+
143
+ width = $line.width();
144
+
145
+ if(width >= maxWidth) {
146
+ // console.log(width, ' previous: ' + previousWidth, property + ' at ' + interval, 'prior: ' + (parseFloat(size) - interval), 'new:' + parseFloat(size));
147
+ $line.css(property, '');
148
+
149
+ if(width === maxWidth) {
150
+ return {
151
+ match: 'exact',
152
+ size: parseFloat((parseFloat(size) - 0.1).toFixed(3))
153
+ };
154
+ }
155
+
156
+ // Since this is an estimate, we calculate how far over the width we went with the new value.
157
+ // If this is word-spacing (our last resort guess) and the over is less than the under, we keep the higher value.
158
+ // Otherwise, we revert to the underestimate.
159
+ var under = maxWidth - previousWidth,
160
+ over = width - maxWidth;
161
+
162
+ return {
163
+ match: 'estimate',
164
+ size: parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3))
165
+ };
166
+ }
167
+
168
+ return width;
169
+ }
170
+
171
+ function calculateSizes($t, $children, maxWidth, maxFontSize, minFontSize)
172
+ {
173
+ var $c = $t.clone(true)
174
+ .addClass('bigtext-cloned')
175
+ .css({
176
+ fontFamily: $t.css('font-family'),
177
+ textTransform: $t.css('text-transform'),
178
+ wordSpacing: $t.css('word-spacing'),
179
+ letterSpacing: $t.css('letter-spacing'),
180
+ position: 'absolute',
181
+ left: BigText.DEBUG_MODE ? 0 : -9999,
182
+ top: BigText.DEBUG_MODE ? 0 : -9999
183
+ })
184
+ .appendTo(document.body);
185
+
186
+ // font-size isn't the only thing we can modify, we can also mess with:
187
+ // word-spacing and letter-spacing. WebKit does not respect subpixel
188
+ // letter-spacing, word-spacing, or font-size.
189
+ // TODO try -webkit-transform: scale() as a workaround.
190
+ var fontSizes = [],
191
+ wordSpacings = [],
192
+ minFontSizes = [],
193
+ ratios = [];
194
+
195
+ $children.css('float', 'left').each(function() {
196
+ var $line = $(this),
197
+ // TODO replace 8, 4 with a proportional size to the calculated font-size.
198
+ intervals = BigText.supports.wholeNumberFontSizeOnly ? [8, 4, 1] : [8, 4, 1, 0.1],
199
+ lineMax,
200
+ newFontSize;
201
+
202
+ if($line.hasClass(BigText.EXEMPT_CLASS)) {
203
+ fontSizes.push(null);
204
+ ratios.push(null);
205
+ minFontSizes.push(false);
206
+ return;
207
+ }
208
+
209
+ // TODO we can cache this ratio?
210
+ var autoGuessSubtraction = 32, // font size in px
211
+ currentFontSize = parseFloat($line.css('font-size')),
212
+ ratio = ( $line.width() / currentFontSize ).toFixed(6);
213
+
214
+ newFontSize = parseInt( maxWidth / ratio, 10 ) - autoGuessSubtraction;
215
+
216
+ outer: for(var m=0, n=intervals.length; m<n; m++) {
217
+ inner: for(var j=1, k=10; j<=k; j++) {
218
+ if(newFontSize + j*intervals[m] > maxFontSize) {
219
+ newFontSize = maxFontSize;
220
+ break outer;
221
+ }
222
+
223
+ lineMax = testLineDimensions($line, maxWidth, 'font-size', newFontSize + j*intervals[m], intervals[m], 'px', lineMax);
224
+ if(typeof lineMax !== 'number') {
225
+ newFontSize = lineMax.size;
226
+
227
+ if(lineMax.match === 'exact') {
228
+ break outer;
229
+ }
230
+ break inner;
231
+ }
232
+ }
233
+ }
234
+
235
+ ratios.push(maxWidth / newFontSize);
236
+
237
+ if(newFontSize > maxFontSize) {
238
+ fontSizes.push(maxFontSize);
239
+ minFontSizes.push(false);
240
+ } else if(!!minFontSize && newFontSize < minFontSize) {
241
+ fontSizes.push(minFontSize);
242
+ minFontSizes.push(true);
243
+ } else {
244
+ fontSizes.push(newFontSize);
245
+ minFontSizes.push(false);
246
+ }
247
+ }).each(function(lineNumber) {
248
+ var $line = $(this),
249
+ wordSpacing = 0,
250
+ interval = 1,
251
+ maxWordSpacing;
252
+
253
+ if($line.hasClass(BigText.EXEMPT_CLASS)) {
254
+ wordSpacings.push(null);
255
+ return;
256
+ }
257
+
258
+ // must re-use font-size, even though it was removed above.
259
+ $line.css('font-size', fontSizes[lineNumber] + 'px');
260
+
261
+ for(var m=1, n=3; m<n; m+=interval) {
262
+ maxWordSpacing = testLineDimensions($line, maxWidth, 'word-spacing', m, interval, 'px', maxWordSpacing);
263
+ if(typeof maxWordSpacing !== 'number') {
264
+ wordSpacing = maxWordSpacing.size;
265
+ break;
266
+ }
267
+ }
268
+
269
+ $line.css('font-size', '');
270
+ wordSpacings.push(wordSpacing);
271
+ }).removeAttr('style');
272
+
273
+ if( !BigText.DEBUG_MODE ) {
274
+ $c.remove();
275
+ } else {
276
+ $c.css({
277
+ 'background-color': 'rgba(255,255,255,.4)'
278
+ });
279
+ }
280
+
281
+ return {
282
+ fontSizes: fontSizes,
283
+ wordSpacings: wordSpacings,
284
+ ratios: ratios,
285
+ minFontSizes: minFontSizes
286
+ };
287
+ }
288
+
289
+ $.fn.bigtext = BigText.jQueryMethod;
290
+ window.BigText = BigText;
291
+
292
+ })(this, jQuery);
@@ -35,6 +35,7 @@ $(document).ready(function(){
35
35
  $('#layoutSelector').change(function(e) {
36
36
  chooseLayout(e.target.value);
37
37
  });
38
+ chooseLayout(null);
38
39
 
39
40
 
40
41
  // Bind events for mobile viewing
@@ -783,6 +784,9 @@ function openNext() {
783
784
  ********************/
784
785
  function chooseLayout(layout)
785
786
  {
787
+ // yay for half-baked data storage schemes
788
+ layout = layout || document.cookieHash['layout'] || 'default';
789
+
786
790
  // in case we're being called externally, make the UI match
787
791
  $('#layoutSelector').val(layout);
788
792
  $("#nextWindowConfirmation").slideUp(125);
@@ -846,6 +850,7 @@ function chooseLayout(layout)
846
850
 
847
851
  }
848
852
 
853
+ document.cookie = "layout="+layout
849
854
  mode.layout = layout;
850
855
  zoom(true);
851
856
  }
data/public/js/showoff.js CHANGED
@@ -25,6 +25,17 @@ var loadSlidesPrefix
25
25
 
26
26
  var mode = { track: true, follow: true };
27
27
 
28
+ // since javascript doesn't have a built-in way to get to cookies easily,
29
+ // let's just add our own data structure.
30
+ document.cookieHash = {}
31
+ document.cookie.split(';').forEach( function(item) {
32
+ var pos = item.indexOf('=');
33
+ var key = item.slice(0,pos).trim();
34
+ var val = item.slice(pos+1).trim();
35
+
36
+ document.cookieHash[key] = val;
37
+ });
38
+
28
39
  $(document).on('click', 'code.execute', executeCode);
29
40
 
30
41
  function setupPreso(load_slides, prefix) {
@@ -568,6 +579,9 @@ function showSlide(back_step, updatepv) {
568
579
  // copy notes to the notes field for mobile.
569
580
  postSlide();
570
581
 
582
+ // make all bigly text tremendous
583
+ currentSlide.children('.content.bigtext').bigtext();
584
+
571
585
  return ret;
572
586
  }
573
587
 
data/views/header.erb CHANGED
@@ -19,6 +19,7 @@
19
19
  <script type="text/javascript" src="<%= @asset_path %>/js/jquery.parsequery.min-6a20f83.js"></script>
20
20
  <script type="text/javascript" src="<%= @asset_path %>/js/jquery.doubletap-4ff02c5.js"></script>
21
21
  <script type="text/javascript" src="<%= @asset_path %>/js/jTypeWriter-1.1.js"></script>
22
+ <script type="text/javascript" src="<%= @asset_path %>/js/bigtext-0.1.8.js"></script>
22
23
  <script type="text/javascript" src="<%= @asset_path %>/js/highlight.pack-9.2.0.js"></script>
23
24
 
24
25
  <script type="text/javascript" src="<%= @asset_path %>/js/coffee-script-1.1.3-pre.js"></script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-01 00:00:00.000000000 Z
12
+ date: 2016-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -328,6 +328,7 @@ files:
328
328
  - public/favicon.ico
329
329
  - public/js/TimeCircles-89ac5ae.js
330
330
  - public/js/annotations.js
331
+ - public/js/bigtext-0.1.8.js
331
332
  - public/js/coffee-script-1.1.3-pre.js
332
333
  - public/js/highlight.pack-9.2.0.js
333
334
  - public/js/jTypeWriter-1.1.js