Usernames are now clickable

This commit is contained in:
Mattias Erming 2014-03-15 16:51:21 +01:00
parent 2516dce8cb
commit be945fe4de
5 changed files with 66 additions and 52 deletions

View File

@ -59,22 +59,25 @@ h2 {
padding: 0 10px; padding: 0 10px;
width: 100%; width: 100%;
} }
#chat .channel, #chat .window {
#chat .network {
background: #fff; background: #fff;
height: 100%; height: 100%;
position: absolute; position: absolute;
width: 100%; width: 100%;
} }
#chat .network .close { #chat .network .close,
display: none;
}
#chat .network .users { #chat .network .users {
display: none; display: none;
} }
#chat .network .messages { #chat .network .messages {
right: 0; right: 0;
} }
#chat .query .users {
display: none;
}
#chat .query .messages {
right: 0;
}
#chat .title { #chat .title {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
height: 43px; height: 43px;

View File

@ -18,7 +18,7 @@
{{#networks}} {{#networks}}
<div class="network list-group" data-id="{{id}}"> <div class="network list-group" data-id="{{id}}">
{{#channels}} {{#channels}}
<a href="" class="channel list-group-item" data-id="{{id}}"> <a href="" class="channel list-group-item" data-id="{{id}}" data-name="{{name}}">
<span class="badge pull-right"></span> <span class="badge pull-right"></span>
{{name}} {{name}}
</a> </a>
@ -50,9 +50,9 @@
<script type="text/html" id="users"> <script type="text/html" id="users">
{{#users}} {{#users}}
<div class="user"> <a href="{{name}}" class="user">
{{mode}}{{name}} {{mode}}{{name}}
</div> </a>
{{/users}} {{/users}}
</script> </script>
@ -60,7 +60,7 @@
{{#messages}} {{#messages}}
<div class="message {{type}}"> <div class="message {{type}}">
<span class="time">{{time}}</span> <span class="time">{{time}}</span>
<span class="user">{{mode}}{{user}}</span> <a href="{{user}}" class="user">{{mode}}{{user}}</a>
<span class="text">{{text}}</span> <span class="text">{{text}}</span>
</div> </div>
{{/messages}} {{/messages}}

View File

@ -65,6 +65,19 @@ $(function() {
} }
} }
sidebar.on("click", ".channel", function(e) {
e.preventDefault();
sidebar.find(".active").removeClass("active");
var item = $(this)
.addClass("active")
.find(".badge")
.html("")
.end();
var id = item.data("id");
chat.find(".window[data-id='" + id + "']")
.bringToTop();
});
chat.on("submit", "form", function() { chat.on("submit", "form", function() {
var input = $(this).find(".input"); var input = $(this).find(".input");
var text = input.val(); var text = input.val();
@ -82,7 +95,7 @@ $(function() {
btn.prop("disabled", true); btn.prop("disabled", true);
socket.emit("input", { socket.emit("input", {
id: btn.closest(".window").data("id"), id: btn.closest(".window").data("id"),
text: "/leave" text: "/LEAVE"
}); });
}); });
@ -92,17 +105,27 @@ $(function() {
badge.html((parseInt(badge.html()) + 1) || "1"); badge.html((parseInt(badge.html()) + 1) || "1");
}); });
sidebar.on("click", ".channel", function(e) { chat.on("click", ".user", function(e) {
e.preventDefault(); e.preventDefault();
sidebar.find(".active").removeClass("active"); });
var item = $(this)
.addClass("active") chat.on("dblclick", ".user", function() {
.find(".badge") var user = $(this);
.html("") var id = user.closest(".window").data("id");
.end(); var name = user.attr("href");
var id = item.data("id");
chat.find(".window[data-id='" + id + "']") var channel = sidebar
.bringToTop(); .find(".channel[data-id='" + id + "']")
.siblings(".channel[data-name='" + name + "']");
if (channel.size() != 0) {
channel.trigger("click");
return;
}
socket.emit("input", {
id: id,
text: "/QUERY " + name
});
}); });
}); });

View File

@ -13,6 +13,7 @@ var id = 1;
models.User = Backbone.Model.extend({ models.User = Backbone.Model.extend({
defaults: { defaults: {
mode: "",
name: "" name: ""
} }
}); });

View File

@ -138,22 +138,6 @@ function handleInput(input) {
); );
break; break;
case "QUERY":
var irc = network.irc;
if (!argv[1] || typeof irc === "undefined") {
break;
}
var channels = network.get("channels");
if (argv[1].charAt(0) != "#" && !channels.findWhere({name: argv[1]})) {
channels.add(
new models.Channel({
name: argv[1]
})
);
}
break;
case "TOPIC": case "TOPIC":
var irc = network.irc; var irc = network.irc;
if (typeof irc === "undefined") { if (typeof irc === "undefined") {
@ -192,6 +176,7 @@ function handleInput(input) {
} }
break; break;
case "QUERY":
case "WHOIS": case "WHOIS":
var irc = network.irc; var irc = network.irc;
if (typeof irc !== "undefined") { if (typeof irc !== "undefined") {
@ -275,6 +260,7 @@ function handleEvent(argv) {
if (typeof channel == "undefined") { if (typeof channel == "undefined") {
channel = channels.add( channel = channels.add(
new models.Channel({ new models.Channel({
type: "query",
name: target name: target
}) })
); );
@ -551,6 +537,7 @@ function handleEvent(argv) {
if (typeof channel == "undefined") { if (typeof channel == "undefined") {
channel = channels.add( channel = channels.add(
new models.Channel({ new models.Channel({
type: "query",
name: argv.args[1] name: argv.args[1]
}) })
); );