;(function() { $.fn.extend({ topandopacity: function(target, opacitytarget, durationtime, easingtype, callback) { return this.animate({ top: target, opacity: opacitytarget }, { duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }); }, toani: function(attr, durationtime, easingtype, callback) { return this.animate(attr, { duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }); }, toleft: function(target, durationtime, easingtype, callback) { return this.animate({ left: target }, { duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }); }, totop: function(target, durationtime, easingtype, callback) { return this.animate({ top: target }, { duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }); }, toopacity: function(target, durationtime, easingtype, callback) { return this.animate({ opacity: target }, { duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }); }, tofadein: function(durationtime, easingtype, callback) { return this.fadein({ duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }) }, tofadeout: function(durationtime, easingtype, callback) { return this.fadeout({ duration: durationtime, easing: easingtype, complete: function() { if (callback) callback(); } }) }, toheight: function(target, durationtime, easingtype, callback) { return this.animate({ height: target }, { duration: durationtime, esing: easingtype, complete: function() { if (callback) callback(); } }) }, towidth: function(target, durationtime, easingtype, callback) { return this.animate({ width: target }, { duration: durationtime, esing: easingtype, complete: function() { if (callback) callback(); } }) } }) })() /** * 表单默认文字显隐 */ ;(function(){ $.fn.extend({ //表单文字显隐 inputfill:function(){ $.each($(this),function(index){ $(this).data("oldval",$(this).val()); }) $(this).focus(function(){ console.log($(this).data("oldval")); if($.trim($(this).val()) == $(this).data("oldval")){ $(this).val(""); } }) $(this).blur(function(){ if($.trim($(this).val()) == ""){ $(this).val($(this).data("oldval")); } }) } }) })() // 表单显隐 $(function(){ $("input.fill").inputfill(); }) /** * 自定义下拉列表 */ ;(function(){ $.fn.extend({ // 自定义下拉列表 selectcontrol:function(args){ var selectorheader = $(args.header); var wrap = $(args.itemwrap); var itemtype = args.item; var _this = $(this); var easingtype = args.easing; var speed = args.speed; var inputtext = $(args.inputitem); // 下拉选择函数 _this.find(selectorheader).on("click",function(){ _this.find(wrap).stop(true).slidetoggle({ duration:speed, easing:easingtype }) }); _this.find(itemtype).on("click",function(){ _this.find(wrap).slideup(500); var $this = {}; $this.txt = $(this).text(); $this.data = $(this).data("type"); var valheader = {}; valheader.txt = selectorheader.text(); valheader.data = selectorheader.data("type"); var temp = {}; temp.txt = valheader.txt; temp.data = valheader.data; selectorheader.data({"type":$this.data}).text($this.txt); // console.log($(this).data("type")); $(this).data({"type":temp.data}).text(temp.txt); inputtext.val(selectorheader.data("type")); }); } }) })() /** * banner幻灯片切换 */ ;(function(){ $.fn.extend({ slide:function(args){ var _this = $(this); var slideitem = _this.find(args.slideitem), clickbtn = _this.find(args.clickbtn), active = args.active, sidebtnleft = $(args.sidebtnleft), sidebtnright = $(args.sidebtnright); var speed = args.speed, durationtime = args.duration, easingtype = args.easing; var slidetype = args.slidetype; var index = 0, len = slideitem.length; init(); function init(){ switch(slidetype){ case "fade": fadeinit(); fadefn(); break; case "right": break; default : leftinit(); leftfn(); break; } function fadeinit(){ slideitem.css({ position:"absolute", width:"100%", height:"100%", left:"0px", top:"0px", display:"none" }); slideitem.first().css("display","block"); } function leftinit(){ _this.css("overflow","hidden"); slideitem.css({ position:"absolute", width:"100%", height:"100%", left:"100%", top:"0px" }); slideitem.first().css("left","0px"); } } /** * @descption 淡入淡出切换幻灯片 * @time 2015.11.23 */ function fadefn(){ function run(){ index ++; if(index >= len){ index = 0; } faderun(); } function faderun(){ slideitem.eq(index).stop(true).fadein({duration:durationtime,easing:easingtype}) .siblings().stop(true).fadeout({duration:durationtime,easing:easingtype}); activeclass(); } clickbtn.on("click",function(){ index = $(this).index(); faderun(); activeclass(); }); var timer = setinterval(run,speed); _this.hover(function(){ clearinterval(timer); },function(){ timer = setinterval(run,speed); }); } /** * @descption 左右切换幻灯片 * @time 2015.11.23 */ function leftfn(){ var z = 0; clickbtn.on("click",function(){ index = $(this).index(); if(index > z){ nextrun(); }else{ prevrun(); } activeclass(); }); // 右边按钮切换 sidebtnleft.on("click",function(){ run(); }); // 左边按钮切换 sidebtnright.on("click",function(){ index --; if(index <0){ prevrun(); } }); // 左边切换 function nextrun(){ slideitem.eq(index).css("left","100%"); slideitem.eq(z).css("left","0px"); slideitem.eq(z).stop(true).animate({ left:"-100%" },{ duration:durationtime,easing:easingtype }); slideitem.eq(index).stop(true).animate({ left:0 },{ duration:durationtime,easing:easingtype,complete:function(){ z = index; } }); } // 右边切换 function prevrun(){ slideitem.eq(index).css("left","-100%"); slideitem.eq(z).css("left","0px"); slideitem.eq(z).stop(true).animate({ left:"100%" },{ duration:durationtime,easing:easingtype }); slideitem.eq(index).stop(true).animate({ left:0 },{ duration:durationtime,easing:easingtype,complete:function(){ z = index; } }); } function run(){ index ++; if(index >=len){ index = 0; } nextrun(); activeclass(); } var timer = setinterval(run,speed); _this.hover(function(){ clearinterval(timer); },function(){ timer = setinterval(run,speed);; }); } // 用于 点击小按钮的 class切换 function activeclass(){ clickbtn.eq(index).addclass(active).siblings().removeclass(active); } } }) })() // 大小图 切换 slide插件 ;(function(){ $.fn.extend({ smallslide:function(args){ var _this = $(this); var big_li = $(args.bigli), small_li = _this.find("li"), small_wrapper = _this; var lioffset = args.lioffset; var small_li_z = 0; var maxoffset = parseint((small_li.length-args.showmaxlen-1)*lioffset); var activeclass = args.activeclass; var durationtime = args.durationtime; var index = 0; var parents = $(args.parents); function init(){ _this.css("width",small_li.length*lioffset+"px"); big_li.css("display","none").find("img").css("opacity",0); big_li.first().css("display","").find("img").css("opacity",1); } init(); small_li.click(function(){ index = $(this).index(); run(); }) function run(){ if(!_this.is(":animated")){ if(small_li.length > args.showmaxlen){ var _left = math.floor(math.abs(_this.position().left)); if(index == small_li.length-1){ _this.animate({left:-(maxoffset + lioffset)},durationtime); }else if(index == 0){ _this.animate({left:0},durationtime); }else if(index > small_li_z && _left <= maxoffset){ _this.stop(true).animate({left:"-="+lioffset+"px"},durationtime); }else if(index < small_li_z && _this.position().left<0){ _this.animate({left:"+="+lioffset+"px"},durationtime); }else if(index <=3 && _this.position().left<0){ _this.stop(true).animate({left:"+="+lioffset+"px"},durationtime); } } small_li_z = index; small_li.eq(index).addclass(activeclass).siblings("li").removeclass(activeclass); big_li.eq(index).show() .find("img").animate({opacity:1},durationtime).parent() .siblings().hide() .find("img").animate({opacity:0},durationtime); } } var next = $(args.next,parents); next.click(function(){ fnrun(); }) var prev = $(args.prev,parents); prev.click(function(){ index --; if(index < 0){ index = small_li.length-1; } run(); }) function fnrun(){ index ++; if(index > small_li.length-1){ index = 0; } run(); } var timer = setinterval(fnrun,3500); parents.hover(function(){ clearinterval(timer); },function(){ timer = setinterval(fnrun,3500); }) // $(small_wrapper).hover(function(){ // clearinterval(timer); // },function(){ // timer = setinterval(fnrun,3500); // }) // // $(prev).hover(function(){ // clearinterval(timer); // },function(){ // timer = setinterval(fnrun,3500); // }) // // $(next).hover(function(){ // clearinterval(timer); // },function(){ // timer = setinterval(fnrun,3500); // }) } }) })(); // ---------------------华丽丽的分割线------------------------- // 首页 别墅装修案例 // e_fn(); $.extend({ bnr:function(args){ var _list_index = 0, _lft = 0, _small_list = args.smallli, _biglist = args.bigli, _list_ul = args.ul, _prev = args.prev, _next = args.next, _class = args.focsname, _auto_time = args.autotime, _speed = args.speed, _visible_size = args.visiblesize, _p_box = args.bigbox, _small_box = args.smallbox, _width = args.smallli.outerwidth() +args.margin, _outer = args.liouter + args.margin, _type = args.atype, _highclass = args.hoverclass; if(!args.time){ _auto_time = 7000; } if(!args.speed){ _speed = 750; } // excute fn _next.click(function(){ _list_index ++; small_fn(); }); _prev.click(function(){ _list_index --; small_fn(); }); _small_list.click(function(){ _list_index = $(this).index(); small_fn(); }); function small_fn(){ var _lft = 0; if(_list_index<0){ _list_index = _small_list.length-1; } if(_list_index >=_small_list.length){ _list_index = 0; _list_ul.animate({left:0}); } if(_list_index !=0){ var $prev_num = _small_list.eq(_list_index).prevall().length, $next_num = _small_list.eq(_list_index).nextall().length; if (_list_index >= _visible_size-3 ) { if ($next_num >= 3) { _lft = _list_index - (_visible_size-3); if ($prev_num >= 3) { _list_ul.animate({left:-(_lft*_width-_outer/2)},_speed); } else { _list_ul.animate({left:-_lft*_width},_speed); } } else { _list_ul.animate({left:-(_small_list.length-_visible_size)*_width+_outer},_speed); } } else { _list_ul.animate({left:0},_speed); } } _small_list.eq(_list_index).addclass(_class).siblings(_type).removeclass(_class); _biglist.eq(_list_index).show() .find("img").animate({opacity:1},{duration:2000,easing:'easeoutexpo'}) .parents(_type).siblings(_type).hide().find("img").css("opacity","0"); } function run(){ _list_index ++; small_fn(); } var timer = setinterval(run,_auto_time); _p_box.hover(function(){ clearinterval(timer); },function(){ timer = setinterval(run,_auto_time); }); _small_list.hover(function(){ clearinterval(timer); if(!$(this).hasclass('active')){ $(this).addclass('hover').siblings("li").removeclass("hover"); } },function(){ timer = setinterval(run,_auto_time); if(!$(this).hasclass('active')){ $(this).removeclass('hover'); } }) } }); /* * lazy load - jquery plugin for lazy loading images * * copyright (c) 2007-2012 mika tuupola * * licensed under the mit license: * http://www.opensource.org/licenses/mit-license.php * * project home: * http://www.appelsiini.net/projects/lazyload * * version: 1.8.0 * */ ;(function($, window) { var $window = $(window); $.fn.lazyload = function(options) { var elements = this; var $container; var settings = { threshold : 0, failure_limit : 0, event : "scroll", effect : "fadein", container : window, data_attribute : "original", skip_invisible : true, appear : null, load : null }; function update() { var counter = 0; elements.each(function() { var $this = $(this); if (settings.skip_invisible && !$this.is(":visible")) { return; } if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) { /* nothing. */ } else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) { $this.trigger("appear"); } else { if (++counter > settings.failure_limit) { return false; } } }); } if(options) { /* maintain bc for a couple of versions. */ if (undefined !== options.failurelimit) { options.failure_limit = options.failurelimit; delete options.failurelimit; } if (undefined !== options.effectspeed) { options.effect_speed = options.effectspeed; delete options.effectspeed; } $.extend(settings, options); } /* cache container as jquery as object. */ $container = (settings.container === undefined || settings.container === window) ? $window : $(settings.container); /* fire one scroll event per scroll. not one scroll event per image. */ if (0 === settings.event.indexof("scroll")) { $container.bind(settings.event, function(event) { return update(); }); } this.each(function() { var self = this; var $self = $(self); self.loaded = false; /* when appear is triggered load original image. */ $self.one("appear", function() { if (!this.loaded) { if (settings.appear) { var elements_left = elements.length; settings.appear.call(self, elements_left, settings); } $("") .bind("load", function() { $self .hide() .attr("src", $self.data(settings.data_attribute)) [settings.effect](settings.effect_speed); self.loaded = true; /* remove image from array so it is not looped next time. */ var temp = $.grep(elements, function(element) { return !element.loaded; }); elements = $(temp); if (settings.load) { var elements_left = elements.length; settings.load.call(self, elements_left, settings); } }) .attr("src", $self.data(settings.data_attribute)); } }); /* when wanted event is triggered load original image */ /* by triggering appear. */ if (0 !== settings.event.indexof("scroll")) { $self.bind(settings.event, function(event) { if (!self.loaded) { $self.trigger("appear"); } }); } }); /* check if something appears when window is resized. */ $window.bind("resize", function(event) { update(); }); /* force initial check if images should appear. */ update(); return this; }; /* convenience methods in jquery namespace. */ /* use as $.belowthefold(element, {threshold : 100, container : window}) */ $.belowthefold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.height() + $window.scrolltop(); } else { fold = $(settings.container).offset().top + $(settings.container).height(); } return fold <= $(element).offset().top - settings.threshold; }; $.rightoffold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.width() + $window.scrollleft(); } else { fold = $(settings.container).offset().left + $(settings.container).width(); } return fold <= $(element).offset().left - settings.threshold; }; $.abovethetop = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrolltop(); } else { fold = $(settings.container).offset().top; } return fold >= $(element).offset().top + settings.threshold + $(element).height(); }; $.leftofbegin = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrollleft(); } else { fold = $(settings.container).offset().left; } return fold >= $(element).offset().left + settings.threshold + $(element).width(); }; $.inviewport = function(element, settings) { return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings); }; /* custom selectors for your convenience. */ /* use as $("img:below-the-fold").something() */ $.extend($.expr[':'], { "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); }, "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); }, "in-viewport" : function(a) { return !$.inviewport(a, {threshold : 0}); }, /* maintain bc for couple of versions. */ "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); } }); })(jquery, window); //旋转 ;(function($, window) { var ele ; //自定义函数 $.fn.extend({ rotate: function () { ele = this ; setinterval('singlerotate()',20); } }); //初始角度 var degree = 0; //单次旋转 function singlerotate() { //一次增加50度 degree = degree + 50 * math.pi / 180; ele.css("transform","rotate("+degree+"deg)"); }; })(jquery, window); if ($(".z_rotate").length > 0) { //$(".z_rotate").rotate(); } //// 自定义下拉列表 //$("div.select").selectcontrol({ // header:".select-header", // itemwrap:".select-item", // item:"a", // easing:"easeoutexpo", // speed:750, // inputitem:"#test" //}); //// banner 插件 //$(".banner").slide({ // slideitem:"li", // clickbtn:".btn a", // active:"active", // sidebtnleft:"#prev", // sidebtnright:"#next", // slidetype:"fade", // speed:3500, // durationtime:750, // easingtype:"easeoutexpo" //}); // 大小图 切换 slide插件 // demo //$("#site-small-image").smallslide({ // bigli:"#site-big-image li", // showmaxlen:5, // lioffset:241, // activeclass:"active", // durationtime:500, //});