Extending the Page Tool Menu
You can extend the page tool menu by adding subpages to it.
You can add subpages to the page tool menu, to the experience selector toolbar, and to the SmartEdit title toolbar. The page tool menu also provides the functionality to trigger a close callback that is set by a configured subpage. For example: you can configure the page tool menu with a subpage that triggers a specific editing mode in SmartEdit. When a user closes the page tool menu, SmartEdit exits this editing mode. The close callback can be leveraged to provide this functionality.
Adding Items to the Page Tool Menu
As is the case of the SmartEdit title toolbar and experience selector toolbar, you can use the toolbar service factory to get an instance of the toolbar service specific to the pageToolMenu key. You can leverage the toolbar service to add new items to the page tool menu.
The following example shows how to add an item, called Page Information, to the page tool menu.
angular.module('myModule', ['toolbarModule', 'myServiceModule'])
.run(
function(toolbarServiceFactory) {
var pageToolMenuService = toolbarServiceFactory.getToolbarService("pageToolMenu");
pageToolMenuService.addItems([{
i18nKey: 'page.tool.menu.page.information',
type: 'HYBRID_ACTION',
icons: {
'default': 'static-resources/images/icon_small_info.png'
},
include: 'path/to/pageInformationWrapperTemplate.html'
}]);
});
Implementing Close Callbacks
To leverage a close callback, do the following:
-
In the template for the Page Information item, declare a directive with an attribute called selected-item-callbacks and bind it to the selectedItemCallbacks object on the scope of the page tool menu directive, as shown in the example from the pageInformationWrapperTemplate.html file:
<page-information selected-item-callbacks="selectedItemCallbacks"></page-information>
-
Define the pageInformation directive to set content, call other services, and leverage the close callback of the page tool menu, as shown in the following example:
angular.module('pageInformationModule', []) .directive('pageInformation', function(pageInformationService, $log) { return { templateUrl: 'path/to/pageInformationTemplate.html', restrict: 'E', transclude: true, scope: { selectedItemCallbacks: "=" }, link: function(scope, elem, attrs) { scope.pageInformationDetails = pageInformationService.getDetails(); scope.selectedItemCallbacks.onClose = function() { pageInformationService.reset(); }; } }; });