{"size": 1347, "ext": "js", "max_stars_repo_path": "lib/xztranslate.js", "max_stars_repo_name": "igorvr/xztranslate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/xztranslate.js", "max_issues_repo_name": "igorvr/xztranslate", "max_issues_repo_issues_event_min_datetime": "2017-04-25T17:49:39.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-25T18:56:54.000Z", "max_forks_repo_path": "lib/xztranslate.js", "max_forks_repo_name": "igorvr/xztranslate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 24.0535714286, "max_line_length": 107, "alphanum_fraction": 0.6681514477}
'use babel';

import XztranslateView from './xztranslate-view';
import { CompositeDisposable } from 'atom';

export default {

  xztranslateView: null,
  modalPanel: null,
  subscriptions: null,

  activate(state) {
    this.xztranslateView = new XztranslateView(state.xztranslateViewState);
    this.modalPanel = atom.workspace.addModalPanel({
      item: this.xztranslateView.getElement(),
      visible: false
    });

    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    this.subscriptions = new CompositeDisposable();

    // Register command that toggles this view
    this.subscriptions.add(atom.commands.add('atom-workspace', {
      'xztranslate:toggle': () => this.toggle()
    }));
  },

  deactivate() {
    this.modalPanel.destroy();
    this.subscriptions.dispose();
    this.xztranslateView.destroy();
  },

  serialize() {
    return {
      xztranslateViewState: this.xztranslateView.serialize()
    };
  },

  toggle() {
    console.log('Xztranslate was toggled!');
    let editor
  if (editor = atom.workspace.getActiveTextEditor()) {
    let selection = editor.getText()
    let sorted = selection.replace(/x|z/gi,function(match){return(match == 'x' | match == 'X')?  'Z':'X';})
    editor.setText(sorted)
//    this.modalPanel.show()
  //  editor.setText(sorted)

  }


  }

};
