Merge pull request #7309 from owncloud/mobile-header

Header optimizations for mobile
This commit is contained in:
Morris Jobke 2014-02-21 13:37:01 +01:00
commit 387cdc81dc
8 changed files with 59 additions and 15 deletions

22
core/css/mobile.css Normal file
View File

@ -0,0 +1,22 @@
@media only screen and (max-width: 600px) {
/* compress search box on mobile, expand when focused */
.searchbox input[type="search"] {
width: 15%;
-webkit-transition: width 100ms;
-moz-transition: width 100ms;
-o-transition: width 100ms;
transition: width 100ms;
}
.searchbox input[type="search"]:focus,
.searchbox input[type="search"]:active {
width: 155px;
}
/* do not show display name on mobile when profile picture is present */
#header .avatardiv.avatardiv-shown + #expandDisplayName {
display: none;
}
}

View File

@ -37,11 +37,12 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari
.header-right { float:right; vertical-align:middle; padding:0.5em; } .header-right { float:right; vertical-align:middle; padding:0.5em; }
.header-right > * { vertical-align:middle; } .header-right > * { vertical-align:middle; }
/* Profile picture in header */
#header .avatardiv { #header .avatardiv {
float: left; float: left;
display: inline-block; display: inline-block;
margin-right: 5px;
} }
#header .avatardiv img { #header .avatardiv img {
opacity: 1; opacity: 1;
} }
@ -218,17 +219,19 @@ textarea:disabled {
color: #bbb; color: #bbb;
} }
/* Searchbox */
.searchbox input[type="search"] { .searchbox input[type="search"] {
position: relative;
font-size: 1.2em; font-size: 1.2em;
padding: .2em .5em .2em 1.5em; padding-left: 1.5em;
background: #fff url('../img/actions/search.svg') no-repeat .5em center; background: #fff url('../img/actions/search.svg') no-repeat .5em center;
border: 0; border: 0;
border-radius: 1em; border-radius: 2em;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity: .7; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity: .7;
margin-top: 10px; margin-top: 6px;
float: right; float: right;
} }
input[type="submit"].enabled { input[type="submit"].enabled {
background: #66f866; background: #66f866;
border: 1px solid #5e5; border: 1px solid #5e5;
@ -719,12 +722,11 @@ label.infield { cursor:text !important; top:1.05em; left:.85em; }
/* USER MENU */ /* USER MENU */
#settings { #settings {
float: right; float: right;
margin-top: 7px;
margin-left: 10px;
color: #bbb; color: #bbb;
} }
#expand { #expand {
padding: 15px 15px 15px 5px; display: block;
padding: 7px 12px 6px 7px;
cursor: pointer; cursor: pointer;
font-weight: bold; font-weight: bold;
} }

View File

