/*!
 * 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','sap/ui/core/Control','sap/ui/core/LocaleData','sap/ui/core/delegate/ItemNavigation','sap/ui/unified/library'],function(q,C,L,I,l){"use strict";var M=C.extend("sap.ui.unified.calendar.MonthPicker",{metadata:{library:"sap.ui.unified",properties:{month:{type:"int",group:"Misc",defaultValue:0}},events:{select:{}}}});(function(){M.prototype.init=function(){this._iColumns=3;};M.prototype.onAfterRendering=function(){var t=this;_(t);e(t);};M.prototype.setMonth=function(m){this.setProperty("month",m,true);m=this.getProperty("month");if(m<0||m>11){throw new Error("Property month must be between 0 and 11; "+this);}if(this.getDomRef()){var t=this;d(t,m);this._oItemNavigation.focusItem(m);}};M.prototype._getLocale=function(){var p=this.getParent();if(p&&p._getLocale){return p._getLocale();}else if(!this._sLocale){this._sLocale=sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale().toString();}return this._sLocale;};M.prototype._getLocaleData=function(){var p=this.getParent();if(p&&p._getLocaleData){return p._getLocaleData();}else if(!this._oLocaleData){var s=this._getLocale();var o=new sap.ui.core.Locale(s);this._oLocaleData=L.getInstance(o);}return this._oLocaleData;};M.prototype.onsapselect=function(E){var t=this;var i=this._oItemNavigation.getFocusedIndex();d(t,i);this.fireSelect();};M.prototype.onThemeChanged=function(){if(this._bNoThemeChange){return;}this._bNamesLengthChecked=undefined;var m=this._oItemNavigation.getItemDomRefs();this._bLongMonth=false;var o=this._getLocaleData();var f=o.getMonthsStandAlone("wide");for(var i=0;i<m.length;i++){var $=q(m[i]);$.text(f[i]);}var t=this;e(t);};function _(t){var r=t.getDomRef();var D=t.$().find(".sapUiCalMonth");var i=t.getMonth();if(!t._oItemNavigation){t._oItemNavigation=new I();t._oItemNavigation.attachEvent(I.Events.AfterFocus,a,t);t._oItemNavigation.attachEvent(I.Events.FocusAgain,b,t);t.addDelegate(t._oItemNavigation);t._oItemNavigation.setHomeEndColumnMode(true,true);t._oItemNavigation.setDisabledModifiers({sapnext:["alt"],sapprevious:["alt"],saphome:["alt"],sapend:["alt"]});}t._oItemNavigation.setRootDomRef(r);t._oItemNavigation.setItemDomRefs(D);t._oItemNavigation.setCycling(true);t._oItemNavigation.setColumns(t._iColumns,false);t._oItemNavigation.setFocusedIndex(i);t._oItemNavigation.setPageSize(D.length);}function a(o){var i=o.getParameter("index");var E=o.getParameter("event");if(!E){return;}if(E.type=="mousedown"){var t=this;c(t,E,i);}}function b(o){var i=o.getParameter("index");var E=o.getParameter("event");if(!E){return;}if(E.type=="mousedown"){var t=this;c(t,E,i);}}function c(t,E,i){d(t,i);t.fireSelect();E.preventDefault();E.setMark("cancelAutoClose");}function d(t,m,n){var D=t._oItemNavigation.getItemDomRefs();var $;var s=t.getId()+"-m"+m;for(var i=0;i<D.length;i++){$=q(D[i]);if($.attr("id")==s){$.addClass("sapUiCalMonthSel");}else{$.removeClass("sapUiCalMonthSel");}}if(!n){t.setProperty("month",m,true);}}function e(t){if(!t._bNamesLengthChecked){var i=0;var m=t._oItemNavigation.getItemDomRefs();var T=false;for(i=0;i<m.length;i++){var o=m[i];if(o.clientWidth<o.scrollWidth){T=true;break;}}if(T){t._bLongMonth=false;var f=t._getLocaleData();var g=f.getMonthsStandAlone("abbreviated");var h=f.getMonthsStandAlone("wide");for(i=0;i<m.length;i++){var $=q(m[i]);$.text(g[i]);$.attr("aria-label",h[i]);}}else{t._bLongMonth=true;}t._bNamesLengthChecked=true;}}}());return M;},true);
