Skip to content

Instantly share code, notes, and snippets.

@MartinMiles
Created April 8, 2019 11:37
Show Gist options
  • Save MartinMiles/9f162db4aa03677c30e292a24c55f78e to your computer and use it in GitHub Desktop.
Save MartinMiles/9f162db4aa03677c30e292a24c55f78e to your computer and use it in GitHub Desktop.
Adding Expand / Collapse buttons to Experience Editor (Sitecore 9)
/* Adds Expand all and Collapse all buttons to Content Editor */
scContentEditor.prototype.onDomReady = function (evt) {
this.addCollapser(window.jQuery || window.$sc);
};
scContentEditor.prototype.addCollapser = function ($) {
$ = $ || window.jQuery || window.$sc;
if (!$) { return; }
$('#EditorTabs').append("<style>.toggler { border: 1px solid #bdbdbd; box-shadow: 0 1px #ffffff inset; cursor: pointer; height: 35px; margin: 16px 1px 0; }</style>");
$('#EditorTabs').append("<button id='expander' class='toggler'>Expand all</button><button id='collapser' class='toggler'>Collapse all</button>");
$('#EditorTabs').on("click", "#collapser", function () {
$('.scEditorSectionCaptionExpanded').each(function () {
var script = $(this).attr("onclick");
eval(script);
});
return false;
});
$('#EditorTabs').on("click", "#expander", function () {
$('.scEditorSectionCaptionCollapsed').each(function () {
var script = $(this).attr("onclick");
eval(script);
});
return false;
});
};
$file2 = Get-Content "ExpanderCollapser.js"
Add-Content "C:\inetpub\wwwroot\Platform.dev.local\sitecore\shell\Applications\Content Manager\Content Editor.js" $file2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment