Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 6fc8f98

Browse files
committed
initial implementation of the app bar
1 parent a0c9bfd commit 6fc8f98

File tree

10 files changed

+175
-54
lines changed

10 files changed

+175
-54
lines changed

css/obBase.css

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,32 @@ form {
202202
width: calc(100% - 230px);
203203
}
204204

205-
#pageNav {
205+
#appBar {
206206
position: fixed;
207-
top: 0;
208-
-webkit-app-region: drag;
207+
width: 100%;
209208
z-index: 13;
209+
background-color: #327EB8;
210+
padding: 10px 8px;
211+
box-sizing: border-box;
212+
-webkit-app-region: drag;
213+
}
214+
215+
#appBar .windowControls {
216+
float: left;
210217
}
211218

219+
.platform-win #appBar .windowControls {
220+
position: absolute;
221+
right: 8px;
222+
top: 8px;
223+
}
224+
225+
#pageNav {
226+
position: fixed;
227+
top: 25px;
228+
-webkit-app-region: no-drag;
229+
z-index: 13;
230+
}
212231

213232
.pageNavContainer {
214233
width: 100%;
@@ -240,7 +259,7 @@ form {
240259
#sideBar {
241260
position: fixed;
242261
right: -183px;
243-
top: 50px;
262+
top: 75px;
244263
width:230px;
245264
background-color: #252525;
246265
border-left: 0;
@@ -2002,7 +2021,39 @@ margin: auto;
20022021
.btn.btn-win.btn-winMax {
20032022
background-color: #B8E986;
20042023
position: relative;
2024+
}
20052025

2026+
.platform-win .btn.btn-win {
2027+
background-color: transparent;
2028+
border-radius: 0;
2029+
width: 19px;
2030+
height: 19px;
2031+
box-shadow: none;
2032+
}
2033+
2034+
.platform-win .btn.btn-winClose {
2035+
float: right;
2036+
margin-left: 6px;
2037+
}
2038+
2039+
.platform-win .btn.btn-win .btn-win-icon {
2040+
display: block;
2041+
top: -3px;
2042+
font-size: 21px;
2043+
color: #fff;
2044+
}
2045+
2046+
.platform-win .btn.btn-winMax {
2047+
float: right;
2048+
margin-left: 6px;
2049+
border: 1px solid #fff;
2050+
width: 13px;
2051+
height: 13px;
2052+
top: 3px;
2053+
}
2054+
2055+
.platform-win .btn.btn-winMax .btn-win-icon {
2056+
display: none;
20062057
}
20072058

20082059
.btn.btn-bar {
@@ -4561,7 +4612,7 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
45614612
padding-top: 20px;
45624613
-webkit-app-region: no-drag;
45634614
position: relative;
4564-
top: 50px;
4615+
top: 85px;
45654616
box-sizing: border-box;
45664617
}
45674618

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ <h2 class="ion-android-close custCol-text clickable"></h2>
4242
</div>
4343
<div id="statusBar"></div>
4444
<div id="pageNav" class="bar navBar navBar-main custCol-secondary padding0"></div>
45+
<div id="appBar" class="top0 alignCenter custCol-secondary"></div>
4546
<!-- the loading modal must be on top of the page nav or the reload button is hidden -->
4647
<div id="loadingModal" class="modal modal-opaque js-loadingModal top0 hide">
4748
<div class="spinner-with-logo fullCentered">

js/languages/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"Cancel": "Cancel",
1616
"TryAgain": "Try Again",
1717
"ClosingOpenBazaar": "Close (Your page will go offline)",
18+
"ClosingOpenBazaarNonInstaller": "Close",
1819
"Minimize": "Minimize",
1920
"Maximize": "Maximize",
2021
"Restore": "Restore",

js/router.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ module.exports = Backbone.Router.extend({
267267

268268
// hide the discover onboarding callout
269269
$('.js-OnboardingIntroDiscoverHolder').addClass('hide');
270+
app.appBar.setTitle(polyglot.t('Discover'));
270271
},
271272

272273
userPage: function(userID, state, itemHash, skipNSFWmodal, handle){
@@ -283,6 +284,7 @@ module.exports = Backbone.Router.extend({
283284
if (handle) options.handle = handle;
284285

285286
this.newView(new userPageView(options),"userPage",'','onPage');
287+
app.appBar.setTitle(handle ? handle : options.userId || this.userModel.get('guid'));
286288
},
287289

288290
userPageViaHandle: function(handle, subPath) {
@@ -324,6 +326,7 @@ module.exports = Backbone.Router.extend({
324326
state: state,
325327
orderID: orderID
326328
}),"userPage");
329+
app.appBar.setTitle(polyglot.t('Transactions'));
327330
},
328331

329332
settings: function(state){
@@ -335,5 +338,6 @@ module.exports = Backbone.Router.extend({
335338
state: state,
336339
socketView: this.socketView
337340
}), "userPage");
341+
app.appBar.setTitle(polyglot.t('Settings'));
338342
}
339343
});

js/start.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ var Polyglot = require('node-polyglot'),
3737
pageNavView = require('./views/pageNavVw'),
3838
ChatVw = require('./views/chatVw'),
3939
StatusBarView = require('./views/statusBarVw'),
40+
AppBarVw = require('./views/appBarVw'),
4041
user = new userModel(),
4142
userProfile = new userProfileModel(),
4243
languages = new languagesModel(),
4344
socketView = require('./views/socketVw'),
4445
cCode = "",
46+
$html = $('html'),
4547
$loadingModal = $('.js-loadingModal'),
4648
ServerConfigsCl = require('./collections/serverConfigsCl'),
4749
ServerConnectModal = require('./views/serverConnectModal'),
@@ -63,7 +65,22 @@ var Polyglot = require('node-polyglot'),
6365
pageConnectModal,
6466
launchOnboarding,
6567
setServerUrl,
66-
guidCreating;
68+
guidCreating,
69+
platformClass;
70+
// appBar;
71+
72+
if (process.platform === 'darwin') {
73+
platformClass = 'platform-mac';
74+
} else if (process.platform === 'win32') {
75+
platformClass = 'platform-win';
76+
} else {
77+
// http://stackoverflow.com/a/8684009
78+
// could be linux, sunos or freebsd
79+
platformClass = `platform-${process.platform}`
80+
}
81+
82+
// $html.addClass(platformClass);
83+
$html.addClass('platform-win');
6784

6885
//put language in the window so all templates and models can reach it. It's especially important in formatting currency.
6986
//retrieve the stored value, since user is a blank model at this point
@@ -89,6 +106,11 @@ user.on('change:language', function(md, lang) {
89106
window.translateIndex();
90107
});
91108

109+
// add in our app bar
110+
app.appBar = new AppBarVw({
111+
el: '#appBar'
112+
}).render();
113+
92114
window.addEventListener('contextmenu', (e) => {
93115
e.preventDefault();
94116
ipcRenderer.send('contextmenu-click', e);
@@ -231,7 +253,7 @@ $(window).bind('hashchange', function(){
231253

232254
//set fancy styles class
233255
if(localStorage.getItem('notFancy') == "true"){
234-
$('html').addClass('notFancy')
256+
$html.addClass('notFancy')
235257
}
236258

237259
//prevent dragging a file to the window from loading that file

js/templates/appBar.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="windowControls ctrlGroup">
2+
<a class="btn btn-win btn-winClose js-navClose tooltip <% ob.platform === 'darwin' && print('tooltip-left') %>" data-tooltip="<% print(polyglot.t(ob.launchedFromInstaller ? 'ClosingOpenBazaar' : 'ClosingOpenBazaarNonInstaller')) %>">
3+
<div class="btn-win-icon ion-ios-close-empty"></div>
4+
</a>
5+
<a class="btn btn-win btn-winMin js-navMin tooltip <% ob.platform === 'darwin' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Minimize') %>">
6+
<div class="btn-win-icon ion-ios-minus-empty"></div>
7+
</a>
8+
<a class="btn btn-win btn-winMax js-navMax tooltip <% ob.platform === 'darwin' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Maximize') %>">
9+
<div class="btn-win-icon ion-ios-plus-empty"></div>
10+
</a>
11+
</div>
12+
<div class="title"><%= ob.title %></div>

js/templates/pageNav.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,6 @@ <h3 class="margin0 marginTop25"><%= polyglot.t('Discover') %></h3>
148148
</div>
149149

150150
<div class="bar navBar pageNavContainer custCol-secondary">
151-
<div class="ctrlGroup">
152-
<a class="btn btn-win btn-winClose js-navClose tooltip" data-tooltip="<%= polyglot.t('ClosingOpenBazaar') %>">
153-
<div class="btn-win-icon ion-ios-close-empty"></div>
154-
</a>
155-
<a class="btn btn-win btn-winMin js-navMin tooltip" data-tooltip="<%= polyglot.t('Minimize') %>">
156-
<div class="btn-win-icon ion-ios-minus-empty"></div>
157-
</a>
158-
<a class="btn btn-win btn-winMax js-navMax tooltip" data-tooltip="<%= polyglot.t('Maximize') %>">
159-
<div class="btn-win-icon ion-ios-plus-empty"></div>
160-
</a>
161-
</div>
162151
<div class="ctrlGroup">
163152
<a class="btn btn-togLeft btn-back ion-chevron-left js-navBack custCol-primary custCol-text fontSize13 tooltip" data-tooltip="<%= polyglot.t('nav.Back') %>"></a>
164153
<a class="btn btn-togRight btn-fwd ion-chevron-right js-navFwd custCol-primary custCol-text fontSize13 tooltip" data-tooltip="<%= polyglot.t('nav.Forward') %>"></a>

js/utils/templateHelpers.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var app = require('../App').getApp(),
2-
moment = require('moment');
2+
moment = require('moment'),
3+
remote = require('electron').remote;
34

45
function cssImageUrl(hash, guid, fallback) {
56
var base = app.serverConfigs.getActive().getServerBaseUrl() + '/',
@@ -24,12 +25,9 @@ function cssImageUrl(hash, guid, fallback) {
2425
return url;
2526
}
2627

27-
function intlNumFormat(numberToFormat, maxDigits){
28-
return app.intlNumFormat(numberToFormat, maxDigits);
29-
}
30-
3128
module.exports = {
3229
cssImageUrl: cssImageUrl,
33-
intlNumFormat: intlNumFormat,
34-
moment: moment
30+
intlNumFormat: app.intlNumFormat,
31+
moment: moment,
32+
launchedFromInstaller: remote.getGlobal('launched_from_installer')
3533
};

js/views/appBarVw.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use strict';
2+
3+
var __ = require('underscore'),
4+
Backbone = require('backbone'),
5+
loadTemplate = require('../utils/loadTemplate'),
6+
remote = require('electron').remote,
7+
BaseVw = require('./baseVw');
8+
9+
module.exports = BaseVw.extend({
10+
titlePrefix: 'OpenBazaar',
11+
12+
events: {
13+
'click .js-navClose': 'navCloseClick',
14+
'click .js-navMin': 'navMinClick',
15+
'click .js-navMax': 'navMaxClick'
16+
},
17+
18+
initialize: function(options) {
19+
this.options = options || {};
20+
this.currentWindow = remote.getCurrentWindow();
21+
this.title = this.titlePrefix;
22+
},
23+
24+
navCloseClick: function() {
25+
if (remote.process.platform !== 'darwin') {
26+
this.currentWindow.close();
27+
} else {
28+
this.currentWindow.hide();
29+
}
30+
},
31+
32+
navMinClick: function() {
33+
this.currentWindow.minimize();
34+
},
35+
36+
navMaxClick: function() {
37+
if(this.currentWindow.isMaximized()) {
38+
this.currentWindow.unmaximize();
39+
this.$('.js-navMax').attr('data-tooltip', window.polyglot.t('Maximize'));
40+
} else {
41+
this.currentWindow.maximize();
42+
this.$('.js-navMax').attr('data-tooltip', window.polyglot.t('Restore'));
43+
}
44+
},
45+
46+
setTitle: function(text) {
47+
var curTitle = this.title;
48+
49+
if (!text) {
50+
this.title = this.titlePrefix;
51+
} else {}
52+
53+
this.title = text ?
54+
`${this.titlePrefix} &mdash; ${text}` :
55+
this.titlePrefix;
56+
57+
if (curTitle !== this.title) {
58+
this.render();
59+
}
60+
},
61+
62+
render: function() {
63+
loadTemplate('./js/templates/appBar.html', (t) => {
64+
this.$el.html(t({
65+
platform: remote.process.platform,
66+
title: this.title
67+
}));
68+
});
69+
70+
return this;
71+
}
72+
});

js/views/pageNavVw.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ var __ = require('underscore'),
1212
//adminPanelView = require('../views/adminPanelVw'),
1313
NotificationsVw = require('../views/notificationsVw'),
1414
PageNavServersVw = require('../views/pageNavServersVw'),
15-
remote = require('remote'),
1615
pjson = require('../../package.json');
1716

1817
var ipcRenderer = require('ipc-renderer'); // Allows to talk Electon main process
@@ -22,9 +21,6 @@ module.exports = baseVw.extend({
2221
el: '#pageNav',
2322

2423
events: {
25-
'click .js-navClose': 'navCloseClick',
26-
'click .js-navMin': 'navMinClick',
27-
'click .js-navMax': 'navMaxClick',
2824
'click .js-navBack': 'navBackClick',
2925
'click .js-navFwd': 'navFwdClick',
3026
'click .js-showAboutModal': 'showAboutModal',
@@ -64,8 +60,6 @@ module.exports = baseVw.extend({
6460
this.showDiscIntro = options.showDiscIntro;
6561
this.notificationsRecord = {}; //store notification timestamps to prevent too many from the same user
6662

67-
this.currentWindow = remote.getCurrentWindow();
68-
6963
this.listenTo(window.obEventBus, "updateProfile", function(response){
7064
this.refreshProfile();
7165
});
@@ -511,29 +505,6 @@ module.exports = baseVw.extend({
511505
this.serverSubmenu.removeClass('server-submenu-opened');
512506
},
513507

514-
navCloseClick: function(){
515-
var process = remote.process;
516-
if (process.platform != 'darwin') {
517-
this.currentWindow.close();
518-
} else {
519-
this.currentWindow.hide();
520-
}
521-
},
522-
523-
navMinClick: function(){
524-
this.currentWindow.minimize();
525-
},
526-
527-
navMaxClick: function(){
528-
if(this.currentWindow.isMaximized()){
529-
this.currentWindow.unmaximize();
530-
$('.js-navMax').attr('data-tooltip', window.polyglot.t('Maximize'));
531-
} else {
532-
this.currentWindow.maximize();
533-
$('.js-navMax').attr('data-tooltip', window.polyglot.t('Restore'));
534-
}
535-
},
536-
537508
navBackClick: function(){
538509
history.back();
539510
},

0 commit comments

Comments
 (0)