_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q19000
preloadLibrarySync
train
function preloadLibrarySync(libConfig) { libConfig = evalLibConfig(libConfig); var lib = libConfig.name, fileType = libConfig.fileType, libPackage = lib.replace(/\./g, '/'), libLoaded = !!sap.ui.loader._.getModuleState(libPackage + '/library.js'); if ( fileType === 'none' || libLoaded ) { return; } var libInfo = mLibraryPreloadBundles[lib] || (mLibraryPreloadBundles[lib] = { }); // already preloaded? if ( libInfo.pending === false ) { return; } // currently loading if ( libInfo.pending ) { if ( libInfo.async ) { Log.warning("request to load " + lib + " synchronously while async loading is pending; this causes a duplicate request and should be avoided by caller"); // fall through and preload synchronously } else { // sync cycle -> ignore nested call (would nevertheless be a dependency cycle) Log.warning("request to load " + lib + " synchronously while sync loading is pending (cycle, ignored)"); return; } } libInfo.pending = true; libInfo.async = false; var resolve; libInfo.promise = new Promise(function(_resolve, _reject) { resolve = _resolve; }); var dependencies; if ( fileType !== 'json' /* 'js' or 'both', not forced to JSON */ ) { var sPreloadModule = libPackage + '/library-preload'; try { sap.ui.requireSync(sPreloadModule); dependencies = dependenciesFromManifest(lib); } catch (e) { Log.error("failed to load '" + sPreloadModule + "' (" + (e && e.message || e) + ")"); if ( e && e.loadError && fileType !== 'js' ) { dependencies = loadJSONSync(lib); } // ignore other errors (preload shouldn't fail) } } else { dependencies = loadJSONSync(lib); } if ( dependencies && dependencies.length ) { dependencies.forEach(preloadLibrarySync); } libInfo.pending = false; resolve(); }
javascript
{ "resource": "" }
q19001
getModulePath
train
function getModulePath(sModuleName, sSuffix){ return sap.ui.require.toUrl(sModuleName.replace(/\./g, "/") + sSuffix); }
javascript
{ "resource": "" }
q19002
train
function(bAsKeyUser) { var oDescriptor = fnGetDescriptor(); return new Promise(function(resolve) { var fnCancel = function() { AppVariantUtils.closeOverviewDialog(); }; sap.ui.require(["sap/ui/rta/appVariant/AppVariantOverviewDialog"], function(AppVariantOverviewDialog) { if (!oAppVariantOverviewDialog) { oAppVariantOverviewDialog = new AppVariantOverviewDialog({ idRunningApp: oDescriptor["sap.app"].id, isOverviewForKeyUser: bAsKeyUser }); } oAppVariantOverviewDialog.attachCancel(fnCancel); oAppVariantOverviewDialog.oPopup.attachOpened(function() { resolve(oAppVariantOverviewDialog); }); oAppVariantOverviewDialog.open(); }); }); }
javascript
{ "resource": "" }
q19003
processArray
train
function processArray(aPromises) { return aPromises.reduce(function(pacc, fn) { return pacc.then(fn); }, Promise.resolve()) .catch(function() { return Promise.resolve(false); }); }
javascript
{ "resource": "" }
q19004
_stringify
train
function _stringify(vObject) { var sData = "", sProp; var type = typeof vObject; if (vObject == null || (type != "object" && type != "function")) { sData = vObject; } else if (isPlainObject(vObject)) { sData = JSON.stringify(vObject); } else if (vObject instanceof ManagedObject) { sData = vObject.getId();//add the id for (sProp in vObject.mProperties) { sData = sData + "$" + _stringify(vObject.mProperties[sProp]); } } else if (Array.isArray(vObject)) { for (var i = 0; vObject.length; i++) { sData = sData + "$" + _stringify(vObject); } } else { Log.warning("Could not stringify object " + vObject); sData = "$"; } return sData; }
javascript
{ "resource": "" }
q19005
train
function(oContext) { // use the id of the ManagedObject instance as the identifier // for the extended change detection var oObject = oContext.getObject(); if (oObject instanceof ManagedObject) { return oObject.getId(); } return JSONListBinding.prototype.getEntryKey.apply(this, arguments); }
javascript
{ "resource": "" }
q19006
train
function(iStartIndex, iLength) { var iSizeLimit; if (this._oAggregation) { var oInnerListBinding = this._oOriginMO.getBinding(this._sMember); //check if the binding is a list binding if (oInnerListBinding) { var oModel = oInnerListBinding.getModel(); iSizeLimit = oModel.iSizeLimit; } var oBindingInfo = this._oOriginMO.getBindingInfo(this._sMember); //sanity check for paging exceeds model size limit if (oBindingInfo && iStartIndex >= 0 && iLength && iSizeLimit && iLength > iSizeLimit) { var bUpdate = false; if (iStartIndex != oBindingInfo.startIndex) { oBindingInfo.startIndex = iStartIndex; bUpdate = true; } if (iLength != oBindingInfo.length) { oBindingInfo.length = iLength; bUpdate = true; } if (bUpdate) { this._oAggregation.update(this._oOriginMO, "change"); } } } return JSONListBinding.prototype._getContexts.apply(this, arguments); }
javascript
{ "resource": "" }
q19007
train
function (oContext) { if (oContext) { oControl = oContext; oControl.addDelegate(this._controlDelegate, false, this); } this.oRb = Core.getLibraryResourceBundle("sap.f"); }
javascript
{ "resource": "" }
q19008
train
function (aRequests) { var oBatchRequest = _serializeBatchRequest(aRequests); return { body : oBatchRequest.body.join(""), headers : { "Content-Type" : "multipart/mixed; boundary=" + oBatchRequest.batchBoundary, "MIME-Version" : "1.0" } }; }
javascript
{ "resource": "" }
q19009
train
function(aEnum, oEnumComparison) { if (aEnum && Array.isArray(aEnum) && aEnum.length) { for (var i = 0; i < aEnum.length; i++) { if (oEnumComparison.hasOwnProperty(aEnum[i])) { continue; } else { return false; } } return true; } return false; }
javascript
{ "resource": "" }
q19010
train
function(sId) { //Match camelCase - case sensitive var idRegEx = /^[a-z][a-zA-Z]+$/; if ( !sId || typeof sId !== 'string') { return false; } if (sId.match(idRegEx) && this.validateStringLength(sId, 6, 50)) { return true; } return false; }
javascript
{ "resource": "" }
q19011
cell
train
function cell(oContent) { return new MatrixLayoutCell({ padding: Padding.None, vAlign: VAlign.Top, content: oContent }); }
javascript
{ "resource": "" }
q19012
image
train
function image(oIcon) { var oImage = new Image({ id: sDialogId + "--icon", tooltip: rb && rb.getText("MSGBOX_ICON_" + oIcon), decorative: true }); oImage.addStyleClass("sapUiMboxIcon"); oImage.addStyleClass(mIconClass[oIcon]); return oImage; }
javascript
{ "resource": "" }
q19013
train
function(sEmail, sSubject, sBody, sCC, sBCC) { var aParams = [], sURL = "mailto:", encode = encodeURIComponent; // Within mailto URLs, the characters "?", "=", "&" are reserved isValidString(sEmail) && (sURL += encode(jQuery.trim(sEmail))); isValidString(sSubject) && aParams.push("subject=" + encode(sSubject)); isValidString(sBody) && aParams.push("body=" + formatMessage(sBody)); isValidString(sBCC) && aParams.push("bcc=" + encode(jQuery.trim(sBCC))); isValidString(sCC) && aParams.push("cc=" + encode(jQuery.trim(sCC))); if (aParams.length) { sURL += "?" + aParams.join("&"); } return sURL; }
javascript
{ "resource": "" }
q19014
train
function (sURL, bNewWindow) { assert(isValidString(sURL), this + "#redirect: URL must be a string" ); this.fireEvent("redirect", sURL); if (!bNewWindow) { window.location.href = sURL; } else { var oWindow = window.open(sURL, "_blank"); if (!oWindow) { Log.error(this + "#redirect: Could not open " + sURL); if (Device.os.windows_phone || (Device.browser.edge && Device.browser.mobile)) { Log.warning("URL will be enforced to open in the same window as a fallback from a known Windows Phone system restriction. Check the documentation for more information."); window.location.href = sURL; } } } }
javascript
{ "resource": "" }
q19015
checkAndSetProperty
train
function checkAndSetProperty(oControl, property, value) { if (value !== undefined) { var fSetter = oControl['set' + capitalize(property)]; if (typeof (fSetter) === "function") { fSetter.call(oControl, value); return true; } } return false; }
javascript
{ "resource": "" }
q19016
train
function(sPercentage, fBaseSize){ if (typeof sPercentage !== "string") { Log.warning("sap.m.PopupHelper: calcPercentageSize, the first parameter" + sPercentage + "isn't with type string"); return null; } if (sPercentage.indexOf("%") <= 0) { Log.warning("sap.m.PopupHelper: calcPercentageSize, the first parameter" + sPercentage + "is not a percentage string (for example '25%')"); return null; } var fPercent = parseFloat(sPercentage) / 100, fParsedBaseSize = parseFloat(fBaseSize); return Math.floor(fPercent * fParsedBaseSize) + "px"; }
javascript
{ "resource": "" }
q19017
isGridSupportedByBrowser
train
function isGridSupportedByBrowser() { return !Device.browser.msie && !(Device.browser.edge && Device.browser.version < EDGE_VERSION_WITH_GRID_SUPPORT); }
javascript
{ "resource": "" }
q19018
train
function (oEvent) { if (this._oView) { this._oView.destroy(); // If we had a view that means this is a navigation so we need to init the busy state this._oContainerPage.setBusy(true); } var oComponent = this.getOwnerComponent(); this._sTopicid = decodeURIComponent(oEvent.getParameter("arguments").id); this._sEntityType = oEvent.getParameter("arguments").entityType; this._sEntityId = decodeURIComponent(oEvent.getParameter("arguments").entityId); // API Reference lifecycle oComponent.loadVersionInfo() .then(function () { // Cache allowed members this._aAllowedMembers = this.getModel("versionData").getProperty("/allowedMembers"); }.bind(this)) .then(APIInfo.getIndexJsonPromise) .then(this._processApiIndexAndLoadApiJson.bind(this)) .then(this._findEntityInApiJsonData.bind(this)) .then(this._buildBorrowedModel.bind(this)) .then(this._createModelAndSubView.bind(this)) .then(this._initSubView.bind(this)) .catch(function (vReason) { // If the symbol does not exist in the available libs we redirect to the not found page if (vReason === this.NOT_FOUND) { this._oContainerPage.setBusy(false); this.getRouter().myNavToWithoutHash("sap.ui.documentation.sdk.view.NotFound", "XML", false); } else if (typeof vReason === "string") { Log.error(vReason); } else if (vReason.name) { Log.error(vReason.name, vReason.message); } else if (vReason.message) { Log.error(vReason.message); } }.bind(this)); }
javascript
{ "resource": "" }
q19019
train
function (oView) { var oController = oView.getController(); // Add the sub view to the current one this._oContainerPage.addContent(oView); this._oContainerPage.setBusy(false); // Init the sub view and controller with the needed references.The view's are nested and work in a // mimic way so they need to share some references. oController.initiate({ sTopicId: this._sTopicid, oModel: this._oModel, aApiIndex: this._aApiIndex, aAllowedMembers: this._aAllowedMembers, oEntityData: this._oEntityData, sEntityType: this._sEntityType, sEntityId: this._sEntityId, oOwnerComponent: this.getOwnerComponent(), oContainerView: this.getView(), oContainerController: this }); }
javascript
{ "resource": "" }
q19020
train
function (oBorrowedData) { // Attach resolved borrowed data this._oControlData.borrowed = oBorrowedData; // Pre-process data and create model this._bindData(this._sTopicid); // Create the sub-view and controller this._oView = sap.ui.view({ height: "100%", viewName: "sap.ui.documentation.sdk.view.SubApiDetail", type: ViewType.XML, async: true, preprocessors: { xml: { models: { data: this._oModel } } } }); // Return view loaded promise return this._oView.loaded(); }
javascript
{ "resource": "" }
q19021
train
function (aLibsData) { var oLibItem, iLen, i; // Find entity in loaded libs data for (i = 0, iLen = aLibsData.length; i < iLen; i++) { oLibItem = aLibsData[i]; if (oLibItem.name === this._sTopicid) { // Check if we are allowed to display the requested symbol // BCP: 1870269087 item may not have visibility info at all. In this case we show the item if (oLibItem.visibility === undefined || this._aAllowedMembers.indexOf(oLibItem.visibility) >= 0) { return oLibItem; } else { // We found the requested symbol but we are not allowed to show it. return Promise.reject(this.NOT_FOUND); } } } // If we are here - the object does not exist so we reject the promise. return Promise.reject(this.NOT_FOUND); }
javascript
{ "resource": "" }
q19022
train
function (aData) { var oEntityData, oMasterController, sTopicId = this._sTopicid; // Cache api-index data this._aApiIndex = aData; // Find symbol function findSymbol (a) { return a.some(function (o) { var bFound = o.name === sTopicId; if (!bFound && o.nodes) { return findSymbol(o.nodes); } else if (bFound) { oEntityData = o; return true; } return false; }); } findSymbol(aData); if (oEntityData) { // Cache entity data this._oEntityData = oEntityData; // If target symbol is deprecated - all deprecated records should be shown in the tree if (oEntityData.deprecated) { oMasterController = this.getOwnerComponent().getConfigUtil().getMasterView("apiId").getController(); oMasterController.selectDeprecatedSymbol(this._sTopicid); } // Load API.json only for selected lib return APIInfo.getLibraryElementsJSONPromise(oEntityData.lib).then(function (aData) { return Promise.resolve(aData); // We have found the symbol and loaded the corresponding api.json }); } // If we are here - the object does not exist so we reject the promise. return Promise.reject(this.NOT_FOUND); }
javascript
{ "resource": "" }
q19023
train
function (aElements, fnFilter, fnFormat) { var i, iLength = aElements.length, aNewElements = [], oElement; for (i = 0; i < iLength; i++) { oElement = aElements[i]; if (fnFilter && !fnFilter(oElement)) { continue; } if (fnFormat) { fnFormat(oElement); } aNewElements.push(oElement); } return aNewElements; }
javascript
{ "resource": "" }
q19024
preloadModules
train
function preloadModules (oData) { // prealod the modules from the live-edited src sap.ui.require.preload(oData.src); // require the init module sap.ui.require([oData.moduleNameToRequire]); }
javascript
{ "resource": "" }
q19025
addOnErrorHook
train
function addOnErrorHook () { window.addEventListener("error", function(error) { error.preventDefault(); var oErrorOutput = document.createElement("span"); oErrorOutput.innerText = error.message; // use save API oErrorOutput.style.cssText = "position:absolute; top:1rem; left:1rem"; if (!document.body) { document.write("<span></span>"); // add content via document.write to ensure document.body is created; } document.body.appendChild(oErrorOutput); }); }
javascript
{ "resource": "" }
q19026
Version
train
function Version(vMajor, iMinor, iPatch, sSuffix) { if ( vMajor instanceof Version ) { // note: even a constructor may return a value different from 'this' return vMajor; } if ( !(this instanceof Version) ) { // act as a cast operator when called as function (not as a constructor) return new Version(vMajor, iMinor, iPatch, sSuffix); } var m; if (typeof vMajor === "string") { m = rVersion.exec(vMajor); } else if (Array.isArray(vMajor)) { m = vMajor; } else { m = arguments; } m = m || []; function norm(v) { v = parseInt(v); return isNaN(v) ? 0 : v; } vMajor = norm(m[0]); iMinor = norm(m[1]); iPatch = norm(m[2]); sSuffix = String(m[3] || ""); /** * Returns a string representation of this version. * * @return {string} a string representation of this version. * @public */ this.toString = function() { return vMajor + "." + iMinor + "." + iPatch + sSuffix; }; /** * Returns the major version part of this version. * * @return {int} the major version part of this version * @public */ this.getMajor = function() { return vMajor; }; /** * Returns the minor version part of this version. * * @return {int} the minor version part of this version * @public */ this.getMinor = function() { return iMinor; }; /** * Returns the patch (or micro) version part of this version. * * @return {int} the patch version part of this version * @public */ this.getPatch = function() { return iPatch; }; /** * Returns the version suffix of this version. * * @return {string} the version suffix of this version * @public */ this.getSuffix = function() { return sSuffix; }; /** * Compares this version with a given one. * * The version with which this version should be compared can be given as a <code>sap/base/util/Version</code> instance, * as a string (e.g. <code>v.compareto("1.4.5")</code>). Or major, minor, patch and suffix values can be given as * separate parameters (e.g. <code>v.compareTo(1, 4, 5)</code>) or in an array (e.g. <code>v.compareTo([1, 4, 5])</code>). * * @return {int} 0, if the given version is equal to this version, a negative value if the given other version is greater * and a positive value otherwise * @public */ this.compareTo = function() { var vOther = Version.apply(window, arguments); /*eslint-disable no-nested-ternary */ return vMajor - vOther.getMajor() || iMinor - vOther.getMinor() || iPatch - vOther.getPatch() || ((sSuffix < vOther.getSuffix()) ? -1 : (sSuffix === vOther.getSuffix()) ? 0 : 1); /*eslint-enable no-nested-ternary */ }; }
javascript
{ "resource": "" }
q19027
train
function(sLogType, aMessageComponents, aValuesToInsert, sCallStack) { var sLogMessage = aMessageComponents.join(' '); sLogMessage = formatMessage(sLogMessage, aValuesToInsert); this.log[sLogType](sLogMessage, sCallStack || ""); }
javascript
{ "resource": "" }
q19028
train
function (oControl) { var oModel; if (!oControl) { return ""; } // Get Model if (oControl && typeof oControl.getModel === "function") { oModel = oControl.getModel(); return Utils._getXSRFTokenFromModel(oModel); } return ""; }
javascript
{ "resource": "" }
q19029
train
function (oModel) { var mHeaders; if (!oModel) { return ""; } if (typeof oModel.getHeaders === "function") { mHeaders = oModel.getHeaders(); if (mHeaders) { return mHeaders["x-csrf-token"]; } } return ""; }
javascript
{ "resource": "" }
q19030
train
function (oControl) { var oAppComponent; // determine UI5 component out of given control if (oControl) { // always return the app component oAppComponent = this.getAppComponentForControl(oControl); // check if the component is an application variant and assigned an application descriptor then use this as reference if (oAppComponent) { var sVariantId = this._getComponentStartUpParameter(oAppComponent, "sap-app-id"); if (sVariantId) { return sVariantId; } if (oAppComponent.getManifestEntry("sap.ui5") && oAppComponent.getManifestEntry("sap.ui5").appVariantId) { return oAppComponent.getManifestEntry("sap.ui5").appVariantId; } } } return Utils.getComponentName(oAppComponent); }
javascript
{ "resource": "" }
q19031
train
function (oControl) { var oManifest = null, oComponent = null, oComponentMetaData = null; // determine UI5 component out of given control if (oControl) { oComponent = this.getAppComponentForControl(oControl); // determine manifest out of found component if (oComponent && oComponent.getMetadata) { oComponentMetaData = oComponent.getMetadata(); if (oComponentMetaData && oComponentMetaData.getManifest) { oManifest = oComponentMetaData.getManifest(); } } } return oManifest; }
javascript
{ "resource": "" }
q19032
train
function (oControl) { var sSiteId = null, oAppComponent = null; // determine UI5 component out of given control if (oControl) { oAppComponent = this.getAppComponentForControl(oControl); // determine siteId from ComponentData if (oAppComponent) { //Workaround for back-end check: isApplicationPermitted //As long as FLP does not know about appDescriptorId we have to pass siteID and applicationID. //With startUpParameter hcpApplicationId we will get a concatenation of “siteId:applicationId” //sSiteId = this._getComponentStartUpParameter(oComponent, "scopeId"); sSiteId = this._getComponentStartUpParameter(oAppComponent, "hcpApplicationId"); } } return sSiteId; }
javascript
{ "resource": "" }
q19033
train
function (sPropertyValue) { var bIsBinding = false; if (sPropertyValue && typeof sPropertyValue === "string" && sPropertyValue.substring(0, 1) === "{" && sPropertyValue.slice(-1) === "}") { bIsBinding = true; } return bIsBinding; }
javascript
{ "resource": "" }
q19034
train
function (oControl) { var sFlexReference = Utils.getComponentClassName(oControl); var oAppComponent = Utils.getAppComponentForControl(oControl); var sComponentName = Utils.getComponentName(oAppComponent); return sFlexReference !== sComponentName; }
javascript
{ "resource": "" }
q19035
train
function (oComponent, sParameterName) { var startUpParameterContent = null; if (sParameterName) { if (oComponent && oComponent.getComponentData) { startUpParameterContent = this._getStartUpParameter(oComponent.getComponentData(), sParameterName); } } return startUpParameterContent; }
javascript
{ "resource": "" }
q19036
train
function (oComponent) { var sComponentName = ""; if (oComponent) { sComponentName = oComponent.getMetadata().getName(); } if (sComponentName.length > 0 && sComponentName.indexOf(".Component") < 0) { sComponentName += ".Component"; } return sComponentName; }
javascript
{ "resource": "" }
q19037
train
function (oControl) { var sComponentId = Utils._getOwnerIdForControl(oControl); if (!sComponentId) { if (oControl && typeof oControl.getParent === "function") { var oParent = oControl.getParent(); if (oParent) { return Utils._getComponentIdForControl(oParent); } } } return sComponentId || ""; }
javascript
{ "resource": "" }
q19038
train
function (oControl) { var oComponent = null; var sComponentId = null; // determine UI5 component out of given control if (oControl) { sComponentId = Utils._getComponentIdForControl(oControl); if (sComponentId) { oComponent = Utils._getComponent(sComponentId); } } return oComponent; }
javascript
{ "resource": "" }
q19039
train
function (oComponent) { var oSapApp = null; // special case for Fiori Elements to reach the real appComponent if (oComponent && oComponent.getAppComponent) { return oComponent.getAppComponent(); } // special case for OVP if (oComponent && oComponent.oComponentData && oComponent.oComponentData.appComponent) { return oComponent.oComponentData.appComponent; } if (oComponent && oComponent.getManifestEntry) { oSapApp = oComponent.getManifestEntry("sap.app"); } else { // if no manifest entry return oComponent; } if (oSapApp && oSapApp.type && oSapApp.type !== "application") { if (oComponent instanceof Component) { // we need to call this method only when the component is an instance of Component in order to walk up the tree // returns owner app component oComponent = this._getComponentForControl(oComponent); } return this.getAppComponentForControl(oComponent); } return oComponent; }
javascript
{ "resource": "" }
q19040
train
function (bIsEndUser) { var oUriParams, sLayer; if (bIsEndUser) { return "USER"; } oUriParams = this._getUriParameters(); sLayer = oUriParams.get("sap-ui-layer") || ""; sLayer = sLayer.toUpperCase(); return sLayer || "CUSTOMER"; }
javascript
{ "resource": "" }
q19041
train
function (oControl) { var oMetadata; if (oControl && typeof oControl.getMetadata === "function") { oMetadata = oControl.getMetadata(); if (oMetadata && typeof oMetadata.getElementName === "function") { return oMetadata.getElementName(); } } }
javascript
{ "resource": "" }
q19042
train
function (ascii) { var asciiArray = ascii.split(","); var parsedString = ""; jQuery.each(asciiArray, function (index, asciiChar) { parsedString += String.fromCharCode(asciiChar); }); return parsedString; }
javascript
{ "resource": "" }
q19043
train
function (string) { var ascii = ""; for (var i = 0; i < string.length; i++) { ascii += string.charCodeAt(i) + ","; } // remove last "," ascii = ascii.substring(0, ascii.length - 1); return ascii; }
javascript
{ "resource": "" }
q19044
train
function(){ var oUshellContainer = Utils.getUshellContainer(); if (oUshellContainer) { var oURLParser = oUshellContainer.getService("URLParsing"); var oParsedHash = oURLParser.parseShellHash(hasher.getHash()); return oParsedHash ? oParsedHash : { }; } return { }; }
javascript
{ "resource": "" }
q19045
train
function (oComponent, sParameterName, aValues) { var oParsedHash = Utils.getParsedURLHash(sParameterName); if (oParsedHash.params) { hasher.changed.active = false; //disable changed signal var mTechnicalParameters = Utils.getTechnicalParametersForComponent(oComponent); // if mTechnicalParameters are not available we write a warning and continue updating the hash if (!mTechnicalParameters) { this.log.warning("Component instance not provided, so technical parameters in component data and browser history remain unchanged"); } if (aValues.length === 0) { delete oParsedHash.params[sParameterName]; mTechnicalParameters && delete mTechnicalParameters[sParameterName]; // Case when ControlVariantsAPI.clearVariantParameterInURL is called with a parameter } else { oParsedHash.params[sParameterName] = aValues; mTechnicalParameters && (mTechnicalParameters[sParameterName] = aValues); // Technical parameters need to be in sync with the URL hash } hasher.replaceHash(Utils.getUshellContainer().getService("URLParsing").constructShellHash(oParsedHash)); // Set hash without dispatching changed signal nor writing history hasher.changed.active = true; // Re-enable signal } }
javascript
{ "resource": "" }
q19046
train
function (mPropertyBag) { var sAppVersion = mPropertyBag.appVersion; var bDeveloperMode = mPropertyBag.developerMode; var sScenario = mPropertyBag.scenario; var oValidAppVersions = { creation: sAppVersion, from: sAppVersion }; if (this._isValidAppVersionToRequired(sAppVersion, bDeveloperMode, sScenario)) { oValidAppVersions.to = sAppVersion; } return oValidAppVersions; }
javascript
{ "resource": "" }
q19047
train
function (sAppVersion, bDeveloperMode, sScenario) { return !!sAppVersion && !!bDeveloperMode && sScenario !== sap.ui.fl.Scenario.AdaptationProject && sScenario !== sap.ui.fl.Scenario.AppVariant; }
javascript
{ "resource": "" }
q19048
train
function (oManifest) { var sUri = ""; if (oManifest){ var oSapApp = (oManifest.getEntry) ? oManifest.getEntry("sap.app") : oManifest["sap.app"]; if (oSapApp && oSapApp.dataSources && oSapApp.dataSources.mainService && oSapApp.dataSources.mainService.uri){ sUri = oSapApp.dataSources.mainService.uri; } } else { this.log.warning("No Manifest received."); } return sUri; }
javascript
{ "resource": "" }
q19049
train
function(aArray, oObject) { var iObjectIndex = -1; aArray.some(function(oArrayObject, iIndex) { var aKeysArray, aKeysObject; if (!oArrayObject) { aKeysArray = []; } else { aKeysArray = Object.keys(oArrayObject); } if (!oObject) { aKeysObject = []; } else { aKeysObject = Object.keys(oObject); } var bSameNumberOfAttributes = aKeysArray.length === aKeysObject.length; var bContains = bSameNumberOfAttributes && !aKeysArray.some(function(sKey) { return oArrayObject[sKey] !== oObject[sKey]; }); if (bContains) { iObjectIndex = iIndex; } return bContains; }); return iObjectIndex; }
javascript
{ "resource": "" }
q19050
train
function(mChanges, sChangeId) { var oResult; Object.keys(mChanges).forEach(function(sControlId) { mChanges[sControlId].some(function(oChange) { if (oChange.getId() === sChangeId) { oResult = oChange; return true; } }); }); return oResult; }
javascript
{ "resource": "" }
q19051
train
function(sModuleName) { //TODO: get rid of require async as soon as sap.ui.require has learned Promises as return value return new Promise(function(fnResolve, fnReject) { sap.ui.require([sModuleName], function(oModule) { fnResolve(oModule); }, function(oError) { fnReject(oError); }); }); }
javascript
{ "resource": "" }
q19052
train
function (mMap, sPath, oItem) { if (oItem) { if (!mMap[sPath]) { mMap[sPath] = [oItem]; } else if (mMap[sPath].indexOf(oItem) < 0) { mMap[sPath].push(oItem); } } }
javascript
{ "resource": "" }
q19053
train
function (aChildren, aAncestors, mChildren) { if (aAncestors.length) { aChildren.forEach(function (sPath) { var aSegments; if (aAncestors.indexOf(sPath) >= 0) { mChildren[sPath] = true; return; } aSegments = sPath.split("/"); aSegments.pop(); while (aSegments.length) { if (aAncestors.indexOf(aSegments.join("/")) >= 0) { mChildren[sPath] = true; break; } aSegments.pop(); } }); } }
javascript
{ "resource": "" }
q19054
train
function () { var i, sPath = "", sSegment; for (i = 0; i < arguments.length; i += 1) { sSegment = arguments[i]; if (sSegment || sSegment === 0) { if (sPath && sPath !== "/" && sSegment[0] !== "(") { sPath += "/"; } sPath += sSegment; } } return sPath; }
javascript
{ "resource": "" }
q19055
train
function (sPart, bEncodeEquals) { var sEncoded = encodeURI(sPart) .replace(rAmpersand, "%26") .replace(rHash, "%23") .replace(rPlus, "%2B"); if (bEncodeEquals) { sEncoded = sEncoded.replace(rEquals, "%3D"); } return sEncoded; }
javascript
{ "resource": "" }
q19056
train
function (sKey, sValue) { return _Helper.encode(sKey, true) + "=" + _Helper.encode(sValue, false); }
javascript
{ "resource": "" }
q19057
train
function (mChangeListeners, sPropertyPath, vValue) { var aListeners = mChangeListeners[sPropertyPath], i; if (aListeners) { for (i = 0; i < aListeners.length; i += 1) { aListeners[i].onChange(vValue); } } }
javascript
{ "resource": "" }
q19058
train
function (mChangeListeners, sPath, oValue, bRemoved) { Object.keys(oValue).forEach(function (sProperty) { var sPropertyPath = _Helper.buildPath(sPath, sProperty), vValue = oValue[sProperty]; if (vValue && typeof vValue === "object") { _Helper.fireChanges(mChangeListeners, sPropertyPath, vValue, bRemoved); } else { _Helper.fireChange(mChangeListeners, sPropertyPath, bRemoved ? undefined : vValue); } }); _Helper.fireChange(mChangeListeners, sPath, bRemoved ? undefined : oValue); }
javascript
{ "resource": "" }
q19059
train
function (vValue, sType) { if (vValue === undefined) { throw new Error("Illegal value: undefined"); } if (vValue === null) { return "null"; } switch (sType) { case "Edm.Binary": return "binary'" + vValue + "'"; case "Edm.Boolean": case "Edm.Byte": case "Edm.Double": case "Edm.Int16": case "Edm.Int32": case "Edm.SByte": case "Edm.Single": return String(vValue); case "Edm.Date": case "Edm.DateTimeOffset": case "Edm.Decimal": case "Edm.Guid": case "Edm.Int64": case "Edm.TimeOfDay": return vValue; case "Edm.Duration": return "duration'" + vValue + "'"; case "Edm.String": return "'" + vValue.replace(rSingleQuote, "''") + "'"; default: throw new Error("Unsupported type: " + sType); } }
javascript
{ "resource": "" }
q19060
train
function (oInstance, sMetaPath, mTypeForMetaPath) { var aFilters = [], sKey, mKey2Value = _Helper.getKeyProperties(oInstance, sMetaPath, mTypeForMetaPath); if (!mKey2Value) { return undefined; } for (sKey in mKey2Value) { aFilters.push(sKey + " eq " + mKey2Value[sKey]); } return aFilters.join(" and "); }
javascript
{ "resource": "" }
q19061
train
function (oInstance, sMetaPath, mTypeForMetaPath, bReturnAlias) { var bFailed, mKey2Value = {}; bFailed = mTypeForMetaPath[sMetaPath].$Key.some(function (vKey) { var sKey, sKeyPath, aPath, sPropertyName, oType, vValue; if (typeof vKey === "string") { sKey = sKeyPath = vKey; } else { sKey = Object.keys(vKey)[0]; // alias sKeyPath = vKey[sKey]; if (!bReturnAlias) { sKey = sKeyPath; } } aPath = sKeyPath.split("/"); vValue = _Helper.drillDown(oInstance, aPath); if (vValue === undefined) { return true; } // the last path segment is the name of the simple property sPropertyName = aPath.pop(); // find the type containing the simple property oType = mTypeForMetaPath[_Helper.buildPath(sMetaPath, aPath.join("/"))]; vValue = _Helper.formatLiteral(vValue, oType[sPropertyName].$Type); mKey2Value[sKey] = vValue; }); return bFailed ? undefined : mKey2Value; }
javascript
{ "resource": "" }
q19062
train
function (mQueryOptions, sPath) { sPath = sPath[0] === "(" ? _Helper.getMetaPath(sPath).slice(1) // avoid leading "/" : _Helper.getMetaPath(sPath); if (sPath) { sPath.split("/").some(function (sSegment) { mQueryOptions = mQueryOptions && mQueryOptions.$expand && mQueryOptions.$expand[sSegment]; return !mQueryOptions; }); } return mQueryOptions && mQueryOptions.$select; }
javascript
{ "resource": "" }
q19063
train
function (iNumber) { if (typeof iNumber !== "number" || !isFinite(iNumber)) { return false; } iNumber = Math.abs(iNumber); // The safe integers consist of all integers from -(2^53 - 1) inclusive to 2^53 - 1 // inclusive. // 2^53 - 1 = 9007199254740991 return iNumber <= 9007199254740991 && Math.floor(iNumber) === iNumber; }
javascript
{ "resource": "" }
q19064
train
function (sUrl, sBase) { return new URI(sUrl).absoluteTo(sBase).toString() .replace(rEscapedTick, "'") .replace(rEscapedOpenBracket, "(") .replace(rEscapedCloseBracket, ")"); }
javascript
{ "resource": "" }
q19065
train
function (sName) { var iIndex = sName.indexOf("/"); if (iIndex >= 0) { // consider only the first path segment sName = sName.slice(0, iIndex); } // now we have a qualified name, drop the last segment (the name) iIndex = sName.lastIndexOf("."); return iIndex < 0 ? "" : sName.slice(0, iIndex); }
javascript
{ "resource": "" }
q19066
train
function (sLiteral, sType, sPath) { function checkNaN(nValue) { if (!isFinite(nValue)) { // this rejects NaN, Infinity, -Infinity throw new Error(sPath + ": Not a valid " + sType + " literal: " + sLiteral); } return nValue; } if (sLiteral === "null") { return null; } switch (sType) { case "Edm.Boolean": return sLiteral === "true"; case "Edm.Byte": case "Edm.Int16": case "Edm.Int32": case "Edm.SByte": return checkNaN(parseInt(sLiteral)); case "Edm.Date": case "Edm.DateTimeOffset": case "Edm.Decimal": case "Edm.Guid": case "Edm.Int64": case "Edm.TimeOfDay": return sLiteral; case "Edm.Double": case "Edm.Single": return sLiteral === "INF" || sLiteral === "-INF" || sLiteral === "NaN" ? sLiteral : checkNaN(parseFloat(sLiteral)); default: throw new Error(sPath + ": Unsupported type: " + sType); } }
javascript
{ "resource": "" }
q19067
train
function (mMap, sPath, oItem) { var aItems = mMap[sPath], iIndex; if (aItems) { iIndex = aItems.indexOf(oItem); if (iIndex >= 0) { if (aItems.length === 1) { delete mMap[sPath]; } else { aItems.splice(iIndex, 1); } } } }
javascript
{ "resource": "" }
q19068
train
function (mHeaders) { var vIfMatchValue = mHeaders && mHeaders["If-Match"]; if (vIfMatchValue && typeof vIfMatchValue === "object") { vIfMatchValue = vIfMatchValue["@odata.etag"]; mHeaders = Object.assign({}, mHeaders); if (vIfMatchValue === undefined) { delete mHeaders["If-Match"]; } else { mHeaders["If-Match"] = vIfMatchValue; } } return mHeaders; }
javascript
{ "resource": "" }
q19069
train
function (oObject, sAnnotation, vValue) { var oPrivateNamespace = oObject["@$ui5._"]; if (!oPrivateNamespace) { oPrivateNamespace = oObject["@$ui5._"] = {}; } oPrivateNamespace[sAnnotation] = vValue; }
javascript
{ "resource": "" }
q19070
train
function (mMap, sTransientPredicate, sPredicate) { var sPath; for (sPath in mMap) { if (sPath.includes(sTransientPredicate)) { // A path may contain multiple different transient predicates ($uid=...) but a // certain transient predicate can only be once in the path and cannot collide // with an identifier (keys must not start with $) and with a value of a key // predicate (they are encoded by encodeURIComponent which encodes $ with %24 // and = with %3D) mMap[sPath.replace(sTransientPredicate, sPredicate)] = mMap[sPath]; delete mMap[sPath]; } } }
javascript
{ "resource": "" }
q19071
train
function () { var oObjectPageLayoutInstance = null; if (this._oComponent && this._oComponent._oView) { oObjectPageLayoutInstance = this._oComponent._oView.byId("ObjectPageLayout"); } else { Log.error("ObjectPageComponentContainer :: cannot find children ObjectPageLayout, has it been rendered already?"); } return oObjectPageLayoutInstance; }
javascript
{ "resource": "" }
q19072
ODataBinding
train
function ODataBinding() { // maps a canonical path of a quasi-absolute or relative binding to a cache object that may // be reused this.mCacheByResourcePath = undefined; this.oCachePromise = SyncPromise.resolve(); this.mCacheQueryOptions = undefined; // used to create cache only for the latest call to #fetchCache this.oFetchCacheCallToken = undefined; // change reason to be used when the binding is resumed this.sResumeChangeReason = ChangeReason.Change; }
javascript
{ "resource": "" }
q19073
train
function(oDragSession, oSessionData, sKey) { oDragSession.setComplexData(SESSION_DATA_KEY_NAMESPACE + (sKey == null ? "" : "-" + sKey), oSessionData); }
javascript
{ "resource": "" }
q19074
expandVertically
train
function expandVertically() { var growWith = 0; for (var i = 0; i < this.virtualGridMatrix.length; i++) { if (this.virtualGridMatrix[i][0] !== 0) { growWith++; } } if (growWith > 0) { this.addEmptyRows(growWith); } }
javascript
{ "resource": "" }
q19075
collectHeaderSpans
train
function collectHeaderSpans(oColumn, index, aCols) { var colSpan = TableUtils.Column.getHeaderSpan(oColumn, iRow), iColIndex; if (nSpan < 1) { if (colSpan > 1) { // In case when a user makes some of the underlying columns invisible, adjust colspan iColIndex = oColumn.getIndex(); colSpan = aCols.slice(index + 1, index + colSpan).reduce(function(span, column){ return column.getIndex() - iColIndex < colSpan ? span + 1 : span; }, 1); } oColumn._nSpan = nSpan = colSpan; iLastVisibleCol = index; } else { //Render column header but this is invisible because of the previous span oColumn._nSpan = 0; } nSpan--; }
javascript
{ "resource": "" }
q19076
isForbiddenType
train
function isForbiddenType(sType) { var aTypes = [ButtonType.Up, ButtonType.Back, ButtonType.Unstyled]; return aTypes.indexOf(sType) !== -1; }
javascript
{ "resource": "" }
q19077
_applyTriggerHook
train
function _applyTriggerHook(sEventType) { if (!jQuery.event.special[sEventType]) { jQuery.event.special[sEventType] = {}; } var oSpecialEvent = jQuery.event.special[sEventType], originalTriggerHook = oSpecialEvent.trigger; oSpecialEvent.trigger = fnTriggerHook; return originalTriggerHook; }
javascript
{ "resource": "" }
q19078
suppressTriggeredEvent
train
function suppressTriggeredEvent(sEventType, oDomRef, aExcludedDomRefs) { var mEventInfo = mTriggerEventInfo[sEventType]; var sId = uid(); if (!mEventInfo) { mEventInfo = mTriggerEventInfo[sEventType] = { domRefs: {}, originalTriggerHook: _applyTriggerHook(sEventType) }; } mEventInfo.domRefs[sId] = { domRef: oDomRef, excludedDomRefs: [].concat(aExcludedDomRefs) }; return { id: sId, type: sEventType }; }
javascript
{ "resource": "" }
q19079
releaseTriggeredEvent
train
function releaseTriggeredEvent(oHandler) { if (!oHandler) { Log.error("Release trigger events must not be called without passing a valid handler!"); return; } var mEventInfo = mTriggerEventInfo[oHandler.type]; if (!mEventInfo) { return; } else if (!mEventInfo.domRefs[oHandler.id] || !mEventInfo.domRefs[oHandler.id].domRef) { Log.warning("Release trigger event for event type " + oHandler.type + "on Control " + oHandler.id + ": DomRef does not exists"); return; } delete mEventInfo.domRefs[oHandler.id]; }
javascript
{ "resource": "" }
q19080
fetchIndex
train
function fetchIndex() { return new Promise(function(resolve, reject) { var oIndex = oIndexCache["index"], oSerializedIndex; if (oIndex) { resolve(oIndex); return; } var req = new XMLHttpRequest(), onload = function (oEvent) { oSerializedIndex = oEvent.target.response || oEvent.target.responseText; if (typeof oSerializedIndex !== 'object') { // fallback in case the browser does not support automatic JSON parsing oSerializedIndex = JSON.parse(oSerializedIndex); } oSerializedIndex = decompressIndex(oSerializedIndex); overrideLunrTokenizer(); oIndex = lunr.Index.load(oSerializedIndex.lunr); oIndexCache["index"] = oIndex; oIndexCache["docs"] = oSerializedIndex.docs; resolve(oIndex); }; if (!bIsMsieBrowser) { // IE does not support 'json' responseType // (and will throw an error if we attempt to set it nevertheless) req.responseType = 'json'; } req.addEventListener("load", onload, false); req.open("get", URL.SEARCH_INDEX); req.send(); }); }
javascript
{ "resource": "" }
q19081
searchIndex
train
function searchIndex(sQuery) { sQuery = preprocessQuery(sQuery); return new Promise(function(resolve, reject) { fetchIndex().then(function(oIndex) { var aSearchResults, oSearchResultsCollector = new SearchResultCollector(); function searchByField(sFieldToSearch, sSubQuery, bReturnMatchedDocWord) { var aResults = oIndex.search(sSubQuery, createSearchConfig(sFieldToSearch)); oSearchResultsCollector.add(aResults, sSubQuery, sFieldToSearch, bReturnMatchedDocWord); } // search by fields in priority order searchByField("title", sQuery); METADATA_FIELDS.forEach(function(sField) { lunr.tokenizer(sQuery).forEach(function(sSubQuery) { searchByField(sField, sSubQuery, true); }); }); searchByField("paramTypes", sQuery); searchByField("contents", sQuery); // collect all results aSearchResults = oSearchResultsCollector.getAll(); resolve({ success: !!(aSearchResults.length), totalHits: aSearchResults.length, matches: aSearchResults }); }); }); }
javascript
{ "resource": "" }
q19082
overrideLunrTokenizer
train
function overrideLunrTokenizer() { var origTokenizer = lunr.tokenizer; var rSeparators = /[-./#_,;\(\)=><|]/g; lunr.tokenizer = function(str) { return origTokenizer.call(lunr, str).reduce( function (result, token) { if ( rSeparators.test(token) ) { token = token.replace(rSeparators, " "); result.push.apply(result, token.toLowerCase().split(/ +/)); } else { result.push(token.toLowerCase()); } return result; }, []); }; Object.keys(origTokenizer).forEach(function (key) { lunr.tokenizer[key] = origTokenizer[key]; }); }
javascript
{ "resource": "" }
q19083
getObjectValues
train
function getObjectValues(oObject) { var aKeys = Object.keys(oObject), aValues = []; aKeys.forEach(function(sKey) { aValues.push(oObject[sKey]); }); return aValues; }
javascript
{ "resource": "" }
q19084
train
function (oTarget) { var iViewLevel; do { iViewLevel = oTarget._oOptions.viewLevel; if (iViewLevel !== undefined) { return iViewLevel; } oTarget = oTarget._oParent; } while (oTarget); return iViewLevel; }
javascript
{ "resource": "" }
q19085
train
function(oTable, vRowIndex, bExpand) { var aIndices = []; var oBinding = oTable ? oTable.getBinding("rows") : null; if (!oTable || !oBinding || !oBinding.expand || vRowIndex == null) { return null; } if (typeof vRowIndex === "number") { aIndices = [vRowIndex]; } else if (Array.isArray(vRowIndex)) { if (bExpand == null && vRowIndex.length > 1) { // Toggling the expanded state of multiple rows seems to be an absurd task. Therefore we assume this is unintentional and // prevent the execution. return null; } aIndices = vRowIndex; } // The cached binding length cannot be used here. In the synchronous execution after re-binding the rows, the cached binding length is // invalid. The table will validate it in its next update cycle, which happens asynchronously. // As of now, this is the required behavior for some features, but leads to failure here. Therefore, the length is requested from the // binding directly. var iTotalRowCount = oTable._getTotalRowCount(true); var aValidSortedIndices = aIndices.filter(function(iIndex) { // Only indices of existing, expandable/collapsible nodes must be considered. Otherwise there might be no change event on the final // expand/collapse. var bIsExpanded = oBinding.isExpanded(iIndex); var bIsLeaf = true; // If the node state cannot be determined, we assume it is a leaf. if (oBinding.nodeHasChildren) { if (oBinding.getNodeByIndex) { bIsLeaf = !oBinding.nodeHasChildren(oBinding.getNodeByIndex(iIndex)); } else { // The sap.ui.model.TreeBindingCompatibilityAdapter has no #getNodeByIndex function and #nodeHasChildren always returns true. bIsLeaf = false; } } return iIndex >= 0 && iIndex < iTotalRowCount && !bIsLeaf && bExpand !== bIsExpanded; }).sort(); if (aValidSortedIndices.length === 0) { return null; } // Operations need to be performed from the highest index to the lowest. This ensures correct results with OData bindings. The indices // are sorted ascending, so the array is iterated backwards. // Expand/Collapse all nodes except the first, and suppress the change event. for (var i = aValidSortedIndices.length - 1; i > 0; i--) { if (bExpand) { oBinding.expand(aValidSortedIndices[i], true); } else { oBinding.collapse(aValidSortedIndices[i], true); } } // Expand/Collapse the first node without suppressing the change event. if (bExpand === true) { oBinding.expand(aValidSortedIndices[0], false); } else if (bExpand === false) { oBinding.collapse(aValidSortedIndices[0], false); } else { oBinding.toggleIndex(aValidSortedIndices[0]); } return oBinding.isExpanded(aValidSortedIndices[0]); }
javascript
{ "resource": "" }
q19086
train
function(oCellRef) { var oInfo = TableGrouping.TableUtils.getCellInfo(oCellRef); if (oInfo.isOfType(TableGrouping.TableUtils.CELLTYPE.DATACELL)) { return oInfo.cell.parent().hasClass("sapUiTableGroupHeader"); } else if (oInfo.isOfType(TableGrouping.TableUtils.CELLTYPE.ROWHEADER | TableGrouping.TableUtils.CELLTYPE.ROWACTION)) { return oInfo.cell.hasClass("sapUiTableGroupHeader"); } return false; }
javascript
{ "resource": "" }
q19087
train
function(oTable, iLevel, bChildren, bSum) { var iIndent = 0; var i; if (oTable.isA("sap.ui.table.TreeTable")) { for (i = 0; i < iLevel; i++) { iIndent = iIndent + (i < 2 ? 12 : 8); } } else if (oTable.isA("sap.ui.table.AnalyticalTable")) { iLevel = iLevel - 1; iLevel = !bChildren && !bSum ? iLevel - 1 : iLevel; iLevel = Math.max(iLevel, 0); for (i = 0; i < iLevel; i++) { if (iIndent == 0) { iIndent = 12; } iIndent = iIndent + (i < 2 ? 12 : 8); } } else { iLevel = !bChildren ? iLevel - 1 : iLevel; iLevel = Math.max(iLevel, 0); for (i = 0; i < iLevel; i++) { iIndent = iIndent + (i < 2 ? 12 : 8); } } return iIndent; }
javascript
{ "resource": "" }
q19088
train
function(oTable, $Row, $RowHdr, iIndent) { var bRTL = oTable._bRtlMode, $FirstCellContentInRow = $Row.find("td.sapUiTableCellFirst > .sapUiTableCellInner"), $Shield = $RowHdr.find(".sapUiTableGroupShield"); if (iIndent <= 0) { // No indent -> Remove custom manipulations (see else) $RowHdr.css(bRTL ? "right" : "left", ""); $Shield.css("width", "").css(bRTL ? "margin-right" : "margin-left", ""); $FirstCellContentInRow.css(bRTL ? "padding-right" : "padding-left", ""); } else { // Apply indent on table row $RowHdr.css(bRTL ? "right" : "left", iIndent + "px"); $Shield.css("width", iIndent + "px").css(bRTL ? "margin-right" : "margin-left", ((-1) * iIndent) + "px"); $FirstCellContentInRow.css(bRTL ? "padding-right" : "padding-left", (iIndent + 8/* +8px standard padding .sapUiTableCellInner */) + "px"); } }
javascript
{ "resource": "" }
q19089
train
function(oTable, oRow, bChildren, bExpanded, bHidden, bSum, iLevel, sGroupHeaderText) { var oDomRefs = oRow.getDomRefs(true), $Row = oDomRefs.row, $ScrollRow = oDomRefs.rowScrollPart, $FixedRow = oDomRefs.rowFixedPart, $RowHdr = oDomRefs.rowSelector, $RowAct = oDomRefs.rowAction; $Row.attr({ "data-sap-ui-level": iLevel }); $Row.data("sap-ui-level", iLevel); if (TableGrouping.isGroupMode(oTable)) { $Row.toggleClass("sapUiAnalyticalTableSum", !bChildren && bSum) .toggleClass("sapUiAnalyticalTableDummy", false) .toggleClass("sapUiTableGroupHeader", bChildren) .toggleClass("sapUiTableRowHidden", bChildren && bHidden || oRow._bHidden); jQuery(document.getElementById(oRow.getId() + "-groupHeader")) .toggleClass("sapUiTableGroupIconOpen", bChildren && bExpanded) .toggleClass("sapUiTableGroupIconClosed", bChildren && !bExpanded) .attr("title", oTable._getShowStandardTooltips() && sGroupHeaderText ? sGroupHeaderText : null) .text(sGroupHeaderText || ""); var iIndent = TableGrouping.calcGroupIndent(oTable, iLevel, bChildren, bSum); TableGrouping.setIndent(oTable, $Row, $RowHdr, iIndent); $Row.toggleClass("sapUiTableRowIndented", iIndent > 0); } var $TreeIcon = null; if (TableGrouping.isTreeMode(oTable)) { $TreeIcon = $Row.find(".sapUiTableTreeIcon"); $TreeIcon.css(oTable._bRtlMode ? "margin-right" : "margin-left", (iLevel * 17) + "px") .toggleClass("sapUiTableTreeIconLeaf", !bChildren) .toggleClass("sapUiTableTreeIconNodeOpen", bChildren && bExpanded) .toggleClass("sapUiTableTreeIconNodeClosed", bChildren && !bExpanded); } if (TableGrouping.showGroupMenuButton(oTable)) { // Update the GroupMenuButton var iScrollbarOffset = 0; var $Table = oTable.$(); if ($Table.hasClass("sapUiTableVScr")) { iScrollbarOffset += $Table.find(".sapUiTableVSb").width(); } var $GroupHeaderMenuButton = $RowHdr.find(".sapUiTableGroupMenuButton"); if (oTable._bRtlMode) { $GroupHeaderMenuButton.css("right", ($Table.width() - $GroupHeaderMenuButton.width() + $RowHdr.position().left - iScrollbarOffset - 5) + "px"); } else { $GroupHeaderMenuButton.css("left", ($Table.width() - $GroupHeaderMenuButton.width() - $RowHdr.position().left - iScrollbarOffset - 5) + "px"); } } oTable._getAccExtension() .updateAriaExpandAndLevelState(oRow, $ScrollRow, $RowHdr, $FixedRow, $RowAct, bChildren, bExpanded, iLevel, $TreeIcon); }
javascript
{ "resource": "" }
q19090
train
function(oTable) { var oBinding = oTable.getBinding("rows"); if (oBinding && oBinding._modified) { TableGrouping.clearMode(oTable); var oBindingInfo = oTable.getBindingInfo("rows"); oTable.unbindRows(); oTable.bindRows(oBindingInfo); } }
javascript
{ "resource": "" }
q19091
train
function (oEvent) { // both xml and html view write this ui5 internal property for the serializer if (oEvent.fFunction && oEvent.fFunction._sapui_handlerName) { var sHandlerName = oEvent.fFunction._sapui_handlerName; // double check that the function is on the controller var oController = oView.getController(); if (oController[sHandlerName] || sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) { return sHandlerName; } } // TODO: ITERARTE OVER HANDLERS AND CHECK THE EVENT FUNCTION // NOTE: JQUERY GUID WON'T WORK AS THE GUID WILL BE SAVED AT THE CLOSURED FUNCTION AS WELL // WHEN THE FUNCTION IS REUSED FOR SEVERAL HANDLERS WE WILL LOSE THE INFORMATION /*for (var sHandler in oController) { if (oController[sHandler] === oEvent.fFunction) { return sHandler; } }*/ }
javascript
{ "resource": "" }
q19092
train
function (oControl) { // Allow specification of desired controlId as changing ids later on is not possible //This has to be the view relative ID if (oControl._sapui_controlId) { return oControl._sapui_controlId; } return oControl.getId().replace(oView.createId(""), ""); }
javascript
{ "resource": "" }
q19093
boot
train
function boot() { if (window.sap && window.sap.ui && window.sap.ui.getCore) { coreInstance = window.sap.ui.getCore(); return initTags(); } window.sap.ui.require(['/ui5loader-autoconfig', 'sap/ui/core/Core', 'sap/ui/integration/util/CustomElements'], function (config, Core, CE) { CustomElements = CE; Core.boot(); coreInstance = Core; Core.attachInit(function () { initTags(); }); //pass on the core instance to Customelements interface CustomElements.coreInstance = coreInstance; }); }
javascript
{ "resource": "" }
q19094
train
function () { var sJson = this._oStorage.get(this._sStorageKey); if (!sJson) { // local storage is empty, apply defaults this._oViewSettings = this._oDefaultSettings; } else { // parse this._oViewSettings = JSON.parse(sJson); // clean filter and remove values that do not exist any longer in the data model // (the cleaned filter are not written back to local storage, this only happens on changing the view settings) //var oFilterData = this.getView().getModel("filter").getData(); var oFilterData = this.getOwnerComponent().getModel("filter").getData(); var oCleanFilter = {}; jQuery.each(this._oViewSettings.filter, function (sProperty, aValues) { var aNewValues = []; jQuery.each(aValues, function (i, aValue) { var bValueIsClean = false; jQuery.each(oFilterData[sProperty], function (i, oValue) { if (oValue.id === aValue) { bValueIsClean = true; return false; } }); if (bValueIsClean) { aNewValues.push(aValue); } }); if (aNewValues.length > 0) { oCleanFilter[sProperty] = aNewValues; } }); this._oViewSettings.filter = oCleanFilter; // handling data stored with an older explored versions if (!this._oViewSettings.hasOwnProperty("compactOn")) { // compactOn was introduced later this._oViewSettings.compactOn = false; } if (!this._oViewSettings.hasOwnProperty("themeActive")) { // themeActive was introduced later this._oViewSettings.themeActive = "sap_bluecrystal"; } else if (this._oViewSettings.version !== this._oDefaultSettings.version) { var oVersion = jQuery.sap.Version(sap.ui.version); if (oVersion.compareTo("1.40.0") >= 0) { // Belize theme is available since 1.40 this._oViewSettings.themeActive = "sap_belize"; } else { // Fallback to BlueCrystal for older versions this._oViewSettings.themeActive = "sap_bluecrystal"; } } if (!this._oViewSettings.hasOwnProperty("rtl")) { // rtl was introduced later this._oViewSettings.rtl = false; } // handle RTL-on in settings as this need a reload if (this._oViewSettings.rtl && !jQuery.sap.getUriParameters().get('sap-ui-rtl')) { this._handleRTL(true); } } }
javascript
{ "resource": "" }
q19095
train
function(oTable) { var oScrollExtension = oTable._getScrollExtension(); var oHSb = oScrollExtension.getHorizontalScrollbar(); if (oHSb && internal(oTable).iHorizontalScrollPosition !== null) { var aScrollTargets = HorizontalScrollingHelper.getScrollAreas(oTable); for (var i = 0; i < aScrollTargets.length; i++) { var oScrollTarget = aScrollTargets[i]; delete oScrollTarget._scrollLeft; } if (oHSb.scrollLeft !== internal(oTable).iHorizontalScrollPosition) { oHSb.scrollLeft = internal(oTable).iHorizontalScrollPosition; } else { var oEvent = jQuery.Event("scroll"); oEvent.target = oHSb; HorizontalScrollingHelper.onScroll.call(oTable, oEvent); } } }
javascript
{ "resource": "" }
q19096
train
function(oTable) { var oDomRef = oTable.getDomRef(); var aScrollableColumnAreas; if (oDomRef) { aScrollableColumnAreas = Array.prototype.slice.call(oTable.getDomRef().querySelectorAll(".sapUiTableCtrlScr")); } var aScrollAreas = [ oTable._getScrollExtension().getHorizontalScrollbar() ].concat(aScrollableColumnAreas); return aScrollAreas.filter(function(oScrollArea) { return oScrollArea != null; }); }
javascript
{ "resource": "" }
q19097
train
function(oEvent) { // For interaction detection. Interaction.notifyScrollEvent && Interaction.notifyScrollEvent(oEvent); if (internal(this).bIsScrolledVerticallyByKeyboard) { // When scrolling with the keyboard the first visible row is already correct and does not need adjustment. log("Vertical scroll event handler: Aborted - Scrolled by keyboard", this); return; } // Do not scroll in action mode, if scrolling was not initiated by a keyboard action! // Might cause loss of user input and other undesired behavior. this._getKeyboardExtension().setActionMode(false); var nNewScrollTop = oEvent.target.scrollTop; // Can be a float if zoomed in Chrome. var nOldScrollTop = oEvent.target._scrollTop; // This will be set in VerticalScrollingHelper#updateScrollPosition. var bScrollWithScrollbar = nNewScrollTop !== nOldScrollTop; if (bScrollWithScrollbar) { log("Vertical scroll event handler: Scroll position changed by scrolling with the scrollbar:" + " From " + internal(this).nVerticalScrollPosition + " to " + nNewScrollTop, this); delete oEvent.target._scrollTop; VerticalScrollingHelper.updateScrollPosition(this, nNewScrollTop, ScrollTrigger.SCROLLBAR); } else { log("Vertical scroll event handler: Scroll position changed by scrolling with VerticalScrollingHelper#updateScrollPosition", this); } internal(this).bIsScrolledVerticallyByWheel = false; }
javascript
{ "resource": "" }
q19098
train
function(oTable) { var oScrollExtension = oTable._getScrollExtension(); var iMaxFirstRenderedRowIndex = oTable._getMaxFirstRenderedRowIndex(); var iNewFirstVisibleRowIndex = VerticalScrollingHelper.getRowIndexAtCurrentScrollPosition(oTable); var iOldFirstVisibleRowIndex = oTable.getFirstVisibleRow(); var bNewFirstVisibleRowInBuffer = iNewFirstVisibleRowIndex < 0; var bOldFirstVisibleRowInBuffer = iOldFirstVisibleRowIndex >= iMaxFirstRenderedRowIndex; var bFirstVisibleRowChanged = iNewFirstVisibleRowIndex !== iOldFirstVisibleRowIndex; var bRowsUpdateRequired = bFirstVisibleRowChanged && !(bNewFirstVisibleRowInBuffer && bOldFirstVisibleRowInBuffer); if (bRowsUpdateRequired) { var bExpectRowsUpdatedEvent = !bOldFirstVisibleRowInBuffer || iNewFirstVisibleRowIndex !== iMaxFirstRenderedRowIndex; if (bNewFirstVisibleRowInBuffer) { // The actual new first visible row cannot be determined yet. It will be done when the inner scroll position gets updated. iNewFirstVisibleRowIndex = iMaxFirstRenderedRowIndex; } log("updateFirstVisibleRow: From " + iOldFirstVisibleRowIndex + " to " + iNewFirstVisibleRowIndex, oTable); oTable.setFirstVisibleRow(iNewFirstVisibleRowIndex, true, bNewFirstVisibleRowInBuffer); if (bExpectRowsUpdatedEvent) { VerticalScrollingHelper.setOnRowsUpdatedPreprocessor(oTable, function(oEvent) { log("updateFirstVisibleRow - onRowsUpdatedPreprocessor: Reason " + oEvent.getParameters().reason, this); oScrollExtension.updateInnerVerticalScrollPosition(); if (bNewFirstVisibleRowInBuffer) { var iCurrentFirstVisibleRow = this.getFirstVisibleRow(); var bFirstVisibleRowNotChanged = iNewFirstVisibleRowIndex === iCurrentFirstVisibleRow; // The firstVisibleRow was previously set to the maximum first visible row index while suppressing the event. If the first // visible row is not adjusted in #updateInnerVerticalScrollPosition, make sure the event is called here. if (bFirstVisibleRowNotChanged) { this.setProperty("firstVisibleRow", -1, true); this.setFirstVisibleRow(iCurrentFirstVisibleRow, true); } } return false; }); } else { log("updateFirstVisibleRow: Update inner vertical scroll position", oTable); oScrollExtension.updateInnerVerticalScrollPosition(); } } else if (TableUtils.isVariableRowHeightEnabled(oTable)) { log("updateFirstVisibleRow: Update inner vertical scroll position", oTable); oScrollExtension.updateInnerVerticalScrollPosition(); } }
javascript
{ "resource": "" }
q19099
train
function(oTable) { var oScrollExtension = oTable._getScrollExtension(); var iMaxRowIndex = oTable._getMaxFirstVisibleRowIndex(); if (iMaxRowIndex === 0) { return 0; } else { var nScrollPosition = VerticalScrollingHelper.getScrollPosition(oTable); var iScrollRange = VerticalScrollingHelper.getScrollRange(oTable); var nScrollRangeRowFraction = VerticalScrollingHelper.getScrollRangeRowFraction(oTable); if (TableUtils.isVariableRowHeightEnabled(oTable)) { if (VerticalScrollingHelper.isScrollPositionInBuffer(oTable)) { return -1; } else { return Math.min(iMaxRowIndex, Math.floor(nScrollPosition / nScrollRangeRowFraction)); } } else { var iRowIndex = Math.floor(nScrollPosition / nScrollRangeRowFraction); // Calculation of the row index can be inaccurate if scrolled to the end. This can happen due to rounding errors in case of // large data or when zoomed in Chrome. In this case it can not be scrolled to the last row. To overcome this issue we consider the // table to be scrolled to the end, if the scroll position is less than 1 pixel away from the maximum. var nDistanceToMaximumScrollPosition = iScrollRange - nScrollPosition; var bScrolledViaScrollTop = oScrollExtension.getVerticalScrollbar()._scrollTop == null || internal(oTable).bIsScrolledVerticallyByWheel; var bScrolledToBottom = nDistanceToMaximumScrollPosition < 1 && bScrolledViaScrollTop || nDistanceToMaximumScrollPosition < 0.01; if (bScrolledToBottom) { // If zoomed in Chrome, scrollTop might not be accurate enough to correctly restore the scroll position after rendering. VerticalScrollingHelper.updateScrollPosition(oTable, iScrollRange, null, true); } return bScrolledToBottom ? iMaxRowIndex : Math.min(iMaxRowIndex, iRowIndex); } } }
javascript
{ "resource": "" }