Toggle show/hide events

This commit is contained in:
Mattias Erming 2014-03-16 21:07:27 +01:00
parent ff53a94440
commit 4e66f1c071
5 changed files with 349 additions and 12 deletions

View File

@ -836,7 +836,7 @@ input[type="button"].btn-block {
white-space: nowrap; white-space: nowrap;
text-align: center; text-align: center;
background-color: #999999; background-color: #999999;
border-radius: 10px; border-radius: 2px;
} }
.badge:empty { .badge:empty {
display: none; display: none;
@ -1015,15 +1015,299 @@ a.list-group-item-danger.active:focus {
margin-bottom: 0; margin-bottom: 0;
line-height: 1.3; line-height: 1.3;
} }
.panel {
margin-bottom: 20px;
background-color: #ffffff;
border: 1px solid transparent;
border-radius: 2px;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}
.panel-body {
padding: 15px;
}
.panel-heading {
padding: 10px 15px;
border-bottom: 1px solid transparent;
border-top-right-radius: 1px;
border-top-left-radius: 1px;
}
.panel-heading > .dropdown .dropdown-toggle {
color: inherit;
}
.panel-title {
margin-top: 0;
margin-bottom: 0;
font-size: 16px;
color: inherit;
}
.panel-title > a {
color: inherit;
}
.panel-footer {
padding: 10px 15px;
background-color: #f5f5f5;
border-top: 1px solid #dddddd;
border-bottom-right-radius: 1px;
border-bottom-left-radius: 1px;
}
.panel > .list-group {
margin-bottom: 0;
}
.panel > .list-group .list-group-item {
border-width: 1px 0;
border-radius: 0;
}
.panel > .list-group:first-child .list-group-item:first-child {
border-top: 0;
border-top-right-radius: 1px;
border-top-left-radius: 1px;
}
.panel > .list-group:last-child .list-group-item:last-child {
border-bottom: 0;
border-bottom-right-radius: 1px;
border-bottom-left-radius: 1px;
}
.panel-heading + .list-group .list-group-item:first-child {
border-top-width: 0;
}
.panel > .table,
.panel > .table-responsive > .table {
margin-bottom: 0;
}
.panel > .table:first-child,
.panel > .table-responsive:first-child > .table:first-child {
border-top-right-radius: 1px;
border-top-left-radius: 1px;
}
.panel > .table:first-child > thead:first-child > tr:first-child td:first-child,
.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child,
.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child,
.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child,
.panel > .table:first-child > thead:first-child > tr:first-child th:first-child,
.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child,
.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child,
.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child {
border-top-left-radius: 1px;
}
.panel > .table:first-child > thead:first-child > tr:first-child td:last-child,
.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child,
.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child,
.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child,
.panel > .table:first-child > thead:first-child > tr:first-child th:last-child,
.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child,
.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child,
.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child {
border-top-right-radius: 1px;
}
.panel > .table:last-child,
.panel > .table-responsive:last-child > .table:last-child {
border-bottom-right-radius: 1px;
border-bottom-left-radius: 1px;
}
.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child,
.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child,
.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child,
.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child,
.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child,
.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child {
border-bottom-left-radius: 1px;
}
.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child,
.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child,
.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child,
.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child,
.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child,
.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child {
border-bottom-right-radius: 1px;
}
.panel > .panel-body + .table,
.panel > .panel-body + .table-responsive {
border-top: 1px solid #dddddd;
}
.panel > .table > tbody:first-child > tr:first-child th,
.panel > .table > tbody:first-child > tr:first-child td {
border-top: 0;
}
.panel > .table-bordered,
.panel > .table-responsive > .table-bordered {
border: 0;
}
.panel > .table-bordered > thead > tr > th:first-child,
.panel > .table-responsive > .table-bordered > thead > tr > th:first-child,
.panel > .table-bordered > tbody > tr > th:first-child,
.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child,
.panel > .table-bordered > tfoot > tr > th:first-child,
.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child,
.panel > .table-bordered > thead > tr > td:first-child,
.panel > .table-responsive > .table-bordered > thead > tr > td:first-child,
.panel > .table-bordered > tbody > tr > td:first-child,
.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child,
.panel > .table-bordered > tfoot > tr > td:first-child,
.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {
border-left: 0;
}
.panel > .table-bordered > thead > tr > th:last-child,
.panel > .table-responsive > .table-bordered > thead > tr > th:last-child,
.panel > .table-bordered > tbody > tr > th:last-child,
.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child,
.panel > .table-bordered > tfoot > tr > th:last-child,
.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child,
.panel > .table-bordered > thead > tr > td:last-child,
.panel > .table-responsive > .table-bordered > thead > tr > td:last-child,
.panel > .table-bordered > tbody > tr > td:last-child,
.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child,
.panel > .table-bordered > tfoot > tr > td:last-child,
.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {
border-right: 0;
}
.panel > .table-bordered > thead > tr:first-child > td,
.panel > .table-responsive > .table-bordered > thead > tr:first-child > td,
.panel > .table-bordered > tbody > tr:first-child > td,
.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td,
.panel > .table-bordered > thead > tr:first-child > th,
.panel > .table-responsive > .table-bordered > thead > tr:first-child > th,
.panel > .table-bordered > tbody > tr:first-child > th,
.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th {
border-bottom: 0;
}
.panel > .table-bordered > tbody > tr:last-child > td,
.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td,
.panel > .table-bordered > tfoot > tr:last-child > td,
.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td,
.panel > .table-bordered > tbody > tr:last-child > th,
.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th,
.panel > .table-bordered > tfoot > tr:last-child > th,
.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th {
border-bottom: 0;
}
.panel > .table-responsive {
border: 0;
margin-bottom: 0;
}
.panel-group {
margin-bottom: 20px;
}
.panel-group .panel {
margin-bottom: 0;
border-radius: 2px;
overflow: hidden;
}
.panel-group .panel + .panel {
margin-top: 5px;
}
.panel-group .panel-heading {
border-bottom: 0;
}
.panel-group .panel-heading + .panel-collapse .panel-body {
border-top: 1px solid #dddddd;
}
.panel-group .panel-footer {
border-top: 0;
}
.panel-group .panel-footer + .panel-collapse .panel-body {
border-bottom: 1px solid #dddddd;
}
.panel-default {
border-color: #dddddd;
}
.panel-default > .panel-heading {
color: #333333;
background-color: #f5f5f5;
border-color: #dddddd;
}
.panel-default > .panel-heading + .panel-collapse .panel-body {
border-top-color: #dddddd;
}
.panel-default > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #dddddd;
}
.panel-primary {
border-color: #428bca;
}
.panel-primary > .panel-heading {
color: #ffffff;
background-color: #428bca;
border-color: #428bca;
}
.panel-primary > .panel-heading + .panel-collapse .panel-body {
border-top-color: #428bca;
}
.panel-primary > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #428bca;
}
.panel-success {
border-color: #d6e9c6;
}
.panel-success > .panel-heading {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}
.panel-success > .panel-heading + .panel-collapse .panel-body {
border-top-color: #d6e9c6;
}
.panel-success > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #d6e9c6;
}
.panel-info {
border-color: #bce8f1;
}
.panel-info > .panel-heading {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
}
.panel-info > .panel-heading + .panel-collapse .panel-body {
border-top-color: #bce8f1;
}
.panel-info > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #bce8f1;
}
.panel-warning {
border-color: #faebcc;
}
.panel-warning > .panel-heading {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
}
.panel-warning > .panel-heading + .panel-collapse .panel-body {
border-top-color: #faebcc;
}
.panel-warning > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #faebcc;
}
.panel-danger {
border-color: #ebccd1;
}
.panel-danger > .panel-heading {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.panel-danger > .panel-heading + .panel-collapse .panel-body {
border-top-color: #ebccd1;
}
.panel-danger > .panel-footer + .panel-collapse .panel-body {
border-bottom-color: #ebccd1;
}
.clearfix:before, .clearfix:before,
.clearfix:after, .clearfix:after,
.nav:before, .nav:before,
.nav:after { .nav:after,
.panel-body:before,
.panel-body:after {
content: " "; content: " ";
display: table; display: table;
} }
.clearfix:after, .clearfix:after,
.nav:after { .nav:after,
.panel-body:after {
clear: both; clear: both;
} }
.center-block { .center-block {

View File

@ -46,6 +46,24 @@ h2 {
font-weight: normal; font-weight: normal;
margin-top: -1px; margin-top: -1px;
} }
#sidebar .panel {
margin: 10px;
}
#sidebar .panel label {
display: inline-block;
cursor: pointer;
margin-left: 5px;
padding: 5px 0;
width: 60px;
}
#sidebar .panel label.first {
margin-top: 10px;
}
#sidebar .panel input[type=checkbox] {
float: left;
margin-top: 1px;
margin-right: 10px;
}
#chat { #chat {
bottom: 0; bottom: 0;
left: 200px; left: 200px;
@ -73,6 +91,12 @@ h2 {
padding: 0 10px; padding: 0 10px;
width: 100%; width: 100%;
} }
#chat.hide-join .join,
#chat.hide-part .part,
#chat.hide-nick .nick,
#chat.hide-quit .quit {
display: none;
}
#chat .window { #chat .window {
background: #fff; background: #fff;
height: 100%; height: 100%;

