Skip to content

Commit

Permalink
fixed #53
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbarbu committed Feb 28, 2013
1 parent 85d0c0c commit ae0f67a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions webchat/Static/Js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function load_chat(){
stream.addEventListener('users', handle_event_users);
stream.addEventListener('ping', handle_event_ping);

set_spacing();

display_rooms();
display_users($('.tab-pane.active').attr('id'));
$('#text').attr('data-provide', 'typeahead');
Expand Down
25 changes: 25 additions & 0 deletions webchat/Static/Js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,29 @@ function handle_tab_show(e) {
*/
function handle_event_ping(e) {
$.post(Url.PongEvent, 'PONG!');
}

/**
* Set the spacing according to the device's resolution
* More specifically: when on mobile phones, remove some spacing
*/
function set_spacing() {
if (window.screen.availHeight < 600 && window.screen.availWidth < 600) {
$('body').css('margin', '0px 0px 0px 0px');
$('.nav.nav-tabs').css('margin', '0px 0px 0px 0px');
$('#user-list').css('padding', '0px');
$('#user-list').css('margin', '1px');
$('label[for=text]').css('margin-bottom', '0px');
$('#text').css('margin-bottom', '0px');
$('#join_rooms').css('margin-bottom', '0px');
$('.well').css('margin-bottom', '0px');
$('.help-block').css('margin-bottom', '0px');

if(document.URL.indexOf('Chat') == -1 ){
$('#rooms').css('margin-bottom', '0px');
$('#nick').css('margin-bottom', '0px');
$('form').css('margin', '0px 0px 0px 0px');
$('br')[1].remove()
}
}
}
3 changes: 0 additions & 3 deletions webchat/Views/Chat/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
};
</script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
type="text/javascript"></script>

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"
type="text/javascript"></script>

Expand Down
7 changes: 6 additions & 1 deletion webchat/Views/Index/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
@if(!ViewData.ModelState.IsValid){
var errors = ViewData.ModelState.Values.SelectMany(v => v.Errors).Select(t => t.ErrorMessage);
@Html.ErrorSummary("form-errors", errors.ToList(), null, new { @class = "alert alert-error" })
}
}

<script type="text/javascript" src="@Url.Content("~/Static/Js/helpers.js")"></script>
<script type="text/javascript">
set_spacing();
</script>
4 changes: 3 additions & 1 deletion webchat/Views/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<meta charset="utf-8">

<link rel="shortcut icon" href="@Url.Content("~/Static/favicon.ico")" />


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
type="text/javascript"></script>
<link type="text/css" href="@Url.Content("~/Static/Css/jquery-ui-1.8.22.custom.css")" rel="stylesheet" />
<link type="text/css" href="@Url.Content("~/Static/Css/bootstrap.min.css")" rel="stylesheet" />
<link type="text/css" href="@Url.Content("~/Static/Css/style.css")" rel="stylesheet" />
Expand Down

0 comments on commit ae0f67a

Please sign in to comment.