PageSourceSearch

https://ipmac.uz/js/tygh/checkout.js?ver=1791327061

js ipmac.uz collected 2026-10-07 16:12:22 UTC 8,354 bytes, 268 lines download raw bytes

1function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
3(function (_, $) {
4  var prevent_scroll = false;
5
6  (function ($) {
7    var inputs_selector = 'input, textarea, select';
8    var place_order_buttons_selector = '.cm-checkout-place-order-buttons';
9    var recalculate_buttons_selector = '.cm-checkout-recalculate-buttons';
10    var form_values = {};
11
12    function changed() {
13      var form = $(this);
14
15      if (checkFormChanged(form) && form.ceFormValidator('check')) {
16        displayRecalculate(form);
17      }
18    }
19
20    function displayRecalculate(form) {
21      var changed_groups = {
22        user_data: false
23      };
24      form.find(inputs_selector).each(function () {
25        var elm = $(this);
26
27        if (elm.attr('type') != 'hidden' && form_values[elm.attr('name') + '_' + elm.attr('id')] != getVal(elm)) {
28          var elm_name = elm.attr('name');
29
30          if (elm_name) {
31            var elm_group = elm_name.split('[')[0];
32            changed_groups[elm_group] = true;
33          }
34        }
35      }); // require recalculate only when user data changed
36
37      if (changed_groups['user_data']) {
38        form.find(place_order_buttons_selector).hide();
39        form.find(recalculate_buttons_selector).show();
40      }
41    }
42
43    function saveFormValues(form) {
44      form.find(inputs_selector).each(function () {
45        var elm = $(this);
46        form_values[elm.attr('name') + '_' + elm.attr('id')] = getVal(elm);
47      });
48    }
49
50    function checkFormChanged(form) {
51      var result = false;
52      form.find(inputs_selector).each(function () {
53        var elm = $(this);
54
55        if (elm.attr('type') != 'hidden' && form_values[elm.attr('name') + '_' + elm.attr('id')] != getVal(elm)) {
56          result = true;
57        }
58      });
59      return result;
60    }
61
62    function getVal(elm) {
63      return ['checkbox', 'radio'].indexOf(elm.attr('type')) != -1 ? elm.is(':checked') : elm.val();
64    }
65
66    var methods = {
67      init: function init(v1) {
68        var form = $(this);
69
70        if (form.data('CheckoutRecalculateFormInited')) {
71          return false;
72        }
73
74        form.data('CheckoutRecalculateFormInited', true);
75
76        if (!form.find(recalculate_buttons_selector).length) {
77          return true;
78        }
79
80        saveFormValues(form);
81        form.find(inputs_selector).on('input propertychange change', function (e) {
82          changed.apply(form);
83        });
84      }
85    };
86
87    $.fn.ceCheckoutRecalculateForm = function (method) {
88      if (methods[method]) {
89        return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
90      } else if (_typeof(method) === 'object' || !method) {
91        return methods.init.apply(this, arguments);
92      } else {
93        $.error('ty.ceCheckoutRecalculateForm: method ' + method + ' does not exist');
94      }
95    };
96  })($);
97
98  $.ceEvent('on', 'ce.commoninit', function (context) {
99    var elm = context.find('.ty-step__title-active');
100
101    if (elm.length && !prevent_scroll) {
102      $.scrollToElm(elm);
103    }
104
105    prevent_scroll = false;
106    elm = context.find('.cm-checkout-recalculate-form');
107
108    if (elm.length) {
109      elm.ceCheckoutRecalculateForm();
110    }
111
112    restoreCustomerNote($('.ty-customer-notes__text'));
113  });
114  $(_.doc).on('click', '.cm-checkout-place-order', function () {
115    var jelm = $(this),
116        form = jelm.parents('form');
117
118    if (!form.ceFormValidator('check')) {
119      return;
120    }
121
122    form.removeClass('cm-ajax').removeClass('cm-ajax-full-render');
123    $.ceEvent('on', 'ce.formpost_' + $(form).attr('name'), function () {
124      $.toggleStatusBox('show', {
125        statusContent: '<span class="ty-ajax-loading-box-with__text-wrapper">' + _.tr('placing_order') + '</span>',
126        statusClass: 'ty-ajax-loading-box_text_block'
127      });
128    });
129  });
130  $(_.doc).on('click', '.cm-checkout-recalculate', function () {
131    prevent_scroll = true;
132  });
133  $(_.doc).on('click', '.cm-select-payment', function () {
134    var jelm = $(this),
135        url = jelm.data('caUrl'),
136        result_ids = jelm.data('caResultIds');
137    $.ceAjax('request', fn_url(url + '&payment_id=' + jelm.val()), {
138      result_ids: result_ids,
139      full_render: true
140    });
141  });
142  $.ceEvent('on', 'ce.loadershow', function () {
143    var forms = $('#checkout_steps', _.doc).find('form');
144    forms.on('submit.checkout_lock', function () {
145      return false;
146    });
147    forms.find('button[type="submit"]').on('click.checkout_lock', function () {
148      return false;
149    });
150  });
151  $.ceEvent('on', 'ce.loaderhide', function () {
152    var forms = $('#checkout_steps', _.doc).find('form');
153    forms.off('submit.checkout_lock');
154    forms.find('button[type="submit"]').off('click.checkout_lock');
155  });
156  $.ceEvent('on', 'ce.payments_tab_switch', function () {
157    restoreCustomerNote($('.ty-customer-notes__text'));
158  });
159  var customerNote = '';
160
161  function saveCustomerNote($textarea) {
162    customerNote = $textarea.val();
163  }
164
165  function restoreCustomerNote($textarea) {
166    $textarea.val(customerNote);
167  }
168
169  $(_.doc).on('input', '.ty-customer-notes__text', function () {
170    saveCustomerNote($(this));
171  });
172})(Tygh, Tygh.$);
173
174function fn_switch_checkout_type() {
175  var $ = Tygh.$;
176  $.ceNotification('closeAll');
177  $('#step_one_register').show();
178  $('#step_one_login').hide();
179}
180
181function fn_show_checkout_buttons(type) {
182  var $ = Tygh.$;
183
184  if (type == 'register') {
185    $('#register_checkout').show();
186    $('#anonymous_checkout').hide();
187  } else {
188    $('#register_checkout').hide();
189    $('#anonymous_checkout').show();
190  }
191}
192/**
193 * This workaround is mainly required for a shipping estimator block to work outside of cart page.
194 * This function cannot be just moved from checkout.js, because some themes ("boilerplate" for example)
195 * might not include cs-cart's native core.js, which will lead to breaking delivery estimation
196 * functionality on the cart page.
197 **/
198
199
200if (window.fn_calculate_total_shipping === undefined) {
201  var fn_calculate_total_shipping = function fn_calculate_total_shipping(wrapper_id) {
202    var $ = Tygh.$;
203    wrapper_id = wrapper_id || 'shipping_estimation';
204    var parent = $('#' + wrapper_id);
205    var radio = $('input[type=radio]:checked', parent);
206    var params = [];
207    $.each(radio, function (id, elm) {
208      params.push({
209        name: elm.name,
210        value: elm.value
211      });
212    });
213    var url = fn_url('checkout.shipping_estimation.get_total');
214
215    for (var i in params) {
216      url += '&' + params[i]['name'] + '=' + encodeURIComponent(params[i]['value']);
217    }
218
219    var suffix = parent.find('input[name="suffix"]').first().val();
220    $.ceAjax('request', url, {
221      result_ids: 'shipping_estimation_total' + suffix,
222      data: {
223        additional_id: parent.find('input[name="additional_id"]').first().val()
224      },
225      method: 'post'
226    });
227  };
228}
229
230function fn_calculate_total_shipping_cost(is_hidden) {
231  is_hidden = is_hidden || false;
232  var params = [],
233      $parents = Tygh.$('#shipping_rates_list'),
234      $radio = Tygh.$('input[type=radio]:checked', $parents),
235      $shippingInfo = Tygh.$('[data-ca-shipping-field]'),
236      url = fn_url('checkout.checkout'),
237      result_ids = 'shipping_rates_list,checkout_info_summary_*,checkout_info_order_info_*',
238      $additional_result_ids = Tygh.$('input[name="additional_result_ids[]"]', $parents);
239  Tygh.$.each($radio, function (id, elm) {
240    params.push({
241      name: elm.name,
242      value: elm.value
243    });
244  });
245  Tygh.$.each($shippingInfo, function (id, elm) {
246    params.push({
247      name: elm.name,
248      value: elm.value
249    });
250  });
251  Tygh.$.each($additional_result_ids, function (id, elm) {
252    result_ids += ',' + $(elm).val();
253  });
254
255  for (var i in params) {
256    url += '&' + params[i]['name'] + '=' + encodeURIComponent(params[i]['value']);
257  }
258
259  Tygh.$.ceAjax('request', url, {
260    result_ids: result_ids,
261    method: 'get',
262    full_render: true,
263    hidden: is_hidden,
264    callback: function callback(response) {
265      $.ceEvent('trigger', 'ce.total-shipping-cost.calculated', [response]);
266    }
267  });
268}

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.