UNPKG

openui5-tour

Version:

An OpenUI5 library to give a guided tour through your UI5 webapp.

7 lines 3.26 kB
"use strict"; /* * openui5-tour * (c) Copyright 2017-2023 Mauricio Lauffer * Licensed under the MIT license. See LICENSE file in the project root for full license information. */sap.ui.define(["sap/m/Button","sap/m/ResponsivePopover","sap/ui/core/Control","sap/m/library"],function(t,e,o,i){const n=o.extend("openui5.tour.TourStep",{metadata:{library:"openui5.tour",properties:{title:{type:"string",group:"Appearance",defaultValue:""},icon:{type:"sap.ui.core.URI",group:"Appearance",defaultValue:""},target:{type:"object",group:"Behavior",defaultValue:""},placement:{type:"sap.m.PlacementType",group:"Behavior",defaultValue:i.PlacementType.PreferredTopOrFlip}},defaultAggregation:"content",aggregations:{content:{type:"sap.ui.core.Control",multiple:false},_popup:{type:"sap.ui.core.Control",multiple:false,visibility:"hidden"}}}});n.prototype.init=function(){this.setIsFirstStep(false);this.setIsLastStep(false)};n.prototype.exit=function(){};n.prototype.open=function(){if(!this.getTarget()){throw new Error("The step you are trying to open has no target assigned.")}if(!this.getAggregation("_popup")){this.setAggregation("_popup",this._getPopup())}this.getTarget().getDomRef().scrollIntoView();this.getAggregation("_popup").openBy(this.getTarget())};n.prototype.close=function(){if(this.getAggregation("_popup")&&this.getAggregation("_popup").isOpen()){this.getAggregation("_popup").close()}};n.prototype.setIsFirstStep=function(t){this._isFirstStep=t};n.prototype.setIsLastStep=function(t){this._isLastStep=t};n.prototype._setFirstStep=function(t){t.getBeginButton().setEnabled(false)};n.prototype._setLastStep=function(t){this._setFinishButton(t)};n.prototype._getPopup=function(){if(this.getContent()){this.getContent().addStyleClass("sapUiSmallMargin")}const t=this._createPopup(this.getId(),this.getPlacement(),this.getTitle(),this.getIcon(),this.getContent());this._setPreviousButton(t);if(this._isFirstStep){this._setFirstStep(t)}if(this._isLastStep){this._setLastStep(t)}else{this._setNextButton(t)}return t};n.prototype._setFinishButton=function(t){const e=this._createFinishButton(t.getId(),this._finishStep.bind(this));t.setEndButton(e);e.setType(i.ButtonType.Emphasized)};n.prototype._setNextButton=function(t){const e=this._createNextButton(t.getId(),this._nextStep.bind(this));t.setEndButton(e);e.setType(i.ButtonType.Emphasized)};n.prototype._setPreviousButton=function(t){const e=this._createPreviousButton(t.getId(),this._previousStep.bind(this));t.setBeginButton(e)};n.prototype._createPopup=function(t,o,i,n,p){return new e(t+"-popover",{modal:true,placement:o,title:i,icon:n,content:p})};n.prototype._createFinishButton=function(e,o){return new t(e+"-finishButton",{icon:"sap-icon://accept",text:"Done",press:o})};n.prototype._createNextButton=function(e,o){return new t(e+"-nextButton",{icon:"sap-icon://open-command-field",text:"Next",press:o})};n.prototype._createPreviousButton=function(e,o){return new t(e+"-previousButton",{icon:"sap-icon://close-command-field",text:"Back",press:o})};n.prototype._nextStep=function(){this.getParent().nextStep()};n.prototype._previousStep=function(){this.getParent().previousStep()};n.prototype._finishStep=function(){this.getParent().complete()};return n}); //# sourceMappingURL=TourStep.js.map