(function(){"use strict";u8.Crm.Widgets.FavoritesPopup=function(e,i){this.Widget(e,$.extend({},u8.Crm.Widgets.FavoritesPopup.defaults,i))};u8.Crm.Widgets.FavoritesPopup.defaults={selectionMode:"single"};u8.Crm.Widgets.FavoritesPopup.makeClass({name:"FavoritesPopup",deriveFrom:u8.Base.Widgets.Widget,events:["Select","Close"]});$.extend(u8.Crm.Widgets.FavoritesPopup.prototype,{open:function(){var e={favorites:$.extend({defaultAction:"A_SelectRecord",menuName:"M_LinkInfoArea",infoAreaIds:this.infoAreaIds},this.favorites)};var i=u8.services.navigation.getPageUrl("Favorites");this._popup=new u8.Base.Widgets.Popup(i,{title:u8.services.schema.idToLabelPlural("FV"),size:{width:800,height:600},parent:this,pageOptions:e,onClose:this._onPopupClose.bind(this)});this._popup.open()},close:function(e){if(!this._popup){return}this._popup.close(e)},select:function(e,i){var t={uid:e};this._addSelection(t);this._completeSelection();if(i){i(this,{selection:this.selection})}},_addSelection:function(e){if(this.selectionMode=="single"){this.selection=e}else{if(!this.selection){this.selection=[]}this.selection.push(e)}},_completeSelection:function(){if(this.selectionMode=="singleStayOpen"){this.raise("Select",{selection:this.selection});return}else if(this.selectionMode=="multi"){return}this.close()},_onPopupClose:function(e,i){this._close(i)},_close:function(e){if(!this._popup){return}if(!e){e={}}if(!e.cancel){e.selection=this.selection}if(this.selectMode!="singleStayOpen"){this.raise("Select",e)}this._popup.dispose();this._popup=null;this.raise("Close",e)},"Command.Select":function(e,i,t){this.select(t.uid)}})})();