stable-rails 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.
@@ -14,8 +14,8 @@ module StableHelper
14
14
  end
15
15
  end
16
16
 
17
- def tr
18
- @builder.tr do
17
+ def tr(html_options = {})
18
+ @builder.tr html_options do
19
19
  yield
20
20
  end
21
21
  end
@@ -24,6 +24,17 @@ module StableHelper
24
24
  @builder.td content, html_options
25
25
  end
26
26
 
27
+ def thead
28
+ @builder.thead do
29
+ yield
30
+ end
31
+ end
32
+
33
+ def tbody
34
+ @builder.tbody do
35
+ yield
36
+ end
37
+ end
27
38
  end
28
39
 
29
40
  module Enumerable
@@ -48,29 +59,34 @@ class STableBuilder
48
59
  @context = context
49
60
  @data = []
50
61
  @column_html_options = []
62
+ @row_wrapper_html_options = []
51
63
  @row_index = -1
52
64
  end
53
65
 
54
66
  def table(options)
55
- options.reverse_merge!({ fixed_rows: 1 })
67
+ @options = options.reverse_merge!({ fixed_rows: 1 })
56
68
  html_options = options.clone
57
69
  html_options.delete :fixed_rows
58
70
 
59
71
  yield
60
72
 
73
+ puts @options.inspect
74
+
61
75
  @context.haml_concat @context.render(:partial => @partial_view,
62
76
  :locals => {
63
77
  :data => @data,
64
- :options => options,
65
- :html_options => html_options
78
+ :options => @options,
79
+ :html_options => html_options,
80
+ :row_wrapper_html_options => @row_wrapper_html_options
66
81
  }
67
82
  )
68
83
  end
69
84
 
70
- def tr
85
+ def tr(html_options)
71
86
  @row_index += 1
72
87
  @col_index = -1
73
88
 
89
+ @row_wrapper_html_options << html_options
74
90
  @data << []
75
91
  yield
76
92
  end
@@ -93,4 +109,13 @@ class STableBuilder
93
109
 
94
110
  @data.last << { value: content, html_options: html_options }
95
111
  end
112
+
113
+ def thead
114
+ yield
115
+ @options[:fixed_rows] = @row_index + 1
116
+ end
117
+
118
+ def tbody
119
+ yield
120
+ end
96
121
  end
@@ -7,25 +7,25 @@
7
7
  .mask
8
8
  .c-left
9
9
  .t-header
10
- - (0..options[:fixed_rows]-1).each do |row|
11
- .t-row
12
- %div{data[row][0][:html_options]}
13
- = data[row][0][:value]
10
+ - (0..options[:fixed_rows]-1).each do |index|
11
+ .t-row{row_wrapper_html_options[index]}
12
+ %div{data[index][0][:html_options]}
13
+ = data[index][0][:value]
14
14
  .t-body.vertical
15
- - data.enum_drop(options[:fixed_rows]) do |row|
16
- .t-row
15
+ - data.enum_drop_with_index(options[:fixed_rows]) do |row, index|
16
+ .t-row{row_wrapper_html_options[index]}
17
17
  %div{row[0][:html_options]}
18
18
  = row[0][:value]
19
19
  .c-right
20
20
  .t-header.horizontal
21
- - (0..options[:fixed_rows]-1).each do |row|
22
- .t-row
23
- - data[row].enum_drop(1) do |cell|
21
+ - (0..options[:fixed_rows]-1).each do |index|
22
+ .t-row{row_wrapper_html_options[index]}
23
+ - data[index].enum_drop(1) do |cell|
24
24
  %div{cell[:html_options]}
25
25
  = cell[:value]
26
26
  .t-body.vertical.horizontal
27
- - data.enum_drop(options[:fixed_rows]) do |row|
28
- .t-row
27
+ - data.enum_drop_with_index(options[:fixed_rows]) do |row, index|
28
+ .t-row{row_wrapper_html_options[index]}
29
29
  - row.enum_drop(1) do |cell|
30
30
  %div{cell[:html_options]}
31
31
  = cell[:value]
@@ -1,6 +1,6 @@
1
1
  %table{ html_options }
2
- - data.each do |row|
3
- %tr
2
+ - data.each_with_index do |row, index|
3
+ %tr{ row_wrapper_html_options[index] }
4
4
  - row.each do |cell|
5
5
  %td{ cell[:html_options] }
6
6
  = cell[:value]
@@ -1,5 +1,5 @@
1
1
  module Stable
2
2
  module Rails
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -51,4 +51,78 @@
51
51
  - td "#{c}4"
52
52
  - td "#{c}5"
53
53
  - td "#{c}6"
54
- - td "#{c}7"
54
+ - td "#{c}7"
55
+
56
+ - stable class: 'w120' do
57
+ - thead do
58
+ - tr class: 'first' do
59
+ - td 'L\N'
60
+ - td 'Title 1'
61
+ - td 'Title 2'
62
+ - td 'Title 3'
63
+ - td 'Title 4'
64
+ - td 'Title 5'
65
+ - tr class: 'second' do
66
+ - td "Title a"
67
+ - td "a1"
68
+ - td "a2"
69
+ - td "a3"
70
+ - td "a4"
71
+ - td "a5"
72
+ - tbody do
73
+ - tr class: 'third' do
74
+ - td "Title b"
75
+ - td "b1"
76
+ - td "b2"
77
+ - td "b3"
78
+ - td "b4"
79
+ - td "b5"
80
+ - tr class: 'forth' do
81
+ - td "Title c"
82
+ - td "c1"
83
+ - td "c2"
84
+ - td "c3"
85
+ - td "c4"
86
+ - td "c5"
87
+ - tr do
88
+ - td "Title d"
89
+ - td "d1"
90
+ - td "d2"
91
+ - td "d3"
92
+ - td "d4"
93
+ - td "d5"
94
+ - tr do
95
+ - td "Title e"
96
+ - td "e1"
97
+ - td "e2"
98
+ - td "e3"
99
+ - td "e4"
100
+ - td "e5"
101
+ - tr class: 'third' do
102
+ - td "Title b"
103
+ - td "b1"
104
+ - td "b2"
105
+ - td "b3"
106
+ - td "b4"
107
+ - td "b5"
108
+ - tr class: 'forth' do
109
+ - td "Title c"
110
+ - td "c1"
111
+ - td "c2"
112
+ - td "c3"
113
+ - td "c4"
114
+ - td "c5"
115
+ - tr do
116
+ - td "Title d"
117
+ - td "d1"
118
+ - td "d2"
119
+ - td "d3"
120
+ - td "d4"
121
+ - td "d5"
122
+ - tr do
123
+ - td "Title e"
124
+ - td "e1"
125
+ - td "e2"
126
+ - td "e3"
127
+ - td "e4"
128
+ - td "e5"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2013-01-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: haml-rails
17
- requirement: &70120944830020 !ruby/object:Gem::Requirement
17
+ requirement: &70322464360100 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70120944830020
25
+ version_requirements: *70322464360100
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sinatra
28
- requirement: &70120944828760 !ruby/object:Gem::Requirement
28
+ requirement: &70322464358840 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70120944828760
36
+ version_requirements: *70322464358840
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sass
39
- requirement: &70120944827440 !ruby/object:Gem::Requirement
39
+ requirement: &70322464357420 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70120944827440
47
+ version_requirements: *70322464357420
48
48
  description: Scrollable table with fixed first row and column.
49
49
  email:
50
50
  - mscebba@manas.com.ar