forked from GitBruno/Novelty
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSection_2_Master.jsx
More file actions
executable file
·76 lines (57 loc) · 1.98 KB
/
Section_2_Master.jsx
File metadata and controls
executable file
·76 lines (57 loc) · 1.98 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
70
71
72
73
74
75
76
/*
Section_2_Master.jsx
Bruno Herfst 2010
An InDesign script to create a section with marker to selected masterpages (applied)
It can also remove the same section elsewhere.
*/
#target indesign;
var myDoc = app.documents.item(0);
// Create a list of master pages
var list_of_master_pages = myDoc.masterSpreads.everyItem().name;
// Dialog
var myDialog = app.dialogs.add({name:"Add section to pages"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
staticTexts.add({staticLabel:"Applied master:"});
var CM = dropdowns.add({stringList:list_of_master_pages, selectedIndex:0});
}
with(dialogRows.add()){
// A decorative checkbox :)
var mySMCheckbox = checkboxControls.add({staticLabel:"Section marker:", checkedState:true});
var mySMField = textEditboxes.add();
}
with(dialogRows.add()){
var myRSMCheckbox = checkboxControls.add({staticLabel:"Remove sectionmarker elsewhere", checkedState:true});
}
}
var myResult = myDialog.show();
if(myResult == true){
// Define variables
var find_master = myDoc.masterSpreads.item(CM.selectedIndex);
var mySM = mySMField.editContents;
var myRSM = myRSMCheckbox.checkedState;
var change_page = [];
// Find the pages
for(myCounter = 0; myCounter < myDoc.pages.length; myCounter++){
myPage = myDoc.pages.item(myCounter);
if(myPage.appliedSection.marker == mySM && myPage == myPage.appliedSection.pageStart && myPage.appliedSection.index != 0) {
myPage.appliedSection.remove();
}
if (myPage.appliedMaster == find_master){
change_page.push(myPage);
}
}
// Now we can start sections
myCounter = 0;
do {
if (change_page[myCounter] == change_page[myCounter].appliedSection.pageStart) {
change_page[myCounter].appliedSection.marker = mySM;
} else {
myDoc.sections.add(change_page[myCounter],{marker:mySM,continueNumbering:true})
}
myCounter++;
} while (myCounter < change_page.length);
alert("Added "+(myCounter+1)+" sections");
} else {
exit();
}