Sha256: c5e53d4b9b4df241de3250e724c68dbb17a483108f258e086e012fc19ff5ffc4

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

(($, ActiveAdmin) => {

  class PerPage {
    constructor(element) {
      this.element = element;
    }

    update() {
      const params = ActiveAdmin
        .queryStringToParams()
        .filter(({name}) => name != 'per_page' || name != 'page')

      params.push({ name: 'per_page', value: this.element.value });

      if (ActiveAdmin.turbolinks) {
        ActiveAdmin.turbolinksVisit(params);
      } else {
        window.location.search = ActiveAdmin.toQueryString(params);
      }
    }

    static _jQueryInterface(config) {
      return this.each(function () {
        const $this = $(this)
        let data = $this.data('perPage')

        if (!data) {
          data = new PerPage(this)
          $this.data('perPage', data)
        }

        if (config === 'update') {
          data[config]()
        }
      })
    }
  };

  $(document).
    on('change', '.pagination_per_page > select', function(event) {
      PerPage._jQueryInterface.call($(this), 'update')
    });

  $.fn['perPage'] = PerPage._jQueryInterface
  $.fn['perPage'].Constructor = PerPage

})(jQuery, window.activeadmin);

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
activeadmin-rails-1.7.1 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-rails-1.7.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.4.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.3.1 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.3.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.2.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.1.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.0.0 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.0.0.rc2 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin-2.0.0.rc1 app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/app/assets/javascripts/active_admin/lib/per_page.es6