mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
list_render: Extract sort handler function from data-sort click handler.
This commit is contained in:
@@ -1,17 +1,5 @@
|
||||
// TODO: make an initialize function for list_render.
|
||||
const initialize = (function () {
|
||||
var initalize_function;
|
||||
|
||||
set_global('$', (f) => {
|
||||
initalize_function = f;
|
||||
});
|
||||
|
||||
// We can move this module scope when we have
|
||||
// an explicit initialize function.
|
||||
zrequire('list_render');
|
||||
|
||||
return initalize_function;
|
||||
}());
|
||||
set_global('$', () => {});
|
||||
zrequire('list_render');
|
||||
|
||||
// We need these stubs to get by instanceof checks.
|
||||
// The list_render library allows you to insert objects
|
||||
@@ -22,11 +10,6 @@ set_global('Element', function () {
|
||||
return { };
|
||||
});
|
||||
|
||||
// This function will be the anonymous click handler
|
||||
// for clicking on any element that matches the
|
||||
// CSS selector of "[data-sort]".
|
||||
var handle_sort_click;
|
||||
|
||||
// We only need very simple jQuery wrappers for when the
|
||||
// "real" code wraps html or sets up click handlers.
|
||||
// We'll simulate most other objects ourselves.
|
||||
@@ -35,16 +18,6 @@ set_global('$', (arg) => {
|
||||
return arg.to_jquery();
|
||||
}
|
||||
|
||||
if (arg === 'body') {
|
||||
return {
|
||||
on: (event_name, selector, f) => {
|
||||
assert.equal(event_name, 'click');
|
||||
assert.equal(selector, '[data-sort]');
|
||||
handle_sort_click = f;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
html: () => arg,
|
||||
};
|
||||
@@ -266,7 +239,6 @@ run_test('sorting', () => {
|
||||
}
|
||||
|
||||
list_render.create(container, list, opts);
|
||||
initialize();
|
||||
|
||||
var button_opts;
|
||||
var button;
|
||||
@@ -281,7 +253,7 @@ run_test('sorting', () => {
|
||||
|
||||
button = sort_button(button_opts);
|
||||
|
||||
handle_sort_click.call(button);
|
||||
list_render.handle_sort.call(button);
|
||||
|
||||
assert(cleared);
|
||||
assert(button.siblings_deactivated);
|
||||
@@ -302,7 +274,7 @@ run_test('sorting', () => {
|
||||
cleared = false;
|
||||
button.siblings_deactivated = false;
|
||||
|
||||
handle_sort_click.call(button);
|
||||
list_render.handle_sort.call(button);
|
||||
|
||||
assert(cleared);
|
||||
assert(button.siblings_deactivated);
|
||||
|
||||
Reference in New Issue
Block a user