royw-shoeshine 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +3 -3
- data/VERSION.yml +1 -1
- data/examples/command_widget.rb +3 -6
- data/examples/dd_menu_widget.rb +5 -2
- data/examples/example_app.rb +2 -4
- data/examples/{unordered_list_action.rb → list_action.rb} +3 -3
- data/examples/list_widget.rb +93 -0
- data/examples/nav.rb +2 -3
- data/lib/shoeshine.rb +0 -1
- data/lib/shoeshine/horizontal_rule.rb +2 -0
- data/lib/shoeshine/list.rb +112 -17
- data/lib/shoeshine/list_item.rb +17 -16
- metadata +6 -7
- data/examples/unordered_list_widget.rb +0 -68
- data/lib/shoeshine/unordered_list.rb +0 -52
data/README.rdoc
CHANGED
@@ -4,15 +4,15 @@ This is a collection of UI elements for shoes (http://shoooes.net).
|
|
4
4
|
|
5
5
|
The collection currently includes:
|
6
6
|
|
7
|
-
*
|
8
|
-
*
|
7
|
+
* List displays lists with various optional bullets or indexes
|
8
|
+
* bullets (circle, star, plus, or custom)
|
9
|
+
* indexes (anything that responds to a .next())
|
9
10
|
* vertical or horizontal orientation
|
10
11
|
* ListItems is a handy wrapper for placing things in the list
|
11
12
|
* DropDownMenu is an inplace drop down menu that can serve as popup menus
|
12
13
|
* An example application to show them off with
|
13
14
|
|
14
15
|
TODOs include:
|
15
|
-
* ordered lists
|
16
16
|
* toolbar (horizontal list of icons)
|
17
17
|
* maybe a menubar
|
18
18
|
|
data/VERSION.yml
CHANGED
data/examples/command_widget.rb
CHANGED
@@ -5,16 +5,13 @@ class CommandWidget
|
|
5
5
|
def show(opt={})
|
6
6
|
app.stack(opt) do
|
7
7
|
app.background app.gradient(app.rgb(0, 255, 255), app.rgb(255, 0, 255), :angle => -35)
|
8
|
-
command_list =
|
8
|
+
command_list = List.new(app, :left_margin => 0)
|
9
9
|
command_list.add ListItem.new("Index",
|
10
10
|
:click => lambda{app.visit(INDEX_PAGE)},
|
11
11
|
:bullet => List::STAR_BULLET)
|
12
12
|
command_list.add HorizontalRule.new(:width => opt[:width])
|
13
|
-
command_list.add ListItem.new("
|
14
|
-
:click => lambda {app.visit(
|
15
|
-
:bullet => List::CIRCLE_BULLET)
|
16
|
-
command_list.add ListItem.new("Ordered Lists",
|
17
|
-
:click => lambda {app.visit(ORDERED_LIST_PAGE)},
|
13
|
+
command_list.add ListItem.new("Lists",
|
14
|
+
:click => lambda {app.visit(LIST_PAGE)},
|
18
15
|
:bullet => List::CIRCLE_BULLET)
|
19
16
|
command_list.add ListItem.new("DropDownMenus",
|
20
17
|
:click => lambda {app.visit(DROP_DOWN_MENU_PAGE)},
|
data/examples/dd_menu_widget.rb
CHANGED
@@ -12,7 +12,8 @@ class DDMenuWidget
|
|
12
12
|
app.para "Both columns close the menu when the mouse leaves it."
|
13
13
|
app.flow do
|
14
14
|
app.stack(:width => 100) do
|
15
|
-
|
15
|
+
app.para "right click"
|
16
|
+
list = List.new(app)
|
16
17
|
numbers = %w(one two three four five).collect do |item|
|
17
18
|
ListItem.new(item,
|
18
19
|
:click => lambda{alert("#{item} was clicked")})
|
@@ -27,9 +28,11 @@ class DDMenuWidget
|
|
27
28
|
))
|
28
29
|
end
|
29
30
|
list.show
|
31
|
+
app.rect(90, 0, 1, 180)
|
30
32
|
end
|
31
33
|
app.stack(:width => 100) do
|
32
|
-
|
34
|
+
app.para 'hover'
|
35
|
+
list = List.new(app)
|
33
36
|
numbers = %w(six seven eight nine).collect do |item|
|
34
37
|
ListItem.new(item,
|
35
38
|
:click => lambda{alert("#{item} was clicked")})
|
data/examples/example_app.rb
CHANGED
@@ -11,8 +11,7 @@ require 'nav'
|
|
11
11
|
require 'action'
|
12
12
|
require 'dd_menu_action'
|
13
13
|
require 'index_action'
|
14
|
-
require '
|
15
|
-
require 'unordered_list_action'
|
14
|
+
require 'list_action'
|
16
15
|
|
17
16
|
class ListExample < Shoes
|
18
17
|
include Nav
|
@@ -42,8 +41,7 @@ class ListExample < Shoes
|
|
42
41
|
|
43
42
|
# define our pages
|
44
43
|
page_def INDEX_PAGE, :index, IndexAction
|
45
|
-
page_def
|
46
|
-
page_def ORDERED_LIST_PAGE, :ol, OrderedListAction
|
44
|
+
page_def LIST_PAGE, :list, ListAction
|
47
45
|
page_def DROP_DOWN_MENU_PAGE, :drop_down_menu, DropDownMenuAction
|
48
46
|
|
49
47
|
private
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'action'
|
2
2
|
require 'nav'
|
3
|
-
require '
|
3
|
+
require 'list_widget'
|
4
4
|
|
5
|
-
class
|
5
|
+
class ListAction < Action
|
6
6
|
include Nav
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
super
|
10
|
-
@widget =
|
10
|
+
@widget = ListWidget.new
|
11
11
|
end
|
12
12
|
|
13
13
|
def execute()
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'shoeshine/widget'
|
2
|
+
|
3
|
+
class ListWidget
|
4
|
+
include Widget
|
5
|
+
include Nav
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def show(opt={})
|
11
|
+
opt = opt.merge(VIEW_AREA_OPTS)
|
12
|
+
app.stack(opt) do
|
13
|
+
app.background(app.floralwhite) if $DEBUG
|
14
|
+
app.caption "Vertical Lists"
|
15
|
+
|
16
|
+
app.para "Various Bullets"
|
17
|
+
app.flow do
|
18
|
+
app.background(app.gainsboro) if $DEBUG
|
19
|
+
@x = 0
|
20
|
+
list_one(80, {})
|
21
|
+
list_one(80, {:bullet => List::CIRCLE_BULLET})
|
22
|
+
list_one(100, {:bullet => List::STAR_BULLET, :indent => 40, :background => app.yellow})
|
23
|
+
list_one(80, {:bullet => List::PLUS_BULLET, :background => app.cyan})
|
24
|
+
list_one(80, {:bullet => List::INDEX_BULLET, :index_seed => '1', :index_separator => '.'})
|
25
|
+
list_one(80, {:bullet => List::INDEX_BULLET, :index_seed => 'a', :index_separator => ')'})
|
26
|
+
list_one(80, {:bullet => List::INDEX_BULLET, :index_seed => 'G', :index_separator => ''})
|
27
|
+
end
|
28
|
+
|
29
|
+
app.para "With Links"
|
30
|
+
app.flow do
|
31
|
+
app.background(app.lavender) if $DEBUG
|
32
|
+
@x = 0
|
33
|
+
list_two(80, {})
|
34
|
+
list_two(80, {:bullet => List::CIRCLE_BULLET})
|
35
|
+
list_two(80, {:bullet => List::STAR_BULLET})
|
36
|
+
list_two(80, {:bullet => List::PLUS_BULLET})
|
37
|
+
end
|
38
|
+
|
39
|
+
app.caption "Horizontal Lists"
|
40
|
+
app.stack do
|
41
|
+
app.background(app.khaki) if $DEBUG
|
42
|
+
@y = 0
|
43
|
+
list_horizontal(30, {:column_width => 90})
|
44
|
+
list_horizontal(30, {:column_width => 100, :bullet => List::CIRCLE_BULLET})
|
45
|
+
list_horizontal(30, {:column_width => 110, :bullet => List::STAR_BULLET})
|
46
|
+
list_horizontal(30, {:column_width => 120, :bullet => List::PLUS_BULLET})
|
47
|
+
end
|
48
|
+
|
49
|
+
app.para ''
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def list_one(width, options)
|
54
|
+
app.stack({:width => width}) do
|
55
|
+
list = List.new(app, options)
|
56
|
+
%w(alpha bravo charlie delta echo foxtrot).each do |item|
|
57
|
+
list.add(ListItem.new(item))
|
58
|
+
end
|
59
|
+
list.show
|
60
|
+
end
|
61
|
+
@x += width
|
62
|
+
app.rect(@x,0,1,140)
|
63
|
+
end
|
64
|
+
|
65
|
+
def list_two(width, options)
|
66
|
+
app.stack({:width => width}) do
|
67
|
+
list = List.new(app, options)
|
68
|
+
%w(alpha bravo charlie delta echo foxtrot).each do |item|
|
69
|
+
list.add(ListItem.new(item, :click => lambda{alert("#{item} clicked")}))
|
70
|
+
end
|
71
|
+
list.show
|
72
|
+
end
|
73
|
+
@x += width
|
74
|
+
app.rect(@x,0,1,140)
|
75
|
+
end
|
76
|
+
|
77
|
+
def list_horizontal(height, options)
|
78
|
+
app.stack(:height => height, :width => '100%') do
|
79
|
+
app.background(app.deeppink) if $DEBUG
|
80
|
+
list = List.new(app, options.merge(:orientation => :horizontal, :width => '100%'))
|
81
|
+
%w(alpha bravo charlie).each do |item|
|
82
|
+
list.add(ListItem.new(item))
|
83
|
+
end
|
84
|
+
%w(delta echo).each do |item|
|
85
|
+
list.add(ListItem.new(item, :click => lambda{alert("#{item} clicked")}))
|
86
|
+
end
|
87
|
+
list.show
|
88
|
+
end
|
89
|
+
@y += height
|
90
|
+
app.rect(0, @y, 5 * options[:column_width], 1)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
data/examples/nav.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Nav
|
2
2
|
INDEX_PAGE = '/'
|
3
|
-
|
4
|
-
ORDERED_LIST_PAGE = '/ol'
|
3
|
+
LIST_PAGE = '/list'
|
5
4
|
DROP_DOWN_MENU_PAGE = '/drop_down_menu'
|
6
5
|
|
7
|
-
COMMAND_AREA_WIDTH =
|
6
|
+
COMMAND_AREA_WIDTH = 160
|
8
7
|
VIEW_AREA_OPTS = {:width => -COMMAND_AREA_WIDTH, :margin_left => 10, :margin_right => @gutter}
|
9
8
|
end
|
data/lib/shoeshine.rb
CHANGED
data/lib/shoeshine/list.rb
CHANGED
@@ -1,19 +1,114 @@
|
|
1
|
+
require 'shoeshine/widget'
|
2
|
+
|
1
3
|
class List
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
include Widget
|
5
|
+
|
6
|
+
STAR_BULLET = lambda{ |app, *ignore| List.star_image(app) }
|
7
|
+
CIRCLE_BULLET = lambda{ |app, *ignore| List.circle_image(app) }
|
8
|
+
PLUS_BULLET = lambda{ |app, *ignore| List.plus_image(app) }
|
9
|
+
SPACE_BULLET = lambda{ |app, *ignore| ' '}
|
10
|
+
INDEX_BULLET = lambda{ |app, counter, separator| List.index_string(app, counter, separator) }
|
11
|
+
IMAGE_BULLET = lambda{ |app, image_url, *ignore| app.image(image_url) unless image_url.nil? }
|
12
|
+
|
13
|
+
IMAGE_SIZE = 20
|
14
|
+
|
15
|
+
def initialize(app, list_opts={})
|
16
|
+
self.app = app
|
17
|
+
@list_opts = list_opts
|
18
|
+
@list_opts ||= {}
|
19
|
+
@list_items = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def add(list_item)
|
23
|
+
@list_items << list_item
|
24
|
+
end
|
25
|
+
|
26
|
+
# list_opts => {
|
27
|
+
# :bullet => one_of(BULLETS.keys),
|
28
|
+
# :background => app.background argument
|
29
|
+
# }
|
30
|
+
def show(opts={})
|
31
|
+
show_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?
|
32
|
+
column_options = {}
|
33
|
+
column_options[:width] = show_options[:column_width] unless show_options[:column_width].nil?
|
34
|
+
counter = show_options[:index_seed]
|
35
|
+
orientation = show_options[:orientation]
|
36
|
+
orientation = :vertical if orientation.nil?
|
37
|
+
case orientation.to_sym
|
38
|
+
when :vertical
|
39
|
+
app.stack(show_options) do
|
40
|
+
@list_items.each do |item|
|
41
|
+
item.app = app
|
42
|
+
app.flow do
|
43
|
+
item.counter = counter
|
44
|
+
item.show @list_opts
|
45
|
+
counter = counter.next unless counter.nil?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
when :horizontal
|
50
|
+
app.flow(show_options.merge(:width => '100%')) do
|
51
|
+
app.background(app.cyan) if $DEBUG
|
52
|
+
@list_items.each do |item|
|
53
|
+
item.app = app
|
54
|
+
app.stack(column_options) do
|
55
|
+
app.background(app.red) if $DEBUG
|
56
|
+
app.flow do
|
57
|
+
app.background(app.yellow) if $DEBUG
|
58
|
+
item.counter = counter
|
59
|
+
item.show @list_opts
|
60
|
+
counter = counter.next unless counter.nil?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
else
|
66
|
+
app.error "Invalid orientation value: '#{orientation.to_s}'"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def self.star_image(app)
|
73
|
+
app.image IMAGE_SIZE, IMAGE_SIZE do
|
74
|
+
top = IMAGE_SIZE / 2 + 2
|
75
|
+
left = IMAGE_SIZE / 2
|
76
|
+
points = 5
|
77
|
+
outer = IMAGE_SIZE / 3
|
78
|
+
inner = IMAGE_SIZE / 6
|
79
|
+
app.star(left, top, points, outer, inner)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.circle_image(app)
|
84
|
+
app.image IMAGE_SIZE, IMAGE_SIZE do
|
85
|
+
top = (IMAGE_SIZE / 2)
|
86
|
+
left = (IMAGE_SIZE / 2)
|
87
|
+
radius = IMAGE_SIZE / 3
|
88
|
+
app.oval(left, top, radius)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.plus_image(app)
|
93
|
+
app.image IMAGE_SIZE, IMAGE_SIZE do
|
94
|
+
# rect(x,y,w,h) NOTE, docs are wrong
|
95
|
+
length = (IMAGE_SIZE * 2) / 3
|
96
|
+
beam = 3
|
97
|
+
top = ((IMAGE_SIZE - length) / 2) + 2
|
98
|
+
left = ((IMAGE_SIZE - length) / 2) + 2
|
99
|
+
vertical_center = IMAGE_SIZE / 2
|
100
|
+
horizontal_center = IMAGE_SIZE / 2
|
101
|
+
app.rect(horizontal_center, top, beam, length, 1) # vertical bar
|
102
|
+
app.rect(left, vertical_center, length, beam, 1) # horizontal bar
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.index_string(app, counter, separator)
|
107
|
+
str = ''
|
108
|
+
separator ||= ''
|
109
|
+
unless counter.nil?
|
110
|
+
str = "#{counter}#{separator}"
|
111
|
+
end
|
112
|
+
app.para(str, :margin_bottom => 0)
|
113
|
+
end
|
19
114
|
end
|
data/lib/shoeshine/list_item.rb
CHANGED
@@ -2,45 +2,46 @@ class ListItem
|
|
2
2
|
include Widget
|
3
3
|
|
4
4
|
attr_reader :options
|
5
|
+
attr_accessor :counter
|
5
6
|
|
6
7
|
def initialize(text, opts={})
|
7
8
|
@text = text
|
8
9
|
@options = opts
|
9
10
|
@options ||= {}
|
11
|
+
@counter = nil
|
10
12
|
end
|
11
13
|
|
12
14
|
def show(list_options={})
|
13
15
|
list_options ||= {}
|
14
16
|
show_options = list_options.merge(self.options)
|
17
|
+
bullet_options = {}
|
18
|
+
bullet_options[:width] = show_options[:indent].nil? ? 20 : show_options[:indent]
|
15
19
|
|
16
20
|
bullet = show_options[:bullet]
|
17
|
-
icon = show_options[:image]
|
18
21
|
menu_items = show_options[:menu_items]
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
# right = (show_options[:margin_right].nil? ? 0 : show_options[:margin_right])
|
24
|
+
# left = (show_options[:margin_left].nil? ? 10 : show_options[:margin_left])
|
25
|
+
# left = (show_options[:indent].nil? ? 10 : show_options[:indent])
|
23
26
|
|
24
|
-
unless
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
unless bullet.nil?
|
29
|
-
indent = 15
|
30
|
-
List::BULLETS[bullet].call(app)
|
31
|
-
end
|
27
|
+
unless show_options[:background].nil?
|
28
|
+
app.background(show_options[:background], :margin_left => bullet_options[:width])
|
29
|
+
# app.background(show_options[:background])
|
30
|
+
# left += 5
|
32
31
|
end
|
33
32
|
|
34
|
-
unless
|
35
|
-
app.
|
36
|
-
|
33
|
+
unless bullet.nil?
|
34
|
+
app.flow(bullet_options) do
|
35
|
+
bullet_image = bullet.call(app, @counter, show_options[:index_separator])
|
36
|
+
end
|
37
37
|
end
|
38
|
+
|
38
39
|
unless menu_items.nil?
|
39
40
|
trigger = show_options[:menu_trigger] || DropDownMenuWidget::RIGHT_BUTTON
|
40
41
|
menu = DropDownMenuWidget.new(app, self, trigger, menu_items, menu_options(show_options))
|
41
42
|
menu.show
|
42
43
|
else
|
43
|
-
para_opts = {:
|
44
|
+
para_opts = {:margin_bottom => 0}
|
44
45
|
app.para(self.as_value(app), para_opts)
|
45
46
|
end
|
46
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: royw-shoeshine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roy Wright
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,19 +34,18 @@ files:
|
|
34
34
|
- examples/example_app.rb
|
35
35
|
- examples/index_action.rb
|
36
36
|
- examples/index_widget.rb
|
37
|
+
- examples/list_action.rb
|
38
|
+
- examples/list_widget.rb
|
37
39
|
- examples/nav.rb
|
38
40
|
- examples/ordered_list_action.rb
|
39
41
|
- examples/ordered_list_widget.rb
|
40
42
|
- examples/page_widget.rb
|
41
43
|
- examples/title_widget.rb
|
42
|
-
- examples/unordered_list_action.rb
|
43
|
-
- examples/unordered_list_widget.rb
|
44
44
|
- lib/shoeshine.rb
|
45
45
|
- lib/shoeshine/drop_down_menu.rb
|
46
46
|
- lib/shoeshine/horizontal_rule.rb
|
47
47
|
- lib/shoeshine/list.rb
|
48
48
|
- lib/shoeshine/list_item.rb
|
49
|
-
- lib/shoeshine/unordered_list.rb
|
50
49
|
- lib/shoeshine/widget.rb
|
51
50
|
- spec/drop_down_menu_spec.rb
|
52
51
|
- spec/spec_helper.rb
|
@@ -81,15 +80,15 @@ test_files:
|
|
81
80
|
- spec/drop_down_menu_spec.rb
|
82
81
|
- examples/example_app.rb
|
83
82
|
- examples/dd_menu_action.rb
|
83
|
+
- examples/list_action.rb
|
84
84
|
- examples/nav.rb
|
85
85
|
- examples/title_widget.rb
|
86
86
|
- examples/dd_menu_widget.rb
|
87
|
-
- examples/unordered_list_action.rb
|
88
87
|
- examples/ordered_list_widget.rb
|
89
88
|
- examples/ordered_list_action.rb
|
90
89
|
- examples/index_action.rb
|
90
|
+
- examples/list_widget.rb
|
91
91
|
- examples/index_widget.rb
|
92
92
|
- examples/page_widget.rb
|
93
93
|
- examples/action.rb
|
94
|
-
- examples/unordered_list_widget.rb
|
95
94
|
- examples/command_widget.rb
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'shoeshine/widget'
|
2
|
-
|
3
|
-
class UnorderedListWidget
|
4
|
-
include Widget
|
5
|
-
include Nav
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
end
|
9
|
-
|
10
|
-
def show(opt={})
|
11
|
-
app.stack(opt) do
|
12
|
-
app.flow do
|
13
|
-
app.para "Various bullets"
|
14
|
-
list_one({})
|
15
|
-
list_one({:bullet => List::CIRCLE_BULLET})
|
16
|
-
list_one({:bullet => List::STAR_BULLET})
|
17
|
-
list_one({:bullet => List::PLUS_BULLET})
|
18
|
-
end
|
19
|
-
app.flow(opt) do
|
20
|
-
app.para "With links"
|
21
|
-
list_two({})
|
22
|
-
list_two({:bullet => List::CIRCLE_BULLET})
|
23
|
-
list_two({:bullet => List::STAR_BULLET})
|
24
|
-
list_two({:bullet => List::PLUS_BULLET})
|
25
|
-
end
|
26
|
-
app.stack(opt) do
|
27
|
-
list_horizontal({})
|
28
|
-
list_horizontal({:bullet => List::CIRCLE_BULLET})
|
29
|
-
list_horizontal({:bullet => List::STAR_BULLET})
|
30
|
-
list_horizontal({:bullet => List::PLUS_BULLET})
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def list_one(options)
|
36
|
-
app.stack({:width => 80}) do
|
37
|
-
list = UnorderedList.new(app, options)
|
38
|
-
%w(alpha bravo charlie delta echo foxtrot).each do |item|
|
39
|
-
list.add(ListItem.new(item))
|
40
|
-
end
|
41
|
-
list.show
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def list_two(options)
|
46
|
-
app.stack({:width => 80}) do
|
47
|
-
list = UnorderedList.new(app, options)
|
48
|
-
%w(alpha bravo charlie delta echo foxtrot).each do |item|
|
49
|
-
list.add(ListItem.new(item, :click => lambda{alert("#{item} clicked")}))
|
50
|
-
end
|
51
|
-
list.show
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def list_horizontal(options)
|
56
|
-
app.stack do
|
57
|
-
list = UnorderedList.new(app, options.merge(:orientation => :horizontal, :width => '100%'))
|
58
|
-
%w(alpha bravo charlie).each do |item|
|
59
|
-
list.add(ListItem.new(item))
|
60
|
-
end
|
61
|
-
%w(delta echo foxtrot).each do |item|
|
62
|
-
list.add(ListItem.new(item, :click => lambda{alert("#{item} clicked")}))
|
63
|
-
end
|
64
|
-
list.show
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class UnorderedList < List
|
2
|
-
include Widget
|
3
|
-
|
4
|
-
public
|
5
|
-
|
6
|
-
def initialize(app, list_opts={})
|
7
|
-
self.app = app
|
8
|
-
@list_opts = list_opts
|
9
|
-
@list_opts ||= {}
|
10
|
-
@list_items = []
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(list_item)
|
14
|
-
@list_items << list_item
|
15
|
-
end
|
16
|
-
|
17
|
-
# list_opts => {
|
18
|
-
# :bullet => one_of(BULLETS.keys),
|
19
|
-
# :background => app.background argument
|
20
|
-
# }
|
21
|
-
def show(opts={})
|
22
|
-
show_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?
|
23
|
-
|
24
|
-
orientation = show_options[:orientation]
|
25
|
-
orientation = :vertical if orientation.nil?
|
26
|
-
case orientation.to_sym
|
27
|
-
when :vertical
|
28
|
-
app.stack(show_options) do
|
29
|
-
@list_items.each do |item|
|
30
|
-
item.app = app
|
31
|
-
app.flow do
|
32
|
-
item.show @list_opts
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
when :horizontal
|
37
|
-
app.flow(show_options) do
|
38
|
-
@list_items.each do |item|
|
39
|
-
item.app = app
|
40
|
-
app.stack(:width => 80) do
|
41
|
-
item.show @list_opts
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
else
|
46
|
-
app.error "Invalid orientation value: '#{orientation.to_s}'"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def show_items
|
51
|
-
end
|
52
|
-
end
|