The Collapsible Heading Widget is by default expanded. This is by design so that the content beneath the heading is visible but can be collapsed by the user. You may, however, decide that you want the headings to be initially collapsed. You can do this by adding some custom script to your project.
- Create a new javascript file in your project script directory (e.g. headings-initially-collapsed.js) using notepad and copy and paste the script below:
(function () { // Define a new feature constructor var collapseAllOnLoadFeature = function(documentInstance) { Innovasys.Content.DocumentFeatureBase.call(this, documentInstance); }; // .. that inherits from the DocumentFeatureBase __extends(collapseAllOnLoadFeature, Innovasys.Content.DocumentFeatureBase); // Return a unique feature name collapseAllOnLoadFeature.prototype.getName = function () { return "Collapse All Toggle Sections On Load"; }; // Make sure it initializes after the built in features collapseAllOnLoadFeature.prototype.initializeContentOrdinal = function () { return 99999; } // When the content initializes, collapse any sections that are not already collapsed collapseAllOnLoadFeature.prototype.initializeContent = function (rootSelector, isInitialLoad) { var toggleFeature = this.documentInstance.getFeatureByName("Toggle Sections"); var expandedSections = $("." + toggleFeature.getToggleHeadingClassName() +":not(." + toggleFeature.getToggleHeadingClassName() + toggleFeature.getToggledSuffix() + ")"); toggleFeature.toggleSection(expandedSections, true); } // The factory is how we register our feature with the Innovasys document object var collapseAllOnLoadFactory = function() {}; collapseAllOnLoadFactory.prototype.createInstance = function (documentInstance) { return new collapseAllOnLoadFeature(documentInstance); }; // Register our factory in the DocumentFeatureConfiguration Innovasys.Content.DocumentFeatureConfiguration.registerDocumentFeatureFactory(new collapseAllOnLoadFactory()); })();
- Add the .js file you created to your project using the Add Existing Other File ribbon command.
After you rebuild your output, collapsible Heading Widgets in your Topics will now be collapsed by default in the generated output.
5 Comments