Sha256: e6dfdd3b6853f3da2475598ed054d906ff0cd7b9ebbcdc9f36ecd95839d04ce5

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

(function(ko, $) {
  "use strict";

  ko.bindingHandlers.sherlock = {
    init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
      var $container  = $(element),
          options     = typeof ko.unwrap(valueAccessor()) === 'object' ? ko.unwrap(valueAccessor()) : {},
          $providerSearchField,
          sherlockVm;
      
      sherlockVm = new app.sherlock.SherlockVm();
      sherlockVm.setup(options);
      
      sherlockVm.params.subscribe(function(params) {
        bindingContext.$data.sherlockParams(params);
      });
      
      ko.renderTemplate('sherlock-container-template', sherlockVm, {}, element);
      
      $container.addClass('sherlock-search-bar');
      
      $providerSearchField = $container.find('.provider-search-field > input');
      
      $providerSearchField.on('focus', function() {
        sherlockVm.providerSearchActive(true);
      });
      
      $providerSearchField.on('blur', function() {
        // if we do not delay this, it will fire before the 'click'
        // event on dropdown list entries, clearing the list
        setTimeout(function() {
          sherlockVm.providerSearchActive(false);
        }, 200);
      });
      
      $container.on('click', function() {
        $providerSearchField.focus();
      });
      
      return { controlsDescendantBindings: true };
    },
    update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {

    }
  };

})(ko, $);

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kea-rails-1.0.6 app/assets/javascripts/kea/bindings/sherlock.js
kea-rails-1.0.5 app/assets/javascripts/kea/bindings/sherlock.js
kea-rails-1.0.4 app/assets/javascripts/kea/bindings/sherlock.js
kea-rails-1.0.3 app/assets/javascripts/kea/bindings/sherlock.js