showoff 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/bin/showoff +9 -0
  3. data/lib/showoff.rb +28 -19
  4. data/lib/showoff/version.rb +1 -1
  5. data/public/css/highlight/agate.css +22 -51
  6. data/public/css/highlight/androidstudio.css +25 -12
  7. data/public/css/highlight/arduino-light.css +88 -0
  8. data/public/css/highlight/arta.css +24 -89
  9. data/public/css/highlight/ascetic.css +19 -26
  10. data/public/css/highlight/atelier-cave-dark.css +83 -0
  11. data/public/css/highlight/atelier-cave-light.css +85 -0
  12. data/public/css/highlight/atelier-cave.dark.css +26 -56
  13. data/public/css/highlight/atelier-cave.light.css +27 -55
  14. data/public/css/highlight/atelier-dune-dark.css +69 -0
  15. data/public/css/highlight/atelier-dune-light.css +69 -0
  16. data/public/css/highlight/atelier-dune.dark.css +22 -47
  17. data/public/css/highlight/atelier-dune.light.css +22 -47
  18. data/public/css/highlight/atelier-estuary-dark.css +84 -0
  19. data/public/css/highlight/atelier-estuary-light.css +84 -0
  20. data/public/css/highlight/atelier-estuary.dark.css +26 -55
  21. data/public/css/highlight/atelier-estuary.light.css +26 -55
  22. data/public/css/highlight/atelier-forest-dark.css +69 -0
  23. data/public/css/highlight/atelier-forest-light.css +69 -0
  24. data/public/css/highlight/atelier-forest.dark.css +22 -47
  25. data/public/css/highlight/atelier-forest.light.css +22 -47
  26. data/public/css/highlight/atelier-heath-dark.css +69 -0
  27. data/public/css/highlight/atelier-heath-light.css +69 -0
  28. data/public/css/highlight/atelier-heath.dark.css +22 -47
  29. data/public/css/highlight/atelier-heath.light.css +22 -47
  30. data/public/css/highlight/atelier-lakeside-dark.css +69 -0
  31. data/public/css/highlight/atelier-lakeside-light.css +69 -0
  32. data/public/css/highlight/atelier-lakeside.dark.css +22 -47
  33. data/public/css/highlight/atelier-lakeside.light.css +22 -47
  34. data/public/css/highlight/atelier-plateau-dark.css +84 -0
  35. data/public/css/highlight/atelier-plateau-light.css +84 -0
  36. data/public/css/highlight/atelier-plateau.dark.css +26 -55
  37. data/public/css/highlight/atelier-plateau.light.css +26 -55
  38. data/public/css/highlight/atelier-savanna-dark.css +84 -0
  39. data/public/css/highlight/atelier-savanna-light.css +84 -0
  40. data/public/css/highlight/atelier-savanna.dark.css +26 -55
  41. data/public/css/highlight/atelier-savanna.light.css +26 -55
  42. data/public/css/highlight/atelier-seaside-dark.css +69 -0
  43. data/public/css/highlight/atelier-seaside-light.css +69 -0
  44. data/public/css/highlight/atelier-seaside.dark.css +22 -47
  45. data/public/css/highlight/atelier-seaside.light.css +22 -47
  46. data/public/css/highlight/atelier-sulphurpool-dark.css +69 -0
  47. data/public/css/highlight/atelier-sulphurpool-light.css +69 -0
  48. data/public/css/highlight/atelier-sulphurpool.dark.css +22 -47
  49. data/public/css/highlight/atelier-sulphurpool.light.css +22 -47
  50. data/public/css/highlight/brown-paper.css +64 -0
  51. data/public/css/highlight/brown-papersq.png +0 -0
  52. data/public/css/highlight/brown_paper.css +21 -60
  53. data/public/css/highlight/codepen-embed.css +22 -59
  54. data/public/css/highlight/color-brewer.css +19 -113
  55. data/public/css/highlight/dark.css +18 -58
  56. data/public/css/highlight/darkula.css +20 -98
  57. data/public/css/highlight/default.css +67 -123
  58. data/public/css/highlight/docco.css +22 -59
  59. data/public/css/highlight/dracula.css +76 -0
  60. data/public/css/highlight/far.css +25 -64
  61. data/public/css/highlight/foundation.css +21 -68
  62. data/public/css/highlight/github-gist.css +25 -165
  63. data/public/css/highlight/github.css +23 -47
  64. data/public/css/highlight/googlecode.css +29 -84
  65. data/public/css/highlight/grayscale.css +101 -0
  66. data/public/css/highlight/gruvbox-dark.css +108 -0
  67. data/public/css/highlight/gruvbox-light.css +108 -0
  68. data/public/css/highlight/hopscotch.css +83 -0
  69. data/public/css/highlight/hybrid.css +16 -78
  70. data/public/css/highlight/idea.css +23 -48
  71. data/public/css/highlight/ir-black.css +73 -0
  72. data/public/css/highlight/ir_black.css +24 -57
  73. data/public/css/highlight/kimbie.dark.css +24 -47
  74. data/public/css/highlight/kimbie.light.css +24 -47
  75. data/public/css/highlight/magula.css +17 -67
  76. data/public/css/highlight/mono-blue.css +22 -31
  77. data/public/css/highlight/monokai-sublime.css +83 -0
  78. data/public/css/highlight/monokai.css +19 -75
  79. data/public/css/highlight/monokai_sublime.css +20 -91
  80. data/public/css/highlight/obsidian.css +25 -89
  81. data/public/css/highlight/paraiso-dark.css +72 -0
  82. data/public/css/highlight/paraiso-light.css +72 -0
  83. data/public/css/highlight/paraiso.dark.css +23 -47
  84. data/public/css/highlight/paraiso.light.css +23 -47
  85. data/public/css/highlight/pojoaque.css +28 -51
  86. data/public/css/highlight/qtcreator_dark.css +83 -0
  87. data/public/css/highlight/qtcreator_light.css +83 -0
  88. data/public/css/highlight/railscasts.css +32 -110
  89. data/public/css/highlight/rainbow.css +33 -55
  90. data/public/css/highlight/school-book.css +72 -0
  91. data/public/css/highlight/school-book.png +0 -0
  92. data/public/css/highlight/school_book.css +24 -63
  93. data/public/css/highlight/solarized-dark.css +84 -0
  94. data/public/css/highlight/solarized-light.css +84 -0
  95. data/public/css/highlight/solarized_dark.css +29 -52
  96. data/public/css/highlight/solarized_light.css +29 -52
  97. data/public/css/highlight/sunburst.css +28 -87
  98. data/public/css/highlight/tomorrow-night-blue.css +24 -45
  99. data/public/css/highlight/tomorrow-night-bright.css +24 -45
  100. data/public/css/highlight/tomorrow-night-eighties.css +24 -45
  101. data/public/css/highlight/tomorrow-night.css +24 -45
  102. data/public/css/highlight/tomorrow.css +24 -45
  103. data/public/css/highlight/vs.css +32 -56
  104. data/public/css/highlight/xcode.css +28 -89
  105. data/public/css/highlight/zenburn.css +26 -64
  106. data/public/css/presenter.css +78 -157
  107. data/public/css/showoff.css +368 -398
  108. data/public/js/highlight.pack.js +6423 -1791
  109. data/public/js/jquery.cycle.all.js +0 -29
  110. data/public/js/presenter.js +26 -67
  111. data/public/js/showoff.js +175 -152
  112. data/views/header.erb +0 -4
  113. data/views/header_mini.erb +0 -2
  114. data/views/index.erb +58 -48
  115. data/views/onepage.erb +4 -4
  116. data/views/presenter.erb +17 -15
  117. metadata +59 -45
  118. data/public/css/fast.png +0 -0
  119. data/public/css/fg.menu.css +0 -114
  120. data/public/css/grippy-close.png +0 -0
  121. data/public/css/grippy.png +0 -0
  122. data/public/css/new_window-a.png +0 -0
  123. data/public/css/new_window-b.png +0 -0
  124. data/public/css/new_window-c.png +0 -0
  125. data/public/css/popdown.png +0 -0
  126. data/public/css/popout.png +0 -0
  127. data/public/css/slow.png +0 -0
  128. data/public/css/spinner.gif +0 -0
  129. data/public/css/theme/images/ui-bg_diagonals-small_100_f0efea_40x40.png +0 -0
  130. data/public/css/theme/images/ui-bg_flat_35_f0f0f0_40x100.png +0 -0
  131. data/public/css/theme/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
  132. data/public/css/theme/images/ui-bg_glow-ball_25_2e2e28_600x600.png +0 -0
  133. data/public/css/theme/images/ui-bg_highlight-soft_100_f0efea_1x100.png +0 -0
  134. data/public/css/theme/images/ui-bg_highlight-soft_25_327E04_1x100.png +0 -0
  135. data/public/css/theme/images/ui-bg_highlight-soft_25_5A9D1A_1x100.png +0 -0
  136. data/public/css/theme/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
  137. data/public/css/theme/images/ui-bg_inset-soft_22_3b3b35_1x100.png +0 -0
  138. data/public/css/theme/images/ui-icons_808080_256x240.png +0 -0
  139. data/public/css/theme/images/ui-icons_8DC262_256x240.png +0 -0
  140. data/public/css/theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  141. data/public/css/theme/images/ui-icons_e7e6e4_256x240.png +0 -0
  142. data/public/css/theme/images/ui-icons_eeeeee_256x240.png +0 -0
  143. data/public/css/theme/images/ui-icons_ffffff_256x240.png +0 -0
  144. data/public/css/theme/ui.accordion.css +0 -9
  145. data/public/css/theme/ui.all.css +0 -2
  146. data/public/css/theme/ui.base.css +0 -9
  147. data/public/css/theme/ui.core.css +0 -37
  148. data/public/css/theme/ui.datepicker.css +0 -62
  149. data/public/css/theme/ui.dialog.css +0 -13
  150. data/public/css/theme/ui.progressbar.css +0 -4
  151. data/public/css/theme/ui.resizable.css +0 -13
  152. data/public/css/theme/ui.slider.css +0 -17
  153. data/public/css/theme/ui.tabs.css +0 -9
  154. data/public/css/theme/ui.theme.css +0 -245
  155. data/public/js/fg.menu.js +0 -645
