'use strict'; $(function () { // tab $('.conv-tab').each(function () { var tabtop = this; var data_group = $(this).data('target').split(','); var width = Math.floor(100 / $(tabtop).children('li').length); for (var i = 0; i < data_group.length; i++) { $(data_group[i]).each(function () { $(this).children('div').hide(0); $(this).children('div:first').show(0); }); } $(tabtop).children('li:first').addClass('active'); $(this).append("
"); $(this) .children('li') .click(function () { var tab_active = $($(tabtop).find('li')).index( $(tabtop).find('li.active') ); var tab_target = $($(tabtop).find('li')).index(this); $(tabtop).children('li.active').removeClass('active'); $(this).addClass('active'); for (var i = 0; i < data_group.length; i++) { $(data_group[i]).each(function () { $(this) .children('div:eq(' + tab_active + ')') .fadeOut(0); $(this) .children('div:eq(' + tab_target + ')') .stop() .fadeIn(200); }); } return false; }); }); // toggle $('.conv-toggle').next().slideUp(0); $('.conv-toggle').click(function () { $(this).toggleClass('open'); $(this).next().slideToggle(100); }); // toggle-img var __clickImgChange = function (that) { var img_tag = $(that).children('img'); var img_info = img_tag.attr('src').split('.'); var img_name = img_info[0]; var img_type = img_info[1]; var img_src = img_name + '.' + img_type; var img_src_on = img_name + '_on.' + img_type; $(that).click(function () { __toggleImg(img_tag, img_src, img_src_on); }); }; var __toggleImg = function (img_tag, img_src, img_src_on) { if (img_tag.attr('src') === img_src_on) img_tag.attr('src', img_src); else img_tag.attr('src', img_src_on); }; $('.conv-toggle-img').each(function () { __clickImgChange(this); }); // fadein-box $(window).scroll(function () { $('.conv-fadein-box').each(function () { if ($(window).scrollTop() >= $(this).data('scroll')) $(this).fadeIn(300); else $(this).fadeOut(300); }); }); // nav // slider var ConvSlider = function (that, intval, speed) { this.dom_list = []; this.now = 0; this.interval = intval; this.speed = speed; this.num = $(that).children('.conv-slider-item').size(); this.sliding = false; $(that) .children('div.conv-slider-item') .wrapAll(''); this.inner = $(that).children('.conv-slider-inner'); for (var i = 0; i < this.num; i++) { this.dom_list[i] = this.inner.children('.conv-slider-item').get(i); } $(this.dom_list[this.now]).css('display', 'block'); // generate next/prev button if (typeof $(that).data('left-btn') === 'undefined') { this.inner.append( ' ' ); this.left_btn = this.inner.children('.conv-slider-btn-left'); } else { this.left_btn = $($(that).data('left-btn')); } if (typeof $(that).data('right-btn') === 'undefined') { this.inner.append( ' ' ); this.right_btn = this.inner.children('.conv-slider-btn-right'); } else { this.right_btn = $($(that).data('right-btn')); } if ($(that).data('selector') === true) { $(that).append('