(function($){ $f = window.$f || { is: function(a, _) { var $ = object.prototype.tostring.call(_).slice(8, -1).tolowercase(); return _ !== undefined && _ !== null && $ === a.tolowercase() }, sizeof:function(a){ if(this.is('array',a)||this.is('string',a)){ return a.length; }else if(this.is('object',a)){ var _ = 0; for(var i in a){_++;} return _; }else{ return 0; } }, create:function(c,p){ var _ = this; if(_.is("function",c))return new c(p); }, extend:function(a,b){ return $.extend(a,b); } }; //1.slide $f.slide = function(_){ var options = { parent:'body', target:'', nav:'.nav', current:'current', start:0, auto:false, dir:1, time:3000, duration:1000, easing:'swing' }; this.options = {}; this.init(options,_); //this.render(); }; $f.slide.prototype = { init:function(_a,_b){ var _ = this,__ = _.options = $f.extend(_a,_b); !!__.target&&(_.par = $(__.parent),_.tar = $(__.target,__.parent),_.nav = $(__.nav,__.parent))&&_.render(); }, render:function(){ var _ = this,__ = _.options; _.tar.hide().eq(__.start).show().addclass(__.current); _.nav.bind('click',function(e,f){ var _self = this; if(!_.click&&!$(_self).hasclass(__.current)){ var _f = _.nav.index(_.nav.filter('.'+__.current)),_t = _.nav.index(_self); _.slidehandler(_f,_t,f); } }).removeclass(__.current).eq(__.start).addclass(__.current); __.auto&&_.timerhandler(); }, slidehandler:function(f,t,flag,c){ var _ = this,__ = _.options;_.click = true ; _.nav.eq(f).removeclass(__.current); _.nav.eq(t).addclass(__.current); _.tar.eq(t).stop(true,false).addclass(__.current).css({"display":"block","left":!!flag?(f>t?"100%":"-100%"):(f>t?"-100%":"100%"),"z-index":1}).animate({left:"0%"},__.duration,__.easing,c); _.tar.eq(t).trigger("slidein"); _.tar.eq(f).trigger("slideout"); if(ft?"-100%":"100%"):(f>t?"100%":"-100%")},__.duration,__.easing,function(){ $(this).hide().trigger("slideoutend"); _.tar.eq(t).trigger("slideinend"); _.click = false; }); _.tar.eq(f).removeclass(__.current);_.tar.eq(t).addclass(__.current); }, slideleftrighthanler:function(dir){ var _ = this,__ = _.options; var _s = $(_.nav).size(),_i = dir==0?-1:1,_f = $(_.nav).index($(_.nav).filter('.'+__.current)),_t = _f+_i<0?_s-1:_f+_i>=_s?0:_f+_i; $(_.nav).eq(_t).trigger("click",(_f+_i<0||_f+_i>=_s)?true:false); }, timerhandler:function(){ var _ = this,__ = _.options,_timerstop=function(){ _.timmer & cleartimeout(_.timmer); },_timerstart=function(_t){ _timerstop(); _.timmer = settimeout(_timer,_t); },_timer=function(){ _.slideleftrighthanler(__.dir); _timerstart(__.time+__.duration); }; _.par.bind("mouseenter",function(){ _timerstop(); }).bind("mouseleave",function(){ _timerstart(__.time); }).trigger("mouseleave"); } }; //2.mask $f.mask = function(tar,_){ if(!$(tar)[0])return; var isie6 = navigator.useragent.tolowercase().indexof("msie 6")>-1; var self=this,options = { closeelement : '', position : 'static', align:'center', valign:'middle', zindex:1000, maskclose : true },$mask = $('
'),_pos=['fixed','absolute','static']; options = $.extend(options,_); $mask.attr("id","f_mask_"+(!$f.mask.id?$f.mask.id=0:$f.mask.id++)); $mask.css({ width:document.body.scrollwidth, height:document.body.scrollheight, position:'absolute', backgroundcolor:'#000', opacity:0.5, left:0,top:0, zindex:options.zindex }).appendto('body'); !$f.mask.list&&($f.mask.list=[],$(window).bind("resize",function(){ $('.f_mask').css({width:$('body').width(), height:document.body.scrollheight}); })); $f.mask.list.push(tar); switch(options.position){ case 'fixed': $(tar).css({ position:!!isie6?'absolute':'fixed', left:'50%',top:!!isie6?$(window).height()/2+$(window).scrolltop():'50%', marginleft:-$(tar).width()/2,margintop:-$(tar).height()/2, 'z-index':$f.mask.id+options.zindex+1 }).show(); break; case 'absolute': $(tar).css({ position:'absolute', left:'50%',top:$(window).height()/2+$(window).scrolltop(), marginleft:-$(tar).width()/2,margintop:-$(tar).height()/2, 'z-index':$f.mask.id+options.zindex+1 }).show(); break; default: $(tar).css({'z-index':$f.mask.id+options.zindex+1}).show(); break; } !!options.closeelement&&$(tar).find(options.closeelement).bind("click",function(){ self.unmask(tar); }); } $f.unmask = function(tar){ $(tar).hide(); $('div').remove('.f_mask'); } $f.select = function(tar,_){ var options = { wrapper:'.f_select', forminput:'', showinput:'.f_select_value', optioncontainer:'ul', option:'li', optionvlaue:'', optionhoverclass:'hover', toggleclass:'open', toggle:true, index:-1, onchange:null, context:null } options = $.extend(options,_); $(tar).each(function(index, element) { var self = this,_sel; $(self).bind('open',function(){ $(self).addclass('open'); $(options.optioncontainer,self).show(); !!_sel&&$(_sel).addclass(options.optionhoverclass); }).bind('close',function(){ $(self).removeclass('open'); $(options.optioncontainer,self).hide(); }); if(!!options.toggle){ $(self).hover(function(e){ $(self).trigger('open'); },function(e){ $(self).trigger('close') }); } options.opt = options.optioncontainer+' '+options.option; $(options.optioncontainer,self).delegate(options.option,"mouseenter",function(){ $(options.opt,self).removeclass(options.optionhoverclass); $(this).addclass(options.optionhoverclass); }).delegate(options.option,"mouseleave",function(){ $(this).removeclass(options.optionhoverclass); }).delegate(options.option,'click',function(){ $(options.showinput,self).text($(this).text()); !!options.forminput&&(_temp = $(options.forminput,self).val(),$(options.forminput,self).val(!!options.optionvlaue?$(this).attr(options.optionvlaue):$(this).text()),_temp!=$(options.forminput,self).val()&&!!options.onchange&&(!!options.context?options.onchange.call(options.context):options.onchange.call(self))); _sel = this ; $(self).trigger('close'); }); if(options.index>-1){ $(options.opt,self).eq(options.index).trigger('click'); } }); } }).call(window,jquery)