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

Commit 7f78cd7

Browse files
committed
allowing app bar style to be configured via an option in settings
1 parent e340bb1 commit 7f78cd7

File tree

7 files changed

+81
-38
lines changed

7 files changed

+81
-38
lines changed

css/obBase.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ form {
218218
top: 6px;
219219
}
220220

221-
html:not(.platform-mac) #appBar .windowControls {
221+
#appBar.style-win .windowControls {
222222
left: auto;
223223
right: 8px;
224224
top: 5px;
@@ -2038,27 +2038,27 @@ margin: auto;
20382038
position: relative;
20392039
}
20402040

2041-
html:not(.platform-mac) .btn.btn-win {
2041+
#appBar.style-win .btn.btn-win {
20422042
background-color: transparent;
20432043
border-radius: 0;
20442044
width: 19px;
20452045
height: 19px;
20462046
box-shadow: none;
20472047
}
20482048

2049-
html:not(.platform-mac) .btn.btn-winClose {
2049+
#appBar.style-win .btn.btn-winClose {
20502050
float: right;
20512051
margin-left: 6px;
20522052
}
20532053

2054-
html:not(.platform-mac) .btn.btn-win .btn-win-icon {
2054+
#appBar.style-win .btn.btn-win .btn-win-icon {
20552055
display: block;
20562056
top: -3px;
20572057
font-size: 21px;
20582058
color: #fff;
20592059
}
20602060

