merb-ui 0.1

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.
@@ -0,0 +1,56 @@
1
+ module Merb::Helpers::Form
2
+ def date_field(*args)
3
+ if bound?(*args)
4
+ current_form_context.bound_date_field(*args)
5
+ else
6
+ current_form_context.unbound_date_field(*args)
7
+ end
8
+ end
9
+ end
10
+
11
+ module Merb::Helpers::Form::Builder
12
+ class Base
13
+ def bound_date_field(method, attrs = {})
14
+ name = control_name(method)
15
+ update_bound_controls(method, attrs, "text")
16
+ unbound_date_field({:name => name, :value => @obj.send(method)}.merge(attrs))
17
+ end
18
+
19
+ def unbound_date_field(attrs)
20
+ update_unbound_controls(attrs, "date")
21
+ if attrs[:name] =~ /\[(.*)\]/
22
+ date = @obj.send($1)
23
+ end
24
+ date = DateTime::now() if date.nil?
25
+
26
+ month_attrs = attrs.merge(
27
+ :class => "date month",
28
+ :selected => date.month,
29
+ :name => attrs[:name] + '[month]',
30
+ :id => attrs[:id] + '_month',
31
+ :collection => (1..12).map{|i|[i, DateTime::MONTHNAMES[i]]}
32
+ )
33
+
34
+ day_attrs = attrs.merge(
35
+ :class => "date day",
36
+ :selected => date.day.to_s,
37
+ :name => attrs[:name] + '[day]',
38
+ :id => attrs[:id] + '_day',
39
+ :collection => (1..31).map{|i|i.to_s},
40
+ :label => nil
41
+ )
42
+
43
+ year_attrs = attrs.merge(
44
+ :class => "date year",
45
+ :selected => date.year.to_s,
46
+ :name => attrs[:name] + '[year]',
47
+ :id => attrs[:id] + '_year',
48
+ :collection => (1900..Time.now.year).map{|i|i.to_s}.reverse,
49
+ :label => nil
50
+ )
51
+
52
+ unbound_select(month_attrs) + unbound_select(day_attrs) + unbound_select(year_attrs)
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,78 @@
1
+ module Merb::MerbUi::StylesHelper
2
+
3
+ def border_radius(options={})
4
+ options[:amount] ||= 0.5
5
+ if mui_browser == 'gecko'
6
+ property('-moz') do
7
+ property('border') do
8
+ if options[:edge] == 'bottom'
9
+ property('radius') do
10
+ property('bottomleft', :value => %{#{options[:amount]}em})
11
+ property('bottomright', :value => %{#{options[:amount]}em})
12
+ property('topleft', :value => 0)
13
+ property('topright', :value => 0)
14
+ end
15
+ elsif options[:edge] == 'top'
16
+ property('radius') do
17
+ property('bottomleft', :value => 0)
18
+ property('bottomright', :value => 0)
19
+ property('topleft', :value => %{#{options[:amount]}em})
20
+ property('topright', :value => %{#{options[:amount]}em})
21
+ end
22
+ else
23
+ property('radius', :value => %{#{options[:amount]}em})
24
+ end
25
+ end
26
+ end
27
+ elsif mui_browser == 'webkit'
28
+ property('-webkit') do
29
+ property('border') do
30
+ if options[:edge] == 'bottom'
31
+ property('bottom-left-radius', :value => %{#{options[:amount]}em})
32
+ property('bottom-right-radius', :value => %{#{options[:amount]}em})
33
+ property('top-left-radius', :value => 0)
34
+ property('top-right-radius', :value => 0)
35
+ elsif options[:edge] == 'top'
36
+ property('bottom-left-radius', :value => 0)
37
+ property('bottom-right-radius', :value => 0)
38
+ property('top-left-radius', :value => %{#{options[:amount]}em})
39
+ property('top-right-radius', :value => %{#{options[:amount]}em})
40
+ else
41
+ property('radius', :value => %{#{options[:amount]}em})
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def color(r,g,b)
49
+ %{rgb(#{decimal_to_rgb(r)}, #{decimal_to_rgb(g)}, #{decimal_to_rgb(b)})}
50
+ end
51
+
52
+ def decimal_to_rgb(d)
53
+ (d * 255).to_i
54
+ end
55
+
56
+ def has_layout
57
+ 'min-height: 0;' if msie?
58
+ end
59
+
60
+ def property(property, options={})
61
+ @parent ||= ''
62
+ @child ||= ''
63
+ if block_given?
64
+ @child = nil
65
+ @parent << %{#{property}-}
66
+ yield
67
+ @parent = nil
68
+ @child
69
+ elsif options[:value]
70
+ @child << %{\r #{@parent}#{property}: #{options[:value]};}
71
+ end
72
+ end
73
+
74
+ def selector(selector)
75
+ "#{selector} {#{yield}\r}\r"
76
+ end
77
+
78
+ end
@@ -0,0 +1,464 @@
1
+ <%= @browser -%>
2
+
3
+ * {
4
+ font-family: "Lucida Grande", "Lucida Sans Unicode", sans-serif;
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+ body {
9
+ font-size: 13px;
10
+ }
11
+ b, em, h1, i, label, strong {
12
+ font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", sans-serif;
13
+ }
14
+ b, em, h1, label, strong {
15
+ font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", sans-serif;
16
+ font-weight: bold;
17
+ }
18
+
19
+ /* bar */
20
+
21
+ div.mui_bar {
22
+ background-color: <%= color(0.1, 0.1, 0.1) %>;
23
+ background-image: url('/slices/merb-ui/images/reflection.png');
24
+ background-position: center center;
25
+ background-repeat: repeat-x;
26
+ border-collapse: collapse;
27
+ color: <%= color(1, 1, 1) %>;
28
+ width: 100%;
29
+ }
30
+
31
+ /* block */
32
+
33
+ *.mui_block {
34
+ margin: 0.5em;
35
+ }
36
+ span.mui_block {
37
+ display: inline-block;
38
+ vertical-align: top;
39
+ }
40
+ div.mui_block_status {
41
+ background-image: url('/slices/merb-ui/images/transparency.png');
42
+ border-color: <%= color(0, 0, 0) %>;
43
+ border-style: solid;
44
+ border-width: 1px;
45
+ color: <%= color(0.5, 0.5, 0.5) %>;
46
+ display: inline-block;
47
+ padding: 1em;
48
+ position: absolute;
49
+ right: 1.5em;
50
+ top: 0;
51
+ <%= border_radius %>
52
+ }
53
+ div.mui_block_tray {
54
+ background-color: <%= color(0.95, 0.95, 0.95) %>;
55
+ border-bottom-color: <%= color(0.9, 0.9, 0.9) %>;
56
+ border-left-color: <%= color(0.8, 0.8, 0.8) %>;
57
+ border-right-color: <%= color(0.8, 0.8, 0.8) %>;
58
+ border-top-color: <%= color(0.7, 0.7, 0.7) %>;
59
+ border-style: solid;
60
+ border-width: 1px;
61
+ padding: 1em;
62
+ <%= border_radius %>
63
+ }
64
+ div.mui_block_tray *.mui_block {
65
+ margin: 0;
66
+ }
67
+ *.mui_block+*.mui_block, div.mui_title+*.mui_block {
68
+ margin-top: 1em !important;
69
+ }
70
+
71
+ /* button */
72
+
73
+ *.mui_button {
74
+ background-image: url('/slices/merb-ui/images/reflection.png');
75
+ background-position: center center;
76
+ background-repeat: repeat-x;
77
+ border-style: solid;
78
+ border-width: 1px;
79
+ font-size: 0.85em;
80
+ min-height: 1.5em;
81
+ padding-left: 1em;
82
+ padding-right: 1em;
83
+ <%= border_radius %>
84
+ }
85
+ *.mui_button_tone_neutral {
86
+ background-color: <%= color(0.2, 0.2, 0.2) %>;
87
+ border-bottom-color: <%= color(0, 0, 0) %>;
88
+ border-left-color: <%= color(0.1, 0.1, 0.1) %>;
89
+ border-right-color: <%= color(0.1, 0.1, 0.1) %>;
90
+ border-top-color: <%= color(0.2, 0.2, 0.2) %>;
91
+ color: <%= color(1, 1, 1) %>;
92
+ }
93
+ *.mui_button_tone_neutral:hover {
94
+ background-color: <%= color(0.3, 0.3, 0.3) %>;
95
+ border-bottom-color: <%= color(0.1, 0.1, 0.1) %>;
96
+ border-left-color: <%= color(0.2, 0.2, 0.2) %>;
97
+ border-right-color: <%= color(0.2, 0.2, 0.2) %>;
98
+ border-top-color: <%= color(0.3, 0.3, 0.3) %>;
99
+ color: <%= color(1, 1, 1) %>;
100
+ }
101
+ *.mui_button_tone_positive {
102
+ background-color: <%= color(0.1, 0.5, 0.1) %>;
103
+ border-bottom-color: <%= color(0, 0.3, 0) %>;
104
+ border-left-color: <%= color(0, 0.4, 0) %>;
105
+ border-right-color: <%= color(0, 0.4, 0) %>;
106
+ border-top-color: <%= color(0.1, 0.5, 0.1) %>;
107
+ color: <%= color(1, 1, 1) %>;
108
+ }
109
+ *.mui_button_tone_positive:hover {
110
+ background-color: <%= color(0.2, 0.6, 0.2) %>;
111
+ border-bottom-color: <%= color(0, 0.4, 0) %>;
112
+ border-left-color: <%= color(0.1, 0.5, 0.1) %>;
113
+ border-right-color: <%= color(0.1, 0.5, 0.1) %>;
114
+ border-top-color: <%= color(0.2, 0.6, 0.2) %>;
115
+ color: <%= color(1, 1, 1) %>;
116
+ }
117
+ *.mui_button_tone_negative {
118
+ background-color: <%= color(0.6, 0, 0) %>;
119
+ border-bottom-color: <%= color(0.4, 0, 0) %>;
120
+ border-left-color: <%= color(0.5, 0, 0) %>;
121
+ border-right-color: <%= color(0.4, 0, 0) %>;
122
+ border-top-color: <%= color(0.6, 0, 0) %>;
123
+ color: <%= color(1, 1, 1) %>;
124
+ }
125
+ *.mui_button_tone_negative:hover {
126
+ background-color: <%= color(0.7, 0, 0) %>;
127
+ border-bottom-color: <%= color(0.5, 0, 0) %>;
128
+ border-left-color: <%= color(0.6, 0, 0) %>;
129
+ border-right-color: <%= color(0.6, 0, 0) %>;
130
+ border-top-color: <%= color(0.7, 0, 0) %>;
131
+ color: <%= color(1, 1, 1) %>;
132
+ }
133
+ button.mui_button {
134
+ padding: 0.5em;
135
+ text-align: left;
136
+ }
137
+ button.mui_button img {
138
+ border-bottom-color: <%= color(0.3, 0.3, 0.3) %>;
139
+ border-left-color: <%= color(0.3, 0.3, 0.3) %>;
140
+ border-right-color: <%= color(0.3, 0.3, 0.3) %>;
141
+ border-top-color: <%= color(0.4, 0.4, 0.4) %>;
142
+ border-style: solid;
143
+ border-width: 1px;
144
+ <%= border_radius %>
145
+ }
146
+ button.mui_button table {
147
+ border-collapse: collapse;
148
+ }
149
+ button.mui_button td {
150
+ padding-right: 1em;
151
+ }
152
+
153
+ /* checkbox */
154
+
155
+ input.mui_checkbox {
156
+ vertical-align: middle;
157
+ }
158
+
159
+ /* code */
160
+
161
+ code.mui_code {
162
+ background-color: <%= color(0, 0, 0) %>;
163
+ border-color: <%= color(0, 0, 0) %>;
164
+ border-style: solid;
165
+ border-width: 1px;
166
+ color: <%= color(1, 1, 1) %>;
167
+ display: block;
168
+ font-family: 'Bitstream Vera Sans Mono', 'Monaco', 'Lucida Console' monospace;
169
+ padding-bottom: 15px;
170
+ padding-left: 30px;
171
+ padding-right: 30px;
172
+ padding-top: 15px;
173
+ margin-top: 5px;
174
+ }
175
+ code.mui_code var {
176
+ color: <%= color(0.75, 0.75, 0.75) %>;
177
+ }
178
+
179
+ /* copyright */
180
+
181
+ div.mui_copyright {
182
+ color: <%= color(0.5, 0.5, 0.5) %>;
183
+ font-size: 0.85em;
184
+ padding-bottom: 2em;
185
+ padding-top: 4em;
186
+ text-align: center;
187
+ }
188
+
189
+ /* date */
190
+
191
+ span.mui_date {
192
+ color: <%= color(0.5, 0.5, 0.5) %>;
193
+ font-size: 0.85em;
194
+ }
195
+
196
+ /* desktop */
197
+
198
+ div.mui_desktop {
199
+ padding-left: 1.5em;
200
+ padding-right: 1.5em;
201
+ padding-top: 1.5em;
202
+ }
203
+
204
+ /* divider */
205
+
206
+ hr.mui_divider {
207
+ background: <%= color(0.85, 0.85, 0.85) %>;
208
+ border: none;
209
+ height: 1px;
210
+ margin-bottom: 1em;
211
+ margin-left: 0.5em;
212
+ margin-right: 0.5em;
213
+ margin-top: 2em;
214
+ }
215
+ div.mui_block_tray hr.mui_divider {
216
+ margin-bottom: 1em;
217
+ margin-left: 0;
218
+ margin-right: 0;
219
+ margin-top: 1.5em;
220
+ }
221
+
222
+ /* form */
223
+
224
+ label {
225
+ display: block;
226
+ font-size: 0.85em;
227
+ }
228
+ input.mui_check {
229
+ margin-right: 0.5em;
230
+ }
231
+ input.mui_password, input.mui_search, input.mui_text, select.mui_menu, textarea.mui_hyper_text {
232
+ background-color: <%= color(1, 1, 1) %>;
233
+ border-bottom-color: <%= color(0.75, 0.75, 0.75) %>;
234
+ border-left-color: <%= color(0.65, 0.65, 0.65) %>;
235
+ border-right-color: <%= color(0.65, 0.65, 0.65) %>;
236
+ border-style: solid;
237
+ border-top-color: <%= color(0.55, 0.55, 0.55) %>;
238
+ border-width: 1px;
239
+ color: <%= color(0, 0, 0) %>;
240
+ display: block;
241
+ font-size: 0.9em;
242
+ min-height: 1.5em;
243
+ margin-top: 0.25em;
244
+ <%= border_radius(:amount => 0.4) %>
245
+ }
246
+ input.mui_search {
247
+ margin-right: 0.5em;
248
+ }
249
+ select.date {
250
+ margin-top: 0.25em;
251
+ }
252
+ select.month, select.day {
253
+ margin-right: 0.25em;
254
+ }
255
+ select.mui_menu {
256
+ height: 20em;
257
+ }
258
+ textarea.mui_hyper_text {
259
+ font-family: 'Bitstream Vera Sans Mono', 'Monaco', 'Lucida Console' monospace;
260
+ height: 20em;
261
+ width: 40em;
262
+ }
263
+
264
+ /* gallery */
265
+
266
+ div.mui_gallery {
267
+ background-color: <%= color(0, 0, 0) %>;
268
+ }
269
+
270
+ /* grid */
271
+
272
+ table.mui_grid {
273
+ border-collapse: collapse;
274
+ }
275
+ *.mui_block+table.mui_grid, table.mui_grid+*.mui_block {
276
+ margin-top: 1em;
277
+ }
278
+
279
+ /* image */
280
+
281
+ img.mui_image {
282
+ background-repeat: no-repeat;
283
+ display: block;
284
+ }
285
+ img.mui_image_rounded {
286
+ <%= border_radius %>
287
+ }
288
+ img.mui_image_border {
289
+ border-color: <%= color(0.5, 0.5, 0.5) %>;
290
+ border-style: solid;
291
+ border-width: 1px;
292
+ }
293
+
294
+ /* key */
295
+
296
+ kbd.mui_key {
297
+ }
298
+
299
+ /* link */
300
+
301
+ a.mui_link {
302
+ color: #0066ff;
303
+ text-decoration: none;
304
+ }
305
+ a.mui_link:visited {
306
+ color: #993399;
307
+ }
308
+ a.mui_link:active {
309
+ color: #3399ff;
310
+ outline: 0;
311
+ text-decoration: underline;
312
+ }
313
+ a.mui_link:focus {
314
+ color: #3399ff;
315
+ outline: 0;
316
+ }
317
+ a.mui_link:hover {
318
+ text-decoration: underline;
319
+ }
320
+
321
+ /* list */
322
+
323
+ ul.mui_list {
324
+ list-style-position: inside;
325
+ margin-left: 0.25em;
326
+ }
327
+ li.mui_list_item {
328
+ margin-top: 0.25em;
329
+ }
330
+
331
+ /* menu */
332
+
333
+ select.mui_menu {
334
+ padding-left: 2px;
335
+ padding-right: 2px;
336
+ }
337
+
338
+ /* message */
339
+
340
+ div.mui_message {
341
+ background-image: url('/slices/merb-ui/images/transparency.png');
342
+ border-style: solid;
343
+ border-bottom-width: 1px;
344
+ border-left-width: 1px;
345
+ border-right-width: 1px;
346
+ border-top-width: 0;
347
+ color: <%= color(1, 1, 1) %>;
348
+ display: none;
349
+ line-height: 2em;
350
+ max-width: 60%;
351
+ min-width: 40%;
352
+ padding: 1em;
353
+ white-space: nowrap;
354
+ <%= border_radius(:edge => 'bottom') %>
355
+ }
356
+ div.mui_message input.mui_button {
357
+ position: absolute;
358
+ right: 1em;
359
+ top: 1em;
360
+ }
361
+ div.mui_message_positive {
362
+ border-color: <%= color(0, 0.6, 0) %>;
363
+ }
364
+ div.mui_message_negative {
365
+ border-color: <%= color(0.6, 0, 0) %>;
366
+ }
367
+ div.mui_message_neutral {
368
+ border-color: <%= color(0, 0, 0) %>;
369
+ }
370
+
371
+ /* paragraph */
372
+
373
+ p.mui_paragraph {
374
+ color: <%= color(0.2, 0.2, 0.2) %>;
375
+ line-height: 1.5em;
376
+ max-width: 40em;
377
+ }
378
+ p.mui_paragraph+p.mui_paragraph {
379
+ margin-top: 1em;
380
+ }
381
+
382
+ /* quote */
383
+
384
+ blockquote.mui_quote {
385
+ background-color: #e5e5e5;
386
+ }
387
+
388
+ /* tab */
389
+
390
+ a.mui_tab {
391
+ background-color: <%= color(0.1, 0.1, 0.1) %>;
392
+ background-image: url('/slices/merb-ui/images/reflection.png');
393
+ background-position: center center;
394
+ background-repeat: repeat-x;
395
+ border-bottom: none;
396
+ border-left: none;
397
+ border-right-color: <%= color(0.1, 0.1, 0.1) %>;
398
+ border-right-style: solid;
399
+ border-right-width: 1px;
400
+ border-top: none;
401
+ color: <%= color(1, 1, 1) %>;
402
+ display: inline-block;
403
+ font-size: 1em;
404
+ line-height: 2em;
405
+ padding-left: 2em;
406
+ padding-right: 2em;
407
+ text-align: center;
408
+ text-decoration: none;
409
+ }
410
+ a.mui_tab:hover {
411
+ background-color: <%= color(0.2, 0.2, 0.2) %>;
412
+ }
413
+ a.mui_tab:active, *.mui_button:active, *.mui_selected {
414
+ background-color: <%= color(0, 0.3, 0.9) %> !important;
415
+ }
416
+
417
+ /* title */
418
+
419
+ div.mui_title {
420
+ color: <%= color(0, 0, 0) %>;
421
+ font-weight: bold;
422
+ letter-spacing: -0.1em;
423
+ line-height: 1em;
424
+ margin-left: -0.05em;
425
+ }
426
+
427
+ /* truncate */
428
+
429
+ span.mui_truncate {
430
+ color: <%= color(0.5, 0.5, 0.5) %>;
431
+ font-size: 0.85em;
432
+ }
433
+
434
+ /* window */
435
+
436
+ table.mui_window {
437
+ border-collapse: collapse;
438
+ }
439
+ table.mui_window_bar {
440
+ background-color: <%= color(0.1, 0.1, 0.1) %>;
441
+ background-image: url('/slices/merb-ui/images/reflection.png');
442
+ background-position: center center;
443
+ background-repeat: repeat-x;
444
+ color: <%= color(1, 1, 1) %>;
445
+ height: 2em;
446
+ width: 100%;
447
+ <%= border_radius(:edge => 'top') %>
448
+ }
449
+ td.mui_window_bar_end {
450
+ padding-right: 0.75em;
451
+ text-align: right;
452
+ }
453
+ td.mui_window_title {
454
+ padding-left: 0.75em;
455
+ }
456
+ td.mui_window_content {
457
+ background-image: url('/slices/merb-ui/images/transparency.png');
458
+ color: <%= color(1, 1, 1) %>;
459
+ padding: 0.5em;
460
+ <%= border_radius(:edge => 'bottom') %>
461
+ }
462
+ div.mui_window_target {
463
+ display: none;
464
+ }