trickster 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.gitignore +16 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +2 -0
  4. data/README.rdoc +57 -13
  5. data/Rakefile +120 -0
  6. data/TODO +4 -0
  7. data/bin/trickster +66 -24
  8. data/css/themes-orig/arta.css +155 -0
  9. data/css/themes-orig/ascetic.css +50 -0
  10. data/css/themes-orig/brown_paper.css +102 -0
  11. data/css/themes-orig/brown_papersq.png +0 -0
  12. data/css/themes-orig/dark.css +101 -0
  13. data/css/themes-orig/default.css +132 -0
  14. data/css/themes-orig/far.css +111 -0
  15. data/css/themes-orig/github.css +131 -0
  16. data/css/themes-orig/googlecode.css +144 -0
  17. data/css/themes-orig/idea.css +121 -0
  18. data/css/themes-orig/ir_black.css +98 -0
  19. data/css/themes-orig/magula.css +119 -0
  20. data/css/themes-orig/monokai.css +112 -0
  21. data/css/themes-orig/pojoaque.css +104 -0
  22. data/css/themes-orig/pojoaque.jpg +0 -0
  23. data/css/themes-orig/rainbow.css +114 -0
  24. data/css/themes-orig/school_book.css +109 -0
  25. data/css/themes-orig/school_book.png +0 -0
  26. data/css/themes-orig/solarized_dark.css +88 -0
  27. data/css/themes-orig/solarized_light.css +88 -0
  28. data/css/themes-orig/sunburst.css +148 -0
  29. data/css/themes-orig/tomorrow-night-blue.css +42 -0
  30. data/css/themes-orig/tomorrow-night-bright.css +41 -0
  31. data/css/themes-orig/tomorrow-night-eighties.css +41 -0
  32. data/css/themes-orig/tomorrow-night.css +42 -0
  33. data/css/themes-orig/tomorrow.css +39 -0
  34. data/css/themes-orig/vs.css +85 -0
  35. data/css/themes-orig/xcode.css +154 -0
  36. data/css/themes-orig/zenburn.css +113 -0
  37. data/css/themes/arta.css +186 -0
  38. data/css/themes/ascetic.css +81 -0
  39. data/css/themes/brown_paper.css +133 -0
  40. data/css/themes/custom.scss +322 -0
  41. data/css/themes/dark.css +132 -0
  42. data/css/themes/default.css +163 -0
  43. data/css/themes/far.css +142 -0
  44. data/css/themes/github.css +162 -0
  45. data/css/themes/googlecode.css +175 -0
  46. data/css/themes/idea.css +152 -0
  47. data/css/themes/ir_black.css +129 -0
  48. data/css/themes/magula.css +150 -0
  49. data/css/themes/monokai.css +143 -0
  50. data/css/themes/pojoaque.css +135 -0
  51. data/css/themes/rainbow.css +145 -0
  52. data/css/themes/school_book.css +140 -0
  53. data/css/themes/solarized_dark.css +119 -0
  54. data/css/themes/solarized_light.css +119 -0
  55. data/css/themes/sunburst.css +179 -0
  56. data/css/themes/tomorrow-night-blue.css +73 -0
  57. data/css/themes/tomorrow-night-bright.css +72 -0
  58. data/css/themes/tomorrow-night-eighties.css +72 -0
  59. data/css/themes/tomorrow-night.css +73 -0
  60. data/css/themes/tomorrow.css +70 -0
  61. data/css/themes/vs.css +116 -0
  62. data/css/themes/xcode.css +185 -0
  63. data/css/themes/zenburn.css +144 -0
  64. data/erb/index.html.erb +2 -2
  65. data/features/build.feature +18 -0
  66. data/features/init.feature +57 -0
  67. data/features/step_definitions/trickster_steps.rb +78 -0
  68. data/features/support/env.rb +15 -0
  69. data/features/update.feature +33 -0
  70. data/js/trickster.js +1 -1
  71. data/lib/trickster.rb +2 -0
  72. data/lib/trickster/copier.rb +11 -0
  73. data/lib/trickster/file_copier.rb +1 -8
  74. data/lib/trickster/renderer/code_renderer.rb +47 -10
  75. data/lib/trickster/theme_copier.rb +16 -0
  76. data/lib/trickster/version.rb +1 -1
  77. data/notes.txt.md +56 -0
  78. data/test/jasmine.yml +4 -0
  79. data/test/js/bullets_spec.js +82 -0
  80. data/test/js/sizer_spec.js +244 -0
  81. data/test/js/trickster_spec.js +10 -0
  82. data/test/js/utils_spec.js +56 -0
  83. data/test/slide_parser_test.rb +50 -0
  84. data/test/slide_renderer_test.rb +316 -0
  85. data/{css → test/slideshow-with-sass/css}/highlight-solarized_light.min.css +0 -0
  86. data/test/slideshow-with-sass/css/normalize.css +375 -0
  87. data/test/slideshow-with-sass/css/styles.scss +66 -0
  88. data/test/slideshow-with-sass/js/bullets.js +83 -0
  89. data/test/slideshow-with-sass/js/custom.js +11 -0
  90. data/test/slideshow-with-sass/js/lib/highlight-7.1.min.js +1 -0
  91. data/test/slideshow-with-sass/js/lib/jquery-1.8.0.min.js +2 -0
  92. data/test/slideshow-with-sass/js/lib/jquerytypewriter.js +54 -0
  93. data/test/slideshow-with-sass/js/lib/underscore-1.3.3.min.js +32 -0
  94. data/test/slideshow-with-sass/js/sizer.js +149 -0
  95. data/test/slideshow-with-sass/js/trickster.js +216 -0
  96. data/test/slideshow-with-sass/js/utils.js +19 -0
  97. data/test/slideshow-with-sass/rudy.png +0 -0
  98. data/test/slideshow-with-sass/slides +47 -0
  99. data/test/slideshow/css/highlight-solarized_light.min.css +37 -0
  100. data/test/slideshow/css/normalize.css +375 -0
  101. data/test/slideshow/css/styles.css +66 -0
  102. data/test/slideshow/css/theme.css +163 -0
  103. data/test/slideshow/index.html +77 -0
  104. data/test/slideshow/js/bullets.js +83 -0
  105. data/test/slideshow/js/custom.js +11 -0
  106. data/test/slideshow/js/lib/highlight-7.1.min.js +1 -0
  107. data/test/slideshow/js/lib/jquery-1.8.0.min.js +2 -0
  108. data/test/slideshow/js/lib/jquerytypewriter.js +54 -0
  109. data/test/slideshow/js/lib/underscore-1.3.3.min.js +32 -0
  110. data/test/slideshow/js/sizer.js +149 -0
  111. data/test/slideshow/js/trickster.js +216 -0
  112. data/test/slideshow/js/utils.js +19 -0
  113. data/test/slideshow/rudy.png +0 -0
  114. data/test/slideshow/slides +47 -0
  115. data/test/test_helper.rb +11 -0
  116. data/trickster.gemspec +27 -0
  117. data/trickster.rdoc +44 -8
  118. metadata +348 -62
  119. data/js/lib/highlight-fc32801.min.js +0 -4601
