Sha256: 3b33ed3aadd6c8bfc918ac6d633969b2037ce0edfdc6c0c33f116e63fa9b81e1

Contents?: true

Size: 1.16 KB

Versions: 44

Compression:

Stored size: 1.16 KB

Contents

// = require html.sortable

((exports) => {

  class SortListComponent {

    /**
     * Creates a sortable list using hmtl5sortable function.
     *
     * @param {String} sortListSelector The list selector that has to be sortable.
     * @param {Object} options An object containing the same options as html5sortable. It also includes
     *                an extra option `onSortUpdate`, a callback which returns the children collection
     *                whenever the list order has been changed.
     *
     * @returns {void} Nothing.
     */
    constructor(sortListSelector, options) {
      if ($(sortListSelector).length > 0) {
        exports.sortable(sortListSelector, options)[0].addEventListener("sortupdate", (event) => {
          const $children = $(event.target).children();

          if (options.onSortUpdate) {
            options.onSortUpdate($children);
          }
        });
      }
    }
  }

  exports.DecidimAdmin = exports.DecidimAdmin || {};
  exports.DecidimAdmin.SortListComponent = SortListComponent;
  exports.DecidimAdmin.createSortList = (sortListSelector, options) => {
    return new SortListComponent(sortListSelector, options);
  };
})(window);

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-admin-0.24.3 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.6 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.24.2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.5 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.24.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.24.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.24.0.rc2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.4 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.24.0.rc1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.3 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.1.rc1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.23.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.22.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.21.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.20.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.20.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.19.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.18.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6