Skip to content

Commit

Permalink
Cleanup and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Atkins-Turkish committed Sep 2, 2016
1 parent 0330e60 commit e49039f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
7 changes: 1 addition & 6 deletions ide/static/ide/css/ide.css
Original file line number Diff line number Diff line change
Expand Up @@ -1137,16 +1137,12 @@ span.cm-autofilled-end {
}

.fuzzy-subheader {
/*background-color: #222;*/
font-weight: bold;
color: #555;
color: #666;
font-variant: small-caps;
margin-left: 1em;

}
.fuzzy-subheader::before {
/*content: '-- ';*/
}

.fuzzy-hint {
opacity: 0.5;
Expand All @@ -1159,7 +1155,6 @@ span.cm-autofilled-end {
}

#fuzzy-results > div {

line-height: 28px;
cursor: pointer;
cursor: hand;
Expand Down
21 changes: 3 additions & 18 deletions ide/static/ide/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ CloudPebble.Editor = (function() {
code_mirror.on('shown', function() {
is_autocompleting = true;
});
current_editor = code_mirror;

// The browser should probably do this without our help. Sometimes Safari doesn't.
$(document).click(function(e) {
Expand Down Expand Up @@ -486,6 +485,7 @@ CloudPebble.Editor = (function() {
CloudPebble.Sidebar.SetActivePane(pane, {
id: 'source-' + file.id,
onRestore: function() {
current_editor = code_mirror;
code_mirror.refresh();
_.defer(function() { code_mirror.focus(); });
check_safe();
Expand All @@ -496,6 +496,7 @@ CloudPebble.Editor = (function() {
fullscreen(code_mirror, false);
resume_fullscreen = true;
}
current_editor = null;
},
onDestroy: function() {
if(!was_clean) {
Expand Down Expand Up @@ -835,7 +836,7 @@ CloudPebble.Editor = (function() {
var codemirror_commands = [
{command: 'indentAuto', refocus: true},
{command: 'toggleComment', hint: 'Cmd-/ or Ctrl-/', refocus: true},
'find', 'replace', 'indentMore', 'indentLess'
'find', 'replace', 'indentMore', 'indentLess', 'save', 'saveAll'
];

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

// local_commands[gettext('Auto Indent')] = function() {
// current_editor.execCommand('indentAuto');
// current_editor.focus();
// };
// local_commands[gettext('Auto Indent')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('indentAuto');
// local_commands[gettext('Find')] = function() {
// current_editor.execCommand('find');
// };
// local_commands[gettext('Find')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('find');


CloudPebble.FuzzyPrompt.AddCommands(gettext('File'), local_commands, function() {
return (!!current_editor);
});

CloudPebble.GlobalShortcuts.SetShortcutHandlers({
save: function() {
save().catch(alert);
}
});

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

Expand Down
2 changes: 1 addition & 1 deletion ide/static/ide/js/fuzzyprompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CloudPebble.FuzzyPrompt = (function() {
var options = {
caseSensitive: false,
sortFn: function(a, b) {
return (a.score === b.score) ? a.item.name.localeCompare(b) : a.score - b.score;
return (a.score === b.score) ? a.item.name.localeCompare(b.item.name) : a.score - b.score;
},
shouldSort: true,
threshold: 0.5,
Expand Down
4 changes: 4 additions & 0 deletions ide/static/ide/js/global_shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ CloudPebble.GlobalShortcuts = (function () {
}
});
},
RemoveShortcutHandler: function(key) {
var shortcut = shortcut_for_command(key);
delete global_shortcuts[shortcut];
},
GetShortcuts: function() {
return global_shortcuts;
},
Expand Down
20 changes: 14 additions & 6 deletions ide/static/ide/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,26 @@ CloudPebble.Resources = (function() {
if(list_entry) {
list_entry.addClass('active');
}

function set_save_shortcut() {
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
"PlatformCmd-S": save
});
}
set_save_shortcut();
CloudPebble.Sidebar.SetActivePane(pane, {
id: 'resource-' + resource.id,
onRestore: _.partial(restore_pane, pane)
onRestore: function() {
restore_pane(pane);
set_save_shortcut();
},
onSuspend: function() {
CloudPebble.GlobalShortcuts.RemoveShortcutHandler("PlatformCmd-S");
}
});
pane.find('#edit-resource-type').val(resource.kind).attr('disabled', 'disabled');
pane.find('#edit-resource-type').change();

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

form.submit(save);
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
save: save
});

restore_pane(pane);
}).finally(function() {
Expand Down

0 comments on commit e49039f

Please sign in to comment.