PageSourceSearch

https://www.tarzan.ch/plugins/css_gutschein/frontend/template/B4/js/plugin.js?v=5.2.0

js tarzan.ch collected 2026-10-05 23:21:00 UTC 8,689 bytes, 250 lines download raw bytes

1(function () {
2  'use strict';
3
4  if (!$.cssVoucher) {
5    $.cssVoucher = {'showDebug': false};
6  }
7
8  var cssVoucherClass = function (options) {
9    this.init(options);
10  };
11
12  cssVoucherClass.VERSION = '2.0.1';
13  cssVoucherClass.DEFAULTS = {
14    showDebug: true,
15    ioUrl: '.'
16  };
17  cssVoucherClass.prototype = {
18
19    constructor: cssVoucherClass,
20
21    init: function (options) {
22      this.options = $.extend({}, cssVoucherClass.DEFAULTS, options);
23      this.options.ioUrl = $("[data-iourl]").first().data("iourl");
24      console.log(this.options.ioUrl);
25      var that = this;
26      that.debug(this);
27    },
28
29
30    register: function () {
31//			this.options.ioUrl = $(".css-gutschein-variations").data('iourl');
32      this.debug("ich starte cssVoucherClass.VERSION " + this.__proto__.constructor.VERSION);
33      this.initAuswahl();
34      this.initVoucherAreaLink();
35      this.initVoucherProperty();
36      this.initPreview();
37      this.initDatepicker();
38      this.initGsCode();
39      this.initRemoveGsFromBasket();
40      this.cssInterval = 0;
41    },
42
43    debug: function (s) {
44      if (this.options.showDebug) {
45        console.log(s);
46      }
47    },
48
49
50    initRemoveGsFromBasket: function () {
51      var that = this;
52      $(document).on("click", "[name='dropGS']", function () {
53        var ioUrl = $(this).data("iourl");
54        that.post_data(
55          "/io.php",
56          "io=css_gutschein&action=removeGsFromBasket&gs=" + $(this).data('gs'));
57      });
58    },
59
60
61    post_data: function (url, data) {
62      var that = this;
63      jQuery.ajax({
64        type: 'POST',
65        url: that.options.ioUrl,
66        data: data,
67        showNoSuggestionNotice: true,
68        dataType: 'json',
69        beforeSend: function (jqXHR) {
70          jqXHR.overrideMimeType('text/json;charset=iso-8859-1');
71        },
72        success: function (data, responseText, jqXHR) {
73          if (jqXHR.status == 204) {
74            that.debug('sorry, here is nothing to do for me. (Token problem?)')
75            return false;
76          }
77          if (jqXHR.status == 404) {
78            that.debug('sorry, here is nothing to show you.')
79            return false;
80          }
81          if (jqXHR.status == 403) {
82            that.debug('sorry, this is no place for you.')
83            return false;
84          }
85          //debug(data);
86          if (data.script) {
87            eval(data.script);
88          }
89          $("body").trigger('contentChanged');
90        },
91        error: function () {
92          that.debug('something is wrong....anything buggy?');
93        },
94        complete: function () {
95
96        }
97      });
98    },
99
100    initGsCode: function () {
101      var that = this;
102      $(document).on("click", "#cssGsCode-submit", function () {
103        that.options.ioUrl = $(this).data("iourl");
104        that.post_data(
105          "/io.php",
106          "io=css_gutschein&action=getGSCode&gsCode=" + $("#cssGsCode").val()
107        );
108      });
109    },
110
111    updateVoucher: function (el, action) {
112      var that = this;
113      that.debug("updateVoucher wird ausgefuehrt.");
114      var form = $(el).closest("form");
115      if (!$(form).attr('id')) {
116        $(form).attr('id', 'css_gutscheinform');
117      }
118      var data = $("#" + $(form).attr('id') + " :not([name='inWarenkorb'],[name='wke'])").seri
118alize();
119      that.debug("form serialize = " + data);
120      that.post_data("io.php", "io=css_gutschein&action=" + action + "&" + data);
121    },
122
123    initPreview: function () {
124      var that = this;
125      $("#vorschau").on("click", function () {
126        that.debug("#vorchau -> ich wurde geklickt.");
127        that.updateVoucher(this, "getBigVoucherPreview");
128      });
129    },
130
131    initVoucherProperty: function (el) {
132      var that = this;
133      $(".css_gutschein input[name*='eigenschaftwert'], .css_gutschein textarea[name*='eigenschaftwert']").not(".VoucherDatePicker").on("change", function () {
134        that.updateVoucher(this, "getGalleryPreview");
135      });
136
137      var lastlength = $.md5($(".css_gutschein textarea.cssVoucherText").val() + $(".css_gutschein input.cssVoucherPrice").val());
138
139      $(".css_gutschein textarea.cssVoucherText, .css_gutschein input.cssVoucherPrice").on("focus", function () {
140        var el = this;
141        if (typeof that.cssInterval != 'undefined') {
142          clearInterval(that.cssInterval);
143        }
144        that.cssInterval = setInterval(function () {
145          $("body").trigger("cssUpdatePreis", Number($(".css_gutschein input.cssVoucherPrice").val()));
146          that.debug("update den Textbereich wenn erforderlich");
147          if (lastlength != $.md5($(".css_gutschein textarea.cssVoucherText").val() + $(".css_gutschein input.cssVoucherPrice").val())) {
148            that.updateVoucher($(el), "getGalleryPreview");
149            lastlength = $.md5($(".css_gutschein textarea.cssVoucherText").val() + $(".css_gutschein input.cssVoucherPrice").val());
150          }
151        }, 1000);
152      });
153
154      $(document).on('evo:changed.article.price', function () {
155        that.debug("evo:changed.article.price");
156        if ($("input.cssVoucherPrice").length > 0) {
157          $("body").trigger("cssUpdatePreis", Number($(".css_gutschein input.cssVoucherPrice").val()));
158// sicherheit, falls das erste Preisupdate wirkungslos ist weil andere sich danach noch mal eingemischt haben.
159          setTimeout(function () {
160            console.log("update den Preis");
161            $("body").trigger("cssUpdatePreis", Number($(".css_gutschein input.cssVoucherPrice").val()));
162          }, 200);
163        }
164      });
165
166      $(".css_gutschein textarea.cssVoucherText , .css_gutschein input.cssVoucherPrice").on("blur", function () {
167        $("body").trigger("cssUpdatePreis", Number($(".css_gutschein input.cssVoucherPrice").val()));
168        if (typeof that.cssInterval != 'undefined') {
169          clearInterval(that.cssInterval);
170        }
171      });
172    },
173
174
175    initVoucherAreaLink: function () {
176      var that = this;
177      $(".voucher-area-link").on("click", function () {
178
179        // sorgt dafür das das nicht immer neu geladen wird wenn ich die Bilder schon geholt habe
180        if ($(this).closest(".panel-default").find(".panel-collapse img").length > 0) return;
181
182        that.debug(".voucher-area-link -> ich wurde geklickt.");
183        var id = $(this).data("id");
184        that.post_data("io.php", "io=css_gutschein&action=getVoucherItems&area=" + id + "&jtl_token=" + $("input[name='jtl_token']").val());
185      });
186
187      setTimeout(function () {
188// wurde entfernt weil es nun möglich ist mehrere Gutscheine zu kaufen.
189//				$("body.css_gutschein").trigger("cssUpdateMaxbestellmenge",1);
190        $("body.css_gutschein").trigger("cssUpdatePreis", Number($(".css_gutschein input.cssVoucherPrice").val()));
191      }, 500);
192    },
193
194    initAuswahl: function () {
195      var that = this;
196      $("#voucherItem").on("click", function () {
197        that.debug("#voucherItem -> ich wurde geklickt.");
198        that.post_data("io.php", "io=css_gutschein&action=getVoucherAreas" + "&jtl_token=" + $("input[name='jtl_token']").val());
199      });
200    },
201
202    initVoucherImage: function () {
203      var that = this;
204      $(".voucher-imageBox").unbind("click");
205      $(".voucher-imageBox").on("click", function () {
206        that.debug(".initVoucherImage -> ich wurde geklickt.");
207        $("input[name='voucherImage']").val($(this).data('id'));
208        $("input[data-type='voucherImage']").val($(this).data('id'));
209        that.post_data("io.php", "io=css_gutschein&action=getVoucherimageInfo&img=" + $(this).data('id') + "&jtl_token=" + $("input[name='jtl_token']").val());
210//					$.cssVouch.post_data("io.php","io=css_gutschein&action=getVoucherAreas");
211      });
212      $("input[name='voucherImage']").on("change", function () {
213        $("input[data-type='voucherImage']").val($(this).val());
214      });
215    },
216
217    // deaktiviert und durch den pignose Kalender ersetzt in Version 1.03
218    initDatepicker: function () {
219      /*
220                      $('.VoucherDatePicker').datepicker({
221                           language: "de",
222                           autoclose: true,
223                           startDate: $('.VoucherDatePicker').attr("data-startDate")
224                     });
225      */
226    },
227  };
228
229  $.cssVoucher.extended = function () {
230    return new cssVoucherClass($.cssVoucher);
231  };
232
233  $.cssVoucher.error = function () {
234    if (console && console.error) {
235      console.error(arguments);
236    }
237  };
238
239
240  $(document).ready(function () {
241    $.cssVoucher.extended().register();
242    $.cssVouch = $.cssVoucher.extended();
243    if ($("input.cssVoucherPrice").length) {
244      $.cssVouch.updateVoucher($("input.cssVoucherPrice"), 'getGalleryPreview');
245    }
246  });
247
248
249})(jQuery);
250

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.