|
19 | 19 | extendMeadCoNamespace(name, definition); |
20 | 20 | })('MeadCo.ScriptX.Print', function () { |
21 | 21 | // module version and the api we are coded for |
22 | | - var version = "1.5.8.0"; |
| 22 | + var version = "1.5.9.0"; |
23 | 23 | var htmlApiLocation = "v1/printHtml"; |
24 | 24 | var pdfApiLocation = "v1/printPdf"; |
25 | 25 |
|
26 | 26 | // default printer |
27 | 27 | var printerName = ""; |
28 | 28 |
|
29 | 29 | /** |
30 | | - * Enum to describe the units used on measurements |
| 30 | + * Enum to describe the units used on measurements. Please be aware that (sadly) these enum values do *not* match |
| 31 | + * the values by the MeadCo ScriptX COM Servers. Please use MeadCo.ScriptX.MeasurementUnits (declared in MeadCoScriptJS) form compatibility |
31 | 32 | * |
32 | 33 | * @memberof MeadCoScriptXPrint |
33 | 34 | * @typedef {number} MeasurementUnits |
34 | 35 | * @enum {MeasurementUnits} |
35 | 36 | * @readonly |
36 | 37 | * @property {number} DEFAULT 0 use the default at the print server |
37 | | - * @property {number} MM 1 millimeters |
38 | | - * @property {number} INCHES 2 |
| 38 | + * @property {number} INCHES 1 |
| 39 | + * @property {number} MM 2 millimeters |
39 | 40 | */ |
40 | 41 | var enumMeasurementUnits = { |
41 | 42 | DEFAULT: 0, |
|
295 | 296 | var devInfo; |
296 | 297 |
|
297 | 298 | if (content === null || typeof content === "undefined" || (typeof content === "string" && content.length === 0)) { |
298 | | - MeadCo.ScriptX.Print.reportError("Request to print no content - access denied?"); |
| 299 | + MeadCo.ScriptX.Print.reportError("Request to print no content - access denied?"); |
299 | 300 | if (typeof fnDone === "function") { |
300 | 301 | fnDone("Request to print no content"); |
301 | 302 | } |
|
318 | 319 | }; |
319 | 320 |
|
320 | 321 | var serverApi = MeadCo.makeApiEndPoint(server, htmlApiLocation); |
321 | | - return printAtServer(serverApi,requestData, |
322 | | - { |
323 | | - fail: function (jqXhr, textStatus, errorThrown) { |
324 | | - var err = MeadCo.parseAjaxError("MeadCo.ScriptX.Print.printHtmlAtServer", jqXhr, textStatus, errorThrown); |
325 | | - progress(requestData, enumPrintStatus.ERROR, err); |
326 | | - MeadCo.ScriptX.Print.reportError(err); |
327 | | - if (typeof fnDone === "function") { |
328 | | - fnDone("Server error"); |
329 | | - } |
330 | | - }, |
331 | | - |
332 | | - queuedToFile: function (data) { |
333 | | - MeadCo.log("default handler on queued to file response"); |
334 | | - progress(requestData, enumPrintStatus.QUEUED); |
335 | | - monitorJob(serverApi,requestData, data.jobIdentifier, |
336 | | - -1, |
337 | | - function (data) { |
338 | | - if (data !== null) { |
339 | | - MeadCo.log("Will download printed file"); |
340 | | - progress(requestData, enumPrintStatus.COMPLETED); |
341 | | - window.open(server + "/download/" + data.jobIdentifier, "_self"); |
342 | | - } |
| 322 | + return printAtServer(serverApi, requestData, |
| 323 | + { |
| 324 | + fail: function (jqXhr, textStatus, errorThrown) { |
| 325 | + var err = MeadCo.parseAjaxError("MeadCo.ScriptX.Print.printHtmlAtServer", jqXhr, textStatus, errorThrown); |
| 326 | + progress(requestData, enumPrintStatus.ERROR, err); |
| 327 | + MeadCo.ScriptX.Print.reportError(err); |
| 328 | + if (typeof fnDone === "function") { |
| 329 | + fnDone("Server error"); |
| 330 | + } |
| 331 | + }, |
343 | 332 |
|
344 | | - if (typeof fnDone === "function") { |
345 | | - fnDone(data === null ? "Server error" : null); |
346 | | - } |
347 | | - }); |
348 | | - }, |
349 | | - |
350 | | - queuedToDevice: function (data) { |
351 | | - MeadCo.log("print was queued to device"); |
352 | | - progress(requestData, enumPrintStatus.QUEUED); |
353 | | - monitorJob(serverApi,requestData, data.jobIdentifier, |
354 | | - -1, |
355 | | - function (data) { |
356 | | - if (data !== null) { |
357 | | - progress(requestData, enumPrintStatus.COMPLETED); |
358 | | - } |
| 333 | + queuedToFile: function (data) { |
| 334 | + MeadCo.log("default handler on queued to file response"); |
| 335 | + progress(requestData, enumPrintStatus.QUEUED); |
| 336 | + monitorJob(serverApi, requestData, data.jobIdentifier, |
| 337 | + -1, |
| 338 | + function (data) { |
| 339 | + if (data !== null) { |
| 340 | + MeadCo.log("Will download printed file"); |
| 341 | + progress(requestData, enumPrintStatus.COMPLETED); |
| 342 | + window.open(server + "/download/" + data.jobIdentifier, "_self"); |
| 343 | + } |
359 | 344 |
|
360 | | - if (typeof fnDone === "function") { |
361 | | - fnDone(data === null ? "Server error" : null); |
362 | | - } |
363 | | - }); |
364 | | - }, |
365 | | - |
366 | | - softError: function (data) { |
367 | | - progress(requestData, enumPrintStatus.ERROR, data.message); |
368 | | - MeadCo.ScriptX.Print.reportError(data.message); |
369 | | - MeadCo.log("print has soft error"); |
370 | | - removeJob(data.jobIdentifier); |
371 | | - if (typeof fnDone === "function") { |
372 | | - MeadCo.log("Call fnDone"); |
373 | | - fnDone("Server error"); |
374 | | - } |
375 | | - }, |
| 345 | + if (typeof fnDone === "function") { |
| 346 | + fnDone(data === null ? "Server error" : null); |
| 347 | + } |
| 348 | + }); |
| 349 | + }, |
376 | 350 |
|
377 | | - ok: function (data) { |
378 | | - progress(requestData, enumPrintStatus.COMPLETED); |
379 | | - MeadCo.log("printed ok, no further information"); |
380 | | - if (typeof fnDone === "function") { |
381 | | - fnDone(null); |
| 351 | + queuedToDevice: function (data) { |
| 352 | + MeadCo.log("print was queued to device"); |
| 353 | + progress(requestData, enumPrintStatus.QUEUED); |
| 354 | + monitorJob(serverApi, requestData, data.jobIdentifier, |
| 355 | + -1, |
| 356 | + function (data) { |
| 357 | + if (data !== null) { |
| 358 | + progress(requestData, enumPrintStatus.COMPLETED); |
| 359 | + } |
| 360 | + |
| 361 | + if (typeof fnDone === "function") { |
| 362 | + fnDone(data === null ? "Server error" : null); |
| 363 | + } |
| 364 | + }); |
| 365 | + }, |
| 366 | + |
| 367 | + softError: function (data) { |
| 368 | + progress(requestData, enumPrintStatus.ERROR, data.message); |
| 369 | + MeadCo.ScriptX.Print.reportError(data.message); |
| 370 | + MeadCo.log("print has soft error"); |
| 371 | + removeJob(data.jobIdentifier); |
| 372 | + if (typeof fnDone === "function") { |
| 373 | + MeadCo.log("Call fnDone"); |
| 374 | + fnDone("Server error"); |
| 375 | + } |
| 376 | + }, |
| 377 | + |
| 378 | + ok: function (data) { |
| 379 | + progress(requestData, enumPrintStatus.COMPLETED); |
| 380 | + MeadCo.log("printed ok, no further information"); |
| 381 | + if (typeof fnDone === "function") { |
| 382 | + fnDone(null); |
| 383 | + } |
382 | 384 | } |
383 | | - } |
384 | | - }); |
| 385 | + }); |
385 | 386 | } |
386 | 387 |
|
387 | 388 | /** |
|
428 | 429 |
|
429 | 430 | var serverApi = MeadCo.makeApiEndPoint(server, pdfApiLocation); |
430 | 431 |
|
431 | | - return printAtServer(serverApi,requestData, |
| 432 | + return printAtServer(serverApi, requestData, |
432 | 433 | { |
433 | 434 | fail: function (jqXhr, textStatus, errorThrown) { |
434 | 435 | var err = MeadCo.parseAjaxError("MeadCo.ScriptX.Print.printPdfAtServer", jqXhr, textStatus, errorThrown); |
|
442 | 443 | queuedToFile: function (data) { |
443 | 444 | MeadCo.log("default handler on queued to file response"); |
444 | 445 | progress(requestData, enumPrintStatus.QUEUED); |
445 | | - monitorJob(serverApi,requestData, data.jobIdentifier, |
| 446 | + monitorJob(serverApi, requestData, data.jobIdentifier, |
446 | 447 | -1, |
447 | 448 | function (data) { |
448 | 449 | if (data !== null) { |
|
460 | 461 | queuedToDevice: function (data) { |
461 | 462 | MeadCo.log("print was queued to device"); |
462 | 463 | progress(requestData, enumPrintStatus.QUEUED); |
463 | | - monitorJob(serverApi,requestData, data.jobIdentifier, |
| 464 | + monitorJob(serverApi, requestData, data.jobIdentifier, |
464 | 465 | -1, |
465 | 466 | function (data) { |
466 | 467 | if (data !== null) { |
|
547 | 548 | resolve(data); |
548 | 549 | }) |
549 | 550 | .fail(function (jqXhr, textStatus, errorThrown) { |
550 | | - errorThrown = MeadCo.parseAjaxError("MeadCo.ScriptX.Print.testServerConnection:",jqXhr, textStatus, errorThrown); |
| 551 | + errorThrown = MeadCo.parseAjaxError("MeadCo.ScriptX.Print.testServerConnection:", jqXhr, textStatus, errorThrown); |
551 | 552 | if (typeof reject === "function") |
552 | 553 | reject(errorThrown); |
553 | 554 | }); |
|
692 | 693 | * @param {function({object})} functionComplete function to call when job is complete. Argument is null on error, the data returned from the status call on success,. |
693 | 694 | * @private |
694 | 695 | */ |
695 | | - function monitorJob(serverAndApi,requestData, jobId, timeOut, functionComplete) { |
| 696 | + function monitorJob(serverAndApi, requestData, jobId, timeOut, functionComplete) { |
696 | 697 | MeadCo.log("monitorJob: " + jobId); |
697 | 698 | var counter = 0; |
698 | 699 | var interval = 1000; |
|
932 | 933 | if (!syncInit) { |
933 | 934 | MeadCo.log("Async connectlite..."); |
934 | 935 | licenseApi.connectLite(server, data.meadcoLicense, |
935 | | - data.meadcoLicenseRevision, |
936 | | - data.meadcoLicensePath); |
| 936 | + data.meadcoLicenseRevision, |
| 937 | + data.meadcoLicensePath); |
937 | 938 | printApi.connectLite(server, data.meadcoLicense); |
938 | 939 | } else { |
939 | 940 | console |
940 | 941 | .warn("Synchronous connection is deprecated, please use data-meadco-syncinit='false'"); |
941 | 942 | licenseApi.connect(server, data.meadcoLicense); |
942 | 943 | if (typeof data.meadcoLicensePath !== "undefined" && |
943 | 944 | typeof data |
944 | | - .meadcoLicenseRevision !== |
| 945 | + .meadcoLicenseRevision !== |
945 | 946 | "undefined") { // if these are not defined then you must use meadco-secmgr.js |
946 | 947 | licenseApi.apply(data.meadcoLicense, |
947 | 948 | data.meadcoLicenseRevision, |
|
990 | 991 | ErrorAction: enumErrorAction, |
991 | 992 |
|
992 | 993 | CollateOptions: enumCollateOptions, |
993 | | - DuplexOptions: enumDuplexOptions, |
| 994 | + DuplexOptions: enumDuplexOptions, |
994 | 995 | MeasurementUnits: enumMeasurementUnits, |
995 | 996 |
|
996 | 997 | /** |
|
0 commit comments