I use the following code to minimize a number of summary link web parts on a SharePoint 2016 welcome page with web parts and it seems to do the expand/collapse work properly in view mode. However, in page edit mode it becomes very complicated for most users to edit the web parts, since they first need to select "restore" to mazimize the web parts. How can I keep the web parts maximized in edit mode?

<script type="text/javascript" src="/sites/xxx/SiteAssets/jquery-3.2.1.min.js"></script>
<script type="text/javascript" >
//Hide the web parts and add expand icon to web part header
setTimeout(function() {
    }, 0);

function MinimizeWebParts(webPartTitles)
    for(index in webPartTitles)
        var title = webPartTitles[index];
        //Hide the web parts

        //Add Expand Icon to Web Part Header
        $('Span#WebPartTitle'+title).find('h2').append("<span style='padding-left:0.5em; text-decoration:none'> <img id='ExpandCollapse' src='/_layouts/images/movedown.gif'></span>");

  //toggle the web part   
  $(".ms-webpart-chrome-title ").click(function()

    //find and toggle the image in the webpart title
    var newSrc = jQuery(this).find(".ms-webpart-titleText img").attr('src') === "/_layouts/images/movedown.gif" ? "/_layouts/images/moveup.gif" : "/_layouts/images/movedown.gif";
    jQuery(this).find(".ms-webpart-titleText img").attr('src', newSrc);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.