PageSourceSearch

https://www.city04.kz/assets/c4271ba4/js/weatherTabs.js?v=1789825604

js city04.kz collected 2026-10-05 07:44:27 UTC 4,800 bytes, 121 lines download raw bytes

1(function ($) {
2    $.fn.weatherTabs = function (option) {
3
4        var WeatherTabs = function (element, options) {
5            this.settings = $.extend({}, WeatherTabs.defaultOptions, options);
6
7            this._element = $(element);
8            this._panes = $(this.settings.panesSelector, this.settings.panesContainer);
9            this._tabs = $(this.settings.tabsSelector, this.settings.tabsContainer);
10            this._selectedTab = null;
11            this._selectedPane = null;
12            this._label = this.settings.useLabelForDate ? $(this.settings.labelForDate) : null;
13
14            this._initEventHandlers();
15            this._selectTab(0);
16        };
17
18        WeatherTabs.namespace = 'weatherTabs';
19
20        WeatherTabs.defaultOptions = {
21            dataDateAttr: "tab-link",
22            dataLabelAttr: "tab-label",
23            tabsSelector: "li",
24            tabsContainer: "ul",
25            panesSelector: "div",
26            panesContainer: "div.tabs",
27            activeTabClass: "active",
28            useLabelForDate: true,
29            labelForDate: "span",
30        };
31
32        WeatherTabs.prototype._updateLabel = function (labelText) {
33            labelText = labelText || (this._selectedTab && this._selectedTab.data(this.settings.dataLabelAttr));
34            if(!this.settings.useLabelForDate || null === this._label || 0 === this._label.length) return false;
35            this._label.text(labelText);
36        };
37
38        WeatherTabs.prototype._deselectTab = function () {
39            if (this._selectedPane) {
40                this._selectedPane.hide();
41            } else {
42                this._panes.hide();
43            }
44            if (this._selectedTab) {
45                this._selectedTab.removeClass(this.settings.activeTabClass);
46            } else {
47                this._tabs.removeClass(this.settings.activeTabClass);
48            }
49        };
50
51        WeatherTabs.prototype._selectTab = function (tab) {
52            var $tab = null;
53            if ($.isNumeric(tab) && this._tabs.length > 0) {
54                var tabIndex = Math.max((Math.min(parseInt(tab, 10), this._tabs.length - 1)), 0);
55                $tab = $(this._tabs[tabIndex]);
56            } else if (typeof tab === 'string') {
57                var filterString = tab;
58                if (/^\d{4}-\d{2}-\d{2}$/.test(tab)) {
59                    filterString = "[data-" + this.settings.dataDateAttr + "='" + tab + "']";
60                }
61                $tab = this._tabs.filter(filterString);
62                if (0 === $tab.length) {
63                    $tab = this._tabs.first();
64                }
65            } else {
66                return false;
67            }
68            if (null === $tab) {
69                return false;
70            }
71            var dataAttr = $tab.data(this.settings.dataDateAttr);
72            var $pane = this._panes.filter("[data-" + this.settings.dataDateAttr + "='" + dataAttr + "']");
73            this._deselectTab();
74            $pane.show();
75            $tab.addClass(this.settings.activeTabClass);
76
77            this._selectedTab = $tab;
78            this._selectedPane = $pane;
79            this._updateLabel();
80        };
81
82        WeatherTabs.prototype._initEventHandlers = function () {
83            var self = this;
84            this._element.on('click.' + WeatherTabs.namespace, this.settings.tabsSelector, function (ev) {
85                ev.preventDefault();
86                var $link = $(this);
87                self._selectTab($link.data(self.settings.dataDateAttr));
88                return false;
89            });
90        };
91
92        WeatherTabs.prototype._getSelectedTab = function () {
93            return this._selectedTab;
94        };
95
96        WeatherTabs.methods = {
97            selectTab: WeatherTabs.prototype._selectTab,
98            getSelectedTab: WeatherTabs.prototype._getSelectedTab,
99        };
100
101        var scopeArguments = arguments;
102        if ('string' === typeof option && 'function' === typeof WeatherTabs.methods[option]) {
103            var data = this.data('cis.' + WeatherTabs.namespace);
104            if(data) {
105                return WeatherTabs.methods[option].apply(data, Array.prototype.slice.call(scopeArguments, 1));
106            }
107        }
108        return this.each(function (index, element) {
109            var $this = $(this);
110            var data = $this.data('cis.' + WeatherTabs.namespace);
111            var options = 'object' === typeof option && option;
112
113            if (!data) {
114                $this.data('cis.' + WeatherTabs.namespace, (data = new WeatherTabs(this, options)));
115            }
116            if ('string' === typeof option && 'function' === typeof WeatherTabs.methods[option]) {
117                WeatherTabs.methods[option].apply(data, Array.prototype.slice.call(scopeArguments, 1));
118            }
119        });
120    };
121})(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.