showoff 0.9.10.6 → 0.9.10.7

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: 451c6ca8036598422dbbc889ed67b1cb574f6bcd
4
- data.tar.gz: f423916c2003ed85acb0d97f27743b1d6969cbd9
3
+ metadata.gz: 7912a55347b4c5f15def2fb0f260993609fba24d
4
+ data.tar.gz: c224a40d9d832ee8dbfb92fbc187e7f7896e496d
5
5
  SHA512:
6
- metadata.gz: 5b82ad5e1c3920b7827cd3d687584a3d5b515f502cf3e5d2951adefd19bb544664f75e217fb2080646076bc90a64f85aaf4ea242eb14d5d8f6f33755331b6fc0
7
- data.tar.gz: 9cb4aba7936cec6edf5bc15c90c840316517442950b6d666ffb65ca50f697affe7d39f8f633d5636aa4e45ccfedf2ad065a8ae2bd4e6cf613cd659831eb85477
6
+ metadata.gz: 32fa15fe9ff154bb26737c7c35ae6e08560bc12b51a5bc65addad8012c34ba277697e1b1331d59d08f06a2ab818d31f63008decf51f15befd165e4e073ad97a2
7
+ data.tar.gz: 4625138c29121dec99bd54dce503b5a5d515329921725c81e79b589104711bba9d4795f5b3d9110000fd11650507e5d0fecffc6e74e2234f7d25bd5562b7c10a
data/lib/showoff.rb CHANGED
@@ -209,7 +209,7 @@ class ShowOff < Sinatra::Application
209
209
  end
210
210
  end
211
211
 
212
- slides.delete_if {|slide| slide.empty? }
212
+ slides.delete_if {|slide| slide.empty? and not slide.bg }
213
213
 
214
214
  final = ''
215
215
  if slides.size > 1
@@ -277,7 +277,7 @@ class ShowOff < Sinatra::Application
277
277
  classes = content_classes.join(' ')
278
278
  content = "<div"
279
279
  content += " id=\"#{id}\"" if id
280
- content += " style=\"background: url('file/#{slide.bg}') center no-repeat;\"" if slide.bg
280
+ content += " style=\"background-image: url('file/#{slide.bg}');\"" if slide.bg
281
281
  content += " class=\"slide #{classes}\" data-transition=\"#{transition}\">"
282
282
 
283
283
  # name the slide. If we've got multiple slides in this file, we'll have a sequence number
@@ -417,25 +417,26 @@ class ShowOff < Sinatra::Application
417
417
 
418
418
  # replace custom markup with html forms
419
419
  def build_forms(content, classes=[])
420
- classes.select { |cl| cl =~ /^form=(\w+)$/ }
420
+ title = classes.collect { |cl| $1 if cl =~ /^form=(\w+)$/ }.compact.first
421
421
  # only process slides marked as forms
422
- return content unless $1
422
+ return content if title.nil?
423
423
 
424
424
  begin
425
425
  tools = '<div class="tools">'
426
426
  tools << '<input type="button" class="display" value="Display Results">'
427
427
  tools << '<input type="submit" value="Save" disabled="disabled">'
428
428
  tools << '</div>'
429
- form = "<form id='#{$1}' action='/form/#{$1}' method='POST'>#{content}#{tools}</form>"
429
+ form = "<form id='#{title}' action='/form/#{title}' method='POST'>#{content}#{tools}</form>"
430
430
  doc = Nokogiri::HTML::DocumentFragment.parse(form)
431
431
  doc.css('p').each do |p|
432
432
  if p.text =~ /^(\w*) ?(?:->)? ?([^\*]*)? ?(\*?)= ?(.*)?$/
433
- id = $1
434
- name = $2.empty? ? $1 : $2
433
+ code = $1
434
+ id = "#{title}_#{code}"
435
+ name = $2.empty? ? code : $2
435
436
  required = ! $3.empty?
436
437
  rhs = $4
437
438
 
438
- p.replace form_element(id, name, required, rhs, p.text)
439
+ p.replace form_element(id, code, name, required, rhs, p.text)
439
440
  end
440
441
  end
441
442
  doc.to_html
@@ -446,50 +447,50 @@ class ShowOff < Sinatra::Application
446
447
  end
447
448
  end
448
449
 
449
- def form_element(id, name, required, rhs, text)
450
+ def form_element(id, code, name, required, rhs, text)
450
451
  required = required ? 'required' : ''
451
- str = "<div class='form element #{required}' id='#{id}'>"
452
+ str = "<div class='form element #{required}' id='#{id}' data-name='#{code}'>"
452
453
  str << "<label for='#{id}'>#{name}</label>"
453
454
  case rhs
454
455
  when /^\[\s+(\d*)\]$$/ # value = [ 5] (textarea)
455
- str << form_element_textarea(id, name, $1)
456
+ str << form_element_textarea(id, code, $1)
456
457
  when /^___+(?:\[(\d+)\])?$/ # value = ___[50] (text)