View File

@ -2,6 +2,8 @@
<html> <html>
<head> <head>
<title>Chat</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
@ -12,6 +14,7 @@
<body> <body>
<aside id="sidebar"> <aside id="sidebar">
<header class="header"> <header class="header">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#list" data-toggle="tab">Channels</a></li> <li class="active"><a href="#list" data-toggle="tab">Channels</a></li>
@ -19,10 +22,24 @@
</ul> </ul>
</header> </header>
<div class="tab-content"> <div class="tab-content">
<div id="list" class="tab-pane fade in active list"></div> <div id="list" class="tab-pane active"></div>
<div id="settings" class="tab-pane fade"></div> <div id="settings" class="tab-pane">
<div class="panel panel-default">
<div class="panel-heading">
Show/hide events
</div> </div>
<div class="panel-body">
<input type="checkbox" value="join"/>
<input type="checkbox" value="part"/>
<input type="checkbox" value="nick"/>
<input type="checkbox" value="quit"/>
</div>
</div>
</div>
</div>
</aside> </aside>
<div id="chat"></div> <div id="chat"></div>
<script type="text/html" id="networks"> <script type="text/html" id="networks">

View File

@ -37,7 +37,7 @@ $(function() {
data.forEach(function(network) { data.forEach(function(network) {
chat.append(Mustache.render(channels, network, partials)); chat.append(Mustache.render(channels, network, partials));
}); });
sidebar.find(".list").html( sidebar.find("#list").html(
Mustache.render(networks, { Mustache.render(networks, {
networks: data networks: data
}) })
@ -71,7 +71,7 @@ $(function() {
sidebar.on("click", ".channel", function(e) { sidebar.on("click", ".channel", function(e) {
e.preventDefault(); e.preventDefault();
sidebar.find(".list .active").removeClass("active"); sidebar.find("#list .active").removeClass("active");
var item = $(this) var item = $(this)
.addClass("active") .addClass("active")
.find(".badge") .find(".badge")
@ -82,6 +82,18 @@ $(function() {
.bringToTop(); .bringToTop();
}); });
sidebar.find("input[type=checkbox]").each(function() {
var input = $(this);
var value = input.val();
input.prop("checked", true).wrap("<label>").parent().append(value);
input.on("change", function() {
chat.toggleClass(
"hide-" + value,
!input.prop("checked")
);
});
});
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();

View File

@ -30,8 +30,8 @@ models.UserCollection = Backbone.Collection.extend({
} }
); );
// Lets iterate all modes and move users with these // Iterate all the modes and move users with these
// modes to top of the list. // 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) {