Better 'Show more' implementation
This commit is contained in:
parent
d2c7c72c38
commit
0f456596ed
|
@ -63,9 +63,11 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="chat">
|
||||
{{#equal <%= messages %> messages.length}}
|
||||
<button class="show-more" data-id="{{id}}">
|
||||
Show more
|
||||
</button>
|
||||
{{/equal}}
|
||||
<div class="messages">
|
||||
{{partial "messages"}}
|
||||
</div>
|
||||
|
|
|
@ -65,7 +65,7 @@ $(function() {
|
|||
.sticky()
|
||||
.end()
|
||||
.find(".input")
|
||||
.tabcomplete(commands, {hint: false})
|
||||
.tabcomplete(complete, {hint: false})
|
||||
.history();
|
||||
|
||||
$("#network-" + data.id)
|
||||
|
@ -97,16 +97,12 @@ $(function() {
|
|||
case "networks":
|
||||
var channels = $.map(data.networks, function(n) { return n.channels; });
|
||||
chat.html(render("windows", {windows: channels}))
|
||||
.find(".input")
|
||||
.tabcomplete(commands, {hint: false})
|
||||
.history()
|
||||
.end()
|
||||
.find(".hidden")
|
||||
.prev(".show-more")
|
||||
.show();
|
||||
chat.find(".chat")
|
||||
.find(".chat")
|
||||
.sticky()
|
||||
.end();
|
||||
.end()
|
||||
.find(".input")
|
||||
.tabcomplete(complete, {hint: false})
|
||||
.history();
|
||||
|
||||
var networks = $("#networks")
|
||||
.html(render("networks", {networks: data.networks}))
|
||||
|
@ -294,6 +290,15 @@ $(function() {
|
|||
|
||||
});
|
||||
|
||||
function complete(word) {
|
||||
return $.grep(
|
||||
commands,
|
||||
function(cmd) {
|
||||
return !cmd.indexOf(word);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function toArray(val) {
|
||||
return Array.isArray(val) ? val : [val];
|
||||
}
|
||||
|
@ -308,6 +313,16 @@ $(function() {
|
|||
});
|
||||
}
|
||||
|
||||
Handlebars.registerHelper(
|
||||
"equal", function(a, b, opt) {
|
||||
a = parseInt(a);
|
||||
b = parseInt(b);
|
||||
if (a == b) {
|
||||
return opt.fn(this);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Handlebars.registerHelper(
|
||||
"uri", function(text) {
|
||||
text = escape(text);
|
||||
|
|
|
@ -61,7 +61,7 @@ function index(req, res, next) {
|
|||
fs.readFile("client/index.html", function(err, file) {
|
||||
var data = _.merge(
|
||||
require("../package.json"),
|
||||
{} // config
|
||||
config
|
||||
);
|
||||
res.end(_.template(
|
||||
file,
|
||||
|
|
Loading…
Reference in New Issue