打开主菜单

少前百科GFwiki β

Widget:InnCollapse

莹lolo讨论 | 贡献2020年12月1日 (二) 02:37的版本 (测试)

<script type="text/javascript">(window.RLQ=window.RLQ||[]).push(function(){ /* 调用多次时仅添加一次事件 */ if(!thisCollapse){

   var thisCollapse = document.querySelectorAll(".innCollapse");
   $(window).resize(function() { 
       $(".innCollapse").children().css("max-width", parseInt(Number($(".innCollapse").parent().width()) -40));});
   $(window).load(function() { 
       forInnColResize();})

} /*  折叠展开   */ function forInnCollapse(element){

   var nextElement = $(element).next().next();
   if($(element).attr("status") == "none"){ 
       $(element).attr("status", "visible");
       $(element).children().children("img").attr("src", "http://www.gfwiki.org/images/8/8d/InnCollapse_up.png");
       nextElement.slideDown("fast");}
   else{ 
       $(element).attr("status", "none");
       $(element).children().children("img").attr("src", "http://www.gfwiki.org/images/a/ac/InnCollapse_down.svg");
       nextElement.slideUp("fast");}

}

/*  宽度改变   */ function forInnColResize() {

   var thisE = $(".innCollapse");
   thisE.next().css("display", "none");
   if(thisE.attr("widthset")){
       thisE.children().width(thisE.attr("widthset"));}
   else{
       var nextE = thisE.next().next();
       var tarwidth = nextE.css("width");
       thisE.children().width(parseInt(Number(tarwidth) - 40));
       thisE.children().css("max-width", parseInt(Number(thisE.parent().width()) -40));
       thisE.unbind('click').removeAttr('onclick').click(function(){ forInnCollapse(this);});

} })</script>