trickster 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/README.rdoc +57 -13
- data/Rakefile +120 -0
- data/TODO +4 -0
- data/bin/trickster +66 -24
- data/css/themes-orig/arta.css +155 -0
- data/css/themes-orig/ascetic.css +50 -0
- data/css/themes-orig/brown_paper.css +102 -0
- data/css/themes-orig/brown_papersq.png +0 -0
- data/css/themes-orig/dark.css +101 -0
- data/css/themes-orig/default.css +132 -0
- data/css/themes-orig/far.css +111 -0
- data/css/themes-orig/github.css +131 -0
- data/css/themes-orig/googlecode.css +144 -0
- data/css/themes-orig/idea.css +121 -0
- data/css/themes-orig/ir_black.css +98 -0
- data/css/themes-orig/magula.css +119 -0
- data/css/themes-orig/monokai.css +112 -0
- data/css/themes-orig/pojoaque.css +104 -0
- data/css/themes-orig/pojoaque.jpg +0 -0
- data/css/themes-orig/rainbow.css +114 -0
- data/css/themes-orig/school_book.css +109 -0
- data/css/themes-orig/school_book.png +0 -0
- data/css/themes-orig/solarized_dark.css +88 -0
- data/css/themes-orig/solarized_light.css +88 -0
- data/css/themes-orig/sunburst.css +148 -0
- data/css/themes-orig/tomorrow-night-blue.css +42 -0
- data/css/themes-orig/tomorrow-night-bright.css +41 -0
- data/css/themes-orig/tomorrow-night-eighties.css +41 -0
- data/css/themes-orig/tomorrow-night.css +42 -0
- data/css/themes-orig/tomorrow.css +39 -0
- data/css/themes-orig/vs.css +85 -0
- data/css/themes-orig/xcode.css +154 -0
- data/css/themes-orig/zenburn.css +113 -0
- data/css/themes/arta.css +186 -0
- data/css/themes/ascetic.css +81 -0
- data/css/themes/brown_paper.css +133 -0
- data/css/themes/custom.scss +322 -0
- data/css/themes/dark.css +132 -0
- data/css/themes/default.css +163 -0
- data/css/themes/far.css +142 -0
- data/css/themes/github.css +162 -0
- data/css/themes/googlecode.css +175 -0
- data/css/themes/idea.css +152 -0
- data/css/themes/ir_black.css +129 -0
- data/css/themes/magula.css +150 -0
- data/css/themes/monokai.css +143 -0
- data/css/themes/pojoaque.css +135 -0
- data/css/themes/rainbow.css +145 -0
- data/css/themes/school_book.css +140 -0
- data/css/themes/solarized_dark.css +119 -0
- data/css/themes/solarized_light.css +119 -0
- data/css/themes/sunburst.css +179 -0
- data/css/themes/tomorrow-night-blue.css +73 -0
- data/css/themes/tomorrow-night-bright.css +72 -0
- data/css/themes/tomorrow-night-eighties.css +72 -0
- data/css/themes/tomorrow-night.css +73 -0
- data/css/themes/tomorrow.css +70 -0
- data/css/themes/vs.css +116 -0
- data/css/themes/xcode.css +185 -0
- data/css/themes/zenburn.css +144 -0
- data/erb/index.html.erb +2 -2
- data/features/build.feature +18 -0
- data/features/init.feature +57 -0
- data/features/step_definitions/trickster_steps.rb +78 -0
- data/features/support/env.rb +15 -0
- data/features/update.feature +33 -0
- data/js/trickster.js +1 -1
- data/lib/trickster.rb +2 -0
- data/lib/trickster/copier.rb +11 -0
- data/lib/trickster/file_copier.rb +1 -8
- data/lib/trickster/renderer/code_renderer.rb +47 -10
- data/lib/trickster/theme_copier.rb +16 -0
- data/lib/trickster/version.rb +1 -1
- data/notes.txt.md +56 -0
- data/test/jasmine.yml +4 -0
- data/test/js/bullets_spec.js +82 -0
- data/test/js/sizer_spec.js +244 -0
- data/test/js/trickster_spec.js +10 -0
- data/test/js/utils_spec.js +56 -0
- data/test/slide_parser_test.rb +50 -0
- data/test/slide_renderer_test.rb +316 -0
- data/{css → test/slideshow-with-sass/css}/highlight-solarized_light.min.css +0 -0
- data/test/slideshow-with-sass/css/normalize.css +375 -0
- data/test/slideshow-with-sass/css/styles.scss +66 -0
- data/test/slideshow-with-sass/js/bullets.js +83 -0
- data/test/slideshow-with-sass/js/custom.js +11 -0
- data/test/slideshow-with-sass/js/lib/highlight-7.1.min.js +1 -0
- data/test/slideshow-with-sass/js/lib/jquery-1.8.0.min.js +2 -0
- data/test/slideshow-with-sass/js/lib/jquerytypewriter.js +54 -0
- data/test/slideshow-with-sass/js/lib/underscore-1.3.3.min.js +32 -0
- data/test/slideshow-with-sass/js/sizer.js +149 -0
- data/test/slideshow-with-sass/js/trickster.js +216 -0
- data/test/slideshow-with-sass/js/utils.js +19 -0
- data/test/slideshow-with-sass/rudy.png +0 -0
- data/test/slideshow-with-sass/slides +47 -0
- data/test/slideshow/css/highlight-solarized_light.min.css +37 -0
- data/test/slideshow/css/normalize.css +375 -0
- data/test/slideshow/css/styles.css +66 -0
- data/test/slideshow/css/theme.css +163 -0
- data/test/slideshow/index.html +77 -0
- data/test/slideshow/js/bullets.js +83 -0
- data/test/slideshow/js/custom.js +11 -0
- data/test/slideshow/js/lib/highlight-7.1.min.js +1 -0
- data/test/slideshow/js/lib/jquery-1.8.0.min.js +2 -0
- data/test/slideshow/js/lib/jquerytypewriter.js +54 -0
- data/test/slideshow/js/lib/underscore-1.3.3.min.js +32 -0
- data/test/slideshow/js/sizer.js +149 -0
- data/test/slideshow/js/trickster.js +216 -0
- data/test/slideshow/js/utils.js +19 -0
- data/test/slideshow/rudy.png +0 -0
- data/test/slideshow/slides +47 -0
- data/test/test_helper.rb +11 -0
- data/trickster.gemspec +27 -0
- data/trickster.rdoc +44 -8
- metadata +348 -62
- data/js/lib/highlight-fc32801.min.js +0 -4601
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
4
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
5
|
+
|
6
|
+
Before do
|
7
|
+
# Using "announce" causes massive warnings on 1.9.2
|
8
|
+
@puts = true
|
9
|
+
@original_rubylib = ENV['RUBYLIB']
|
10
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
After do
|
14
|
+
ENV['RUBYLIB'] = @original_rubylib
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: I can update my slideshow after I upgrade trickster
|
2
|
+
Since the slideshow is self-contained
|
3
|
+
I need a way to get the latest features of trickster
|
4
|
+
|
5
|
+
Scenario Outline: Can update a slideshow
|
6
|
+
Given a slideshow in "test_slideshow"
|
7
|
+
And the JS files and CSS files in "test_slideshow" are out-of-date
|
8
|
+
When I cd to "test_slideshow"
|
9
|
+
And I successfully run `trickster update <args>`
|
10
|
+
Then the JS files and CSS files in "test_slideshow" should be up-to-date
|
11
|
+
And a file named "css/theme.css" should exist
|
12
|
+
But "css/styles.css" in "test_slideshow" should not have been touched
|
13
|
+
And "js/custom.js" in "test_slideshow" should not have been touched
|
14
|
+
And "css/theme.css" in "test_slideshow" should not have been touched
|
15
|
+
|
16
|
+
Examples:
|
17
|
+
| args |
|
18
|
+
| |
|
19
|
+
| files |
|
20
|
+
|
21
|
+
Scenario: Can update the theme
|
22
|
+
Given a slideshow in "test_slideshow"
|
23
|
+
And the JS files and CSS files in "test_slideshow" are out-of-date
|
24
|
+
When I cd to "test_slideshow"
|
25
|
+
And I successfully run `trickster update theme`
|
26
|
+
Then "css/theme.css" in "test_slideshow" should be identical to "default.css"
|
27
|
+
|
28
|
+
Scenario: Can update the theme
|
29
|
+
Given a slideshow in "test_slideshow"
|
30
|
+
And the JS files and CSS files in "test_slideshow" are out-of-date
|
31
|
+
When I cd to "test_slideshow"
|
32
|
+
And I successfully run `trickster update theme -t github`
|
33
|
+
Then "css/theme.css" in "test_slideshow" should be identical to "github.css"
|
data/js/trickster.js
CHANGED
@@ -44,7 +44,7 @@ var TricksterLoader = function(config,functions) {
|
|
44
44
|
if ($(this).attr("data-strikeouts")) {
|
45
45
|
var strikes = $(this).attr("data-strikeouts").split(",");
|
46
46
|
for(var index in strikes) {
|
47
|
-
var line = parseInt(strikes[index])
|
47
|
+
var line = parseInt(strikes[index]);
|
48
48
|
$(this).find(".line-" + line).css("text-decoration","line-through");
|
49
49
|
}
|
50
50
|
}
|
data/lib/trickster.rb
CHANGED
@@ -6,4 +6,6 @@ require 'trickster/renderer/commandline_renderer'
|
|
6
6
|
require 'trickster/renderer/normal_renderer'
|
7
7
|
require 'trickster/renderer/image_renderer'
|
8
8
|
require 'trickster/slide_renderer'
|
9
|
+
require 'trickster/copier'
|
9
10
|
require 'trickster/file_copier'
|
11
|
+
require 'trickster/theme_copier'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Trickster
|
2
|
+
# Base copier for copying files from the trickster install to the slideshow location
|
3
|
+
class Copier
|
4
|
+
# install_root:: where the root of trickster's install is, to find files to copy
|
5
|
+
# destination_root:: root of where we are copying to
|
6
|
+
def initialize(install_root,destination_root)
|
7
|
+
@install_root = install_root
|
8
|
+
@destination_root = destination_root
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,12 +1,5 @@
|
|
1
1
|
module Trickster
|
2
|
-
class FileCopier
|
3
|
-
# install_root:: where the root of trickster's install is, to find files to copy
|
4
|
-
# destination_root:: root of where we are copying to
|
5
|
-
def initialize(install_root,destination_root)
|
6
|
-
@install_root = install_root
|
7
|
-
@destination_root = destination_root
|
8
|
-
end
|
9
|
-
|
2
|
+
class FileCopier < Copier
|
10
3
|
# Shallow copies all files from +from+ with the given extension
|
11
4
|
#
|
12
5
|
# from:: location, relative to @install_root where files are copied from
|
@@ -3,21 +3,58 @@ module Trickster
|
|
3
3
|
class CodeRenderer
|
4
4
|
def render(io,content,options)
|
5
5
|
content = read_file_if_content_is_filename(content)
|
6
|
-
|
7
|
-
|
8
|
-
io.puts "#{content[-1]}</code></pre>"
|
6
|
+
content = wrap_lines_with_callouts(content,options)
|
7
|
+
io.puts "<pre><code #{language(options)}data-strikeouts='#{strikes(options)}' data-callout-lines='#{callouts(options)}'>#{content}</code></pre>"
|
9
8
|
end
|
10
9
|
|
11
10
|
private
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def wrap_lines_with_callouts(content,options)
|
13
|
+
i = 0
|
14
|
+
callout_lines = callout_option(options).map(&:abs)
|
15
|
+
previous_line_called_out = false
|
16
|
+
marked_up_lines = ""
|
17
|
+
stop_callout_block = "";
|
18
|
+
content.each_with_index do |line,i|
|
19
|
+
callout_class = '';
|
20
|
+
start_callout_block = "";
|
21
|
+
stop_callout_block = "";
|
22
|
+
|
23
|
+
if callout_lines.include?(i+1)
|
24
|
+
callout_class = "line-callout";
|
25
|
+
if !previous_line_called_out
|
26
|
+
start_callout_block = "<div class='lines-callout'>";
|
27
|
+
end
|
28
|
+
previous_line_called_out = true
|
29
|
+
else
|
30
|
+
if previous_line_called_out
|
31
|
+
stop_callout_block = "</div>";
|
32
|
+
end
|
33
|
+
previous_line_called_out = false;
|
34
|
+
end
|
35
|
+
marked_up_lines += stop_callout_block
|
36
|
+
stop_callout_block = ""
|
37
|
+
marked_up_lines += start_callout_block
|
38
|
+
marked_up_lines += "<span class='line line-#{i+1} #{callout_class}' >"
|
39
|
+
marked_up_lines += line
|
40
|
+
marked_up_lines += "</span>\n"
|
41
|
+
end
|
42
|
+
if previous_line_called_out
|
43
|
+
stop_callout_block = "</div>";
|
44
|
+
end
|
45
|
+
marked_up_lines = marked_up_lines.gsub(/\n$/,'')
|
46
|
+
marked_up_lines += stop_callout_block
|
47
|
+
marked_up_lines.gsub(/\n$/,'')
|
18
48
|
end
|
19
|
-
|
20
|
-
|
49
|
+
|
50
|
+
def read_file_if_content_is_filename(content)
|
51
|
+
if content[0] =~ /file:\/\/(.*$)/
|
52
|
+
File.open($1).readlines.map(&:chomp)
|
53
|
+
else
|
54
|
+
content
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
21
58
|
def language(options)
|
22
59
|
language = ''
|
23
60
|
if options =~/language=([^\s]+)/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Trickster
|
2
|
+
class ThemeCopier < Copier
|
3
|
+
# Copies the theme from the trickster install into the @destination_root
|
4
|
+
def copy_theme(theme)
|
5
|
+
extension = %w(.css .scss).find { |extension| File.exists?(trickster_css_file(theme,extension)) }
|
6
|
+
destination_file = File.join(@destination_root,'css','theme' + extension)
|
7
|
+
FileUtils.cp trickster_css_file(theme,extension),destination_file
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def trickster_css_file(theme,extension)
|
13
|
+
(File.join(@install_root,'css','themes',theme + extension))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/trickster/version.rb
CHANGED
data/notes.txt.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# trickster - create and present a nice presentation, quickly
|
2
|
+
|
3
|
+
trickster allows you to do a few things:
|
4
|
+
|
5
|
+
* Author a presentation in Markdown instead of a GUI
|
6
|
+
* Allow anyone to connect to your laptop to view the presentation on their screen
|
7
|
+
* Have a "presenter view" either in another window or another device
|
8
|
+
|
9
|
+
|
10
|
+
## Authoring
|
11
|
+
|
12
|
+
Authoring is just like showoff; you create a `showoff.json` and various
|
13
|
+
markdown slides; this gets turned into your presentation
|
14
|
+
|
15
|
+
### Themeing
|
16
|
+
|
17
|
+
Each presentation comes witha `styles.css` that handles all themeing. You can
|
18
|
+
tweak this or try others that exist
|
19
|
+
|
20
|
+
## Presenting
|
21
|
+
|
22
|
+
You can present just as with showoff, by doing screen mirroring and
|
23
|
+
driving the presentation off. OR, you can get the "speakers view"
|
24
|
+
in another window or device and drive the presentation that way.
|
25
|
+
|
26
|
+
- use showoff-style source; showoff.json and markdown slides in showoff format
|
27
|
+
- pml-style callout to code
|
28
|
+
- ability to highlight/reveal code
|
29
|
+
- clean styles for easy themeing
|
30
|
+
- default theme handles:
|
31
|
+
- sublists
|
32
|
+
- blockquotes
|
33
|
+
- Presentation works standalone or connected to presenter
|
34
|
+
- Get static version
|
35
|
+
- Get PDF version
|
36
|
+
|
37
|
+
Present
|
38
|
+
|
39
|
+
- presentations in-progress connect to server
|
40
|
+
- presenter connects to server and can send commands to presentation
|
41
|
+
- forward
|
42
|
+
- back
|
43
|
+
- arbitrary slide
|
44
|
+
- laser pointer
|
45
|
+
- should work on an iPad
|
46
|
+
- TIMER
|
47
|
+
|
48
|
+
# Questions
|
49
|
+
|
50
|
+
* Why not just beef up showoff?
|
51
|
+
* Well, this is for me to learn node and showoff is a Sinatra app
|
52
|
+
* showoff is also kinda hacked up over the years, and there's no tests
|
53
|
+
* CLI?
|
54
|
+
* Ruby - quick and easy via GLI, but requires an extra dep to install
|
55
|
+
* JavaScript - less to install, but probably suck to implement
|
56
|
+
* Markdown for JS?
|
data/test/jasmine.yml
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
describe("Bullets",function() {
|
2
|
+
var originalJQuery = $;
|
3
|
+
afterEach(function() {
|
4
|
+
$ = originalJQuery;
|
5
|
+
});
|
6
|
+
function makeCurrentSlideFunction(size) {
|
7
|
+
return function() {
|
8
|
+
return {
|
9
|
+
children: function() {
|
10
|
+
return {
|
11
|
+
find: function() {
|
12
|
+
return {
|
13
|
+
size: function() { return size; }
|
14
|
+
};
|
15
|
+
}
|
16
|
+
};
|
17
|
+
}
|
18
|
+
};
|
19
|
+
};
|
20
|
+
}
|
21
|
+
it("initially has bullets to advance if there is at least one bulleted item",function() {
|
22
|
+
var bullets = TricksterBullets(makeCurrentSlideFunction(1),{});
|
23
|
+
|
24
|
+
expect(bullets.hasBulletsToAdvanceFirst()).toBe(true);
|
25
|
+
});
|
26
|
+
it("initially has NO bullets to advance if there are no bulleted items",function() {
|
27
|
+
var bullets = TricksterBullets(makeCurrentSlideFunction(0),{});
|
28
|
+
|
29
|
+
expect(bullets.hasBulletsToAdvanceFirst()).toBe(false);
|
30
|
+
});
|
31
|
+
|
32
|
+
describe("LI bullets",function() {
|
33
|
+
it("sets the next LI to be visible when we advance",function() {
|
34
|
+
var visible = "none";
|
35
|
+
var advanced = false;
|
36
|
+
var currentSlide = function() {
|
37
|
+
return {
|
38
|
+
children: function() {
|
39
|
+
return {
|
40
|
+
find: function(selector) {
|
41
|
+
return {
|
42
|
+
eq: function(index) {
|
43
|
+
if (index == 0) {
|
44
|
+
return {
|
45
|
+
0: {
|
46
|
+
tagName: "LI"
|
47
|
+
},
|
48
|
+
css: function(cssAttribute,value) {
|
49
|
+
if ( (cssAttribute == "visibility") && value ) {
|
50
|
+
visible = value;
|
51
|
+
advanced = visible == "visible";
|
52
|
+
}
|
53
|
+
}
|
54
|
+
};
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
return {};
|
58
|
+
}
|
59
|
+
},
|
60
|
+
size: function() {
|
61
|
+
if (advanced) {
|
62
|
+
return 0;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
return 1;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
};
|
69
|
+
},
|
70
|
+
};
|
71
|
+
}
|
72
|
+
};
|
73
|
+
};
|
74
|
+
var bullets = TricksterBullets(currentSlide,{});
|
75
|
+
|
76
|
+
bullets.advanceToNextBullet();
|
77
|
+
|
78
|
+
expect(bullets.hasBulletsToAdvanceFirst()).toBe(false);
|
79
|
+
expect(visible).toBe("visible");
|
80
|
+
});
|
81
|
+
});
|
82
|
+
});
|
@@ -0,0 +1,244 @@
|
|
1
|
+
describe("Sizer",function() {
|
2
|
+
var originalJQuery = $;
|
3
|
+
afterEach(function() {
|
4
|
+
$ = originalJQuery;
|
5
|
+
});
|
6
|
+
/** Returns an element that will behavior more or less like the jquery element
|
7
|
+
* that we'd use in the browser */
|
8
|
+
function makeElement(initialWidth,initialHeight,cssClass) {
|
9
|
+
return {
|
10
|
+
w : initialWidth,
|
11
|
+
h : initialHeight,
|
12
|
+
0 : {
|
13
|
+
scrollWidth: this.w,
|
14
|
+
scrollHeight: this.h,
|
15
|
+
},
|
16
|
+
findInternal: function() {
|
17
|
+
return {
|
18
|
+
length: 0,
|
19
|
+
each: function() {}
|
20
|
+
};
|
21
|
+
},
|
22
|
+
find : function() { return this.findInternal(); },
|
23
|
+
fontSizes : [16],
|
24
|
+
marginTops : [0],
|
25
|
+
hasClass : function(classToCheck) {
|
26
|
+
if (cssClass) {
|
27
|
+
return classToCheck == cssClass;
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
},
|
33
|
+
cssInternal : function(cssAttribute,value) {
|
34
|
+
if (cssAttribute == "font-size") {
|
35
|
+
if (value) {
|
36
|
+
this.fontSizes.push(value);
|
37
|
+
this.w = initialWidth * parseInt(value);
|
38
|
+
this.h = initialHeight * parseInt(value);
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
return this.fontSizes[this.fontSizes.length - 1] + "px";
|
42
|
+
}
|
43
|
+
}
|
44
|
+
else if ( (cssAttribute == "margin-top") && value) {
|
45
|
+
this.marginTops.push(value);
|
46
|
+
}
|
47
|
+
},
|
48
|
+
css : function(cssAttribute, value) { return this.cssInternal(cssAttribute,value); },
|
49
|
+
width : function() { return this.w; },
|
50
|
+
height : function() { return this.h; }
|
51
|
+
};
|
52
|
+
}
|
53
|
+
var sizeFunction = Sizer.sizeFunction(1024,768);
|
54
|
+
|
55
|
+
describe("non code/commandline slide",function() {
|
56
|
+
it("resizes a square object",function() {
|
57
|
+
var element = makeElement(10,10);
|
58
|
+
|
59
|
+
sizeFunction(element);
|
60
|
+
|
61
|
+
expect(element.fontSizes.length).toBe(4);
|
62
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(38);
|
63
|
+
});
|
64
|
+
|
65
|
+
it("resizes a tall object",function() {
|
66
|
+
var element = makeElement(10,100);
|
67
|
+
|
68
|
+
sizeFunction(element);
|
69
|
+
|
70
|
+
expect(element.fontSizes.length).toBe(3); // hits max early
|
71
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(26);
|
72
|
+
});
|
73
|
+
|
74
|
+
it("resizes a wide object",function() {
|
75
|
+
var element = makeElement(100,10);
|
76
|
+
|
77
|
+
sizeFunction(element);
|
78
|
+
|
79
|
+
expect(element.fontSizes.length).toBe(4);
|
80
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(38);
|
81
|
+
});
|
82
|
+
});
|
83
|
+
describe("BULLETS slide",function() {
|
84
|
+
it("resizes a square object",function() {
|
85
|
+
var element = makeElement(10,10,"BULLETS");
|
86
|
+
|
87
|
+
sizeFunction(element);
|
88
|
+
|
89
|
+
expect(element.fontSizes.length).toBe(4);
|
90
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(76);
|
91
|
+
});
|
92
|
+
|
93
|
+
it("resizes a tall object",function() {
|
94
|
+
var element = makeElement(10,100,"BULLETS");
|
95
|
+
|
96
|
+
sizeFunction(element);
|
97
|
+
|
98
|
+
expect(element.fontSizes.length).toBe(3); // hits max early
|
99
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(26);
|
100
|
+
});
|
101
|
+
|
102
|
+
it("resizes a wide object",function() {
|
103
|
+
var element = makeElement(100,10,"BULLETS");
|
104
|
+
|
105
|
+
sizeFunction(element);
|
106
|
+
|
107
|
+
expect(element.fontSizes.length).toBe(4);
|
108
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(76);
|
109
|
+
});
|
110
|
+
});
|
111
|
+
describe("CODE slide",function() {
|
112
|
+
it("shrinks if it there was word-wrapping",function() {
|
113
|
+
$ = function(element) {
|
114
|
+
if (typeof(element) == "number") {
|
115
|
+
return {
|
116
|
+
height: function() { return element; }
|
117
|
+
};
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
return {};
|
121
|
+
}
|
122
|
+
};
|
123
|
+
|
124
|
+
var element = makeElement(200,80,"CODE");
|
125
|
+
|
126
|
+
var calls = 0;
|
127
|
+
var callsUntilWrappingStops = 10;
|
128
|
+
element["find"] = function(selector) {
|
129
|
+
if (selector == ".line") {
|
130
|
+
return {
|
131
|
+
length: 4,
|
132
|
+
each: function(f) {
|
133
|
+
if (calls < callsUntilWrappingStops) {
|
134
|
+
f(0,12);
|
135
|
+
f(1,12);
|
136
|
+
f(2,24);
|
137
|
+
f(3,12);
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
f(0,12);
|
141
|
+
f(1,12);
|
142
|
+
f(2,12);
|
143
|
+
f(3,12);
|
144
|
+
}
|
145
|
+
calls = calls + 1;
|
146
|
+
}
|
147
|
+
};
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
return this.findInternal();
|
151
|
+
}
|
152
|
+
};
|
153
|
+
element["css"] = function(cssAttribute,value) {
|
154
|
+
if ((cssAttribute == "font-size") && value) {
|
155
|
+
this.fontSizes.push(value);
|
156
|
+
this.w = 10 * parseInt(value);
|
157
|
+
this.h = parseInt(value) + this.fontSizes.length;
|
158
|
+
}
|
159
|
+
else {
|
160
|
+
return this.cssInternal(cssAttribute,value);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
sizeFunction(element);
|
165
|
+
|
166
|
+
expect(element.fontSizes.length).toBe(25 - callsUntilWrappingStops);
|
167
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(666);
|
168
|
+
expect(element.marginTops[element.marginTops.length - 1]).toBe(-666);
|
169
|
+
});
|
170
|
+
it("resizes a square object",function() {
|
171
|
+
var element = makeElement(10,10,"CODE");
|
172
|
+
|
173
|
+
sizeFunction(element);
|
174
|
+
|
175
|
+
expect(element.fontSizes.length).toBe(4);
|
176
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(76);
|
177
|
+
expect(element.marginTops[element.marginTops.length - 1]).toBe(-76);
|
178
|
+
});
|
179
|
+
|
180
|
+
it("resizes a tall object",function() {
|
181
|
+
var element = makeElement(10,100,"CODE");
|
182
|
+
|
183
|
+
sizeFunction(element);
|
184
|
+
|
185
|
+
expect(element.fontSizes.length).toBe(3); // hits max early
|
186
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(26);
|
187
|
+
expect(element.marginTops[element.marginTops.length - 1]).toBe(-26);
|
188
|
+
});
|
189
|
+
|
190
|
+
it("resizes a wide object",function() {
|
191
|
+
var element = makeElement(100,10,"CODE");
|
192
|
+
|
193
|
+
sizeFunction(element);
|
194
|
+
|
195
|
+
expect(element.fontSizes.length).toBe(4);
|
196
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(76);
|
197
|
+
expect(element.marginTops[element.marginTops.length - 1]).toBe(-76);
|
198
|
+
});
|
199
|
+
});
|
200
|
+
describe("COMMANDLINE slide",function() {
|
201
|
+
it("resizes sets display inline before resizing, then restoring it back to display none",function() {
|
202
|
+
var element = makeElement(10,10,"COMMANDLINE");
|
203
|
+
element["displays"] = [];
|
204
|
+
element["css"] = function(cssAttribute,value) {
|
205
|
+
if ( (cssAttribute == "display") && value) {
|
206
|
+
this.displays.push(value);
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
return this.cssInternal(cssAttribute,value);
|
210
|
+
}
|
211
|
+
};
|
212
|
+
element["find"] = function(selector) {
|
213
|
+
if (selector == ".cli-element") {
|
214
|
+
return {
|
215
|
+
length: 1,
|
216
|
+
each: function(f) {
|
217
|
+
f(0,element);
|
218
|
+
}
|
219
|
+
};
|
220
|
+
}
|
221
|
+
else {
|
222
|
+
return this.findInternal();
|
223
|
+
}
|
224
|
+
};
|
225
|
+
$ = function(elt) {
|
226
|
+
if (elt == element) {
|
227
|
+
return element;
|
228
|
+
}
|
229
|
+
else {
|
230
|
+
return {};
|
231
|
+
}
|
232
|
+
};
|
233
|
+
|
234
|
+
sizeFunction(element);
|
235
|
+
|
236
|
+
expect(element.fontSizes.length).toBe(4);
|
237
|
+
expect(element.displays.length).toBe(2);
|
238
|
+
expect(element.displays[0]).toBe("inline");
|
239
|
+
expect(element.displays[1]).toBe("none");
|
240
|
+
expect(element.fontSizes[element.fontSizes.length - 1]).toBe(76);
|
241
|
+
expect(element.marginTops[element.marginTops.length - 1]).toBe(-76);
|
242
|
+
});
|
243
|
+
});
|
244
|
+
});
|