"use strict"; ;(function($) { $.fn.animated = function(options) { if(this.length == 0) return this; if(this.length > 1){ this.each(function(){$(this).animated(options)}); return this; } var el = this; var ww = $(window).width(); var wh = $(window).height(); var setting = { triggers: { eachdelay: 'el', delaytime: 't', delayStart: 'dl', animate: 'an', effect: 'ef', reach: 'reach', hover: 'hover', breakas: 'break', split: 'split', firstactive: 'fa', prefix: 'prefix', goto: 'goto', subattr: 'attr', absovcenter: 'absovcenter', imgvcenter: 'imgvcenter' }, callback: function() {} } $.extend(setting, options); var init = function() { interactDom(); interactLessDom(); } var interactDom = function() { } var interactLessDom = function() { $('['+setting.triggers.goto+']').each(function () { $(this).on('click', function () { var $tar = $(this).attr(setting.triggers.goto); $("html,body").animate({ scrollTop: $($tar).offset().top }, 1000); }); }); $('['+setting.triggers.breakas+']').each(function () { var _temp = []; var _text = []; var _html = ''; var _class; typeof ($(this).attr('tagClass')) != 'undefined' ? _class = ' class="' + $(this).attr('tagClass') + '" ' : _class = ''; var $tagName = $(this).attr(setting.triggers.breakas); var $text = $(this).text(); _temp = $text.split('#'); $.each(_temp, function (k, v) { _text[k] = v.split(" "); }); $.each(_text, function (k, line) { $.each(line, function (a, word) { _html += '<' + $tagName + ' ' + _class + '>' + word + ' '; }); _html += '
'; }); $(this).html(_html); }); $('['+setting.triggers.absovcenter+']').each(function () { var $target = $(this).attr(setting.triggers.absovcenter); var $position = $(this).css('position'); if ($position != 'absolute' && $position != 'relative' && $position != 'fixed') { $(this).css({ position: 'relative' }); } var $targetHeight = $(this).find($target).outerHeight(); $(this).find($target).css({ position: 'absolute', top: '50%', marginTop: -$targetHeight / 2 }); }); $('['+setting.triggers.imgvcenter+']').each(function () { var tar = $(this).attr(setting.triggers.imgvcenter); var outheight = $(this).height(); $(this).find(tar).load(function () { var inheight = $(this).outerHeight(); $(this).css({ 'margin-top': (outheight - inheight) / 2 }); }); }); // subattr $(el.find('['+setting.triggers.subattr+']')).each(function() { if($(this).attr(setting.triggers.subattr)) { var attr = $(this).attr(setting.triggers.subattr).split(','); var target = $(this).find(attr[0]); attr.splice(0,1); $.each(attr, function(k, v) { var attrel = v.split('='); target.attr(attrel[0],attrel[1]); }); } }); // split $('['+setting.triggers.split+']').each(function () { var _temp = []; var _html = ''; if (!$(this).attr('rendered')) { var $tar = $(this).attr(setting.triggers.split); var $text = $(this).text(); for (var i = 0; i < $text.length; i++) { _temp.push($text.substring(i, i + 1)); } for (var i = 0; i < _temp.length; i++) { if (_temp[i] == "#") { _html += '
'; } else { _html += '<' + $tar + '>' + _temp[i] + ''; } } $(this).html(_html); $(this).attr('rendered', 'true'); } }); // eachdelay $(el.find('['+setting.triggers.eachdelay+']')).each(function() { // if(!$(this).attr(setting.triggers.eachdelay)) return this; var target = $(this).find($(this).attr(setting.triggers.eachdelay)); var delayTime = $(this).attr(setting.triggers.delaytime) ? parseFloat($(this).attr(setting.triggers.delaytime)) : .2; var delayStart = $(this).attr(setting.triggers.delayStart) ? parseFloat($(this).attr(setting.triggers.delayStart)) : 0; target.each(function(k) { $(this).css({ 'animation-delay': k*delayTime+delayStart + 's', '-webkit-animation-delay': k*delayTime+delayStart + 's' }); }) }) // animate $(el.find('['+setting.triggers.animate+']')).each(function() { if(!$(this).attr(setting.triggers.animate)) return this; var animate = $(this).attr(setting.triggers.animate); var target = $(this).attr(setting.triggers.effect)?$(this).find($(this).attr(setting.triggers.effect)):$(this).find($(this).attr(setting.triggers.eachdelay)); var arr = animate.indexOf(',')>=0 ? animate.split(',') : ["fadeIn", "zoomIn", "fadeInUp", "fadeInRight", "fadeInDown", "fadeInLeft"]; if (animate == "random" || animate.indexOf(',') >= 0) { target.each(function () { var random = Math.floor(Math.random() * (arr.length)); random = arr[random]; $(this).addClass(random + ' animated'); }); } else { target.addClass(animate + ' animated'); } }) // first active $(el.find('['+setting.triggers.firstactive+']')).each(function() { var target = $(this).attr(setting.triggers.firstactive)?$(this).find($(this).attr(setting.triggers.firstactive)):$(this).attr(setting.triggers.eachdelay); $(this).find(target).eq(0).addClass('active'); }) // class index prefix $(el.find('['+setting.triggers.prefix+']')).each(function() { var prefix = $(this).attr(setting.triggers.prefix)?$(this).attr(setting.triggers.prefix).split(','):['#id','item']; var target = $(this).find(prefix[0]); target.each(function(k) { $(this).addClass(prefix[1] + k); }); }) $('['+setting.triggers.reach+']').each(function () { if ($(document).scrollTop() + $(window).height() >= $(this).offset().top) { var animate = $(this).attr(setting.triggers.reach); var animateClass = $(this).attr('animateClass') ? $(this).attr('animateClass') : ''; var arr, random; if (animate.indexOf(',') >= 0) { arr = animate.split(','); } else { arr = ["fadeIn", "zoomIn", "fadeInUp", "fadeInRight", "fadeInDown", "fadeInLeft"]; } if ($(this).attr(setting.triggers.eachdelay)) { var effectchild = $(this).attr(setting.triggers.eachdelay); $(this).find(effectchild).each(function () { if (animate == "random" || animate.indexOf(',') >= 0) { random = Math.floor(Math.random() * (arr.length)); random = arr[random]; $(this).addClass(random + " animated " + animateClass); } else { $(this).addClass(animate + " animated " + animateClass); } }); $(this).find(effectchild).css({ 'visibility': 'visible' }); } else { $(this).addClass(animate + " animated " + animateClass); $(this).css({ 'visibility': 'visible' }); } // $(this).removeAttr('reach'); } }); $(window).scroll(function () { var topval = $(document).scrollTop(); // console.log(topval); $('['+setting.triggers.reach+']').each(function () { if (topval > $(this).offset().top - $(window).height()) { var animate = $(this).attr(setting.triggers.reach); if ($(this).attr(setting.triggers.eachdelay)) { var effectchild = $(this).attr(setting.triggers.eachdelay); $(this).find(effectchild).addClass(animate + " animated"); $(this).find(effectchild).css({ 'visibility': 'visible' }); } else { $(this).addClass(animate + " animated"); $(this).css({ 'visibility': 'visible' }); } } else { var animate = $(this).attr('reach'); if ($(this).attr(setting.triggers.eachdelay)) { var effectchild = $(this).attr(setting.triggers.eachdelay); $(this).find(effectchild).removeClass(animate + " animated"); $(this).find(effectchild).css({ 'visibility': 'hidden' }); } else { $(this).removeClass(animate + " animated"); $(this).css({ 'visibility': 'hidden' }); } } }); }); } el.reloadanimated = function() { interactLessDom(); } init(); return this; } $.fn.forslide = function (_option) { var _temp='', _html='', _clear; var _setting = { item: '.item', step: 4, tagName: 'li', tagClass: '', clear: false, attr: '', rerender: false, callback: function () { } } $.extend(_setting, _option); var o = this; var _size = o.find(_setting.item).length; if (_setting.clear) { _clear = '
'; } else { _clear = ''; } if (_size > _setting.step) { if (_size % _setting.step == 0) { for (var _i = 0; _i < _size; _i++) { _temp += o.find(_setting.item + ':eq(' + _i + ')').prop('outerHTML'); if ((_i + 1) % _setting.step == 0) { _html += '<' + _setting.tagName + ' ' + _setting.attr + ' class="' + _setting.tagClass + '">' + _temp + _clear + ''; _temp = ''; } } } else { var _page = Math.floor(_size / _setting.step); for (var _i = 0; _i < _size; _i++) { _temp += o.find(_setting.item + ':eq(' + _i + ')').prop('outerHTML'); if ((_i + 1) % _setting.step == 0 && _i + 1 <= _page * _setting.step) { _html += '<' + _setting.tagName + ' ' + _setting.attr + ' class="' + _setting.tagClass + '">' + _temp + _clear + ''; _temp = ''; } } _html += '<' + _setting.tagName + ' ' + _setting.attr + ' class="' + _setting.tagClass + '">' + _temp + _clear + ''; } } else { _html += '<' + _setting.tagName + ' ' + _setting.attr + ' class="' + _setting.tagClass + '">' + o.html() + ''; } o.empty().html(_html); if(_setting.rerender) { o.animated(); } _setting.callback(); } })(jQuery); $(document).ready(function() { $('body').animated(); $('.mail_forbid').on('click',function () { $('.sha_hint_box').fadeIn(500) }); $('.btn_close').on('click',function () { $('.sha_hint_box').fadeOut(500) }) // $('[class^=calc-]').each(function() { // }); })