457
- str << form_element_text(id, name, $1)
458
+ str << form_element_text(id, code, $1)
458
459
  when /^\(x?\)/ # value = (x) option one () opt2 () opt3 -> option 3 (radio)
459
- str << form_element_radio(id, name, rhs.scan(/\((x?)\)\s*([^()]+)\s*/))
460
+ str << form_element_radio(id, code, rhs.scan(/\((x?)\)\s*([^()]+)\s*/))
460
461
  when /^\[x?\]/ # value = [x] option one [] opt2 [] opt3 -> option 3 (checkboxes)
461
- str << form_element_checkboxes(id, name, rhs.scan(/\[(x?)\] ?([^\[\]]+)/))
462
+ str << form_element_checkboxes(id, code, rhs.scan(/\[(x?)\] ?([^\[\]]+)/))
462
463
  when /^\{(.*)\}$/ # value = {BOS, SFO, (NYC)} (select shorthand)
463
- str << form_element_select(id, name, rhs.scan(/\(?\w+\)?/))
464
+ str << form_element_select(id, code, rhs.scan(/\(?\w+\)?/))
464
465
  when /^\{$/ # value = { (select)
465
- str << form_element_select_multiline(id, name, text)
466
+ str << form_element_select_multiline(id, code, text)
466
467
  when '' # value = (radio/checkbox list)
467
- str << form_element_multiline(id, name, text)
468
+ str << form_element_multiline(id, code, text)
468
469
  else
469
470
  @logger.warn "Unmatched form element: #{rhs}"
470
471
  end
471
472
  str << '</div>'
472
473
  end
473
474
 
474
- def form_element_text(id, name, length)
475
- "<input type='text' id='#{id}' name='#{id}' size='#{length}' />"
475
+ def form_element_text(id, code, length)
476
+ "<input type='text' id='#{id}_response' name='#{code}' size='#{length}' />"
476
477
  end
477
478
 
478
- def form_element_textarea(id, name, rows)
479
+ def form_element_textarea(id, code, rows)
479
480
  rows = 3 if rows.empty?
480
- "<textarea id='#{id}' name='#{id}' rows='#{rows}'></textarea>"
481
+ "<textarea id='#{id}_response' name='#{code}' rows='#{rows}'></textarea>"
481
482
  end
482
483
 
483
- def form_element_radio(id, name, items)
484
- form_element_check_or_radio_set('radio', id, name, items)
484
+ def form_element_radio(id, code, items)
485
+ form_element_check_or_radio_set('radio', id, code, items)
485
486
  end
486
487
 
487
- def form_element_checkboxes(id, name, items)
488
- form_element_check_or_radio_set('checkbox', id, name, items)
488
+ def form_element_checkboxes(id, code, items)
489
+ form_element_check_or_radio_set('checkbox', id, code, items)
489
490
  end
490
491
 
491
- def form_element_select(id, name, items)
492
- str = "<select id='#{id}' name='#{name}'>"
492
+ def form_element_select(id, code, items)
493
+ str = "<select id='#{id}_response' name='#{code}'>"
493
494
  str << '<option value="">----</option>'
494
495
 
495
496
  items.each do |item|
@@ -504,8 +505,8 @@ class ShowOff < Sinatra::Application
504
505
  str << '</select>'
505
506
  end
506
507
 
507
- def form_element_select_multiline(id, name, text)
508
- str = "<select id='#{id}' name='#{id}'>"
508
+ def form_element_select_multiline(id, code, text)
509
+ str = "<select id='#{id}_response' name='#{code}'>"
509
510
  str << '<option value="">----</option>'
510
511
 
511
512
  text.split("\n")[1..-1].each do |item|
@@ -523,7 +524,7 @@ class ShowOff < Sinatra::Application
523
524
  str << '</select>'
524
525
  end
525
526
 
526
- def form_element_multiline(id, name, text)
527
+ def form_element_multiline(id, code, text)
527
528
  str = '<ul>'
528
529
 
529
530
  text.split("\n")[1..-1].each do |item|
@@ -541,13 +542,13 @@ class ShowOff < Sinatra::Application
541
542
  end
542
543
 
543
544
  str << '<li>'
544
- str << form_element_check_or_radio(type, id, value, label, checked)
545
+ str << form_element_check_or_radio(type, id, code, value, label, checked)
545
546
  str << '</li>'
546
547
  end
547
548
  str << '</ul>'
548
549
  end
549
550
 
550
- def form_element_check_or_radio_set(type, id, name, items)
551
+ def form_element_check_or_radio_set(type, id, code, items)
551
552
  str = ''
552
553
  items.each do |item|
553
554
  checked = item[0].empty? ? '': "checked='checked'"
@@ -559,17 +560,17 @@ class ShowOff < Sinatra::Application
559
560
  value = label = item[1]
560
561
  end
561
562
 
562
- str << form_element_check_or_radio(type, id, value, label, checked)
563
+ str << form_element_check_or_radio(type, id, code, value, label, checked)
563
564
  end
564
565
  str
565
566
  end
566
567
 
567
- def form_element_check_or_radio(type, id, value, label, checked)
568
+ def form_element_check_or_radio(type, id, code, value, label, checked)
568
569
  # yes, value and id are conflated, because this is the id of the parent widget
569
570
 
570
- id = "#{id}[]" if type == 'checkbox'
571
- str = "<input type='#{type}' name='#{id}' id='#{value}' value='#{value}' #{checked} />"
572
- str << "<label for='#{value}'>#{label}</label>"
571
+ name = (type == 'checkbox') ? "#{code}[]" : code
572
+ str = "<input type='#{type}' name='#{name}' id='#{id}_#{value}' value='#{value}' #{checked} />"
573
+ str << "<label for='#{id}_#{value}'>#{label}</label>"
573
574
  end
574
575
 
575
576
  # TODO: deprecated
@@ -1,4 +1,4 @@
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.9.10.6'
3
+ SHOWOFF_VERSION = '0.9.10.7'
4
4
 
@@ -18,6 +18,13 @@
18
18
  -webkit-box-shadow:0 0 25px rgba(0,0,0,0.35);
19
19
  -moz-box-shadow:0 0 25px rgba(0,0,0,0.35);
20
20
  box-shadow:0 0 25px rgba(0,0,0,0.35);
21
+ background-repeat: no-repeat;
22
+ background-position: center;
23
+ background-size: cover;
24
+ }
25
+
26
+ #preso, .slide.background-fit {
27
+ background-size: contain;
21
28
  }
