Sha256: 7df0e8a2851be162bc5f9ed397b1da28b9a5ae1dbb6eb2d2e7cf4246a808b56a

Contents?: true

Size: 1.16 KB

Versions: 54

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

54 entries across 54 versions & 2 rubygems

Version Path
decidim-admin-0.10.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.10.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.9.3 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.9.2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.9.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.9.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.8.4 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.8.3 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.8.2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.8.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.8.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.7.4 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.7.3 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.7.2 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.7.1 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.7.0 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.6.8 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-0.6.8 decidim-admin/app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-admin-0.6.7 app/assets/javascripts/decidim/admin/sort_list.component.js.es6
decidim-0.6.7 decidim-admin/app/assets/javascripts/decidim/admin/sort_list.component.js.es6