uber_select_rails 0.2.1 → 0.3.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: 1565e41dee2dcac6cb743f1fef1670eba707eeb6aa677ddefded94f5341ea372
4
- data.tar.gz: 3b1ab982cd3917c97aa271710cc73c8133455a2e4c001ecb8d4f190486801508
3
+ metadata.gz: 41f2e1a1877958978c0a5577a899c31130a2a77e6392e5aa05b61286e5cfa4df
4
+ data.tar.gz: ed725ab8f9ab6d676c77c340cec323ee6082c539500fffe02611694e0de05c5e
5
5
  SHA512:
6
- metadata.gz: 80acab71f2ef75247a3237ee21291f602b3bab8ff7e491e0a22d5f1eb5a5dd1e630088046c74a59898d8b74f30d48fac61ccfba6eb00c044e08ad83c020b7067
7
- data.tar.gz: 599c1dbcc3986af1b83782080e7e101a4d0dcf6b1edbab91dda19570e7ddd936ea4b56986c67980aa79c957a66c540ba64eb8f9255a5c5bb7e2544559b18b68e
6
+ metadata.gz: 0dab72aac31c287920ea7ce4d75c3919c9a27d5954efc537fd609f6f87d3f9841bf55a5c083ff48f1af66c62135fe221dc1f9e8679ab87e247b08e9ab6256016
7
+ data.tar.gz: b633f6e04dd022376cf002ace1752ec08e84821255717ac85365372521cef766b0cd8b7750207b0eb683fa79360a70f02308c09e5768aea70aa653d17f42c50b
@@ -1,3 +1,3 @@
1
1
  module UberSelectRails
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -94,6 +94,9 @@ Data is an array of objects. Each object may have the following properties:
94
94
  - ##### text
95
95
  String shown to the user in the list of results. This value is required if *value* is not provided.
96
96
 
97
+ - ##### selectedText
98
+ String shown to the user in the output container when this option is selected. *optional*
99
+
97
100
  - ##### value
98
101
  This is matched against the *value* option passed UberSearch and will appear selected if it matches. It is also used to match against search input text when the user searches. This value is required if *text* is not provided.
99
102
 
@@ -103,6 +106,9 @@ Data is an array of objects. Each object may have the following properties:
103
106
  - ##### visibility
104
107
  This is used to determine whether the option appears only when searching or only when not searching. Values accepted: `query`, `no-query`. *optional*
105
108
 
109
+ - ##### disabled
110
+ This is used to determine whether the option appears disabled. *optional*
111
+
106
112
  - ##### group
107
113
  This is used to visually group options. All options with the same group will appear together. *optional*
108
114
 
@@ -79,6 +79,7 @@
79
79
  // This is optimized for performance and does not use jQuery convenience methods. Seems to be about 30% faster loading during non-scientific tests.
80
80
  datum = {
81
81
  text: option.textContent,
82
+ selectedText: getAttribute(option, 'data-selected-text'),
82
83
  value: getAttribute(option, 'value'),
83
84
  disabled: getAttribute(option, 'disabled'),
84
85
  matchValue: getAttribute(option, 'data-match-value'),
@@ -288,7 +288,11 @@ var UberSearch = function(data, options){
288
288
  }
289
289
 
290
290
  function textFromValue(value){
291
- return $.map(data, function(datum){ if (datum.value == value) return datum.text })[0]
291
+ return $.map(data, function(datum) {
292
+ if (datum.value == value) {
293
+ return datum.selectedText || datum.text
294
+ }
295
+ })[0]
292
296
  }
293
297
 
294
298
  function updateMessages(){
@@ -199,6 +199,22 @@
199
199
  <p>This example has a disabled select that should disable the entire UI.</p>
200
200
  </span>
201
201
 
202
+ <span class="example">
203
+ <label for="select">
204
+ Selected Text
205
+ </label>
206
+ <select>
207
+ <option></option>
208
+ <option>Jimmy Johnson</option>
209
+ <option data-selected-text="Good Choice!">Custom Selected Text</option>
210
+ <option>Cosmo Kramer</option>
211
+ <option>Bob Zickowski</option>
212
+ <option>Nicholas Cage</option>
213
+ <option>Queen Latifah</option>
214
+ </select>
215
+ <p>This example has an option with <code>data-selected-text</code> that should show custom text in the output container when selected.</p>
216
+ </span>
217
+
202
218
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
203
219
  <script src="javascript/string_extensions.js"></script>
204
220
  <script src="javascript/search_field.js"></script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber_select_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen