"click .chan": "chanClick"\r
},\r
\r
+ // none=0, action=1, activity=2, highlight=3\r
+ alert_level: 0,\r
+\r
// The container this panel is within\r
$container: null,\r
\r
line_msg = '<div class="msg <%= type %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
$this.append(_.template(line_msg, msg));\r
\r
+ if (msg.type === 'action') {\r
+ this.alert('action');\r
+ } else if (msg.msg.indexOf(kiwi.gateway.get('nick')) > -1) {\r
+ this.alert('highlight');\r
+ } else {\r
+ this.alert('activity');\r
+ }\r
+\r
this.scrollToBottom();\r
\r
// Make sure our DOM isn't getting too large (Acts as scrollback)\r
}\r
\r
this.scrollToBottom();\r
+ this.alert('none');\r
\r
this.trigger('active', this.model);\r
kiwi.app.panels.trigger('active', this.model);\r
},\r
\r
\r
+ alert: function (level) {\r
+ // No need to highlight if this si the active panel\r
+ if (this.model == kiwi.app.panels.active) return;\r
+\r
+ var types, type_idx;\r
+ var types = ['none', 'action', 'activity', 'highlight'];\r
+\r
+ // Default alert level\r
+ level = level || 'none';\r
+\r
+ // If this alert level does not exist, assume clearing current level\r
+ type_idx = _.indexOf(types, level);\r
+ if (!type_idx) {\r
+ level = 'none';\r
+ type_idx = 0;\r
+ }\r
+\r
+ // Only 'upgrade' the alert. Never down (unless clearing)\r
+ console.log(type_idx, this.alert_level);\r
+ if (type_idx !== 0 && type_idx <= this.alert_level) {\r
+ return;\r
+ }\r
+\r
+ // Clear any existing levels\r
+ this.model.tab.removeClass(function (i, css) {\r
+ return (css.match (/\balert_\S+/g) || []).join(' ');\r
+ });\r
+\r
+ // Add the new level if there is one\r
+ if (level !== 'none') {\r
+ this.model.tab.addClass('alert_' + level);\r
+ }\r
+\r
+ this.alert_level = type_idx;\r
+ },\r
+\r
+\r
// Scroll to the bottom of the panel\r
scrollToBottom: function () {\r
// TODO: Don't scroll down if we're scrolled up the panel a little\r
);
}
#toolbar .panellist .active { padding-right:23px; }
-#toolbar .panellist .highlight {
+#toolbar .panellist .alert_highlight {
background: #990000;
font-weight: bold;
}
-#toolbar .panellist .activity { font-weight: bold; background: #009900; }
+#toolbar .panellist .alert_activity { font-weight: bold; background: #009900; }
#toolbar .panellist li img { width:1em; height:1em; top:7px; right:5px; position:absolute; }
#toolbar .panellist li img.icon { left:5px; top:2px; height:auto; width:auto; }