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

Commit 7d6d413

Browse files
committed
Add Save shortcut key for forms.
1 parent a44e166 commit 7d6d413

File tree

11 files changed

+166
-67
lines changed

11 files changed

+166
-67
lines changed

js/config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ module.exports = {
1010

1111
bitcoinValidationRegex: bitcoinValidationRegex,
1212

13+
keyShortcutPrefix: window.navigator.platform === 'MacIntel' ? '⌘' : 'Ctrl+',
14+
1315
keyShortcuts: {
16+
undo: 'z',
1417
discover: 'd',
1518
myPage: 'h',
1619
customizePage: 'e',
@@ -19,7 +22,8 @@ module.exports = {
1922
sales: 'y',
2023
cases: 'j',
2124
settings: 'g',
22-
addressBar: 'l'
25+
addressBar: 'l',
26+
save: 's'
2327
},
2428

2529
setTestnet: function(testNetBoolean){

js/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ $(window).bind('keydown', function(e) {
196196

197197
if (ctrl) {
198198
switch (char) {
199-
case 'z':
199+
case config.keyShortcuts.undo:
200200
//run undo programmatically to avoid crash
201201
e.preventDefault();
202202
document.execCommand('undo');
@@ -229,11 +229,14 @@ $(window).bind('keydown', function(e) {
229229
// Select all text in address bar
230230
$('.js-navAddressBar').select();
231231
break;
232+
case config.keyShortcuts.save:
233+
window.obEventBus.trigger('saveCurrentForm');
234+
break;
232235
}
233236

234237
if (route !== null) {
235238
e.preventDefault();
236-
Backbone.history.navigate(route, {
239+
Backbone.history.navigate(route, {
237240
trigger: true
238241
});
239242
}

js/templates/itemEdit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ <h5><%= polyglot.t('Expiration') %> (<%= polyglot.t('Optional') %>)</h5>
413413
<div class="ctrlGroup js-itemEditButtons floatRight">
414414
<a class="btn btn-large custCol-secondary js-saveItem">
415415
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
416-
<%= polyglot.t('SaveChanges') %>
416+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
417417
</a>
418418
</div>
419419
<div class="ctrlGroup js-itemEditButtons textOpacity1 floatRight marginRight5">

js/templates/pageNav.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ <h3 class="margin0 marginTop25"><%= polyglot.t('Discover') %></h3>
7070
<a href="#userPage">
7171
<span class="ion-document-text fontSize12 marginRight2 textOpacity1"></span>
7272
<%= polyglot.t('nav.myPage') %>
73-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.myPage.toUpperCase() %></span>
73+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.myPage.toUpperCase() %></span>
7474
</a>
7575
<a href="#userPage/<%= ob.guid %>/customize">
7676
<span class="ion-paintbucket fontSize10 textOpacity1"></span>
7777
<%= polyglot.t('nav.customizePage') %>
78-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.customizePage.toUpperCase() %></span>
78+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.customizePage.toUpperCase() %></span>
7979
</a>
8080
<% if(ob.vendor) { %>
8181
<a href="#userPage/<%= ob.guid %>/listingNew" >
8282
<span class="ion-ios-pricetag fontSize10 marginRight2 textOpacity1"></span>
8383
<%= polyglot.t('nav.createListing') %>
84-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.create.toUpperCase() %></span>
84+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.create.toUpperCase() %></span>
8585
</a>
8686
<% }else{ %>
8787
<a href="#userPage/<%= ob.guid %>/createStore">
@@ -101,27 +101,27 @@ <h3 class="margin0 marginTop25"><%= polyglot.t('Discover') %></h3>
101101
<a href="#transactions/purchases">
102102
<span class="ion-log-out fontSize11 marginRight2 textOpacity1"></span>
103103
<%= polyglot.t('nav.purchases') %>
104-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.purchases.toUpperCase() %></span>
104+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.purchases.toUpperCase() %></span>
105105
</a>
106106
<% if(ob.vendor) { %>
107107
<a href="#transactions/sales">
108108
<span class="ion-log-in fontSize11 marginRight2 textOpacity1"></span>
109109
<%= polyglot.t('nav.sales') %>
110-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.sales.toUpperCase() %></span>
110+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.sales.toUpperCase() %></span>
111111
</a>
112112
<% } %>
113113
<% if(ob.moderator) { %>
114114
<a href="#transactions/cases">
115115
<span class="ion-briefcase fontSize11 marginRight2 textOpacity1"></span>
116116
<%= polyglot.t('nav.cases') %>
117-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.cases.toUpperCase() %></span>
117+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.cases.toUpperCase() %></span>
118118
</a>
119119
<% } %>
120120
<hr/>
121121
<a href="#settings">
122122
<span class="ion-toggle-filled fontSize11 marginRight2 textOpacity1"></span>
123123
<%= polyglot.t('nav.settings') %>
124-
<span class="pull-right txt-muted"><%= ob.ctrlCmdKey + config.keyShortcuts.settings.toUpperCase() %></span>
124+
<span class="pull-right txt-muted"><%= config.keyShortcutPrefix + config.keyShortcuts.settings.toUpperCase() %></span>
125125
</a>
126126
<hr/>
127127
<a class="js-showAboutModal">
@@ -172,7 +172,7 @@ <h3 class="margin0 marginTop25"><%= polyglot.t('Discover') %></h3>
172172
</div>
173173
</div>
174174
<div class="ctrlGroup">
175-
<a class="btn btn-home ion-eye custCol-primary custCol-text fontSize15 tooltip" href="#home" data-tooltip="<%= polyglot.t('Discover') %> (<%= ob.ctrlCmdKey + config.keyShortcuts.discover.toUpperCase() %>)"></a>
175+
<a class="btn btn-home ion-eye custCol-primary custCol-text fontSize15 tooltip" href="#home" data-tooltip="<%= polyglot.t('Discover') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.discover.toUpperCase() %>)"></a>
176176
</div>
177177
<div class="ctrlGroup">
178178
<div class="btn btn-notifications ion-android-notifications custCol-primary custCol-text fontSize14 js-navNotifications tooltip" data-tooltip="<%= polyglot.t('nav.notifications') %>" data-popmenu=".popMenu-notifications">

js/templates/settings.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('General') %></h3>
179179

180180
<a class="btn btn-large js-saveGeneral custCol-secondary pull-right marginRight15 marginTop15 marginBottom50 btn-secondary">
181181
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
182-
<%= polyglot.t('SaveChanges') %>
182+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
183183
</a>
184184
<a class="btn btn-large js-cancelGeneral custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
185185

@@ -676,7 +676,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Theme') %></h3>
676676

677677
<a class="btn btn-large js-savePage custCol-secondary pull-right marginRight15 marginTop15 marginBottom50 btn-secondary">
678678
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
679-
<%= polyglot.t('SaveChanges') %>
679+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
680680
</a>
681681
<a class="btn btn-large js-cancelPage custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
682682

@@ -813,7 +813,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Content') %></h3>
813813

814814
<a class="btn btn-large js-saveStore custCol-secondary pull-right marginRight15 marginTop15 marginBottom5 btn-secondary">
815815
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
816-
<%= polyglot.t('SaveChanges') %>
816+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
817817
</a>
818818
<a class="btn btn-large js-cancelStore custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
819819
</div>
@@ -982,7 +982,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('NewAddress') %></h3>
982982

983983
<a class="btn btn-large js-saveAddress custCol-secondary pull-right marginRight15 marginTop15 marginBottom50 btn-secondary">
984984
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
985-
<%= polyglot.t('SaveChanges') %>
985+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
986986
</a>
987987
<a class="btn btn-large js-cancelAddress custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
988988
</div>
@@ -1043,7 +1043,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('moderatorSettings.Di
10431043
</div>
10441044
<a class="btn btn-large js-saveModerator custCol-secondary pull-right marginRight15 marginTop15 marginBottom50 btn-secondary">
10451045
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
1046-
<%= polyglot.t('SaveChanges') %>
1046+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
10471047
</a>
10481048
<a class="btn btn-large js-cancelModerator custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
10491049
</div>
@@ -1227,7 +1227,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Advanced') %></h3>
12271227

12281228
<a class="btn btn-large js-saveAdvanced custCol-secondary pull-right marginRight15 marginTop15 marginBottom50 btn-secondary">
12291229
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
1230-
<%= polyglot.t('SaveChanges') %>
1230+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
12311231
</a>
12321232
<a class="btn btn-large js-cancelAdvanced custCol-secondary pull-right marginRight5 marginTop15 marginBottom50 btn-secondary width87px"><%= polyglot.t('Reset') %></a>
12331233
</div>

js/templates/userPage.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="ctrlGroup js-pageCustomizationButtons js-userPageControls hide">
2727
<a class="btn btn-txt custCol-primary js-saveCustomization">
2828
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
29-
<%= polyglot.t('SaveChanges') %>
29+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
3030
</a>
3131
</div>
3232
</div>
@@ -203,13 +203,13 @@ <h1 class="page-userNameLarge floatLeft fancy-heading fontSize20 colorWhiteForce
203203
<div class="ctrlGroup hide js-itemEditButtons js-userPageControls hide">
204204
<a class="btn btn-txt custCol-primary js-saveItem">
205205
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
206-
<%= polyglot.t('SaveChanges') %>
206+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
207207
</a>
208208
</div>
209209
<div class="ctrlGroup hide js-itemCustomizationButtons js-userPageControls hide">
210210
<a class="btn btn-txt custCol-primary js-saveCustomization">
211211
<span class="ion-checkmark fontSize11 marginRight2 textOpacity1"></span>
212-
<%= polyglot.t('SaveChanges') %>
212+
<%= polyglot.t('SaveChanges') %> (<%= config.keyShortcutPrefix + config.keyShortcuts.save.toUpperCase() %>)
213213
</a>
214214
</div>
215215
</div>

js/views/itemEditVw.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module.exports = baseVw.extend({
8989

9090
render: function(){
9191
var self = this;
92+
9293
loadTemplate('./js/templates/itemEdit.html', function(loadedTemplate) {
9394
var context = __.extend({}, self.model.toJSON(), { MAX_PHOTOS: self.MAX_PHOTOS });
9495

js/views/itemVw.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = baseVw.extend({
8585
"use strict";
8686
var imageExtension = self.model.get('imageExtension') || "";
8787
});
88+
8889
//el must be passed in from the parent view
8990
loadTemplate('./js/templates/item.html', function(loadedTemplate) {
9091
loadTemplate('./js/templates/ratingStars.html', function(starsTemplate) {

js/views/pageNavVw.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ module.exports = baseVw.extend({
248248
//load userProfile data into model
249249
this.model.set('guid', this.userProfile.get('profile').guid);
250250
this.model.set('avatar_hash', this.userProfile.get('profile').avatar_hash);
251-
this.model.set('ctrlCmdKey', window.navigator.platform === 'MacIntel' ? '&#8984;' : 'Ctrl+');
252251
this.model.set('version', pjson.version);
253252
loadTemplate('./js/templates/pageNav.html', function(loadedTemplate) {
254253
self.$el.html(loadedTemplate(self.model.toJSON()));

0 commit comments

Comments
 (0)