Sha256: e6761bbeb04ed73b6a2e3c8b9c8f1ddda340e3021e2a8f39803c89d4ec729da4

Contents?: true

Size: 1 KB

Versions: 44

Compression:

Stored size: 1 KB

Contents

export default 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();
        }
      });
    }
  }
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.4 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.27.9 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.29.0 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.3 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.27.8 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.29.0.rc4 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.29.0.rc3 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.29.0.rc2 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.29.0.rc1 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.2 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.27.7 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.1 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.27.6 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.26.10 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.26.9 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.0 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.27.5 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.0.rc5 app/packs/src/decidim/admin/auto_buttons_by_position.component.js
decidim-admin-0.28.0.rc4 app/packs/src/decidim/admin/auto_buttons_by_position.component.js