22
29
 
23
30
  #footer {
data/public/js/showoff.js CHANGED
@@ -182,6 +182,7 @@ function initializePresentation(prefix) {
182
182
  slaveWindow.renderForm($(this).closest('form').attr('id'));
183
183
  }
184
184
  catch (e) {
185
+ console.log(e);
185
186
  renderForm($(this).closest('form'));
186
187
  }
187
188
  });
@@ -495,7 +496,7 @@ function renderForm(form) {
495
496
  $.getJSON(action, function( data ) {
496
497
  //console.log(data);
497
498
  form.children('div.form.element').each(function() {
498
- var key = $(this).attr('id');
499
+ var key = $(this).attr('data-name');
499
500
  var sum = 0;
500
501
 
501
502
  $(this).find('ul > li > *').each(function() {
@@ -521,7 +522,7 @@ function renderForm(form) {
521
522
  case 'radio':
522
523
  case 'checkbox':
523
524
  // Just render these directly and migrate the label to inside the span
524
- var name = $(this).attr('id');
525
+ var value = $(this).attr('value');
525
526
  var label = $(this).next('label');
526
527
  var text = label.text();
527
528
 
@@ -529,7 +530,7 @@ function renderForm(form) {
529
530
  $(this).remove();
530
531
  }
531
532
  else{
532
- $(this).replaceWith('<div class="item barstyle'+style+'" id="'+name+'">'+text+'</div>');
533
+ $(this).replaceWith('<div class="item barstyle'+style+'" data-value="'+value+'">'+text+'</div>');
533
534
  }
534
535
  label.remove();
535
536
  break;
@@ -544,7 +545,7 @@ function renderForm(form) {
544
545
  var text = $(this).text();
545
546
 
546
547
  if(! text.match(/^-+$/)) {
547
- parent.append('<div class="item barstyle'+style+'" id="'+value+'">'+text+'</div>');
548
+ parent.append('<div class="item barstyle'+style+'" data-value="'+value+'">'+text+'</div>');
548
549
 
549
550
  // loop style counter
550
551
  style++; style %= max;
@@ -562,18 +563,26 @@ function renderForm(form) {
562
563
  if(data) {
563
564
  // double loop so we can handle re-renderings of the form
564
565
  $(this).find('.item').each(function() {
565
- var name = $(this).attr('id');
566
- var count = data[key][name];
566
+ var name = $(this).attr('data-value');
567
567
 
568
- if(count) { sum += count; }
568
+ if(key in data) {
569
+ var count = data[key][name];
570
+ if(count) { sum += count; }
571
+ }
569
572
  });
570
573
 
571
574
 
572
575
  $(this).find('.item').each(function() {
573
- var name = $(this).attr('id');
576
+ var name = $(this).attr('data-value');
574
577
  var oldCount = $(this).attr('data-count');
575
578
  var oldSum = $(this).attr('data-sum');
576
- var count = data[key][name] || 0;
579
+
580
+ if(key in data) {
581
+ var count = data[key][name] || 0;
582
+ }
583
+ else {
584
+ var count = 0;
585
+ }
577
586
 
578
587
  if(count != oldCount || sum != oldSum) {
579
588
  var percent = (sum) ? ((count/sum)*100)+'%' : '0%';
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10.6
4
+ version: 0.9.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra