From df14c2ce34566648ff967b941606dda427bb34b8 Mon Sep 17 00:00:00 2001 From: "Nicolab.net" Date: Fri, 5 Jun 2015 11:23:56 +0200 Subject: [PATCH] Atom@v1 API, fix #29 --- lib/local-history-view.js | 22 ++++++++++++++++------ package.json | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/local-history-view.js b/lib/local-history-view.js index e4674c4..e572cca 100644 --- a/lib/local-history-view.js +++ b/lib/local-history-view.js @@ -6,8 +6,7 @@ */ var helpers = require('atom-helpers'); -var _atom = require('atom'); -var SelectListView = _atom.SelectListView; +var SelectListView = require('atom-space-pen-views').SelectListView; var exec = require("child_process").exec; var path = require('path'); var fsPlus = require('fs-plus'); @@ -40,6 +39,14 @@ LocalHistoryView.prototype.destroy = function() { return LocalHistoryView.__super__.detach.apply(this, arguments); }; +LocalHistoryView.prototype.cancelled = function() { + this.hide(); +}; + +LocalHistoryView.prototype.hide = function() { + this.modalPanel.hide(); +}; + LocalHistoryView.prototype.viewForItem = function(item) { var ext = path.extname(item); var typeClass = 'icon-file-text'; @@ -101,8 +108,9 @@ LocalHistoryView.prototype.confirmed = function(item) { }; LocalHistoryView.prototype.findLocalHistory = function() { - var currentFilePath, needRevList; + var currentFilePath, needRevList, workspaceView; + workspaceView = atom.views.getView(atom.workspace); currentFilePath = helpers.editor.getCurrentFilePath(); needRevList = [ @@ -121,8 +129,9 @@ LocalHistoryView.prototype.findLocalHistory = function() { 'Local history path: ' + localHistoryPath + ''); } - atom.workspaceView.append(this); - + this.modalPanel = atom.workspace.addModalPanel({item: this}); + this.modalPanel.show(); + this.focusFilterEditor(); }; @@ -133,6 +142,7 @@ LocalHistoryView.prototype.openDifftoolForCurrentFile = function openDifftoolFor return this.openDifftool(currentFilePath, revision); } }; + LocalHistoryView.prototype.openDifftool = function openDifftool(current, revision) { var basePath = atom.project.getPath(); var diffCmd = atom.config.get('local-history.difftoolCommand'); @@ -170,7 +180,7 @@ LocalHistoryView.prototype.openDifftool = function openDifftool(current, revisio LocalHistoryView.prototype.saveRevision = function saveRevision(buffer) { var now, day, month, pathDirName, file, revFileName; - + now = new Date(); day = '' + now.getDate(); month = '' + (now.getMonth() + 1); diff --git a/package.json b/package.json index c36b744..38fc9ed 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "dependencies": { "atom-helpers": "^1.1.4", "atom-message-panel": "^1.2.2", + "atom-space-pen-views": "^2.0.5", "bluebird": "^2.9.24", "fs-plus": "^2.7.0", "humanize-plus": "^1.5.0"