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.24.3 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.6 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.24.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.5 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.24.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.24.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.24.0.rc2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.4 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.24.0.rc1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.3 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.2 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.1.rc1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.23.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.22.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.21.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.20.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.20.0 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.19.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6
decidim-admin-0.18.1 app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6