json Acrobat Javascript-自定义对话框
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json Acrobat Javascript-自定义对话框相关的知识,希望对你有一定的参考价值。
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
//<CodeAbove>
//</CodeAbove>
var Section2 =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strShape:"",
strTilt:"",
nDepth:"",
nWidth:"",
nHeight:"",
strColor:"",
strFinish:"",
strTexture:"",
nInputSelect:"dlux",
strComments:"",
nprg1:0,
GetRadioSel:function(oRslts,aCtrls){
for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
if(oRslts[strRtn] == true)
return strRtn;
}
return "";
},
SetListSel:function(list,path){if(path.length == 0) return;
eval("list[\""+ ((typeof path.join != "function")?path:path.join("\"][\"")) + "\"] = 1")},
GetListSel:function(oLstRslts,path){
for(var item in oLstRslts){
if( ((typeof oLstRslts[item]=="number")&&(oLstRslts[item]>0))
|| this.GetListSel(oLstRslts[item],path) )
{path.push(item);return true;}
}
return false;
},
initialize: function(dialog)
{
var listshap =
{
"Rectangle": -1,
"Oval": -1,
"Pentagon": -1,
"Hexagram": -1,
"Septagram": -1,
};
this.SetListSel(listshap, this.strShape);
var listtilt =
{
"36.0 degrees": -1,
"12.5 degrees": -1,
"45.0 degrees": -1,
"62.5 degrees": -1,
"90.0 degrees": -1,
};
this.SetListSel(listtilt, this.strTilt);
var listcolr =
{
"White": -1,
"Black": -1,
"Light Gray": -1,
"Dark Gray": -1,
"Darker Gray": -1,
"Neon Pink": -1,
};
this.SetListSel(listcolr, this.strColor);
var listfnsh =
{
"Plain": -1,
"Granite": -1,
"Glossy Metal": -1,
"Wood (Oak)": -1,
"Wood (Cherry)": -1,
"Marbled": -1,
};
this.SetListSel(listfnsh, this.strFinish);
var listtxtr =
{
"Standard": -1,
"Smooth": -1,
"Dimpled": -1,
"Rough": -1,
"Broken Glass": -1,
};
this.SetListSel(listtxtr, this.strTexture);
var dlgInit =
{
"imsg": "In the section below list the exact dimensions of you need for the item to fit. Allow 1/4 inch on all sides for trim. We cut to the exact demensions indicated\r\n\r\nFor Color and Finish please include all details",
"shap": listshap,
"tilt": listtilt,
"colr": listcolr,
"fnsh": listfnsh,
"txtr": listtxtr,
"dpth": this.nDepth,
"wdth": this.nWidth,
"hght": this.nHeight,
"edt1": this.strComments,
"prg1": this.nprg1,
};
dlgInit[this.nInputSelect] = true;
dialog.load(dlgInit);
SetProgressSect2(this,dialog);
NavTo("Sect2");
},
validate: function(dialog)
{
var oRslts = dialog.store();
var mtexp = /^\s*$/;
var strMsg1 = "";
var path = new Array();
this.GetListSel(oRslts["shap"],path);
if(mtexp.test(path.toString() ) )
strMsg1 += " Shape,";
path = new Array();
this.GetListSel(oRslts["tilt"],path);
if( mtexp.test(path.toString() ) )
strMsg1 += " Tilt,";
if( mtexp.test(oRslts["dpth"] ) )
strMsg1 += " Depth,";
if( mtexp.test(oRslts["wdth"]) )
strMsg1 += " Width,";
if( mtexp.test(oRslts["hght"]) )
strMsg1 += " Height,";
var strMsg2 = "";
if(!mtexp.test(oRslts["dpth"]) && isNaN(oRslts["dpth"]) )
strMsg2 += " Depth,";
if(!mtexp.test(oRslts["wdth"]) && isNaN(oRslts["wdth"]) )
strMsg2 += " Width,";
if(!mtexp.test(oRslts["hght"]) && isNaN(oRslts["hght"]) )
strMsg2 += " Height,";
var strMsg3 = "";
path = new Array();
this.GetListSel(oRslts["colr"],path);
if(mtexp.test(path.toString() ) )
strMsg3 += " Color,";
path = new Array();
this.GetListSel(oRslts["fnsh"],path);
if(mtexp.test(path.toString() ) )
strMsg3 += " Finish,";
path = new Array();
this.GetListSel(oRslts["txtr"],path);
if(mtexp.test(path.toString() ) )
strMsg3 += " Texture,";
var strMsg = "";
if(strMsg1.length > 0)
strMsg += " Missing Dimension data: " + strMsg1 + "\n\n";
if(strMsg2.length > 0)
strMsg += " These Fields must contain a number: " + strMsg2 + "\n\n";
if(strMsg3.length > 0)
strMsg += " Missing Finish Data: " + strMsg3 + "\n\n";
var bRtn = true;
if(strMsg.length > 0)
{
bRtn = (4 == app.alert("Some fields are not filled in appropiately:\n\n" + strMsg + "\n\nDo you want to continue?", 2,2, "Options and Data"));
}
return bRtn;
},
commit: function(dialog)
{
var oRslt = dialog.store();
var path = new Array();
this.strShape = (this.GetListSel(oRslt["shap"],path))?path.reverse():"";
var path = new Array();
this.strTilt = (this.GetListSel(oRslt["tilt"],path))?path.reverse():"";
this.nDepth = oRslt["dpth"];
this.nWidth = oRslt["wdth"];
this.nHeight = oRslt["hght"];
var path = new Array();
this.strColor = (this.GetListSel(oRslt["colr"],path))?path.reverse():"";
var path = new Array();
this.strFinish = (this.GetListSel(oRslt["fnsh"],path))?path.reverse():"";
var path = new Array();
this.strTexture = (this.GetListSel(oRslt["txtr"],path))?path.reverse():"";
this.nInputSelect = this.GetRadioSel(oRslt,["stnd","dlux"]);
this.strComments = oRslt["edt1"];
},
"CanB": function(dialog)
{
this.result="cancel";
dialog.end("cancel");
},
"NxtB": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
this.result="next";
dialog.end("next");
}
},
"PrvB": function(dialog)
{
this.commit(dialog);
this.result="prev";
dialog.end("prev");
},
"aply": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
SetSection2(this);
}
},
"dlux": function(dialog)
{
SetProgressSect2(this,dialog);
},
"stnd": function(dialog)
{
SetProgressSect2(this,dialog);
},
"txtr": function(dialog)
{
SetProgressSect2(this,dialog);
},
"fnsh": function(dialog)
{
SetProgressSect2(this,dialog);
},
"colr": function(dialog)
{
SetProgressSect2(this,dialog);
},
"hght": function(dialog)
{
SetProgressSect2(this,dialog);
},
"wdth": function(dialog)
{
SetProgressSect2(this,dialog);
},
"dpth": function(dialog)
{
SetProgressSect2(this,dialog);
},
"tilt": function(dialog)
{
SetProgressSect2(this,dialog);
},
"shap": function(dialog)
{
SetProgressSect2(this,dialog);
},
description:
{
name: "Section 2: Options and Data",
elements:
[
{
type: "view",
width: 590,
height: 300,
elements:
[
{
type: "static_text",
item_id: "sta1",
name: "Section 2: Options and Data",
},
{
type: "cluster",
item_id: "cls1",
elements:
[
{
type: "static_text",
item_id: "imsg",
width: 511,
height: 61,
alignment: "align_fill",
font: "dialog",
bold: true,
},
]
},
{
type: "static_text",
item_id: "sta5",
name: "(A dialog can be used to build data in a different way than it is entered on the form)",
alignment: "align_center",
},
{
type: "cluster",
item_id: "cls2",
name: "Dimensions",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Shape:",
alignment: "align_right",
font: "dialog",
},
{
type: "popup",
item_id: "shap",
variable_Name: "strShape",
width: 100,
height: 23,
char_width: 8,
},
]
},
{
type: "gap",
item_id: "gap5",
width: 25,
height: 10,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Tilt Angle:",
alignment: "align_right",
font: "dialog",
},
{
type: "popup",
item_id: "tilt",
variable_Name: "strTilt",
char_width: 8,
},
]
},
{
type: "gap",
item_id: "gap4",
width: 25,
height: 10,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta3",
name: "Depth:",
alignment: "align_right",
font: "dialog",
},
{
type: "edit_text",
item_id: "dpth",
variable_Name: "nDepth",
width: 38,
height: 23,
char_width: 8,
SpinEdit: "true",
},
{
type: "static_text",
item_id: "sta6",
name: "inches",
},
]
},
]
},
{
type: "gap",
item_id: "gap8",
width: 36,
height: 5,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta2",
name: "Width (inches):",
alignment: "align_fill",
font: "dialog",
},
{
type: "edit_text",
item_id: "wdth",
variable_Name: "nWidth",
char_width: 8,
},
]
},
{
type: "gap",
item_id: "gap3",
width: 44,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta4",
name: "Height (inches):",
alignment: "align_fill",
font: "dialog",
},
{
type: "edit_text",
item_id: "hght",
variable_Name: "nHeight",
width: 72,
height: 23,
char_width: 8,
},
]
},
]
},
]
},
{
type: "gap",
item_id: "gap2",
width: 36,
height: 5,
char_width: 4,
char_height: 4,
},
{
type: "cluster",
item_id: "cls3",
name: "Surface Finish",
align_children: "align_top",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Color",
alignment: "align_right",
font: "dialog",
},
{
type: "popup",
item_id: "colr",
variable_Name: "strColor",
width: 87,
height: 23,
char_width: 8,
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta0",
name: "Finish:",
alignment: "align_right",
font: "dialog",
},
{
type: "popup",
item_id: "fnsh",
variable_Name: "strFinish",
width: 90,
height: 23,
char_width: 8,
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta6",
name: "Texture:",
width: 86,
height: 23,
alignment: "align_right",
font: "dialog",
},
{
type: "popup",
item_id: "txtr",
variable_Name: "strTexture",
width: 94,
height: 23,
char_width: 8,
},
]
},
]
},
{
type: "gap",
item_id: "gap6",
width: 36,
height: 8,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_row",
alignment: "align_fill",
elements:
[
{
type: "radio",
item_id: "stnd",
group_id: "modl",
name: "Standard Model ($59.95)",
variable_Name: "nInputSelect",
},
{
type: "radio",
item_id: "dlux",
group_id: "modl",
name: "Deluxe Model ($109.95)",
},
]
},
{
type: "gap",
item_id: "gap7",
width: 36,
height: 5,
char_width: 4,
char_height: 4,
},
{
type: "cluster",
item_id: "cls2",
name: "Comments",
width: 566,
height: 25,
alignment: "align_fill",
align_children: "align_fill",
elements:
[
{
type: "edit_text",
item_id: "edt1",
variable_Name: "strComments",
width: 550,
height: 100,
char_width: 8,
alignment: "align_fill",
multiline: "true",
},
]
},
{
type: "gap",
item_id: "gap9",
width: 38,
height: 11,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
alignment: "align_right",
elements:
[
{
type: "static_text",
item_id: "sta7",
name: "Progress",
},
{
type: "progress_bar",
item_id: "prg1",
width: 220,
height: 20,
char_width: 8,
char_height: 2,
},
{
type: "gap",
item_id: "ga00",
width: 38,
height: 11,
char_width: 4,
char_height: 4,
},
{
type: "button",
item_id: "aply",
name: "Apply",
},
{align_children: "align_row",type: "view",elements:[{item_id:"PrvB",name:"Previous",type:"button"},{item_id:"NxtB",name:"Next",type:"button"},{item_id:"CanB",name:"Cancel",type:"button"}]},
]
},
]
},
]
}
};
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
//<CodeAbove>
//</CodeAbove>
var Section3 =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strShip:"",
nTaxPercent:"",
nProg:66,
GetRadioSel:function(oRslts,aCtrls){
for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
if(oRslts[strRtn] == true)
return strRtn;
}
return "";
},
initialize: function(dialog)
{
var dlgInit =
{
"imsg": "Ground shipping takes 3 to 4 days. Air is overnight.\r\n\r\nItems are shipped 3 to 6 weeks after the order is processed.\r\n\r\n",
"prg1": this.nProg,
"taxs": this.nTaxPercent,
};
dlgInit[this.strShip] = true;
dialog.load(dlgInit);
SetProgressSect3(this,dialog);
NavTo("Sect3");
},
validate: function(dialog)
{
var oRslts = dialog.store();
var mtexp = /^\d+(\.\d+)?$/;
var bRtn = true;
if(!mtexp.test(oRslts["taxs"]))
{
bRtn = (4 == app.alert("Tax Percentage must be filled in with a number value\n\nDo you want to continue?", 2,2, "Shipping and Taxes"));
}
return bRtn;
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.strShip = this.GetRadioSel(oRslt,["AirS","GndS"]);
this.nTaxPercent = oRslt["taxs"];
},
"CanB": function(dialog)
{
this.result="cancel";
dialog.end("cancel");
},
"NxtB": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
this.result="done";
dialog.end("done");
}
},
"PrvB": function(dialog)
{
this.commit(dialog);
this.result="prev";
dialog.end("prev");
},
"aply": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
SetSection3(this);
}
},
"taxs": function(dialog)
{
SetProgressSect3(this,dialog);
},
"GndS": function(dialog)
{
SetProgressSect3(this,dialog);
},
"AirS": function(dialog)
{
SetProgressSect3(this,dialog);
},
description:
{
name: "Section 3: Shipping & Taxes",
elements:
[
{
type: "view",
width: 590,
height: 300,
elements:
[
{
type: "view",
elements:
[
{
type: "cluster",
item_id: "cls3",
name: "Section 3: Shipping",
char_width: 8,
char_height: 8,
elements:
[
{
type: "cluster",
item_id: "cls1",
elements:
[
{
type: "static_text",
item_id: "imsg",
width: 511,
height: 61,
alignment: "align_fill",
font: "dialog",
bold: true,
},
]
},
{
type: "gap",
item_id: "gap8",
width: 36,
height: 13,
char_width: 4,
char_height: 4,
},
{
type: "view",
width: 337,
height: 25,
align_children: "align_top",
elements:
[
{
type: "radio",
item_id: "AirS",
group_id: "Ship",
name: "Air ($89.45)",
},
{
type: "gap",
item_id: "ga00",
width: 36,
height: 13,
char_width: 4,
char_height: 4,
},
{
type: "radio",
item_id: "GndS",
group_id: "Ship",
name: "Ground ($3.99)",
},
]
},
]
},
{
type: "gap",
item_id: "gap9",
width: 36,
height: 16,
char_width: 4,
char_height: 4,
},
{
type: "cluster",
item_id: "cls4",
name: "Section 3: Taxes",
elements:
[
{
type: "cluster",
item_id: "cls5",
elements:
[
{
type: "static_text",
item_id: "sta6",
name: "Enter your current state tax rate as a percentage",
font: "dialog",
bold: true,
},
]
},
{
type: "view",
width: 119,
height: 53,
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta1",
name: "Tax:",
},
{
type: "edit_text",
item_id: "taxs",
variable_Name: "nTaxPercent",
width: 38,
height: 23,
},
{
type: "static_text",
item_id: "sta3",
name: "%",
},
]
},
]
},
{
type: "view",
align_children: "align_top",
alignment: "align_right",
elements:
[
{
type: "static_text",
item_id: "sta7",
name: "Progress",
},
{
type: "progress_bar",
item_id: "prg1",
variable_Name: "nProg",
width: 220,
height: 20,
char_width: 8,
char_height: 2,
},
{
type: "gap",
item_id: "gap5",
width: 23,
height: 11,
char_width: 4,
char_height: 4,
},
{
type: "button",
item_id: "aply",
name: "Apply",
},
{align_children: "align_row",type: "view",elements:[{item_id:"PrvB",name:"Previous",type:"button"},{item_id:"NxtB",name:"Finish",type:"button"},{item_id:"CanB",name:"Cancel",type:"button"}]},
]
},
]
},
]
},
]
}
};
//*********************************
// Section 1 functions
function SetSection1(oDlgLit)
{
// Section 1 field data
this.getField("UserTitle").value = Section1.strTitle;
this.getField("UserFirstName").value = Section1.strFirstName;
this.getField("UserLastName").value = Section1.strLastName;
this.getField("UserStreet").value = Section1.strStreet;
this.getField("UserCity").value = Section1.strCity;
this.getField("UserZip").value = Section1.strZip.toString();
}
function SetProgressSect1(dlgLit,dialog)
{
var nProg = 0;
var oRslt = dialog.store();
var mtPtrn = /^\s*$/;
if(!mtPtrn.test(oRslt["namf"]))
nProg += 7;
if(!mtPtrn.test(oRslt["naml"]))
nProg += 7;
if(! mtPtrn.test(oRslt["strt"]))
nProg += 7;
if(!mtPtrn.test(oRslt["city"]))
nProg += 6;
if(!mtPtrn.test(oRslt["zipc"]))
nProg += 6;
dialog.load({"prg1":nProg});
console.println("Progress = " + nProg );
}
//*********************************
// Section 2 functions
function SetSection2(oDlgLit)
{
// Section 2 field data
this.getField("Option").value = Section2.nInputSelect;
this.getField("Data1").value = Section2.strShape + " Shape with a Tilt of " + Section2.strTilt
+ ", dimensions = " + Section2.nWidth + " x " + Section2.nHeight + " x " + Section2.nDepth;
this.getField("Data2").value = "Color: " + Section2.strColor + ", Finish: " + Section2.strFinish + ", Texture: " + Section2.strTexture;
this.getField("Comments").value = Section2.strComments;
}
function GetSection2(oDlgLit)
{
// Section 2 Initialization
Section2.nInputSelect = this.getField("Option").value;
Section2.strComments = this.getField("Comments").value;
// Section 2 field data
if(/(\w+) Shape with a Tilt of (\d+(\.\d+)? degrees), dimensions = (\d+(\.\d+)?) x (\d+(\.\d+)?) x (\d+(\.\d+)?)/.test(this.getField("Data1").value) )
{
Section2.strShape = RegExp.$1;
Section2.strTilt = RegExp.$2;
Section2.nWidth = RegExp.$4;
Section2.nHeight = RegExp.$6;
Section2.nDepth = RegExp.$8;
}
if(/Color: ([\w\s]+), Finish: ([\w\s]+), Texture: ([\w\s]+)/.test(this.getField("Data2").value))
{
Section2.strColor = RegExp.$1;
Section2.strFinish = RegExp.$2;
Section2.strTexture = RegExp.$3;
}
}
function SetProgressSect2(dlgLit,dialog)
{
var nProg = 33;
var oRslt = dialog.store();
var shp = dlgLit.GetRadioSel(oRslt,["stnd","dlux"]);
var mtexp = /^\s*$/;
if(!mtexp.test(shp))
nProg += 4;
if(/^\d+(\.\d+)?$/.test(oRslt["dpth"]))
nProg += 4;
if(/^\d+(\.\d+)?$/.test(oRslt["wdth"]))
nProg += 4;
if(/^\d+(\.\d+)?$/.test(oRslt["hght"]))
nProg += 4;
var path = new Array();
dlgLit.GetListSel(oRslt["shap"],path);
if(!mtexp.test(path.toString() ) )
nProg += 4;
path = new Array();
dlgLit.GetListSel(oRslt["tilt"],path);
if( !mtexp.test(path.toString() ) )
nProg += 4;
path = new Array();
dlgLit.GetListSel(oRslt["colr"],path);
if( !mtexp.test(path.toString() ) )
nProg += 4;
path = new Array();
dlgLit.GetListSel(oRslt["fnsh"],path);
if( !mtexp.test(path.toString() ) )
nProg += 4;
path = new Array();
dlgLit.GetListSel(oRslt["txtr"],path);
if( !mtexp.test(path.toString() ) )
nProg += 4;
dialog.load({"prg1":nProg});
console.println("Progress = " + nProg );
}
//*********************************
// Section 3 functions
function SetSection3(oDlgLit)
{
// Section 3 field data
this.getField("Shipping").value = Section3.strShip;
this.getField("Tax").value = Section3.nTaxPercent/100;
}
function SetProgressSect3(dlgLit,dialog)
{
var nProg = 66;
var oRslt = dialog.store();
var shp = dlgLit.GetRadioSel(oRslt,["AirS","GndS"]);
if(!/^\s*$/.test(shp))
nProg += 17;
if(/^\d+(\.\d+)?$/.test(oRslt["taxs"]))
nProg += 17;
dialog.load({"prg1":nProg});
console.println("Progress: " + nProg );
}
//*********************************
// General functions
function NavTo(cSect)
{
this.gotoNamedDest(cSect);
}
//*********************************
// Main function
function DoDemoFormWizard()
{
Section1.strTitle = this.getField("UserTitle").value;
Section1.strFirstName = this.getField("UserFirstName").value;
Section1.strLastName = this.getField("UserLastName").value;
Section1.strStreet = this.getField("UserStreet").value;
Section1.strCity = this.getField("UserCity").value;
Section1.strZip = this.getField("UserZip").value.toString();
// Section 2 Initialization
GetSection2();
// Section 3
Section3.strShip = this.getField("Shipping").value;
if(!isNaN(this.getField("Tax").value))
Section3.nTaxPercent = util.printf("%2.2f",this.getField("Tax").value * 100);
else
Section3.nTaxPercent = "";
var dlgArr_Test = [WJWizSplash,Section1,Section2,Section3,];
var cRtnCode = "next";
var i=0;
WizLoop:
while((cRtnCode == "prev") || (cRtnCode == "next"))
{
cRtnCode = dlgArr_Test[i].DoDialog();
if(cRtnCode.length == 0)
cRtnCode = dlgArr_Test[i].result;
switch(cRtnCode)
{
case "prev":
i--;
break;
case "next":
i++;
break;
default:
break WizLoop;
}
}
if(cRtnCode == "done")
{// Process Data
SetSection1();
SetSection2();
SetSection3();
}
}
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
//<CodeAbove>
//</CodeAbove>
var Section1 =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strTitle:"",
strFirstName:"",
strLastName:"",
strStreet:"",
strCity:"",
strZip:"",
nprg1:0,
GetRadioSel:function(oRslts,aCtrls){
for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
if(oRslts[strRtn] == true)
return strRtn;
}
return "";
},
initialize: function(dialog)
{
var dlgInit =
{
"imsg": "Please fill in your contact information below. Unless marked otherwise, all data is necessary so that we may process your order in a timely fashion. \r\n\r\nThankyou.",
"namf": this.strFirstName,
"naml": this.strLastName,
"strt": this.strStreet,
"city": this.strCity,
"zipc": this.strZip,
"prg1": this.nprg1,
};
dlgInit[this.strTitle] = true;
dialog.load(dlgInit);
SetProgressSect1(this,dialog);
NavTo("Sect1");
},
validate: function(dialog)
{
var oRslts = dialog.store();
var bRtn = true;
var mtexp = /^\s*$/;
if(mtexp.test(oRslts["namf"]) || mtexp.test(oRslts["naml"]) || mtexp.test(oRslts["strt"])
|| mtexp.test(oRslts["city"]) || mtexp.test(oRslts["zipc"]) )
{
bRtn = (4 == app.alert("Some fields are not filled in\n\nDo you want to continue?", 2,2, "Customer Info"));
}
return bRtn;
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.strTitle = this.GetRadioSel(oRslt,["ttMR","tMRS","ttMS"]);
this.strFirstName = oRslt["namf"];
this.strLastName = oRslt["naml"];
this.strStreet = oRslt["strt"];
this.strCity = oRslt["city"];
this.strZip = oRslt["zipc"];
},
"CanB": function(dialog)
{
this.result="cancel";
dialog.end("cancel");
},
"NxtB": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
this.result="next";
dialog.end("next");
}
},
"PrvB": function(dialog)
{
this.commit(dialog);
this.result="prev";
dialog.end("prev");
},
"aply": function(dialog)
{
if(this.validate(dialog))
{
this.commit(dialog);
SetSection1(this);
}
},
"zipc": function(dialog)
{
SetProgressSect1(this,dialog);
},
"city": function(dialog)
{
SetProgressSect1(this,dialog);
},
"strt": function(dialog)
{
SetProgressSect1(this,dialog);
},
"naml": function(dialog)
{
SetProgressSect1(this,dialog);
},
"namf": function(dialog)
{
SetProgressSect1(this,dialog);
},
description:
{
name: "Section1: Customer Info",
elements:
[
{
type: "view",
width: 590,
height: 300,
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Section 1: Customer Info",
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "cluster",
item_id: "cls1",
elements:
[
{
type: "static_text",
item_id: "sta3",
name: "(Here are some form instructions that may not fit well on a busy form)",
alignment: "align_center",
font: "palette",
italic: true,
},
{
type: "static_text",
item_id: "imsg",
width: 511,
height: 61,
alignment: "align_fill",
font: "dialog",
bold: true,
},
]
},
{
type: "gap",
item_id: "gap1",
width: 36,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta1",
name: "Title (optional):",
},
{
type: "radio",
item_id: "ttMR",
group_id: "titl",
name: "Mr.",
variable_Name: "strTitle",
},
{
type: "radio",
item_id: "tMRS",
group_id: "titl",
name: "Mrs.",
},
{
type: "radio",
item_id: "ttMS",
group_id: "titl",
name: "Ms.",
},
]
},
{
type: "gap",
item_id: "gap1",
width: 36,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta2",
name: "FirstName:",
},
{
type: "edit_text",
item_id: "namf",
variable_Name: "strFirstName",
width: 123,
height: 23,
char_width: 8,
},
]
},
{
type: "gap",
item_id: "gap1",
width: 36,
height: 24,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta3",
name: "LastName:",
},
{
type: "edit_text",
item_id: "naml",
variable_Name: "strLastName",
width: 129,
height: 23,
char_width: 8,
},
]
},
]
},
{
type: "gap",
item_id: "gap2",
width: 36,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "cluster",
item_id: "cls1",
name: "Address",
char_width: 8,
char_height: 8,
elements:
[
{
type: "static_text",
item_id: "sta2",
name: "Note: No Deliveries will be made to P.O. Boxes or addresses outside the US/Canada",
font: "palette",
bold: true,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta4",
name: "Street:",
},
{
type: "edit_text",
item_id: "strt",
variable_Name: "strStreet",
width: 410,
height: 23,
char_width: 8,
},
]
},
{
type: "gap",
item_id: "gap3",
width: 36,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "view",
width: 60,
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta5",
name: "City:",
},
{
type: "edit_text",
item_id: "city",
variable_Name: "strCity",
width: 230,
height: 23,
char_width: 8,
},
]
},
{
type: "view",
width: 60,
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta6",
name: "Zip:",
},
{
type: "edit_text",
item_id: "zipc",
variable_Name: "strZip",
width: 82,
height: 23,
char_width: 8,
},
]
},
]
},
]
},
]
},
{
type: "gap",
item_id: "gap3",
width: 36,
height: 12,
char_width: 4,
char_height: 4,
},
{
type: "view",
align_children: "align_top",
alignment: "align_right",
elements:
[
{
type: "static_text",
item_id: "sta7",
name: "Progress",
},
{
type: "progress_bar",
item_id: "prg1",
width: 220,
height: 20,
char_width: 8,
char_height: 2,
},
{
type: "gap",
item_id: "gap6",
width: 38,
height: 11,
char_width: 4,
char_height: 4,
},
{
type: "button",
item_id: "aply",
name: "Apply",
},
{align_children: "align_row",type: "view",elements:[{item_id:"PrvB",name:"Previous",type:"button"},{item_id:"NxtB",name:"Next",type:"button"},{item_id:"CanB",name:"Cancel",type:"button"}]},
]
},
]
},
]
}
};
以上是关于json Acrobat Javascript-自定义对话框的主要内容,如果未能解决你的问题,请参考以下文章
将 Acrobat JavaScript 代码添加到 pdf 导出
Adobe Acrobat DC 自定义批量动作(pdf 批量导出图片)