list_render: Rename __set_events().

I rename it to set_up_event_handlers.

This commit does not attempt to fix any buggy
behavior with how we set up event handlers; it's
purely cosmetic.
This commit is contained in:
Steve Howell
2020-04-11 12:07:05 +00:00
committed by Tim Abbott
parent 42c2e9c429
commit ced5511cdd
2 changed files with 8 additions and 10 deletions

View File

@@ -28,8 +28,8 @@ function make_containers() {
// parent container is the nearest ancestor to our main
// container that has a max-height attribute, and then
// the parent container will have a scroll event attached to
// it. This is a good time to read __set_events in the
// real code.
// it. This is a good time to read set_up_event_handlers
// in the real code.
const parent_container = {};
const container = {};

View File

@@ -56,7 +56,7 @@ exports.create = function ($container, list, opts) {
return DEFAULTS.instances.get(opts.name)
.set_container($container)
.set_opts(opts)
.__set_events()
.set_up_event_handlers()
.data(list)
.init();
}
@@ -259,10 +259,9 @@ exports.create = function ($container, list, opts) {
meta.sorting_function = false;
};
// this sets the events given the particular arguments assigned in
// the container and opts.
widget.__set_events = function () {
widget.set_up_event_handlers = function () {
let $nearestScrollingContainer = $container;
while ($nearestScrollingContainer.length) {
if ($nearestScrollingContainer.is("body, html")) {
blueslip.warn("Please wrap progressive scrolling lists in an element with 'max-height' attribute. Error found in:\n" + blueslip.preview_node($container));
@@ -290,8 +289,7 @@ exports.create = function ($container, list, opts) {
if (opts.filter && opts.filter.element) {
opts.filter.element.on(opts.filter.event || "input", function () {
const self = this;
const value = self.value.toLocaleLowerCase();
const value = this.value.toLocaleLowerCase();
// run the sort algorithm that was used last, which is done
// by passing `undefined` -- which will make it use the params
@@ -315,8 +313,6 @@ exports.create = function ($container, list, opts) {
return this;
};
widget.__set_events();
// add built-in generic sort functions.
widget.add_generic_sort_function("alphabetic", function (prop) {
return function (a, b) {
@@ -346,6 +342,8 @@ exports.create = function ($container, list, opts) {
};
});
widget.set_up_event_handlers();
// Save the instance for potential future retrieval if a name is provided.
if (opts.name) {
DEFAULTS.instances.set(opts.name, widget);