'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; }); }); // toggleup $('.conv-toggle-up').prev().slideUp(0); $('.conv-toggle-up').click(function () { $(this).toggleClass('open'); $(this).prev().slideToggle(100); console.log($(this).before()); }); // 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('
'); for (var i = 0; i < this.num; i++) $(that) .children('.conv-slider-selector') .append(''); this.selector = $(that).children('.conv-slider-selector'); this.selector.children('a:first-child').addClass('selected'); } }; ConvSlider.prototype.slide = function (to, direction) { if (this.sliding) return; this.sliding = true; var next = to; var that = this; var nowLeftPrefix; var nextLeftPrefix; if (direction == 'left') { nowLeftPrefix = '-'; nextLeftPrefix = ''; } else if (direction == 'right') { nowLeftPrefix = ''; nextLeftPrefix = '-'; } $(this.dom_list[this.now]) .stop() .animate( { left: nowLeftPrefix + '100%', }, this.speed, function () { $(this).css('display', 'none'); that.now = next; if (typeof that.selector != 'undefined') { that.selector.children('a').removeClass('selected'); that.selector .children('a:nth-child(' + (that.now + 1) + ')') .addClass('selected'); } that.sliding = false; } ); $(this.dom_list[next]) .css({ display: 'block', left: nextLeftPrefix + '100%' }) .stop() .animate( { left: 0, }, this.speed ); this.restart(); }; ConvSlider.prototype.slide_left = function () { this.slide((this.now + 1) % this.num, 'left'); }; ConvSlider.prototype.slide_right = function () { this.slide((this.now - 1 + this.num) % this.num, 'right'); }; ConvSlider.prototype.start = function () { var that = this; if (typeof this.right_btn != 'undefined') this.right_btn.on('click', function () { that.slide_right(); return false; }); if (typeof this.left_btn != 'undefined') this.left_btn.on('click', function () { that.slide_left(); return false; }); if (typeof this.selector != 'undefined') this.selector.children('a').on('click', function () { if (!$(this).hasClass('selected')) { var destination = $(this).attr('href') - 0; var direction = 'left'; that.slide(destination, direction); } return false; }); this.timer = setInterval(function () { that.slide_left(); }, this.interval); }; ConvSlider.prototype.restart = function () { var that = this; clearInterval(this.timer); this.timer = setInterval(function () { that.slide_left(); }, this.interval); }; $('.conv-slider').each(function () { var obj = new ConvSlider( this, typeof $(this).data('interval') === 'undefined' ? 1000 : $(this).data('interval'), typeof $(this).data('speed') === 'undefined' ? 300 : $(this).data('speed') ); obj.start(); }); // popup var ConvPopup = function (that) { this.close_btn = $('
x
').appendTo( that ); this.overlayer = $('
').appendTo( 'body' ); this.element = $(that); var width = $(that).width(); var height = $(that).height(); $(that).css({ 'margin-top': -height / 2 + 'px', 'margin-left': -width / 2 + 'px', }); }; ConvPopup.prototype.show = function () { var that = this; this.overlayer.animate( { opacity: '0.8', }, 300, function () { that.element.fadeIn('slow'); that.element.css('opacity', '1'); that.overlayer.click(function () { that.hide(); }); that.close_btn.click(function () { that.hide(); }); $(window).keydown(function (e) { if (e.keyCode == 27) { that.hide(); return false; } }); } ); }; ConvPopup.prototype.hide = function () { var that = this; this.element.fadeOut(300, function () { that.overlayer.animate( { opacity: '0', }, 300, function () { that.close_btn.remove(); that.overlayer.remove(); } ); }); $(window).keydown(function (e) {}); }; $('.conv-popup').each(function () { var target = $(this).attr('href'); var that = this; $(target).addClass('conv-popup-content'); $(target).hide(0); $(this).click(function () { var obj = new ConvPopup(target); obj.show(); return false; }); }); // pagejack $('.conv-pagejack').each(function () { var obj = new ConvPopup(this); obj.show(); }); // tab-img var __tabImgOn = 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; __toggleImg(img_tag, img_src, img_src_on); }; var __tabImgOff = 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_off = img_name .split('') .reverse() .join('') .replace('no_', '') .split('') .reverse() .join('') + '.' + img_type; __toggleImg(img_tag, img_src, img_src_off); }; $('.conv-tab-img').each(function () { var img_tags = $('li a', this); var img_active = $('li.active a', this); img_tags.click(function () { __tabImgOn(this); __tabImgOff(img_active); img_active = this; }); __tabImgOn(img_active); }); }); /*------------------------------------*/ /* require.js - 2009.11.22 /* http://tshinobu.com/lab/javascript/require/ /*------------------------------------*/ (function () { var s = document.getElementsByTagName('script'); var d = s[s.length - 1].src.substring( 0, s[s.length - 1].src.lastIndexOf('/') + 1 ); for (var i = 0; i < arguments.length; i++) { document.write( '' ); } })('load-files/js-flipsnap/flipsnap.js', 'load-files/Snap.js/snap.js');