forked from GitBruno/Novelty
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInsert_Impresion_Numbers.jsx
More file actions
executable file
·69 lines (66 loc) · 2.07 KB
/
Insert_Impresion_Numbers.jsx
File metadata and controls
executable file
·69 lines (66 loc) · 2.07 KB
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
#target InDesign;
switch(app.selection[0].constructor.name){
case "Character":
case "Paragraph":
case "Word":
case "Text":
case "TextStyleRange":
app.selection[0].contents = ""; // results in app.selection[0] == InsertionPoint;
//break; // no break as we want to continue as InsertionPoint
case "InsertionPoint":
insertImpressionNumber(app.selection[0]);
break;
default:
alert("This is an "+ app.selection[0].constructor.name + "\nThis function is meant to be run inside from within text-frame.");
}
function insertImpressionNumber(selection){
var impression = {left:"10 9 8 7 6 5 4 3 2 1",centre:"1 3 5 7 9 10 8 6 4 2",right:"1 2 3 4 5 6 7 8 9 10"};
// try and get the alignment automatically without asking
switch(String(selection.justification)){
case "LEFT_ALIGN":
case "LEFT_JUSTIFIED":
selection.contents = impression.left;
break;
case "RIGHT_ALIGN":
case "RIGHT_JUSTIFIED":
selection.contents = impression.right;
break;
case "CENTER_ALIGN":
case "CENTER_JUSTIFIED":
selection.contents = impression.centre;
break;
//case "TO_BINDING_SIDE":
//case "AWAY_FROM_BINDING_SIDE":
// break; //we need to get the parent page first
default: //FULLY_JUSTIFIED: Ask what the user wants to do
_placeViaAlignmentUI(selection, impression);
}
}
function _placeViaAlignmentUI(selection, impression){
// Make the dialog box for selecting the alignment
var dlg = app.dialogs.add({name:"Insert Impression Number"});
with(dlg.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
var requestedJustification = dropdowns.add({stringList:["Left","Centre","Right"], selectedIndex:0});
}
}
}
//show dialog
if(dlg.show() == true){
switch(requestedJustification.selectedIndex){
case 0:
selection.contents = impression.left;
break;
case 1:
selection.contents = impression.centre;
break;
case 2:
selection.contents = impression.right;
break;
default:
// do nothing
break;
}
}
}