PageSourceSearch

https://www.caritasmalaga.es/main-files/themes/101wp-child/modules…/accordion-box-build.js?ver=1.0.0

js caritasmalaga.es collected 2026-09-26 14:53:54 UTC 4,915 bytes, 146 lines download raw bytes

1(function (scope, $) {
2
3    var instances = [];
4
5    function initializeInstance($obj) {
6
7        var $view = $obj;
8
9        function onCloseTouched(e) {
10            if (e) { e.preventDefault(); }
11            var $this = $(this).parents('div.item');
12            $view
13                .find('div.item')
14                .removeClass('opened')
15                .css('height', '244px');
16        }
17
18        function onMoreinfoToched(e) {
19            if (e) { e.preventDefault(); }
20            var $this = $(this).parents('div.item');
21            if ($this.hasClass('opened')) {
22                onCloseTouched(null);
23                return;
24            }
25            $view
26                .find('div.item')
27                .removeClass('opened');
28            $this
29                .css('height', 'auto')
30                .addClass('opened');
31            // Evento para cerrar
32            $this
33                .find('a.close')
34                .off('touchend', onCloseTouched)
35                .on('touchend', onCloseTouched);
36            $this
37                .find('div.second')
38                .css({
39                    height: 'auto' // $this.find('div.main').width()
40                });
41        }
42
43        function onCloseClicked(e) {
44            if (e) { e.preventDefault(); }
45            var $this = $view.find('div.item.opened');
46            $view.find('.second').removeAttr('style');
47            if ($view.find('.accordion-box-wrapper .item').length === 1) {
48                $view.find('div.item.opened .main').removeAttr('style');
49            }
50            $view
51                .find('div.item')
52                .removeClass('opened')
53                .css('width', $this.data('width'));
54        }
55
56        function onMoreinfoClicked(e) {
57            if (e) { e.preventDefault(); }
58            var $this = $(this).parents('div.item');
59            if ($this.hasClass('opened')) {
60                onCloseClicked(null);
61                return;
62            }
63            $view
64                .find('div.item')
65                .removeClass('opened')
66                .css('width', '0%');
67            $this
68                .css('width', '100%')
69                .addClass('opened');
70            // Evento para cerrar
71            $this
72            .find('a.close')
73            .off('click', onCloseClicked)
74            .on('click', onCloseClicked);
75
76            // 
77            var items = $view.find('.accordion-box-wrapper .item').length;
78            // var mainWidth = Math.floor($view.find('.container').width() / items);
79            var mainWidth = (items === 1) ? ($view.find('.module-accordion-box-container-wrapper').width() / 2) : $view.find('.item').width();
80            // console.log('MainWidth: ', items, mainWidth);
81            var secondWidth = Math.floor($view.find('.module-accordion-box-container-wrapper').width() - mainWidth);
82
83            // Content
84            $this
85            .find('div.second')
86            .css({
87                width: secondWidth // $this.find('div.main').width()
88            });
89            // Add the same width to wrapper to fix the text movement
90            $this.find('div.second .wrapper').css('width', secondWidth);
91            // Main box
92            $this
93            .find('div.main')
94            .css({
95                width: mainWidth // $this.find('div.main').width()
96            });
97        }
98
99        function normalizeMainWidth() {
100            $view.find('.item').each(function () {
101                $(this).find('.main').width($(this).width());
102            });
103            $view.find('p.more-info span.more-info').off().on('click', onMoreinfoClicked);
104        }
105
106        function attachEvents() {
107            console.log('AccordionBox::attachEvents');
108            // Remove events form buttons
109            $view.find('p.more-info a').off();
110            $(this).find('.main').removeAttr('style');
111
112            if ($(window).width() < 767) {
113                $view.find('p.more-info span.more-info').off().on('touchend', onMoreinfoToched);
114            }
115            else {
116                setTimeout(function () {
117                    normalizeMainWidth();
118                }, 1000);
119            }
120        }
121
122        return {
123            init: function () {
124                // attachEvents();
125                // Events.subscribe('EQUALIZE_COLS_FINISHED', attachEvents);
126                // $view.find('p.more-info span.more-info').on('click', function (e) {
127                    // e.preventDefault();
128                // });
129                setTimeout(function () {
130                    attachEvents( (($(window).width() < 767) ? 'mobile' : 'desktop') );
131                }, 1500);
132            }
133        }
134    }
135
136    function onReady() {
137        $('.module.accordion-box').each(function () {
138            var instance = initializeInstance($(this));
139            instances.push(instance);
140            instance.init();
141        });
142    }
143
144    $(onReady);
145
146})(window, jQuery);

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.