//=============================================================
// Script by Luis Felipe Corullón
// Contato: lf@corullon.com.br
// Site: http://scripts.corullon.com.br
// +55 (51) 9-9685.7565
// Version: 20230418_1458_GMT-3
//=============================================================
var doc = app.activeDocument;
var msp = doc.masterSpreads.everyItem().name;
var ps = doc.paragraphStyles.everyItem().name;
var data;
msp.unshift("Master to apply");
var w = new Window("dialog" , "Script by LFCorullón");
w.alignChildren = "left";
var g = w.add("group");
g.orientation = "column";
var pFix = g.add("panel" , undefined , "Scrollable");
pFix.orientation = "row";
pFix.alignment = "fill";
pFix.alignChildren = "right";
pFix.margins.top = 20;
pFix.maximumSize.height = 200;
var p1 = pFix.add("group");
p1.orientation = "column";
p1.alignment = "fill";
p1.alignChildren = "right";
p1.margins.bottom = 20;
p1.maximumSize.height = 999999;
var gParaStyle = p1.add("group");
gParaStyle.orientation = "column";
gParaStyle.alignChildren = "right";
var g2 = gParaStyle.add("group");
g2.orientation = "row";
g2.alignChildren = "center";
var dParaStyle = g2.add("checkbox" , undefined , "Paragraph style");
var dParaStyle_sel = g2.add("dropdownlist" , [0,0,100,22] , ps);
var dParaStyle_msp = g2.add("dropdownlist" , [0,0,120,22] , msp);
dParaStyle.value = dParaStyle_sel.enabled = dParaStyle_msp.enabled = false;
dParaStyle_msp.selection = 0;
dParaStyle_msp.helpTip = "\"Master to apply\" option will apply the [None] master page";
var dParaStyle_btns = g2.add("group");
dParaStyle_btns.spacing = 5;
var dParaStyle_plus = dParaStyle_btns.add("button" , [0,0,20,20] , "+");
dParaStyle_plus.enabled = false;
dParaStyle_plus.onClick = function () {
addRow(gParaStyle , "Paragraph style" , ps , this);
}
var scrollBar = pFix.add("scrollbar");
scrollBar.size = [14 , 190];
scrollBar.stepdelta = scrollBar.jumpdelta = 10;
scrollBar.value = 0;
scrollBar.minvalue = 0;
scrollBar.maxvalue = 0;
scrollBar.onChanging = function () {
p1.location.y = -1 * this.value;
}
dParaStyle.onClick = function () {
if (this.value == true) {
dParaStyle_sel.enabled = dParaStyle_msp.enabled = dParaStyle_plus.enabled = true;
dParaStyle_sel.enabled = dParaStyle_plus.enabled = true;
}
else {
dParaStyle_sel.enabled = dParaStyle_msp.enabled = dParaStyle_plus.enabled = false;
if (gParaStyle.children.length > 1) {
for (var i=gParaStyle.children.length-1; i>=1; i--) {
gParaStyle.remove(gParaStyle.children[i]);
w.layout.layout(true);
p1.size.height = (gParaStyle.children.length)*32;
scrollBar.location = [pFix.size.width-18 , 0];
scrollBar.minvalue = -20;
scrollBar.maxvalue = p1.size.height - pFix.size.height + 20;
}
}
dParaStyle_sel.selection = null;
}
}
//========================================================================================
//========================================================================================
function addRow(group , style , array , btn) {
gg = group.add("group");
gg.alignChildren = "top";
gg.check = gg.add("statictext" , undefined , style);
gg.ps = gg.add("dropdownlist" , [0,0,100,22] , array);
gg.msp = gg.add("dropdownlist" , [0,0,120,22] , msp);
gg.msp.selection = 0;
gg.msp.helpTip = "\"Master to apply\" option will apply the [None] master page";
gg.btns = gg.add("group");
gg.btns.spacing = 5;
gg.btns.minus = gg.btns.add("button" , [0,0,20,20] , "-");
gg.btns.minus.onClick = remRow;
w.maximumSize.width = wW;
w.center();
n = gParaStyle.children.length + 1;
v = p1.location.y;
w.layout.layout(true);
p1.size.height = (gParaStyle.children.length)*32;
scrollBar.location = [pFix.size.width-18 , 0];
scrollBar.minvalue = -20;
scrollBar.maxvalue = p1.size.height - pFix.size.height + 20;
p1.location.y = v;
}
//========================================================================================
//========================================================================================
function remRow() {
this.parent.parent.parent.remove(this.parent.parent);
w.maximumSize.width = wW;
w.center();
n = gParaStyle.children.length + 1;
v = p1.location.y;
w.layout.layout(true);
p1.size.height = (gParaStyle.children.length)*32;
scrollBar.location = [pFix.size.width-18 , 0];
scrollBar.minvalue = -20;
scrollBar.maxvalue = p1.size.height - pFix.size.height + 20;
scrollBar.value -= 32;
p1.location.y = v;
if (p1.size.height > pFix.size.height && p1.bounds.bottom < pFix.bounds.bottom-20) {
scrollBar.location = [pFix.size.width-18 , 0];
scrollBar.maxvalue = p1.size.height - pFix.size.height + 20;
p1.location.y = (v+32);
}
if (p1.size.height <= pFix.size.height-20) {
scrollBar.location = [pFix.size.width-18 , 0];
scrollBar.maxvalue = p1.size.height - pFix.size.height + 20;
p1.location.y = 20;
}
}
//========================================================================================
//========================================================================================
//========================================================================================
//========================================================================================
w.onShow = function () {
wW = w.frameBounds.width;
p1.maximumSize.height = (gParaStyle.children.length)*1000;
scrollBar.location = [pFix.size.width-18 , 0];
}
//========================================================================================
//========================================================================================
//========================================================================================
//========================================================================================
if (w.show() != 2) {
var ps_selections = [];
if (dParaStyle.value == true) {
for (var i=0; i<gParaStyle.children.length; i++) {
var ps_name = gParaStyle.children[i].children[1].selection.text;
var ps_msp = gParaStyle.children[i].children[2].selection.text;
ps_selections.push([ps_name , ps_msp]);
}
}
data = ps_selections;
}
else exit();
//========================================================================================
//========================================================================================
... View more