Sha256: 6e9c0417f4eaa428aa7fb20bd99ee0f5d7e762c574d343482e85ba23c7de30f8

Contents?: true

Size: 874 Bytes

Versions: 4

Compression:

Stored size: 874 Bytes

Contents

/*jslint vars: true, browser: true, white: true */
/*global jQuery, IQVOC */

IQVOC.quicksearch = (function($) {

"use strict";

var defaults = {
  minLength: 3,
  autoFocus: true,
  source: getConcepts,
  focus: function(ev, ui) { ev.preventDefault(); },
  select: onSelect
};

function onSelect(ev, ui) {
  if(ui.item.value) {
    $(ev.target).val(ui.item.label);
    document.location = ui.item.value;
  }
  ev.preventDefault();
}

function getConcepts(req, callback) {
  var form = $(this.element).closest("form");
  $.ajax({
    type: form.attr("method"),
    url: form.attr("action"),
    data: form.serialize(),
    success: function(data, status, xhr) {
      callback(IQVOC.extractConcepts(data));
    }
  });
}

return function(selector, options) {
  options = options ? $.extend(defaults, options) : defaults;
  $(selector).autocomplete(options);
};

}(jQuery));

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iqvoc-4.0.6 app/assets/javascripts/iqvoc/quicksearch.js
iqvoc-4.0.5 app/assets/javascripts/iqvoc/quicksearch.js
iqvoc-4.0.4 app/assets/javascripts/iqvoc/quicksearch.js
iqvoc-4.0.3 app/assets/javascripts/iqvoc/quicksearch.js