effective_bootstrap 0.10.0 → 0.10.4
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/effective_bootstrap/reveal_mail_to.js +12 -0
- data/app/assets/javascripts/effective_bootstrap.js +1 -1
- data/app/assets/stylesheets/effective_bootstrap/forms.scss +4 -0
- data/app/helpers/effective_bootstrap_helper.rb +7 -2
- data/app/models/effective/form_builder.rb +0 -4
- data/app/models/effective/form_input.rb +3 -6
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +3 -5
- data/app/assets/javascripts/effective_scale/initialize.js.coffee +0 -38
- data/app/assets/javascripts/effective_scale/input.js +0 -1
- data/app/models/effective/form_inputs/scale_field.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce183f7b5ec8710057b26c596d126df576635f2f056c2b5f691c817aa043d49d
|
4
|
+
data.tar.gz: 2e4697f95f477939c744e6fd7e7e44426f15975b192fae10c7061baaab384096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf040655168c88bfe628a87182d061147ecc7b82554e268fa9b1ac75cbbf2cdb911326642c730a568d60438762cb71da7fcdc57f2f46622bf40f99d8051d9392
|
7
|
+
data.tar.gz: 01ab704d07b028abc72d72311e6ac090bc68de56993c1be93d8b74945d8cccb560275d50ba71fcdfb798834cb99f07ee615f378c262236a284791bdf6f98fc78
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// reveal_mail_to
|
2
|
+
$(document).on('click', '[data-mailto-rot13]', function(event) {
|
3
|
+
event.preventDefault();
|
4
|
+
|
5
|
+
var $link = $(event.currentTarget);
|
6
|
+
|
7
|
+
var email = $link.data('mailto-rot13').replace(/[a-zA-Z]/g, function(c) {
|
8
|
+
return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
9
|
+
});
|
10
|
+
|
11
|
+
$link.attr('href', 'mailto:' + email).html(email).removeAttr('data-mailto-rot13');
|
12
|
+
});
|
@@ -3,6 +3,7 @@
|
|
3
3
|
//= require ./effective_bootstrap/form
|
4
4
|
//= require ./effective_bootstrap/logic
|
5
5
|
//= require ./effective_bootstrap/other
|
6
|
+
//= require ./effective_bootstrap/reveal_mail_to
|
6
7
|
//= require ./effective_bootstrap/tabs
|
7
8
|
|
8
9
|
//= require ./effective_datetime/input
|
@@ -25,6 +26,5 @@
|
|
25
26
|
//= require ./effective_price/input
|
26
27
|
//= require ./effective_radio/input
|
27
28
|
//= require ./effective_rich_text_area/input
|
28
|
-
//= require ./effective_scale/input
|
29
29
|
//= require ./effective_select/input
|
30
30
|
//= require ./effective_select_or_text/input
|
@@ -63,3 +63,7 @@ div.form-group > label + .btn-group { display: block; }
|
|
63
63
|
|
64
64
|
.effective-checks.is-invalid .invalid-feedback { display: block; }
|
65
65
|
.effective-checks.is-valid .valid-feedback { display: block; }
|
66
|
+
|
67
|
+
.invalid-feedback { text-transform: capitalize; }
|
68
|
+
.valid-feedback { display: none; }
|
69
|
+
|
@@ -277,9 +277,9 @@ module EffectiveBootstrapHelper
|
|
277
277
|
def list_group_link_to(label, path, opts = {})
|
278
278
|
# Regular link item
|
279
279
|
opts[:class] = if request.fullpath.include?(path)
|
280
|
-
[opts[:class], 'list-group-item active'].compact.join(' ')
|
280
|
+
[opts[:class], 'list-group-item list-group-item-action active'].compact.join(' ')
|
281
281
|
else
|
282
|
-
[opts[:class], 'list-group-item'].compact.join(' ')
|
282
|
+
[opts[:class], 'list-group-item list-group-item-action'].compact.join(' ')
|
283
283
|
end
|
284
284
|
|
285
285
|
link_to(label.to_s, path, opts)
|
@@ -470,6 +470,11 @@ module EffectiveBootstrapHelper
|
|
470
470
|
# Let Kaminari override this method.
|
471
471
|
alias_method(:paginate, :bootstrap_paginate) unless (respond_to?(:paginate) || defined?(Kaminari))
|
472
472
|
|
473
|
+
def reveal_mail_to(email)
|
474
|
+
raise('expected an email') unless email.kind_of?(String) && email.include?('@')
|
475
|
+
link_to 'Click to reveal email', '#', 'data-mailto-rot13' => email.tr('A-Za-z', 'N-ZA-Mn-za-m')
|
476
|
+
end
|
477
|
+
|
473
478
|
# Tabs DSL
|
474
479
|
# Inserts both the tablist and the tabpanel
|
475
480
|
|
@@ -145,10 +145,6 @@ module Effective
|
|
145
145
|
Effective::FormInputs::Save.new(name, options, builder: self).to_html { super(name, options) }
|
146
146
|
end
|
147
147
|
|
148
|
-
def scale_field(name, options = {})
|
149
|
-
Effective::FormInputs::ScaleField.new(name, options, builder: self).to_html
|
150
|
-
end
|
151
|
-
|
152
148
|
def select(name, choices = nil, *args)
|
153
149
|
options = args.extract_options!.merge!(collection: choices)
|
154
150
|
Effective::FormInputs::Select.new(name, options, builder: self).to_html
|
@@ -180,13 +180,10 @@ module Effective
|
|
180
180
|
|
181
181
|
invalid = object.errors[name].to_sentence.presence if object.respond_to?(:errors)
|
182
182
|
invalid ||= options[:feedback][:invalid].delete(:text).presence
|
183
|
-
invalid ||= [("
|
184
|
-
invalid ||= "
|
183
|
+
invalid ||= [("Can't be blank" if options[:input][:required]), ('must be valid' if validated?(name))].tap(&:compact!).join(' and ').presence
|
184
|
+
invalid ||= "Can't be blank or is invalid"
|
185
185
|
|
186
|
-
|
187
|
-
|
188
|
-
content_tag(:div, invalid.html_safe, options[:feedback][:invalid]) +
|
189
|
-
content_tag(:div, valid.html_safe, options[:feedback][:valid])
|
186
|
+
content_tag(:div, invalid.html_safe, options[:feedback][:invalid])
|
190
187
|
end
|
191
188
|
|
192
189
|
def has_error?(name = nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -428,6 +428,7 @@ files:
|
|
428
428
|
- app/assets/javascripts/effective_bootstrap/form.js.coffee
|
429
429
|
- app/assets/javascripts/effective_bootstrap/logic.js.coffee
|
430
430
|
- app/assets/javascripts/effective_bootstrap/other.js.coffee
|
431
|
+
- app/assets/javascripts/effective_bootstrap/reveal_mail_to.js
|
431
432
|
- app/assets/javascripts/effective_bootstrap/tabs.js
|
432
433
|
- app/assets/javascripts/effective_bootstrap_editor.js
|
433
434
|
- app/assets/javascripts/effective_checks/initialize.js.coffee
|
@@ -473,8 +474,6 @@ files:
|
|
473
474
|
- app/assets/javascripts/effective_rich_text_area/extensions.js
|
474
475
|
- app/assets/javascripts/effective_rich_text_area/initialize.js
|
475
476
|
- app/assets/javascripts/effective_rich_text_area/input.js
|
476
|
-
- app/assets/javascripts/effective_scale/initialize.js.coffee
|
477
|
-
- app/assets/javascripts/effective_scale/input.js
|
478
477
|
- app/assets/javascripts/effective_select/initialize.js.coffee
|
479
478
|
- app/assets/javascripts/effective_select/input.js
|
480
479
|
- app/assets/javascripts/effective_select/overrides.js.coffee
|
@@ -677,7 +676,6 @@ files:
|
|
677
676
|
- app/models/effective/form_inputs/reset.rb
|
678
677
|
- app/models/effective/form_inputs/rich_text_area.rb
|
679
678
|
- app/models/effective/form_inputs/save.rb
|
680
|
-
- app/models/effective/form_inputs/scale_field.rb
|
681
679
|
- app/models/effective/form_inputs/search_field.rb
|
682
680
|
- app/models/effective/form_inputs/select.rb
|
683
681
|
- app/models/effective/form_inputs/select_or_text.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# Prevent non-numeric buttons from being pressed
|
2
|
-
$(document).on 'keydown', "input[type='text'].effective_scale", (event) ->
|
3
|
-
allowed = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '.']
|
4
|
-
|
5
|
-
if event.key && event.key.length == 1 && event.metaKey == false && allowed.indexOf(event.key) == -1
|
6
|
-
event.preventDefault()
|
7
|
-
|
8
|
-
# Assign the hidden input a value of ScaleX value
|
9
|
-
$(document).on 'change keyup', "input[type='text'].effective_scale", (event) ->
|
10
|
-
$input = $(event.target)
|
11
|
-
|
12
|
-
value = $input.val().replace(/,/g, '')
|
13
|
-
scale = parseInt($input.data('scale'))
|
14
|
-
|
15
|
-
unless value == ''
|
16
|
-
value = (parseFloat(value || 0.0) * (10.0 ** scale)).toFixed(0)
|
17
|
-
|
18
|
-
$input.siblings("input[type='hidden']").first().val(value)
|
19
|
-
|
20
|
-
# Format the value for display as currency (USD)
|
21
|
-
$(document).on 'change', "input[type='text'].effective_scale", (event) ->
|
22
|
-
$input = $(event.target)
|
23
|
-
|
24
|
-
value = $input.siblings("input[type='hidden']").first().val()
|
25
|
-
scale = parseInt($input.data('scale'))
|
26
|
-
|
27
|
-
unless value == ''
|
28
|
-
value = parseInt(value || 0)
|
29
|
-
|
30
|
-
if isNaN(value) == false && value != ''
|
31
|
-
value = (value / (10.0 ** scale)) if value != 0
|
32
|
-
|
33
|
-
value = value.toFixed(scale).toString()
|
34
|
-
value = value.replace(('.' + '0'.repeat(scale)), '')
|
35
|
-
else
|
36
|
-
value = ''
|
37
|
-
|
38
|
-
$input.val(value)
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require ./initialize
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Effective
|
4
|
-
module FormInputs
|
5
|
-
class ScaleField < Effective::FormInput
|
6
|
-
|
7
|
-
def build_input(&block)
|
8
|
-
@builder.hidden_field(name, value: scale_to_integer, id: tag_id + '_value_as_integer') +
|
9
|
-
@template.text_field_tag(name, scale_to_s, options[:input].merge(id: tag_id, name: nil))
|
10
|
-
end
|
11
|
-
|
12
|
-
def input_html_options
|
13
|
-
{ class: 'form-control effective_scale', autocomplete: 'off', id: tag_id, 'data-scale': scale }
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def scale
|
19
|
-
@scale ||= (options.delete(:scale) || 2)
|
20
|
-
end
|
21
|
-
|
22
|
-
def scaled(value)
|
23
|
-
"%.#{scale}f" % (value / (10.0 ** scale))
|
24
|
-
end
|
25
|
-
|
26
|
-
def scale_to_integer
|
27
|
-
return nil unless value
|
28
|
-
value.kind_of?(Integer) ? value : scaled(value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def scale_to_s
|
32
|
-
return nil unless value
|
33
|
-
|
34
|
-
str = (value.kind_of?(Integer) ? scaled(value) : value).to_s
|
35
|
-
str.gsub('.' + ('0' * scale), '')
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|