PageSourceSearch

https://www.pinglighting.com/modules/ets_reviews/views/js/front.js

js pinglighting.com collected 2026-10-06 18:27:41 UTC 18,594 bytes, 428 lines download raw bytes

1/**
2  * Copyright ETS Software Technology Co., Ltd
3 *
4 * NOTICE OF LICENSE
5 *
6 * This file is not open source! Each license that you purchased is only available for 1 website only.
7 * If you want to use this file on more websites (or projects), you need to purchase additional licenses.
8 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
9 *
10 * DISCLAIMER
11 *
12 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
13 * versions in the future.
14 *
15 * @author ETS Software Technology Co., Ltd
16 * @copyright  ETS Software Technology Co., Ltd
17 * @license    Valid for 1 website (or project) for each purchase of license
18 */
19
20var ets_rv_fo = {
21    readURL: function (input) {
22        if (input.files && input.files[0]) {
23            var reader = new FileReader();
24            reader.onload = function (e) {
25                $('#ets_rv_avatar_thumbnail > img')
26                    .attr({'src': e.target.result, 'title': input.files[0].name})
27                    .css('max-width', '110px')
28                    .addClass('image-loading')
29                ;
30            };
31            reader.readAsDataURL(input.files[0]); // convert to base64 string
32        }
33    },
34    copyToClipboard: function (el) {
35        var $temp = $("<input>");
36        $("body").append($temp);
37        $temp.val(el.text()).select();
38        document.execCommand("copy");
39        $temp.remove();
40        el.parent().addClass('copied');
41        //showSuccessMessage(ets_rv_copied_translate);
42        setTimeout(function () {
43            el.removeClass('copy');
44            el.parent().removeClass('copied');
45        }, 1500);
46    },
47    isSafari: function () {
48        var e = navigator, c = e.userAgent, g = e.vendor;
49        return (!(/(Chrome|CriOS)\s*\/\s*(\d[\d\.]*)/i).test(c) && ((/Apple/i).test(g) || !g) && (/Safari\s*\/\s*(\d[\d\.]*)/i).test(c));
50    }
51};
52var ets_rv_op = {
53    initialize: function () {
54        if ($('body[id=identity]').length > 0 && $('#customer-form input[name=new_password], #identity input[name=new_password]').length > 0 && $('.ets_rv_upload_avatar').length > 0) {
55            var form_field = $('.ets_rv_upload_avatar .form-group').clone(true);
56            $('#customer-form input[name=new_password], #identity input[name=new_password]').parents('.form-group').after(form_field);
57            $('.ets_rv_upload_avatar').remove();
58        }
59    },
60};
61$(document).ready(function () {
62    var maskCustomerNameText = function (name) {
63        var value = (name || '').toString().trim();
64        if (!value) {
65            return '';
66        }
67        var chars = value.split('');
68        if (chars.length <= 1) {
69            return value;
70        }
71        if (chars.length === 2) {
72            return chars[0] + '*';
73        }
74        return chars[0] + '***' + chars[chars.length - 1];
75    };
76
77    var applyCustomerNameMask = function () {
78        $('.ets_rv_wrap .ets-rv-comment-author-name').each(function () {
79            var $el = $(this);
80            var raw = ($el.text() || '').trim();
81            if (raw) {
82                $el.text(maskCustomerNameText(raw));
83            }
84        });
85        $('.ets_rv_wrap .ets-rv-comment-author-avatar[title]').each(function () {
86            var $el = $(this);
87            var title = ($el.attr('title') || '').trim();
88            if (title) {
89                $el.attr('title', maskCustomerNameText(title));
90            }
91        });
92    };
93
94    var getReviewDesktopTab = function () {
95        return $('a[data-toggle="tab"][data-is-review="1"]').first();
96    };
97
98    var getReviewMobileAccordion = function () {
99        return $('.accordion-title.js-accordion[data-is-review="1"]').first();
100    };
101
102    var getReviewPane = function () {
103        var $reviewDesktopTab = getReviewDesktopTab();
104        var $reviewMobileAccordion = getReviewMobileAccordion();
105        var paneSelector = '';
106
107        if ($reviewDesktopTab.length > 0) {
108            paneSelector = $reviewDesktopTab.attr('href') || '';
109        }
110        if (!paneSelector && $reviewMobileAccordion.length > 0) {
111            paneSelector = $reviewMobileAccordion.attr('href') || '';
112        }
113
114        if (paneSelector && paneSelector.charAt(0) === '#') {
115            return $(paneSelector).first();
116        }
117
118        return $();
119    };
120
121    var syncInnerReviewTabState = function () {
122        var $reviewFilterTab = $('.ets_rv_filter .ets_rv_tab_reviews').first();
123        var $reviewContent = $('#ets-rv-product-comments-list').first();
124        var $questionFilterTab = $('.ets_rv_filter .ets_rv_tab_questions').first();
125        var $questionContent = $('#ets-rv-product-questions-list').first();
126
127        if ($reviewFilterTab.length > 0 && !$reviewFilterTab.hasClass('active')) {
128            $('.ets_rv_filter .ets_rv_tab.active').removeClass('active');
129            $reviewFilterTab.addClass('active');
130        }
131        if ($reviewContent.length > 0 && !$reviewContent.hasClass('active')) {
132            $('.ets_rv_tabs .ets_rv_tab_content.active').removeClass('active');
133            $reviewContent.addClass('active');
134        }
135        if ($questionFilterTab.length > 0) {
136            $questionFilterTab.removeClass('active');
137        }
138        if ($questionContent.length > 0) {
139            $questionContent.removeClass('active');
140        }
141
142        if ($('.ets_rv_review_photos_wrap').length > 0) {
143            $('.ets_rv_review_photos_wrap').addClass('active');
144        }
145
146        if ($reviewContent.length > 0 && $reviewContent.find('.ets-rv-product-comment-list-item').length < 1 && typeof productC
146ommentsETS !== "undefined" && typeof productCommentsETS.paginate === "function") {
147            productCommentsETS.paginate({page: 1}, 'comment');
148        }
149        $(document).trigger('ets-rv:review-tab-activated');
150    };
151
152    var openReviewTabAndScroll = function () {
153        var isMobile = window.matchMedia('(max-width: 991px)').matches;
154        var $reviewPane = getReviewPane();
155        var $reviewDesktopTab = getReviewDesktopTab();
156        var $reviewMobileAccordion = getReviewMobileAccordion();
157        var $reviewAnchor = $('#ets-rv-product-comments-list-header').first();
158        var activateDesktopReviewTab = function () {
159            if ($reviewPane.length < 1 && $reviewDesktopTab.length > 0) {
160                var href = $reviewDesktopTab.attr('href');
161                if (href && href.charAt(0) === '#') {
162                    $reviewPane = $(href).first();
163                }
164            }
165
166            if ($reviewDesktopTab.length > 0) {
167                if (typeof $reviewDesktopTab.tab === 'function') {
168                    $reviewDesktopTab.tab('show');
169                } else {
170                    $reviewDesktopTab.trigger('click');
171                }
172            }
173
174            if ($reviewPane.length > 0) {
175                var paneId = $reviewPane.attr('id');
176                $('#wrapper-tab-product .tab-content .tab-pane, #wrapper-tab-product .tab-content .wc-tab')
177                    .removeClass('active in show');
178                $reviewPane.addClass('active in show').show();
179
180                $('#wrapper-tab-product [data-toggle="tab"]').each(function () {
181                    var $tab = $(this);
182                    var active = false;
183                    if (paneId && $tab.attr('href') === '#' + paneId) {
184                        active = true;
185                    }
186                    if (!active && $tab.is('[data-is-review="1"]') && $reviewPane.is('[data-is-review="1"]')) {
187                        active = true;
188                    }
189                    $tab.toggleClass('active', active).attr('aria-selected', active ? 'true' : 'false');
190                    $tab.closest('.nav-item').toggleClass('active', active);
191                });
192            } else if ($reviewDesktopTab.length > 0) {
193                $reviewDesktopTab.addClass('active').attr('aria-selected', 'true').closest('.nav-item').addClass('active');
194            }
195        };
196
197        if (isMobile) {
198            $('.accordion-title.js-accordion.active_accordion').not($reviewMobileAccordion).each(function () {
199                var $activeAccordion = $(this);
200                var target = $activeAccordion.attr('href');
201                $activeAccordion.removeClass('active_accordion').attr('aria-expanded', 'false');
202                if (target && target.charAt(0) === '#') {
203                    $(target).removeClass('active in show').attr('aria-expanded', 'false').hide();
204                }
205            });
206
207            if ($reviewMobileAccordion.length > 0 && !$reviewMobileAccordion.hasClass('active_accordion')) {
208                $reviewMobileAccordion.trigger('click');
209            }
210
211            if ($reviewMobileAccordion.length > 0) {
212                $reviewMobileAccordion.addClass('active_accordion').attr('aria-expanded', 'true');
213            }
214
215            if ($reviewPane.length > 0) {
216                $reviewPane.addClass('active in show').show().attr('aria-expanded', 'true');
217            }
218        } else {
219            var reviewTabActive = ($reviewPane.length > 0 && $reviewPane.hasClass('active')) || ($reviewDesktopTab.length > 0 && ($reviewDesktopTab.hasClass('active') || $reviewDesktopTab.parent().hasClass('active')));
220            if (!reviewTabActive) {
221                activateDesktopReviewTab();
222            }
223        }
224
225        syncInnerReviewTabState();
226
227        if ($('.ets_rv_tab_reviews').length > 0 && !$('.ets_rv_tab_reviews').hasClass('active')) {
228            $('.ets_rv_tab_reviews').trigger('click');
229        }
230
231        setTimeout(function () {
232            if (!isMobile && $reviewDesktopTab.length > 0 && !$reviewDesktopTab.hasClass('active') && !$reviewDesktopTab.closest('.nav-item').hasClass('active')) {
233                activateDesktopReviewTab();
234            }
235            var $target = $reviewAnchor.length > 0 ? $reviewAnchor : $reviewPane;
236            if ($target.length > 0 && $target.offset()) {
237                $('html, body').animate({
238                    scrollTop: $target.offset().top - 120
239                }, 500);
240            }
241        }, 180);
242    };
243    var reviewDesktopTabSelector = 'a[data-toggle="tab"][data-is-review="1"]';
244    var reviewAccordionSelector = '.accordion-title.js-accordion[data-is-review="1"]';
245    var deactivateReviewOuterTabState = function () {
246        var $reviewPane = getReviewPane();
247        $(reviewDesktopTabSelector)
248            .removeClass('active')
249            .attr('aria-selected', 'false')
250            .closest('.nav-item')
251            .removeClass('active');
252        $(reviewAccordionSelector)
253            .removeClass('active_accordion')
254            .attr('aria-expanded', 'false');
255        if ($reviewPane.length > 0) {
256            $reviewPane
257                .removeClass('active in show')
258                .attr('aria-expanded', 'false');
259        }
260    };
261
262
263    if ( $('.product-quantity .ets-rv-product-comments-additional-info').length > 0 ){
264        var review_under_addcart = $('.product-quantity .ets-rv-product-comments-additional-info').clone();
265        $('.product-quantity .ets-rv-product-comments-additional-info').remove();
266        $('.product-quantity').after(review_under_addcart);
267    }
268    applyCustomerNameMask();
269    if (window.location.hash === '#review') {
270        setTimeout(syncInnerReviewTabState, 120);
271    }
272    ets_rv_op.initialize();
273    $(document).on('hooksLoaded', function () {
274        ets_rv_op.initialize();
275    });
276
277    if (typeof funcPCETS !== "undefined") {
278        var avatar = $('.ets_rv_author_avatar.gene-color');
279        if (avatar.length > 0)
280            avatar.css('background-color', funcPCETS.colorHex(avatar.data('profile')));
281    }
282
283    var star_content = $('.product-list-reviews .ets-rv-star-content');
284    if (star_content.length > 0) {
285        star_content.each(function () {
286            $(this).parents('._thumb-container').addClass('hasreview');
287        });
288    }
289
290    $(document).on('click', '.extra_videos_show', function () {
291        $(this).parents('.multi_videos,.ets_rv_videos').addClass('show_videos');
292
293    });
294    $(document).on('click', 'a.ets-rv-btn-read-user, a.goto-product-review-tab', function (e) {
295        e.preventDefault();
296        openReviewTabAndScroll();
297    });
298    $(document).on('click', reviewDesktopTabSelector + ', ' + reviewAccordionSelector, function () {
299        setTimeout(syncInnerReviewTabState, 120);
300    });
301    $(document).on('click', '#wrapper-tab-product [data-toggle="tab"], .accordion-title.js-accordion', function () {
302        var $tab = $(this);
303        if ($tab.is(reviewDesktopTabSelector) || $tab.is(reviewAccordionSelector)) {
304            return;
305        }
306        setTimeout(deactivateReviewOuterTabState, 0);
307    });
308
309    if ($('body#comment').length > 0 || $('body[id$=comment]').length > 0) {
310        productCommentsETS.paginate({page: 1}, $('.ets_rv_comments_wrap.question').length > 0 ? 'question' : 'comment');
311        if ($('.ets_rv_comments_wrap').length > 0) {
312            $('.ets_rv_btn_show_answer, .nb-comment.question').addClass('active');
313            $('.ets_rv_answer_list.answer, .ets_rv_comment_list').addClass('show_content');
314        }
315    }
316    $(document).on('click', '.ets_rv_voucher_box.code', function () {
317        ets_rv_fo.copyToClipboard($(this));
318    });
319    $(document).on('keyup', 'body', function (e) {
320        if ($('.ets-rv-product-comment-modal textarea.error').length > 0) {
321            var textarea_content = $('textarea.error').val();
322            if (textarea_content.length > 0) {
323                $('textarea.error').removeClass('error');
324            }
325        }
326        if ($('.ets-rv-product-comment-modal input.error').length > 0) {
327            var input_content = $('input.error').val();
328            if (input_content.length > 0) {
329                $('input.error').removeClass('error');
330            }
331        }
332    });
333    $(document).on('click', '#avatar-selectbutton', function () {
334        $('#customer-form input[name=avatar], #identity input[name=avatar]').trigger('click');
335    });
336    $(document).on('change', '#customer-form input[name=avatar], #identity input[name=avatar]', function () {
337        var _thumb = $('#ets_rv_avatar_thumbnail'),
338            form = _thumb.parents('form'),
339            image = _thumb.find('img')
340        ;
341        if (!_thumb.hasClass('loading') && $(this).val()) {
342            _thumb.addClass('loading');
343            $('#avatar-name').val(this.files[0].name);
344            if (!_thumb.find('img').length > 0) {
345                _thumb.append('<img/><span class="ets_rv_delete_avatar" title="' + _thumb.data('btn-delete-title') + '"><i class="fa fa-trash"> </i></span>');
346            }
347            ets_rv_fo.readURL(this);
348            var formData = new FormData(form[0]);
349            if (form.find('input[type="file"]').length > 0 && ets_rv_fo.isSafari()) {
350                form.find('input[type="file"]').each(function () {
351                    if (document.getElementById($(this).attr('id')).files.length === 0) {
352                        formData.delete($(this).attr('id'));
353                    }
354                });
355            }
356
357            formData.append('ajax', 1);
358            formData.append('action', 'uploadProfileImage');
359
360            $.ajax({
361                url: _thumb.data('upload-url'),
362                type: 'POST',
363                data: formData,
364                contentType: false,
365                processData: false,
366                dataType: 'json',
367                success: function (json) {
368                    _thumb.removeClass('loading');
369                    if (json) {
370                        image.removeClass('image-loading');
371                        if (json.errors) {
372                            if (!$('.ets_rv_profile_image .ets_rv_error').length > 0) {
373                                $('.ets_rv_profile_image').append('<div class="bootstrap"><div class="ets_rv_error alert alert-danger"></div></div>');
374                            }
375                            $('.ets_rv_profile_image .ets_rv_error').html(json.errors);
376                            image.hide();
377                            $('.post-comment-buttons button, .post-question-buttons button').removeClass('active');
378                        } else {
379                            if (json.msg)
380                                $.growl.notice({title: "", message: json.msg});
381                            if ($('.ets_rv_profile_image .bootstrap').length > 0) {
382                                $('.ets_rv_profile_image .bootstrap').hide();
383                                image.show();
384                            }
385                            form.find('#avatar-name, #avatar').val('');
386                        }
387                    }
388                },
389                error: function () {
390                    _thumb.removeClass('loading');
391                    $('.post-comment-buttons button, .post-question-buttons button').removeClass('active');
392                }
393            });
394        }
395    });
396
397    $(document).on('click', '.ets_rv_delete_avatar', function () {
398        var btn = $(this), _thumb = $('#ets_rv_avatar_thumbnail');
399        if (!btn.hasClass('active') && _thumb.data('upload-url') !== '') {
400            btn.addClass('active');
401            $.ajax({
402                url: _thumb.data('upload-url'),
403                type: 'POST',
404                data: 'ajax=1&action=deleteProfileImage',
405                dataType: 'json',
406                success: function (json) {
407                    btn.removeClass('active');
408                    if (json) {
409                        if (json.errors) {
410                            if (!$('.ets_rv_profile_image .ets_rv_error').length > 0) {
411                                $('.ets_rv_profile_image').append('<div class="bootstrap"><div class="ets_rv_error alert alert-danger"></div></div>');
412                            }
413                            $('.ets_rv_profile_image .ets_rv_error').html(json.errors);
414                        } else {
415                            if (json.msg)
416                                $.growl.notice({title: "", message: json.msg});
417                            _thumb.html('');
418                            $('#avatar-name').val('');
419                        }
420                    }
421                },
422                error: function () {
423                    btn.removeClass('active');
424                }
425            });
426        }
427    });
428});

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.