/*!
 * 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','./Dialog','./Popover','./library','sap/ui/core/Control','sap/ui/core/delegate/ItemNavigation','sap/m/ActionSheet','sap/m/ActionSheetRenderer'],function(q,D,P,l,C,I,A,a){"use strict";var O=A.extend("sap.m._overflowToolbarHelpers.OverflowToolbarAssociativeActionSheet",{metadata:{associations:{associatedButtons:{type:"sap.m.Button",multiple:true,singularName:"associatedButton"}}},renderer:a.render});O.prototype.init=function(){A.prototype.init.apply(this,arguments);this._mButtonStateMap={};};O.prototype.addAssociatedButton=function(b){this.addAssociation("associatedButtons",b,true);this._preProcessActionButton(b);b.attachPress(this._buttonSelected,this);return this;};O.prototype.removeAssociatedButton=function(b){var r=this.removeAssociation("associatedButtons",b,true),B;if(r){B=sap.ui.getCore().byId(r);B.detachPress(this._buttonSelected,this);this._postProcessActionButton(B);}return r;};O.prototype.removeAllAssociatedButtons=function(){var r=this.removeAllAssociation("associatedButtons",true),b;r.forEach(function(B){b=sap.ui.getCore().byId(B);b.detachPress(this._buttonSelected,this);this._postProcessActionButton(b);},this);return r;};O.prototype._getAllButtons=function(){var b=this.getAssociatedButtons().map(function(i){return sap.ui.getCore().byId(i);});if(this.getPlacement()===sap.m.PlacementType.Top){b.reverse();}return this.getButtons().concat(b);};O.prototype._getButtonsIdsHash=function(){return this.getAssociatedButtons().join(".");};O.prototype._preProcessActionButton=function(b){var t=b.getType();this._mButtonStateMap[b.getId()]={isInverted:b.hasStyleClass("sapMBtnInverted"),isTransparent:b.hasStyleClass("sapMBtnTransparent"),buttonType:t};if(t!==sap.m.ButtonType.Accept&&t!==sap.m.ButtonType.Reject){b.setProperty("type",sap.m.ButtonType.Transparent,true);}b.addStyleClass("sapMBtnInverted");if(b.getMetadata().getName()==="sap.m.OverflowToolbarButton"){b._bInOverflow=true;}return this;};O.prototype._postProcessActionButton=function(b){var p=this._mButtonStateMap[b.getId()];if(p){if(!p.isInverted){b.removeStyleClass("sapMBtnInverted");}if(!p.isTransparent){b.removeStyleClass("sapMBtnTransparent");}if(b.getType()!==p.buttonType){b.setProperty("type",p.buttonType,true);}}b.removeStyleClass("sapMActionSheetButton");b.removeStyleClass("sapMActionSheetButtonNoIcon");b.removeStyleClass("sapMActionSheetCancelButton");b.$().remove();if(b.getMetadata().getName()==="sap.m.OverflowToolbarButton"){delete b._bInOverflow;}return this;};O.prototype._closeWithoutAnimation=function(){var o=P._bIE9;P._bIE9=true;this.close();P._bIE9=o;};O._acceptsControl=function(c){var s=c.getMetadata().getName();return["sap.m.Button","sap.m.OverflowToolbarButton"].indexOf(s)!==-1;};return O;},false);