2061-
html:not(.platform-mac) .btn.btn-winMax {
2061+
#appBar.style-win .btn.btn-winMax {
20622062
float: right;
20632063
margin-left: 6px;
20642064
border: 1px solid #fff;
@@ -2067,8 +2067,8 @@ html:not(.platform-mac) .btn.btn-winMax {
20672067
top: 3px;
20682068
}
20692069

2070-
html:not(.platform-mac) .btn.btn-winMax .btn-win-icon,
2071-
html:not(.platform-mac) .btn.btn-win.btn-winMax:hover .btn-win-icon {
2070+
#appBar.style-win .btn.btn-winMax .btn-win-icon,
2071+
#appBar.style-win .btn.btn-win.btn-winMax:hover .btn-win-icon {
20722072
display: none;
20732073
}
20742074

js/languages/en-US.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@
346346
"Avatar": "Avatar",
347347
"AdditionalPaymentData": "Additional payment data",
348348
"AdditionalPaymentDataInfo": "Include name of purchase and order number in payment QR code?",
349+
"AppBarStyle": "Application Top Bar Style",
350+
"AppBarStyleInfo": "How should the top bar of the application be styled?",
351+
"OSWindows": "Windows",
352+
"OSMac": "Mac",
349353
"ShippableHelp": "This product can be shipped to one of your currently saved addresses. Add more addresses in the Settings/Addresses section to be able to purchase more listings.",
350354
"firewall": {
351355
"Open": "Open",

js/start.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var Polyglot = require('node-polyglot'),
4343
languages = new languagesModel(),
4444
socketView = require('./views/socketVw'),
4545
cCode = "",
46-
$html = $('html'),
4746
$loadingModal = $('.js-loadingModal'),
4847
ServerConfigsCl = require('./collections/serverConfigsCl'),
4948
ServerConnectModal = require('./views/serverConnectModal'),
@@ -65,20 +64,7 @@ var Polyglot = require('node-polyglot'),
6564
pageConnectModal,
6665
launchOnboarding,
6766
setServerUrl,
68-
guidCreating,
69-
platformClass;
70-
71-
if (process.platform === 'darwin') {
72-
platformClass = 'platform-mac';
73-
} else if (process.platform === 'win32') {
74-
platformClass = 'platform-win';
75-
} else {
76-
// http://stackoverflow.com/a/8684009
77-
// could be linux, sunos or freebsd
78-
platformClass = `platform-${process.platform}`
79-
}
80-
81-
$html.addClass(platformClass);
67+
guidCreating;
8268

8369
//put language in the window so all templates and models can reach it. It's especially important in formatting currency.
8470
//retrieve the stored value, since user is a blank model at this point
@@ -251,7 +237,7 @@ $(window).bind('hashchange', function(){
251237

252238
//set fancy styles class
253239
if(localStorage.getItem('notFancy') == "true"){
254-
$html.addClass('notFancy')
240+
$('html').addClass('notFancy')
255241
}
256242

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

js/templates/appBar.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<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')) %>">
2+
<a class="btn btn-win btn-winClose js-navClose tooltip <% ob.style !== 'mac' && print('tooltip-left') %>" data-tooltip="<% print(polyglot.t(ob.launchedFromInstaller ? 'ClosingOpenBazaar' : 'ClosingOpenBazaarNonInstaller')) %>">
33
<div class="btn-win-icon ion-ios-close-empty"></div>
44
</a>
5-
<a class="btn btn-win btn-winMin js-navMin tooltip <% ob.platform !== 'darwin' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Minimize') %>">
5+
<a class="btn btn-win btn-winMin js-navMin tooltip <% ob.style !== 'mac' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Minimize') %>">
66
<div class="btn-win-icon ion-ios-minus-empty"></div>
77
</a>
8-
<a class="btn btn-win btn-winMax js-navMax tooltip <% ob.platform !== 'darwin' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Maximize') %>">
8+
<a class="btn btn-win btn-winMax js-navMax tooltip <% ob.style !== 'mac' && print('tooltip-left') %>" data-tooltip="<%= polyglot.t('Maximize') %>">
99
<div class="btn-win-icon ion-ios-plus-empty"></div>
1010
</a>
1111
</div>

js/templates/settings.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,26 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Advanced') %></h3>
12391239
</div>
12401240
</div>
12411241

1242+
<div class="flexRow">
1243+
<div class="flexCol-3 borderRight custCol-border">
1244+
<div class="fieldItem">
1245+
<label>
1246+
<%= polyglot.t('AppBarStyle') %>
1247+
</label>
1248+
<i class="ion-help-circled tooltip tooltip-box" data-tooltip="<%= polyglot.t('AppBarStyleInfo') %>"></i>
1249+
</div>
1250+
</div>
1251+
1252+
<div class="flexCol-9 borderRight0 custCol-border">
1253+
<div class="fieldItem">
1254+
<input type="radio" class="fieldItem" id="app_bar_style_windows" name="appBarStyle" value="win" checked />
1255+
<label for="app_bar_style_windows" class="radioLabel"><%= polyglot.t('OSWindows') %></label>
1256+
<input type="radio" class="fieldItem" id="app_bar_style_mac" name="appBarStyle" value="mac" />
1257+
<label for="app_bar_style_mac" class="radioLabel"><%= polyglot.t('OSMac') %></label>
1258+
</div>
1259+
</div>
1260+
</div>
1261+
12421262
<div class="flexRow">
12431263

12441264
<div class="flexCol-3 borderRight custCol-border">

js/views/appBarVw.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,32 @@ module.exports = BaseVw.extend({
1616
},
1717

1818
initialize: function(options) {
19+
var style = localStorage.appBarStyle;
20+
1921
this.options = options || {};
2022
this.currentWindow = remote.getCurrentWindow();
2123
this.title = this.titlePrefix;
24+
25+
if (!style || ['mac', 'win'].indexOf(style) === -1) {
26+
style = remote.process.platform === 'win32' ? 'win' : 'mac';
27+
}
28+
29+
this.setStyle(style);
30+
},
31+
32+
setStyle: function(style) {
33+
if (!style || ['mac', 'win'].indexOf(style) === -1) {
34+
throw new Error(`Please provide a style ('mac' or 'win')`);
35+
}
36+
37+
this.$el.removeClass('style-mac style-win');
38+
this.$el.addClass(`style-${style}`);
39+
localStorage.appBarStyle = style;
40+
this.render();
41+
},
42+
43+
getStyle: function() {
44+
return localStorage.appBarStyle;
2245
},
2346

2447
navCloseClick: function() {
@@ -62,7 +85,7 @@ module.exports = BaseVw.extend({
6285
render: function() {
6386
loadTemplate('./js/templates/appBar.html', (t) => {
6487
this.$el.html(t({
65-
platform: remote.process.platform,
88+
style: this.getStyle(),
6689
title: this.title
6790
}));
6891
});

js/views/settingsVw.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = Backbone.View.extend({
5656
'keyup #moderatorFeeInput': 'keypressFeeInput',
5757
'click #advancedForm input[name="notFancy"]': 'toggleFancyStyles',
5858
'click #advancedForm input[name="useTestnet"]': 'toggleTestnet',
59+
'change #advancedForm input[name="appBarStyle"]': 'changeAppBarStyle',
5960
'blur input': 'validateInput',
6061
'blur textarea': 'validateInput',
6162
'change #handle': 'handleChange',
@@ -385,6 +386,8 @@ module.exports = Backbone.View.extend({
385386
currency = this.$('#currency_code'),
386387
timezone = this.$('#time_zone'),
387388
language = this.$('#language'),
389+
generalForm = this.$('#generalForm'),
390+
advancedForm = this.$('#advancedForm'),
388391
user = this.model.get('user'),
389392
avatar = user.avatar_hash,
390393
ship_country_str = "",
@@ -400,13 +403,15 @@ module.exports = Backbone.View.extend({
400403

401404
smtp_notifications = (user.smtp_notifications == 1) ? true : false;
402405

403-
this.$('#pageForm input[name=nsfw]').val([String(pageNSFW)]);
404-
this.$("#generalForm input[name=nsfw][value=" + localStorage.getItem('NSFWFilter') + "]").prop('checked', true);
405-
this.$("#generalForm input[name=notifications][value=" + notifications + "]").prop('checked', true);
406-
this.$("#storeForm input[name=vendor][value=" + vendorStatus + "]").prop('checked', true);
407-
this.$("#advancedForm input[name=notFancy][value=" + fancyStatus + "]").prop('checked', true);
408-
this.$("#advancedForm input[name=additionalPaymentData][value=" + localStorage.getItem('AdditionalPaymentData') + "]").prop('checked', true);
409-
this.$("#advancedForm input[name=smtp_notifications][value=" + smtp_notifications + "]").prop('checked', true);
406+
this.$("#pageForm").find("input[name=nsfw]").val([String(pageNSFW)]);
407+
generalForm.find("input[name=nsfw][value=" + localStorage.getItem('NSFWFilter') + "]").prop('checked', true);
408+
generalForm.find("input[name=notifications][value=" + notifications + "]").prop('checked', true);
409+
this.$("#storeForm").find("input[name=vendor][value=" + vendorStatus + "]").prop('checked', true);
410+
advancedForm.find("input[name=notFancy][value=" + fancyStatus + "]").prop('checked', true);
411+
advancedForm.find("input[name=additionalPaymentData][value=" + localStorage.getItem('AdditionalPaymentData') + "]").prop('checked', true);
412+
advancedForm.find("input[name=smtp_notifications][value=" + smtp_notifications + "]").prop('checked', true);
413+
advancedForm.find("input[name=smtp_notifications][value=" + smtp_notifications + "]").prop('checked', true);
414+
advancedForm.find("input[name=appBarStyle][value=" + app.appBar.getStyle() + "]").prop('checked', true);
410415

411416
currencyList = __.uniq(currencyList, function(item){return item.code;});
412417
currencyList = currencyList.sort(function(a,b){
@@ -462,8 +467,7 @@ module.exports = Backbone.View.extend({
462467

463468
//set moderator status
464469
this.$('#moderatorForm').find('input[name=moderator]').val([String(moderatorStatus)]);
465-
466-
this.$('#advancedForm').find('input[name=smtp_mo]').val([String(moderatorStatus)]);
470+
advancedForm.find('input[name=smtp_mo]').val([String(moderatorStatus)]);
467471
},
468472

469473
showModeratorFeeHolder: function(){
@@ -1089,11 +1093,13 @@ module.exports = Backbone.View.extend({
10891093
},
10901094

10911095
toggleFancyStyles: function(){
1096+
var $html = $('html');
1097+
10921098
if($('#advancedForm').find('input[name="notFancy"]').prop('checked')){
1093-
$('html').addClass('notFancy');
1099+
$html.addClass('notFancy');
10941100
localStorage.setItem('notFancy', "true");
10951101
} else {
1096-
$('html').removeClass('notFancy');
1102+
$html.removeClass('notFancy');
10971103
localStorage.setItem('notFancy', "false");
10981104
}
10991105
},
@@ -1103,6 +1109,10 @@ module.exports = Backbone.View.extend({
11031109
window.location.reload();
11041110
},
11051111

1112+
changeAppBarStyle: function(e) {
1113+
app.appBar.setStyle($(e.target).val());
1114+
},
1115+
11061116
close: function(){
11071117
"use strict";
11081118
__.each(this.subModels, function(subModel) {

0 commit comments

Comments
 (0)