;(function($){ var accordion = function (obj,option){ var self = this ; this.obj = obj; this.option = option; this.lessthanie8 = /msie 6.0|msie 7.0|msie 8.0/gi.test(window.navigator.useragent); this.defaults = { imageobj : [], arrangement : "horizontal", //verticality fontcut : 500, defaultwidth : 100, defaultheight : 100, animatewidth : 600, animateheight : 200, response : true, stylecolor : {"background":"#fff","font":"#333333","textshadow":"0px 0px 1px green"}, animatetime : "0.5s" }; $.extend(this.defaults,this.option); this.defaultdom(); self.eachimgwidth= 100; var img = new image(); $.each(this.defaults.imageobj,function(i,src){ img.src = self.defaults.imageobj[i]; $(img).on('load error',function() { self.winwidth = self.obj.find('ul[data-name="accordion"]').innerwidth(); }); }) this.winwidth = this.obj.find('ul[data-name="accordion"]').innerwidth(); this.li = this.obj.find('.accordion-li'); this.icon = this.obj.find('.accordion-icon'); this.description = this.obj.find('.accordion-description'); this.title = this.obj.find('.accordion-title'); this.content = this.obj.find('.accordion-content'); this.div = this.obj.parents('.accordion-div'); this.len = this.defaults.imageobj.length; this.eachsmallimgwidth = this.defaults.defaultwidth; this.icon.css('color',this.defaults.stylecolor.font); this.description.css('backgroundcolor',this.defaults.stylecolor.background); this.title.css('textshadow',this.defaults.stylecolor.textshadow); this.content.css('textshadow',this.defaults.stylecolor.textshadow); this.responsedom(); this.cutoverflowstring(); // animate if(this.defaults.arrangement === "horizontal"){ this.obj.hover(function() { $(this).find(".accordion-li").css("transition","width "+ self.defaults.animatetime +""); }); var response = (this.defaults.response)?self.eachimgwidth:self.defaults.defaultwidth; this.li.hover(function(e) { $(this).siblings('.accordion-li').width(self.eachsmallimgwidth); $(this).addclass('active').css("width",self.defaults.animatewidth); if(self.lessthanie8){ $(this).find(".accordion-description").css("background",self.defaults.stylecolor.background).parents('.accordion-li').siblings() .find(".accordion-description").css("background",self.defaults.stylecolor.background); }else{ $(this).find(".accordion-description").css("background","linear-gradient("+self.colormd5count(self.defaults.stylecolor.background,0).rgba+","+ self.defaults.stylecolor.background +")"); } },function(e){ $(this).removeclass('active'); self.li.css("width",response); $(this).find(".accordion-description").css("background","linear-gradient("+self.defaults.stylecolor.background+","+ self.defaults.stylecolor.background +")"); }) }else if(this.defaults.arrangement === "verticality"){ this.div.css('overflow','inherit'); this.li.on('click',function(){ if($(this).hasclass('active')){ $(this).css("height",self.defaults.defaultheight).removeclass('active') $(this).find(".accordion-description").css({ "background":"linear-gradient("+self.colormd5count(self.defaults.stylecolor.background,100).rgba+","+ self.defaults.stylecolor.background +")", "transition":"all "+self.defaults.animatetime }); }else{ $(this).addclass('active').siblings().css("height",self.defaults.defaultheight).removeclass('active'); $(this).css('height', self.defaults.animateheight); $(this).find(".accordion-description").css({ "background":"linear-gradient("+self.colormd5count(self.defaults.stylecolor.background,0).rgba+","+ self.defaults.stylecolor.background +")", "transition":"all "+self.defaults.animatetime }); }; }); } }; accordion.prototype = { defaultdom:function(){ var imgarr = this.defaults.imageobj, lihtml = ''; if(!imgarr) return; $.each( imgarr , function(index, val) { val.alt = val.alt || null; val.icon = val.icon || null; val.title = val.title || null; val.content = val.content || null; val.url = val.url || "javascript:void(0)"; lihtml += '