-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.jsx
82 lines (63 loc) · 2.53 KB
/
save.jsx
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
78
79
80
81
82
/************************************************
save.jsx 1.0
Paul Conigliaro http://conigs.com
Oct 2017 1.0
Finally save your After Effects project
in a simple, intuitive way!
************************************************/
(function (thisObject) {
var strings = {
scriptName: "Save",
buttons: {
save: "Save"
},
helpTips: {
save: "Save"
},
instructions: {
save: "Click to save!"
},
errors: {
cantSave: "Can't Save!"
}
}
buildPanel(thisObject);
function buildPanel(thisObject) {
function buildUI(thisObject) {
var win = (thisObject instanceof Panel) ? thisObject : new Window("palette", strings.scriptName, undefined, {resizeable: true});
win.grp = win.add("group", undefined);
win.grp.orientation = "column";
win.grp.preferredSize = [200,70];
win.grp.alignment = ['left', 'top'];
win.grp.alignChildren = ['left','top'];
win.grp.saveInstructions = win.grp.add("statictext", undefined, strings.instructions.save);
win.grp.saveInstructions.preferredSize = [190,20];
win.grp.saveInstructions.justify = 'center';
win.grp.saveBtn = win.grp.add("button", undefined, strings.buttons.save);
win.grp.saveBtn.preferredSize = [190,30];
win.grp.saveBtn.helpTip = strings.helpTips.save;
win.layout.layout(true);
win.grp.minimumSize = win.grp.size;
win.layout.resize();
win.onResizing = win.onResize = function(){this.layout.resize()};
win.grp.saveBtn.onClick = saveFunction;
return win;
}
var scriptPalette = buildUI(thisObject);
if(scriptPalette != null && scriptPalette instanceof Window) {
scriptPalette.center();
scriptPalette.show();
}
}
function saveFunction(paletteObj) {
var saveCommand = app.findMenuCommandId("Save");
var saveAsCommand = app.findMenuCommandId("Save As...");
try {
if(app.project.file === null) {
app.executeCommand(saveAsCommand);
} else {
app.executeCommand(saveCommand);
}
} catch(e) { alert(strings.errors.cantSave);}
}
})(this);