-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathturn_off_extras.jsx
381 lines (351 loc) · 12.2 KB
/
turn_off_extras.jsx
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/* ---------------------------------------------------------------------------------- *\
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\* ---------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------- *\
turn_off_extras
Description:Toggle most display preferences in one UI
[Ver. 1]
[Author: Gerald Singelmann. ]
[Lang: DE, EN, FR]
[Tested with: InDesign CC]
[Creat: 19-08-21]
Bugs & Feedback : https://github.com/gsingelmann/indd_turn_off_extras
www.cuppascript.com
\* ---------------------------------------------------------------------------------- */
if ( app.documents.length ) main();
function main() {
// --------------------------------------------------------------------------------------------
// Localisation strings in _l are set in init()
// --------------------------------------------------------------------------------------------
var _l = {};
init();
var doc = app.activeDocument;
// --------------------------------------------------------------------------------------------
// The preferences we set
// e.g. 'enableStylePreviewMode' is exactly the name of the property in InDesign
// --------------------------------------------------------------------------------------------
var prefs = {
textPreferences: {
enableStylePreviewMode: false,
highlightCustomSpacing: false,
highlightHjViolations: false,
highlightKeeps: false,
highlightKinsoku: false,
highlightSubstitutedFonts: false,
highlightSubstitutedGlyphs: false,
showInvisibles: false,
},
gridPreferences: {
baselineGridShown: false,
documentGridShown: false,
},
guidePreferences: {
guidesShown: false,
},
viewPreferences: {
showFrameEdges: false,
showNotes: false,
},
xmlViewPreferences: {
showTaggedFrames: false,
showTagMarkers: false,
}
}
// --------------------------------------------------------------------------------------------
// labels HAS to have the same structure as prefs + section_names
// --------------------------------------------------------------------------------------------
var labels = {
textPreferences: {
section_name: localize( _l.textPreferences ),
enableStylePreviewMode: localize( _l.enableStylePreviewMode ),
highlightCustomSpacing: localize( _l.highlightCustomSpacing ),
highlightHjViolations: localize( _l.highlightHjViolations ),
highlightKeeps: localize( _l.highlightKeeps ),
highlightKinsoku: localize( _l.highlightKinsoku ),
highlightSubstitutedFonts: localize( _l.highlightSubstitutedFonts ),
highlightSubstitutedGlyphs: localize( _l.highlightSubstitutedGlyphs ),
showInvisibles: localize( _l.showInvisibles ),
},
gridPreferences: {
section_name: localize( _l.gridPreferences ),
baselineGridShown: localize( _l.baselineGridShown ),
documentGridShown: localize( _l.documentGridShown ),
},
guidePreferences: {
section_name: localize( _l.guidePreferences ),
guidesShown: localize( _l.guidesShown ),
},
viewPreferences: {
section_name: localize( _l.viewPreferences ),
showFrameEdges: localize( _l.showFrameEdges ),
showNotes: localize( _l.showNotes ),
},
xmlViewPreferences: {
section_name: localize( _l.xmlViewPreferences ),
showTaggedFrames: localize( _l.showTaggedFrames ),
showTagMarkers: localize( _l.showTagMarkers ),
}
}
// --------------------------------------------------------------------------------------------
// Store the current settings in the prefs-Object
// --------------------------------------------------------------------------------------------
for ( var section in prefs ) {
for ( var pref in prefs[section] ) {
if ( doc.hasOwnProperty( section ) ) {
if ( doc[section].hasOwnProperty( pref ) ) {
prefs[section][pref] = doc[section][pref];
}
}
}
}
// --------------------------------------------------------------------------------------------
// Remember the current settings once per document
// --------------------------------------------------------------------------------------------
if ( doc.extractLabel("gs_prefs_resetter") == "" ) {
doc.insertLabel( "gs_prefs_resetter", prefs.toSource() );
}
// --------------------------------------------------------------------------------------------
// Ask the user
// --------------------------------------------------------------------------------------------
var w = new Window("dialog");
w.orientation ="row";
w.alignChildren = "top";
w.main = w.add("group");
w.main.orientation = "column";
w.main.alignChildren = "fill";
for ( var section in prefs ) {
w.main[section] = w.main.add( "panel" );
w.main[section].text = labels[section].section_name;
w.main[section].alignChildren = "fill";
for ( var pref in prefs[section] ) {
var aux = w.main[section].add("group");
aux.alignChildren = "bottom"
w.main[section][pref] = aux.add('checkbox');
w.main[section][pref].value = prefs[section][pref];
aux.add("statictext", undefined, labels[section][pref] );
}
}
w.btns = w.add("group");
w.btns.orientation = "column";
w.btns.alignChildren = "fill";
w.defaultElement = w.btns.add("button", undefined, localize( _l.defaultElement ));
w.btns.cancel = w.btns.add("button", undefined, localize( _l.cancel ));
w.btns.ok = w.btns.add("button", undefined, localize( _l.ok ) );
w.btns.restore = w.btns.add("button", undefined, localize( _l.restore ), {enabled: doc.extractLabel("gs_prefs_resetter") != ""} );
w.btns.last_combo = w.btns.add("button", undefined, localize( _l.last_combo ), {enabled: app.extractLabel("gs_extras_last_settings") != ""} );
w.btns.ok.onClick = function() {
for ( var section in prefs ) {
for ( var pref in prefs[section] ) {
prefs[section][pref] = this.window.main[section][pref].value;
}
}
w.close(1);
}
w.btns.cancel.onClick = function() {
w.close(2);
}
w.defaultElement.onClick = function() {
w.close(3);
}
w.defaultElement.notify = function() {
w.close(3);
}
w.btns.restore.onClick = function() {
w.close(4);
}
w.btns.last_combo.onClick = function() {
w.close(5);
}
var todo = w.show();
// --------------------------------------------------------------------------------------------
// 1 = "Apply"
// --------------------------------------------------------------------------------------------
if ( todo == 1 ) {
app.insertLabel( "gs_extras_last_settings", prefs.toSource() );
for ( var section in prefs ) {
for ( var pref in prefs[section] ) {
doc[section][pref] = prefs[section][pref];
}
}
// --------------------------------------------------------------------------------------------
// 3 = "All off"
// --------------------------------------------------------------------------------------------
} else if ( todo == 3 ) {
for ( var section in prefs ) {
for ( var pref in prefs[section] ) {
doc[section][pref] = false;
}
}
// --------------------------------------------------------------------------------------------
// 4 = "Restore"
// --------------------------------------------------------------------------------------------
} else if ( todo == 4 ) {
var saved = doc.extractLabel( "gs_prefs_resetter" );
if ( saved != "" ) {
saved = eval( saved );
for ( var section in saved ) {
for ( var pref in saved[section] ) {
doc[section][pref] = saved[section][pref];
} // for pref in section
} // for section in saved
} // if saved
// --------------------------------------------------------------------------------------------
// 5 = "Last Settings"
// --------------------------------------------------------------------------------------------
} else if ( todo == 5 ) {
var saved = app.extractLabel( "gs_extras_last_settings" );
if ( saved != "" ) {
saved = eval( saved );
for ( var section in saved ) {
for ( var pref in saved[section] ) {
doc[section][pref] = saved[section][pref];
} // for pref in section
} // for section in saved
} // if saved
} // if todo == x
function init() {
_l = {
textPreferences: {
de: 'Text Einstellungen',
en: 'Text Preferences',
fr: 'Paramètres de texte'
},
enableStylePreviewMode: {
de: 'Formatabweichungen anzeigen',
en: 'Style Preview Mode',
fr: 'Surligneur de remplacement de style'
},
highlightCustomSpacing: {
de: 'Spationierung anzeigen',
en: 'Custom Spacing',
fr: 'Approche/Crénage personalisés'
},
highlightHjViolations: {
de: 'Silbentrennung anzeigen',
en: 'HJ Violations',
fr: 'Infraction de césures et de justification'
},
highlightKeeps: {
de: 'Umbruchverletzung anzeigen',
en: 'Keeps Violations',
fr: 'Infraction d’enchainement'
},
highlightKinsoku: {
de: 'Kinsoku anzeigen',
en: 'Kinsoku',
fr: 'Composition Kinsoku'
},
highlightSubstitutedFonts: {
de: 'Ersetzte Schriften anzeigen',
en: 'Substituted Fonts',
fr: 'Polices substituées'
},
highlightSubstitutedGlyphs: {
de: 'Ersetzte Glyphen anzeigen',
en: 'Substituted Glyphs',
fr: 'Glyphes remplacés'
},
showInvisibles: {
de: 'Verborgene Zeichen anzeigen',
en: 'Show Invisibles',
fr: 'Afficher les caractères masqués'
},
gridPreferences: {
de: 'Raster Einstellungen',
en: 'Grid Preferences',
fr: 'Paramètres de la grille'
},
baselineGridShown: {
de: 'Grundlinienraster anzeigen',
en: 'Baseline Grid',
fr: 'Afficher la grille de ligne de base'
},
documentGridShown: {
de: 'Dokumentraster azeigen',
en: 'Document Grid',
fr: 'Afficher la grille de document'
},
guidePreferences: {
de: 'Hilfslinien Einstellungen',
en: 'Guides',
fr: 'Paramètres des guides'
},
guidesShown: {
de: 'Hilfslinien anzeigen',
en: 'Show Guides',
fr: 'Afficher les guides'
},
viewPreferences: {
de: 'Fenster Einstellungen',
en: 'View Preferences',
fr: 'Paramètres d’affichage'
},
showFrameEdges: {
de: 'Rahmenkanten anzeigen',
en: 'Show Frame Edges',
fr: 'Afficher le contour des blocs'
},
showNotes: {
de: 'Notizen anzeigen',
en: 'Show Notes',
fr: 'Afficher les notes'
},
xmlViewPreferences: {
de: 'XML Einstellungen',
en: 'XML Preferences',
fr: 'Paramètres XML'
},
showTaggedFrames: {
de: 'Getaggte Rahmen anzeigen',
en: 'Show Tagged Frames',
fr: 'Afficher les blocs balisés'
},
showTagMarkers: {
de: 'Tagmarken anzeigen',
en: 'Show Tag Markers',
fr: 'Afficher les marques des balises'
},
defaultElement: {
de: 'Alle aus',
en: 'Everything off',
fr: 'Désactiver tout'
},
cancel: {
de: 'Abbrechen',
en: 'Cancel',
fr: 'Annuler'
},
ok: {
de: 'Anwenden',
en: 'Apply',
fr: 'Appliquer'
},
restore: {
de: 'org. Zustand',
en: 'Initial Settings',
fr: 'Restaurer les paramêtres'
},
last_combo: {
de: 'letzte Kombo',
en: 'Last Combo',
fr: 'Dernier Combo'
}
}
}
}