uber_select_rails 0.4.3 → 0.5.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d7f2ac671dfba382d9ce1d1bd226fcac0b92d3c7473e720f1c200a398234e3
|
4
|
+
data.tar.gz: ff3372fdb170c871823be80159c2c654d2982a8354e76442e16ec9337c250160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95851208aa9e978b3c544b818d27865d1015df4b62ccdc9c83aa35874f7bbd539c23dac85441aa2f9703ff7c741fb9e61d916900a619a5cd4de19ddddbf33485
|
7
|
+
data.tar.gz: f4d6512cb2e83c586eb5d462292d47490bf76d3526dcdef559c49a0df5839d2f0748984208bb3581aecafc985e77560cf63c57b8410b55d33cfc1003df02d6c2
|
@@ -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,
|
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
|
-
|
148
|
-
|
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(
|
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:'✕' // 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(
|
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
|
+
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:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|