javascript - HTML Source Editor - Web Part -
i working on html web part. wanted make other web parts on page collapsable , expandable. found script place in html form web part. want. thing other parts automatically expanded when page loaded. read through script but, not familiar jquery syntax. line in code believe need change make sections automatically collapsed is:
$(this).closest('.s4-wptoptable').find('tr:first').next().toggle().is(":visible") ? img.attr('src',collapse) : img.attr('src',expand );
i believe need change has toggle visible not visible. not sure how write that.
here's whole script:
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.1.min.js"></script> <script type="text/javascript"> jquery(function($) { $('.s4-wptoptable').find('tr:first h3').append('<a class=\'min\' style=\'float:right\'><img src=\'/_layouts/images/collapse.gif\'/></a>'); var collapse = "/_layouts/images/collapse.gif"; var expand = "/_layouts/images/expand.gif"; $('.min').click(function(){ var img = $(this).children(); $(this).closest('.s4-wptoptable').find('tr:first').next().toggle().is(":visible") ? img.attr('src',collapse) : img.attr('src',expand ); }); }); </script>
here trick may work you.click on edit web part,under appearance find chrome state, need set chrome state 'minimized',by default chrome state 'normal.
then place code either in cewp or in .aspx page using sharepoint designer.
Comments
Post a Comment