mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
Move stream sidebar rows into a handlebars template.
(imported from commit f1f2acecec0a0a1ff86bffc2a0244e015535ce86)
This commit is contained in:
@@ -79,38 +79,18 @@ function get_subject_filter_li(stream, subject) {
|
|||||||
// Adds the sidebar stream name that, when clicked,
|
// Adds the sidebar stream name that, when clicked,
|
||||||
// narrows to that stream
|
// narrows to that stream
|
||||||
function add_narrow_filter(name, type) {
|
function add_narrow_filter(name, type) {
|
||||||
var uri = narrow.by_stream_uri(name);
|
|
||||||
var list_item;
|
|
||||||
|
|
||||||
if (get_filter_li(type, name).length) {
|
if (get_filter_li(type, name).length) {
|
||||||
// already exists
|
// already exists
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For some reason, even though the span is inline-block, if it is empty it
|
var args = {name: name,
|
||||||
// takes up no space and you don't see the background color. Thus, add a
|
id: subs.stream_id(name),
|
||||||
// to get the inline-block behavior we want.
|
uri: narrow.by_stream_uri(name),
|
||||||
var swatch = $('<span/>').attr('id', "stream_sidebar_swatch_" + subs.stream_id(name))
|
not_in_home_view: (subs.have(name).in_home_view === false),
|
||||||
.addClass('streamlist_swatch')
|
invite_only: subs.have(name).invite_only,
|
||||||
.css('background-color', subs.get_color(name)).html(" ");
|
color: subs.get_color(name)};
|
||||||
list_item = $('<li>').attr('data-name', name)
|
var list_item = templates.render('stream_sidebar_row', args);
|
||||||
.addClass("narrow-filter")
|
|
||||||
.html(swatch);
|
|
||||||
if (type === 'stream') {
|
|
||||||
list_item.attr('id', "stream_sidebar_" + subs.stream_id(name));
|
|
||||||
if (subs.have(name).in_home_view === false) {
|
|
||||||
list_item.addClass("out_of_home_view");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list_item.append($('<a>').attr('href', uri)
|
|
||||||
.addClass('subscription_name')
|
|
||||||
.text(name)
|
|
||||||
.append('<span class="count">(<span class="value"></span>)</span>'))
|
|
||||||
.append('<span class="arrow pull-right">▽</span>');
|
|
||||||
if (type === "stream" && subs.have(name).invite_only) {
|
|
||||||
list_item.append("<i class='icon-lock'/>");
|
|
||||||
}
|
|
||||||
$("#" + type + "_filters").append(list_item);
|
$("#" + type + "_filters").append(list_item);
|
||||||
return list_item;
|
return list_item;
|
||||||
}
|
}
|
||||||
|
|||||||
21
zephyr/static/templates/stream_sidebar_row.handlebars
Normal file
21
zephyr/static/templates/stream_sidebar_row.handlebars
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{{! Stream sidebar rows }}
|
||||||
|
|
||||||
|
<li data-name="{{name}}" class="narrow-filter{{#if not_in_home_view}} out_of_home_view{{/if}}"
|
||||||
|
id="stream_sidebar_{{id}}">
|
||||||
|
|
||||||
|
{{! For some reason, even though the span is inline-block, if it is empty it
|
||||||
|
takes up no space and you don't see the background color. Thus, add a
|
||||||
|
to get the inline-block behavior we want. }}
|
||||||
|
|
||||||
|
<span id="stream_sidebar_swatch_{{id}}" class="streamlist_swatch"
|
||||||
|
style="background-color: {{color}}"> </span>
|
||||||
|
|
||||||
|
<a href="{{uri}}" class="subscription_name">{{name}}<span class="count">(<span class="value"></span>)</span></a>
|
||||||
|
|
||||||
|
<span class="arrow pull-right">▽</span>
|
||||||
|
|
||||||
|
{{#if invite_only}}
|
||||||
|
<i class="icon-lock"></i>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
</li>
|
||||||
Reference in New Issue
Block a user