mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 04:12:02 +00:00
user-groups: Add function wrappers to reduce variable scope.
Extract set_up_typeahead function. Extract pill_remove function.
This commit is contained in:
@@ -23,7 +23,6 @@ exports.reload = function () {
|
|||||||
exports.populate_user_groups = function () {
|
exports.populate_user_groups = function () {
|
||||||
var user_groups_section = $('#user-groups').expectOne();
|
var user_groups_section = $('#user-groups').expectOne();
|
||||||
var user_groups_array = user_groups.get_realm_user_groups();
|
var user_groups_array = user_groups.get_realm_user_groups();
|
||||||
|
|
||||||
_.each(user_groups_array, function (data) {
|
_.each(user_groups_array, function (data) {
|
||||||
user_groups_section.append(templates.render('admin_user_group_list', {
|
user_groups_section.append(templates.render('admin_user_group_list', {
|
||||||
user_group: {
|
user_group: {
|
||||||
@@ -197,49 +196,50 @@ exports.populate_user_groups = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var input = pill_container.children('.input');
|
var input = pill_container.children('.input');
|
||||||
|
(function set_up_typeahead() {
|
||||||
|
input.typeahead({
|
||||||
|
items: 5,
|
||||||
|
fixed: true,
|
||||||
|
dropup: true,
|
||||||
|
source: function () {
|
||||||
|
return user_pill.typeahead_source(pills);
|
||||||
|
},
|
||||||
|
highlighter: function (item) {
|
||||||
|
return typeahead_helper.render_person(item);
|
||||||
|
},
|
||||||
|
matcher: function (item) {
|
||||||
|
var query = this.query.toLowerCase();
|
||||||
|
return (item.email.toLowerCase().indexOf(query) !== -1
|
||||||
|
|| item.full_name.toLowerCase().indexOf(query) !== -1);
|
||||||
|
},
|
||||||
|
sorter: function (matches) {
|
||||||
|
return typeahead_helper.sort_recipientbox_typeahead(
|
||||||
|
this.query, matches, "");
|
||||||
|
},
|
||||||
|
updater: function (user) {
|
||||||
|
append_user(user);
|
||||||
|
input.focus();
|
||||||
|
update_cancel_button();
|
||||||
|
},
|
||||||
|
stopAdvance: true,
|
||||||
|
});
|
||||||
|
}());
|
||||||
|
|
||||||
input.typeahead({
|
(function pill_remove() {
|
||||||
items: 5,
|
pills.onPillRemove(function () {
|
||||||
fixed: true,
|
// onPillRemove is fired before the pill is removed from
|
||||||
dropup: true,
|
// the DOM.
|
||||||
source: function () {
|
|
||||||
return user_pill.typeahead_source(pills);
|
|
||||||
},
|
|
||||||
highlighter: function (item) {
|
|
||||||
return typeahead_helper.render_person(item);
|
|
||||||
},
|
|
||||||
matcher: function (item) {
|
|
||||||
var query = this.query.toLowerCase();
|
|
||||||
return (item.email.toLowerCase().indexOf(query) !== -1
|
|
||||||
|| item.full_name.toLowerCase().indexOf(query) !== -1);
|
|
||||||
},
|
|
||||||
sorter: function (matches) {
|
|
||||||
return typeahead_helper.sort_recipientbox_typeahead(
|
|
||||||
this.query, matches, "");
|
|
||||||
},
|
|
||||||
updater: function (user) {
|
|
||||||
append_user(user);
|
|
||||||
input.focus();
|
|
||||||
update_cancel_button();
|
update_cancel_button();
|
||||||
},
|
setTimeout(function () {
|
||||||
stopAdvance: true,
|
input.focus();
|
||||||
});
|
}, 100);
|
||||||
|
});
|
||||||
pills.onPillRemove(function () {
|
}());
|
||||||
// onPillRemove is fired before the pill is removed from
|
|
||||||
// the DOM.
|
|
||||||
update_cancel_button();
|
|
||||||
setTimeout(function () {
|
|
||||||
input.focus();
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.set_up = function () {
|
exports.set_up = function () {
|
||||||
meta.loaded = true;
|
meta.loaded = true;
|
||||||
|
|
||||||
exports.populate_user_groups();
|
exports.populate_user_groups();
|
||||||
|
|
||||||
$(".organization").on("submit", "form.admin-user-group-form", function (e) {
|
$(".organization").on("submit", "form.admin-user-group-form", function (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user