Skip to content

Instantly share code, notes, and snippets.

@ADTC
Created September 25, 2017 15:27
Show Gist options
  • Save ADTC/f1816435b039d03bdbb4005d5fad1701 to your computer and use it in GitHub Desktop.
Save ADTC/f1816435b039d03bdbb4005d5fad1701 to your computer and use it in GitHub Desktop.
Adding a Save button in Atom Status Bar
Install the 'reload-button' package.
Open it and click View Code.
Open the reload-button-view.js file and update the code.
Save file and relaunch Atom.
Note: There is no save icon in Octicons, so I settled for another one.
Diff is included for the curious.
--- reload-button package
+++ modified to Save file
@@ -1,13 +1,15 @@
'use babel';
export default class ReloadButtonView {
constructor(statusBar) {
this.element = document.createElement('a');
- this.element.classList.add('icon', 'icon-sync');
+ this.element.classList.add('icon', 'icon-checklist');
+ this.element.title = "Save file in active editor";
+ atom.tooltips.add(this.element, "");
this.element.addEventListener('click', this.onClick);
this.statusBarTile = statusBar.addRightTile({ item: this.element, priority: 1000 });
}
@@ -21,10 +23,10 @@
this.element = null;
}
onClick(e) {
e.preventDefault();
e.stopPropagation();
- atom.commands.dispatch(atom.views.getView(atom.workspace), 'window:reload');
+ atom.commands.dispatch(atom.views.getView(atom.workspace.getActiveTextEditor()), 'core:save');
}
}
'use babel';
export default class ReloadButtonView {
constructor(statusBar) {
this.element = document.createElement('a');
this.element.classList.add('icon', 'icon-checklist');
this.element.title = "Save file in active editor";
atom.tooltips.add(this.element, "");
this.element.addEventListener('click', this.onClick);
this.statusBarTile = statusBar.addRightTile({ item: this.element, priority: 1000 });
}
destroy() {
this.statusBarTile.destroy();
this.statusBarTile = null;
this.element.removeEventListener('click', this.onClick);
this.element.remove();
this.element = null;
}
onClick(e) {
e.preventDefault();
e.stopPropagation();
atom.commands.dispatch(atom.views.getView(atom.workspace.getActiveTextEditor()), 'core:save');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment