Added mobile interface. Close #8

This commit is contained in:
Mattias Erming 2014-05-29 17:23:23 -07:00
parent 9a06832e6e
commit f33670954d
3 changed files with 197 additions and 39 deletions

View File

@ -6,10 +6,15 @@
} }
html, html,
body { body {
color: #222;
height: 100%; height: 100%;
font: 14px Lato, sans-serif; font: 14px Lato, sans-serif;
margin: 0; margin: 0;
} }
body {
overflow-x: hidden;
position: relative;
}
a { a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
@ -26,11 +31,30 @@ li {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
button {
border: none;
background: none;
margin: 0;
outline: none;
padding: 0;
}
#wrap {
height: 100%;
position: relative;
overflow: hidden;
width: 100%;
}
#viewport {
height: 100%;
position: relative;
width: 100%;
}
#sidebar { #sidebar {
background: #262c36; background: #262c36;
bottom: 0; bottom: 0;
left: 0; left: 0;
line-height: 2em; line-height: 2em;
overflow-y: auto;
padding: 50px; padding: 50px;
position: absolute; position: absolute;
top: 0; top: 0;
@ -102,7 +126,6 @@ li {
margin-top: 30px; margin-top: 30px;
} }
#main { #main {
background: #f00;
bottom: 0; bottom: 0;
left: 240px; left: 240px;
position: absolute; position: absolute;
@ -113,14 +136,13 @@ li {
background: #fff; background: #fff;
bottom: 0; bottom: 0;
left: 0; left: 0;
overflow: hidden;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
} }
#chat { #chat {
font: 13px "Consolas", monospace; font: 13px "Consolas", monospace;
line-height: 1.5em; line-height: 1.3em;
} }
#chat a { #chat a {
color: #33b0f7; color: #33b0f7;
@ -129,32 +151,77 @@ li {
#chat a:hover { #chat a:hover {
opacity: .6; opacity: .6;
} }
#chat .header {
background: #fff;
border-bottom: 1px solid #eee;
color: #ccc;
display: none;
font-size: 13px;
height: 40px;
line-height: 40px;
position: relative;
text-align: center;
}
#chat .header h1 {
color: #222;
display: inline;
font-size: 15px;
}
#chat .header button {
background: no-repeat url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIi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AxLDE1LjQ5OSw1LjAxeiBNMTUuNDk5LDEwLjAxDQoJCQlIMC41MDFjLTAuMjc1LDAtMC41LDAuMjQtMC41LDAuNTM1djEuOTQ3YzAsMC4yODEsMC4yMjUsMC41MTIsMC41LDAuNTEyaDE0Ljk5OGMwLjI3NSwwLDAuNS0wLjIzLDAuNS0wLjUxMnYtMS45NDcNCgkJCUMxNS45OTksMTAuMjUsMTUuNzc0LDEwLjAxLDE1LjQ5OSwxMC4wMXoiLz4NCgk8L2c+DQo8L2c+DQo8L3N2Zz4NCg==);
background-position: 8px 10px;
height: 32px;
opacity: .2;
transition: all .1s;
width: 32px;
}
#chat .header button:hover {
opacity: .5;
}
#chat .header .lt {
left: 4px;
position: absolute;
top: 4px;
}
#chat .header .rt {
position: absolute;
right: 4px;
top: 4px;
}
#chat .header .type {
text-transform: capitalize;
}
#chat .chat { #chat .chat {
background: #fff;
border-bottom: 1px solid #eee;
bottom: 35px; bottom: 35px;
box-shadow: inset 160px 0 #f9f9f9; box-shadow: inset 160px 0 #f9f9f9;
left: 0; left: 0;
padding: 10px 10px 2px;
position: absolute; position: absolute;
right: 180px; right: 180px;
top: 0; top: 0;
} }
#chat .messages { #chat .messages {
display: table;
width: 100%; width: 100%;
} }
#chat .messages td { #chat .row {
padding-top: 2px; display: table-row;
padding-bottom: 2px;
vertical-align: top;
word-break: break-word; word-break: break-word;
word-wrap: break-word; word-wrap: break-word;
} }
#chat td:hover .time { #chat .row span {
display: table-cell;
padding-top: 2px;
padding-bottom: 3px;
}
#chat .row:hover .time {
color: #aaa; color: #aaa;
} }
#chat .from { #chat .from {
padding-right: 10px; padding-right: 10px;
text-align: right; text-align: right;
width: 150px; width: 160px;
} }
#chat .text { #chat .text {
padding-left: 10px; padding-left: 10px;
@ -188,15 +255,20 @@ li {
text-align: center; text-align: center;
width: 50px; width: 50px;
} }
#chat .sidebar {
bottom: 0;
position: absolute;
right: 0;
width: 180px;
top: 0;
}
#chat .meta { #chat .meta {
border: 1px solid #eee; border: 1px solid #eee;
border-width: 0 0 1px 1px; border-width: 0 0 1px 1px;
color: #ccc; color: #ccc;
height: 80px; height: 80px;
padding: 21px 0 0 21px; padding: 25px 0 0 21px;
right: 0; width: 100%;
position: absolute;
width: 180px;
} }
#chat .meta h1 { #chat .meta h1 {
color: #222; color: #222;
@ -212,9 +284,8 @@ li {
overflow-y: auto; overflow-y: auto;
padding: 15px 20px; padding: 15px 20px;
position: absolute; position: absolute;
right: 0;
top: 80px; top: 80px;
width: 180px; width: 100%;
} }
#chat .users li { #chat .users li {
display: table-row; display: table-row;
@ -223,7 +294,6 @@ li {
display: table-cell; display: table-cell;
} }
#chat .form { #chat .form {
border-top: 1px solid #eee;
bottom: 0; bottom: 0;
height: 35px; height: 35px;
left: 0; left: 0;
@ -244,3 +314,55 @@ li {
margin-left: -999px; margin-left: -999px;
position: absolute; position: absolute;
} }
@media (max-width: 768px) {
#viewport.lt {
margin-left: 240px;
}
#viewport.rt {
margin-left: -180px;
}
#viewport.rt .active .sidebar {
display: block;
}
#sidebar {
margin-left: -240px;
}
#main {
left: 0;
}
#chat .lobby .rt,
#chat .query .rt {
display: none;
}
#chat .header {
display: block;
}
#chat .chat {
box-shadow: none;
top: 40px;
}
#chat .chat,
#chat .form {
right: 0;
}
#chat .sidebar {
display: none;
margin-right: -180px;
}
#chat .messages {
display: block;
padding: 4px 6px;
}
#chat .row {
display: block;
padding: 2px 0;
}
#chat .row span {
display: inline;
padding: 0;
}
#chat .row .time {
display: none;
}
}

