Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle navibar on mobile #190

Merged
merged 2 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Toggle navigation bar on mobile and desktop devices
Signed-off-by: Artem Anufrij <artem.anufrij@live.de>
  • Loading branch information
artemanufrij authored and juliushaertl committed Jun 19, 2017
commit efb14bdf8511ba20e73d3832025dd22a9062b993
74 changes: 42 additions & 32 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,48 +118,66 @@ button.button-inline:hover {
}

#board {
position: relative;
height: 100%;
position: absolute;
white-space: nowrap;
overflow: auto;
z-index: 100;
width: 100%;
bottom: 0px;
top: 44px;
}

#board #innerBoard {
padding: 10px;
}

#board-header {
#controls {
width: inherit;
color: #333333;
position: relative;
z-index: 120;
min-height: 44px;
display: flex;
align-items: center;
font-size: 14pt;
position: inherit;
width: 100% !important;
padding-left: 44px;
}

#board-header .crumb {
background-image: url('../../../core/img/breadcrumb.svg?v=1');
background-size: auto 24px;
background-position: right center;
background-repeat: no-repeat;
padding: 7px 14px;
#controls .crumb, #controls a {
top: 12px;
}

#board-header > h1 {
#controls > h1 {
white-space: nowrap;
padding: 7px;
}

#controls button {
height: inherit;
}

#controls input[type='text'] {
padding: 4px 5px;
margin: 3px 3px 3px 0px;
border: 0px none transparent;
min-height: initial;
background-color: transparent;
height: inherit;
}

#controls #button-home {
background-image: url(../../../core/img/places/home.svg);
background-position: 8px center;
background-repeat: no-repeat;
padding: 10px 24px 10px 14px;
}

#app-navigation-toggle {
position: relative;
top: 0px;
width: 44px;
height: 44px;
width: 45px;
height: 40px;
cursor: pointer;
opacity: 1;
display: inline-block !important;
position: fixed;
}

.board-header-controls {
Expand Down Expand Up @@ -210,17 +228,13 @@ button.button-inline:hover {
background-color: rgba(240,240,240,.9);
border-radius: 3px;
margin: 3px;
display: flex;
align-content: center;
}

#stack-add > form {
display: flex;
}

#stack-add input {
padding: 4px 5px;
border: 0px none transparent;
min-height: initial;
background-color: transparent;
align-content: center;
}

#stack-add input:invalid {
Expand Down Expand Up @@ -707,9 +721,11 @@ button.button-inline:hover {
* Board list main screen area
*/
#boardlist {
position: absolute;
overflow: auto;
width: 100%;
height: 100%;
overflow: scroll;
bottom: 0px;
top: 44px;
}

#boardlist thead td {
Expand Down Expand Up @@ -965,12 +981,6 @@ button.button-inline:hover {
}
}

@media (max-width: 768px) {
#app-navigation-toggle {
display: none !important;
}
}

/**
* Markdown rendering
*/
Expand Down
20 changes: 20 additions & 0 deletions js/app/Run.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,24 @@ app.run(function ($document, $rootScope, $transitions, BoardService) {
OC.filePath('deck', 'img', 'app-512.png')
);

$('#app-navigation-toggle').off('click');
// App sidebar on mobile
var snapper = new Snap({
element: document.getElementById('app-content'),
disable: 'right',
maxPosition: 250,
minDragDistance: 100
});

$('#app-navigation-toggle').click(function(){
if($(window).width() > 768) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this if, since the toggle should always be visible - then you won't need !important in CSS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it for different behavior. on mobile devices app-content will be moved to the right. on desktop app-navigation will be hide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it even work, @artemanufrij ? Look at the next line toggle('hidde') is not correct 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works fine....

$('#app-navigation').toggle('hidde');
} else {
if(snapper.state().state == 'left'){
snapper.close();
} else {
snapper.open('left');
}
}
});
});
4 changes: 0 additions & 4 deletions js/controller/AppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ app.controller('AppController', function ($scope, $location, $http, $route, $log
$rootScope.sidebar = {
show: false
};
$rootScope.navibar = {
show: true
};
$scope.sidebar = $rootScope.sidebar;
$scope.navibar = $rootScope.navibar;
$scope.user = oc_current_user;
});
5 changes: 3 additions & 2 deletions templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@

<div id="app" class="app-deck" data-ng-app="Deck" ng-controller="AppController" ng-cloak>

<div id="app-navigation" data-ng-controller="ListController" ng-init="initSidebar()" ng-if="navibar.show">
<div id="app-navigation" data-ng-controller="ListController" ng-init="initSidebar()">
<?php print_unescaped($this->inc('part.navigation')); ?>
<?php /* print_unescaped($this->inc('part.settings')); */ ?>
</div>
<div id="app-content" ng-class="{ 'details-visible': sidebar.show }" ui-view>
<div id="app-content" ng-class="{ 'details-visible': sidebar.show }">
<div ui-view></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need additional <div> here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise it doesn't work with core-functions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which function exactly? I tested locally and didn't find any errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the toggle button will be created by js.js from core (see line 1569) automatically. it works only if ui-view is in a separate div instead in app-content

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we create a DOM element using JS if it has to be present in 100% of cases? Seems like a waste of resources. cc @juliushaertl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pixelipo This is part of the logic from core, so that apps don't need to care about adding this sidebar slide functionality. But since we use our own js code to toggle those of course we could also just keep the existing structure and add the toggle button to the template.

</div>
<route-loading-indicator></route-loading-indicator>

Expand Down
11 changes: 5 additions & 6 deletions templates/part.board.mainView.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
<p>{{ statusservice.text }}</p></div>
</div>

<div id="board-header">
<div id="app-navigation-toggle" class="icon-menu" ng-click="navibar.show=!navibar.show"></div>
<a class="crumb" href="#" title="<?php p($l->t('All Boards')); ?>">
<i class="icon icon-home"></i>
<span class="hidden-visually"><?php p($l->t('All Boards')); ?></span>
</a>
<div id="controls">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert to previous version of this code. It was decided some time ago that it's a good approach. CHanges here are not needed to make toggle work.

I do agree with renaming #board-header to #controls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, but it's same code like files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"same code as files" I remember that discussion from a different PR 😉 files also has a wrong. This is what is causing issue with positioning of icons mentioned by @juliushaertl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we discussed that some times ago, yes, although I'm not sure what exactly the reason was for that. 🙈 Let's use our fixed approach, we can always go to the way files does it once it is implemented properly there.

<div class="crumb svg last">
<a href="#" id="button-home" title="<?php p($l->t('All Boards')); ?>">
</a>
</div>
<h1 class="title" style="border-bottom: 2px solid #{{boardservice.getCurrent().color }};">
{{ boardservice.getCurrent().title }}
</h1>
Expand Down
14 changes: 8 additions & 6 deletions templates/part.boardlist.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div id="board-header">
<div id="app-navigation-toggle" class="icon-menu" ng-click="navibar.show=!navibar.show"></div>
<a class="crumb" href="#" title="<?php p($l->t('All Boards')); ?>">
<i class="icon icon-home"></i>
<span class="hidden-visually"><?php p($l->t('All Boards')); ?></span>
</a>
<div id="controls">
<div class="breadcrumb">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

<div class="crumb svg last">
<a href="#" id="button-home" title="<?php p($l->t('All Boards')); ?>">
</a>
<span style="display: none;"></span>
</div>
</div>
</div>
<div id="boardlist">
<table width="100%">
Expand Down