Sha256: 4d979d72555f0c7e2aa8f4cbc6fc39832a40b108acc4295b04bc11b162078b8a

Contents?: true

Size: 1.16 KB

Versions: 19

Compression:

Stored size: 1.16 KB

Contents

define([

], function () {
  function SelectOnClose () { }

  SelectOnClose.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    container.on('close', function (params) {
      self._handleSelectOnClose(params);
    });
  };

  SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
    if (params && params.originalSelect2Event != null) {
      var event = params.originalSelect2Event;

      // Don't select an item if the close event was triggered from a select or
      // unselect event
      if (event._type === 'select' || event._type === 'unselect') {
        return;
      }
    }

    var $highlightedResults = this.getHighlightedResults();

    // Only select highlighted results
    if ($highlightedResults.length < 1) {
      return;
    }

    var data = $highlightedResults.data('data');

    // Don't re-select already selected resulte
    if (
      (data.element != null && data.element.selected) ||
      (data.element == null && data.selected)
    ) {
      return;
    }

    this.trigger('select', {
        data: data
    });
  };

  return SelectOnClose;
});

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
adminlte_rails-0.1.0 vendor/assets/javascripts/adminlte/plugins/select2/src/js/select2/dropdown/selectOnClose.js
card-1.94.1 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.94.0 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.13 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.12 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.11 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.10 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.9 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.8 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.7 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
jinda_lte-0.0.1 lib/generators/jinda_lte/templates/app/assets/jinda_assets/bower_components/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.6 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.5 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.4 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.3 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.2 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.1 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
card-1.93.0 mod/bootstrap/vendor/select2/src/js/select2/dropdown/selectOnClose.js
trestle-0.8.0 vendor/assets/bower_components/trestle/select2/src/js/select2/dropdown/selectOnClose.js