PageSourceSearch

https://b2b.unsoiralopera.com/modules/obsattributedesc/views/js/obsattributedesc.js

js unsoiralopera.com collected 2026-10-02 19:38:52 UTC 4,153 bytes, 121 lines download raw bytes

1/**
2 * 2011-2025 OBSOLUTIONS WD S.L. All Rights Reserved.
3 *
4 * NOTICE:  All information contained herein is, and remains
5 * the property of OBSOLUTIONS WD S.L. and its suppliers,
6 * if any.  The intellectual and technical concepts contained
7 * herein are proprietary to OBSOLUTIONS WD S.L.
8 * and its suppliers and are protected by trade secret or copyright law.
9 * Dissemination of this information or reproduction of this material
10 * is strictly forbidden unless prior written permission is obtained
11 * from OBSOLUTIONS WD S.L.
12 *
13 *  @author    OBSOLUTIONS WD S.L. <http://addons.prestashop.com/en/65_obs-solutions>
14 *  @copyright 2011-2025 OBSOLUTIONS WD S.L.
15 *  @license   OBSOLUTIONS WD S.L. All Rights Reserved
16 *  International Registered Trademark & Property of OBSOLUTIONS WD S.L.
17 */
18function OBSready(callbackFunc) {
19    if (document.readyState !== 'loading') {
20        callbackFunc();
21    } else if (document.addEventListener) {
22        document.addEventListener('DOMContentLoaded', callbackFunc);
23    } else {
24        document.attachEvent('onreadystatechange', function () {
25            if (document.readyState === 'complete') {
26                callbackFunc();
27            }
28        });
29    }
30}
31
32OBSready(function () {
33    function createOrUpdateDescElement(id, content, $parent) {
34        let $desc = $('#obsAttrDescGroup_' + id);
35        if ($desc.length === 0) {
36            $desc = $('<div>', {
37                id: 'obsAttrDescGroup_' + id,
38                class: 'obsDescElement'
39            }).appendTo($parent);
40        }
41        $desc.html(content);
42    }
43
44    function clearDescContent(id) {
45        const $descGroup = $('#obsAttrDescGroup_' + id);
46        if ($descGroup.length) {
47            $descGroup.html('');
48        }
49    }
50
51    function obsShowDesc(select, text) {
52        if ($('.obsAttrRadio').length === 0) {
53            const $select = $(select);
54            const id = $select.attr('id');
55            const $parent = $select.parent();
56            createOrUpdateDescElement(id, text, $parent);
57        }
58    }
59
60    function obsShowColorDesc(select, text) {
61        const $select = $(select);
62        const id = $select.attr('data-product-attribute');
63        const $container = $select.closest('.ce-product-variants__item');
64        createOrUpdateDescElement(id, text, $container);
65    }
66
67    function obsHideDesc(select) {
68        const name = $(select).attr('id');
69        clearDescContent(name);
70    }
71
72    function obsHideColorDesc(select) {
73        const name = $(select).attr('data-product-attribute');
74        clearDescContent(name);
75    }
76
77    function handleAttributeClick(input, type = 'default') {
78        const $input = $(input);
79        const value = $input.val();
80        const $descSource = $('#obsAttrDesc_' + value);
81        const text = $descSource.length ? $descSource.html() : '';
82
83        if (text) {
84            if (type === 'default') obsShowDesc(input, text);
85            else obsShowColorDesc(input, text);
86        } else {
87            if (type === 'default') obsHideDesc(input);
88            else obsHideColorDesc(input);
89        }
90    }
91
92    function initAttributeDescriptions() {
93        $('.product-variants-item .form-control-select option:selected').each(function () {
94            handleAttributeClick($(this).parent());
95        });
96
97        $('.ce-product-variants__item input[checked]').each(function () {
98            const type = $(this).hasClass('input-radio') ? 'radio' : 'color';
99            handleAttributeClick(this, type);
100        });
101    }
102
103    $('#content-wrapper').on('change', '.product-variants-item select option', function () {
104        handleAttributeClick($(this).parent());
105    });
106
107    $('#content-wrapper').on('click', '.product-variants-item ul li .input-color', function () {
108        handleAttributeClick(this, 'color');
109    });
110
111    $('#content-wrapper').on('click', '.ce-product-variants__item input', function () {
112        handleAttributeClick(this, 'radio');
113    });
114
115    prestashop.on('updatedProduct', function () {
116        initAttributeDescriptions();
117    });
118
119    // Inicializar descripciones al cargar por primera vez
120    initAttributeDescriptions();
121});

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.