Advertisement
OSRSMargins

Untitled

Oct 4th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var job = {
  2.   //The artwork we are proofing after it has been clipped to avoid losing items.
  3.   name : 'Test',
  4.   artwork : "Test A/W",
  5.   legend : {
  6.     //The selected legend
  7.     proof : undefined,
  8.     //Print Material Selected
  9.     material : "Material",
  10.     //Leading Edge Selected
  11.     leading : undefined,
  12.     //Legend object
  13.     obj : undefined,
  14.     //Core Size
  15.     core : undefined,
  16.     //Number Per Roll
  17.     noPerRoll : undefined,
  18.     //Version No
  19.     version : undefined,
  20.     //Barcode no
  21.     barcode : undefined
  22.   },
  23.   dimentions : {
  24.     cutter : {
  25.       //Cutter width in PX/PT
  26.       width : undefined,
  27.       //Cutter height in PX/PT
  28.       height : undefined
  29.     },
  30.     artwork : {
  31.       //Artwork width in PX/PT
  32.       width : undefined,
  33.       //Artwork height in PX/PT
  34.       height : undefined
  35.     },
  36.     legend : {
  37.       width : undefined,
  38.       height : undefined
  39.     }
  40.   },
  41.   guides : {
  42.     //Corner radius
  43.     cutter : undefined,
  44.     shape : undefined,
  45.     corners : undefined,
  46.     labels : {
  47.       //Width Label. E.G: 180mm
  48.       width : undefined,
  49.       //Height Label. E.G: 180mm
  50.       hight : undefined
  51.     },
  52.     arrows : {
  53.       //True/False as to weather to add leading direction arrow
  54.       enabled : true,
  55.       //File path for the arrow file
  56.       file : {
  57.         right : path + "Assets/Arrows/Leading Arrow Right.pdf",
  58.         left : path + "Assets/Arrows/Leading Arrow Left.pdf",
  59.       },
  60.       //Text to be displayed along side the arrows
  61.       text : "LEAD DIRECTION"
  62.     }
  63.   }
  64. };
  65.  
  66. function ProofJob() {
  67.  
  68. };
  69.  
  70. ProofJob.prototype = {
  71.   getName : function() {
  72.     return job.name;
  73.   },
  74.  
  75.   setName : function(name) {
  76.     job.name = name;
  77.   },
  78.  
  79.   getCutterDimensions : function() {
  80.     return job.dimentions.cutter;
  81.   },
  82.  
  83.   setCutterDimensions : function(width, height) {
  84.     job.dimentions.cutter = {
  85.       width : width,
  86.       height : height
  87.     };
  88.     job.guides.labels = {
  89.       width: measurmentAsString(api.units.pxToMM(width)),
  90.       height: measurmentAsString(api.units.pxToMM(height))
  91.     };
  92.   },
  93.  
  94.   getCutterWidth : function() {
  95.     return job.dimentions.cutter.width;
  96.   },
  97.  
  98.   getCutterHeight : function() {
  99.     return job.dimentions.cutter.height;
  100.   },
  101.  
  102.   getWidthLabel : function() {
  103.     return job.guides.labels.width;
  104.   },
  105.  
  106.   getHeightLabel : function() {
  107.     return job.guides.labels.height;
  108.   },
  109.  
  110.   getSizeLabel : function() {
  111.     var leading = getLeading();
  112.     if (leading == "Right Hand Leading" && leading == "Left Hand Leading") {
  113.       return this.getHeightLabel() + " x " + this.getWidthLabel();
  114.     } else {
  115.       return this.getWidthLabel() + " x " + this.getHeightLabel();
  116.     }
  117.   },
  118.  
  119.   getArtworkDimensions : function() {
  120.     return job.dimentions.artwork;
  121.   },
  122.  
  123.   setArtworkDimensions : function(width, height) {
  124.     job.dimentions.artwork = {
  125.       width : width,
  126.       height : height
  127.     };
  128.   },
  129.  
  130.   getArtworkWidth : function() {
  131.     return job.dimentions.artwork.width;
  132.   },
  133.  
  134.   getArtworkHeight : function() {
  135.     return job.dimentions.artwork.height;
  136.   },
  137.  
  138.   getLegendDimentions : function() {
  139.     return job.dimentions.legend;
  140.   },
  141.  
  142.   setLegendDimentions : function(width, height) {
  143.     job.dimentions.legend = {
  144.       width : width,
  145.       height : height
  146.     }
  147.   },
  148.  
  149.   getLegendWidth : function() {
  150.     return job.dimentions.legend.width;
  151.   },
  152.  
  153.   getLegendHeight : function() {
  154.     return job.dimentions.legend.height;
  155.   },
  156.  
  157.   getCornerRadius : function() {
  158.     return job.guides.corners;
  159.   },
  160.  
  161.   setCornerRadius : function(radius) {
  162.     job.guides.corners = radius;
  163.   },
  164.  
  165.   getShape : function() {
  166.     return job.guides.shape;
  167.   },
  168.  
  169.   setShape : function(shape) {
  170.     job.guides.shape = shape;
  171.   },
  172.  
  173.   getMaterial : function() {
  174.     return job.legend.material;
  175.   },
  176.  
  177.   setMaterial : function(material) {
  178.     job.legend.material = material;
  179.   },
  180.  
  181.   getLeading : function() {
  182.     return job.legend.leading;
  183.   },
  184.  
  185.   setLeading : function(leading) {
  186.     job.legend.leading = leading;
  187.   },
  188.  
  189.   getVersion : function() {
  190.     return job.legend.version;
  191.   },
  192.  
  193.   setVersion : function(version) {
  194.     job.legend.version = version;
  195.   },
  196.  
  197.   getBarcode : function() {
  198.     return job.legend.barcode;
  199.   },
  200.  
  201.   setBarcode : function(barcode) {
  202.     job.legend.barcode = barcode;
  203.   },
  204.  
  205.   getCore : function() {
  206.     return job.legend.core;
  207.   },
  208.  
  209.   setCore : function(core) {
  210.     job.legend.core = core;
  211.   },
  212.  
  213.   getNoPerRoll : function() {
  214.     return job.legend.noPerRoll;
  215.   },
  216.  
  217.   setNoPerRoll : function(noPerRoll) {
  218.     job.legend.noPerRoll = noPerRoll;
  219.   },
  220.  
  221.   getDate : function() {
  222.     return api.util.dateString();
  223.   },
  224.  
  225.   getProof : function() {
  226.     return job.legend.proof;
  227.   },
  228.  
  229.   setProof : function(proof) {
  230.     job.legend.proof = proof;
  231.   },
  232.  
  233.   getProofObject : function() {
  234.     return job.legend.obj;
  235.   },
  236.  
  237.   setProofObject : function(obj) {
  238.     alert(job.name);
  239.     alert(job.legend.material);
  240.     job.legend.obj = obj;
  241.     var dimentions = api.util.dimentions(api.util.visibleBounds(obj));
  242.     this.setLegendDimentions(dimentions.width, dimentions.height);
  243.   },
  244.  
  245.   getArtworkObject : function() {
  246.     return job.artwork;
  247.   },
  248.  
  249.   setArtworkObject : function(artwork) {
  250.     job.artwork = artwork;
  251.   },
  252.  
  253.   getArrows : function() {
  254.     return job.guides.arrows.enabled;
  255.   },
  256.  
  257.   setArrows : function(arrows) {
  258.     job.guides.arrows.enabled = arrows;
  259.   },
  260.  
  261.   getLeftArrowFile : function() {
  262.     return job.guides.arrows.file.left;
  263.   },
  264.  
  265.   getRightArrowFile : function() {
  266.     return job.guides.arrows.file.right;
  267.   },
  268.  
  269.   getCustomCutter : function() {
  270.     return job.guides.cutter;
  271.   },
  272.  
  273.   setCustomCutter : function(cutter) {
  274.     job.guides.cutter = cutter;
  275.   }
  276. }
  277.  
  278. /*
  279. * Helpful methods
  280. */
  281.  
  282. function measurmentAsString(measurement) {
  283.   var string = "" + measurement.toFixed(2);
  284.   if (string.indexOf(".00") !== -1) string = string.replace(".00", "");
  285.   if (string.indexOf(".") !== -1 && string.charAt(string.length - 1) == "0") string = string.slice(0, string.length - 1);
  286.   return string + "mm";
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement