fix: menu direct par action, plus de choix intermediaire
Chaque action est un item de menu separe : "Imposer un livret", "Delivretiser", etc. Un clic = une action. Seul le creep est demande via app.response. Corrige aussi "doc is not defined". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -179,12 +179,7 @@ CDImp.Livret.construireDocument = function (srcDoc, planches, creepMm) {
|
||||
* @param {Doc} doc document imposes (planches doubles), document actif si omis
|
||||
*/
|
||||
CDImp.Livret.delivretiser = function (doc) {
|
||||
try {
|
||||
doc = CDImp.Util.getDocActif(doc);
|
||||
} catch (e) {
|
||||
CDImp.Util.erreur(e.toString());
|
||||
return;
|
||||
}
|
||||
doc = CDImp.Util.getDocActif(doc);
|
||||
|
||||
var nPlanches = doc.numPages;
|
||||
if (nPlanches % 2 !== 0) {
|
||||
@@ -239,45 +234,23 @@ CDImp.Livret.delivretiser = function (doc) {
|
||||
// -----------------------------------------------------------------------
|
||||
// Point d'entree du module (appele depuis le panneau principal, Module 1)
|
||||
// -----------------------------------------------------------------------
|
||||
CDImp.Livret.lancer = function (doc) {
|
||||
try {
|
||||
doc = CDImp.Util.getDocActif(doc);
|
||||
} catch (e) {
|
||||
app.alert("Veuillez ouvrir un document PDF.");
|
||||
return;
|
||||
}
|
||||
|
||||
CDImp.Livret.imposer = function () {
|
||||
var doc = CDImp.Util.getDocActif();
|
||||
var nPages = doc.numPages;
|
||||
var reste = nPages % 4;
|
||||
var info = "Document : " + nPages + " pages";
|
||||
|
||||
var info = "Document : " + nPages + " pages.";
|
||||
if (reste !== 0) {
|
||||
info += " (pas multiple de 4, " + (4 - reste) + " page(s) blanche(s) seront ajoutees a la fin)";
|
||||
info += "\n" + (4 - reste) + " page(s) blanche(s) seront ajoutees a la fin.";
|
||||
}
|
||||
|
||||
var saisie = app.response({
|
||||
cQuestion: info + "\n\nTapez une commande :\n I = Imposer (creer un livret)\n D = Delivretiser\n I,creep = Imposer avec chasse en mm (ex: I,0.5)\n\nExemples : I ou I,0.3 ou D",
|
||||
cTitle: "Livret / Delivretiser",
|
||||
cDefault: "I"
|
||||
cQuestion: info + "\n\nCompensation de chasse (creep) en mm par feuille :\n(0 = aucune)",
|
||||
cTitle: "Imposer un livret",
|
||||
cDefault: "0"
|
||||
});
|
||||
if (!saisie) return;
|
||||
saisie = saisie.toUpperCase().replace(/\s/g, "");
|
||||
|
||||
if (saisie === "D") {
|
||||
CDImp.Livret.delivretiser(doc);
|
||||
return;
|
||||
}
|
||||
|
||||
var creepMm = 0;
|
||||
if (saisie.indexOf(",") !== -1) {
|
||||
var parts = saisie.split(",");
|
||||
saisie = parts[0];
|
||||
creepMm = parseFloat(parts[1]) || 0;
|
||||
}
|
||||
|
||||
if (saisie !== "I") {
|
||||
app.alert("Commande non reconnue. Tapez I ou D.");
|
||||
return;
|
||||
}
|
||||
if (saisie === null) return;
|
||||
var creepMm = parseFloat(saisie) || 0;
|
||||
|
||||
if (reste !== 0) {
|
||||
CDImp.Livret.ajouterPagesBlanches(doc, 4 - reste, "fin");
|
||||
@@ -285,19 +258,14 @@ CDImp.Livret.lancer = function (doc) {
|
||||
}
|
||||
|
||||
var planches = CDImp.Livret.calculerOrdre(nPages);
|
||||
|
||||
var destDoc;
|
||||
try {
|
||||
destDoc = CDImp.Livret.construireDocument(doc, planches, creepMm);
|
||||
} catch (e) {
|
||||
app.alert("Erreur lors de la construction du livret : " + e.toString());
|
||||
return;
|
||||
}
|
||||
var destDoc = CDImp.Livret.construireDocument(doc, planches, creepMm);
|
||||
|
||||
if (CDImp.Auto && CDImp.Auto.enregistrerDerniereAction) {
|
||||
CDImp.Auto.enregistrerDerniereAction("Livret.imposer", { creepMm: creepMm });
|
||||
}
|
||||
|
||||
app.alert("Livret cree avec succes (" + planches.length + " planches).\nPensez a l'enregistrer sous un nouveau nom.");
|
||||
|
||||
CDImp.Util.info("Livret cree avec succes (" + planches.length + " planches).\nPensez a l'enregistrer (Ctrl+S) sous un nouveau nom.");
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user