uber_select_rails 0.4.3 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5852b1fc530f2e2990d6bae6c9de18be71ef5365c243cbf9e2955dd0d9f07292
4
- data.tar.gz: d30d7e27c9686b276e4fad9d0b7971d1404a240f292dbeece1adf87a5e03bf40
3
+ metadata.gz: 55d7f2ac671dfba382d9ce1d1bd226fcac0b92d3c7473e720f1c200a398234e3
4
+ data.tar.gz: ff3372fdb170c871823be80159c2c654d2982a8354e76442e16ec9337c250160
5
5
  SHA512:
6
- metadata.gz: 1abd187f4db26bc3f70145935439ba8fe19f7aa1c16e73fe0d00737a9674dcb3ff7ce3dbf6b3f9696d5cccdd0587041638caa8e356339915945ca5b661ae32d9
7
- data.tar.gz: 3c4fdfa37229c36ea9e1e30ba79333f94b84f0e02fc396b5bb24faae2694a922a8920bddaf2698d1be80780ff6a485a669ef0c78599b52cc8f80b1e32dcf316b
6
+ metadata.gz: 95851208aa9e978b3c544b818d27865d1015df4b62ccdc9c83aa35874f7bbd539c23dac85441aa2f9703ff7c741fb9e61d916900a619a5cd4de19ddddbf33485
7
+ data.tar.gz: f4d6512cb2e83c586eb5d462292d47490bf76d3526dcdef559c49a0df5839d2f0748984208bb3581aecafc985e77560cf63c57b8410b55d33cfc1003df02d6c2
@@ -1,3 +1,3 @@
1
1
  module UberSelectRails
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -196,6 +196,9 @@ as a JSON string.
196
196
  Sets the text to show when the results list is empty and no search is in progress
197
197
 
198
198
  Default: `'No options'`
199
+
200
+ - ##### searchInputAttributes
201
+ An Object containing attributes to add to the search input element.
199
202
 
200
203
  - ##### buildResult
201
204
  A function that is used to build result elements.
@@ -44,7 +44,7 @@
44
44
  $(select).on(eventsObserved.refreshOptions, refreshOptionsList)
45
45
 
46
46
  // When the select value changes
47
- $(select).on(eventsObserved.refresh, updateSelectedValue)
47
+ $(select).on(eventsObserved.refresh, refresh)
48
48
 
49
49
  // When a result is selected
50
50
  $(uberSearch).on('select', function(_, datum){
@@ -139,18 +139,20 @@
139
139
  }
140
140
 
141
141
  function refreshOptionsList(){
142
- uberSearch.setDisabled($(select).is(':disabled'))
143
142
  uberSearch.setData(dataFromSelect(select))
144
143
  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
145
144
  }
146
145
 
147
- // Updates the UberSearch's selected value from the select element's value
148
- function updateSelectedValue(){
146
+ function refresh(){
147
+ uberSearch.setDisabled($(select).is(':disabled'))
149
148
  uberSearch.setValue($(select).val())
150
149
  }
151
150
 
152
151
  function updateSelectValue(value){
153
- $(select).val(value).trigger('change')
152
+ var before = $(select).val()
153
+ $(select).val(value)
154
+ var after = $(select).val() // Read value the same way instead of comparing to `value` so the same coercion is applied
155
+ if (before != after) { $(select).trigger('change') } // Only trigger a change if the value has actually changed
154
156
  }
155
157
 
156
158
  // Selects the option with an emptystring value, or the first option if there is no blank option
@@ -1,11 +1,15 @@
1
1
  function SearchField(options){
2
2
  options = $.extend({
3
3
  placeholder: 'Type to Search',
4
+ searchInputAttributes: { 'aria-label': "Type to Search" },
4
5
  clearButton:'&#x2715;' // Text content of clear search button
5
6
  }, options)
6
7
 
8
+ var inputAttrs = {}
9
+ $.extend(inputAttrs, { placeholder: options.placeholder }, options.searchInputAttributes)
10
+
7
11
  var context = this
8
- var input = this.input = $('<input type="search" class="search_input">').attr('placeholder', options.placeholder)
12
+ var input = this.input = $('<input type="search" class="search_input">').attr(inputAttrs)
9
13
  var value = input.val()
10
14
  var clearButton = this.clearButton = $('<span class="clear_search_button"></span>').html(options.clearButton)
11
15
  var view = this.view = $('<span class="search_field_container"></span>').append(input).append(clearButton)
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.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-22 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails