|
@@ -1,57 +1,31 @@
|
|
|
'use babel';
|
|
|
|
|
|
-import OrderthingsView from './orderthings-view';
|
|
|
import { CompositeDisposable } from 'atom';
|
|
|
|
|
|
export default {
|
|
|
|
|
|
- orderthingsView: null,
|
|
|
- modalPanel: null,
|
|
|
subscriptions: null,
|
|
|
|
|
|
- activate(state) {
|
|
|
- this.orderthingsView = new OrderthingsView(state.orderthingsViewState);
|
|
|
- this.modalPanel = atom.workspace.addModalPanel({
|
|
|
- item: this.orderthingsView.getElement(),
|
|
|
- visible: false
|
|
|
- });
|
|
|
-
|
|
|
+ activate() {
|
|
|
|
|
|
this.subscriptions = new CompositeDisposable();
|
|
|
|
|
|
|
|
|
this.subscriptions.add(atom.commands.add('atom-workspace', {
|
|
|
- 'orderthings:toggle': () => this.toggle()
|
|
|
+ 'orderthings:fetch': () => this.fetch()
|
|
|
}));
|
|
|
},
|
|
|
|
|
|
deactivate() {
|
|
|
- this.modalPanel.destroy();
|
|
|
this.subscriptions.dispose();
|
|
|
- this.orderthingsView.destroy();
|
|
|
- },
|
|
|
-
|
|
|
- serialize() {
|
|
|
- return {
|
|
|
- orderthingsViewState: this.orderthingsView.serialize()
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- toggle1() {
|
|
|
- console.log('Orderthings was toggled!');
|
|
|
- return (
|
|
|
- this.modalPanel.isVisible()
|
|
|
- ? this.modalPanel.hide()
|
|
|
- : this.modalPanel.show()
|
|
|
- );
|
|
|
},
|
|
|
|
|
|
- toggle() {
|
|
|
+ fetch() {
|
|
|
let editor;
|
|
|
if (editor = atom.workspace.getActiveTextEditor()) {
|
|
|
let selection = editor.getSelectedText();
|
|
|
- let reversed = selection.split('').reverse().join('');
|
|
|
- editor.insertText(reversed);
|
|
|
+ selection = selection.split('').reverse().join('');
|
|
|
+ editor.insertText(selection);
|
|
|
}
|
|
|
}
|
|
|
};
|