Sha256: d875b0c4175a193190b7d3ce197cb5944468c0313217f68fc87dcd4d99a2c2c2

Contents?: true

Size: 1.4 KB

Versions: 40

Compression:

Stored size: 1.4 KB

Contents

(function($){
  Sufia.Search = function (element) {
    this.$element = $(element);

    this.init = function() {
      this.$label = this.$element.find('[data-search-element="label"]');
      this.$items = this.$element.find('[data-search-option]');
      this.setDefault();
    }

    this.init();
    this.attachEvents();
  }


  Sufia.Search.prototype = {
    attachEvents: function() {

      _this = this;
      this.$items.on('click', function(event) {
        event.preventDefault();
        _this.clicked($(this))
      });
    },

    clicked: function($anchor) {
      this.setLabel($anchor.data('search-label'));
      this.setFormAction($anchor.data('search-option'));
    },

    setFormAction: function(path) {
      this.$element.attr('action', path);
    },

    getLabelForValue: function(value) {
      selected = this.$element.find('[data-search-option="'+ value +'"]');
      return selected.data('search-label');
    },

    setDefault: function() {
      this.setLabel(this.getLabelForValue(this.$element.attr('action')));
    },

    setLabel: function(label) {
      this.$label.html(label);
    }

  }

  $.fn.search = function(option) {
    return this.each(function() {
      var $this = $(this);
      var data  = $this.data('search');

      if (!data) $this.data('search', (data = new Sufia.Search(this)));
    })
  }

})(jQuery);


Blacklight.onLoad(function() {
  $('#search-form-header').search();
});

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
sufia-7.4.1 app/assets/javascripts/sufia/search.js
sufia-7.4.0 app/assets/javascripts/sufia/search.js
sufia-7.3.1 app/assets/javascripts/sufia/search.js
sufia-7.3.0 app/assets/javascripts/sufia/search.js
sufia-7.3.0.rc3 app/assets/javascripts/sufia/search.js
sufia-7.3.0.rc2 app/assets/javascripts/sufia/search.js
sufia-7.3.0.rc1 app/assets/javascripts/sufia/search.js
sufia-7.2.0 app/assets/javascripts/sufia/search.js
sufia-6.7.0 app/assets/javascripts/sufia/search.js
sufia-7.1.0 app/assets/javascripts/sufia/search.js
sufia-7.0.0 app/assets/javascripts/sufia/search.js
sufia-7.0.0.rc2 app/assets/javascripts/sufia/search.js
sufia-7.0.0.rc1 app/assets/javascripts/sufia/search.js
sufia-7.0.0.beta4 app/assets/javascripts/sufia/search.js
sufia-7.0.0.beta3 app/assets/javascripts/sufia/search.js
sufia-7.0.0.beta2 app/assets/javascripts/sufia/search.js
sufia-7.0.0.beta1 app/assets/javascripts/sufia/search.js
sufia-6.6.1 app/assets/javascripts/sufia/search.js
sufia-6.6.0 app/assets/javascripts/sufia/search.js
sufia-6.5.0 app/assets/javascripts/sufia/search.js