@@ -0,0 +1,32 @@
1
+ // Underscore.js 1.3.3
2
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Underscore is freely distributable under the MIT license.
4
+ // Portions of Underscore are inspired or borrowed from Prototype,
5
+ // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
+ // For all details and documentation:
7
+ // http://documentcloud.github.com/underscore
8
+ (function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9
+ c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
10
+ g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
11
+ c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
12
+ a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
13
+ c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
14
+ a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15
+ function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
16
+ (e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
17
+ j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
18
+ 0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
19
+ e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
20
+ i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
21
+ 1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
22
+ i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
23
+ g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
24
+ return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
25
+ c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
26
+ function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
27
+ b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
28
+ b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
29
+ function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
30
+ u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
31
+ b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
32
+ this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
@@ -0,0 +1,149 @@
1
+ var Sizer = function() {
2
+ function isCodeSlide(element) { return (element.hasClass("CODE") || element.hasClass("COMMANDLINE")); }
3
+ function scrollWidth(element) { return element[0].scrollWidth; }
4
+ function scrollHeight(element) { return element[0].scrollHeight; }
5
+
6
+ function linesNotAllSameHeight(element) {
7
+ var heights = {};
8
+ var selector = ".line";
9
+ if (element.find(selector).length == 0) {
10
+ selector = ".cli-line";
11
+ }
12
+ element.find(selector).each(function(index,thisElement) {
13
+ if ($(thisElement).height() != 0) {
14
+ heights[$(thisElement).height()] = true;
15
+ }
16
+ });
17
+ return Object.keys(heights).length > 1;
18
+ }
19
+
20
+ /**
21
+ * @param element JQueryElement element to shrink
22
+ * @param maxTries int max attempts at shrinking (controls for infinite loops)
23
+ * @param shouldShrink function given the element, returns true if the element should be shrunken more
24
+ */
25
+ function shrinkElement(element,maxTries,shouldShrink,step) {
26
+ var fontSize = parseInt(element.css("font-size"));
27
+ var count = 0;
28
+ var STEP = 10;
29
+ if (step) {
30
+ STEP = step;
31
+ }
32
+ while (shouldShrink(element) && (count < maxTries)) {
33
+ fontSize -= STEP;
34
+ element.css("font-size",fontSize);
35
+ if (isCodeSlide(element)) {
36
+ element.css("margin-top",-1 * fontSize);
37
+ }
38
+ count += 1;
39
+ }
40
+ return count == maxTries;
41
+ }
42
+
43
+ function shrinkToPreventWrapping(element) {
44
+ if (!isCodeSlide(element)) { return false; }
45
+ return shrinkElement(element,20,linesNotAllSameHeight);
46
+ }
47
+
48
+ function shrinkToFitWidth(element,maxWidth) {
49
+ if (isCodeSlide(element)) { return false; }
50
+ var shouldShrink = function(elem) {
51
+ return (scrollWidth(element) > maxWidth);
52
+ };
53
+ return shrinkElement(element,10,shouldShrink);
54
+ }
55
+ function shrinkToFitHeight(element,maxHeight) {
56
+ var step = 10;
57
+ if (isCodeSlide(element)) {
58
+ step = 4;
59
+ }
60
+ var shouldShrink = function(elem) {
61
+ return (scrollHeight(element) > maxHeight);
62
+ };
63
+ return shrinkElement(element,10,shouldShrink,step);
64
+ }
65
+
66
+ function resizeImageSlide(slide,maxWidth,maxHeight) {
67
+ var img = slide.find("img");
68
+ var width = maxWidth;
69
+ var height = maxHeight;
70
+ var widthDiff = img.width() - width;
71
+ var heightDiff = img.height() - height;
72
+ if ((widthDiff > 0) || (heightDiff > 0)) {
73
+ if (widthDiff > heightDiff) {
74
+ img.width(width);
75
+ }
76
+ else {
77
+ img.height(height);
78
+ }
79
+ }
80
+ }
81
+
82
+ function preResize(element) {
83
+ if (element.hasClass("COMMANDLINE")) {
84
+ element.find(".cli-element").each(function(index,thisElement) {
85
+ $(thisElement).css("display","inline")
86
+ });
87
+ }
88
+ }
89
+
90
+ function postResize(element) {
91
+ if (element.hasClass("COMMANDLINE")) {
92
+ element.find(".cli-element").each(function(index,thisElement) {
93
+ $(thisElement).css("display","none")
94
+ });
95
+ }
96
+ }
97
+
98
+ function increaseSize(element,fontSize) {
99
+ element.css("font-size",fontSize);
100
+ var results = [scrollWidth(element),element.height()];
101
+ return results;
102
+ }
103
+
104
+ function resizeNonImageSlide(element,maxWidth,maxHeight) {
105
+ preResize(element);
106
+ var currentFontSize = parseInt(element.css("font-size"));
107
+ var currentSize = increaseSize(element,currentFontSize);
108
+ var newFontSize = currentFontSize + 10;
109
+
110
+ for(var i=0;i<3;i = i + 1) {
111
+ if (newFontSize > currentFontSize) {
112
+ newSize = increaseSize(element,newFontSize);
113
+ rise = newFontSize - currentFontSize;
114
+ runWidth = newSize[0] - currentSize[0];
115
+ runHeight = newSize[1] - currentSize[1];
116
+
117
+ currentFontSize = newFontSize;
118
+ currentSize = newSize;
119
+ if (isCodeSlide(element)) {
120
+ element.css("margin-top",-1 * newFontSize);
121
+ newFontSize = Math.floor(rise * maxHeight / runHeight);
122
+ }
123
+ else if (element.hasClass("BULLETS")) {
124
+ newFontSize = Math.floor(rise * maxHeight / runHeight);
125
+ }
126
+ else {
127
+ newFontSize = Math.floor((rise * maxWidth / runWidth, rise * maxHeight / runHeight) / 2);
128
+ }
129
+ }
130
+ }
131
+ shrinkToPreventWrapping(element);
132
+ shrinkToFitWidth(element,maxWidth);
133
+ shrinkToFitHeight(element,maxHeight);
134
+ postResize(element);
135
+ }
136
+
137
+ return {
138
+ sizeFunction: function(maxWidth,maxHeight) {
139
+ return function(element) {
140
+ if (element.hasClass("IMAGE")) {
141
+ resizeImageSlide(element,maxWidth,maxHeight);
142
+ }
143
+ else {
144
+ resizeNonImageSlide(element,maxWidth,maxHeight);
145
+ }
146
+ };
147
+ }
148
+ };
149
+ }();
@@ -0,0 +1,216 @@
1
+ var TricksterDefaultConfig = {
2
+ /** Padding between max width and max font size */
3
+ padding: 128,
4
+ /** Time, in ms, to transition between slides */
5
+ transitionTime: 200,
6
+ /** Time, in ms, that it should take to type each command */
7
+ typingTime: 1000,
8
+ /** Keycodes that advance to the next slide */
9
+ advanceKeycodes: [74, // j
10
+ 39, // right arrow
11
+ 34, // Kensington presenter right arrow
12
+ 32], // space bar
13
+ /** Keycodes that go back to the previous slide */
14
+ backKeycodes: [75, // k
15
+ 37, // left arrow
16
+ 33, // Kensington presenter left arrow
17
+ 8], // delete
18
+ startOverKeycodes: [66], // Kensington presenter down/stop
19
+ /** These keycodes, if encountered, will not be sent along
20
+ to the browser. Useful if there might be some vertical
21
+ scrolling and 32/33/34 would otherwise scroll */
22
+ keyCodesPreventingDefault: [ 34, 32, 33 ]
23
+ };
24
+ /** Loads Trickster.
25
+ * config: configuration, or TricksterDefaultConfig to get the defaults
26
+ * functions: override helper functions
27
+ */
28
+ var TricksterLoader = function(config,functions) {
29
+ var slides = Utils.fOr(functions.slides,function() {
30
+ return $("section");
31
+ });
32
+ var browserWindow = Utils.fOr(functions.browserWindow,function() {
33
+ return {
34
+ width: $(window).width(),
35
+ height: $(window).height()
36
+ };
37
+ });
38
+ var keyboardBindings = Utils.fOr(functions.keyboardBindings,function() {
39
+ return $(window);
40
+ });
41
+
42
+ var strikeThroughCode = Utils.fOr(functions.strikeThroughCode,function() {
43
+ $("code").each(function() {
44
+ if ($(this).attr("data-strikeouts")) {
45
+ var strikes = $(this).attr("data-strikeouts").split(",");
46
+ for(var index in strikes) {
47
+ var line = parseInt(strikes[index]);
48
+ $(this).find(".line-" + line).css("text-decoration","line-through");
49
+ }
50
+ }
51
+ });
52
+ });
53
+
54
+ var syntaxHighlighter = Utils.fOr(functions.syntaxHighlighter,function() {
55
+ return {
56
+ highlight: function() {
57
+ hljs.lineNodes = true;
58
+ hljs.initHighlighting();
59
+ strikeThroughCode();
60
+ }
61
+ }
62
+ });
63
+ var bindKeys = Utils.fOr(functions.bindKeys,function(keyCodes,f) {
64
+ $(window).keyup(function(event) {
65
+ if (keyCodes.indexOf(event.which) != -1) {
66
+ f();
67
+ }
68
+ });
69
+ });
70
+ var preventDefaultKeyCodeAction = Utils.fOr(functions.preventDefaultKeyCodeAction,function(keyCodes) {
71
+ $(window).keydown(function(event) {
72
+ if (keyCodes.indexOf(event.which) != -1) {
73
+ event.preventDefault();
74
+ }
75
+ });
76
+ });
77
+
78
+ function currentSlide(whichSlide) {
79
+ if (typeof whichSlide === "undefined") {
80
+ whichSlide = Trickster.currentSlide;
81
+ }
82
+ return slides().eq(whichSlide);
83
+ };
84
+
85
+ function initCurrentSlide() {
86
+ var slideNumber = 0;
87
+ if (document.location.hash !== "") {
88
+ slideNumber = parseInt(document.location.hash.replace("#",""));
89
+ Trickster.currentSlide = slideNumber;
90
+ }
91
+ applySlideClassToBody(currentSlide(slideNumber));
92
+ };
93
+
94
+ function applySlideClassToBody(slide) {
95
+ $("body").attr("class",slide.attr("class"));
96
+ if (slide.attr("data-background")) {
97
+ $("body").css("background","#" + slide.attr("data-background"));
98
+ }
99
+ else {
100
+ $("body").css("background","");
101
+ }
102
+ }
103
+
104
+ function changeSlides(nextSlide,afterChanges) {
105
+ if ((nextSlide != 0) && (nextSlide != Trickster.previousSlide)){
106
+ Trickster.previousSlide = Trickster.currentSlide;
107
+ }
108
+ afterChanges = Utils.f(afterChanges);
109
+ var transitionTime = config.transitionTime / 2;
110
+ if (currentSlide().attr("data-transition")) {
111
+ transitionTime = parseInt(currentSlide().attr("data-transitionTime"));
112
+ }
113
+ currentSlide().fadeOut(transitionTime, function() {
114
+ applySlideClassToBody(currentSlide(nextSlide));
115
+ currentSlide(nextSlide).fadeIn(transitionTime, function() {
116
+ Trickster.currentSlide = nextSlide;
117
+ window.history.replaceState({},"",document.URL.replace(/#.*$/,"") + "#" + Trickster.currentSlide);
118
+ afterChanges();
119
+ });
120
+ });
121
+ };
122
+
123
+ function sizeAllToFit() {
124
+ slides().each(function(index,element) {
125
+ // Order matters here
126
+ var sizeToFit = Sizer.sizeFunction(browserWindow().width,browserWindow().height);
127
+ sizeToFit($(element));
128
+ });
129
+ }
130
+
131
+ function setupKeyBindings() {
132
+ bindKeys(config.advanceKeycodes,Trickster.advance);
133
+ bindKeys(config.backKeycodes,Trickster.back);
134
+ bindKeys(config.startOverKeycodes,Trickster.startOver);
135
+ preventDefaultKeyCodeAction(config.keyCodesPreventingDefault);
136
+ bindKeys([189],Trickster.shrink); // -
137
+ bindKeys([187],Trickster.embiggen); // +
138
+ }
139
+
140
+ function hideAllSlides() {
141
+ $("section").css("display","none");
142
+ $("li").css("visibility","hidden");
143
+ $("section.COMMANDLINE .cli-element").css("display","none");
144
+ }
145
+
146
+ var Bullets = TricksterBullets(currentSlide,config);
147
+ return {
148
+ /** State */
149
+ currentSlide: 0,
150
+ totalSlides: 1,
151
+ previousSlide: 0,
152
+
153
+ /** Set everything up for the slideshow */
154
+ load: function() {
155
+ // Order matters here
156
+ Trickster.totalSlides = slides().length;
157
+ initCurrentSlide();
158
+ setupKeyBindings();
159
+ syntaxHighlighter().highlight();
160
+ sizeAllToFit();
161
+ hideAllSlides();
162
+ currentSlide().fadeIn(config.transitionTime / 2);
163
+ },
164
+
165
+ /** Reduce the font-size of the current slide slightly */
166
+ shrink: function() {
167
+ var currentSize = parseInt(currentSlide().css("font-size"));
168
+ currentSlide().css("font-size",currentSize - 4);
169
+ if (currentSlide().hasClass("CODE") || currentSlide().hasClass("COMMANDLINE")) {
170
+ currentSlide().css("margin-top",-1 * (currentSize - 4));
171
+ }
172
+ },
173
+ /** Increase the font-size of the current slide slightly */
174
+ embiggen: function() {
175
+ var currentSize = parseInt(currentSlide().css("font-size"));
176
+ currentSlide().css("font-size",currentSize + 4);
177
+ if (currentSlide().hasClass("CODE") || currentSlide().hasClass("COMMANDLINE")) {
178
+ currentSlide().css("margin-top",-1 * (currentSize - 4));
179
+ }
180
+ },
181
+
182
+ startOver: function() {
183
+ if (Trickster.currentSlide == 0) {
184
+ changeSlides(Trickster.previousSlide, Bullets.rehideBullets());
185
+ }
186
+ else {
187
+ changeSlides(0,Bullets.rehideBullets());
188
+ }
189
+ },
190
+
191
+ /** Move forward one slide */
192
+ advance: function() {
193
+ if (Bullets.hasBulletsToAdvanceFirst()) {
194
+ Bullets.advanceToNextBullet();
195
+ }
196
+ else {
197
+ var nextSlide = Trickster.currentSlide + 1;
198
+ if (nextSlide >= Trickster.totalSlides) {
199
+ nextSlide = 0;
200
+ }
201
+ changeSlides(nextSlide, Bullets.rehideBullets());
202
+ }
203
+ },
204
+
205
+ /** Move back one slide */
206
+ back: function() {
207
+ var nextSlide = Trickster.currentSlide - 1;
208
+ if (nextSlide < 0) {
209
+ nextSlide = Trickster.totalSlides - 1;
210
+ }
211
+ changeSlides(nextSlide, Bullets.rehideBullets());
212
+ }
213
+ };
214
+ };
215
+ // 66 - Kensington down/stop
216
+ // 116 - Kensington up/laser
@@ -0,0 +1,19 @@
1
+ var Utils = function() {
2
+ /** If possibleFunction is undefined, use otherFunction */
3
+ function fOr(possibleFunction,otherFunction) {
4
+ if (typeof possibleFunction != "undefined") {
5
+ return possibleFunction;
6
+ }
7
+ else {
8
+ return otherFunction;
9
+ }
10
+ };
11
+ /** Turn possibly-undefined into a function */
12
+ function f(possibleFunction) {
13
+ return fOr(possibleFunction,function() {});
14
+ };
15
+ return {
16
+ f: f,
17
+ fOr: fOr
18
+ };
19
+ }();
Binary file
@@ -0,0 +1,47 @@
1
+ Title of your slideshow
2
+ !TITLE
3
+ Title of your slideshow
4
+ Subtitle
5
+ Sub-sub title
6
+
7
+ !SECTION: background=dddddd
8
+ A section
9
+
10
+ !BULLETS
11
+ A bullet list
12
+ * can use any
13
+ - reasonable
14
+ + bullet
15
+
16
+ !CODE: callout=3,-4,5
17
+ class YourCode
18
+
19
+ def initialize(will)
20
+ @be_highlighted
21
+ end
22
+
23
+ end
24
+
25
+ !IMAGE
26
+ rudy.png
27
+
28
+ !COMMANDLINE
29
+ > ls -ltr
30
+ -rw-r--r-- 1 David staff 1697 Aug 28 10:03 notes.txt.md
31
+ -rw-r--r-- 1 David staff 97 Aug 28 10:03 trickster.rdoc
32
+ -rw-r--r-- 1 David staff 1339 Aug 28 10:03 Rakefile
33
+ -rw-r--r-- 1 David staff 25 Aug 28 10:03 Gemfile
34
+ drwxr-xr-x 7 David staff 238 Sep 10 16:53 js
35
+ drwxr-xr-x 6 David staff 204 Sep 10 16:53 features
36
+ drwxr-xr-x 3 David staff 102 Sep 10 16:53 erb
37
+ drwxr-xr-x 5 David staff 170 Sep 10 16:53 css
38
+ -rw-r--r-- 1 David staff 1254 Sep 10 16:53 trickster.gemspec
39
+ drwxr-xr-x 3 David staff 102 Sep 10 16:53 bin
40
+ -rw-r--r-- 1 David staff 150 Sep 10 16:53 TODO
41
+ -rw-r--r-- 1 David staff 1563 Sep 10 16:53 Gemfile.lock
42
+ drwxr-xr-x 4 David staff 136 Sep 10 16:58 lib
43
+ -rw-r--r-- 1 David staff 3991 Sep 10 17:01 README.rdoc
44
+ drwxr-xr-x 3 David staff 102 Sep 10 17:07 tmp
45
+ -rw-r--r-- 1 David staff 87290 Sep 10 17:07 results.html
46
+ drwxr-xr-x 9 David staff 306 Sep 10 17:19 test
47
+ > rm *