-
Notifications
You must be signed in to change notification settings - Fork 0
/
template_script.jsx
72 lines (58 loc) · 1.97 KB
/
template_script.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
main();
// general variables
var myLayer;
var myDocument;
var myPageWidth;
var myPageHeight;
var myPage;
var myMargins;
function main() {
// populate variables
myDocument = app.activeDocument;
myPageWidth = myDocument.documentPreferences.pageWidth;
myPageHeight = myDocument.documentPreferences.pageHeight;
myPage = myDocument.layoutWindows[0].activePage;
myMargins = myPage.marginPreferences;
alert(myMargins.top);
alert(myMargins.bottom);
alert(myMargins.left);
alert(myMargins.right);
//$.writeln(myPageWidth/2);
//$.writeln(myPageHeight/2);
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
//Display the browser.
//var textFile = File.openDialog("Select a text file", "");
// display dialog box
//myDisplayDialog(textFile);
}
/* ---- FUNCTIONS ---- */
// Function to display dialog box
function myDisplayDialog(myTextFile) {
var myLabelWidth = 90;
var myDialog = app.dialogs.add({name: "Grid Layout"});
with (myDialog.dialogColumns.add()) {
with (dialogRows.add()) {
with (dialogColumns.add()) {
staticTexts.add({staticLabel: "Rows:", minWidth: myLabelWidth});
staticTexts.add({staticLabel: "Columns:", minWidth: myLabelWidth});
}
with (dialogColumns.add()) {
var myNumberOfRowsField = integerEditboxes.add({editValue: 2});
var myNumberOfColumnsField = integerEditboxes.add({editValue: 2});
}
}
}
var myResult = myDialog.show();
if (myResult == true) {
// Get input variables
var myNumberOfRows = myNumberOfRowsField.editValue;
var myNumberOfColumns = myNumberOfColumnsField.editValue;
// destroy dialog
myDialog.destroy();
// Next Actions
// Next Actions
} else {
myDialog.destroy();
}
}