tungsten 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/tungsten/_form_helpers.js +21 -0
- data/app/assets/javascripts/tungsten/code.js +20 -0
- data/app/assets/javascripts/tungsten/tungsten.js +4 -20
- data/app/assets/stylesheets/tungsten/_code-color.scss +0 -0
- data/app/assets/stylesheets/tungsten/_colors.yml +68 -4
- data/app/assets/stylesheets/tungsten/_index.scss +5 -0
- data/app/assets/stylesheets/tungsten/code/_codemirror.scss +56 -0
- data/app/assets/stylesheets/tungsten/code/_color.scss +58 -0
- data/app/assets/stylesheets/tungsten/code/_highlighted.scss +64 -0
- data/app/assets/stylesheets/tungsten/code/_index.scss +3 -0
- data/app/assets/stylesheets/tungsten/core/_buttons.scss +144 -0
- data/app/assets/stylesheets/tungsten/core/_cards.scss +90 -0
- data/app/assets/stylesheets/tungsten/core/_colors.scss +20 -0
- data/app/assets/stylesheets/tungsten/core/_globals.scss +172 -0
- data/app/assets/stylesheets/tungsten/core/_grid.scss +164 -0
- data/app/assets/stylesheets/tungsten/core/_index.scss +7 -13
- data/app/assets/stylesheets/tungsten/core/_layout.scss +47 -0
- data/app/assets/stylesheets/tungsten/core/_text.scss +219 -0
- data/app/assets/stylesheets/tungsten/form/_base.scss +235 -0
- data/app/assets/stylesheets/tungsten/form/_check-radio.scss +154 -0
- data/app/assets/stylesheets/tungsten/form/_check-switch.scss +104 -0
- data/app/assets/stylesheets/tungsten/form/_index.scss +4 -0
- data/app/assets/stylesheets/tungsten/form/_label-placeholder.scss +98 -0
- data/app/assets/stylesheets/tungsten/tungsten.scss +1 -3
- data/app/helpers/tungsten/card_helper.rb +76 -0
- data/app/helpers/tungsten/deployments_helper.rb +59 -0
- data/app/helpers/tungsten/form_helper.rb +509 -0
- data/app/helpers/tungsten/layout_helper.rb +7 -0
- data/app/helpers/tungsten/toggle_nav_helper.rb +84 -0
- data/app/views/layouts/tungsten/default.html.slim +47 -0
- data/app/views/shared/tungsten/_defs.html.slim +6 -0
- data/app/views/shared/tungsten/_footer.html.slim +2 -0
- data/app/views/shared/tungsten/_header.html.slim +2 -0
- data/config/data/deployments.yml +110 -0
- data/lib/tungsten.rb +26 -2
- data/lib/tungsten/helper.rb +4 -0
- data/lib/tungsten/version.rb +1 -1
- data/public/{tungsten-0.1.0.js → code-0.1.1.js} +43 -69
- data/public/code-0.1.1.js.gz +0 -0
- data/public/code-0.1.1.map.json +1 -0
- data/public/tungsten-0.1.1.css +1523 -0
- data/public/tungsten-0.1.1.css.gz +0 -0
- data/public/tungsten-0.1.1.js +79 -0
- data/public/tungsten-0.1.1.js.gz +0 -0
- data/public/tungsten-0.1.1.map.json +1 -0
- metadata +120 -16
- data/app/helpers/tungsten/application_helper.rb +0 -4
- data/app/views/layouts/tungsten/default.html.erb +0 -17
- data/public/tungsten-0.1.0.css +0 -17
- data/public/tungsten-0.1.0.css.gz +0 -0
- data/public/tungsten-0.1.0.js.gz +0 -0
- data/public/tungsten-0.1.0.map.json +0 -1
@@ -0,0 +1,59 @@
|
|
1
|
+
module Tungsten
|
2
|
+
module DeploymentsHelper
|
3
|
+
def deployment_data(name = nil)
|
4
|
+
deployments = Cyborg.config_data['deployments']['deployments']
|
5
|
+
|
6
|
+
if name.nil?
|
7
|
+
deployments
|
8
|
+
else
|
9
|
+
deployment = deployments.find { |d|
|
10
|
+
d[:name] =~ /#{name}/i
|
11
|
+
}
|
12
|
+
|
13
|
+
if deployment.nil? && !Rails.env.production?
|
14
|
+
raise %Q{No deployment type "#{name}" exists.}
|
15
|
+
end
|
16
|
+
|
17
|
+
deployment
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def deployment_graphic
|
22
|
+
@deployment_icon ||= Esvg.find_symbol('deployment')
|
23
|
+
end
|
24
|
+
|
25
|
+
def deployment_text(text, options={})
|
26
|
+
options = {
|
27
|
+
x: deployment_graphic.width.to_f / 2,
|
28
|
+
y: deployment_graphic.height.to_f / 2, fill: "currentColor",
|
29
|
+
"font-weight" => 700,
|
30
|
+
"font-size" => "57px",
|
31
|
+
"text-anchor" => "middle",
|
32
|
+
"dominant-baseline" =>"central",
|
33
|
+
"alignment-baseline" => "central"
|
34
|
+
}.merge(options)
|
35
|
+
|
36
|
+
content_tag(:text, text, options).html_safe
|
37
|
+
end
|
38
|
+
|
39
|
+
def deployment_svg(name, options={})
|
40
|
+
data = deployment_data(name)
|
41
|
+
(options[:use] ||= {})
|
42
|
+
options[:use][:stroke] ||= options.delete(:stroke) || "currentColor"
|
43
|
+
options[:use][:stroke_width] ||= options.delete(:stroke_width) || 4
|
44
|
+
options[:use][:class] = "deployment-icon-hex #{options[:use][:class]}".strip
|
45
|
+
|
46
|
+
options[:color] ||= "#fff"
|
47
|
+
options[:fill] ||= "url(##{name.downcase}-gradient-bg)"
|
48
|
+
options[:content] ||= deployment_text(data[:short_name], options.delete(:text) || {})
|
49
|
+
|
50
|
+
deployment_graphic.use(options).html_safe
|
51
|
+
end
|
52
|
+
|
53
|
+
def deployment_icon(name, options={})
|
54
|
+
options[:stroke_width] ||= 8
|
55
|
+
options[:text] ||= { "font-weight" => 600, "font-size" => "76px" }
|
56
|
+
deployment_svg name, options
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,509 @@
|
|
1
|
+
module Tungsten
|
2
|
+
module FormHelper
|
3
|
+
INPUT_OPTIONS = {
|
4
|
+
email: {
|
5
|
+
type: "email",
|
6
|
+
placeholder: "Email address",
|
7
|
+
pattern: "[^@]+@[^@]+\\.[a-zA-Z]{2,}",
|
8
|
+
autocorrect: "off",
|
9
|
+
autocapitalize: "off",
|
10
|
+
spellcheck: "false",
|
11
|
+
data: { message: "Please enter a valid email address." }
|
12
|
+
},
|
13
|
+
|
14
|
+
password: {
|
15
|
+
type: "password",
|
16
|
+
placeholder: "Password"
|
17
|
+
},
|
18
|
+
|
19
|
+
text: {
|
20
|
+
type: "text"
|
21
|
+
},
|
22
|
+
|
23
|
+
tel: {
|
24
|
+
type: "tel",
|
25
|
+
placeholder: "Phone number"
|
26
|
+
},
|
27
|
+
|
28
|
+
url: {
|
29
|
+
type: "text",
|
30
|
+
placeholder: "Web address",
|
31
|
+
autocorrect: "off",
|
32
|
+
autocapitalize: "off",
|
33
|
+
spellcheck: "false",
|
34
|
+
pattern: ".+\\.[a-zA-Z]{2,}"
|
35
|
+
},
|
36
|
+
|
37
|
+
card_number: {
|
38
|
+
type: "text",
|
39
|
+
required: true,
|
40
|
+
pattern: "[0-9 -]{13,20}",
|
41
|
+
placeholder: "Credit Card Number",
|
42
|
+
data: {
|
43
|
+
stripe: "number",
|
44
|
+
message: "Please enter a valid credit card number."
|
45
|
+
}
|
46
|
+
},
|
47
|
+
|
48
|
+
card_month: {
|
49
|
+
type: "text",
|
50
|
+
required: true,
|
51
|
+
pattern: "0[1-9]|1[012]",
|
52
|
+
placeholder: "MM",
|
53
|
+
data: {
|
54
|
+
stripe: "exp_month",
|
55
|
+
message: "Please enter a valid expiration month."
|
56
|
+
}
|
57
|
+
},
|
58
|
+
|
59
|
+
card_year: {
|
60
|
+
type: "text",
|
61
|
+
required: true,
|
62
|
+
pattern: "[0-9]{4}",
|
63
|
+
placeholder: "YYYY",
|
64
|
+
data: {
|
65
|
+
stripe: "exp_year",
|
66
|
+
message: "Please enter a valid expiration year."
|
67
|
+
}
|
68
|
+
},
|
69
|
+
|
70
|
+
card_cvc: {
|
71
|
+
type: "text",
|
72
|
+
required: true,
|
73
|
+
pattern: "[0-9]{3,4}",
|
74
|
+
placeholder: "CVC",
|
75
|
+
data: {
|
76
|
+
stripe: "cvc",
|
77
|
+
message: "Please enter a valid security code."
|
78
|
+
}
|
79
|
+
},
|
80
|
+
|
81
|
+
select_country: {
|
82
|
+
type: "select",
|
83
|
+
country_options: {
|
84
|
+
include_blank: "Select a country",
|
85
|
+
priority_countries: ["US", "GB", "CA"],
|
86
|
+
},
|
87
|
+
|
88
|
+
html_options: {}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
def table_form_for(record, options = {}, &block)
|
93
|
+
form_for record, options do |f|
|
94
|
+
table_form_tag f, &block
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def table_form_tag(form = nil)
|
99
|
+
form.style = 'table' if form
|
100
|
+
content_tag :div, class: ['table', 'table-form'] do
|
101
|
+
yield form if block_given?
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def stacked_form_for(record, options = {}, &block)
|
106
|
+
form_for record, options do |f|
|
107
|
+
stacked_form_tag f, &block
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def stacked_form_tag(form = nil)
|
112
|
+
form.style = 'stacked' if form
|
113
|
+
content_tag :div, class: 'stacked-form' do
|
114
|
+
yield form if block_given?
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def slider_input_tag(name, options={})
|
119
|
+
options = options.stringify_keys
|
120
|
+
classnames = options.delete('class') || ''
|
121
|
+
|
122
|
+
if label = options.delete('label')
|
123
|
+
label = content_tag(:span, class: 'label-text') { label }
|
124
|
+
end
|
125
|
+
|
126
|
+
data = options['data'] || {}
|
127
|
+
data['input'] ||= name
|
128
|
+
|
129
|
+
if options['position_label']
|
130
|
+
data['position_label'] = options['position_label']
|
131
|
+
end
|
132
|
+
|
133
|
+
# Set values (and max based on values size)
|
134
|
+
if values = options['values']
|
135
|
+
data['values'] = values.join(',')
|
136
|
+
options['max'] ||= values.size - 1
|
137
|
+
end
|
138
|
+
|
139
|
+
# Support legacy option
|
140
|
+
options['labels'] ||= options['label']
|
141
|
+
|
142
|
+
if labels = options['labels']
|
143
|
+
if labels.is_a?(Array)
|
144
|
+
data['label'] = labels.join(';')
|
145
|
+
options['max'] ||= labels.size - 1
|
146
|
+
elsif labels.is_a?(Hash)
|
147
|
+
labels.each do |label, value|
|
148
|
+
data['label-'+dasherize(label.to_s.downcase)] = value.join(';')
|
149
|
+
options['max'] ||= value.size - 1
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if labels == false
|
155
|
+
data['label'] = 'false'
|
156
|
+
end
|
157
|
+
|
158
|
+
if labels = options['external_labels']
|
159
|
+
if labels.is_a?(Hash)
|
160
|
+
labels.each do |label, value|
|
161
|
+
data['external-label-'+dasherize(label.to_s.downcase)] = value.join(';')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
if before = options['before']
|
167
|
+
if before.is_a?(String)
|
168
|
+
data['before-label'] = before
|
169
|
+
else
|
170
|
+
before.each do |key, value|
|
171
|
+
data["before-label-#{key}"] = value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
if mark = options['mark']
|
177
|
+
data['mark'] = mark.join(',')
|
178
|
+
end
|
179
|
+
|
180
|
+
if after = options['after']
|
181
|
+
if after.is_a?(String)
|
182
|
+
data['after-label'] = after
|
183
|
+
else
|
184
|
+
after.each do |key, value|
|
185
|
+
data["after-label-#{key}"] = value
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
if line_labels = options['line_labels']
|
191
|
+
data['line_labels'] = []
|
192
|
+
line_labels.each do |k, v|
|
193
|
+
data['line_labels'] << "#{k}:#{v}"
|
194
|
+
end
|
195
|
+
data['line_labels'] = data['line_labels'].join(';')
|
196
|
+
end
|
197
|
+
|
198
|
+
options['value'] ||= options['min'] || 0
|
199
|
+
|
200
|
+
html_options = {"id"=> options['id'], "class" => classnames, "type" => "range", "min" => options['min'], "max" => options['max'], "value" => options['value'] }.update('data' => data)
|
201
|
+
|
202
|
+
content_tag(:label, class: 'range-label') {
|
203
|
+
concat label if label
|
204
|
+
concat tag :input, html_options
|
205
|
+
}
|
206
|
+
end
|
207
|
+
alias :range_input_tag :slider_input_tag
|
208
|
+
|
209
|
+
# Country select
|
210
|
+
def select_country_tag(name, options = {}, country_options = {})
|
211
|
+
country_options.reverse_merge! INPUT_OPTIONS[:select_country][:country_options]
|
212
|
+
|
213
|
+
options = INPUT_OPTIONS[:select_country][:html_options].deep_merge options
|
214
|
+
options[:class] ||= ' '
|
215
|
+
options[:class] += " #{label_class(:select)}"
|
216
|
+
|
217
|
+
content_tag(:label, class: options.delete(:class) ) do
|
218
|
+
country_select :user, :country, country_options, options
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# Email inputs
|
223
|
+
def email_input_tag(name, value = nil, options = {})
|
224
|
+
input_tag(:email, name, value, options)
|
225
|
+
end
|
226
|
+
|
227
|
+
# Passowrd inputs
|
228
|
+
def password_input_tag(name, value = nil, options = {})
|
229
|
+
input_tag(:password, name, value, options)
|
230
|
+
end
|
231
|
+
|
232
|
+
def text_input_tag(name, value = nil, options = {})
|
233
|
+
input_tag(:text, name, value, options)
|
234
|
+
end
|
235
|
+
|
236
|
+
def url_input_tag(name, value = nil, options = {})
|
237
|
+
input_tag(:url, name, value, options)
|
238
|
+
end
|
239
|
+
|
240
|
+
def tel_input_tag(name, value = nil, options = {})
|
241
|
+
input_tag(:tel, name, value, options)
|
242
|
+
end
|
243
|
+
|
244
|
+
def textarea_tag(name, value = nil, options = {}, &block)
|
245
|
+
input_tag(:textarea, name, value, options, &block)
|
246
|
+
end
|
247
|
+
|
248
|
+
def number_input_tag(name, value = nil, options = {})
|
249
|
+
input_tag(:number, name, value, options)
|
250
|
+
end
|
251
|
+
|
252
|
+
def search_input_tag(name, value = nil, options = {})
|
253
|
+
input_tag(:search, name, value, options)
|
254
|
+
end
|
255
|
+
|
256
|
+
def card_number_tag(name, value=nil, options={})
|
257
|
+
input_tag(:card_number, name, value, options)
|
258
|
+
end
|
259
|
+
|
260
|
+
def card_month_tag(name, value=nil, options={})
|
261
|
+
input_tag(:card_month, name, value, options)
|
262
|
+
end
|
263
|
+
|
264
|
+
def card_year_tag(name, value=nil, options={})
|
265
|
+
input_tag(:card_year, name, value, options)
|
266
|
+
end
|
267
|
+
|
268
|
+
def card_cvc_tag(name, value=nil, options={})
|
269
|
+
input_tag(:card_cvc, name, value, options)
|
270
|
+
end
|
271
|
+
|
272
|
+
def radio_button_input_tag(name, value, checked = false, options = {})
|
273
|
+
|
274
|
+
if checked.is_a? Hash
|
275
|
+
options = checked
|
276
|
+
checked = false
|
277
|
+
end
|
278
|
+
|
279
|
+
options[:type] = :radio
|
280
|
+
|
281
|
+
tick_wrapper( name, options ) do
|
282
|
+
radio_button_tag(name, value, checked, options)
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
def checkbox_input_tag(name, checked = false, options = {})
|
288
|
+
value = true
|
289
|
+
|
290
|
+
if checked.is_a? Hash
|
291
|
+
options = checked
|
292
|
+
checked = false
|
293
|
+
end
|
294
|
+
|
295
|
+
options[:type] = :checkbox
|
296
|
+
|
297
|
+
tick_wrapper( name, options ) do
|
298
|
+
options.delete(:class)
|
299
|
+
concat tag :input, name: name, type: :hidden, value: false
|
300
|
+
concat check_box_tag(name, value, checked, options)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def select_input_tag(name, option_tags=nil, options={}, &block)
|
305
|
+
if option_tags.is_a? Hash
|
306
|
+
options = option_tags
|
307
|
+
option_tags = nil
|
308
|
+
end
|
309
|
+
|
310
|
+
options[:label] ||= options.delete(:label_placeholder)
|
311
|
+
|
312
|
+
option_tags ||= capture(&block).html_safe if block_given?
|
313
|
+
|
314
|
+
input_tag(:select, name, option_tags.html_safe, options)
|
315
|
+
end
|
316
|
+
|
317
|
+
def switch_input_tag(name, checked = false, options = {})
|
318
|
+
|
319
|
+
if checked.is_a? Hash
|
320
|
+
options = checked
|
321
|
+
checked = false
|
322
|
+
end
|
323
|
+
|
324
|
+
if label_text = options.delete(:label)
|
325
|
+
label_text = content_tag(:span, class: 'label-text') { label_text }
|
326
|
+
end
|
327
|
+
|
328
|
+
content_tag(:label, class: 'check-switch switch-label', data: { input: 'checkbox' }) do
|
329
|
+
concat tag :input, name: name, type: :hidden, value: false
|
330
|
+
concat label_text
|
331
|
+
concat check_box_tag(name, true, checked, options)
|
332
|
+
|
333
|
+
concat content_tag(:span, class: 'check-switch-panel') {
|
334
|
+
concat content_tag(:span, class: 'check-switch-tick') { '' }
|
335
|
+
}
|
336
|
+
|
337
|
+
concat content_tag(:span, class: 'check-switch-label') { 'Enable' }
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
private
|
343
|
+
|
344
|
+
def base_tag(name, value, options, type, &block)
|
345
|
+
case type
|
346
|
+
when :select
|
347
|
+
value = value.html_safe if value
|
348
|
+
select_tag(name, value, options)
|
349
|
+
when :textarea
|
350
|
+
value ||= capture(&block).html_safe if block_given?
|
351
|
+
options[:class] = "#{options[:class]} empty".strip if value.nil?
|
352
|
+
text_area_tag(name, value, options)
|
353
|
+
else
|
354
|
+
options[:class] = "#{options[:class]} empty".strip if value.nil?
|
355
|
+
text_field_tag(name, value, options)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def input_tag(type, name, value, options=nil, &block)
|
360
|
+
type.to_sym! if type.is_a?( String )
|
361
|
+
|
362
|
+
if value.is_a? Hash
|
363
|
+
options = value
|
364
|
+
value = nil
|
365
|
+
end
|
366
|
+
|
367
|
+
options = (INPUT_OPTIONS[type]||{}).deep_merge options
|
368
|
+
options[:type] ||= type
|
369
|
+
|
370
|
+
|
371
|
+
label_options = {
|
372
|
+
class: "#{label_class(options[:type])} #{options.delete(:class)}"
|
373
|
+
}
|
374
|
+
|
375
|
+
if label_placeholder = options.delete(:label_placeholder)
|
376
|
+
options[:placeholder] = label_placeholder
|
377
|
+
label_placeholder = content_tag(:span, class: 'placeholder-label-text') { label_placeholder }
|
378
|
+
label_options[:class] += ' placeholder-label'
|
379
|
+
end
|
380
|
+
|
381
|
+
if !label_placeholder && label_text = options.delete(:label)
|
382
|
+
label_text = content_tag(:span, class: 'label-text') { label_text }
|
383
|
+
end
|
384
|
+
|
385
|
+
content_tag(:label, label_options) {
|
386
|
+
concat label_text
|
387
|
+
concat base_tag(name, value, options, type, &block)
|
388
|
+
concat label_placeholder
|
389
|
+
}
|
390
|
+
|
391
|
+
end
|
392
|
+
|
393
|
+
private
|
394
|
+
|
395
|
+
def label_class( type )
|
396
|
+
type = case type
|
397
|
+
when :tel, :password, :number, :url, :email, :search
|
398
|
+
"text"
|
399
|
+
when :checkbox, :radio
|
400
|
+
"tick"
|
401
|
+
else
|
402
|
+
type.to_s
|
403
|
+
end
|
404
|
+
|
405
|
+
"#{type}-label"
|
406
|
+
end
|
407
|
+
|
408
|
+
def tick_wrapper( name, options, &block )
|
409
|
+
|
410
|
+
tag = capture(&block).html_safe
|
411
|
+
|
412
|
+
tick = content_tag(:span, class: 'tick') {''}
|
413
|
+
label = content_tag(:span, class: 'label-text') { options.delete(:label) || name }
|
414
|
+
|
415
|
+
options[:class] ||= ' '
|
416
|
+
options[:class] << "#{label_class( options.delete(:type) )} tick-box"
|
417
|
+
|
418
|
+
content_tag(:label, options ) {
|
419
|
+
concat tag.html_safe
|
420
|
+
concat tick
|
421
|
+
concat content_tag(:span, class: 'label-text-wrapper') { label }
|
422
|
+
}
|
423
|
+
end
|
424
|
+
|
425
|
+
def slider_input_tag(name, options={})
|
426
|
+
options = options.stringify_keys
|
427
|
+
classnames = options.delete('class') || ''
|
428
|
+
|
429
|
+
data = options['data'] || {}
|
430
|
+
data['input'] ||= name
|
431
|
+
|
432
|
+
if options['position_label']
|
433
|
+
data['position_label'] = options['position_label']
|
434
|
+
end
|
435
|
+
|
436
|
+
# Set values (and max based on values size)
|
437
|
+
if values = options['values']
|
438
|
+
data['values'] = values.join(',')
|
439
|
+
options['max'] ||= values.size - 1
|
440
|
+
end
|
441
|
+
|
442
|
+
# Support legacy option
|
443
|
+
options['labels'] ||= options['label']
|
444
|
+
|
445
|
+
if labels = options['labels']
|
446
|
+
if labels.is_a?(Array)
|
447
|
+
data['label'] = labels.join(';')
|
448
|
+
options['max'] ||= labels.size - 1
|
449
|
+
elsif labels.is_a?(Hash)
|
450
|
+
labels.each do |label, value|
|
451
|
+
data['label-'+dasherize(label.to_s.downcase)] = value.join(';')
|
452
|
+
options['max'] ||= value.size - 1
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
if labels == false
|
458
|
+
data['label'] = 'false'
|
459
|
+
end
|
460
|
+
|
461
|
+
if labels = options['external_labels']
|
462
|
+
if labels.is_a?(Hash)
|
463
|
+
labels.each do |label, value|
|
464
|
+
l = label.to_s.downcase.dasherize
|
465
|
+
data['external-label-'+l] = value.join(';')
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
if before = options['before']
|
471
|
+
if before.is_a?(String)
|
472
|
+
data['before-label'] = before
|
473
|
+
else
|
474
|
+
before.each do |key, value|
|
475
|
+
data["before-label-#{key}"] = value
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
if mark = options['mark']
|
481
|
+
data['mark'] = mark.join(',')
|
482
|
+
end
|
483
|
+
|
484
|
+
if after = options['after']
|
485
|
+
if after.is_a?(String)
|
486
|
+
data['after-label'] = after
|
487
|
+
else
|
488
|
+
after.each do |key, value|
|
489
|
+
data["after-label-#{key}"] = value
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
if line_labels = options['line_labels']
|
495
|
+
data['line_labels'] = []
|
496
|
+
line_labels.each do |k, v|
|
497
|
+
data['line_labels'] << "#{k}:#{v}"
|
498
|
+
end
|
499
|
+
data['line_labels'] = data['line_labels'].join(';')
|
500
|
+
end
|
501
|
+
|
502
|
+
options['value'] ||= options['min'] || 0
|
503
|
+
|
504
|
+
html_options = {"class" => classnames, "type" => "range", "min" => options['min'], "max" => options['max'], "value" => options['value'] }.update('data' => data)
|
505
|
+
tag :input, html_options
|
506
|
+
end
|
507
|
+
alias :range_input_tag :slider_input_tag
|
508
|
+
end
|
509
|
+
end
|