1WAREZVERSION = "7.2"; 2console.log("WAREZ-PRINTABLE V"+WAREZVERSION); 3 4 var customizerMenuSet = "regular"; 5 var warezCustomizer = null; 6 var editor = null; 7 var sourcePdfConf = []; 8 var localUrl = "https://h2.customerscanvas.com/Users/fa124c7e-1832-4d47-95f0-528da8115891//" 9// var localUrl = "https://h2.customerscanvas.com/Users/fa124c7e-1832-4d47-95f0-528da8115891/" 10 11 //"https://h2.customerscanvas.com/Users/1155cc2f-a00a-400f-a274-07120fe1a444/"; //"https://h2.customerscanvas.com/Users/fa124c7e-1832-4d47-95f0-528da8115891/"; 12 13 var previewUrl = localUrl + "api/Preview/GeneratePreview"; 14 var hiresUrl = localUrl + "PsdWebService/api/rendering/hires"; //"PsdWebService"; //"/api/hires?disablecache=true"; 15 var hiresJPGURL = localUrl + "PsdWebService/api/rendering/hires?disablecache=true"; 16 17 var HI_RES_JPG = null; 18 var HI_RES_STUFF = null; 19 20//https://customerscanvas.com/dev/sdks/design-editor-js/reference/IframeApi/index.html 21 22var modeset = "default"; 23var watermark_set = jQuery("#hwtmlcheck").val(); 24 25if(watermark_set == "") watermark_set = false; 26 27 28var sourcePdfConf = { 29 "flyer": { 30 "type": "image", 31 "image": null, 32 //"rotate": 0, 33 "resizeMode": "Fit", //Fill 34 "format": "jpg" 35 }, 36 "crop marks\\crop": { 37 "type": "shape", 38 "visible": false 39 }//,"rotate": 90 40}; 41 var watermark = {}; 42 if(watermark_set) { 43 var watermark = { 44 // The watermark configuration. 45 text: { 46 /* 47 text: "", 48 fontSettings: { 49 postScriptName: "ArialMT", 50 fauxBold: false, 51 fauxItalic: false 52 },*/ 53 scale: 0.28, 54 opacity: 0.5 55 }, 56 image: { 57 name: "watermark-h.png", 58 repeat: true, 59 opacity: 0.5 60 }, 61 visibility: { 62 proof: true, 63 canvas: true 64 } 65 } 66 } 67 68var templateSets = { 69 "2.5x4": { 70 "Portrait": { 71 "1UP" : { template: "templates/HWTM-Favor-Portrait-1Up.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 72 "6UP" : { template: "templates/HWTM-Favor-Portrait-6Up.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 73 74 } 75 }, 76 "3x3.875": { 77 "Portrait": { 78 "1UP" : { template: "templates/HWTM-Mini-Portrait-1Up.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 79 "6UP" : { template: "templates/HWTM-Mini-Portrait-6Up.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 80 81 }, 82 "Landscape": { 83 "1UP" : { template: "templates/HWTM-Mini-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 84 "6UP" : { template: "templates/HWTM-Mini-Portrait-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 85 86 } 87 }, 88 "4x5": { 89 "Portrait": { 90 "1UP" : { template: "templates/HWTM-4x5-Portrait-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 91 "2UP" : { template: "templates/HWTM-4x5-Portrait-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 92 "4UP" : { template: "templates/HWTM-4x5-Portrait-4UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 93 }, 94 "Landscape": { 95 "1UP" : { template: "templates/HWTM-4x5-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 96 "2UP" : { template: "templates/HWTM-4x5-Landscape-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 97 "4UP" : { template: "templates/HWTM-4x5-Landscape-4UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 98 } 99 }, 100 "4x6": { 101 "Portrait": { 102 "1UP" : { template: "templates/HWTM-4x6-Portrait-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 103 "2UP" : { template: "templates/HWTM-4x6-Portrait-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 104 }, 105 "Landscape": { 106 "1UP" : { template: "templates/HWTM-4x6-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 107 "2UP" : { template: "templates/HWTM-4x6-Landscape-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 108 } 109 }, 110 111 "5x7": { 112 "Portrait": { 113 "1UP" : { template: "templates/HWTM-5x7-Portrait-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 114 "2UP" : { template: "templates/HWTM-5x7-Portrait-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 115 }, 116 "Landscape": { 117 "1UP" : { template: "templates/HWTM-5x7-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 118 "2UP" : { template: "templates/HWTM-5x7-Landscape-2UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 119 } 120 }, 121 "8x10" : { 122 "Portrait": { 123 "1UP": { template: "templates/HWTM-8x10-Portrait-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 124 }, 125 "Landscape": { 126 "1UP": { template: "templates/HWTM-8x10-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 127 "2UP": { template: "templates/HWTM-8x10-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } } 128 } 129 }, 130 "8.5x11": { 131 "Portrait": { 132 "1UP" : { template: "templates/HWTM-Letter-Portrait-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 133 }, 134 "Landscape": { 135 "1UP" : { template: "templates/HWTM-Letter-Landscape-1UP.psd", Data: sourcePdfConf, format: "jpg", Size: { height: 800 } }, 136 } 137 }, 138 139 140 "Portrait": { 141 one : "imposition/letter-full.psd", 142 two : "imposition/hwtm-2up2.psd", 143 four: "imposition/hwtm-4up.psd" 144 }, 145 "Landscape": { 146 one: "imposition/hwtm-full-landscape.psd", 147 two : "imposition/hwtm-2up2.psd", 148 four: "imposition/hwtm-4up.psd" 149 } 150} 151 152 153//We will build on these. 154var myLayouts = {} 155var multiOptionDisplay = false;
156var hasMultipleLayouts = false; //jQuery(".custom_download_opt").length > 0; 157var displayMode = "Portrait"; 158var displaySize = "5x7"; 159 160var allowedSizes = ['2.5x4', '3x3.875', '4x5', '4x6', '5x7', '8x10', '8.5x11']; 161var allowedUp = ['1UP', '2UP', '4UP', '6UP']; 162var hasUps = ['1UP']; 163 164 165function load_customizer_frame(frame, designs, th) { 166 167 168 productDefinition = { 169 //This safety line is applied to all surfaces of the product. 170 defaultSafetyLines: [{ 171 margin: 8.5, 172 color: 'rgba(0,255,0,255)', 173 altColor: 'rgba(255,255,255,0)', 174 stepPx: 5, 175 widthPx: 1 176 }], 177 surfaces: [designs] 178 179 /* 180 surfaces: [ 181 //The first surface - a front side of the business card. 182 { 183 printAreas: [{ designFile: "BusinessCard2_side1" }] 184 }, 185 //The second surface - a back side of the business card. 186 { 187 printAreas: [{ designFile: "BusinessCard2_side2" }] 188 }]*/ 189 }; 190 191 theDesign = designs; 192 modeset = (jQuery(th).hasClass("tryoutmode")) ? "trial" : "reg"; 193 194 jQuery("#previewCustomizer, #saveCustomizer").addClass("disabled").hide(); 195 jQuery("#downloadhref, #perpagesetup").hide(); 196 jQuery("#format_type_one, #custom_download_opt_one").click(); 197 198 199 hasMultipleLayouts = false; //Reset... 200 multiOptionDisplay = false; 201 revertToSrc(jQuery(".previewpics")); //Need to test this. 202 hasUps = ['1UP']; 203 204 var attributes = jQuery(th).data("attri"); 205 var devMode = jQuery(th).hasClass("devmodeenabled"); 206 207 //Is the design Landscape or Portrait? 208 if(attributes.indexOf("Landscape")!= -1) { 209 displayMode = "Landscape"; 210 } 211 212 //What size is the design? 213 for (i = 0; i < allowedSizes.length; i++) { 214 if(attributes.indexOf(allowedSizes[i])!=-1) { 215 displaySize = allowedSizes[i]; 216 break; 217 } 218 } 219 //Setup which ones are allowed to see for UP's. 220 for (i = 0; i < allowedUp.length; i++) { 221 if(attributes.indexOf(allowedUp[i])!=-1) { 222 hasUps.push( allowedUp[i] ); 223 } 224 } 225 226 jQuery(".wpoptrad").hide(); 227 for(i=0; i<hasUps.length; i++) { 228 //console.log(hasUps[i]); 229 jQuery(".w"+hasUps[i]).show(); 230 } 231 232 if(hasUps.length > 1) { 233 hasMultipleLayouts = true; 234 } 235 236 myLayouts = JSON.parse(JSON.stringify( templateSets[displaySize][displayMode] )); 237 238 if(jQuery("body").hasClass("logged-in")) { 239 uid = window.current_user_id; 240 }else{ 241 uid = Date.now() + getRandomInt(1000); 242 } 243 244 //If we have determined them to have multiple layouts... 245 //Display multiple option display versus single PDF download. 246 if(hasMultipleLayouts) { 247 multiOptionDisplay = true; 248 }else{ 249 //If we are not a multi layout, but have templates we want to fit within. 250 multiOptionDisplay = (attributes != ""); 251 jQuery('#perpagesetup, #saveCustomizer, #previewCustomizer').hide(); 252 } 253 254 fileFormat = (multiOptionDisplay)?"JPG":"PDF" 255 256 print_rendering = { 257 hiResOutputColorSpace: "RGB", 258 hiResOutputFileFormat: fileFormat, 259 hiResOutputDpi: 300 260 } 261 262 configuration = { 263 initialMode : "Advanced",
264 "widgets": { "FinishButton": { "mode": "Disabled"}, 265 /* 266 "ColorPicker": { 267 "sectionCollapseEnabled": false, 268 "showPaletteOnly": false, 269 "defaultColorSpace": "cmyk", 270 "availableColorSpaces": ["cmyk"], 271 "sections": [ 272 { 273 "type": "NoColorSection", 274 "targets": ["Fill", "Border", "Background"] 275 }, 276 { 277 "type": "RecentSection" 278 }, 279 { 280 "type": "PaletteSection", 281 "palette": [ 282 [ 283 "cmyk(0%, 100%, 100%, 0%, 100%)", 284 "cmyk(0%, 0%, 100%, 0%, 100%)", 285 "cmyk(100%, 0%, 100%, 0%, 100%)", 286 "cmyk(100%, 0%, 0%, 0%, 100%)", 287 "cmyk(100%, 100%, 0%, 0%, 100%)", 288 "cmyk(0%, 100%, 0%, 0%, 100%)", 289 "cmyk(40%, 100%, 45%, 25%, 100%)" 290 ] 291 ] 292 } 293 */ 294 }, 295 /* customStyle: "warez_overrides",*/ 296 userId: uid, 297 preloader: { 298 enabled: false, 299 firstTimeMessage: "Wait a moment. The product is being configured for the first launch.", 300 errorMessage: "An error occurred!" 301 }, 302 rendering: print_rendering, 303 "violationWarningsSettings": { 304 "qualityMeter": { 305 "enabled": true, 306 "qualityLevels": { 307 "warning": 100, 308 "bad": 50 309 } 310 }, 311 "regionViolationWarningEnabled": false, 312 //saveCustomizer"safetyLines": true, 313 "textCropViolationWarningEnabled": true, 314 "shapeViolationsEnabled": true 315 } 316 } 317 318 jQuery(".warez_holder .loading .loading_text_customizer").html("<div class='preparepreview'></div>"); 319 jQuery(".warez_holder .loading").show(); 320 321 //NEW CODE SEGMENT TRYING TO GET THIS TO WORK... 322 //document.addEventListener('DOMContentLoaded', async () => { 323 let product = { 324 defaultSafetyLines: [{ 325 margin: 8.5, 326 //color: 'rgba(0,255,0,255)', 327 //altColor: 'rgba(255,255,255,0)', 328 stepPx: 5, 329 widthPx: 1 330 }], 331 "surfaces": [{ 332 "printAreas": [{ 333 "designFile": theDesign 334 }], 335 336 }]/*, 337 "mockup": { 338 "down": "samples/test-page" 339 }*/ 340 }; 341 342 let config = { 343 "autoLoadUserInfo": true, 344 "userInfo": { 345 //"Image": "public:samples/test-page/Image.jpg" 346 } 347 }; 348 349 //document.getElementById("version-box").innerText = "version " + CustomersCanvas.VERSION; 350 351 // Customer's Canvas is loaded with this line. See the JSON objects above for params. 352 var editor = CustomersCanvas.IframeApi.loadEditor( 353 document.getElementById("warez_customizer_frame"), product, configuration).then(function(e) { 354 setTimeout(function(){ jQuery("#warez_customizer_frame").show();// console.log("loading done."); 355 jQuery(".warez_holder .loading").hide(); 356 if(multiOptionDisplay) { 357 jQuery("#previewCustomizer").removeClass('disabled').show(); 358 }else{ 359 jQuery("#saveCustomizer").removeClass('disabled').show(); 360 } 361 //modeset = 'live'; //turn this off once in prod mode. 362 if (modeset != "trial") { 363 if (multiOptionDisplay) { 364 jQuery("#previewCustomizer") 365 .removeClass('disabled') 366 .show(); 367 } else { 368 console.log(e); 369 370 configuration.widgets = { "FinishButton": { "mode": "Disabled"} }; 371 372 editor.updateConfiguration(configuration); 373 jQuery("#saveCustomizer") 374 .removeClass('disabled') 375 .show(); 376 } 377 jQuery("#popPurchase").hide(); 378 jQuery("#demomode_message").hide(); 379 } else { 380 jQuery("#saveCustomizer, #previewCustomizer") 381 .hide(); 382 jQuery("#popPurchase").show(); 383 jQuery("#demomode_message").show(); 384 } 385 386 }, 1000); 387 388 warezCustomizer = e; 389 editor = e; 390 console.log("Canvas Loaded..."); 391 }); 392 393 394 395 /*document.getElementById("finish").removeAttribute("disabled"); 396 397 document.getElementById('finish').addEventListener('click', async () => { 398 let result = await editor.finishProductDesign(); 399 console.log("finishProductDesign returned this structure: ", result); 400 let link = document.createElement("a"); 401 link.style = "position:absolute; top:-99999999; left:-9999999; visibility:hidden"; 402 link.download = 'printfile.pdf'; 403 link.href = result.hiResOutputUrls[0]; 404 document.body.appendChild(link); 405 link.click(); 406 document.body.removeChild(link); 407 });*/ 408 //}); 409 410 } 411 412 document.addEventListener('DOMContentLoaded', async () => { 413 414 415 jQuery(".saveCustomizer").click(function(){ 416 //Saving a product to the StateFileName.st file. 417 418 if(warezCustomizer == null){ 419 // return false;
420 } 421 console.log("SAVING"); 422 423 424 //{fileName: "DesignHero"} 425 result = warezCustomizer.finishProductDesign() 426 //If product customization is completed successfully. 427 .then(function (result) { 428 console.log(result); 429 430 console.log("Pass to reopen the design (private design id and user id accordingly): ", result.stateId, result.userId); 431 console.log("Links to print-ready files: ", result.hiResUrls); 432 console.log("Links to proof images: ", result.proofImageUrls); 433 hiResOutputUrls = result.hiResOutputUrls; 434 proofImageUrls = result.proofImageUrls; 435 stateId = result.stateId; 436 returnToEditUrl = result.returnToEditUrl; 437 boundsData = result.boundsData; 438 userChanges = result.userChanges; 439 //console.log(hiResOutputUrls); 440 441 var anchor = document.createElement('a'); 442 anchor.href = hiResOutputUrls[0]; 443 anchor.target = '_blank'; 444 anchor.download = hiResOutputUrls[0]; 445 anchor.click(); 446 447 448 jQuery("#downloadhref").attr("href", hiResOutputUrls[0]); 449 jQuery("#downloadhref").html("Click Here if your download does not start."); 450 jQuery("#downloadhref").show(); 451 452 }).catch(function (error) { 453 console.error("Completing product customization failed with exception: ", error); 454 }); 455 456 }); 457 458 459 }); 460 461 462 function getRandomInt(max) { 463 return Math.floor(Math.random() * Math.floor(max)); 464 } 465 466 function popup(mylink, windowname) { if (! window.focus)return true; var href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; window.open(href, windowname, 'width=1000,height=700,scrollbars=yes,menubar=no,location=no,directories=no'); return false; } 467 468 function canvas_api_call(URI, DATA, CALLBACK, DELAY) { 469 jQuery.ajax({ 470 url: URI, 471 type: "POST", 472 contentType: 'application/json; charset=utf-8', 473 dataType: 'json', 474 // headers: {"X-CustomersCanvasAPIKey": "warezprintablesv1"} 475 data: JSON.stringify(DATA) 476 }).done(function(d){ 477 setTimeout(function(){ 478 CALLBACK(d); 479 }, DELAY); 480 }); 481 } 482 483 function getPreview(design, callback) { 484 canvas_api_call(previewUrl, design, callback, 0); 485 } 486 487 function getDesign(design, callback) { 488 canvas_api_call(hiresUrl, design, callback, 2000); 489 } 490 491jQuery().ready(function () { 492 493 //if(get_warez_cookie == "") { 494 //console.log("Setting cookie."); 495 //setCookie("whwtmsub" 1, 1); 496 //} 497 498 jQuery("#privacy_policy_field input").prop("checked", "checked"); 499 500 if( jQuery("#payment_method_ppec_paypal").length ) { 501 //warez_check_paypal(); 502 } 503 504 //Once things are done we want to make sure this triggers.. 505 var checkFixer = setInterval(function(){ 506 loaded = true; 507 jQuery(".fixit .avada-product-gallery-thumbs-wrapper img").each(function(i,v){ 508 if(jQuery(this).attr("src") == "") { 509 loaded = false; 510 } 511 }); 512 if(loaded == true) { 513 jQuery(".fixit .avada-product-gallery-thumbs-wrapper").css("height", "110px"); 514 jQuery(".fixit .avada-product-gallery .flex-control-thumbs").css("opacity", ""); 515 516 clearInterval(checkFixer); 517 } 518 519 }, 500); 520 521 jQuery(".fixit .avada-product-gallery-thumbs-wrapper").addClass("readySet"); 522 jQuery(".fixit .avada-product-gallery-thumbs-wrapper").css("height", "110px"); 523 524 jQuery(".warez_close").click(function(){ 525 jQuery(this).parents(".warez_popup").find(".warez_step").hide(); 526 jQuery(this).parents(".warez_popup").hide(); 527 jQuery(this).parents(".warez_customizer").hide(); 528 529 jQuery(".customizer_preview_menu").show(); 530 jQuery(".custom_download_opt:first").prop("checked","checked"); 531 532 jQuery("#customizerDownload").hide(); 533 jQuery(".warez_screen").hide(); 534 }); 535 536 537 jQuery(".woocommerce-account .cancel").click(function(){ 538 if(confirm("Are you sure you want to cancel your subscription?\n"+ 539 "Doing so will end all access immediately.") ) { 540 return true; 541 }else{ 542 return false;
543 } 544 }); 545 546 /* Old code will be removeing once we migrate to the new step process... */ 547 548 //Second ROUTE 549 550 jQuery("#gobacktocustomizer").click(function () { 551 //warezCustomizer.revertProduct(); 552 currentPage = "design"; 553 jQuery(".customizer_preview_menu").show(); 554 jQuery(".warez_step").hide(); 555 jQuery("#approve-page").hide(); 556 jQuery("#warez_customizer_frame").fadeIn(); 557 }); 558 559 jQuery("#finalizecustom").click(function () { 560 jQuery(".warez_holder #approve-page").hide(); 561 //jQuery(".warez_holder .loading .loading_text_customizer").html("Preparing to Download"); 562 //jQuery(".warez_holder .loading").show(); 563 //jQuery(".warez_holder #customizerDownload").show(); 564 customDesignSwitch("hires"); 565 //getPDF(); 566 }); 567 568 jQuery(".custom_download_type").click(function() { 569 if(jQuery(this).val() == "pdf" && hasMultipleLayouts) { 570 jQuery("#perpagesetup").show(); 571 }else{ 572 jQuery("#custom_download_opt_one").click();//Revert to single option. 573 jQuery("#perpagesetup").hide(); 574 } 575 }); 576 577 //After selecting a layout they can then review designs. 578 jQuery("#previewCustomizer").click(function(){ 579 customDesignSwitch("preview"); 580 }); 581 582 jQuery(".custom_download_opt").click(function(){ 583 584 /* 585 switch(jQuery(this).val()) { 586 case "one": 587 jQuery("#custom_preview_single").show(); 588 jQuery("#custom_preview_two, #custom_preview_four, #custom_preview_six").hide(); 589 break; 590 591 case "two": 592 jQuery("#custom_preview_single, #custom_preview_four, #custom_preview_six").hide(); 593 jQuery("#custom_preview_two").show(); 594 break; 595 596 case "four": 597 jQuery("#custom_preview_single, #custom_preview_two, #custom_preview_six").hide(); 598 jQuery("#custom_preview_four").show(); 599 break; 600 601 case "six": 602 jQuery("#custom_preview_single, #custom_preview_two, #custom_preview_four").hide(); 603 jQuery("#custom_preview_six").show(); 604 break; 605 606 }*/ 607 608 warez_ready_check(); 609 610 }); 611 612 jQuery(".warez_ready_check").click(function(){ 613 warez_ready_check(); 614 }) 615 616 function customDesignSwitch(STEP) { 617 618 var downloadURI = "/warez/download.php?o=dh&n=DesignHero&p="+jQuery("#customizer_post_id").val(); 619 620 currentPage = STEP; 621 layoutName = jQuery(".custom_download_opt:checked").val(); 622 fileType = jQuery(".custom_download_type:checked").val(); 623 624 //console.log("CURRENT: "+STEP); 625 switch(STEP){ 626 case "preview": 627 jQuery(".customizer_preview_menu, #warez_customizer_frame").hide(); 628 jQuery(".warez_holder .loading .loading_text_customizer").html("<div class='preparepreview'></div>"); 629 jQuery(".warez_holder .loading").show(); 630 jQuery("#approveButton").addClass('disabled'); 631 632 var doProof = false; 633 634 if(doProof) { 635 editor.getProofImages().then(function (result) { 636 //Saving the proof images info. 637 approveData = result; 638 //console.log(result); 639 640 console.log("Proof finished"); 641 642 flipPreviewPic("#custom_preview_single", approveData['proofImageUrls'][0][0]); 643 644 if(jQuery(".custom_download_opt:checked").val() == "one") { 645 jQuery("#custom_preview_single").show(); 646 }else{ 647 jQuery("#custom_preview_single").hide(); 648 } 649 650 jQuery(".warez_holder .loading").hide(); 651 jQuery("#preview-page").fadeIn(); 652 653 myLayouts["1UP"]["Data"]["flyer"]["image"] = approveData['proofImageUrls'][0][0]; 654 655 //Should always have a 1UP in the template... 656 myLayouts["1UP"]["Size"]["height"] = 800; 657 myLayouts["1UP"]["Data"]["flyer"]["image"] = approveData['proofImageUrls'][0][0]; 658 659 660 if(jQuery.inArray("2UP", hasUps) != -1 && hasMultipleLayouts) { 661 /* 662 myLayouts["2UP"]["Size"]["height"] = 800; 663 myLayouts["2UP"]["Data"]["flyer"]["image"] = approveData['proofImageUrls'][0][0]; 664 665 //console.log("2UP preview..."); 666 //console.log(myLayouts["2UP"]); 667 668 getPreview(myLayouts["2UP"], function(d){ 669 //Do something with this... 670 flipPreviewPic("#custom_preview_two", d); 671 672 if(jQuery(".custom_download_opt:checked").val() == "two") { 673 jQuery("#custom_preview_two").show(); 674 }else{ 675 jQuery("#custom_preview_two").hide(); 676 } 677 });*/ 678 679 } 680 681 682 if(jQuery.inArray("4UP", hasUps) != -1 && hasMultipleLayouts) { 683 /* 684 myLayouts["4UP"]["Size"]["height"] = 800; 685 myLayouts["4UP"]["Data"]["flyer"]["image"] = approveData['proofImageUrls'][0][0]; 686 687 //console.log("2UP preview..."); 688 //console.log(myLayouts["2UP"]); 689 690 getPreview(myLayouts["4UP"], function(d){ 691 //Do something with this... 692 flipPreviewPic("#custom_preview_four", d); 693 694 if(jQuery(".custom_download_opt:checked").val() == "four") { 695 jQuery("#custom_preview_four").show(); 696 }else{ 697 jQuery("#custom_preview_four").hide(); 698 } 699 });*/ 700 701 } 702 703 if(jQuery.inArray("6UP", hasUps) != -1 && hasMultipleLayouts) { 704 /* 705 myLayouts["6UP"]["Size"]["height"] = 800; 706 myLayouts["6UP"]["Data"]["flyer"]["image"] = approveData['proofImageUrls'][0][0]; 707 708 //console.log("2UP preview..."); 709 //console.log(myLayouts["2UP"]); 710 711 getPreview(myLayouts["6UP"], function(d){ 712 //Do something with this... 713 flipPreviewPic("#custom_preview_six", d); 714 715 if(jQuery(".custom_download_opt:checked").val() == "six") { 716 jQuery("#custom_preview_six").show(); 717 }else{ 718 jQuery("#custom_preview_six").hide(); 719 } 720 });*/ 721 722 } 723 724 725 726 }).catch(function (error) { /* We will do something here @TODO's */ }); 727 } 728 729 //We are also going to do the final render "SINGLE" to speed up our finale. 730 warezCustomizer.finishProductDesign().then((result) => { 731 HI_RES_STUFF = result; 732 HI_RES_JPG = result.hiResOutputUrls[0]; 733 PREVIEW_JPG = result.proofImageUrls[0][0]; 734 735 flipPreviewPic("#custom_preview_single", PREVIEW_JPG); 736 737 if(jQuery(".custom_download_opt:checked").val() == "one") { 738 jQuery("#custom_preview_single").show(); 739 }else{ 740 jQuery("#custom_preview_single").hide(); 741 } 742 743 jQuery(".warez_holder .loading").hide(); 744 jQuery("#preview-page").fadeIn(); 745 jQuery("#customizer_one_jpg").val(HI_RES_JPG); 746 747 sourcePdfConf.flyer.image = HI_RES_JPG; 748 749 //console.log("Final Render."); 750 //console.log(myLayouts["1UP"]); 751 752 myLayouts["1UP"]["Size"]["height"] = 1200; 753 myLayouts["1UP"]["Data"]["flyer"]["image"] = HI_RES_JPG; 754 755 getDesign(myLayouts["1UP"], function(d) { 756 jQuery("#customizer_one_pdf").val(d); 757 }); 758 759 if(hasMultipleLayouts && jQuery.inArray("2UP", hasUps) != -1 ) { 760 console.log("Getting 2UP"); 761 myLayouts["2UP"]["Size"]["height"] = 1200; 762 myLayouts["2UP"]["Data"]["flyer"]["image"] = HI_RES_JPG; 763 myLayouts["2UP"]["Data"]["flyer"]["format"] = "pdf"; 764 getDesign(myLayouts["2UP"], function(d){ 765 console.log("Download Complete 2UP"); 766 jQuery("#customizer_two_pdf").val(d); 767 }); 768 } 769 770 if(hasMultipleLayouts && jQuery.inArray("4UP", hasUps) != -1 ) { 771 myLayouts["4UP"]["Size"]["height"] = 1200; 772 myLayouts["4UP"]["Data"]["flyer"]["image"] = HI_RES_JPG; 773 myLayouts["4UP"]["Data"]["flyer"]["format"] = "pdf"; 774 getDesign(myLayouts["4UP"], function(d){ 775 jQuery("#customizer_four_pdf").val(d); 776 }); 777 } 778 if(hasMultipleLayouts && jQuery.inArray("6UP", hasUps) != -1 ) { 779 myLayouts["6UP"]["Size"]["height"] = 1200; 780 myLayouts["6UP"]["Data"]["flyer"]["image"] = HI_RES_JPG; 781 myLayouts["6UP"]["Data"]["flyer"]["format"] = "pdf"; 782 getDesign(myLayouts["6UP"], function(d){ 783 jQuery("#customizer_six_pdf").val(d); 784 }); 785 } 786 787 788 }).catch((error) => { 789 console.log("Failed on 546 - finishProductDesign()"); 790 console.log(error); /* @TODO */ 791 }); 792 793 break; 794 795 case "hires": 796 797 var what_id = "customizer_"+jQuery(".custom_download_opt:checked").val()+"_"+jQuery(".custom_download_type:checked").val(); 798 799 downloadURI += "&u="+jQuery("#"+what_id).val(); 800 downloadURI += "&t="+jQuery(".custom_download_type:checked").val(); 801 802 console.log("READY? " +downloadURI); 803 804 jQuery("#warezDownloadCustom").attr("href", downloadURI); 805 jQuery("#warezDownloadCustom")[0].click(); 806 807 break; 808 809 case "download": 810 811 812 break; 813 } 814 815 816 } 817 818 819 820}); 821 822function warez_ready_check() { 823 824 var what_id = "customizer_"+jQuery(".custom_download_opt:checked").val()+"_"+jQuery(".custom_download_type:checked").val(); 825 826 //console.log("Checking.. "+what_id); 827 828 //console.log(what_id); 829 if(jQuery("#"+what_id).val() != "") { 830 //We are ready! 831 jQuery("#download_rendering_loader").hide(); 832 jQuery("#finalizecustom").prop("disabled", false); 833 834 jQuery("#finalizecustom").removeClass("disable"); 835 jQuery("#finalizecustom").val("Download"); 836 //console.log("Ready!"); 837 838 }else{ 839 jQuery("#download_rendering_loader").show(); 840 jQuery("#finalizecustom").prop("disabled", true); 841 jQuery("#finalizecustom").addClass("disable"); 842 jQuery("#finalizecustom").val("Download Preparing..."); 843 setTimeout(warez_ready_check, "1000"); 844 } 845} 846 847 848(function ( $ ) { 849 $.fn.keepElementInView = function() 850 { 851 //var elemPosTop = this.position().top; 852 var theElem = this; 853 var thisBox = $(this); 854 jQuery(window).scroll(function() 855 { 856 857 thisBox.css({ 858 position: 'fixed', 859 top: (jQuery(window).height() - thisBox.outerHeight()) / 2, 860 left: (jQuery(window).width() - thisBox.outerWidth()) / 2 861 }); 862 863 /* 864 var wintop = jQuery(window).scrollTop(), docheight = jQuery(document).height(), winheight = jQuery(window).height(); 865 if (wintop > elemPosTop) 866 { 867 theElem.center(); 868 //theElem.css({ "position":"fixed", "top":"10px" }); 869 } 870 else 871 { 872 theElem.center(); 873 // theElem.css({ "position":"inherit" }); 874 }*/ 875 }); 876 return theElem; 877 } 878 879 jQuery(document).ready( function() 880 { 881 jQuery('.keepup').keepElementInView(); 882 }); 883}( jQuery )); 884 885 886function warez_step_handler(step, mode, action) { 887 if(mode == "multi") { 888 switch(step) { 889 case "start": break; //Start Render 890 case "finalize": break; //Finalize Selections. 891 case "finish": break; 892 } 893 }else{ 894 action(); 895 } 896} 897 898function setCookie(cname, cvalue, exdays) { 899 var d = new Date(); 900 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 901 var expires = "expires="+ d.toUTCString(); 902 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 903} 904 905function getCookie(cname) { 906 var name = cname + "="; 907 var decodedCookie = decodeURIComponent(document.cookie); 908 var ca = decodedCookie.split(';'); 909 for(var i = 0; i <ca.length; i++) { 910 var c = ca[i]; 911 while (c.charAt(0) == ' ') { 912 c = c.substring(1); 913 } 914 if (c.indexOf(name) == 0) { 915 return c.substring(name.length, c.length); 916 } 917 } 918 return ""; 919} 920 921//Execute process once HI RES JPG is no longer null. 922function Variable(initVal, onChange) 923{ 924 this.val = initVal; //Value to be stored in this object 925 this.onChange = onChange; //OnChange handler 926 this.ready = false;
927 928 //This method returns stored value 929 this.GetValue = function() 930 { 931 return this.val; 932 } 933 934 //This method changes the value and calls the given handler 935 this.SetValue = function(value) 936 { 937 this.val = value; 938 this.ready = true; 939 this.onChange(); 940 } 941} 942 943 944function warez_check_paypal(){ 945 var ch = jQuery("#payment_method_ppec_paypal"); 946 947 //console.log(ch.is(":checked")); 948 949 if(ch.is(":checked")){ 950 jQuery("#place_order").hide(); 951 }else{ 952 jQuery("#place_order").show(); 953 954 } 955 956 setTimeout(warez_check_paypal, 1000); 957} 958 959function flipPreviewPic(th, src) { 960 jQuery(th).prop("srcSave", jQuery(th).attr("src")); 961 jQuery(th).attr("src", src); 962} 963function revertToSrc(th) { 964 var srcSave = jQuery(th).prop("srcSave"); 965 if(srcSave != "") jQuery(th).attr("src", jQuery(th).prop("srcSave")); 966} 967 968function getUrlParameter(name) { 969 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); 970 var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); 971 var results = regex.exec(location.search); 972 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); 973}; 974 975 976/* Email Stuff */ 977jQuery(document).ready(function(){ 978window.cfields = []; 979window._show_thank_you = function(id, message, trackcmp_url) { 980 var form = document.getElementById('_form_' + id + '_'), thank_you = form.querySelector('._form-thank-you'); 981 form.querySelector('._form-content').style.display = 'none'; 982 thank_you.innerHTML = message; 983 thank_you.style.display = 'block'; 984 if (typeof(trackcmp_url) != 'undefined' && trackcmp_url) { 985 // Site tracking URL to use after inline form submission. 986 _load_script(trackcmp_url); 987 } 988 setCookie("mail_subscribed", 1, 30); //ADDON THAT SAYS HEY WE ARE DONE! 989 if (typeof window._form_callback !== 'undefined') window._form_callback(id); 990}; 991window._show_error = function(id, message, html) { 992 var form = document.getElementById('_form_' + id + '_'), err = document.createElement('div'), button = form.querySelector('button'), old_error = form.querySelector('._form_error'); 993 if (old_error) old_error.parentNode.removeChild(old_error); 994 err.innerHTML = message; 995 err.className = '_error-inner _form_error _no_arrow'; 996 var wrapper = document.createElement('div'); 997 wrapper.className = '_form-inner'; 998 wrapper.appendChild(err); 999 button.parentNode.insertBefore(wrapper, button); 1000 document.querySelector('[id^="_form"][id$="_submit"]').disabled = false; 1001 if (html) { 1002 var div = document.createElement('div'); 1003 div.className = '_error-html'; 1004 div.innerHTML = html; 1005 err.appendChild(div); 1006 } 1007}; 1008window._load_script = function(url, callback) { 1009 var head = document.querySelector('head'), script = document.createElement('script'), r = false; 1010 script.type = 'text/javascript'; 1011 script.charset = 'utf-8'; 1012 script.src = url; 1013 if (callback) { 1014 script.onload = script.onreadystatechange = function() { 1015 if (!r && (!this.readyState || this.readyState == 'complete')) { 1016 r = true; 1017 callback(); 1018 } 1019 }; 1020 } 1021 head.appendChild(script); 1022}; 1023(function() { 1024 if (window.location.search.search("excludeform") !== -1) return false; 1025 var getCookie = function(name) { 1026 var match = document.cookie.match(new RegExp('(^|; )' + name + '=([^;]+)')); 1027 return match ? match[2] : null; 1028 } 1029 var setCookie = function(name, value) { 1030 var now = new Date(); 1031 var time = now.getTime(); 1032 var expireTime = time + 1000 * 60 * 60 * 24 * 365; 1033 now.setTime(expireTime); 1034 document.cookie = name + '=' + value + '; expires=' + now + ';path=/'; 1035 } 1036 var addEvent = function(element, event, func) { 1037 if (element.addEventListener) { 1038 element.addEventListener(event, func); 1039 } else { 1040 var oldFunc = element['on' + event]; 1041 element['on' + event] = function() { 1042 oldFunc.apply(this, arguments); 1043 func.apply(this, arguments); 1044 }; 1045 } 1046 } 1047 1048 try{ 1049 1050 var _removed = false; 1051 var form_to_submit = document.getElementById('_form_5_'); 1052 var allInputs = form_to_submit.querySelectorAll('input, select, textarea'), tooltips = [], submitted = false;
1053 1054 var getUrlParam = function(name) { 1055 var regexStr = '[\?&]' + name + '=([^&#]*)'; 1056 var results = new RegExp(regexStr, 'i').exec(window.location.href); 1057 return results != undefined ? decodeURIComponent(results[1]) : false; 1058 }; 1059 1060 for (var i = 0; i < allInputs.length; i++) { 1061 var regexStr = "field\\[(\\d+)\\]"; 1062 var results = new RegExp(regexStr).exec(allInputs[i].name); 1063 if (results != undefined) { 1064 allInputs[i].dataset.name = window.cfields[results[1]]; 1065 } else { 1066 allInputs[i].dataset.name = allInputs[i].name; 1067 } 1068 var fieldVal = getUrlParam(allInputs[i].dataset.name); 1069 1070 if (fieldVal) { 1071 if (allInputs[i].type == "radio" || allInputs[i].type == "checkbox") { 1072 if (allInputs[i].value == fieldVal) { 1073 allInputs[i].checked = true; 1074 } 1075 } else { 1076 allInputs[i].value = fieldVal; 1077 } 1078 } 1079 } 1080 1081 var remove_tooltips = function() { 1082 for (var i = 0; i < tooltips.length; i++) { 1083 tooltips[i].tip.parentNode.removeChild(tooltips[i].tip); 1084 } 1085 tooltips = []; 1086 }; 1087 var remove_tooltip = function(elem) { 1088 for (var i = 0; i < tooltips.length; i++) { 1089 if (tooltips[i].elem === elem) { 1090 tooltips[i].tip.parentNode.removeChild(tooltips[i].tip); 1091 tooltips.splice(i, 1); 1092 return; 1093 } 1094 } 1095 }; 1096 var create_tooltip = function(elem, text) { 1097 var tooltip = document.createElement('div'), arrow = document.createElement('div'), inner = document.createElement('div'), new_tooltip = {}; 1098 if (elem.type != 'radio' && elem.type != 'checkbox') { 1099 tooltip.className = '_error'; 1100 arrow.className = '_error-arrow'; 1101 inner.className = '_error-inner'; 1102 inner.innerHTML = text; 1103 tooltip.appendChild(arrow); 1104 tooltip.appendChild(inner); 1105 elem.parentNode.appendChild(tooltip); 1106 } else { 1107 tooltip.className = '_error-inner _no_arrow'; 1108 tooltip.innerHTML = text; 1109 elem.parentNode.insertBefore(tooltip, elem); 1110 new_tooltip.no_arrow = true; 1111 } 1112 new_tooltip.tip = tooltip; 1113 new_tooltip.elem = elem; 1114 tooltips.push(new_tooltip); 1115 return new_tooltip; 1116 }; 1117 var resize_tooltip = function(tooltip) { 1118 var rect = tooltip.elem.getBoundingClientRect(); 1119 var doc = document.documentElement, scrollPosition = rect.top - ((window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)); 1120 if (scrollPosition < 40) { 1121 tooltip.tip.className = tooltip.tip.className.replace(/ ?(_above|_below) ?/g, '') + ' _below'; 1122 } else { 1123 tooltip.tip.className = tooltip.tip.className.replace(/ ?(_above|_below) ?/g, '') + ' _above'; 1124 } 1125 }; 1126 var resize_tooltips = function() { 1127 if (_removed) return; 1128 for (var i = 0; i < tooltips.length; i++) { 1129 if (!tooltips[i].no_arrow) resize_tooltip(tooltips[i]); 1130 } 1131 }; 1132 var validate_field = function(elem, remove) { 1133 var tooltip = null, value = elem.value, no_error = true; 1134 remove ? remove_tooltip(elem) : false; 1135 if (elem.type != 'checkbox') elem.className = elem.className.replace(/ ?_has_error ?/g, ''); 1136 if (elem.getAttribute('required') !== null) { 1137 if (elem.type == 'radio' || (elem.type == 'checkbox' && /any/.test(elem.className))) { 1138 var elems = form_to_submit.elements[elem.name]; 1139 if (!(elems instanceof NodeList || elems instanceof HTMLCollection) || elems.length <= 1) { 1140 no_error = elem.checked; 1141 } 1142 else { 1143 no_error = false; 1144 for (var i = 0; i < elems.length; i++) { 1145 if (elems[i].checked) no_error = true; 1146 } 1147 } 1148 if (!no_error) { 1149 tooltip = create_tooltip(elem, "Please select an option."); 1150 } 1151 } else if (elem.type =='checkbox') { 1152 var elems = form_to_submit.elements[elem.name], found = false, err = []; 1153 no_error = true; 1154 for (var i = 0; i < elems.length; i++) { 1155 if (elems[i].getAttribute('required') === null) continue; 1156 if (!found && elems[i] !== elem) return true; 1157 found = true; 1158 elems[i].className = elems[i].className.replace(/ ?_has_error ?/g, ''); 1159 if (!elems[i].checked) { 1160 no_error = false;
1161 elems[i].className = elems[i].className + ' _has_error'; 1162 err.push("Checking %s is required".replace("%s", elems[i].value)); 1163 } 1164 } 1165 if (!no_error) { 1166 tooltip = create_tooltip(elem, err.join('<br/>')); 1167 } 1168 } else if (elem.tagName == 'SELECT') { 1169 var selected = true; 1170 if (elem.multiple) { 1171 selected = false; 1172 for (var i = 0; i < elem.options.length; i++) { 1173 if (elem.options[i].selected) { 1174 selected = true; 1175 break; 1176 } 1177 } 1178 } else { 1179 for (var i = 0; i < elem.options.length; i++) { 1180 if (elem.options[i].selected && !elem.options[i].value) { 1181 selected = false; 1182 } 1183 } 1184 } 1185 if (!selected) { 1186 elem.className = elem.className + ' _has_error'; 1187 no_error = false; 1188 tooltip = create_tooltip(elem, "Please select an option."); 1189 } 1190 } else if (value === undefined || value === null || value === '') { 1191 elem.className = elem.className + ' _has_error'; 1192 no_error = false; 1193 tooltip = create_tooltip(elem, "This field is required."); 1194 } 1195 } 1196 if (no_error && elem.name == 'email') { 1197 if (!value.match(/^[\+_a-z0-9-'&=]+(\.[\+_a-z0-9-']+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i)) { 1198 elem.className = elem.className + ' _has_error'; 1199 no_error = false; 1200 tooltip = create_tooltip(elem, "Enter a valid email address."); 1201 } 1202 } 1203 if (no_error && /date_field/.test(elem.className)) { 1204 if (!value.match(/^\d\d\d\d-\d\d-\d\d$/)) { 1205 elem.className = elem.className + ' _has_error'; 1206 no_error = false; 1207 tooltip = create_tooltip(elem, "Enter a valid date."); 1208 } 1209 } 1210 tooltip ? resize_tooltip(tooltip) : false; 1211 return no_error; 1212 }; 1213 var needs_validate = function(el) { 1214 return el.name == 'email' || el.getAttribute('required') !== null; 1215 }; 1216 var validate_form = function(e) { 1217 var err = form_to_submit.querySelector('._form_error'), no_error = true; 1218 if (!submitted) { 1219 submitted = true; 1220 for (var i = 0, len = allInputs.length; i < len; i++) { 1221 var input = allInputs[i]; 1222 if (needs_validate(input)) { 1223 if (input.type == 'text') { 1224 addEvent(input, 'blur', function() { 1225 this.value = this.value.trim(); 1226 validate_field(this, true); 1227 }); 1228 addEvent(input, 'input', function() { 1229 validate_field(this, true); 1230 }); 1231 } else if (input.type == 'radio' || input.type == 'checkbox') { 1232 (function(el) { 1233 var radios = form_to_submit.elements[el.name]; 1234 for (var i = 0; i < radios.length; i++) { 1235 addEvent(radios[i], 'click', function() { 1236 validate_field(el, true); 1237 }); 1238 } 1239 })(input); 1240 } else if (input.tagName == 'SELECT') { 1241 addEvent(input, 'change', function() { 1242 validate_field(this, true); 1243 }); 1244 } else if (input.type == 'textarea'){ 1245 addEvent(input, 'input', function() { 1246 validate_field(this, true); 1247 }); 1248 } 1249 } 1250 } 1251 } 1252 remove_tooltips(); 1253 for (var i = 0, len = allInputs.length; i < len; i++) { 1254 var elem = allInputs[i]; 1255 if (needs_validate(elem)) { 1256 if (elem.tagName.toLowerCase() !== "select") { 1257 elem.value = elem.value.trim(); 1258 } 1259 validate_field(elem) ? true : no_error = false; 1260 } 1261 } 1262 if (!no_error && e) { 1263 e.preventDefault(); 1264 } 1265 resize_tooltips(); 1266 return no_error; 1267 }; 1268 addEvent(window, 'resize', resize_tooltips); 1269 addEvent(window, 'scroll', resize_tooltips); 1270 window._old_serialize = null; 1271 if (typeof serialize !== 'undefined') window._old_serialize = window.serialize; 1272 _load_script("//d3rxaij56vjege.cloudfront.net/form-serialize/0.3/serialize.min.js", function() { 1273 window._form_serialize = window.serialize;
1274 if (window._old_serialize) window.serialize = window._old_serialize; 1275 }); 1276 var form_submit = function(e) { 1277 e.preventDefault(); 1278 if (validate_form()) { 1279 // use this trick to get the submit button & disable it using plain javascript 1280 document.querySelector('#_form_5_submit').disabled = true; 1281 var serialized = _form_serialize(document.getElementById('_form_5_')); 1282 var err = form_to_submit.querySelector('._form_error'); 1283 err ? err.parentNode.removeChild(err) : false; 1284 _load_script('https://hwtm.activehosted.com/proc.php?' + serialized + '&jsonp=true'); 1285 } 1286 return false; 1287 }; 1288 addEvent(form_to_submit, 'submit', form_submit); 1289 1290 } 1291 catch(err){} 1292 1293 1294})(); 1295 1296});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.