View File

@ -13,8 +13,8 @@
</head> </head>
<body> <body>
<div id="viewport">
<div id="wrap"> <div id="wrap">
<div id="viewport">
<aside id="sidebar"> <aside id="sidebar">
<section> <section>
<h1>Shout</h1> <h1>Shout</h1>
@ -55,29 +55,48 @@
<script type="text/html" class="windows"> <script type="text/html" class="windows">
{{#each windows}} {{#each windows}}
<div id="window-{{id}}" class="window {{type}}"> <div id="window-{{id}}" class="window {{type}}">
<div class="chat"> <div class="sidebar">
<table class="messages"> <div class="meta">
{{partial "messages"}}
</table>
</div>
<div class="meta">
<h1> <h1>
{{name}} {{name}}
</h1> </h1>
{{#if users}} {{#if users}}
<div class="count"> <div class="count">
Users:
{{users.length}} {{users.length}}
users
</div> </div>
{{else}} {{else}}
<div class="type"> <div class="type">
{{type}} {{type}}
</div> </div>
{{/if}} {{/if}}
</div>
<ul class="users">
{{partial "users"}}
</ul>
</div> </div>
<ul class="users"> <div class="chat">
{{partial "users"}} <div class="messages">
</ul> {{partial "messages"}}
</div>
</div>
<header class="header">
<button class="lt"></button>
<button class="rt"></button>
<h1>
{{name}}
</h1>
{{#if users}}
<span class="count">
{{users.length}}
users
</span>
{{else}}
<span class="type">
{{type}}
</span>
{{/if}}
</header>
<form class="form" data-target="{{id}}"> <form class="form" data-target="{{id}}">
<input class="submit" tabindex="-1" type="submit" > <input class="submit" tabindex="-1" type="submit" >
<input class="input"> <input class="input">
@ -98,24 +117,25 @@
<script type="text/html" class="messages"> <script type="text/html" class="messages">
{{#each messages}} {{#each messages}}
<tr class="msg {{type}}"> <div class="row {{type}}">
<td class="from">
<span class="from">
<a href="#{{from}}" class="user"> <a href="#{{from}}" class="user">
{{from}} {{from}}
</a> </a>
</td> </span>
<td class="text"> <span class="text">
{{#if type}} {{#if type}}
<em class="type"> <em class="type">
{{type}} {{type}}
</em> </em>
{{/if}} {{/if}}
{{{uri text}}} {{{uri text}}}
</td> </span>
<td class="time"> <span class="time">
{{time}} {{time}}
</td> </span>
</tr> </div>
{{/each}} {{/each}}
</script> </script>
</div> </div>

View File

@ -113,7 +113,8 @@ $(function() {
} }
var z = 1; var z = 1;
sidebar.on("click", "a", function() { sidebar.on("click", "a", function(e) {
e.preventDefault();
var link = $(this); var link = $(this);
var target = link.attr("href"); var target = link.attr("href");
if (!target) { if (!target) {
@ -125,7 +126,11 @@ $(function() {
.removeClass("highlight") .removeClass("highlight")
.empty(); .empty();
var window = $(target) var window = $(target)
.css("z-index", z++) .siblings()
.removeClass("active")
.end()
.css("z-index", z++)
.addClass("active")
.find("input") .find("input")
.focus(); .focus();
}); });
@ -156,6 +161,16 @@ $(function() {
return false; return false;
}); });
var viewport = $("#viewport");
chat.on("click", ".lt, .rt", function() {
var btn = $(this);
viewport.toggleClass(btn.attr("class"));
});
chat.on("focus", ".input", function() {
viewport.removeClass();
});
chat.on("append", ".messages", function() { chat.on("append", ".messages", function() {
var messages = $(this); var messages = $(this);
var id = messages.closest(".window").find(".form").data("target"); var id = messages.closest(".window").find(".form").data("target");
@ -175,7 +190,8 @@ $(function() {
target.replaceWith(html); target.replaceWith(html);
}); });
chat.on("click", ".user", function() { chat.on("click", ".user", function(e) {
e.preventDefault();
var user = $(this); var user = $(this);
var id = user.closest(".window").find(".form").data("target"); var id = user.closest(".window").find(".form").data("target");
var name = user.html().replace(/[\s+@]/g, ""); var name = user.html().replace(/[\s+@]/g, "");