Sha256: e0bd40d845d5173983f4ebecc596ba3354f2380a653f7cde4db117933970bfbb

Contents?: true

Size: 1.22 KB

Versions: 44

Compression:

Stored size: 1.22 KB

Contents

((exports) => {
  class AutoButtonsByPositionComponent {
    constructor(options = {}) {
      this.listSelector = options.listSelector;
      this.hideOnFirstSelector = options.hideOnFirstSelector;
      this.hideOnLastSelector = options.hideOnLastSelector;

      this.run();
    }

    run() {
      const $list = $(this.listSelector);
      const hideOnFirst = this.hideOnFirstSelector;
      const hideOnLast = this.hideOnLastSelector;

      if ($list.length === 1) {
        const $item = $list.first();

        $item.find(hideOnFirst).hide();
        $item.find(hideOnLast).hide();
      } else {
        $list.each((idx, el) => {
          if (el.id === $list.first().attr("id")) {
            $(el).find(hideOnFirst).hide();
            $(el).find(hideOnLast).show();
          }
          else if (el.id === $list.last().attr("id")) {
            $(el).find(hideOnLast).hide();
            $(el).find(hideOnFirst).show();
          }
          else {
            $(el).find(hideOnLast).show();
            $(el).find(hideOnFirst).show();
          }
        });
      }
    }
  }

  exports.DecidimAdmin = exports.DecidimAdmin || {};
  exports.DecidimAdmin.AutoButtonsByPositionComponent = AutoButtonsByPositionComponent;
})(window);

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-admin-0.19.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.17.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.18.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.17.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.16.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.17.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.16.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.15.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.15.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.15.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.14.4 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.14.3 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.14.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.14.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.13.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.12.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.13.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.12.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.13.0.pre1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.12.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6