/*! * UI development toolkit for HTML5 (OpenUI5) * (c) Copyright 2009-2018 SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ sap.ui.define([ "sap/ui/core/Control", "sap/ui/base/ManagedObject", "sap/f/library", "sap/f/DynamicPage", "sap/f/DynamicPageTitle", "sap/f/DynamicPageHeader", "sap/m/OverflowToolbar", "sap/m/ActionSheet", "./SemanticTitle", "./SemanticFooter", "./SemanticShareMenu", "./SemanticConfiguration", "./SemanticPageRenderer" ], function( Control, ManagedObject, library, DynamicPage, DynamicPageTitle, DynamicPageHeader, OverflowToolbar, ActionSheet, SemanticTitle, SemanticFooter, SemanticShareMenu, SemanticConfiguration, SemanticPageRenderer ) { "use strict"; // shortcut for sap.f.DynamicPageTitleArea var DynamicPageTitleArea = library.DynamicPageTitleArea; /** * Constructor for a new SemanticPage. * * @param {string} [sId] ID for the new control, generated automatically if no ID is given * @param {object} [mSettings] Initial settings for the new control * * @class * An enhanced {@link sap.f.DynamicPage}, that contains controls with semantic-specific meaning. * *

Overview

* * Content specified in the sap.f.semantic.SemanticPage aggregations is automatically * positioned in dedicated sections of the title or the footer of the page, depending on * the control's semantics. * * The actions in the SemanticPage title are grouped to text actions or icon actions. * When an aggregation is set, the actions appear in the following predefined order (from left to right): * * * * * * The actions in the SemanticPage footer are positioned either on its left or right area and have the following predefined order: * * * * * *

Usage

* * Using the SemanticPage facilitates the implementation of the SAP Fiori 2.0 design guidelines. * *

Responsive behavior

* * The responsive behavior of the SemanticPage depends on the behavior of the content that is displayed. * To adjust the SemanticPage content padding, the sapUiContentPadding, * sapUiNoContentPadding, and sapUiResponsiveContentPadding CSS classes can be used. * * @extends sap.ui.core.Control * * @author SAP SE * @version 1.60.23 * * @constructor * @public * @since 1.46.0 * @alias sap.f.semantic.SemanticPage * @see {@link topic:47dc86847f7a426a8e557167cf523bda Semantic Page} * @see {@link topic:84f3d52f492648d5b594e4f45dca7727 Semantic Pages} * @see {@link topic:4a97a07ec8f5441d901994d82eaab1f5 Semantic Page (sap.m)} * @see {@link fiori:https://experience.sap.com/fiori-design-web/semantic-page/ Semantic Page} * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel */ var SemanticPage = Control.extend("sap.f.semantic.SemanticPage", /** @lends sap.f.semantic.SemanticPage.prototype */ { metadata: { library: "sap.f", properties: { /** * Determines whether the header is expanded. * * The header can be also expanded/collapsed by user interaction, * which requires the property to be internally mutated by the control to reflect the changed state. * * Note: Please be aware, that initially collapsed header state is not supported, * so headerExpanded should not be set to false when initializing the control. */ headerExpanded: {type: "boolean", group: "Behavior", defaultValue: true}, /** * Determines whether the header is pinnable. */ headerPinnable: {type: "boolean", group: "Behavior", defaultValue: true}, /** * Preserves the current header state when scrolling. * * For example, if the user expands the header by clicking on the title * and then scrolls down the page, the header will remain expanded. * * Note: Based on internal rules, the value of the property is not always taken into account - for example, * when the control is rendered on tablet or mobile and the title and the header * are with height larger than a given threshold. */ preserveHeaderStateOnScroll: {type: "boolean", group: "Behavior", defaultValue: false}, /** * Determines whether the user can switch between the expanded/collapsed states of the * header by clicking on the title. * * If set to false, the title is not clickable and the application * must provide other means for expanding/collapsing the header, if necessary. */ toggleHeaderOnTitleClick: {type: "boolean", group: "Behavior", defaultValue: true}, /** * Determines whether the footer is visible. */ showFooter: {type: "boolean", group: "Behavior", defaultValue: false}, /** * Determines which of the title areas (Begin, Middle) is primary. * * Note: The primary area is shrinking at a lower rate, remaining visible as long as it can. * * @since 1.52 * * @deprecated as of version 1.58. Please use the titleAreaShrinkRatio property instead. * The value of titleAreaShrinkRatio must be set in Heading:Content:Actions format * where Heading, Content and Actions are numbers greater than or equal to 0. The greater value a * section has the faster it shrinks when the screen size is being reduced. * * titlePrimaryArea=Begin can be achieved by setting a low number for the Heading area to * titleAreaShrinkRatio, for example 1:1.6:1.6. * * titlePrimaryArea=Middle can be achieved by setting a low number for the Content area to * titleAreaShrinkRatio, for example 1.6:1:1.6. */ titlePrimaryArea : {type: "sap.f.DynamicPageTitleArea", group: "Appearance", defaultValue: DynamicPageTitleArea.Begin}, /** * Assigns shrinking ratio to the SemanticPage title areas (Heading, Content, Actions). * The greater value a section has the faster it shrinks when the screen size is being reduced. * * The value must be set in Heading:Content:Actions format where Title, Content and Actions * are numbers greater than or equal to 0. If set to 0, the respective area will not shrink. * * For example, if 2:7:1 is set, the Content area will shrink seven times faster than * the Actions area. So, when all three areas have width of 500px and the available space is reduced by 100px * the Title area will be reduced by 20px, the Content area - by 70px and the Actions area - by 10px. * * If all the areas have assigned values greater than 1, the numbers are scaled so that at least one of them * is equal to 1. For example, value of 2:4:8 is equal to 1:2:4. * * When this property is set the titlePrimaryArea property has no effect. * * @since 1.58 */ titleAreaShrinkRatio : {type: "sap.f.DynamicPageTitleShrinkRatio", group: "Appearance", defaultValue: "1:1.6:1.6"} }, defaultAggregation : "content", aggregations: { /** * The SemanticPage heading. * * A typical usage is the sap.m.Title or any other UI5 control, * that serves as a heading for an object. * * Note: The control will be placed in the title`s leftmost area. */ titleHeading: {type: "sap.ui.core.Control", multiple: false, defaultValue: null, forwarding: {getter: "_getTitle", aggregation: "heading"}}, /** * The titleExpandedHeading is positioned in the SemanticPage title left area * and is displayed when the header is in expanded state only. * Use this aggregation to display a title (or any other UI5 control that serves * as a heading) that has to be present in expanded state only. * * Note: In order for titleExpandedHeading to be taken into account, * titleHeading has to be empty. Combine titleExpandedHeading with * titleSnappedHeading to switch content when the header switches state. * @since 1.58 */ titleExpandedHeading: {type: "sap.ui.core.Control", multiple: false, defaultValue: null, forwarding: {getter: "_getTitle", aggregation: "expandedHeading"}}, /** * The titleSnappedHeading is positioned in the SemanticPage title left area * and is displayed when the header is in collapsed (snapped) state only. * Use this aggregation to display a title (or any other UI5 control that serves * as a heading) that has to be present in collapsed state only. * * Note: In order for titleSnappedHeading to be taken into account, * titleHeading has to be empty. Combine titleSnappedHeading with * titleExpandedHeading to switch content when the header switches state. * @since 1.58 */ titleSnappedHeading: {type: "sap.ui.core.Control", multiple: false, defaultValue: null, forwarding: {getter: "_getTitle", aggregation: "snappedHeading"}}, /** * The SemanticPage breadcrumbs. * * A typical usage is the sap.m.Breadcrumbs control or any other UI5 control, * that implements the sap.m.IBreadcrumbs interface. * * Note: The control will be placed in the title`s top-left area. * @since 1.52 */ titleBreadcrumbs: {type: "sap.m.IBreadcrumbs", multiple: false, defaultValue: null, forwarding: {getter: "_getTitle", aggregation: "breadcrumbs"}}, /** * The content, displayed in the title, when the header is in collapsed state. * * Note: The controls will be placed in the title`s left area, * under the titleHeading aggregation. */ titleSnappedContent: {type: "sap.ui.core.Control", multiple: true, forwarding: {getter: "_getTitle", aggregation: "snappedContent"}}, /** * The content,displayed in the title, when the header is in expanded state. * * Note: The controls will be placed in the title`s left area, * under the titleHeading aggregation. */ titleExpandedContent: {type: "sap.ui.core.Control", multiple: true, forwarding: {getter: "_getTitle", aggregation: "expandedContent"}}, /** * The content, displayed in the title. * * Note: The controls will be placed in the middle area. * @since 1.52 */ titleContent: {type: "sap.ui.core.Control", multiple: true, forwarding: {getter: "_getTitle", aggregation: "content"}}, /** * A semantic-specific button which is placed in the SemanticPage title as first action. */ titleMainAction: {type: "sap.f.semantic.TitleMainAction", multiple: false}, /** * A semantic-specific button which is placed in the TextActions area of the SemanticPage title. * @since 1.50 */ editAction: {type: "sap.f.semantic.EditAction", multiple: false}, /** * A semantic-specific button which is placed in the TextActions area of the SemanticPage title. */ deleteAction: {type: "sap.f.semantic.DeleteAction", multiple: false}, /** * A semantic-specific button which is placed in the TextActions area of the SemanticPage title. */ copyAction: {type: "sap.f.semantic.CopyAction", multiple: false}, /** * A semantic-specific button which is placed in the TextActions area of the SemanticPage title. */ addAction: {type: "sap.f.semantic.AddAction", multiple: false}, /** * A semantic-specific button which is placed in the IconActions area of the SemanticPage title. */ flagAction: {type: "sap.f.semantic.FlagAction", multiple: false}, /** * A semantic-specific button which is placed in the IconActions area of the SemanticPage title. */ favoriteAction: {type: "sap.f.semantic.FavoriteAction", multiple: false}, /** * A semantic-specific button which is placed in the IconActions area of the SemanticPage title. */ fullScreenAction: {type: "sap.f.semantic.FullScreenAction", multiple: false}, /** * A semantic-specific button which is placed in the IconActions area of the SemanticPage title. */ exitFullScreenAction: {type: "sap.f.semantic.ExitFullScreenAction", multiple: false}, /** * A semantic-specific button which is placed in the IconActions area of the SemanticPage title. */ closeAction: {type: "sap.f.semantic.CloseAction", multiple: false}, /** * The titleCustomTextActions are placed in the TextActions area of the * SemanticPage title, right before the semantic text action. */ titleCustomTextActions: {type: "sap.m.Button", multiple: true}, /** * The titleCustomIconActions are placed in the IconActions area of the * SemanticPage title, right before the semantic icon action. */ titleCustomIconActions: {type: "sap.m.OverflowToolbarButton", multiple: true}, /** * The header content. */ headerContent: {type: "sap.ui.core.Control", multiple: true, forwarding: {getter: "_getHeader", aggregation: "content"}}, /** * The SemanticPage content. * * Note: The SAP Fiori Design guidelines require that the * SemanticPage's header content and the SemanticPage's content * are aligned vertically. When using {@link sap.ui.layout.form.Form}, * {@link sap.m.Panel}, {@link sap.m.Table} and {@link sap.m.List} in the content area of * SemanticPage, if the content is not already aligned, you need to adjust * their left text offset to achieve the vertical alignment. To do this, apply the * sapFSemanticPageAlignContent CSS class to them and set their width * property to auto (if not set by default). * * Example: * *
				*  <Panel class=“sapFSemanticPageAlignContent” width=“auto”></Panel> 
				* 
* * Please keep in mind that the alignment is not possible when the controls are placed in * a {@link sap.ui.layout.Grid} or in other layout controls that use * overflow:hidden CSS property. */ content: {type: "sap.ui.core.Control", multiple: false}, /** * A semantic-specific button which is placed in the FooterRight area of the SemanticPage * footer with default text value set to Save. */ footerMainAction: {type: "sap.f.semantic.FooterMainAction", multiple: false}, /** * A semantic-specific button which is placed in the FooterLeft area of the SemanticPage * footer as a first action. */ messagesIndicator: {type: "sap.f.semantic.MessagesIndicator", multiple: false}, /** * A semantic-specific button which is placed in the FooterLeft area of the SemanticPage * footer as a second action. */ draftIndicator: {type: "sap.m.DraftIndicator", multiple: false}, /** * A semantic-specific button which is placed in the FooterRight area of the SemanticPage * footer with default text value set to Accept. */ positiveAction: {type: "sap.f.semantic.PositiveAction", multiple: false}, /** * A semantic-specific button which is placed in the FooterRight area of the SemanticPage * footer with default text value set to Reject. */ negativeAction: {type: "sap.f.semantic.NegativeAction", multiple: false}, /** * The footerCustomActions are placed in the FooterRight area of the * SemanticPage footer, right after the semantic footer actions. * * Note: Buttons that are part of this aggregation will always have their type * property set to Transparent by design. */ footerCustomActions: {type: "sap.m.Button", multiple: true}, /** * A semantic-specific button which is placed in the ShareMenu area of the SemanticPage title. */ discussInJamAction: {type: "sap.f.semantic.DiscussInJamAction", multiple: false}, /** * A button which is placed in the ShareMenu area of the SemanticPage title. */ saveAsTileAction: {type: "sap.m.Button", multiple: false}, /** * A semantic-specific button which is placed in the ShareMenu area of the SemanticPage title. */ shareInJamAction: {type: "sap.f.semantic.ShareInJamAction", multiple: false}, /** * A semantic-specific button which is placed in the ShareMenu area of the SemanticPage title. */ sendMessageAction: {type: "sap.f.semantic.SendMessageAction", multiple: false}, /** * A semantic-specific button which is placed in the ShareMenu area of the SemanticPage title. */ sendEmailAction: {type: "sap.f.semantic.SendEmailAction", multiple: false}, /** * A semantic-specific button which is placed in the ShareMenu area of the SemanticPage title. */ printAction: {type: "sap.f.semantic.PrintAction", multiple: false}, /** * The customShareActions are placed in the ShareMenu area of the * SemanticPage title, right after the semantic actions. */ customShareActions: {type: "sap.m.Button", multiple: true}, /** * The aggregation holds DynamicPage, used internally. */ _dynamicPage: {type: "sap.f.DynamicPage", multiple: false, visibility: "hidden"} }, designtime : "sap/f/designtime/SemanticPage.designtime" } }); /* * STATIC MEMBERS */ SemanticPage._EVENTS = { SHARE_MENU_CONTENT_CHANGED : "_shareMenuContentChanged" }; SemanticPage._SAVE_AS_TILE_ACTION = "saveAsTileAction"; SemanticPage.CONTENT_PADDING_CLASSES_TO_FORWARD = { "sapUiNoContentPadding": true, "sapUiContentPadding": true, "sapUiResponsiveContentPadding": true }; /* * LIFECYCLE METHODS */ SemanticPage.prototype.init = function () { this._bSPBeingDestroyed = false; this._initDynamicPage(); this._attachShareMenuButtonChange(); this._fnActionSubstituteParentFunction = function () { return this; }.bind(this); }; SemanticPage.prototype.exit = function () { this._bSPBeingDestroyed = true; this._cleanMemory(); }; /* * ================================================= * PROPERTY PROXY METHODS * ================================================= */ SemanticPage.prototype.setHeaderExpanded = function (bHeaderExpanded) { this._getPage().setHeaderExpanded(bHeaderExpanded); return this; }; SemanticPage.prototype.getHeaderExpanded = function () { // We must override the getter, // because DynamicPage mutates the headerExpanded internally. return this._getPage().getHeaderExpanded(); }; SemanticPage.prototype.setHeaderPinnable = function (bHeaderPinnable) { var oDynamicPage = this._getPage(), oDynamicPageHeader = oDynamicPage.getHeader(); oDynamicPageHeader.setPinnable(bHeaderPinnable); return this.setProperty("headerPinnable", oDynamicPageHeader.getPinnable(), true); }; SemanticPage.prototype.setPreserveHeaderStateOnScroll = function (bPreserveHeaderStateOnScroll) { var oDynamicPage = this._getPage(); oDynamicPage.setPreserveHeaderStateOnScroll(bPreserveHeaderStateOnScroll); return this.setProperty("preserveHeaderStateOnScroll", oDynamicPage.getPreserveHeaderStateOnScroll(), true); }; SemanticPage.prototype.setToggleHeaderOnTitleClick = function (bToggleHeaderOnTitleClick) { this._getPage().setToggleHeaderOnTitleClick(bToggleHeaderOnTitleClick); return this.setProperty("toggleHeaderOnTitleClick", bToggleHeaderOnTitleClick, true); }; SemanticPage.prototype.setShowFooter = function (bShowFooter) { this._getPage().setShowFooter(bShowFooter); return this.setProperty("showFooter", bShowFooter, true); }; SemanticPage.prototype.setTitlePrimaryArea = function (oPrimaryArea) { var oDynamicPageTitle = this._getTitle(); oDynamicPageTitle.setPrimaryArea(oPrimaryArea); return this.setProperty("titlePrimaryArea", oDynamicPageTitle.getPrimaryArea(), true); }; SemanticPage.prototype.setTitleAreaShrinkRatio = function (sAreaShrinkRatio) { var oDynamicPageTitle = this._getTitle(); oDynamicPageTitle.setAreaShrinkRatio(sAreaShrinkRatio); return this.setProperty("titleAreaShrinkRatio", oDynamicPageTitle.getAreaShrinkRatio(), true); }; SemanticPage.prototype.addStyleClass = function (sClass, bSuppressRerendering) { var oDynamicPage = this.getAggregation("_dynamicPage"); if (SemanticPage.CONTENT_PADDING_CLASSES_TO_FORWARD[sClass]) { oDynamicPage.addStyleClass(sClass, true); } return Control.prototype.addStyleClass.call(this, sClass, bSuppressRerendering); }; SemanticPage.prototype.removeStyleClass = function (sClass, bSuppressRerendering) { var oDynamicPage = this.getAggregation("_dynamicPage"); if (SemanticPage.CONTENT_PADDING_CLASSES_TO_FORWARD[sClass]) { oDynamicPage.removeStyleClass(sClass, true); } return Control.prototype.removeStyleClass.call(this, sClass, bSuppressRerendering); }; /* * ================================================= * AGGREGATION METHODS * ================================================= */ SemanticPage.prototype.setAggregation = function (sAggregationName, oObject, bSuppressInvalidate) { var oOldChild = this.mAggregations[sAggregationName], sType, sPlacement; if (oOldChild === oObject) { return this; } oObject = this.validateAggregation(sAggregationName, oObject, false); if (sAggregationName === SemanticPage._SAVE_AS_TILE_ACTION) { sType = SemanticPage._SAVE_AS_TILE_ACTION; } else { sType = this.getMetadata().getManagedAggregation(sAggregationName).type; } if (SemanticConfiguration.isKnownSemanticType(sType)) { sPlacement = SemanticConfiguration.getPlacement(sType); if (oOldChild) { this._onRemoveAggregation(oOldChild, sType); this._getSemanticContainer(sPlacement).removeContent(oOldChild, sPlacement); } if (oObject) { oObject._getType = function() { return sType; }; this._getSemanticContainer(sPlacement).addContent(oObject, sPlacement); this._onAddAggregation(oObject, sType); } return ManagedObject.prototype.setAggregation.call(this, sAggregationName, oObject, true); } return ManagedObject.prototype.setAggregation.call(this, sAggregationName, oObject, bSuppressInvalidate); }; SemanticPage.prototype.destroyAggregation = function (sAggregationName, bSuppressInvalidate) { var oAggregationInfo = this.getMetadata().getAggregations()[sAggregationName], oObject, sPlacement, sType; if (sAggregationName === SemanticPage._SAVE_AS_TILE_ACTION) { sType = SemanticPage._SAVE_AS_TILE_ACTION; } else { sType = oAggregationInfo && oAggregationInfo.type; } if (sType && SemanticConfiguration.isKnownSemanticType(sType)) { oObject = ManagedObject.prototype.getAggregation.call(this, sAggregationName); if (oObject) { sPlacement = SemanticConfiguration.getPlacement(sType); this._onRemoveAggregation(oObject, sType); !this._bSPBeingDestroyed && this._getSemanticContainer(sPlacement).removeContent(oObject, sPlacement); } } return ManagedObject.prototype.destroyAggregation.call(this, sAggregationName, bSuppressInvalidate); }; /** * Proxies the sap.f.semantic.SemanticPage content * aggregation methods to the sap.f.DynamicPage content aggregation. * * @override */ ["getContent", "setContent", "destroyContent"] .forEach(function (sMethod) { SemanticPage.prototype[sMethod] = function (oControl) { var oDynamicPage = this._getPage(); return oDynamicPage[sMethod].apply(oDynamicPage, arguments); }; }, this); /** * Proxies the sap.f.semantic.SemanticPage titleCustomTextActions * aggregation methods to the internal sap.f.DynamicPageTitle, * using the sap.f.semantic.SemanticTitle wrapper class. * * @override */ [ "addTitleCustomTextAction", "insertTitleCustomTextAction", "indexOfTitleCustomTextAction", "removeTitleCustomTextAction", "removeAllTitleCustomTextActions", "destroyTitleCustomTextActions", "getTitleCustomTextActions" ].forEach(function (sMethod) { SemanticPage.prototype[sMethod] = function () { var oSemanticTitle = this._getSemanticTitle(), sSemanticTitleMethod = sMethod.replace(/TitleCustomTextAction?/, "CustomTextAction"); return oSemanticTitle[sSemanticTitleMethod].apply(oSemanticTitle, arguments); }; }, this); /** * Proxies the sap.f.semantic.SemanticPage titleCustomIconActions * aggregation methods to the internal sap.f.DynamicPageTitle, * using the sap.f.semantic.SemanticTitle wrapper class. * * @override */ [ "addTitleCustomIconAction", "insertTitleCustomIconAction", "indexOfTitleCustomIconAction", "removeTitleCustomIconAction", "removeAllTitleCustomIconActions", "destroyTitleCustomIconActions", "getTitleCustomIconActions" ].forEach(function (sMethod) { SemanticPage.prototype[sMethod] = function () { var oSemanticTitle = this._getSemanticTitle(), sSemanticTitleMethod = sMethod.replace(/TitleCustomIconAction?/, "CustomIconAction"); return oSemanticTitle[sSemanticTitleMethod].apply(oSemanticTitle, arguments); }; }, this); /** * Proxies thesap.f.semantic.SemanticPage footerCustomActions aggregation methods * to OverflowToolbar, using the sap.f.semantic.SemanticFooter wrapper class. * * @override */ [ "addFooterCustomAction", "insertFooterCustomAction", "indexOfFooterCustomAction", "removeFooterCustomAction", "removeAllFooterCustomActions", "destroyFooterCustomActions", "getFooterCustomActions" ].forEach(function (sMethod) { SemanticPage.prototype[sMethod] = function () { var oSemanticFooter = this._getSemanticFooter(), sSemanticFooterMethod = sMethod.replace(/FooterCustomAction?/, "CustomAction"); return oSemanticFooter[sSemanticFooterMethod].apply(oSemanticFooter, arguments); }; }, this); /** * Proxies the sap.f.semantic.SemanticPage customShareActions aggregation methods. * * @override */ [ "addCustomShareAction", "insertCustomShareAction", "indexOfCustomShareAction", "removeCustomShareAction", "removeAllCustomShareActions", "destroyCustomShareActions", "getCustomShareActions" ].forEach(function (sMethod) { SemanticPage.prototype[sMethod] = function () { var oSemanticShareMenu = this._getShareMenu(), sSemanticShareMenuMethod = sMethod.replace(/CustomShareAction?/, "CustomAction"); return oSemanticShareMenu[sSemanticShareMenuMethod].apply(oSemanticShareMenu, arguments); }; }, this); /** * Process the given control, * before setting it to one of the sap.f.semantic.SemanticPage aggregations. * @param {sap.ui.core.Control} oControl * @param {String} sType * @private */ SemanticPage.prototype._onAddAggregation = function (oControl, sType) { if (sType === SemanticPage._SAVE_AS_TILE_ACTION) { this._replaceParent(oControl); } }; /** * Process the given control, * after removing it from one of the sap.f.semantic.SemanticPage aggregations. * @param {sap.ui.core.Control} oControl * @param {String} sType * @private */ SemanticPage.prototype._onRemoveAggregation = function (oControl, sType) { if (sType === SemanticPage._SAVE_AS_TILE_ACTION) { this._restoreParent(oControl); } if (oControl._getType) { delete oControl._getType; } }; /** * Replaces the getParent function of the given control, * so the control would return the SemanticPage as its parent, rather than its real parent. * @param {sap.ui.core.Control} oControl * @private */ SemanticPage.prototype._replaceParent = function (oControl) { if (oControl._fnOriginalGetParent) { return; } oControl._fnOriginalGetParent = oControl.getParent; oControl.getParent = this._fnActionSubstituteParentFunction; }; /** * Restores the original getParent function of the given control. * @param oControl * @private */ SemanticPage.prototype._restoreParent = function (oControl) { if (oControl && oControl._fnOriginalGetParent) { oControl.getParent = oControl._fnOriginalGetParent; } }; /* * Attaches a handler to the ShareMenu base button change. * When the ShareMenu base button changes, * the old base button should be replaced by the new one. * * @private */ SemanticPage.prototype._attachShareMenuButtonChange = function () { this.attachEvent(SemanticPage._EVENTS.SHARE_MENU_CONTENT_CHANGED, this._onShareMenuContentChanged, this); }; /* * Handles the SHARE_MENU_CONTENT_CHANGED event. * * @private */ SemanticPage.prototype._onShareMenuContentChanged = function (oEvent) { var bShareMenuEmpty = oEvent.getParameter("bEmpty"), oSemanticTitle = this._getSemanticTitle(), oSemanticShareMenu = this._getShareMenu(), oShareMenuButton = oSemanticShareMenu._getShareMenuButton(); if (!oShareMenuButton.getParent()) { oSemanticTitle.addContent(oShareMenuButton, "shareIcon"); return; } oShareMenuButton.setVisible(!bShareMenuEmpty); }; /* * ================================================= * CREATION METHODS of: * sap.f.DynamicPage, * sap.f.DynamicPageTitle, * sap.f.DynamicPageHeader, * sap.f.semantic.SemanticTitle, * sap.f.semantic.SemanticFooter and * sap.f.semantic.SemanticShareMenu. * ================================================= */ /** * Retrieves the internal DynamicPage aggregation. * * @returns {sap.f.DynamicPage} * @private */ SemanticPage.prototype._getPage = function () { if (!this.getAggregation("_dynamicPage")) { this._initDynamicPage(); } return this.getAggregation("_dynamicPage"); }; /** * Initializes the internal sap.f.DynamicPage aggregation. * @private */ SemanticPage.prototype._initDynamicPage = function () { this.setAggregation("_dynamicPage", new DynamicPage(this.getId() + "-page", { title : this._getTitle(), header : this._getHeader(), footer: this._getFooter() }), true); }; /** * Retrieves a sap.f.DynamicPageTitle instance, * used for the title aggregation of the . * * @returns {sap.f.DynamicPageTitle} * @private */ SemanticPage.prototype._getTitle = function () { if (!this._oDynamicPageTitle) { this._oDynamicPageTitle = this._getSemanticTitle()._getContainer(); } return this._oDynamicPageTitle; }; /** * Retrieves a sap.f.DynamicPageHeader instance, * used for the header aggregation of the . * * @returns {sap.f.DynamicPageHeader} * @private */ SemanticPage.prototype._getHeader = function () { if (!this._oDynamicPageHeader) { this._oDynamicPageHeader = new DynamicPageHeader(this.getId() + "-pageHeader"); } return this._oDynamicPageHeader; }; /** * Retrieves a sap.m.OverflowToolbar instance, * used for the footer aggregation of the . * * @returns {sap.m.OverflowToolbar} * @private */ SemanticPage.prototype._getFooter = function () { if (!this._oDynamicPageFooter) { this._oDynamicPageFooter = this._getSemanticFooter()._getContainer(); } return this._oDynamicPageFooter; }; /** * Retrieves a sap.f.SemanticTitle instance. * * @returns {sap.f.SemanticTitle} * @private */ SemanticPage.prototype._getSemanticTitle = function() { if (!this._oSemanticTitle) { this._oSemanticTitle = new SemanticTitle(new DynamicPageTitle(this.getId() + "-pageTitle"), this); } return this._oSemanticTitle; }; /** * Retrieves a sap.f.SemanticShareMenu instance. * * @returns {sap.f.SemanticShareMenu} * @private */ SemanticPage.prototype._getShareMenu = function() { if (!this._oShareMenu) { this._oShareMenu = new SemanticShareMenu(this._getActionSheet(), this); // Ensure bindings on top level control propagate properly this.addDependent(this._oShareMenu._oContainer); } return this._oShareMenu; }; /** * Retrieves a sap.m.ActionSheet instance. * * @returns {sap.m.ActionSheet} * @private */ SemanticPage.prototype._getActionSheet = function() { if (!this._oActionSheet) { this._oActionSheet = new ActionSheet(this.getId() + "-shareMenu"); } return this._oActionSheet; }; /** * Retrieves a sap.f.SemanticFooter instance. * * @returns {sap.f.SemanticFooter} * @private */ SemanticPage.prototype._getSemanticFooter = function() { if (!this._oSemanticFooter) { this._oSemanticFooter = new SemanticFooter(this._getOverflowToolbar(), this); } return this._oSemanticFooter; }; /** * Retrieves a sap.m.OverflowToolbar instance, * used for footer aggregation of the sap.f.DynamicPage. * * @returns {sap.m.OverflowToolbar} * @private */ SemanticPage.prototype._getOverflowToolbar = function() { if (!this._oOverflowToolbar) { this._oOverflowToolbar = new OverflowToolbar(this.getId() + "-pageFooter"); } return this._oOverflowToolbar; }; /** * Retrieves a sap.f.semantic.SemanticContainer instance * for the given placement - TITLE_TEXT, TITLE_ICON, FOOTER_LEFT, FOOTER_RIGHT or SHARE_MENU. * * @param {String} sPlacement * @returns {sap.f.semantic.SemanticContainer | null} * @private */ SemanticPage.prototype._getSemanticContainer = function(sPlacement) { var oPlacement = SemanticConfiguration._Placement; if (sPlacement === oPlacement.titleText || sPlacement === oPlacement.titleIcon) { return this._getSemanticTitle(); } else if (sPlacement === oPlacement.footerLeft || sPlacement === oPlacement.footerRight) { return this._getSemanticFooter(); } else if (sPlacement === oPlacement.shareMenu) { return this._getShareMenu(); } return null; }; /** * Cleans references of the used objects and destroys them. * * @private */ SemanticPage.prototype._cleanMemory = function() { if (this._oShareMenu) { this._oShareMenu.destroy(); this._oShareMenu = null; } if (this._oActionSheet) { this._oActionSheet.destroy(); this._oActionSheet = null; } if (this._oSemanticTitle) { this._oSemanticTitle.destroy(); this._oSemanticTitle = null; } if (this._oDynamicPageTitle) { this._oDynamicPageTitle.destroy(); this._oDynamicPageTitle = null; } if (this._oDynamicPageHeader) { this._oDynamicPageHeader.destroy(); this._oDynamicPageHeader = null; } if (this._oSemanticFooter) { this._oSemanticFooter.destroy(); this._oSemanticFooter = null; } if (this._oDynamicPageFooter) { this._oDynamicPageFooter.destroy(); this._oDynamicPageFooter = null; } if (this._oOverflowToolbar) { this._oOverflowToolbar.destroy(); this._oOverflowToolbar = null; } }; return SemanticPage; });