@ -1,6 +1,13 @@
$(document).ready(function(){ $(document).ready(function(){
if (OC.currentUser) { if (OC.currentUser) {
$('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true); var callback = function() {
// do not show display name on mobile when profile picture is present
if($('#header .avatardiv').children().length > 0) {
$('#header .avatardiv').addClass('avatardiv-shown');
}
};
$('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true, callback);
// Personal settings // Personal settings
$('#avatar .avatardiv').avatar(OC.currentUser, 128); $('#avatar .avatardiv').avatar(OC.currentUser, 128);
} }

View File

@ -39,10 +39,15 @@
* This will behave like the first example, but it will hide the avatardiv, if * This will behave like the first example, but it will hide the avatardiv, if
* it will display the default placeholder. undefined is the ie8fix from * it will display the default placeholder. undefined is the ie8fix from
* example 4 and can be either true, or false/undefined, to be ignored. * example 4 and can be either true, or false/undefined, to be ignored.
*
* 6. $('.avatardiv').avatar('jdoe', 128, undefined, true, callback);
* This will behave like the above example, but it will call the function
* defined in callback after the avatar is placed into the DOM.
*
*/ */
(function ($) { (function ($) {
$.fn.avatar = function(user, size, ie8fix, hidedefault) { $.fn.avatar = function(user, size, ie8fix, hidedefault, callback) {
if (typeof(size) === 'undefined') { if (typeof(size) === 'undefined') {
if (this.height() > 0) { if (this.height() > 0) {
size = this.height(); size = this.height();
@ -91,6 +96,9 @@
$div.html('<img src="'+url+'">'); $div.html('<img src="'+url+'">');
} }
} }
if(typeof callback === 'function') {
callback();
}
}); });
}); });
}; };

View File

@ -860,6 +860,7 @@ function initCore() {
// checkShowCredentials(); // checkShowCredentials();
// $('input#user, input#password').keyup(checkShowCredentials); // $('input#user, input#password').keyup(checkShowCredentials);
// user menu
$('#settings #expand').keydown(function(event) { $('#settings #expand').keydown(function(event) {
if (event.which === 13 || event.which === 32) { if (event.which === 13 || event.which === 32) {
$('#expand').click() $('#expand').click()
@ -872,7 +873,8 @@ function initCore() {
$('#settings #expanddiv').click(function(event){ $('#settings #expanddiv').click(function(event){
event.stopPropagation(); event.stopPropagation();
}); });
$(document).click(function(){//hide the settings menu when clicking outside it //hide the user menu when clicking outside it
$(document).click(function(){
$('#settings #expanddiv').slideUp(200); $('#settings #expanddiv').slideUp(200);
}); });

View File

@ -15,7 +15,7 @@
</title> </title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.0">
<meta name="apple-itunes-app" content="app-id=543672169"> <meta name="apple-itunes-app" content="app-id=543672169">
<link rel="shortcut icon" href="<?php print_unescaped(image_path('', 'favicon.png')); ?>" /> <link rel="shortcut icon" href="<?php print_unescaped(image_path('', 'favicon.png')); ?>" />
<link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>" /> <link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>" />
@ -51,12 +51,12 @@
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<div id="settings" class="svg"> <div id="settings" class="svg">
<span id="expand" tabindex="0" role="link"> <span id="expand" tabindex="0" role="link">
<?php if ($_['enableAvatars']): ?>
<div class="avatardiv"></div>
<?php endif; ?>
<span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span> <span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span>
<img class="svg" alt="" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /> <img class="svg" alt="" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" />
</span> </span>
<?php if ($_['enableAvatars']): ?>
<div class="avatardiv"></div>
<?php endif; ?>
<div id="expanddiv"> <div id="expanddiv">
<ul> <ul>
<?php foreach($_['settingsnavigation'] as $entry):?> <?php foreach($_['settingsnavigation'] as $entry):?>

View File

@ -332,6 +332,7 @@ class OC {
} }
OC_Util::addStyle("styles"); OC_Util::addStyle("styles");
OC_Util::addStyle("mobile");
OC_Util::addStyle("icons"); OC_Util::addStyle("icons");
OC_Util::addStyle("apps"); OC_Util::addStyle("apps");
OC_Util::addStyle("fixes"); OC_Util::addStyle("fixes");

View File

@ -52,9 +52,11 @@ function updateAvatar (hidedefault) {
if(hidedefault) { if(hidedefault) {
$headerdiv.hide(); $headerdiv.hide();
$('#header .avatardiv').removeClass('avatardiv-shown');
} else { } else {
$headerdiv.css({'background-color': ''}); $headerdiv.css({'background-color': ''});
$headerdiv.avatar(OC.currentUser, 32, true); $headerdiv.avatar(OC.currentUser, 32, true);
$('#header .avatardiv').addClass('avatardiv-shown');
} }
$displaydiv.css({'background-color': ''}); $displaydiv.css({'background-color': ''});
$displaydiv.avatar(OC.currentUser, 128, true); $displaydiv.avatar(OC.currentUser, 128, true);