Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.AbstractFolderWidget=Ext.extend(Zarafa.core.ui.widget.Widget,{folder:void 0,store:void 0,folderType:void 0,constructor:function(a){a=a||{};Ext.applyIf(a,{hasConfig:!0});Zarafa.widgets.folderwidgets.AbstractFolderWidget.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.widgets.folderwidgets.AbstractFolderWidget.superclass.initEvents.apply(this,arguments);var a=container.getHierarchyStore();this.mon(a,"load",this.onHierarchyLoad,this);this.onHierarchyLoad(a);
this.mon(this.store,"load",this.onStoreLoad,this,{single:!0});this.mon(this.store,"update",this.onStoreUpdate,this)},onHierarchyLoad:function(a){(this.folder=a.getDefaultFolder(this.folderType))&&this.reloadStore()},onStoreLoad:function(){var a=this.get("reloadinterval")||3E5;Ext.TaskMgr.start({run:this.reloadStore,interval:a,scope:this})},onStoreUpdate:function(){this.updateFilter()},reloadStore:function(){this.folder&&this.store.load({folder:this.folder})},updateFilter:Ext.emptyFn,config:function(){var a=
new Ext.Window({title:_("Configure widget"),layout:"fit",width:320,height:130,items:[{xtype:"form",frame:!0,cls:"k-configure-widget",labelWidth:120,items:[{xtype:"zarafa.spinnerfield",fieldLabel:_("Reload interval"),name:"reloadinterval",boxLabel:_("seconds."),width:60,minValue:30,maxValue:1800,incrementValue:30,defaultValue:this.get("reloadinterval")/1E3||300,listeners:{change:this.onFieldChange,scope:this},plugins:["zarafa.numberspinner"]}],buttons:[{text:_("Close"),scope:this,handler:function(){a.close()}}],
buttons:[{text:_("Close"),scope:this,handler:function(){a.close()}}]}]});a.show(this)},onFieldChange:function(a,b,c){this.set(a.getName(),1E3*b)}});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.AppointmentsWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.calendar.AppointmentStore;Ext.applyIf(a,{height:300,autoScroll:!0,layout:"fit",folderType:"calendar",store:b,items:[{xtype:"zarafa.gridpanel",store:b,border:!0,hideHeaders:!0,loadMask:{msg:_("Loading appointments")+"..."},sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No appointments for today.")+
"</div>",forceFit:!0,enableRowBody:!0,getRowClass:this.applyRowClass},colModel:new Ext.grid.ColumnModel({columns:[{header:_("Subject"),dataIndex:"subject",editable:!1,menuDisabled:!0,renderer:this.subjectRenderer,width:300}]}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this}}]});Zarafa.widgets.folderwidgets.AppointmentsWidget.superclass.constructor.call(this,a)},reloadStore:function(){if(this.folder){var a=new Date,b=a.clearTime().add(Date.DAY,1);this.store.load({folder:this.folder,
params:{restriction:{startdate:a.getTime()/1E3,duedate:b.getTime()/1E3}}})}},updateFilter:function(){this.store.filterBy(function(a){var b=new Date,c=a.get("startdate")||b;a=a.get("duedate")||b;return(c>=b||a>=b)&&c<b.clearTime().add(Date.DAY,1)},this)},subjectRenderer:function(a,b,c,d,e,f){f=new Date;d=(c.get("startdate")||f).format(_("G:i"));e=(c.get("duedate")||f).format(_("G:i"));(c.get("startdate")||f)<f?b.attr="style='color: #888; font-weight: bold;'":b.attr="style='font-weight: bold;'";b="";
f=function(a){return'<img src="'+a.src+'" /> '};!0===c.get("private")&&(b+=f(Zarafa.calendar.ui.IconCache.getPrivateIcon()));!0===c.get("recurring")&&(b=!0===c.get("exception")?b+f(Zarafa.calendar.ui.IconCache.getExceptionIcon()):b+f(Zarafa.calendar.ui.IconCache.getRecurringIcon()));return c.get("alldayevent")?String.format(_("Today: {1} {0}"),Ext.util.Format.htmlEncode(a),b):String.format(_("{1}&minus;{2}: {3} {0}"),Ext.util.Format.htmlEncode(a),d,e,b)},applyRowClass:function(a,b,c,d){(b=a.get("location"))?
(c.body='<table style="width: 100%; padding: 0; border-spacing: 0;">',c.body+=String.format('<tr><td style="width: 100%; font-size: 80%;"><i>{0}</i></td></tr>',Ext.util.Format.htmlEncode(b)),c.body+="</table>"):c.body="";switch(a.get("busystatus")){case Zarafa.core.mapi.BusyStatus.FREE:return"today-item today-free";case Zarafa.core.mapi.BusyStatus.TENTATIVE:return"today-item today-tentative";case Zarafa.core.mapi.BusyStatus.BUSY:return"today-item today-busy";case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:return"today-item today-outofoffice";
default:return"today-item today-unknown"}},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);var d;this.folder&&(b=container.getContextByFolder(this.folder))&&(d=b.getModel());Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),model:d})},onRowDblClick:function(a,b,c){a=a.getSelectionModel().getSelected();Ext.isEmpty(a)||a.isRecurringOccurence()&&(a=a.convertToOccurenceRecord());Zarafa.core.data.UIFactory.openViewRecord(a)}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"appointments",displayName:_("Today's Appointments"),iconPath:"plugins/folderwidgets/resources/images/appointments.png",widgetConstructor:Zarafa.widgets.folderwidgets.AppointmentsWidget}))});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.MailWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.mail.MailStore;b.setDefaultSort(b.defaultSortInfo.field,b.defaultSortInfo.direction);b.setRestriction({search:Zarafa.core.data.RestrictionFactory.dataResBitmask("0x00E070003",Zarafa.core.mapi.Restrictions.BMR_EQZ,Zarafa.core.mapi.MessageFlags.MSGFLAG_READ)});b.isAdvanceSearchStore=function(){return!0};Ext.applyIf(a,{height:200,autoScroll:!0,layout:"fit",
folderType:"inbox",store:b,items:[{xtype:"zarafa.gridpanel",id:"unread-mail-widget",store:b,border:!0,loadMask:{msg:_("Loading mail")+"..."},sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No unread mail.")+"</div>",forceFit:!0,enableRowBody:!0,rowSelectorDepth:15,getRowClass:this.viewConfigGetRowClass},colModel:new Ext.grid.ColumnModel({columns:[{header:_("From"),dataIndex:"sent_representing_name",menuDisabled:!0,renderer:Ext.util.Format.htmlEncode},
{header:_("Received"),dataIndex:"message_delivery_time",editable:!1,menuDisabled:!0,renderer:Zarafa.common.ui.grid.Renderers.datetime}]}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this}}]});Zarafa.widgets.folderwidgets.MailWidget.superclass.constructor.call(this,a)},updateFilter:function(){this.store.filterBy(function(a){return!a.isRead()},this)},viewConfigGetRowClass:function(a,b,c,d){b=a.isRead()?"mail_read":"mail_unread";var e;c.body='<table cellspacing="0" cellpadding="0" border="0" style="width: 100%;">';
c.body+="<tr>";d={};e=Zarafa.common.ui.grid.Renderers.subject(a.get("subject"),d,a);c.body+=String.format('<td style="width: 100%"><div class="grid_compact grid_compact_left grid_compact_subject_cell {0}" style="height: 24px;">{1}</div></td>',d.css,e);d={};e=Zarafa.common.ui.grid.Renderers.attachment(a.get("hasattach"),d,a);c.body+=String.format('<td style="width: 24px"><div class="grid_compact {0}" style="height: 24px; width: 24px;">{1}</div></td>',d.css,e);d={};e=Zarafa.common.ui.grid.Renderers.importance(a.get("importance"),
d,a);c.body+=String.format('<td style="width: 24px"><div class="grid_compact {0}" style="height: 24px; width: 24px;">{1}</div></td>',d.css,e);c.body+="</tr></table>";return"x-grid3-row-expanded "+b},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);var d;this.folder&&(b=container.getContextByFolder(this.folder))&&(d=b.getModel());Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),model:d})},onRowDblClick:function(a,b,c){Zarafa.core.data.UIFactory.openViewRecord(a.getSelectionModel().getSelected())}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"mail",displayName:_("Unread Mail"),iconPath:"plugins/folderwidgets/resources/images/mail.png",widgetConstructor:Zarafa.widgets.folderwidgets.MailWidget}))});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.TasksWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.task.TaskStore;b.setRestriction({search:Zarafa.core.data.RestrictionFactory.dataResProperty("status",Zarafa.core.mapi.Restrictions.RELOP_NE,Zarafa.core.mapi.TaskStatus.COMPLETE)});b.isAdvanceSearchStore=function(){return!0};Ext.applyIf(a,{height:200,autoScroll:!0,layout:"fit",folderType:"task",store:b,items:[{xtype:"zarafa.gridpanel",store:b,border:!0,
loadMask:{msg:_("Loading tasks")+"..."},sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No tasks.")+"</div>",forceFit:!0},colModel:new Ext.grid.ColumnModel({columns:[{header:_("Owner"),dataIndex:"owner",menuDisabled:!0,renderer:Ext.util.Format.htmlEncode},{header:_("Subject"),dataIndex:"subject",editable:!1,menuDisabled:!0,renderer:Ext.util.Format.htmlEncode}]}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,
scope:this}}]});Zarafa.widgets.folderwidgets.TasksWidget.superclass.constructor.call(this,a)},updateFilter:function(){this.store.filterBy(function(a){return a.get("status")!=Zarafa.core.mapi.TaskStatus.COMPLETE},this)},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);var d;this.folder&&(b=container.getContextByFolder(this.folder))&&(d=b.getModel());Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),model:d})},onRowDblClick:function(a,
b,c){Zarafa.core.data.UIFactory.openViewRecord(a.getSelectionModel().getSelected())}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"tasks",displayName:_("Tasks"),iconPath:"plugins/folderwidgets/resources/images/tasks.png",widgetConstructor:Zarafa.widgets.folderwidgets.TasksWidget}))});//# sourceMappingURL=folderwidgets.js.map
