mirror of https://github.com/zulip/zulip.git
components: Add `disable_tab` attribute.
This commit is contained in:
parent
ca48b4ec9f
commit
80ceb1a46d
|
@ -34,6 +34,11 @@ run_test('basics', () => {
|
|||
self.class = _.without(tokens, c).join(' ');
|
||||
};
|
||||
|
||||
self.hasClass = function (c) {
|
||||
var tokens = self.class.trim().split(/ +/);
|
||||
return tokens.includes(c);
|
||||
};
|
||||
|
||||
self.data = function (name) {
|
||||
assert.equal(name, 'tab-id');
|
||||
return i;
|
||||
|
@ -197,4 +202,14 @@ run_test('basics', () => {
|
|||
|
||||
click_f.call(tabs[1]);
|
||||
assert.equal(widget.value(), 'translated: Message formatting');
|
||||
|
||||
callback_args = undefined;
|
||||
widget.disable_tab("search-operators");
|
||||
assert.equal(tabs[2].hasClass('disabled'), true);
|
||||
assert.equal(tabs[2].class, "last disabled");
|
||||
|
||||
widget.goto('keyboard-shortcuts');
|
||||
assert.equal(focused_tab, 0);
|
||||
widget.goto("search-operators");
|
||||
assert.equal(focused_tab, 0);
|
||||
});
|
||||
|
|
|
@ -42,9 +42,12 @@ exports.toggle = function (opts) {
|
|||
};
|
||||
|
||||
function select_tab(idx) {
|
||||
var elem = meta.$ind_tab.eq(idx);
|
||||
if (elem.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
meta.$ind_tab.removeClass("selected");
|
||||
|
||||
var elem = meta.$ind_tab.eq(idx);
|
||||
elem.addClass("selected");
|
||||
|
||||
meta.idx = idx;
|
||||
|
@ -98,6 +101,15 @@ exports.toggle = function (opts) {
|
|||
maybe_go_left: maybe_go_left,
|
||||
maybe_go_right: maybe_go_right,
|
||||
|
||||
disable_tab: function (name) {
|
||||
var value = _.find(opts.values, function (o) {
|
||||
return o.key === name;
|
||||
});
|
||||
|
||||
var idx = opts.values.indexOf(value);
|
||||
meta.$ind_tab.eq(idx).addClass('disabled');
|
||||
},
|
||||
|
||||
value: function () {
|
||||
if (meta.idx >= 0) {
|
||||
return opts.values[meta.idx].label;
|
||||
|
|
Loading…
Reference in New Issue