/*! * 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(['./library','sap/ui/core/Control','sap/ui/core/library','sap/m/Text','./ObjectAttributeRenderer',"sap/base/Log"],function(l,C,c,T,O,L){"use strict";var a=c.TextDirection;var b=C.extend("sap.m.ObjectAttribute",{metadata:{library:"sap.m",designtime:"sap/m/designtime/ObjectAttribute.designtime",properties:{title:{type:"string",group:"Misc",defaultValue:null},text:{type:"string",group:"Misc",defaultValue:null},active:{type:"boolean",group:"Misc",defaultValue:null},textDirection:{type:"sap.ui.core.TextDirection",group:"Appearance",defaultValue:a.Inherit}},aggregations:{customContent:{type:"sap.ui.core.Control",multiple:false},_textControl:{type:"sap.ui.core.Control",multiple:false,visibility:"hidden"}},events:{press:{parameters:{domRef:{type:"string"}}}}}});b.prototype.init=function(){this.setAggregation('_textControl',new T());};b.prototype._getUpdatedTextControl=function(){var A=this.getAggregation('customContent')||this.getAggregation('_textControl'),t=this.getTitle(),s=this.getAggregation('customContent')?this.getAggregation('customContent').getText():this.getText(),d=this.getTextDirection(),p=this.getParent(),P=sap.ui.getCore().getConfiguration().getRTL(),m=O.MAX_LINES.MULTI_LINE,w=true,o='';if(d===a.LTR&&P){o='\u200e';}if(d===a.RTL&&!P){o='\u200f';}s=o+s+o;if(t){s=t+": "+s;}A.setProperty('text',s,true);if(p instanceof sap.m.ObjectListItem){w=false;m=O.MAX_LINES.SINGLE_LINE;}this._setControlWrapping(A,w,m);return A;};b.prototype._setControlWrapping=function(A,w,m){if(A.isA("sap.m.Link")){A.setProperty('wrapping',w,true);}if(A.isA("sap.m.Text")){A.setProperty('maxLines',m,true);}};b.prototype.ontap=function(e){if(this._isSimulatedLink()&&(e.target.id===this.getId()+"-text")){this.firePress({domRef:this.getDomRef()});}};b.prototype.onsapenter=function(e){if(this._isSimulatedLink()){this.firePress({domRef:this.getDomRef()});e.setMarked();}};b.prototype.onsapspace=function(e){this.onsapenter(e);};b.prototype._isEmpty=function(){if(this.getAggregation('customContent')&&!(this.getAggregation('customContent').isA("sap.m.Link")||this.getAggregation('customContent').isA("sap.m.Text"))){L.warning("Only sap.m.Link or sap.m.Text are allowed in \"sap.m.ObjectAttribute.customContent\" aggregation");return true;}return!(this.getText().trim()||this.getTitle().trim());};b.prototype.ontouchstart=function(e){if(this._isSimulatedLink()){e.originalEvent._sapui_handledByControl=true;}};b.prototype.getPopupAnchorDomRef=function(){return this.getDomRef("text");};b.prototype._isSimulatedLink=function(){return(this.getActive()&&this.getText()!=="")&&!this.getAggregation('customContent');};b.prototype.setCustomContent=function(o){if(o&&o.isA('sap.m.Link')){o._getTabindex=function(){return"-1";};}return this.setAggregation('customContent',o);};b.prototype._isClickable=function(){return(this.getActive()&&this.getText()!=="")||(this.getAggregation('customContent')&&this.getAggregation('customContent').isA('sap.m.Link'));};return b;});