PageSourceSearch

https://www.enkashop.com/8.4.3.2/storefront/assets/javascript/component/midblock.js?revision=8.4.3.2-843204

js enkashop.com collected 2026-09-30 04:27:36 UTC 6,556 bytes, 157 lines download raw bytes

1;(function ($, w) {
2    'use strict';
3    if (!w.jQuery) {
4        throw 'Ideasoft: jQuery not found';
5    }
6    w.IdeaApp.midblock = {
7        currentOffset: 1,
8        currentTab: 1,
9        tabClass: '.tabbed-midblocks-container',
10        blockLength: null,
11
12        init: function () {
13            this.eventListener();
14            this.useTabBlock();
15        },
16
17        useTabBlock: function () {
18            var self = IdeaApp.midblock;
19            IdeaApp.plugins.tab(self.tabClass, function () {
20                self.onStart.call(this);
21            }, function () {
22                self.beforeClick.call(this);
23            }, function () {
24                self.onClick.call(this);
25            });
26        },
27
28        onStart: function () {
29            var self = IdeaApp.midblock,
30                $self = $(this);
31            var block = $self.find('[data-tab-index]').eq(0).data('tab-index');
32            self.currentTab = block;
33            IdeaApp.plugins.loading.add($self.find('[data-tab-content='+block+']'));
34            IdeaApp.midblock.tabAjax(block, 1, function (result) {
35                IdeaApp.plugins.loading.remove($self.find('[data-tab-content='+block+']'));
36                $self.find('[data-tab-content='+block+']').html(result.template);
37                self.blockLength = Math.ceil(result.count / result.limit);
38                self.controlButtons();
39            });
40        },
41
42        controlButtons: function () {
43            var self = IdeaApp.midblock;
44            if (self.blockLength == 0) {
45                $(self.tabClass + ' [data-selector="prev-page"]').addClass('passive');
46                $(self.tabClass + ' [data-selector="next-page"]').addClass('passive');
47            } else {
48                if (self.currentOffset == 1) {
49                    $(self.tabClass + ' [data-selector="prev-page"]').addClass('passive');
50                } else {
51                    $(self.tabClass + ' [data-selector="prev-page"]').removeClass('passive');
52                }
53                if (self.currentOffset == this.blockLength) {
54                    $(self.tabClass + ' [data-selector="next-page"]').addClass('passive');
55                } else {
56                    $(self.tabClass + ' [data-selector="next-page"]').removeClass('passive');
57                }
58            }
59        },
60
61        beforeClick: function () {
62            var self = IdeaApp.midblock,
63                $self = $(this),
64                tabIndex = $self.attr('data-tab-index');
65            $self.parents(self.tabClass).find('[data-tab-content=' + tabIndex + ']').html('');
66            IdeaApp.plugins.loading.add($self.parents(self.tabClass).find('[data-tab-content=' + tabIndex + ']'));
67            $self.addClass('disabled');
68        },
69
70        onClick: function () {
71            var self = IdeaApp.midblock,
72                $self = $(this);
73            self.beforeClick();
74            self.currentOffset = 1;
75            self.currentTab = parseInt($self.attr('data-tab-index'));
76            IdeaApp.midblock.tabAjax(self.currentTab, self.currentOffset, function (result) {
77                IdeaApp.plugins.loading.remove($self.parents(self.tabClass).find('[data-tab-content=' + self.currentTab + ']'));
78                $self.parents(self.tabClass).find('[data-tab-content=' + self.currentTab + ']').html(result.template);
79                self.blockLength = Math.ceil(result.count / result.limit);
80                self.controlButtons();
81                $self.removeClass('disabled');
82            });
83        },
84
85        prevTab: function () {
86            var self = IdeaApp.midblock,
87                $self = $(this),
88                container = $self.parents(self.tabClass);
89                var prevTab = $('[data-tab-index=' + self.currentTab + ']').prev().attr('data-tab-index');
90                container.find('[data-tab-index=' + prevTab + ']').click();
91        },
92
93        nextTab: function () {
94            var self = IdeaApp.midblock,
95                $self = $(this),
96                container = $self.parents(self.tabClass);
97                var nextTab = $('[data-tab-index=' + self.currentTab + ']').next().attr('data-tab-index');
98                container.find('[data-tab-index=' + nextTab + ']').click();
99        },
100
101        prevPage: function () {
102            var self = IdeaApp.midblock,
103                $self = $(this);
104            if (self.currentOffset == 1) {
105                return false;
106            } else {
107                $self.addClass('disabled');
108                self.currentOffset--;
109                IdeaApp.midblock.tabAjax(self.currentTab, self.currentOffset, function (result) {
110                    $self.parents(self.tabClass).find('[data-tab-content=' + self.currentTab + ']').html(result.template);
111                    self.controlButtons();
112                    $self.removeClass('disabled');
113                });
114            }
115        },
116
117        nextPage: function () {
118            var self = IdeaApp.midblock,
119                $self = $(this);
120            if (self.currentOffset < self.blockLength) {
121                $self.addClass('disabled');
122                self.currentOffset++;
123                IdeaApp.midblock.tabAjax(self.currentTab, self.currentOffset, function (result) {
124                    $self.parents(self.tabClass).find('[data-tab-content=' + self.currentTab + ']').html(result.template);
125                    self.controlButtons();
126                    $self.removeClass('disabled');
127                });
128            }
129        },
130
131        tabAjax: function (block, offset, callback) {
132            IdeaApp.helpers.ajaxRequest({
133                url: IdeaApp.routing.generate("/tabli-vitrin"),
134                data: "midBlock=" + block + "&offset=" + offset,
135                success: function (result) {
136                    callback(result);
137                }
138            });
139        },
140
141        eventListener: function () {
142            var self = this;
143            $(document).on('click', self.tabClass + ' [data-selector="prev-page"]', function () {
144                self.prevPage.call(this);
145            });
146            $(document).on('click', self.tabClass + ' [data-selector="next-page"]', function () {
147                self.nextPage.call(this);
148            });
149            $(document).on('click', self.tabClass + ' [data-selector="prev-tab"]', function () {
150                self.prevTab.call(this);
151            });
152            $(document).on('click', self.tabClass + ' [data-selector="next-tab"]', function () {
153                self.nextTab.call(this);
154            });
155        }
156    }
157}(jQuery, window));

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.