uber_select_rails 0.4.0 → 0.4.5

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
  SHA256:
3
- metadata.gz: 4c4e02c23ba5d8d6ba50707be770694a60f4abc20cbff88c2fbe9baa7ed63619
4
- data.tar.gz: fbcbd8c7ab7ff3910e2161fd980e78eb215bda8942f71d64c2332d874817a622
3
+ metadata.gz: 84ef1d0cf1002249e0227db7b418a8939b08565eaf4c0f1d41d9fb30fe06fb16
4
+ data.tar.gz: df218314fbdf61a2a11a3f7b7fdda895893368f5ff8da73345eae6f597fb6dea
5
5
  SHA512:
6
- metadata.gz: 5d8afa5bdfdb0b4a50df1dc5fc9154d32f7d2b9823fb63075ce6f9cd26edf11bc274ac73a2f91a75fac64c58dc023dc3ab8c54aa80a38385493ff411d9a0d648
7
- data.tar.gz: b8d8f1986c48ee1b2c502a16932fcc0809a10abaa8a4bc577423d1931361d55a79e3e1b4484c9a145761fa6aba9accb9a286a86c51c69c6f91d87cfcec09b179
6
+ metadata.gz: c655fe9651218f7e292e5efbaf28b96b339f0993e3e344c5f3f116271bf850d7a1aa4b2cfa8523ea39b159208a7cb7d750bf4838d0111841c047f3c916e1835d
7
+ data.tar.gz: 921dc47d6440caa9e76f6f83e5e843dee45b84f1bd51e5f01a3382b582d6d335f51438a417baeb3673b9e99cbab92361dfa85c9985a4d9566adc733a6ed4c593
@@ -1,3 +1,3 @@
1
1
  module UberSelectRails
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.5"
3
3
  end
data/uber_select.gemspec CHANGED
@@ -3,6 +3,8 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'uber_select_rails/version'
5
5
 
6
+ `git submodule update` # Ensure we've checked the correct submodule files
7
+
6
8
  Gem::Specification.new do |spec|
7
9
  spec.name = "uber_select_rails"
8
10
  spec.version = UberSelectRails::VERSION
@@ -21,6 +21,10 @@ you can use UberSelect to gussy up forms, without changing any of the underlying
21
21
  $('.my_selects').uberSelect(options);
22
22
  ```
23
23
 
24
+ #### Attributes <a name="UberSearch attributes"></a>
25
+ Attribtes on the outermost element can be specified by setting the `data-uber-attributes` attribute on the `<select>` element. Values should be passed
26
+ as a JSON string of key/value pairs where the key is the attribute name and the value is the attribute value.
27
+
24
28
  #### Options
25
29
  Options can be specified by setting the `data-uber-options` attribute on the `<select>` element. Values should be passed
26
30
  as a JSON string. All options on the are passed to the underlying UberSearch, see [UberSearch options](#UberSearchOptions).
@@ -20,7 +20,7 @@
20
20
  optionFromDatum: optionFromDatum, // A function to create select options
21
21
  value: $(select).val() // Initialize the UberSearch with this selected value
22
22
  }, opts, $(select).data('uber-options'))
23
-
23
+ var uberAttributes = $(select).data('uber-attributes'); // Attributes defined as data-uber-attributes on the original select element. These will be added as attributes on the uberSelect element.
24
24
  var uberSearch = this.uberSearch = new UberSearch(dataFromSelect(select), options)
25
25
 
26
26
 
@@ -53,11 +53,16 @@
53
53
 
54
54
  // INITIALIZATION
55
55
 
56
+ if (uberAttributes) {
57
+ uberSearch.view.attr(uberAttributes)
58
+ }
59
+
56
60
  uberSearch.view.insertBefore(select).append(select)
57
61
  hideSelect()
58
62
  if (options.dataUrl) {
59
63
  $.getJSON(options.dataUrl).done(function(data){
60
64
  $(select).append(optionsFromData(data))
65
+ updateSelectValue(options.value)
61
66
  uberSearch.setData(dataFromSelect(select))
62
67
  $(select).trigger(eventsTriggered.ready)
63
68
  })
@@ -82,7 +87,7 @@
82
87
  selectedText: getAttribute(option, 'data-selected-text'),
83
88
  value: getAttribute(option, 'value'),
84
89
  title: getAttribute(option, 'title'),
85
- disabled: getAttribute(option, 'disabled'),
90
+ disabled: getAttribute(option, 'disabled') === undefined ? false : true,
86
91
  matchValue: getAttribute(option, 'data-match-value'),
87
92
  visibility: getAttribute(option, 'data-visibility'),
88
93
  element: option
@@ -136,7 +141,7 @@
136
141
  function refreshOptionsList(){
137
142
  uberSearch.setDisabled($(select).is(':disabled'))
138
143
  uberSearch.setData(dataFromSelect(select))
139
- updateSelectedValue()
144
+ updateSelectValue($(select).find('option[selected]').attr('value')) // Read the value of the option that is selected because the <select> element's value is defunct now that we've updated the <option> elements
140
145
  }
141
146
 
142
147
  // Updates the UberSearch's selected value from the select element's value
@@ -145,7 +150,10 @@
145
150
  }
146
151
 
147
152
  function updateSelectValue(value){
148
- $(select).val(value).trigger('change')
153
+ var before = $(select).val()
154
+ $(select).val(value)
155
+ var after = $(select).val() // Read value the same way instead of comparing to `value` so the same coercion is applied
156
+ if (before != after) { $(select).trigger('change') } // Only trigger a change if the value has actually changed
149
157
  }
150
158
 
151
159
  // Selects the option with an emptystring value, or the first option if there is no blank option
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber_select_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
- description:
55
+ description:
56
56
  email:
57
57
  - nicholas.jakobsen@gmail.com
58
58
  executables: []
@@ -84,7 +84,7 @@ files:
84
84
  homepage: https://github.com/culturecode/uber_select_rails
85
85
  licenses: []
86
86
  metadata: {}
87
- post_install_message:
87
+ post_install_message:
88
88
  rdoc_options: []
89
89
  require_paths:
90
90
  - lib
@@ -99,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.0.3
103
- signing_key:
102
+ rubygems_version: 3.0.8
103
+ signing_key:
104
104
  specification_version: 4
105
105
  summary: A Rails gem containing a javascript plugin that adds a layer of UI goodness
106
106
  overtop of basic HTML select elements