Guest User

Untitled

a guest
Jan 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. unlayer.registerPropertyEditor({
  2. name: 'couponType',
  3. layout: 'bottom',
  4. Widget: unlayer.createWidget({
  5. render(value) {
  6. return `
  7. <div id="barcodediv" class="blockbuilder-widget blockbuilder-text-widget row">
  8. <div class="col-12">
  9. <div class="blockbuilder-widget-label pb-2">
  10. <label class="blockbuilder-label-primary"><span>Coupon Type</span></label>
  11. </div>
  12. <select id="couponType" name="couponType" class="form-control">
  13. <option></option>
  14. <option value="static">Enter Static Code</option>
  15. <option value="upload">Upload Dynamic Codes</option>
  16. <option value="generate">Create Dynamic Codes</option>
  17. </select>
  18. </div>
  19. </div>
  20. <div id="barcodediv" class="blockbuilder-widget blockbuilder-text-widget row">
  21. <div class="col-12">
  22. <div class="blockbuilder-widget-label pb-2">
  23. <label class="blockbuilder-label-primary"><span>Coupon Type</span></label>
  24. </div>
  25. <select id="couponType" name="couponType" class="form-control">
  26. <option></option>
  27. <option value="static">Enter Static Code</option>
  28. <option value="upload">Upload Dynamic Codes</option>
  29. <option value="generate">Create Dynamic Codes</option>
  30. </select>
  31. </div>
  32. </div>
  33. <div id="staticoffer" style="display:none;padding-top:15px;">
  34. <div class="blockbuilder-text-widget row">
  35. <div class="col-12">
  36. <div class="blockbuilder-widget-label pb-2">
  37. <label class="blockbuilder-label-primary"><span>Coupon Code</span></label>
  38. </div>
  39. <input type="text" name="staticCouponId" id="staticCouponId" value="${(value.staticCouponId != null ? value.staticCouponId : '')}" class="form-control" />
  40. </div>
  41. </div>
  42. </div>
  43. `
  44. },
  45. mount(node, value, updateValue) {
  46. var getValuesToUpdate = function() {
  47. return {
  48. couponType: $("#couponType").val(),
  49. staticCouponId: $("#staticCouponId").val()
  50. };
  51. };
  52.  
  53. var handleShowHide = function() {
  54. switch($("#couponType").val()) {
  55. case 'static':
  56. $("#staticoffer").show();
  57. break;
  58. }
  59. };
  60.  
  61. $("#couponType").off().on("change",function() {
  62. postToParent(
  63. "couponSettingsUpdate",
  64. {
  65. field: $(this).attr("id"),
  66. value: $(this).val()
  67. }
  68. );
  69.  
  70. handleShowHide();
  71. updateValue(getValuesToUpdate());
  72. });
  73.  
  74. $("#staticCouponId").off().on("keyup",function(e){
  75. updateValue(getValuesToUpdate());
  76.  
  77. postToParent(
  78. "couponSettingsUpdate",
  79. {
  80. field: $(this).attr("id"),
  81. value: $(this).val()
  82. }
  83. );
  84. });
  85.  
  86. handleShowHide();
  87. }
  88. })
  89. });
Add Comment
Please, Sign In to add comment