@@ -221,10 +221,6 @@ function buildOptions($cont, $slides, els, options, o) {
221
221
 
222
222
  saveOriginalOpts(opts);
223
223
 
224
- // clearType corrections
225
- if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
226
- clearTypeFix($slides);
227
-
228
224
  // container requires non-static position so that slides can be position within
229
225
  if ($cont.css('position') == 'static')
230
226
  $cont.css('position', 'relative');
@@ -462,9 +458,6 @@ function exposeAddSlide(opts, els) {
462
458
  opts.nextSlide++;
463
459
  }
464
460
 
465
- if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
466
- clearTypeFix($s);
467
-
468
461
  if (opts.fit && opts.width)
469
462
  $s.width(opts.width);
470
463
  if (opts.fit && opts.height && opts.height != 'auto')
@@ -736,28 +729,6 @@ $.fn.cycle.hopsFromLast = function(opts, fwd) {
736
729
  return hops;
737
730
  };
738
731
 
739
- // fix clearType problems in ie6 by setting an explicit bg color
740
- // (otherwise text slides look horrible during a fade transition)
741
- function clearTypeFix($slides) {
742
- function hex(s) {
743
- s = parseInt(s).toString(16);
744
- return s.length < 2 ? '0'+s : s;
745
- };
746
- function getBg(e) {
747
- for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
748
- var v = $.css(e,'background-color');
749
- if (v.indexOf('rgb') >= 0 ) {
750
- var rgb = v.match(/\d+/g);
751
- return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
752
- }
753
- if (v && v != 'transparent')
754
- return v;
755
- }
756
- return '#ffffff';
757
- };
758
- $slides.each(function() { $(this).css('background-color', getBg(this)); });
759
- };
760
-
761
732
  // reset common props before the next transition
