uber_select_rails 0.5.1 → 0.6.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:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0dad48d52dd5e14c133c8d6c01861f5ae3e9069110df7b8b5faa7840703342f7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 72be4762c753d35290e7f9d63d6b9575f0967d44d9a9b382d417accb6324fd6b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a39831aaeb705925e5bf27053e4445232096eb8ba8f4e572ce2809a21b1cd4a9f42af62189614089fa7dba4fa9b5f046988fcfea92ce47ee872e76f24692b797
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 98cdf58391fea57de5ac5ea903a72e2d6fb15b67956ec64d0ffcdf73aa3231349f38b1555a31f2422653b2ed6acb37b63882918cbf16856368cb54af42c1924f
         
     | 
| 
         @@ -52,13 +52,28 @@ as a JSON string. All options on the are passed to the underlying UberSearch, se 
     | 
|
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
              Default: `<select>` element attributes `<select placeholder="my placeholder" data-placeholder="my placeholder">`
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
            - ##### dataUrl
         
     | 
| 
      
 55 
     | 
    
         
            +
            - ##### dataUrl <a name="dataUrl"></a>
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
              A url to pre-fetch select options from. JSON response should be of the form
         
     | 
| 
       58 
58 
     | 
    
         
             
              `[{text:'option with explicit value', value: 'some value'}, {text:'option with implicit value'}]`. For a custom JSON response, use in conjunction with optionFromDatum.
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
60 
     | 
    
         
             
              Default: `null`
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
      
 62 
     | 
    
         
            +
            - ##### dataFormatter
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              A function that can modify the data from the dataUrl before it is used.
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              The function signature is as follows:
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              ```js
         
     | 
| 
      
 69 
     | 
    
         
            +
                function(data) {
         
     | 
| 
      
 70 
     | 
    
         
            +
                  // Modify the data
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  return modifiedData
         
     | 
| 
      
 73 
     | 
    
         
            +
                }
         
     | 
| 
      
 74 
     | 
    
         
            +
              ```
         
     | 
| 
      
 75 
     | 
    
         
            +
              See <a href="#dataUrl">dataUrl</a> for details about the expected format of `data`.
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       62 
77 
     | 
    
         
             
            - ##### optionFromDatum
         
     | 
| 
       63 
78 
     | 
    
         | 
| 
       64 
79 
     | 
    
         
             
              A function that is used to customize the options value and text built from a JSON response. `datum` is a single result returned from the JSON response.
         
     | 
| 
         @@ -156,6 +171,15 @@ Data is an array of objects. Each object may have the following properties: 
     | 
|
| 
       156 
171 
     | 
    
         | 
| 
       157 
172 
     | 
    
         
             
              Sets the data. `data` should be an Array conforming to the specifications described in <a href="#data">Data</a>
         
     | 
| 
       158 
173 
     | 
    
         | 
| 
      
 174 
     | 
    
         
            +
            - ##### getValue()
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
              Returns the currently selected value.
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
            - ##### getSelection()
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              Returns the currently selected element from the search results.
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
       159 
183 
     | 
    
         
             
            #### Options <a name="UberSearch options"></a>
         
     | 
| 
       160 
184 
     | 
    
         | 
| 
       161 
185 
     | 
    
         
             
            Options can be specified by setting the `data-uber-options` attribute on the `<select>` element. Values should be passed
         
     | 
| 
         @@ -241,7 +265,7 @@ as a JSON string. 
     | 
|
| 
       241 
265 
     | 
    
         
             
              Sets the text to show when the results list is empty and no search is in progress
         
     | 
| 
       242 
266 
     | 
    
         | 
| 
       243 
267 
     | 
    
         
             
              Default: `'No options'`
         
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
       245 
269 
     | 
    
         
             
            - ##### searchInputAttributes
         
     | 
| 
       246 
270 
     | 
    
         | 
| 
       247 
271 
     | 
    
         
             
              An Object containing attributes to add to the search input element.
         
     | 
| 
         @@ -17,6 +17,7 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    disabled: $(select).is(':disabled'),                                              // Whether the select is currently disabled
         
     | 
| 
       18 
18 
     | 
    
         
             
                    placeholder: $(select).attr('placeholder') || $(select).attr('data-placeholder'), // Placeholder to show in the selected text area
         
     | 
| 
       19 
19 
     | 
    
         
             
                    dataUrl: null,                                                                    // A url to pre-fetch select options from, see optionsFromData for data format
         
     | 
| 
      
 20 
     | 
    
         
            +
                    dataFormatter: function(data) { return data },                                    // A function to manipulate data received from the dataUrl before it is used. The function should return an array of data with desired modifications.
         
     | 
| 
       20 
21 
     | 
    
         
             
                    optionFromDatum: optionFromDatum,                                                 // A function to create select options
         
     | 
| 
       21 
22 
     | 
    
         
             
                    value: $(select).val()                                                            // Initialize the UberSearch with this selected value
         
     | 
| 
       22 
23 
     | 
    
         
             
                  }, opts, $(select).data('uber-options'))
         
     | 
