cutlass_js_rails 0.1.12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83bdc4c13ffa1c217e4cbc9e5adfd601f343de91
4
- data.tar.gz: 898569b59596e191c729965be98cc0d33e5c615b
3
+ metadata.gz: 5f6ade3d21d7ccb219a3908cc7f47d385d10989b
4
+ data.tar.gz: bc7b764c1c6d3846314b2fcf77c54fcfe79e3c71
5
5
  SHA512:
6
- metadata.gz: 421af33765f7eb6ed0aa44f36c7971108ffe6de63c8d7e97ca3060b9ab2f9df9eba2d08c448fb58cc1ab6a2a520b27baa375d24dd8eb106a9b251ea391c7c0f4
7
- data.tar.gz: 41c15427955118d73edbe464b04bb4e504d1637d63d60567468ff6b8e1c1cf2132b73042c6a7bc001d85a7046f77ebf0e49323b7b150b851a9b4bac4912a4afe
6
+ metadata.gz: 156f9da3631a769733f75622d2c5156daed9a050e4fffe062f27012b11912869ab86519897ac121fcd5666cb458066e95f88c9aff5f71b28713f651500b09110
7
+ data.tar.gz: 7d35ac53a6553ce8b711a9cb15d93ad6a3517064be833a58db31554f70922fd0a24d8d103aca05f3193fb89453f0fd8a500b6c7ab7b9102a54a27555ac6bb0f4
@@ -8,6 +8,7 @@ Cutlass.generateHTML = function(inputTypes){
8
8
  Cutlass.wrapInItem($(this), 'm-' + inputType)
9
9
  Cutlass.addLabel($(this))
10
10
  Cutlass.addError($(this))
11
+ Cutlass.addWrapperClasses($(this))
11
12
  Cutlass.ifAlwaysActive($(this))
12
13
  })
13
14
  })
@@ -32,6 +33,16 @@ Cutlass.addError = function($input){
32
33
  $input.before($error)
33
34
  }
34
35
  }
36
+ Cutlass.addWrapperClasses = function($input){
37
+ var classes = $input.data('wrapper-classes');
38
+ if(classes){
39
+ classes = classes.split(' ');
40
+ console.log($input);
41
+ classes.forEach(function(klass){
42
+ $input.parent().addClass(klass)
43
+ })
44
+ }
45
+ }
35
46
  Cutlass.ifAlwaysActive = function($input){
36
47
  if($input.data('always-active')){
37
48
  $input.parent().addClass('m-always-active')
@@ -1,3 +1,3 @@
1
1
  <% css_classes = (defined? css_classes) ? css_classes : '' %>
2
2
  <% props = local_assigns.fetch(:props, {}) %>
3
- <%= f.text_field field, class: "Cutlass-input-text #{css_classes}", 'data-label': label, type: 'tel', 'data-always-active': true, 'data-error': model.errors[field][0], **props %>
3
+ <%= f.text_field code, class: "Cutlass-input-text #{css_classes}", 'data-label': label, type: 'tel', 'data-always-active': true, 'data-error': model.errors[field][0], **props %>
@@ -1,12 +1,12 @@
1
- <% value = model.loot_get(field) %>
1
+ <% code = local_assigns.fetch(:code) %>
2
+ <% value = model.loot_get(code) %>
2
3
  <% options.map! do |option| %>
3
- <% option = option.with_indifferent_access %>
4
- <% OpenStruct.new(value: option['value'], label: option['label']) %>
4
+ <% OpenStruct.new(value: option[0], label: option[1]) %>
5
5
  <% end %>
6
6
 
7
- <div class="Cutlass-input-radio" data-label="<%= label %>" data-error=<%= model.errors[field][0] %>>
7
+ <div class="Cutlass-input-radio" data-label="<%= label %>" data-error=<%= model.errors[code][0] %>>
8
8
  <% count = 0 %>
9
- <%= f.collection_radio_buttons(field, options, 'value', 'label' ) do |b| %>
9
+ <%= f.collection_radio_buttons(code, options, 'value', 'label' ) do |b| %>
10
10
  <div class="Cutlass-input-radio-single">
11
11
  <%= b.radio_button(checked: (b.value == value || options.first.value), class: 'icheck-me Cutlass-input-radio-single' ) %>
12
12
  <%= b.label %>
@@ -1,3 +1,4 @@
1
1
  <% css_classes = (defined? css_classes) ? css_classes : '' %>
2
+ <% code = local_assigns.fetch(:code) %>
2
3
  <% props = local_assigns.fetch(:props, {}) %>
3
- <%= f.select field, options, props, { class: "Cutlass-input-select #{css_classes}", 'data-label': label, 'data-error': model.errors[field][0] } %>
4
+ <%= f.select code, options_for_select(options, selected: value), props.merge(selected: value), { class: "Cutlass-input-select #{css_classes}", 'data-label': label, 'data-error': model.errors[code][0] } %>
@@ -1,3 +1,5 @@
1
1
  <% css_classes = (defined? css_classes) ? css_classes : '' %>
2
2
  <% props = (defined? props) ? props.to_h : {} %>
3
- <%= f.text_field field, class: "Cutlass-input-text #{css_classes}", 'data-label': label, 'data-error': model.errors[field][0], **props %>
3
+ <% code = local_assigns.fetch(:code) %>
4
+ <% value = local_assigns.fetch(:value, '') %>
5
+ <%= f.text_field code, class: "Cutlass-input-text #{css_classes}", value: value, **({ 'data-label' => label, 'data-error' => model.errors[code][0] }.merge(props).symbolize_keys) %>
@@ -1,5 +1,9 @@
1
1
  <% css_classes = (defined? css_classes) ? css_classes : '' %>
2
- <%= f.check_box field, {
2
+ <% code = local_assigns.fetch(:code) %>
3
+ <% label = local_assigns.fetch(:label) %>
4
+ <% value = local_assigns.fetch(:value, '') %>
5
+ <%= f.check_box code, {
3
6
  class: "Cutlass-input-toggler js-conditional-switch #{css_classes}",
7
+ checked: value == 'true',
4
8
  'data-label': label
5
9
  }, 'true', 'false' %>
@@ -1,3 +1,3 @@
1
1
  module CutlassJsRails
2
- VERSION = '0.1.12'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutlass_js_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chardos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-15 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler