Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Fixed #39: Backbutton for Electron and Cordova
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Rauber committed Feb 26, 2016
1 parent 919b0f0 commit 7d3cd2c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/BoardZ/app/components/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li back-button>
<a>
<i class="fa fa-arrow-circle-left"></i>
</a>
</li>
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-bell-o"> </i>
Expand Down
3 changes: 2 additions & 1 deletion src/BoardZ/app/components/header/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {LoginService} from '../../services/login.service';
import {TokenService} from '../../services/token.service';
import {NotificationService} from '../../services/notification.service';
import {LogService} from '../../services/log.service';
import {BackButtonDirective} from '../../directives/back.button.directive';

@Component({
selector: 'boardz-header',
directives: [NgClass],
directives: [NgClass, BackButtonDirective],
templateUrl: 'app/components/header/header.html'
})
export class HeaderComponent implements OnInit {
Expand Down
26 changes: 26 additions & 0 deletions src/BoardZ/app/directives/back.button.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Directive, HostListener} from 'angular2/core';
import {PlatformInformationService} from '../services/platform.information.service';
import {Location} from 'angular2/router';
@Directive({
selector: '[back-button]',
host: {
'[attr.hidden]': 'isHidden'
}
})
export class BackButtonDirective {
public isHidden: boolean = true;

constructor(private _platformInformationService: PlatformInformationService,
private _location: Location) {
this.setHidden();
}

private setHidden(): void {
this.isHidden = this._platformInformationService.isWeb;
}

@HostListener('click')
public onClick() {
this._location.back();
}
}
2 changes: 1 addition & 1 deletion src/BoardZ/app/services/platform.information.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export class PlatformInformationService {
private guessPlatform(): void {
this._isMobile = !!window.cordova;
this._isDesktop = window.navigator.userAgent.match(/Electron/) !== null;
this._isWeb = !(this._isMobile && this._isDesktop);
this._isWeb = !(this._isMobile || this._isDesktop);
}
}
5 changes: 5 additions & 0 deletions src/BoardZ/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
.content-wrapper {
overflow-y: scroll;
}

/* Navigation */
body .navbar-custom-menu [hidden="true"] {
display: none;
}

0 comments on commit 7d3cd2c

Please sign in to comment.