Sha256: 505e5b7bb710a967f71034e53878d1601d8a7a89b0822a2f5518ca6d2c8bf6f1

Contents?: true

Size: 976 Bytes

Versions: 86

Compression:

Stored size: 976 Bytes

Contents

define([

], function () {
  function HidePlaceholder (decorated, $element, options, dataAdapter) {
    this.placeholder = this.normalizePlaceholder(options.get('placeholder'));

    decorated.call(this, $element, options, dataAdapter);
  }

  HidePlaceholder.prototype.append = function (decorated, data) {
    data.results = this.removePlaceholder(data.results);

    decorated.call(this, data);
  };

  HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
    if (typeof placeholder === 'string') {
      placeholder = {
        id: '',
        text: placeholder
      };
    }

    return placeholder;
  };

  HidePlaceholder.prototype.removePlaceholder = function (_, data) {
    var modifiedData = data.slice(0);

    for (var d = data.length - 1; d >= 0; d--) {
      var item = data[d];

      if (this.placeholder.id === item.id) {
        modifiedData.splice(d, 1);
      }
    }

    return modifiedData;
  };

  return HidePlaceholder;
});

Version data entries

86 entries across 86 versions & 7 rubygems

Version Path
card-mod-bootstrap-0.18.1 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.18.0 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
radius-rails-3.1.4 app/assets/components/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.17.0 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.16.0 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.6 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.5 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.4 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.3 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.1.2 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.2.pre1 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.1.1 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.1 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.15.0 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.14.2 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.14.1 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.14.0 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.13.4 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.13.3 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js
card-mod-bootstrap-0.13.2 vendor/select2/src/js/select2/dropdown/hidePlaceholder.js