| 
         @@ -61,6 +62,7 @@ 
     | 
|
| 
       61 
62 
     | 
    
         
             
                  hideSelect()
         
     | 
| 
       62 
63 
     | 
    
         
             
                  if (options.dataUrl) {
         
     | 
| 
       63 
64 
     | 
    
         
             
                    $.getJSON(options.dataUrl).done(function(data){
         
     | 
| 
      
 65 
     | 
    
         
            +
                      data = options.dataFormatter(data)
         
     | 
| 
       64 
66 
     | 
    
         
             
                      $(select).append(optionsFromData(data))
         
     | 
| 
       65 
67 
     | 
    
         
             
                      updateSelectValue(options.value)
         
     | 
| 
       66 
68 
     | 
    
         
             
                      uberSearch.setData(dataFromSelect(select))
         
     | 
| 
         @@ -134,7 +136,11 @@ 
     | 
|
| 
       134 
136 
     | 
    
         | 
| 
       135 
137 
     | 
    
         
             
                  // Copies the value of the select into the search input
         
     | 
| 
       136 
138 
     | 
    
         
             
                  function updateSearchValueFromSelect(){
         
     | 
| 
       137 
     | 
    
         
            -
                     
     | 
| 
      
 139 
     | 
    
         
            +
                    var index = select.selectedIndex
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                    if (index == undefined) { return }
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                    uberSearch.searchField.input.val($(select).find('option').eq(index).text())
         
     | 
| 
       138 
144 
     | 
    
         
             
                    uberSearch.searchField.refresh()
         
     | 
| 
       139 
145 
     | 
    
         
             
                  }
         
     | 
| 
       140 
146 
     | 
    
         | 
| 
         @@ -39,7 +39,7 @@ var UberSearch = function(data, options){ 
     | 
|
| 
       39 
39 
     | 
    
         
             
              var pane             = new Pane()
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
              if (options.ariaLabel) { view.attr("aria-label", options.ariaLabel) }
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       43 
43 
     | 
    
         
             
              var searchField = new SearchField({
         
     | 
| 
       44 
44 
     | 
    
         
             
                  placeholder: options.searchPlaceholder,
         
     | 
| 
       45 
45 
     | 
    
         
             
                  clearButton: options.clearSearchButton,
         
     | 
| 
         @@ -88,9 +88,9 @@ var UberSearch = function(data, options){ 
     | 
|
| 
       88 
88 
     | 
    
         
             
              // When the pane is opened
         
     | 
| 
       89 
89 
     | 
    
         
             
              $(pane).on('shown', function(){
         
     | 
| 
       90 
90 
     | 
    
         
             
                search.clear()
         
     | 
| 
       91 
     | 
    
         
            -
                markSelected() 
     | 
| 
      
 91 
     | 
    
         
            +
                markSelected()
         
     | 
| 
       92 
92 
     | 
    
         
             
                view.addClass('open')
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       94 
94 
     | 
    
         
             
                if (options.search) {
         
     | 
| 
       95 
95 
     | 
    
         
             
                  $(searchField.input).focus()
         
     | 
| 
       96 
96 
     | 
    
         
             
                } else {
         
     | 
| 
         @@ -189,6 +189,11 @@ var UberSearch = function(data, options){ 
     | 
|
| 
       189 
189 
     | 
    
         
             
                markSelected()
         
     | 
| 
       190 
190 
     | 
    
         
             
              }
         
     | 
| 
       191 
191 
     | 
    
         | 
| 
      
 192 
     | 
    
         
            +
              // Returns the selected value
         
     | 
| 
      
 193 
     | 
    
         
            +
              function getValue(){
         
     | 
| 
      
 194 
     | 
    
         
            +
                return selectedValue
         
     | 
| 
      
 195 
     | 
    
         
            +
              }
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
       192 
197 
     | 
    
         
             
              // Enables or disables UberSearch
         
     | 
| 
       193 
198 
     | 
    
         
             
              function setDisabled(boolean){
         
     | 
| 
       194 
199 
     | 
    
         
             
                outputContainer.setDisabled(boolean)
         
     | 
| 
         @@ -362,5 +367,5 @@ var UberSearch = function(data, options){ 
     | 
|
| 
       362 
367 
     | 
    
         | 
| 
       363 
368 
     | 
    
         
             
              // PUBLIC INTERFACE
         
     | 
| 
       364 
369 
     | 
    
         | 
| 
       365 
     | 
    
         
            -
              $.extend(this, {view:view,  searchField:searchField, setValue:setValue, setData:setData, setDisabled:setDisabled, options:options})
         
     | 
| 
      
 370 
     | 
    
         
            +
              $.extend(this, {view:view,  searchField:searchField, setValue:setValue, getValue: getValue, setData:setData, setDisabled:setDisabled, getSelection:getSelection, options:options})
         
     | 
| 
       366 
371 
     | 
    
         
             
            }
         
     | 
    
        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.6.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: 2022-02 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-03-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     |