-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathInstantDialog.jsx
More file actions
117 lines (102 loc) · 3.09 KB
/
InstantDialog.jsx
File metadata and controls
117 lines (102 loc) · 3.09 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#target 'indesign'
// Path to IdExtenso entry point.
// ---
#include '../$$.jsxinc'
// Include Yalt and Dom.Dialog.
// ---
#include '../etc/$$.Yalt.jsxlib'
#include '../etc/$$.Dom.Dialog.jsxlib'
// =============================================================================
// InstantDialog [180313]
// -----------------
// DOM dialog fast and easy.
// Demonstrates:
// - Usage of `$$.Dom.Dialog.fromXML()`
// - Displaying the dialog and having strings Yalt-localized :-)
// - Access to control values using `setValueKey()` and `getValueKey()`
// - Using $$.isBooting to prepend persistent data
// (makes sense when #targetengine is used.)
// =============================================================================
if( $$.isBooting() )
{
// XML descriptor (declared once.)
// ---
const myDialogXML =
<Dialog name="InstantDialog" canCancel="true">
<DialogColumn>
<Dropdown key="scope" caption="Scope" list="Selection|Spread|Document" />
<PercentEditbox key="factor" caption="Factor" value="150" min="100" max="300" small="5" large="10" />
<CheckboxControl key="check1" caption="Some checkbox" checked="true" />
<CheckboxControl key="check2" caption="Another one" checked="false" />
<StaticText rem="empty-line" />
<EnablingGroup key="checkGrp" caption="Extra options" checked="false">
<DialogColumn>
<StaticText caption="Just to show how this works." />
<CheckboxControl key="great" caption="Great feature" />
</DialogColumn>
</EnablingGroup>
</DialogColumn>
</Dialog>;
// Yalt package (EN+FR) for this UI.
// ---
$$.Yalt(
'''
/*<YALT> # FRENCH
------------------------------------
Scope # Portée
Factor # Facteur
Some checkbox # Une option
Another one # Et une autre
Extra options # Options additionnelles
Just to show how this works. # Juste pour illustrer le fonctionnement.
Great feature # Fonction géniale
------------------------------------
Selection # Sélection
Spread # Planche
Document # Document
------------------------------------
Scope: [%1], factor: %2, and %3 to the great feature! # Portée : [%1], facteur : %2, et %3 pour la fonction géniale !
YES # OUI
NO # NON
</YALT>*/
'''
);
}
// Load the framework.
// ---
$$.load();
try
{
// Create the dialog.
// ---
var dlg = $$.Dom.Dialog(myDialogXML);
// Preset (before showing the dialog.)
// ---
dlg.setValueKey("scope",1); // Select index 1 in the list -> "Spread"
dlg.setValueKey("great",true); // In fact, we want that chekbox ON.
// Show me now.
// ---
if( dlg.show() )
{
var msg = __(
"Scope: [%1], factor: %2, and %3 to the great feature!"
, __(['Selection','Spread','Document'][dlg.getValueKey('scope')])
, dlg.getValueKey('factor')
, __(dlg.getValueKey('checkGrp') && dlg.getValueKey('great') ? 'YES' : 'NO')
);
$$.success(msg, dlg.name);
}
// In case you don't need to re-use it.
// ---
dlg.destroy();
}
catch(e)
{
// Should anything go wrong...
// ---
$$.receiveError(e);
}
// =============================================================================
// Unload the framework.
// ---
$$.unload();