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;
width: 100%;
}
#chat .channel,
#chat .network {
#chat .window {
background: #fff;
height: 100%;
position: absolute;
width: 100%;
}
#chat .network .close {
display: none;
}
#chat .network .close,
#chat .network .users {
display: none;
}
#chat .network .messages {
right: 0;
}
#chat .query .users {
display: none;
}
#chat .query .messages {
right: 0;
}
#chat .title {
border-bottom: 1px solid #ccc;
height: 43px;

View File

@ -18,7 +18,7 @@
{{#networks}}
<div class="network list-group" data-id="{{id}}">
{{#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>
{{name}}
</a>
@ -50,9 +50,9 @@
<script type="text/html" id="users">
{{#users}}
<div class="user">
<a href="{{name}}" class="user">
{{mode}}{{name}}
</div>
</a>
{{/users}}
</script>
@ -60,7 +60,7 @@
{{#messages}}
<div class="message {{type}}">
<span class="time">{{time}}</span>
<span class="user">{{mode}}{{user}}</span>
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
<span class="text">{{text}}</span>
</div>
{{/messages}}

View File

@ -65,33 +65,6 @@ $(function() {
}
}
chat.on("submit", "form", function() {
var input = $(this).find(".input");
var text = input.val();
if (text != "") {
input.val("");
socket.emit("input", {
id: input.data("target"),
text: text
});
}
});
chat.on("click", ".close", function() {
var btn = $(this);
btn.prop("disabled", true);
socket.emit("input", {
id: btn.closest(".window").data("id"),
text: "/leave"
});
});
chat.on("append", ".window", function() {
var id = $(this).data("id");
var badge = sidebar.find(".channel[data-id='" + id + "']:not(.active) .badge");
badge.html((parseInt(badge.html()) + 1) || "1");
});
sidebar.on("click", ".channel", function(e) {
e.preventDefault();
sidebar.find(".active").removeClass("active");
@ -104,6 +77,56 @@ $(function() {
chat.find(".window[data-id='" + id + "']")
.bringToTop();
});
chat.on("submit", "form", function() {
var input = $(this).find(".input");
var text = input.val();
if (text != "") {
input.val("");
socket.emit("input", {
id: input.data("target"),
text: text
});
}
});
chat.on("click", ".close", function() {
var btn = $(this);
btn.prop("disabled", true);
socket.emit("input", {
id: btn.closest(".window").data("id"),
text: "/LEAVE"
});
});
chat.on("append", ".window", function() {
var id = $(this).data("id");
var badge = sidebar.find(".channel[data-id='" + id + "']:not(.active) .badge");
badge.html((parseInt(badge.html()) + 1) || "1");
});
chat.on("click", ".user", function(e) {
e.preventDefault();
});
chat.on("dblclick", ".user", function() {
var user = $(this);
var id = user.closest(".window").data("id");
var name = user.attr("href");
var channel = sidebar
.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
});
});
});
(function($) {

View File

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

View File

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