762
733
  $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
763
734
  $(opts.elements).not(curr).hide();
@@ -16,22 +16,6 @@ $(document).ready(function(){
16
16
  // the presenter window doesn't need the reload on resize bit
17
17
  $(window).unbind('resize');
18
18
 
19
- // side menu accordian crap
20
- $("#preso").bind("showoff:loaded", function (event) {
21
- $(".menu > ul ul").hide()
22
- $(".menu > ul a").click(function() {
23
- if ($(this).next().is('ul')) {
24
- $(this).next().toggle()
25
- } else {
26
- gotoSlide($(this).attr('rel'));
27
- try { slaveWindow.gotoSlide($(this).attr('rel'), false) } catch (e) {}
28
- postSlide();
29
- update();
30
- }
31
- return false;
32
- }).next().hide();
33
- });
34
-
35
19
  $("#minStop").hide();
36
20
  $("#startTimer").click(function() { toggleTimer() });
37
21
  $("#stopTimer").click(function() { toggleTimer() });
@@ -90,7 +74,7 @@ function presenterPopupToggle(page, event) {
90
74
  $.get(page, function(data) {
91
75
  var link = $('<a>'),
92
76
  content = $('<div>');
93
-
77
+
94
78
  link.attr({
95
79
  href: page,
96
80
  target: '_new'
@@ -98,15 +82,15 @@ function presenterPopupToggle(page, event) {
98
82
  link.text('Open in a new page...');
99
83
 
100
84
  content.attr('id', page.substring(1, page.length));
101
- content.append(link);
85
+ content.append(link);
102
86
  content.append($(data).find('#wrapper').html());
103
87
  popup.append(content);
104
-
88
+
105
89
  setupStats(); // this function is in showoff.js because /stats does not load presenter.js
106
-
90
+
107
91
  $('body').append(popup);
108
- popup.slideDown(200); // #presenterPopup is display: none by default
109
- });
92
+ popup.slideDown(200); // #presenterPopup is display: none by default
93
+ });
110
94
  }
111
95
  }
112
96
 
@@ -208,11 +192,6 @@ function openNext()
208
192
  catch(e) {
209
193
  console.log('Failed to open or connect next window. Popup blocker?');
210
194
  }
211
-
212
- // Set up a maintenance loop to keep the connection between windows. I wish there were a cleaner way to do this.
213
- //if (typeof maintainNext == 'undefined') {
214
- // maintainNext = setInterval(openNext, 1000);
215
- //}
216
195
  }
217
196
  else {
218
197
  try {
@@ -255,6 +234,17 @@ function openNotes()
255
234
  }
256
235
  }
257
236
 
237
+ function printSlides()
238
+ {
239
+ try {
240
+ var printWindow = window.open('/print');
241
+ printWindow.window.print();
242
+ }
243
+ catch(e) {
244
+ console.log('Failed to open print window. Popup blocker?');
245
+ }
246
+ }
247
+
258
248
  function askQuestion(question) {
259
249
  $("#questions ul").prepend($('<li/>').text(question));
260
250
 
@@ -297,37 +287,15 @@ function updatePace() {
297
287
  var position = Math.max(Math.min(sum, 90), 10); // between 10 and 90
298
288
  $("#paceMarker").css({ left: position+"%" });
299
289
 
300
- if(position > 75) {
290
+ if(position > 75) {
301
291
  $("#paceFast").show();
302
- } else {
292
+ } else {
303
293
  $("#paceFast").hide();
304
294
  }
305
- if(position < 25) {
306
- $("#paceSlow").show();
307
- } else {
308
- $("#paceSlow").hide();
309
- }
310
- }
311
-
312
- function zoom()
313
- {
314
- if(window.innerWidth <= 480) {
315
- $(".zoomed").css("zoom", 0.32);
316
- }
317
- else {
318
- var hSlide = parseFloat($("#preso").height());
319
- var wSlide = parseFloat($("#preso").width());
320
- var hPreview = parseFloat($("#preview").height());
321
- var wPreview = parseFloat($("#preview").width());
322
- var factor = parseFloat($("#zoomer").val());
323
-
324
- newZoom = factor * Math.min(hPreview/hSlide, wPreview/wSlide) - 0.04;
325
-
326
- $(".zoomed").css("zoom", newZoom);
327
- $(".zoomed").css("-ms-zoom", newZoom);
328
- $(".zoomed").css("-webkit-zoom", newZoom);
329
- $(".zoomed").css("-moz-transform", "scale("+newZoom+")");
330
- $(".zoomed").css("-moz-transform-origin", "left top");
295
+ if(position < 25) {
296
+ $("#paceSlow").show();
297
+ } else {
298
+ $("#paceSlow").hide();
331
299
  }
332
300
  }
333
301
 
@@ -337,6 +305,9 @@ gotoSlide = function (slideNum)
337
305
  {
338
306
  origGotoSlide.call(this, slideNum)
339
307
  try { slaveWindow.gotoSlide(slideNum, false) } catch (e) {}
308
+ if ( !mobile() ) {
309
+ $("#navigation li li").get(slidenum).scrollIntoView();
310
+ }
340
311
  postSlide()
341
312
  }
342
313
 
@@ -392,11 +363,6 @@ function presPrevStep()
392
363
 
393
364
  function presNextStep()
394
365
  {
395
- /* // I don't know what the point of this bit was, but it's not needed.
396
- // read the variables set by our spawner
397
- incrCurr = slaveWindow.incrCurr
398
- incrSteps = slaveWindow.incrSteps
399
- */
400
366
  nextStep();
401
367
  try { slaveWindow.nextStep(false) } catch (e) {};
402
368
  try { nextWindow.gotoSlide(nextSlideNum()) } catch (e) {};
@@ -589,10 +555,3 @@ function toggleUpdater()
589
555
  mode.update = $("#followerToggle").attr("checked");
590
556
  update();
591
557
  }
592
-
593
- /*
594
- // redefine defaultMode
595
- defaultMode = function() {
596
- return mobile() ? modeState.follow : modeState.passive;
597
- }
598
- */
@@ -46,6 +46,7 @@ function setupPreso(load_slides, prefix) {
46
46
  loadSlides(loadSlidesBool, loadSlidesPrefix)
47
47
 
48
48
  loadKeyDictionaries();
49
+ setupSideMenu();
49
50
 
50
51
  doDebugStuff()
51
52
 
@@ -62,44 +63,18 @@ function setupPreso(load_slides, prefix) {
62
63
 
63
64
  // make sure that the next view doesn't bugger things on the first load
64
65
  if(query.next == 'true') {
65
- $('#preso').addClass('zoomed');
66
66
  mode.next = true;
67
- zoom();
68
67
  }
69
68
 
70
69
  // Make sure the slides always look right.
71
70
  // Better would be dynamic calculations, but this is enough for now.
72
- $(window).resize(function(){location.reload();});
73
-
74
- $("#feedbackWrapper").hover(
75
- function() {
76
- $('#feedbackSidebar').show();
77
- toggleKeybinding();
78
- },
79
- function() {
80
- $('#feedbackSidebar').hide();
81
- toggleKeybinding();
82
- }
83
- );
84
-
85
- $("#paceSlower").click(function() { sendPace('slower'); });
86
- $("#paceFaster").click(function() { sendPace('faster'); });
87
- $("#askQuestion").click(function() { askQuestion( $("textarea#question").val()) });
88
- $("#sendFeedback").click(function() {
89
- sendFeedback($( "input:radio[name=rating]:checked" ).val(), $("textarea#feedback").val())
90
- });
91
- $("#editSlide").click(function() { editSlide(); });
71
+ zoom();
72
+ $(window).resize(function() {zoom();});
92
73
 
93
74
  // Open up our control socket
94
75
  if(mode.track) {
95
76
  connectControlChannel();
96
77
  }
97
- /*
98
- ws = new WebSocket('ws://' + location.host + '/control');
99
- ws.onopen = function() { connected(); };
100
- ws.onclose = function() { disconnected(); }
101
- ws.onmessage = function(m) { parseMessage(m.data); };
102
- */
103
78
  }
104
79
 
105
80
  function loadSlides(load_slides, prefix, reload) {
@@ -130,7 +105,7 @@ function loadKeyDictionaries () {
130
105
 
131
106
  function initializePresentation(prefix) {
132
107
  // unhide for height to work in static mode
133
- $("#slides").show();
108
+ $("#slides").show();
134
109
 
135
110
  //copy into presentation area
136
111
  $("#preso").empty()
@@ -197,47 +172,155 @@ function initializePresentation(prefix) {
197
172
  $("#preso").trigger("showoff:loaded");
198
173
  }
199
174
 
200
- /* This looks like the zoom() function for the presenter preview, but it uses a different algorithm */
201
- function zoom()
202
- {
203
- if(window.innerWidth <= 480) {
204
- $(".zoomed").css("zoom", 0.32);
175
+ function zoom() {
176
+ var preso = $("#preso");
177
+ var hSlide = parseFloat(preso.height());
178
+ var wSlide = parseFloat(preso.width());
179
+ var hBody = parseFloat(preso.parent().height());
180
+ var wBody = parseFloat(preso.parent().width());
181
+
182
+ var newZoom = Math.min(hBody/hSlide, wBody/wSlide);
183
+ // Because Firefox's transform doesn't scale up very well
184
+ newZoom = newZoom > 1 ? 1 : newZoom - .04;
185
+
186
+ preso.css("zoom", newZoom);
187
+ preso.css("-ms-zoom", newZoom);
188
+ preso.css("-webkit-zoom", newZoom);
189
+ // Firefox doesn't support zoom
190
+ // Don't use standard transform to avoid modifying Chrome
191
+ preso.css("-moz-transform", "scale(" + newZoom + ")");
192
+ preso.css("-moz-transform-origin", "0 0 0");
193
+ }
194
+
195
+ function setupSideMenu() {
196
+ $("#hamburger").click(function() {
197
+ $('#feedbackSidebar, #sidebarExit').toggle();
198
+ toggleKeybinding();
199
+
200
+ });
201
+
202
+ $("#navToggle").click(function() {
203
+ $("#navigation").toggle();
204
+ });
205
+
206
+ $('#fileDownloads').click(function() {
207
+ closeMenu();
208
+ window.open('/download');
209
+ })
210
+
211
+ $("#paceSlower").click(function() {
212
+ sendPace('slower');
213
+ });
214
+
215
+ $("#paceFaster").click(function() {
216
+ sendPace('faster');
217
+ });
218
+
219
+ $('#questionToggle').click(function() {
220
+ $('#questionSubmenu').toggle();
221
+ });
222
+ $("#askQuestion").click(function() {
223
+ askQuestion( $("#question").val());
224
+ feedback_response(this, "Sending...");
225
+ });
226
+
227
+ $('#feedbackToggle').click(function() {
228
+ $('#feedbackSubmenu').toggle();
229
+ });
230
+ $("#sendFeedback").click(function() {
231
+ sendFeedback($( "input:radio[name=rating]:checked" ).val(), $("#feedback").val());
232
+ feedback_response(this, "Sending...");
233
+ });
234
+
235
+ $("#editSlide").click(function() {
236
+ editSlide();
237
+ closeMenu();
238
+ });
239
+
240
+ $('#closeMenu, #sidebarExit').click(function() {
241
+ closeMenu();
242
+ });
243
+
244
+ function closeMenu() {
245
+ $('#feedbackSidebar, #sidebarExit').hide();
246
+ toggleKeybinding('on');
205
247
  }
206
- else {
207
- var hSlide = parseFloat($("#preso").height());
208
- var wSlide = parseFloat($("#preso").width());
209
- var hBody = parseFloat($("html").height());
210
- var wBody = parseFloat($("html").width());
211
-
212
- newZoom = Math.min(hBody/hSlide, wBody/wSlide) - 0.04;
213
-
214
- $(".zoomed").css("zoom", newZoom);
215
- $(".zoomed").css("-ms-zoom", newZoom);
216
- $(".zoomed").css("-webkit-zoom", newZoom);
217
- $(".zoomed").css("-moz-transform", "scale("+newZoom+")");
218
- $(".zoomed").css("-moz-transform-origin", "left top");
248
+
249
+ function feedback_response(elem, response) {
250
+ var originalText = $(elem).text();
251
+ $(elem).text(response);
252
+ window.setTimeout(function() {
253
+ $(elem).parent().hide();
254
+ closeMenu();
255
+ $(elem).text(originalText);
256
+ }, 1000);
219
257
  }
220
258
  }
221
259
 
222
260
  function setupMenu() {
223
- $('#navmenu').hide();
261
+ var nav = $("<ul>"),
262
+ currentSection = '',
263
+ sectionUL = '';
264
+
265
+ slides.each(function(s, slide){
266
+ var slidePath = $(slide)
267
+ .find(".content")
268
+ .attr('ref')
269
+ .split('/')
270
+ .shift();
271
+ var headers = $(slide).children("h1, h2");
272
+ var slideTitle = '';
273
+
274
+ if (currentSection !== slidePath) {
275
+ currentSection = slidePath;
276
+ var newSection = $("<li>");
277
+ var icon = $('<i>')
278
+ .addClass('fa fa-angle-down');
279
+ var sectionLink = $("<a>")
280
+ .addClass('navSection')
281
+ .attr('href', '#')
282
+ .text(slidePath)
283
+ .append(icon)
284
+ .click(function() {
285
+ $(this).next().toggle();
286
+ return false;
287
+ });
288
+ sectionUL = $("<ul>");
289
+ newSection.append(sectionLink, sectionUL);
290
+ nav.append(newSection);
291
+ }
224
292
 
225
- var currSlide = 0
226
- var menu = new ListMenu()
293
+ if (headers.length > 0) {
294
+ slideTitle = headers.first().text();
295
+ } else {
296
+ slideTitle = $(slide)
297
+ .find(".content")
298
+ .text()
299
+ .substr(0, 20);
300
+ }
227
301
 
228
- slides.each(function(s, elem) {
229
- content = $(elem).find(".content")
230
- shortTxt = $(content).text().substr(0, 20)
231
- path = $(content).attr('ref').split('/')
232
- currSlide += 1
233
- menu.addItem(path, shortTxt, currSlide)
234
- })
302
+ var navLink = $("<a>")
303
+ .addClass('navItem')
304
+ .attr('rel', s)
305
+ .attr('href', '#')
306
+ .text((s + 1) + ". " + slideTitle)
307
+ .click(function() {
308
+ gotoSlide(s);
309
+ if (typeof slaveWindow !== 'undefined' && slaveWindow !== null) {
310
+ slaveWindow.gotoSlide(s, false);
311
+ postSlide();
312
+ update();
313
+ }
314
+ return false;
315
+ });
316
+ var navItem = $("<li>").append(navLink);
235
317
 
236
- $('#navigation').html(menu.getList())
237
- $('#navmenu').menu({
238
- content: $('#navigation').html(),
239
- flyOut: true
240
- });
318
+ sectionUL.append(navItem);
319
+ });
320
+
321
+ // can't use .children.replaceWith() because this starts out empty...
322
+ $("#navigation").empty();
323
+ $("#navigation").append(nav);
241
324
  }
242
325
 
243
326
  function checkSlideParameter() {
@@ -369,21 +452,15 @@ function showSlide(back_step, updatepv) {
369
452
 
370
453
  }
371
454
 
372
- // Update presenter view nav for current slide
373
- $( ".menu > ul > li > ul > li" ).each(function() {
374
- if ($(this).text().split(". ")[0] == slidenum+1) {
375
- $(".menu > ul > li > ul ").hide(); //Collapse nav
376
- $(".menu > ul > li > ul > li").removeClass('highlighted');
377
- $(this).addClass('highlighted'); //Highlight current menu item
378
- $(this).parent().show(); //Show nav block containing current slide
455
+ // Update nav
456
+ $('.highlighted').removeClass('highlighted');
457
+ $('#navigation ul ul').hide();
379
458
 
380
- if( ! mobile() ) {
381
- $(this).get(0).scrollIntoView(); //Scroll so current item is at the top of the view
382
- }
383
- }
384
- });
459
+ var active = $(".navItem").get(slidenum);
460
+ $(active).parent().addClass('highlighted');
461
+ $(active).parent().parent().show();
385
462
 
386
- return ret;
463
+ return ret;
387
464
  }
388
465
 
389
466
  function getSlideProgress()
@@ -506,12 +583,12 @@ function renderForm(form) {
506
583
  var action = form.attr("action");
507
584
  $.getJSON(action, function( data ) {
508
585
  //console.log(data);
509
- form.children('div.form.element').each(function() {
586
+ form.children('.element').each(function() {
510
587
  var key = $(this).attr('data-name');
511
588
 
512
589
  // add a counter label if we haven't already
513
- if( $(this).has('span.count').length == 0 ) {
514
- $(this).prepend('<span class="count"></span>');
590
+ if( $(this).next('.count').length === 0 ) {
591
+ $(this).after($('<h1>').addClass('count'));
515
592
  }
516
593
 
517
594
  $(this).find('ul > li > *').each(function() {
@@ -522,8 +599,6 @@ function renderForm(form) {
522
599
  });
523
600
 
524
601
  // replace all input widgets with spans for the bar chart
525
- var max = 5;
526
- var style = 0;
527
602
  $(this).children(':input').each(function() {
528
603
  switch( $(this).attr('type') ) {
529
604
  case 'text':
@@ -537,16 +612,21 @@ function renderForm(form) {
537
612
  case 'radio':
538
613
  case 'checkbox':
539
614
  // Just render these directly and migrate the label to inside the span
540
- var value = $(this).attr('value');
541
615
  var label = $(this).next('label');
542
- var classes = $(this).attr('class');
543
616
  var text = label.text();
617
+ var classes = $(this).attr('class');
544
618
 
545
619
  if(text.match(/^-+$/)) {
546
620
  $(this).remove();
547
- }
548
- else{
549
- $(this).replaceWith('<div class="item barstyle'+style+' '+classes+'" data-value="'+value+'">'+text+'</div>');
621
+ } else {
622
+ var resultDiv = $('<div>')
623
+ .addClass('item')
624
+ .attr('data-value', $(this).attr('value'))
625
+ .text(text);
626
+ if (classes) {
627
+ resultDiv.addClass(classes);
628
+ }
629
+ $(this).replaceWith(resultDiv);
550
630
  }
551
631
  label.remove();
552
632
  break;
@@ -554,26 +634,26 @@ function renderForm(form) {
554
634
  default:
555
635
  // select doesn't have a type attribute... yay html
556
636
  // poke inside to get options, then render each as a span and replace the select
557
- parent = $(this).parent();
637
+ var parent = $(this).parent();
558
638
 
559
639
  $(this).children('option').each(function() {
560
- var value = $(this).val();
561
640
  var text = $(this).text();
562
641
  var classes = $(this).attr('class');
563
642
 
564
643
  if(! text.match(/^-+$/)) {
565
- parent.append('<div class="item barstyle'+style+' '+classes+'" data-value="'+value+'">'+text+'</div>');
566
-
567
- // loop style counter
568
- style++; style %= max;
644
+ var resultDiv = $('<div>')
645
+ .addClass('item')
646
+ .attr('data-value', $(this).val())
647
+ .text(text);
648
+ if (classes) {
649
+ resultDiv.addClass(classes);
650
+ }
651
+ parent.append(resultDiv);
569
652
  }
570
653
  });
571
654
  $(this).remove();
572
655
  break;
573
656
  }
574
-
575
- // loop style counter
576
- style++; style %= max;
577
657
  });
578
658
 
579
659
  // only start counting and sizing bars if we actually have usable data
@@ -592,7 +672,7 @@ function renderForm(form) {
592
672
  });
593
673
 
594
674
  // insert the total into the counter label
595
- $(this).find('span.count').each(function() {
675
+ $(this).next('.count').each(function() {
596
676
  $(this).text(total);
597
677
  });
598
678
 
@@ -956,51 +1036,6 @@ function swipeRight() {
956
1036
  prevStep();
957
1037
  }
958
1038
 
959
- function ListMenu(s)
960
- {
961
- this.slide = s
962
- this.typeName = 'ListMenu'
963
- this.itemLength = 0;
964
- this.items = new Array();
965
- this.addItem = function (key, text, slide) {
966
- if (key.length > 1) {
967
- thisKey = key.shift()
968
- if (!this.items[thisKey]) {
969
- this.items[thisKey] = new ListMenu(slide)
970
- }
971
- this.items[thisKey].addItem(key, text, slide)
972
- } else {
973
- thisKey = key.shift()
974
- this.items[thisKey] = new ListMenuItem(text, slide)
975
- }
976
- }
977
- this.getList = function() {
978
- var newMenu = $("<ul>")
979
- for(var i in this.items) {
980
- var item = this.items[i]
981
- var domItem = $("<li>")
982
- if (item.typeName == 'ListMenu') {
983
- choice = $("<a rel=\"" + (item.slide - 1) + "\" href=\"#\">" + i + "</a>")
984
- domItem.append(choice)
985
- domItem.append(item.getList())
986
- }
987
- if (item.typeName == 'ListMenuItem') {
988
- choice = $("<a rel=\"" + (item.slide - 1) + "\" href=\"#\">" + item.slide + '. ' + item.textName + "</a>")
989
- domItem.append(choice)
990
- }
991
- newMenu.append(domItem)
992
- }
993
- return newMenu
994
- }
995
- }
996
-
997
- function ListMenuItem(t, s)
998
- {
999
- this.typeName = "ListMenuItem"
1000
- this.slide = s
1001
- this.textName = t
1002
- }
1003
-
1004
1039
  var removeResults = function() {
1005
1040
  $('.results').remove();
1006
1041
 
@@ -1052,7 +1087,6 @@ function executeCode() {
1052
1087
  // any code that can be run directly in the browser
1053
1088
  function executeLocalCode(lang, codeDiv) {
1054
1089
  var result = null;
1055
- var codeDiv = $(this);
1056
1090
 
1057
1091
  setExecutionSignal(true, codeDiv);
1058
1092
  setTimeout(function() { setExecutionSignal(false, codeDiv);}, 1000 );
@@ -1271,16 +1305,5 @@ function setupStats()
1271
1305
 
1272
1306
  /* Is this a mobile device? */
1273
1307
  function mobile() {
1274
- /*
1275
- return ( navigator.userAgent.match(/Android/i)
1276
- || navigator.userAgent.match(/webOS/i)
1277
- || navigator.userAgent.match(/iPhone/i)
1278
- || navigator.userAgent.match(/iPad/i)
1279
- || navigator.userAgent.match(/iPod/i)
1280
- || navigator.userAgent.match(/BlackBerry/i)
1281
- || navigator.userAgent.match(/Windows Phone/i)
1282
- );
1283
- */
1284
-
1285
1308
  return ( $(window).width() <= 480 )
1286
1309
  }