Skip to content

Commit e49039f

Browse files
author
Joseph Atkins-Turkish
committed
Cleanup and fixes
1 parent 0330e60 commit e49039f

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

ide/static/ide/css/ide.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,16 +1137,12 @@ span.cm-autofilled-end {
11371137
}
11381138

11391139
.fuzzy-subheader {
1140-
/*background-color: #222;*/
11411140
font-weight: bold;
1142-
color: #555;
1141+
color: #666;
11431142
font-variant: small-caps;
11441143
margin-left: 1em;
11451144

11461145
}
1147-
.fuzzy-subheader::before {
1148-
/*content: '-- ';*/
1149-
}
11501146

11511147
.fuzzy-hint {
11521148
opacity: 0.5;
@@ -1159,7 +1155,6 @@ span.cm-autofilled-end {
11591155
}
11601156

11611157
#fuzzy-results > div {
1162-
11631158
line-height: 28px;
11641159
cursor: pointer;
11651160
cursor: hand;

ide/static/ide/js/editor.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ CloudPebble.Editor = (function() {
240240
code_mirror.on('shown', function() {
241241
is_autocompleting = true;
242242
});
243-
current_editor = code_mirror;
244243

245244
// The browser should probably do this without our help. Sometimes Safari doesn't.
246245
$(document).click(function(e) {
@@ -486,6 +485,7 @@ CloudPebble.Editor = (function() {
486485
CloudPebble.Sidebar.SetActivePane(pane, {
487486
id: 'source-' + file.id,
488487
onRestore: function() {
488+
current_editor = code_mirror;
489489
code_mirror.refresh();
490490
_.defer(function() { code_mirror.focus(); });
491491
check_safe();
@@ -496,6 +496,7 @@ CloudPebble.Editor = (function() {
496496
fullscreen(code_mirror, false);
497497
resume_fullscreen = true;
498498
}
499+
current_editor = null;
499500
},
500501
onDestroy: function() {
501502
if(!was_clean) {
@@ -835,7 +836,7 @@ CloudPebble.Editor = (function() {
835836
var codemirror_commands = [
836837
{command: 'indentAuto', refocus: true},
837838
{command: 'toggleComment', hint: 'Cmd-/ or Ctrl-/', refocus: true},
838-
'find', 'replace', 'indentMore', 'indentLess'
839+
'find', 'replace', 'indentMore', 'indentLess', 'save', 'saveAll'
839840
];
840841

841842
_.each(codemirror_commands, function(entry) {
@@ -848,26 +849,10 @@ CloudPebble.Editor = (function() {
848849
local_commands[name].hint = !!entry.hint ? entry.hint : CloudPebble.GlobalShortcuts.GetShortcutForCommand(command);
849850
});
850851

851-
// local_commands[gettext('Auto Indent')] = function() {
852-
// current_editor.execCommand('indentAuto');
853-
// current_editor.focus();
854-
// };
855-
// local_commands[gettext('Auto Indent')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('indentAuto');
856-
// local_commands[gettext('Find')] = function() {
857-
// current_editor.execCommand('find');
858-
// };
859-
// local_commands[gettext('Find')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('find');
860-
861-
862852
CloudPebble.FuzzyPrompt.AddCommands(gettext('File'), local_commands, function() {
863853
return (!!current_editor);
864854
});
865855

866-
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
867-
save: function() {
868-
save().catch(alert);
869-
}
870-
});
871856

872857
CloudPebble.FuzzyPrompt.AddCommands(gettext('Actions'), global_commands);
873858

ide/static/ide/js/fuzzyprompt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CloudPebble.FuzzyPrompt = (function() {
3333
var options = {
3434
caseSensitive: false,
3535
sortFn: function(a, b) {
36-
return (a.score === b.score) ? a.item.name.localeCompare(b) : a.score - b.score;
36+
return (a.score === b.score) ? a.item.name.localeCompare(b.item.name) : a.score - b.score;
3737
},
3838
shouldSort: true,
3939
threshold: 0.5,

ide/static/ide/js/global_shortcuts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ CloudPebble.GlobalShortcuts = (function () {
6262
}
6363
});
6464
},
65+
RemoveShortcutHandler: function(key) {
66+
var shortcut = shortcut_for_command(key);
67+
delete global_shortcuts[shortcut];
68+
},
6569
GetShortcuts: function() {
6670
return global_shortcuts;
6771
},

ide/static/ide/js/resources.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,26 @@ CloudPebble.Resources = (function() {
470470
if(list_entry) {
471471
list_entry.addClass('active');
472472
}
473-
473+
function set_save_shortcut() {
474+
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
475+
"PlatformCmd-S": save
476+
});
477+
}
478+
set_save_shortcut();
474479
CloudPebble.Sidebar.SetActivePane(pane, {
475480
id: 'resource-' + resource.id,
476-
onRestore: _.partial(restore_pane, pane)
481+
onRestore: function() {
482+
restore_pane(pane);
483+
set_save_shortcut();
484+
},
485+
onSuspend: function() {
486+
CloudPebble.GlobalShortcuts.RemoveShortcutHandler("PlatformCmd-S");
487+
}
477488
});
478489
pane.find('#edit-resource-type').val(resource.kind).attr('disabled', 'disabled');
479490
pane.find('#edit-resource-type').change();
480491

481-
var save = function(e) {
492+
function save(e) {
482493
if (e) e.preventDefault();
483494
process_resource_form(form, false, resource.file_name, "/ide/project/" + PROJECT_ID + "/resource/" + resource.id + "/update").then(function(data) {
484495
delete project_resources[resource.file_name];
@@ -764,9 +775,6 @@ CloudPebble.Resources = (function() {
764775
}).init();
765776

766777
form.submit(save);
767-
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
768-
save: save
769-
});
770778

771779
restore_pane(pane);
772780
}).finally(function() {

0 commit comments

Comments
 (0)