(函数($){/***使用平滑动画切换字段集的可见性。*/Drupal.toggleFieldset=函数(fieldset){var$fieldset=$(fieldset);if($fieldset.is('.collapsed')){var$content=$('>.fieldset-wrapper',fieldset).hide();$字段集.removeClass(“折叠”).trigger({type:“折叠”,value:false})find('>legendspan.fieldset-legend-prefix').html(Drupal.t('Hide'));$content.slideDown(向下滑动)({持续时间:“快速”,宽松:“线性”,完成:函数(){Drupal.colappseScrollIntoView(字段集);fieldset.animating=假;},步骤:函数(){//将字段集滚动到视图中。Drupal.collapseScrollIntoView(字段集);}});}其他{$fieldset.trigger({type:'colladed',value:true});$('>.fieldset-wrapper',fieldset).slideUp('fast',function(){$字段集.addClass(“折叠”).find('>legend span.fieldset legend prefix').html(Drupal.t('Show'));fieldset.animating=假;});}};/***尽可能将给定字段集滚动到视图中。*/Drupal.collapseScrollIntoView=函数(节点){var h=document.documentElement.clientHeight||document.body.clientHeight||0;var offset=document.documentElement.scrollTop||document.body.scroll Top||0;var posY=$(节点).offset().top;var fudge=55;if(posY+node.offsetHeight+fudge>h+offset){if(node.offsetHeight>h){window.crollTo(0,posY);}其他{window.rollTo(0,posY+node.offsetHeight-h+fudge);}}};Drupal.behaviors.collapse={附加:函数(上下文,设置){$('fieldset.sublesable',context).once('collapse',function(){var$fieldset=$(此);//如果内部有错误,或者如果它包含//URI片段标识符所针对的元素。var锚=位置哈希&位置哈希!=“#”?“,”+location.hash:“”;if($fieldset.find('.error'+anchor).length){$fieldset.removeClass('collapsed');}var摘要=$('');$fieldset。bind('summaryUpdated',函数(){var text=$.trim($fieldset.drupalGetSummary());summary.html(文本?'('+text+')':'');}).trigger('summaryUpdated');//将图例转换为可单击的链接,但保留span.fieldset-legend//用于CSS定位。var$legend=$('>legend.fieldset-legend',this);$('').append($fieldset.hasClass(“合并”)?Drupal.t('显示'):Drupal.t('隐藏').prependTo($legend).after(“”);//.wrapInner()不保留绑定事件。var$link=$('').prepend($legend.contents()).appendTo($legend).单击(函数(){var字段集=$fieldset.get(0);//不要多次设置动画。if(!fieldset.animating){fieldset.animating=真;Drupal.toggleFieldset(字段集);}返回false;});$legend.append(摘要);});}};})(jQuery);