DVHMA/DVHMA-OpenUI5/www/resources/sap/m/ActionSelect.js

7 lines
2.1 KiB
JavaScript

/*!
* SAP UI development toolkit for HTML5 (SAPUI5/OpenUI5)
* (c) Copyright 2009-2015 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
*/
sap.ui.define(['jquery.sap.global','./Select','./library'],function(q,S,l){"use strict";var A=S.extend("sap.m.ActionSelect",{metadata:{library:"sap.m",associations:{buttons:{type:"sap.m.Button",multiple:true,singularName:"button"}}}});A.prototype.init=function(){S.prototype.init.call(this);this.getList().addEventDelegate({onfocusin:this.onfocusinList},this);};A.prototype.hasContent=function(){return S.prototype.hasContent.call(this)||!!this.getButtons().length;};A.prototype.addContent=function(){var c=sap.ui.getCore(),p=this.getPicker();this.getButtons().forEach(function(b){p.addContent(c.byId(b));});};A.prototype.onAfterRenderingPicker=function(){S.prototype.onAfterRenderingPicker.call(this);this.getPicker().addStyleClass(sap.m.ActionSelectRenderer.CSS_CLASS+"Picker");};A.prototype.removeButton=function(b){var p=this.getPicker();if(p){if(typeof b==="number"){b=this.getButtons()[b];}p.removeContent(b);}return this.removeAssociation("buttons",b);};A.prototype.removeAllButtons=function(){var p=this.getPicker();if(p){this.getButtons().forEach(function(b){p.removeContent(b);});}return this.removeAllAssociation("buttons");};A.prototype.onsaptabprevious=function(e){if(e.isMarked()||!this.getEnabled()){return;}e.setMarked();var b=this.getButtons();var p=this.getPicker();if(p&&p.isOpen()&&b.length>0){sap.ui.getCore().byId(b[b.length-1]).focus();e.preventDefault();}};A.prototype.onsaptabnext=function(e){if(e.isMarked()||!this.getEnabled()){return;}e.setMarked();var b=this.getButtons();var p=this.getPicker();if(p&&p.isOpen()&&b.length>0){sap.ui.getCore().byId(b[0]).focus();e.preventDefault();}};A.prototype.onsapfocusleave=function(e){var b=this.getButtons();var k=(b.indexOf(e.relatedControlId)==-1);if(k){S.prototype.onsapfocusleave.apply(this,arguments);}};A.prototype.onfocusinList=function(e){if(document.activeElement!==this.getList().getDomRef()){this.focus();}};return A;},true);