//banner幻灯片通用 function pcbannercartoon(boxid,_name,numid,_numname,_hover,_antime,_speed,_bool,lastid,nextid){ var _box = $(boxid); var _arr = _box.find(_name); var _length = _arr.length; var _index = 0; var _numbox = $(numid); var _cartoon; var _last = 1; //_arr.eq(_index).css("display","block").siblings().css("display","none"); _arr.eq(_index).css("z-index",5).siblings().css("z-index",1); var _numsrc = ""; for(var i=0;i<_length;i++){ var _nn = i + 1; _numsrc += "<"+_numname+">"+_nn+""; } _numbox.html(_numsrc); var _num = _numbox.find(_numname); _num.eq(_index).addclass(_hover).siblings().removeclass(_hover); var _movego = function(){ //if(_arr.eq(_last).is(":animated")){_arr.eq(_last).stop(true,true);} //_arr.eq(_index).fadein(_antime).siblings().css("display","none"); _arr.eq(_last).css("z-index",5).siblings().css("z-index",1); _arr.eq(_index).css("z-index",3); _num.eq(_index).addclass(_hover).siblings().removeclass(_hover); _arr.eq(_last).fadeout(300,function(){ $(this).css({"z-index":1,"display":"block"}); }); }; var _lastshow = function(){ _last = _index; _index--; if(_index < 0){ _index = _length-1;} _movego(); }; var _nextshow = function(){ _last = _index; _index++; if(_index >= _length){ _index = 0;} _movego(); }; if(_bool){ _cartoon = setinterval(_nextshow,_speed); } if(lastid != ""){ $(lastid).click(function(){ _lastshow(); }); $(lastid).hover(function(){ if(_bool){ clearinterval(_cartoon); } },function(){ if(_bool){ _cartoon = setinterval(_nextshow,_speed); } }); } if(nextid != ""){ $(nextid).click(function(){ _nextshow(); }); $(nextid).hover(function(){ if(_bool){ clearinterval(_cartoon); } },function(){ if(_bool){ _cartoon = setinterval(_nextshow,_speed); } }); } _num.hover(function(){ _last = _numbox.find("."+_hover).index(); _index = $(this).index(); if(_last != _index){ _movego(); } if(_bool){ clearinterval(_cartoon); } },function(){ if(_bool){ _cartoon = setinterval(_nextshow,_speed); } }); } //导航下拉 function pcnavdown(boxid,_name,_hover,_down){ var _box = $(boxid); var _arr = _box.find(_name); var _index = _box.find("."+_hover).index(); _arr.hover(function(){ $(this).addclass(_hover).siblings().removeclass(_hover); if($(this).find(_down).is(":animated")){ $(this).find(_down).stop(true,true); } $(this).find(_down).slidedown(300); },function(){ if($(this).find(_down).is(":animated")){ $(this).find(_down).stop(true,true); } $(this).find(_down).slideup(300); }); _box.mouseleave(function(){ _arr.eq(_index).addclass(_hover).siblings().removeclass(_hover); }); } //.data-wrap li .number span $(function(){ $('.mainnav menu').each(function(){ var menuw=$(this).width(); $(this).css('margin-left',-menuw/2+'px'); }) // for(var i=0;i<$('.data-wrap li').length;i++){ // $('.data-wrap li').eq(i).find('.span1').text(function(){ // shuzi($('.data-wrap li').eq(i).find('.span1').text(),i) // }) // } // function shuzi(_shuzi,index){ // var shuzi=_shuzi; // var shuzi1=math.floor(shuzi/2); // var shuzi2=math.floor(shuzi/100); // var shuzi3=0; // var settime=setinterval(function(){ // if(shuzi2==0){ // if(shuzi3<=shuzi){ // shuzi3++; // $('.data-wrap .span1').eq(index).text(shuzi3); // } // else{ // $('.data-wrap .span1').eq(index).text(shuzi); // clearinterval(settime); // return; // } // }else{ // if(shuzi1= i && a + (n.data("appear-bottom-offset") || 0) <= i + s.height() && u + n.width() >= r && u - (n.data("appear-left-offset") || 0) <= r + s.width()) { return true } else { return false } }; e.fn.extend({ appear: function(s) { var o = e.extend({}, i, s || {}); var a = this.selector || this; if (!n) { var f = function() { if (r) { return } r = true; settimeout(u, o.interval) }; e(window).scroll(f).resize(f); n = true } if (o.force_process) { settimeout(u, o.interval) } t.push(a); return e(a) } }); e.extend({ force_appear: function() { if (n) { u(); return true } return false } }) })(jquery); // $.fn.countto = function (options) { // options = options || {}; // return $(this).each(function () { // // set options for current element // var settings = $.extend({}, $.fn.countto.defaults, { // from: $(this).data('from'), // to: $(this).data('to'), // speed: $(this).data('speed'), // refreshinterval: $(this).data('refresh-interval'), // decimals: $(this).data('decimals') // }, options); // // how many times to update the value, and how much to increment the value on each update // var loops = math.ceil(settings.speed / settings.refreshinterval), // increment = (settings.to - settings.from) / loops; // // references & variables that will change with each update // var self = this, // $self = $(this), // loopcount = 0, // value = settings.from, // data = $self.data('countto') || {}; // $self.data('countto', data); // // if an existing interval can be found, clear it first // if (data.interval) { // clearinterval(data.interval); // } // data.interval = setinterval(updatetimer, settings.refreshinterval); // // initialize the element with the starting value // render(value); // function updatetimer() { // value += increment; // loopcount++; // render(value); // if (typeof(settings.onupdate) == 'function') { // settings.onupdate.call(self, value); // } // if (loopcount >= loops) { // // remove the interval // $self.removedata('countto'); // clearinterval(data.interval); // value = settings.to; // if (typeof(settings.oncomplete) == 'function') { // settings.oncomplete.call(self, value); // } // } // } // function render(value) { // var formattedvalue = settings.formatter.call(self, value, settings); // $self.html(formattedvalue); // } // }); // }; // $.fn.countto.defaults = { // from: 0, // the number the element should start at // to: 0, // the number the element should end at // speed: 1000, // how long it should take to count between the target numbers // refreshinterval: 100, // how often the element should be updated // decimals: 0, // the number of decimal places to show // formatter: formatter, // handler for formatting the value before rendering // onupdate: null, // callback method for every time the element is updated // oncomplete: null // callback method for when the element finishes updating // }; // function formatter(value, settings) { // return value.tofixed(settings.decimals); // } // // custom formatting example // $('#count-number').data('counttooptions', { // formatter: function (value, options) { // return value.tofixed(options.decimals).replace(/\b(?=(?:\d{3})+(?!\d))/g, ','); // } // }); // // start all the timers // $('.timer').each(count); // function count(options) { // var $this = $(this); // options = $.extend({}, options || {}, $this.data('counttooptions') || {}); // $this.countto(options); // } (function($) { $.fn.countto = function(options) { options = options || {}; return $(this).each(function() { // set options for current element var settings = $.extend({}, $.fn.countto.defaults, { from: $(this).data('from'), to: $(this).data('to'), speed: $(this).data('speed'), refreshinterval: $(this).data('refresh-interval'), decimals: $(this).data('decimals') }, options); // how many times to update the value, and how much to increment the value on each update var loops = math.ceil(settings.speed / settings.refreshinterval), increment = (settings.to - settings.from) / loops; // references & variables that will change with each update var self = this, $self = $(this), loopcount = 0, value = settings.from, data = $self.data('countto') || {}; $self.data('countto', data); // if an existing interval can be found, clear it first if (data.interval) { clearinterval(data.interval); } data.interval = setinterval(updatetimer, settings.refreshinterval); // initialize the element with the starting value render(value); function updatetimer() { value += increment; loopcount++; render(value); if (typeof(settings.onupdate) == 'function') { settings.onupdate.call(self, value); } if (loopcount >= loops) { // remove the interval $self.removedata('countto'); clearinterval(data.interval); value = settings.to; if (typeof(settings.oncomplete) == 'function') { settings.oncomplete.call(self, value); } } } function render(value) { var formattedvalue = settings.formatter.call(self, value, settings); $self.html(formattedvalue); } }); }; $.fn.countto.defaults = { from: 0, // the number the element should start at to: 0, // the number the element should end at speed: 3000, // how long it should take to count between the target numbers refreshinterval: 10, // how often the element should be updated decimals: 0, // the number of decimal places to show formatter: formatter, // handler for formatting the value before rendering onupdate: null, // callback method for every time the element is updated oncomplete: null // callback method for when the element finishes updating }; function formatter(value, settings) { return value.tofixed(settings.decimals); } }(jquery)); //timer jquery('.timer').appear(); jquery(document.body).on('appear', '.timer', function() { jquery(this).countto(); }); jquery(document.body).on('disappear', '.timer', function() { jquery(this).removeclass('timer'); }); })