Fix event trigger bug
This commit is contained in:
parent
15a23d131e
commit
2c8040a6ca
|
@ -17,8 +17,10 @@ $(function() {
|
||||||
|
|
||||||
function event(type, json) {
|
function event(type, json) {
|
||||||
console.log(json);
|
console.log(json);
|
||||||
switch (type) {
|
console.log(type);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
case "network":
|
case "network":
|
||||||
var html = "";
|
var html = "";
|
||||||
json.forEach(function(network) {
|
json.forEach(function(network) {
|
||||||
|
@ -81,7 +83,7 @@ $(function() {
|
||||||
if (typeof json.target !== "undefined") {
|
if (typeof json.target !== "undefined") {
|
||||||
target = chat.find(".window[data-id='" + json.target + "']");
|
target = chat.find(".window[data-id='" + json.target + "']");
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = json.data;
|
var message = json.data;
|
||||||
if (message.type == "error") {
|
if (message.type == "error") {
|
||||||
target = target.parent().find(".active");
|
target = target.parent().find(".active");
|
||||||
|
|
|
@ -24,8 +24,7 @@ models.Users = Backbone.Collection.extend({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Iterate all the modes and move users with these
|
// Move users with these modes to the top.
|
||||||
// modes to the top of the collection.
|
|
||||||
var modes = ["+", "@"];
|
var modes = ["+", "@"];
|
||||||
for (var i in modes) {
|
for (var i in modes) {
|
||||||
this.models = _.remove(this.models, function(user) {
|
this.models = _.remove(this.models, function(user) {
|
||||||
|
@ -108,8 +107,11 @@ models.Network = Backbone.Model.extend({
|
||||||
channels: new models.Channels,
|
channels: new models.Channels,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get("channels").on("message user", function() { this.trigger(action, data); }, this);
|
|
||||||
this.get("channels").on("all", function(action, data) {
|
this.get("channels").on("all", function(action, data) {
|
||||||
|
if (action == "message"
|
||||||
|
|| action == "user") {
|
||||||
|
return this.trigger(action, data);
|
||||||
|
}
|
||||||
this.trigger("channel", {
|
this.trigger("channel", {
|
||||||
target: this.get("id"),
|
target: this.get("id"),
|
||||||
type: "channel",
|
type: "channel",
|
||||||
|
|
|
@ -86,8 +86,10 @@ function input(json) {
|
||||||
"msg",
|
"msg",
|
||||||
channel.get("name")
|
channel.get("name")
|
||||||
);
|
);
|
||||||
case "msg":
|
case "msg":
|
||||||
channel.addMessage({message: _.tail(args, 2)});
|
channel.addMessage({
|
||||||
|
message: _.tail(args, 2).join(" ")
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "server":
|
case "server":
|
||||||
|
|
Loading…
Reference in New Issue