PageSourceSearch

https://stork.or.kr/stork/asset/plugin/MateTabs/MateTabs.js

js stork.or.kr collected 2026-10-03 02:52:10 UTC 8,752 bytes, 211 lines download raw bytes

1(function($, window, document, undefined) {
2    var pluginName = 'mateTabs',
3        defaults = {
4            triggers: 'click',
5            transform: 'auto',
6            activeTabs: 1,
7            showSpeed: 300,
8            borderColor: '#fff',
9            contentColor: '#902950',
10            panelColor: '#fff',
11			inactiveBGColor: '#CFCFCF',
12			inactiveColor: '#fff',
13            accordionActiveColor: '#000000',
14            tabsLightBorder: '#ffffff',
15            tabsDarkBorder: '#ffffff',
16            tabsFontColor: '#000',
17            tabscActiveFontColor: '#ffffff',
18			tabsContentColor: '#fff',
19            tabsMarginLeft: '0px'
20        };
21
22    function MateTabs(element, options) {
23        this.element = $(element);
24        var ele = this;
25        this.options = $.extend({}, defaults, options);
26        this._defaults = defaults;
27        this._name = pluginName;
28        this.init(ele)
29    };
30    MateTabs.prototype.variables = function(ele) {
31        this.op = this.options;
32        this.ul = this.element.children('ul');
33        this.li = this.ul.children('li');
34        this.liL = this.li.length;
35        this.liH = this.li.innerHeight();
36        this.activeTabs = (this.op.activeTabs <= 0 || this.op.activeTabs > this.liL) ? 0 : this.op.activeTabs - 1;
37        this.con = this.element.children('section');
38        this.conL = this.con.length;
39        this.conCount = this.op.activeTabs
40    };
41    MateTabs.prototype.createEle = function(ele) {
42        this.con.each(function() {
43            if ($(this).children('.zl_nav_trig').length < 1) {
44                var accBtn = $('<div class="zl_nav_trig zl_switch_to_nav"></div>');
45                $(this).before(accBtn)
46            }
47        });
48        this.nav = this.element.children('.zl_nav_trig')
49    };
50    MateTabs.prototype.resizeFunc = function(tran, arg1, arg2, ele) {
51        if (tran === true) {
52            this.li.css('display', arg1);
53            this.nav.css('display', arg2)
54        } else {
55            var count = 0;
56            this.con.each(function() {
57                if ($(this).css('display') !== 'none') {
58                    count = 1
59                }
60            });
61            if (count === 0) {
62                ele.con.eq(ele.activeTabs).show();
63                ele.csshop(ele, ele.li.eq(ele.activeTabs), 'li', '', this.op.contentColor)
64            }
65        }
66    };
67    MateTabs.prototype.onResize = function(ele) {
68        this.ulW = this.ul.innerWidth();
69        this.ulH = this.ul.innerHeight();
70        this.winW = $(window).width();
71        if (this.op.transform === 'auto') {
72            this.liCount = 0;
73            this.li.each(function() {
74                var liW = $(this).outerWidth(true);
75                ele.liCount += liW
76            });
77			
78			if (this.ulW <= 227) {
79				this.li.removeClass('tab_response');
80			}else{
81				this.li.addClass('tab_response');
82			}
83			
84            if (this.ulW <= 0) {
85                this.resizeFunc(true, 'none', 'block', ele);
86            } else {
87                this.resizeFunc(true, 'block', 'none', ele);
88                this.resizeFunc(false, 'block', 'none', ele)
89            }
90        } else if (typeof(this.op.transform) === 'number') {
91            if (this.winW <= this.op.transform) {
92                this.resizeFunc(true, 'none', 'block', ele)
93            } else {
94                this.resizeFunc(true, 'block', 'none', ele);
95                this.resizeFunc(false, 'block', 'none', ele)
96            }
97        };
98        this.con.each(function() {
99            if ($(this).css('display') !== 'none') {
100                ele.csshop(ele, $(this).prev('.zl_nav_trig'), '.zl_nav_trig', ele.op.panelColor, ele.op.accordionActiveColor)
101            }
102        })
103    };
104    MateTabs.prototype.csshop = function(ele, arg1, who, bc, active_color) {
105		if(who == "li") who = "li:not(:last-child)";
106        arg1.css({
107            'background-color': active_color,
108            'color': this.op.tabscActiveFontColor,
109			'width': 'auto'
110        }).siblings(who).css({
111            'background-color': this.op.inactiveBGColor,
112            'color': this.op.inactiveColor,
113			'width': 'auto'
114        })
115    };
116    MateTabs.prototype.startPosition = function(ele) {
117        this.element.css('border-color', this.op.borderColor);
118        this.ul.css('background-color', this.op.panelColor);
119        this.con.css('background-color', this.op.tabsContentColor).eq(this.activeTabs).show();
120        this.li.css({
121            'color': this.op.tabsFontColor,
122            'border-left-color': this.op.tabsLightBorder,
123            'border-right-color': this.op.tabsDarkBorder
124        }).addClass('zl_switch_to_nav').each(function() {
125            var li = $(this),
126                html = li.html(),
127                ind = li.index();
128            ele.con.eq(ind).prev('.zl_nav_trig').html(html)
129        }).eq(0).css({
130            'margin-left': this.op.tabsMarginLeft,
131            'border-left': 'none'
132        }).end().eq(-1).css('border-right', 'none');
133        this.csshop(ele, this.li.eq(this.activeTabs), 'li', '', this.op.contentColor);
134        this.nav.css({
135            'color': this.op.tabsFontColor,
136            'background-color': this.op.panelColor,
137            'border-top-color': this.op.tabsLightBorder,
138            'border-bottom-color': this.op.tabsDarkBorder
139        }).eq(0).css('border-top', 'none').end().eq(-1).css('border-bottom', 'none');
140		
141		this.li.eq(this.li.length-1).css({'background-color': this.op.contentColor, 'color': this.op.tabscActiveFontColor});
142		
143        if (this.op.transform === 'now') {
144            this.resizeFunc(true, 'none', 'block', ele)
145        }
146    };
147    MateTabs.prototype.eventFunc = function(ele, ind, sw, val) {
148        switch (val) {
149            case 0:
150                this.con.eq(ind).fadeTo(this.op.showSpeed, 1).siblings('section').hide();
151                this.csshop(ele, sw, 'li', '', this.op.contentColor);
152                break;
153            case 1:
154                if (this.op.triggers === 'click') {
155                    if (sw.next('section').css('display') !== 'none') {
156                        sw.siblings('section').hide().siblings('.zl_nav_trig').css({
157                            'background-color': this.op.panelColor,
158                            'color': this.op.tabsFontColor
159                        })
160                    } else {
161                        sw.next('section').fadeTo(this.op.showSpeed, 1).siblings('section').hide();
162                        var index_sec = sw.index('.zl_nav_trig');
163                        this.csshop(ele, this.li.eq(index_sec), 'li', '', this.op.contentColor);
164                        this.csshop(ele, sw, '.zl_nav_trig', this.op.panelColor, this.op.accordionActiveColor)
165                    }
166                } else {
167                    sw.next('section').fadeTo(this.op.showSpeed, 1).siblings('section').hide();
168                    var index_sec = sw.index('.zl_nav_trig');
169                    this.csshop(ele, this.li.eq(index_sec), 'li', '', this.op.contentColor);
170                    this.csshop(ele, sw, '.zl_nav_trig', this.op.panelColor, this.op.accordionActiveColor)
171                };
172                break
173        }
174    };
175    MateTabs.prototype.triggers = function(ele) {
176        this.sw = this.element.find('.zl_switch_to_nav');
177        if (this.op.triggers === 'click') {
178            this.sw.on('click.mateTabsClick', function() {
179                var sw = $(this),
180                    ind = $(this).index();
181                (sw.is('li')) ? ele.eventFunc(ele, ind, sw, 0): ele.eventFunc(ele, ind, sw, 1)
182            })
183        } else {
184            this.sw.on('mouseenter.mateTabsMouse', function() {
185                var sw = $(this),
186                    ind = $(this).index();
187                (sw.is('li')) ? ele.eventFunc(ele, ind, sw, 0): ele.eventFunc(ele, ind, sw, 1)
188            })
189        }
190    };
191    MateTabs.prototype.init = function(ele) {
192        this.variables(ele);
193        this.createEle(ele);
194        this.startPosition(ele);
195        this.triggers(ele);
196        $(window).on('resize.TabsResize', function() {
197            clearTimeout(timer_resize);
198            var timer_resize = setTimeout(function() {
199                ele.onResize(ele)
200            }, 300)
201        });
202        this.onResize(ele)
203    };
204    $.fn[pluginName] = function(options) {
205        return this.each(function() {
206            if (!$.data(this, 'plugin_' + pluginName)) {
207                $.data(this, 'plugin_' + pluginName, new MateTabs(this, options))
208            }
209        })
210    }
211})(jQuery, window, document);

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.