PageSourceSearch

https://kassis.ru/assets/components/msoptionsprice/js/web/default.js?v=b3f69e47

js kassis.ru collected 2026-09-30 09:51:28 UTC 35,948 bytes, 936 lines download raw bytes

1/* 2.4.6 */
2(function (window, document, $, msOptionsPriceConfig) {
3    var msOptionsPrice = msOptionsPrice || {};
4
5
6    msOptionsPrice.options = {
7        errorClass: "error",
8        errorElement: "span",
9        showSpinner: true,
10    };
11
12
13    msOptionsPrice.setup = function () {
14        msOptionsPrice.$doc = $(document);
15        msOptionsPrice.$body = $('body');
16        msOptionsPrice.$spinner = null;
17
18        msOptionsPrice.Product.parent = '#msProduct';
19        msOptionsPrice.Product.form = '.ms2_form.msoptionsprice-product';
20        msOptionsPrice.Product.modification = '.ms2_form.msoptionsprice-modification';
21        msOptionsPrice.Product.cost = '.msoptionsprice-cost';
22        msOptionsPrice.Product.old_cost = '.msoptionsprice-old-cost';
23        msOptionsPrice.Product.price = '.msoptionsprice-old-price';
24        msOptionsPrice.Product.mass = '.msoptionsprice-mass';
25        msOptionsPrice.Product.article = '.msoptionsprice-article';
26        msOptionsPrice.Product.weight = '.msoptionsprice-weight';
27        msOptionsPrice.Product.count = '.msoptionsprice-count';
28        msOptionsPrice.Product.name = '.msoptionsprice-name';
29        msOptionsPrice.Product.msbonus = '.msoptionsprice-msbonus';
30
31        msOptionsPrice.Product.gallery = '.msoptionsprice-gallery';
32        msOptionsPrice.Product.fotorama = '.fotorama';
33        msOptionsPrice.Product.image = '.msoptionsprice-image';
34        msOptionsPrice.Product.prefix = '.msoptionsprice-';
35
36        msOptionsPrice.exclude = {};
37
38        msOptionsPrice.exclude.fieldNames = ['count'];
39        msOptionsPrice.exclude.fieldClasess = ['msal_input'];
40
41        msOptionsPrice.Product.msal_price = '#msal_price_original';
42
43        msOptionsPrice.Product.inputParent = '.input-parent';
44        msOptionsPrice.timeout = 300;
45    };
46
47
48    msOptionsPrice.initialize = function () {
49        msOptionsPrice.setup();
50        msOptionsPrice.miniShop2.initialize();
51
52        /* get modification on change options */
53        msOptionsPrice.$doc.on('change', msOptionsPrice.Product.form, function (e) {
54
55            if (msOptionsPrice.Tools.inArray(e.target.name, msOptionsPrice.exclude.fieldNames)) {
56                console.info('[msOptionsPrice] Exclude field "' + e.target.name + '"');
57
58                return false;
59            }
60
61            for (i in msOptionsPrice.exclude.fieldClasess) {
62                if (!msOptionsPrice.exclude.fieldClasess.hasOwnProperty(i)) {
63                    continue;
64                }
65
66                var cls = msOptionsPrice.exclude.fieldClasess[i];
67                if ($(e.target).hasClass(cls)) {
68
69                    console.info('[msOptionsPrice] Exclude field "' + e.target.name + '"');
70                    return false;
71                }
72            }
73
74            msOptionsPrice.Product.processOptions(this);
75
76            setTimeout((function () {
77                msOptionsPrice.Product.action('modification/get', this);
78            }.bind(this)), msOptionsPrice.timeout);
79
80            e.preventDefault();
81            return false;
82        });
83
84        /* get modification on document ready */
85        msOptionsPrice.$doc.ready(function () {
86            msOptionsPrice.mSearch2.setOptionsByFilter();
87            $(msOptionsPrice.Product.form).each(function () {
88                $(this).trigger('change');
89                /*
90                 msOptionsPrice.Product.action('modification/get', this);
91                 */
92            });
93        });
94
95        /* get modification on change image */
96        msOptionsPrice.$doc.on('fotorama:show', msOptionsPrice.Product.gallery + ' ' + msOptionsPrice.Product.fotorama, function (e, fotorama, extra) {
97            var item, form;
98
99            item = fotorama.activeFrame;
100            if (extra.user && item.rid && item.iid) {
101
102                form = $(e.target).closest(msOptionsPrice.Product.parent).find(msOptionsPrice.Product.form);
103                if (!form) {
104                    form = $(msOptionsPrice.Product.cost + msOptionsPrice.Product.prefix + item.rid)
105                        .closest(msOptionsPrice.Product.form);
106                }
107                if (form) {
108                    msOptionsPrice.Product.action('modification/get', form, {id: item.rid, iid: item.iid});
109                }
110            }
111        });
112
113        /* set rid, iid image */
114        msOptionsPrice.$doc.on('fotorama:load', msOptionsPrice.Product.gallery + ' ' + msOptionsPrice.Product.fotorama, function (e, fotorama, extra) {
115
116            fotorama.data.filter(function (item, r) {
117                if (item.rid && item.iid && item.thumb) {
118                    var thumb = $(this).find('img[src$="' + item.thumb + '"]');
119
120                    if (thumb) {
121                        thumb
122                            .data('i', item.i)
123                            .attr('data-i', item.i)
124                            .data('rid', item.rid)
125                            .attr('data-rid', item.rid)
126                            .data('iid', item.rid)
127                            .attr('data-iid', item.iid);
128                    }
129
130                    if (fotorama.activeFrame.i == item.i) {
131                        var form = $(e.target).closest(msOptionsPrice.Product.parent).find(msOptionsPrice.Product.form);
132                        if (!form) {
133                            form = $(msOptionsPrice.Product.cost + msOptionsPrice.Product.prefix + item.rid)
134                                .closest(msOptionsPrice.Product.form);
135                        }
136                        if (form) {
137                            msOptionsPrice.Product.action('modification/get', form, {id: item.rid, iid: item.iid});
138                        }
139                    }
140                }
141
142            }, this);
143        });
144
145        /* set options and get modification on "mse2_load" */
146        msOptionsPrice.$doc.on('mse2_load', function (e, response) {
147            msOptionsPrice.mSearch2.setOptionsByFilter();
148            $(msOptionsPrice.Product.form).each(function () {
149                $(this).trigger('change');
150                /*
151                 msOptionsPrice.Product.action('modification/get', this);
152                 */
153            });
154        });
155
156        /* get modification on "pdopage_load" */
157        msOptionsPrice.$doc.on('pdopage_load', function (e, response) {
158            $(msOptionsPrice.Product.form).each(function () {
159                $(this).trigger('change');
160            });
161        });
162
163        /* set options and get modification on "modification" click */
164        msOptionsPrice.$doc.on('click touchend', msOptionsPrice.Product.modification, function (e) {
165            if (!$(e.target).is(":submit")) {
166                msOptionsPrice.Product.action('modification/set', this);
167            }
168        });
169
170    };
171
172
173    msOptionsPrice.mSearch2 = {
174
175        setOptionsByFilter: function () {
176            /* if mse2Config set options */
177            if (typeof(mse2Config) != 'undefined' && mSearch2.initialized) {
178                var filterDelimeter = mse2Config.filter_delimeter || '|';
179                var valuesDelimeter = mse2Config.values_delimeter || ',';
180                var aliases = mse2Config.aliases || {};
181                var filters = mSearch2.getFilters();
182
183                for (i in filters) {
184                    if (!filters.hasOwnProperty(i)) {
185                        continue;
186                    }
187
188                    var filterName = String(i);
189                    var filterValue = String(filters[i]).split(valuesDelimeter);
190
191                    if (typeof(aliases[filterName]) != 'undefined') {
192                        filterName = aliases[filterName];
193                    }
194
195                    filterName = String(filterName).split(filterDelimeter);
196
197                    switch (filterName[0]) {
198
199                        case 'msoption':
200                            msOptionsPrice.Tools.setOptionValue(filterName[1], filterValue);
201                            break;
202
203                    }
204                }
205            }
206        },
207
208    };
209
210
211    msOptionsPrice.miniShop2 = {
212        initialize: function () {
213            if (typeof(miniShop2) == 'undefined') {
214                console.log('[msOptionsPrice:Error] Initialization Error. msOptionsPrice required');
215                return false;
216            }
217
218            if (msOptionsPriceConfig.allow_remains) {
219                miniShop2.Callbacks.add('Cart.change.response.error', 'msoptionsprice', function (response) {
220                    var count = miniShop2.sendData.$form.find(miniShop2.Cart.countInput);
221                    count.val(count.attr('value'));
222                });
223
224                miniShop2.Callbacks.add('Cart.change.response.success', 'msoptionsprice', function (response) {
225                    var count = miniShop2.sendData.$form.find(miniShop2.Cart.countInput);
226                    count.removeClass(msOptionsPrice.options.errorClass);
227                });
228
229                miniShop2.Callbacks.add('Order.submit.before', 'msoptionsprice', function () {
230                    var result = msOptionsPrice.Order.action('order/check', miniShop2.sendData.$form);
231                    if (!result) {
232                        $(':button, a', miniShop2.Order.order).attr('disabled', false).prop('disabled', false);
233                    }
234                    return result;
235                });
236            }
237
238        },
239
240    };
241
242
243    msOptionsPrice.Order = {
244        action: function (action, form, data) {
245            var formData = new FormData($(form)[0]);
246
247            if (!msOptionsPrice.Tools.empty(data)) {
248                for (key in data) {
249                    if (!data.hasOwnProperty(key)) {
250                        continue;
251                    }
252                    formData.append(key, data[key]);
253                }
254            }
255
256            formData.append('action', action);
257            formData.append('ctx', msOptionsPriceConfig.ctx);
258
259            var request = $.ajax({
260                type: 'POST',
261                url: msOptionsPriceConfig.actionUrl,
262                dataType: 'json',
263                data: formData,
264                async: false,
265                cache: false,
266                contentType: false,
267                processData: false,
268                beforeSend: function () {
269                    msOptionsPrice.Spinner.show();
270
271                    return true;
272                },
273                success: function (response) {
274                    msOptionsPrice.Spinner.hide();
275
276                    msOptionsPrice.$doc.trigger('msoptionsprice_order_action', [action, form, response]);
277
278                    var data = response.data;
279                    var errors = [];
280
281                    if (!msOptionsPrice.Tools.empty(data.errors)) {
282                        errors.push(data.errors);
283                    }
284
285                    if (!response.success) {
286                        if (!msOptionsPrice.Tools.empty(response.message)) {
287                            miniShop2.Message.error(response.message);
288                        }
289
290                        if (!msOptionsPrice.Tools.empty(data.required)) {
291                            for (var key in data.required) {
292                                if (!data.required.hasOwnProperty(key)) {
293                                    continue;
294                                }
295                                var pls = data.required[key];
296                                var item = $('#' + key);
297                                var count = item.find(miniShop2.Cart.countInput);
298
299                                count.addClass(msOptionsPrice.options.errorClass);
300
301                                var f = count.closest('form');
302                                var err = item.find(msOptionsPrice.options.errorElement + '.' + msOptionsPrice.options.errorClass);
303                                if (err.length < 1) {
304                                    err = $("<" + msOptionsPrice.options.errorElement + "/>").appendTo(f.parent())
305                                        .addClass(msOptionsPrice.options.errorClass);
306                                }
307
308                                err.text(pls['message']).show();
309
310                            }
311                        }
312                    }
313                    else {
314                        if (!msOptionsPrice.Tools.empty(data.cart)) {
315                            for (var key in data.cart) {
316                                if (!data.cart.hasOwnProperty(key)) {
317                                    continue;
318                                }
319
320                                var pls = data.cart[key];
321                                var item = $('#' + key);
322                                if (item.length < 1) {
323                                    continue;
324                                }
325
326                                var count = item.find(miniShop2.Cart.countInput);
327
328                                count.removeClass(msOptionsPrice.options.errorClass);
329
330                                var err = item.find(msOptionsPrice.options.errorElement + '.' + msOptionsPrice.options.errorClass);
331                                err.text('').hide();
332                            }
333                        }
334                    }
335
336                    if (!msOptionsPrice.Tools.empty(errors)) {
337                        console.log(errors.join('<br>'));
338                    }
339
340                }
341            }).done(function (response) {
342
343            }).fail(function (jqXHR, textStatus, errorThrown) {
344
345            });
346
347            if (!!request.responseJSON) {
348                msOptionsPrice.Spinner.hide();
349
350                return request.responseJSON.success || false;
351            }
352
353            return true;
354        }
355    };
356
357
358    msOptionsPrice.Product = {
359
360        action: function (action, form, data) {
361
362            var formData = new FormData($(form)[0]);
363
364            if (!msOptionsPrice.Tools.empty(data)) {
365                for (key in data) {
366                    if (!data.hasOwnProperty(key)) {
367                        continue;
368                    }
369                    formData.append(key, data[key]);
370                }
371            }
372
373            formData.append('action', action);
374            formData.append('ctx', msOptionsPriceConfig.ctx);
375
376            $.ajax({
377                type: 'POST',
378                url: msOptionsPriceConfig.actionUrl,
379                dataType: 'json',
380                data: formData,
381                async: true,
382                cache: false,
383                contentType: false,
384                processData: false,
385                beforeSend: function () {
386                    msOptionsPrice.Spinner.show();
387                    msOptionsPrice.Product.submitDisabled($(form)[0]);
388
389                    return true;
390                },
391                success: function (response) {
392                    msOptionsPrice.Spinner.hide();
393                    msOptionsPrice.Product.submitEnabled($(form)[0]);
394
395                    msOptionsPrice.$doc.trigger('msoptionsprice_product_action', [action, form, response]);
396
397                    if (response.success && response.data) {
398
399                        var data = response.data;
400                        var errors = [];
401                        var html;
402
403                        if (!msOptionsPrice.Tools.empty(data.errors)) {
404                            errors.push(data.errors);
405                        }
406
407                        if (!msOptionsPrice.Tools.empty(data.modification)) {
408                            ['name', 'article', 'count', 'weight', 'cost', 'old_cost', 'price', 'mass', 'msbonus'].filter(function (key) {
409                                if (msOptionsPrice.Product[key]) {
410                                    var value = data.modification[key];
411
412                                    switch (key) {
413                                        case 'old_cost':
414                                            if (data.modification[key] == data.modification['cost']) {
415                                                value = 0;
416                                            }
417                                            break;
418                                        default:
419                                            break;
420                                    }
421
422                                    if (msOptionsPrice.Tools.empty(value) && !msOptionsPriceConfig['allow_zero_' + key]) {
423                                        return true;
424                                    }
425
426                                    msOptionsPrice.Tools.setValue(null, value, key, data.rid);
427                                }
428                            });
429
430
431                            key = 'description';
432                            html = $(msOptionsPrice.Product.prefix + data.rid + msOptionsPrice.Product.prefix + key);
433                            if (html.length > 0) {
434                                html.html(data.modification[key] || "");
435                            }
436
437                        }
438
439                        /* set modification/set */
440                        var msoptionsprice_mid = $(msOptionsPrice.Product.prefix + data.rid).closest(msOptionsPrice.Product.form).find('input[name="mid"]');
441                        if (msoptionsprice_mid.length) {
442                            if (action == 'modification/set') {
443                                msoptionsprice_mid.val(data.modification.id);
444                            }
445                            if (action == 'modification/get') {
446                                msoptionsprice_mid.val(data.modification.id);
447                            }
448                        }
449
450                        /* set image  */
451                        if (miniShop2.Gallery && !msOptionsPrice.Tools.empty(data.modification.images) && msOptionsPrice.Tools.empty(data.set.options)) {
452                            $('.fotorama').on('fotorama:load', function (e, fotorama, extra) {
453                                if (extra && extra.frame && extra.frame.iid == data.modification.images[0]) {
454                                    msOptionsPrice.Tools.setGalleryImage(extra.frame.rid, extra.frame.iid);
455                                }
456                            });
457                            msOptionsPrice.Tools.setGalleryImage(data.rid, data.modification.images[0]);
458                        } else if (miniShop2.Gallery && !msOptionsPrice.Tools.empty(data.modification.images) && !msOptionsPrice.Tools.empty(data.set.image)) {
459                            msOptionsPrice.Tools.setGalleryImage(data.rid, data.modification.images[0]);
460                        }
461
462                        /* set options */
463                        var set = !msOptionsPrice.Tools.empty(data.set.options);
464
465                        /* set msal */
466                        var msal = data.options['msal'];
467                        if (!set && !msOptionsPrice.Tools.empty(msal)) {
468                            data.options = {
469                                'msal': msal
470                            };
471                            set = true;
472                        }
473
474                        if (set) {
475                            for (var key in data.options) {
476                                if (!data.options.hasOwnProperty(key)) {
477                                    continue;
478                                }
479                                var value = data.options[key];
480                                if (typeof value === "object") {
481                                    for (idx in value) {
482                                        var _key = [key, idx];
483                                        var _value = value[idx];
484
485                                        _value = msOptionsPrice.Tools.formatOptionValue(key, _value);
486                                        msOptionsPrice.Tools.setOptionValue(_key, _value, data.rid);
487                                    }
488                                }
489                                else {
490                                    value = msOptionsPrice.Tools.formatOptionValue(key, value);
491                                    msOptionsPrice.Tools.setOptionValue(key, value, data.rid);
492                                }
493                            }
494                        }
495
496                        // html
497                        for (var key in data.options) {
498                            if (!data.options.hasOwnProperty(key)) {
499                                continue;
500                            }
501
502                            html = $(msOptionsPrice.Product.prefix + data.rid + msOptionsPrice.Product.prefix + key);
503                            if (html.length > 0) {
504                                html.html(data.options[key]);
505                            }
506                        }
507
508
509                        if (!msOptionsPrice.Tools.empty(errors)) {
510                            console.log(errors.join('<br>'));
511                        }
512                    }
513                    else if (!response.success) {
514
515                    }
516                }
517            }).done(function (response) {
518
519            }).fail(function (jqXHR, textStatus, errorThrown) {
520                msOptionsPrice.Spinner.hide();
521                msOptionsPrice.Product.submitEnabled($(form)[0]);
522
523            });
524        },
525
526
527        processOptions: function (form) {
528            var $form = $(form),
529                $constraints,
530                $related,
531                $enabled = [],
532                $disabled = [],
533                constraints,
534                options = {},
535                selector = 'input, option';
536
537            $constraints = $form.find("[data-constraints]");
538            $related = $form.find("[data-constraints]").find(selector);
539
540            constraints = $constraints.map(function () {
541                return $(this).data('constraints');
542            });
543
544            constraints = $.grep(constraints, function (v, k) {
545                return $.inArray(v, constraints) === k;
546            });
547            constraints.sort();
548
549            constraints.filter(function (key) {
550                var value = msOptionsPrice.Tools.getOptionValue(key, form);
551                if (typeof (value) != 'undefined') {
552                    options[key] = value;
553                }
554                return true;
555            });
556
557            if (options.length < 1) {
558                return;
559            }
560
561            $related.filter(function () {
562                var $curr = $(this);
563
564                switch (this.tagName) {
565                    case 'OPTION':
566                        $curr = $curr.parent('select');
567                        break;
568
569                }
570
571                var opts = [];
572                var currConstraints = $curr.data('constraints') || $curr.closest('[data-constraints]').data('constraints') || [];
573
574                currConstraints.filter(function (key) {
575                    if (options.hasOwnProperty(key)) {
576                        opts.push('' + key + '=' + msOptionsPrice.Tools.escapedValue(options[key]) + '');
577                        //opts.push('' + key + '=' + options[key] + '');
578                        //opts.push('"'+key+'='+options[key]+'"');
579                    }
580                });
581
582                opts.sort();
583               /* opts = opts.join('(.*?)');
584                opts = msOptionsPrice.Tools.escapedValue(opts);
585                opts = new RegExp(opts);*/
586                opts = opts.join('([^\"]+)');
587                opts = new RegExp(opts+'([\&\"])');
588
589                if (this.dataset.relations && msOptionsPrice.Tools.escapedValue(this.dataset.relations).match(opts)) {
590                    $enabled.push(this);
591                }
592                else {
593                    $disabled.push(this);
594                }
595                return true;
596            });
597
598            $enabled = $($enabled).map(function (i, self) {
599                return self;
600            });
601            $disabled = $($disabled).map(function (i, self) {
602                return self;
603            });
604
605            $enabled.attr('disabled', false).prop('disabled', false);
606            $disabled.attr('disabled', true).prop('disabled', true);
607
608            $enabled.closest(msOptionsPrice.Product.inputParent).show();
609            $disabled.closest(msOptionsPrice.Product.inputParent).hide();
610
611            $constraints.map(function () {
612                var $fields = $(this).find(selector);
613                if ($fields.length < 1) {
614                    return true;
615
616                }
617                switch ($fields[0].tagName) {
618                    case 'INPUT':
619                        if ($fields.filter(':not(:disabled):checked').length < 1) {
620                            $fields.filter(':not(:disabled):first').prop('checked', true);
621                        }
622                        break;
623
624                    case 'OPTION':
625                        if ($fields.filter(':not(:disabled):checked:selected').length < 1) {
626                            $fields.filter(':not(:disabled):first').prop('checked', true).prop('selected', true);
627                        }
628                        break;
629                }
630            });
631        },
632
633        submitDisabled: function (form) {
634            $(form).find(':button[value="cart/add"], a[value="cart/add"]').attr('disabled', true).prop('disabled', true);
635        },
636
637        submitEnabled: function (form) {
638            $(form).find(':button[value="cart/add"], a[value="cart/add"]').attr('disabled', false).prop('disabled', false);
639        },
640
641    };
642
643
644    msOptionsPrice.Tools = {
645        escapedValue: function (value) {
646            return value
647                .replace(new RegExp("\\^", "g"), '{v}')
648                .replace(new RegExp("\\$", "g"), '{s}')
649                .replace(new RegExp('\\*', "g"), '{z}')
650                .replace(new RegExp('\\+', "g"), '{p}');
651        },
652
653        arrayIntersect: function (array1, array2) {
654            var result = array1.filter(function (n) {
655                return array2.indexOf(n) !== -1;
656            });
657
658            return result;
659        },
660
661        inArray: function (needle, haystack) {
662            for (key in haystack) {
663                if (haystack[key] == needle) return true;
664            }
665
666            return false;
667        },
668
669        empty: function (value) {
670            return (typeof(value) == 'undefined' || value == 0 || value === null || value === false || (typeof(value) == 'string' && value.replace(/\s+/g, '') == '') || (typeof(value) == 'object' && value.length == 0));
671        },
672
673        setValue: function (self, value, key, rid) {
674            var $this = null;
675            if (self) {
676                $this = $(self);
677            }
678            else if (key && rid) {
679                $this = $(msOptionsPrice.Product[key] + msOptionsPrice.Product.prefix + rid);
680            }
681
682            if (!$this.length && !rid) {
683                $this = $(msOptionsPrice.Product[key]);
684            }
685
686            if (!$this.length) {
687                return;
688            }
689
690            var tagName = $this[0].tagName;
691            var tagType = $this[0].type;
692
693            switch (true) {
694                case tagName == 'INPUT' && (key instanceof Array) && msOptionsPrice.Tools.inArray('msal', key):
695                    $this.val(value).trigger('change');
696                    break;
697                case tagName == 'INPUT' && tagType == 'checkbox':
698                    if (!(value instanceof Array)) {
699                        value = [value];
700                    }
701
702                    if (msOptionsPrice.Tools.inArray($this.val(), value)) {
703                        $this.prop('checked', true);
704                    }
705                    else {
706                        $this.prop('checked', false);
707                    }
708                    break;
709                case tagName == 'INPUT' && tagType != 'radio':
710                    $this.val(value);
711                    break;
712                case tagName == 'INPUT' && tagType == 'radio':
713                    if (!(value instanceof Array)) {
714                        value = [value];
715                    }
716                    value.filter(function (item, r) {
717                        if ($this.val() == item) {
718                            $this.prop('checked', true);
719                        }
720                        else {
721                            $this.prop('checked', false);
722                        }
723                    }, this);
724                    break;
725                case tagName == 'SELECT':
726                    if (!(value instanceof Array)) {
727                        value = [value];
728                    }
729                    value.filter(function (item, r) {
730                        if ($this.find('option[value="' + item + '"]').length) {
731                            $this.val([item]);
732                        }
733                    }, this);
734                    break;
735
736                default:
737                    switch (true) {
738                        case key == 'cost':
739                            /* refresh msal price */
740                            msOptionsPrice.Tools.setValue(null, value, 'msal_price', rid);
741                            break;
742                        case  key == 'old_cost' && msOptionsPrice.Tools.empty(value):
743                            /* hide empty old_cost */
744                            $this.parent().hide();
745                            break;
746                        case  key == 'old_cost' && !msOptionsPrice.Tools.empty(value):
747                            /* show not empty old_cost */
748                            $this.parent().show();
749                            break;
750                    }
751
752                    value = msOptionsPrice.Tools.formatOptionValue(key, value);
753                    $this.html(value);
754
755                    break;
756            }
757
758            return;
759        },
760
761        getOptionName: function (key) {
762            var name = 'options';
763            if (!(key instanceof Array)) {
764                key = [key];
765            }
766
767            key.filter(function (i) {
768                name += '[' + i + ']';
769            });
770
771            return name.toString();
772        },
773
774        getOptionValue: function (key, form) {
775            var value;
776            var name = msOptionsPrice.Tools.getOptionName(key);
777            var $field = $(form).find('[name="' + name + '"]');
778
779            if ($field.length > 0) {
780                switch ($field[0].tagName) {
781                    case 'INPUT':
782                        value = $field.filter(':checked').val();
783                        break;
784                    case 'SELECT':
785                        value = $field.val();
786                        break;
787                }
788            }
789            return value;
790        },
791
792        setOptionValue: function (key, value, rid) {
793            var inputs;
794            var name = msOptionsPrice.Tools.getOptionName(key);
795
796            if (rid) {
797                inputs = $(msOptionsPrice.Product.cost + msOptionsPrice.Product.prefix + rid)
798                    .closest(msOptionsPrice.Product.form)
799                    .find('[name="' + name + '"]');
800            }
801            else {
802                inputs = $(msOptionsPrice.Product.cost)
803                    .closest(msOptionsPrice.Product.form)
804                    .find('[name="' + name + '"]');
805            }
806
807            if (inputs) {
808                inputs.each(function () {
809                    msOptionsPrice.Tools.setValue(this, value, key);
810                });
811            }
812
813            return;
814        },
815
816        setGalleryImage: function (rid, iid) {
817            var fotorama = $('.fotorama__img[data-rid="' + rid + '"]').closest(msOptionsPrice.Product.gallery).find('.fotorama').data('fotorama');
818
819            if (!!fotorama) {
820                if (fotorama.activeFrame['iid'] == iid) {
821                    return;
822                }
823                fotorama.data.filter(function (item, r) {
824                    if (item['iid'] == iid) {
825                        fotorama.show(item['i'] - 1);
826                    }
827                }, this);
828            }
829        },
830
831        formatOptionValue: function (key, value) {
832
833            switch (key) {
834                case 'cost':
835                case 'old_cost':
836                case 'price':
837                case 'old_price':
838                    if (miniShop2 && miniShop2.Utils.formatPrice) {
839                        value = miniShop2.Utils.formatPrice(value);
840                    }
841                    break;
842                case 'mass':
843                case 'weight':
844                    if (miniShop2 && miniShop2.Utils.formatWeight) {
845                        value = miniShop2.Utils.formatWeight(value);
846                    }
847                    break;
848                default:
849                    break;
850            }
851
852            return value;
853        },
854
855        /* TODO remove */
856        setInputValue: function (key, value, rid) {
857            var inputs;
858
859            if (rid) {
860                inputs = $(msOptionsPrice.Product.cost + msOptionsPrice.Product.prefix + rid)
861                    .closest(msOptionsPrice.Product.form)
862                    .find('[name="options[' + key + ']"]');
863            }
864            else {
865                inputs = $(msOptionsPrice.Product.cost)
866                    .closest(msOptionsPrice.Product.form)
867                    .find('[name="options[' + key + ']"]');
868            }
869
870            if (!inputs) {
871                return false;
872            }
873
874            inputs.each(function () {
875                msOptionsPrice.Tools.setValue(this, value);
876            });
877        },
878
879    };
880
881
882    msOptionsPrice.Spinner = {
883        create: function () {
884            return $('<div class="msoptionsprice-spinner"></div>');
885        },
886        show: function () {
887            if (!msOptionsPrice.options.showSpinner) {
888                return;
889            }
890            msOptionsPrice.$spinner = msOptionsPrice.$spinner || this.create();
891            msOptionsPrice.$body.append(msOptionsPrice.$spinner);
892
893            return msOptionsPrice.$spinner.show();
894        },
895
896        hide: function () {
897            if (msOptionsPrice.$spinner) {
898                return msOptionsPrice.$spinner.remove();
899            }
900        },
901    };
902
903
904    $(document).ready(function ($) {
905
906    });
907
908
909    msOptionsPrice.initialize();
910    window.msOptionsPrice = msOptionsPrice;
911
912})(window, document, jQuery, msOptionsPriceConfig);
913
914
915/* event example */
916/*$(document).on('msoptionsprice_product_action', function (e, action, form, response) {
917
918    //console.log(action, form, response);
919});*/
920
921/*
922reload gallery
923$(document).on('msoptionsprice_product_action', function (e, action, form, r) {
924    if (action == 'modification/get' && r.success && r.data) {
925        var m = r.data.modification || {};
926
927        var thumbs = m.thumbs || {main:['default.png']};
928        var fotorama = $(form).closest('#msProduct').find('.fotorama').data('fotorama');
929        if (fotorama) {
930            var images = [];
931            (thumbs.main || []).filter(function (href) {
932                images.push({img: href, caption: ''})
933            });
934        }
935    }
936});*/

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.