forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom-tests.ts
77 lines (61 loc) · 1.39 KB
/
atom-tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/// <reference path="../node/node.d.ts" />
/// <reference path="./atom.d.ts" />
/// <reference path="../pathwatcher/pathwatcher.d.ts" />
import path = require("path");
import _atom = require("atom");
import pathwatcher = require("pathwatcher");
var File = pathwatcher.File;
class SampleView extends _atom.ScrollView {
editorId:string;
file:PathWatcher.IFile;
editor:AtomCore.IEditor;
static deserialize(state:any):SampleView {
return new SampleView(state);
}
static content():any {
return this.div({class: 'sample native-key-bindings', tabindex: -1});
}
constructor(params:{editorId?:string; filePath?:string;} = {}) {
super();
this.editorId = params.editorId;
if (this.editorId) {
this.resolveEditor(this.editorId);
} else {
this.file = new File(params.filePath);
}
}
get jq():JQuery {
// dirty hack
return <any>this;
}
serialize() {
return {
deserializer: 'SampleView',
editorId: this.editorId
};
}
destroy() {
this.unsubscribe();
}
resolveEditor(editorId:string) {
var resolve = ()=> {
if (this.editor) {
this.jq.trigger("title-changed");
} else {
var view = this.jq.parents('.pane').view();
if (view) {
view.destroyItem(this);
}
}
};
if (atom.workspace) {
resolve();
} else {
atom.packages.once("activated", ()=> {
resolve();
});
}
}
}
atom.deserializers.add(SampleView);
export = SampleView;