Ext.namespace("Zarafa");
Ext.apply(Zarafa,{isReady:false,readyEvent:new Ext.util.Event,onReady:function(a,b,c){if(this.isReady){this.readyEvent.addListener(a,b,c);this.readyEvent.fire();this.readyEvent.clearListeners()}else this.readyEvent.addListener(a,b,c)},fireReady:function(){this.isReady=true;this.readyEvent.fire();this.readyEvent.clearListeners()},inside:function(a,b,c){return b>=a.x&&b<a.x+a.width&&c>=a.y&&c<a.y+a.height},supportsCanvas:function(){if(!container.getSettingsModel().get("zarafa/v1/main/use_canvas_rendering"))return false;if(!Ext.isDefined(this.browserSupportsCanvas))this.browserSupportsCanvas=
!!document.createElement("canvas").getContext;return this.browserSupportsCanvas},resizeCanvas:function(a,b,c){a.setWidth(a.dom.width=b);a.setHeight(a.dom.height=c)},generateId:function(a){for(var b="",c=0;c<a;c++)b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random()*62));return b}});Ext.apply(String.prototype,{trim:function(){var a=/^[\s\xA0]+|[\s\xA0]+$/g;return function(){return this.replace(a,"")}}()});
if(!Object.keys)Object.keys=function(){var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if(typeof e!=="object"&&typeof e!=="function"||e===null)throw new TypeError("Object.keys called on non-object");var f=[];for(var g in e)a.call(e,g)&&f.push(g);if(b)for(g=0;g<d;g++)a.call(e,c[g])&&f.push(c[g]);return f}}();
Ext.apply(Date.prototype,{add:function(a,b){var c=this.clone();if(!a||b===0)return c;switch(a.toLowerCase()){case Date.HOUR:b*=60;case Date.MINUTE:b*=60;case Date.SECOND:b*=1E3;case Date.MILLI:c=new Date(c.getTime()+b);break;case Date.DAY:c.setDate(this.getDate()+b);break;case Date.MONTH:var d=this.getDate();if(d>28)d=Math.min(d,this.getFirstDateOfMonth().add(Date.MONTH,b).getLastDateOfMonth().getDate());c.setDate(d);c.setMonth(this.getMonth()+b);break;case Date.YEAR:c.setFullYear(this.getFullYear()+
b);break}return c},toUTC:function(a){if(a===true)a=new Date(Date.UTC(this.getFullYear(),this.getMonth(),this.getDate()));else{a=new Date(this.getTime()+this.getTimezoneOffset()*6E4);a.setMilliseconds(a.getMilliseconds()+Date.getDSTDiff(a,this))}return a},fromUTC:function(a){return a===true?new Date(this.toDateString()):new Date(this.getTime()-this.getTimezoneOffset()*6E4)},getNextWeekDay:function(a){var b=this.getDay();return Ext.isDefined(a)?a<b?this.add(Date.DAY,7-(b-a)):this.add(Date.DAY,a-b):
this.add(Date.DAY,1)},getPreviousWeekDay:function(a){var b=this.getDay();return Ext.isDefined(a)?a<=b?this.add(Date.DAY,a-b):this.add(Date.DAY,-7+(a-b)):this.add(Date.DAY,-1)},clearTime:function(a){if(a)return this.clone().clearTime();this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this},clearSeconds:function(a){if(a)return this.clone().clearSeconds();this.setSeconds(0);this.setMilliseconds(0);return this},round:function(a,b){switch(a){case Date.MILLI:var c=this.getMilliseconds();
c%b>0&&this.setMilliseconds(c-c%b+(c%b>=b/2)*b);break;case Date.SECOND:c=this.getSeconds();c%b>0&&this.setSeconds(c-c%b+(c%b>=b/2)*b);this.setMilliseconds(0);break;case Date.MINUTE:c=this.getMinutes();c%b>0&&this.setMinutes(c-c%b+(c%b>=b/2)*b);this.setSeconds(0);this.setMilliseconds(0);break;case Date.HOUR:c=this.getHours();c%b>0&&this.setHours(c-c%b+(c%b>=b/2)*b);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);break}return this},ceil:function(a,b){switch(a){case Date.MILLI:var c=this.getMilliseconds();
c%b>0&&this.setMilliseconds(c-c%b+b);break;case Date.SECOND:c=this.getSeconds();c%b>0&&this.setSeconds(c-c%b+b);this.setMilliseconds(0);break;case Date.MINUTE:c=this.getMinutes();c%b>0&&this.setMinutes(c-c%b+b);this.setSeconds(0);this.setMilliseconds(0);break;case Date.HOUR:c=this.getHours();c%b>0&&this.setHours(c-c%b+b);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);break}return this},floor:function(a,b){switch(a){case Date.MILLI:var c=this.getMilliseconds();c%b>0&&this.setMilliseconds(c-
c%b);break;case Date.SECOND:c=this.getSeconds();c%b>0&&this.setSeconds(c-c%b);this.setMilliseconds(0);break;case Date.MINUTE:c=this.getMinutes();c%b>0&&this.setMinutes(c-c%b);this.setSeconds(0);this.setMilliseconds(0);break;case Date.HOUR:c=this.getHours();c%b>0&&this.setHours(c-c%b);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);break}return this},getWeekOfMonth:function(){var a=this.getWeekOfYear(),b=this.add(Date.DAY,-(this.getDate()-1)).getWeekOfYear();return a-b+1}});
Ext.apply(Date,{dayInMillis:864E5,getDSTDiff:function(a,b){return(a.getTimezoneOffset()-b.getTimezoneOffset())*60*1E3},diff:function(a,b,c){var d=b.getTime(),e=c.getTime();switch(a){case Date.DAY:e+=Date.getDSTDiff(b,c);d/=24;e/=24;case Date.HOUR:d/=60;e/=60;case Date.MINUTE:d/=60;e/=60;case Date.SECOND:d/=1E3;e/=1E3;case Date.MILLI:default:break}return d-e},getTimezoneStruct:function(){var a=[],b=0,c=new Date,d={};c.setMonth(0);c.setDate(1);c.setMinutes(0);c.setSeconds(0);c.setMilliseconds(0);c=
c.getNextWeekDay(0);c.setHours(5);for(var e=c.getTimezoneOffset(),f=0;f<52;f++){if(c.getTimezoneOffset()!=e){a[b]={switchweek:c.getWeekOfMonth(),switchmonth:c.getMonth(),offset:c.getTimezoneOffset()};b++;if(b==2)break;e=c.getTimezoneOffset()}c=c.add(Date.DAY,7)}if(b==0)d={timezone:c.getTimezoneOffset(),timezonedst:0,dststartday:0,dststartweek:0,dststartmonth:0,dststarthour:0,dstendday:0,dstendweek:0,dstendmonth:0,dstendhour:0};else if(b!=1)if(b==2)d=a[0].offset<a[1].offset?{timezone:a[1].offset,timezonedst:a[0].offset-
a[1].offset,dststartday:0,dststartweek:a[0].switchweek==4?5:a[0].switchweek,dststartmonth:a[0].switchmonth+1,dststarthour:2,dstendday:0,dstendweek:a[1].switchweek==4?5:a[1].switchweek,dstendmonth:a[1].switchmonth+1,dstendhour:3}:{timezone:a[0].offset,timezonedst:a[1].offset-a[0].offset,dststartday:0,dststartweek:a[1].switchweek==4?5:a[1].switchweek,dststartmonth:a[1].switchmonth+1,dststarthour:2,dstendday:0,dstendweek:a[0].switchweek==4?5:a[0].switchweek,dstendmonth:a[0].switchmonth+1,dstendhour:3};
return d}});Ext.apply(Array.prototype,{clone:function(){return this.slice(0)},equals:function(a){if(this===a)return true;if(this.length!==a.length)return false;for(var b=0,c=a.length;b<c;b++)if(this[b]!==a[b])return false;return true},clear:function(){this.splice(0,this.length)}});Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.Widget=Ext.extend(Ext.ux.Portlet,{guid:undefined,hasConfig:false,widgetPanel:undefined,constructor:function(a){a=a||{};var b=a.tools||[];a.hasConfig===true&&b.push({id:"gear",handler:this.config,scope:this});b.push({id:"close",scope:this,handler:this.close});Ext.applyIf(a,{anchor:"100%",frame:true,collapsible:true,draggable:{ddGroup:"dd.widget"},tools:b});Zarafa.core.ui.widget.Widget.superclass.constructor.call(this,a)},isWidgetVisible:function(){return this.isVisible()&&!this.widgetPanel.collapsed},
onRender:function(){Zarafa.core.ui.widget.Widget.superclass.onRender.apply(this,arguments);this.widgetPanel=this.findParentByType("zarafa.widgetpanel")},get:function(a){return container.getSettingsModel().get(Zarafa.core.ui.widget.Widget.settingsPath(this.guid,a))},set:function(a,b){container.getSettingsModel().set(Zarafa.core.ui.widget.Widget.settingsPath(this.guid,a),b)},close:function(){this.widgetPanel.destroyWidget(this)},config:Ext.emptyFn});Ext.reg("zarafa.widget",Zarafa.core.ui.widget.Widget);
Zarafa.core.ui.widget.Widget.settingsPath=function(a,b){return("zarafa/v1/widgets/"+a+"/"+b).replace(/(\/)+/,"/")};Ext.namespace("Zarafa.core.ui.menu");
Zarafa.core.ui.menu.ConditionalMenu=Ext.extend(Ext.menu.Menu,{records:undefined,constructor:function(a){Ext.applyIf(a,{xtype:"zarafa.conditionalmenu"});Ext.apply(this,a);Zarafa.core.ui.menu.ConditionalMenu.superclass.constructor.call(this,a);this.mon(this,"beforeshow",this.onMenuBeforeShow,this)},onMenuBeforeShow:function(a){var b=this.records,c=true,d=-1;a.items.each(function(h,i){if(h.isXType("zarafa.conditionalitem")){if(Ext.isFunction(h.beforeShow))h.beforeShow.call(h.scope||h,h,b);Ext.isDefined(h.menu)&&
this.onMenuBeforeShow(h.menu)}if(h.isXType("menuseparator")){h.setVisible(c===false);if(c===false)c=true}else if(h.hidden===false){c=false;d=i}},this);if(d===-1)return false;for(var e=d,f=a.items.getCount();e<f;e++){var g=a.items.items[e];g.isXType("menuseparator")&&g.setVisible(false)}if(d===-1)return false}});Ext.reg("zarafa.conditionalmenu",Zarafa.core.ui.menu.ConditionalMenu);Ext.namespace("Zarafa.core.ui.menu");
Zarafa.core.ui.menu.ConditionalItem=Ext.extend(Ext.menu.Item,{hideOnDisabled:true,emptySelectOnly:false,nonEmptySelectOnly:false,singleSelectOnly:false,multiSelectOnly:false,constructor:function(a){Ext.applyIf(a,{xtype:"zarafa.conditionalitem"});Ext.applyIf(this,a);Zarafa.core.ui.menu.ConditionalItem.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.core.ui.menu.ConditionalItem.superclass.initComponent.apply(this,arguments);if(this.hideOnDisabled){this.enable=this.show;this.disable=
this.hide}},onRender:function(){Zarafa.core.ui.menu.ConditionalItem.superclass.onRender.apply(this,arguments);var a=this.getRecords();if(this.emptySelectOnly)Ext.isDefined(a)&&(!Ext.isArray(a)||a.length>0)?this.setDisabled(true):this.setDisabled(false);if(this.nonEmptySelectOnly)Ext.isDefined(a)&&Ext.isArray(a)&&a.length==0?this.setDisabled(true):this.setDisabled(false);if(this.singleSelectOnly)!Ext.isDefined(a)||Ext.isArray(a)&&a.length!=1?this.setDisabled(true):this.setDisabled(false);if(this.multiSelectOnly)!Ext.isDefined(a)||
!Ext.isArray(a)||a.length==1?this.setDisabled(true):this.setDisabled(false)},beforeShow:Ext.emptyFn,getRecords:function(){return this.getRootMenu().records},getRootMenu:function(){var a=this.parentMenu;if(!a&&this.ownerCt instanceof Ext.menu.Menu)a=this.ownerCt;for(;a&&(Ext.isDefined(a.parentMenu)||a.ownerCt instanceof Ext.menu.Menu);)a=a.parentMenu||a.ownerCt;return a}});Ext.reg("zarafa.conditionalitem",Zarafa.core.ui.menu.ConditionalItem);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.View=Ext.extend(Ext.util.Observable,{baseCls:undefined,itemCls:undefined,themeCls:undefined,parentView:undefined,container:undefined,children:undefined,elements:undefined,rendered:false,isDestroyed:false,constructor:function(a){Ext.apply(this,a);this.addEvents("beforedestroy","destroy");Zarafa.core.ui.View.superclass.constructor.call(this,a);this.init()},init:function(){this.children=[];this.elements=[];Ext.isDefined(this.parentView)&&this.parentView.addChildView(this)},getBaseClassName:function(){return this.itemCls?
this.baseCls+"-"+this.itemCls:this.baseCls},getClassName:function(a,b,c){var d=this.getBaseClassName(),e=this.baseCls;Ext.isEmpty(this.themeCls)||(e+=" "+this.baseCls+"-"+this.themeCls);e+=" "+d+"-"+a;if(Ext.isDefined(b)&&!Ext.isArray(b))b=[b];if(!Ext.isEmpty(b))for(var f=0,g=b.length;f<g;f++)e+=" "+d+"-"+a+"-"+b[f];if(Ext.isDefined(c)&&!Ext.isArray(c))c=[c];if(!Ext.isEmpty(c)){f=0;for(g=c.length;f<g;f++)e+=" "+d+"-"+c[f]}return e},createDiv:function(a,b,c){return this.create("div",a,b,c)},create:function(a,
b,c,d){a=Ext.isObject(a)?a:{tag:a};Ext.applyIf(a,{cls:d||this.baseCls});b=Ext.get(b).createChild(a);if(this[c])if(Ext.isArray(this[c]))this[c].push(b);else this[c]=[this[c],b];else this[c]=b;this.elements.push(b);return b},remove:function(a){a=Ext.get(a);this.elements.remove(a);a.remove()},getContainer:function(){return this.container},renderChildren:function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].render(a||this.container)},render:function(a){this.container=a;this.rendered=
true},layoutChildren:function(){for(var a=0,b=this.children.length;a<b;a++)this.children[a].layout()},onBeforeLayout:Ext.emptyFn,onLayout:Ext.emptyFn,onAfterLayout:Ext.emptyFn,layout:function(){this.onBeforeLayout();this.onLayout();this.onAfterLayout()},destroyChildren:function(){for(var a=0,b=this.children.length;a<b;a++)this.children[a].destroy()},destroy:function(){if(!this.isDestroyed){if(this.fireEvent("beforedestroy",this)!==false){for(var a=0,b=this.elements.length;a<b;a++)this.elements[a].remove();
this.destroyChildren();this.fireEvent("destroy",this);this.purgeListeners()}this.isDestroyed=true}},setParentView:function(a){this.parentView=a},addChildView:function(a){a.setParentView(this);this.children.push(a);return a},removeChildView:function(a,b){this.children.remove(a);a.setParentView(undefined);b&&a.destroy()},purgeListeners:Ext.Container.prototype.purgeListeners,clearMons:Ext.Container.prototype.clearMons,createMons:Ext.Container.prototype.createMons,mon:Ext.Container.prototype.mon,mun:Ext.Container.prototype.mun});
Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.ToolbarButton=Ext.extend(Ext.Button,{emptySelectOnly:false,nonEmptySelectOnly:false,singleSelectOnly:false,multiSelectOnly:false,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.toolbarbutton"});Ext.apply(this,a);Zarafa.core.ui.ToolbarButton.superclass.constructor.call(this,a);a=container.getCurrentContext().getModel();if(Ext.isDefined(a)){this.onRecordSelectionChange(a,a.getSelectedRecords());this.mon(a,"recordselectionchange",this.onRecordSelectionChange,this)}},onRecordSelectionChange:function(a,
b){if(this.emptySelectOnly)Ext.isDefined(b)&&(!Ext.isArray(b)||b.length>0)?this.setDisabled(true):this.setDisabled(false);else if(this.nonEmptySelectOnly)!Ext.isDefined(b)||Ext.isArray(b)&&b.length==0?this.setDisabled(true):this.setDisabled(false);else if(this.singleSelectOnly)!Ext.isDefined(b)||Ext.isArray(b)&&b.length!=1?this.setDisabled(true):this.setDisabled(false);else if(this.multiSelectOnly)!Ext.isDefined(b)||!Ext.isArray(b)||b.length==1?this.setDisabled(true):this.setDisabled(false)}});
Ext.reg("zarafa.toolbarbutton",Zarafa.core.ui.ToolbarButton);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.Toolbar=Ext.extend(Ext.Toolbar,{initialSizeCorrectionDone:false,constructor:function(a){Ext.apply(this,a,{xtype:"zarafa.toolbar",enableOverflow:true});Zarafa.core.ui.Toolbar.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterLayout,this)},addItems:function(a,b){var c=[];if(Ext.isDefined(a))Ext.isEmpty(a)||(c=c.concat(a));if(Ext.isString(b)){var d=container.populateInsertionPoint(b);Ext.isEmpty(d)||(c=c.concat(d))}c=Ext.flatten(c);this.add(c)},onAfterLayout:function(){if(!this.initialSizeCorrectionDone&&
this.el.getHeight()>0){var a=[],b=0;this.items.each(function(c){if(c.isXType("buttongroup")){c=c.body;b=Math.max(b,c.getHeight());a.push(c)}});if(b>0){Ext.each(a,function(c){c.setHeight(b)},this);this.initialSizeCorrectionDone=true}}}});Ext.reg("zarafa.toolbar",Zarafa.core.ui.Toolbar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.SwitchViewContentContainer=Ext.extend(Ext.Container,{lazyItems:undefined,autoClean:true,constructor:function(a){a=a||{};if(Ext.isEmpty(a.items)&&!Ext.isEmpty(a.lazyItems))a.items=[a.lazyItems[0]];if(Ext.isEmpty(a.activeItem))a.activeItem=a.items[0].id;Ext.applyIf(a,{autoDestroy:true});this.addEvents("switchview");Zarafa.core.ui.SwitchViewContentContainer.superclass.constructor.call(this,a)},onLayout:function(){Zarafa.core.ui.SwitchViewContentContainer.superclass.onLayout.apply(this,
arguments);var a=this.getActiveItem();Ext.isFunction(a.doLayout)&&a.doLayout()},switchView:function(a){var b=this.getActiveItem(),c=this.findById(a);if(!(!Ext.isDefined(c)||b==c)){var d=this.getLayout();if(Ext.isString(d))this.activeItem=a;else this.getLayout().setActiveItem(a);this.fireEvent("switchview",this,c,b);if(this.autoClean===true&&b&&b!=this.getActiveItem()){this.remove(b);delete b}}},getActiveItem:function(){var a=this.getLayout();return Ext.isString(a)?this.activeItem:this.getLayout().activeItem},
findById:function(a){var b=Zarafa.core.ui.SwitchViewContentContainer.superclass.findById.call(this,a);if(!b){b=this.findBy(function(c){return c.id===a});Ext.isEmpty(b)||(b=b[0])}return b},findBy:function(a,b){var c=Zarafa.core.ui.SwitchViewContentContainer.superclass.findBy.apply(this,arguments);if(Ext.isDefined(this.lazyItems))for(var d=0;d<this.lazyItems.length;d++){var e=this.lazyItems[d];if(a.call(b||e,e,this)===true){e=Ext.create(Ext.apply({},e));this.add(e);c.push(e)}}return c}});
Ext.reg("zarafa.switchviewcontentcontainer",Zarafa.core.ui.SwitchViewContentContainer);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.PreviewPanel=Ext.extend(Ext.Panel,{model:undefined,recordComponentPlugin:undefined,ignoreUpdates:undefined,record:undefined,showLoadMask:true,loadMask:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",stateful:true,minWidth:200,minHeight:200});a.tbar=Ext.applyIf(a.tbar||{},{cls:"zarafa-previewpanel-toolbar",xtype:"zarafa.toolbar",hidden:true,items:[]});var b=[container.populateInsertionPoint("previewpanel.toolbar.left",this,a.model),{xtype:"tbfill"},a.tbar.items,
container.populateInsertionPoint("previewpanel.toolbar.right",this,a.model)];a.tbar.items=Ext.flatten(b);a.plugins=Ext.value(a.plugins,[]);a.plugins.push({ptype:"zarafa.recordcomponentplugin",useShadowStore:true,ignoreUpdates:a.ignoreUpdates,allowWrite:false,record:a.record});a.plugins.push({ptype:"zarafa.markasreadplugin"});Zarafa.core.ui.PreviewPanel.superclass.constructor.call(this,a);this.model&&this.mon(this.model,"previewrecordchange",this.onPreviewRecordChange,this);this.mon(this,"openrecord",
this.onOpenRecord,this);this.mon(this,"exceptionrecord",this.onExceptionRecord,this);this.mon(this,"show",this.onPreviewPanelShow,this);this.mon(this,"expand",this.onPreviewPanelShow,this)},setRecord:function(a){if(this.record=a)a.isOpened()||this.showLoadMask();for(var b=0;b<this.toolbars.length;b++)this.toolbars[b].setVisible(a);this.recordComponentPlugin&&this.recordComponentPlugin.setRecord(a)},showRecordInPanel:function(a){var b;if(this.record!==a)if(!(this.record&&a&&this.record.equals(a))){if(Ext.isDefined(a))if((b=
container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.preview"],a))&&this.get(0)instanceof b){this.setRecord(a);return}this.removeAll();this.hideLoadMask();b&&this.add(new b);this.setRecord(a);this.doLayout()}},removeAll:function(){var a=[];this.getTopToolbar()&&a.concat(this.getTopToolbar().removeAll.apply(this,arguments));this.getBottomToolbar()&&a.concat(this.getBottomToolbar().removeAll.apply(this,arguments));a.concat(Zarafa.core.ui.PreviewPanel.superclass.removeAll.apply(this,
arguments));return a},onPreviewRecordChange:function(a,b){this.isVisible()&&this.showRecordInPanel(b)},showLoadMask:function(a){if(this.showLoadMask!==false){if(!this.loadMask)this.loadMask=new Zarafa.common.ui.LoadMask(this.el);a?this.loadMask.showError():this.loadMask.show()}},hideLoadMask:function(){this.showLoadMask!==false&&this.loadMask&&this.loadMask.hide()},onOpenRecord:function(){this.hideLoadMask()},onExceptionRecord:function(){this.showLoadMask(true)},onPreviewPanelShow:function(){if(Ext.isDefined(this.model)){var a=
this.model.getPreviewRecord();Ext.isDefined(a)&&this.showRecordInPanel(a)}},getStateName:function(){return"preview/"+Zarafa.core.ui.PreviewPanel.superclass.getStateName.call(this)}});Ext.reg("zarafa.previewpanel",Zarafa.core.ui.PreviewPanel);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MainViewport=Ext.extend(Ext.Viewport,{navigationPanel:undefined,widgetPanel:undefined,contentPanel:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",items:[{xtype:"container",layout:"border",cls:"zarafa-panel-body",border:false,items:[this.createTopbarContainer(),this.createNavigationPanel(),this.createTodayPanel(),this.createContentContainer(),this.createBottomBar()]}]});Zarafa.core.ui.MainViewport.superclass.constructor.call(this,a)},createNavigationPanel:function(){return this.navigationPanel=
new Zarafa.core.ui.NavigationPanel({region:"west",stateful:true,statefulName:"hierarchybar",statefulRelativeDimensions:false})},getNavigationPanel:function(){return this.navigationPanel},createTodayPanel:function(){return this.widgetPanel=new Zarafa.core.ui.widget.WidgetPanel({region:"east",title:_("Today"),numColumns:1,stateful:true,statefulName:"todaybar",statefulRelativeDimensions:false,settingsPath:"zarafa/v1/contexts/today/sidebar",collapsed:true})},getWidgetPanel:function(){return this.widgetPanel},
createContentContainer:function(){return this.contentPanel=new Zarafa.core.ui.ContextContainer({name:"main.content",region:"center"})},getContentPanel:function(){return this.contentPanel},createTopbarContainer:function(){return new Ext.Container({name:"main.topbar",region:"north",layout:"border",height:84,items:[new Zarafa.core.ui.MainTabBar({name:"main.maintabbar",region:"center",height:28}),new Zarafa.core.ui.MainToolbar({name:"main.toolbar",region:"south",height:56})]})},createBottomBar:function(){return new Ext.Container({name:"main.bottombar",
region:"south",ref:"bottomBar",height:8,cls:"zarafa-bottombar"})}});Ext.namespace("Zarafa.core.ui");Zarafa.core.ui.MainViewSidebar=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);Ext.applyIf(a,{cls:"zarafa-context-mainpanel",border:false,collapsible:true,collapsed:false,split:true,width:250,minSize:150,maxSize:400});Zarafa.core.ui.MainViewSidebar.superclass.constructor.call(this,a)},getStateName:function(){return"sidebars/"+Zarafa.core.ui.MainViewSidebar.superclass.getStateName.call(this)}});
Ext.reg("mainviewsidebar",Zarafa.core.ui.MainViewSidebar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MainTabBar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.maintabbar",cls:"zarafa-maintabbar",defaultType:"zarafa.maintab",defaults:{height:20}});Zarafa.core.ui.MainTabBar.superclass.constructor.call(this,a);this.initBar()},initBar:function(){var a=container.populateInsertionPoint("main.maintabbar.left",this)||[],b=container.populateInsertionPoint("main.maintabbar.right",this)||[];a=Zarafa.core.Util.sortArray(a,"ASC","tabOrderIndex");b=Zarafa.core.Util.sortArray(b,
"DESC","tabOrderIndex");var c={xtype:"tbtext",width:"auto",cls:"zarafa-maintabbar-logintext",text:String.format(_("You are logged on as {0}"),container.getUser().getDisplayName())},d={text:_("Logout"),handler:this.onLogoutButton};this.add(a,{xtype:"tbfill"},c,b,d)},onLogoutButton:function(){container.logout()}});Ext.reg("zarafa.maintabbar",Zarafa.core.ui.MainTabBar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MainTab=Ext.extend(Ext.Button,{context:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.maintab",cls:"zarafa-maintab",buttonActiveCls:"zarafa-maintabbar-maintab-active",handler:this.selectContext});Zarafa.core.ui.MainTab.superclass.constructor.call(this,a);this.mon(container,"contextswitch",this.onContextSwitch,this);this.mon(this,"render",this.onRenderButton,this)},onContextSwitch:function(a,b,c){this.setContextActivityState(c)},onRenderButton:function(){this.setContextActivityState(container.getCurrentContext())},
setContextActivityState:function(a){this.context==a.getName()?this.addClass(this.buttonActiveCls):this.removeClass(this.buttonActiveCls)},selectContext:function(){var a=container.getContextByName(this.context);if(a)if(a!==container.getCurrentContext()){var b=a.getModel(),c;if(b){c=b.getFolders();if(Ext.isEmpty(c))c=b.getDefaultFolder()}container.switchContext(a,c);container.getNavigationBar().setShowFolderList(false)}}});Ext.reg("zarafa.maintab",Zarafa.core.ui.MainTab);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.Dialog=Ext.extend(Ext.Container,{title:undefined,standalone:false,width:800,height:550,browser:false,defaultTitle:undefined,alwaysUseDefaultTitle:true,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.inputautofocusplugin");Ext.applyIf(a,{xtype:"zarafa.dialog",stateful:true});Zarafa.core.ui.Dialog.superclass.constructor.call(this,a);if(this.extWindow){this.relayEvents(this.extWindow,["beforeshow","show","beforeclose","close","beforehide","hide"]);
this.extWindow.saveState=function(){this.saveState()}.createDelegate(this)}this.browserWindow&&this.relayEvents(this.browserWindow,["beforeshow","show","beforeclose","close","beforehide","hide"]);this.initializeChildComponent(this);Ext.isDefined(this.title)&&this.setTitle(this.title);if(!this.standalone){Zarafa.core.data.DialogMgr.register(this);this.mon(this,"close",this.onDialogClose,this)}},initializeChildComponent:function(a){if(!Ext.isEmpty(a)){var b=function(c){this.initializeChildComponent(c)};
if(Ext.isArray(a))Ext.each(a,b,this);else if(a instanceof Ext.util.MixedCollection)a.each(b,this);else if(a.isXType("container")){a.dialog=this;Ext.isEmpty(a.toolbars)||this.initializeChildComponent(a.toolbars);Ext.isEmpty(a.items)||this.initializeChildComponent(a.items)}}},close:function(){if(this.extWindow)this.extWindow.close();else this.browserWindow&&this.browserWindow.close()},focus:function(){if(this.extWindow)this.extWindow.toFront(true);else this.browserWindow&&this.browserWindow.focus()},
setTitle:function(a){if(this.extWindow)this.extWindow.setTitle(a);else if(this.browserWindow)document.title=a},isBrowser:function(){return this.browserWindow?true:false},isModal:function(){if(this.extWindow)return this.extWindow.modal;else if(this.browserWindow)return this.browserWindow.modal},getInitialConfig:function(){if(this.extWindow)return this.extWindow.initialConfig;else if(this.browserWindow)return this.browserWindow.initialConfig},getStateName:function(){return"dialogs/"+Zarafa.core.ui.Dialog.superclass.getStateName.call(this)},
getState:function(){var a=Zarafa.core.ui.Dialog.superclass.getState.call(this)||{};Ext.apply(a,{browser:this.browser});return Ext.apply(a,this.getSize())},onDialogClose:function(){Zarafa.core.data.DialogMgr.unregister(this)}});Zarafa.core.ui.Dialog.register=function(a,b){Ext.reg(b,a);a.create=function(c){Zarafa.core.ui.Dialog.create(b,c)}};
Zarafa.core.ui.Dialog.createBrowser=function(a,b){b=Ext.applyIf(b||{},{toolbar:0,scrollbars:0,location:0,status:true,menubar:0,resizable:true});var c=[];for(var d in b)c.push(d+"="+b[d]);c=c.join(",");d="window_"+a.replace(/\./,"_")+Math.round(Math.random()*1E6);var e=window.open("index.php?load=dialog",d,c);e.initialConfig=b;var f=setInterval(function(){if(e.document&&e.document.getElementById("initScript")){b.browserWindow=e;e.initDialog(a,b);clearInterval(f)}},50)};
Zarafa.core.ui.Dialog.createWindow=function(a,b){var c=new Ext.Window({layout:"fit",modal:b.modal,constrainHeader:true,headerCfg:{tag:"div",cls:"zarafa-window-header x-window-header x-unselectable x-window-draggable"}});c.on("afterrender",function(e){Ext.isDefined(e.header)&&Ext.isElement(e.header.dom)&&Ext.DomHelper.append(e.header.dom,"<span class='fade'>&nbsp;</span>")});var d=Ext.create(Ext.apply(b,{extWindow:c}),a);c.add(d);c.show()};
Zarafa.core.ui.Dialog.create=function(a,b){b=b||{};b.browser?Zarafa.core.ui.Dialog.createBrowser(a,b):Zarafa.core.ui.Dialog.createWindow(a,b)};Zarafa.core.ui.Dialog.openDialogComponent=function(a,b,c){a=container.getSharedComponent(a,b);Zarafa.core.ui.Dialog.openDialog(a,b,c)};Zarafa.core.ui.Dialog.openDialog=function(a,b,c){if(a){c=c||{};c.record=b;a.create(c)}};Ext.reg("zarafa.dialog",Zarafa.core.ui.Dialog);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.ContextNavigationPanel=Ext.extend(Ext.Panel,{context:null,constructor:function(a){a=a||{};Ext.applyIf(a,{border:false,autoScroll:true,layout:"table",layoutConfig:{columns:1,tableAttrs:{style:{width:"100%"}}},defaults:{border:false,autoScroll:false,headerCfg:{cls:"zarafa-hierarchy-header x-panel-header"},defaults:{cls:"zarafa-context-navigation-item-body"}}});Zarafa.core.ui.ContextNavigationPanel.superclass.constructor.call(this,a)},getContext:function(){return this.context||false}});
Ext.reg("zarafa.contextnavigation",Zarafa.core.ui.ContextNavigationPanel);Ext.namespace("Zarafa.core.ui");Zarafa.core.ui.ButtonGroup=Ext.extend(Ext.ButtonGroup,{constructor:function(a){Ext.apply(this,a,{xtype:"zarafa.buttongroup"});Zarafa.core.ui.ButtonGroup.superclass.constructor.call(this,a)},hasVisibleButtons:function(){var a=this.items.getRange();if(!Ext.isEmpty(a))for(var b=0;b<a.length;b++)if(a[b].hidden===false)return true;return false}});Ext.reg("zarafa.buttongroup",Zarafa.core.ui.ButtonGroup);
Ext.namespace("Zarafa.core.data");
Zarafa.core.data.StatefulObservable=Ext.extend(Ext.util.Observable,{stateful:false,stateId:undefined,stateEvents:undefined,statefulName:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.core.data.StatefulObservable.superclass.constructor.call(this,a);if(this.stateful!==false){if(!this.stateId)this.stateId=Ext.id(null,"state-");Ext.state.Manager.register(this);this.initStateEvents()}},getStateName:function(){return this.statefulName},getStateId:function(){return this.stateId||this.id},initStateEvents:function(){if(this.stateEvents)for(var a=
0,b;b=this.stateEvents[a];a++)this.on(b,this.saveState,this,{delay:100})},initState:function(){if(Ext.state.Manager){var a=this.getStateId();if(a)if(a=Ext.state.Manager.get(a))if(this.fireEvent("beforestaterestore",this,a)!==false){this.applyState(Ext.apply({},a));this.fireEvent("staterestore",this,a)}}},applyState:function(a){a&&Ext.apply(this,a)},getState:function(){return null},saveState:function(){if(Ext.state.Manager&&this.stateful!==false){var a=this.getStateId();if(a){var b=this.getState();
if(this.fireEvent("beforestatesave",this,b)!==false){Ext.state.Manager.set(a,b);this.fireEvent("statesave",this,b)}}}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.SettingsStateProvider=Ext.extend(Ext.state.Provider,{basePath:"zarafa/v1/state",constructor:function(a){Ext.apply(this,a);Zarafa.core.data.SettingsStateProvider.superclass.constructor.call(this,a)},getStatePath:function(a){return this.basePath+"/"+a.getStateName()},encodeValue:function(a,b,c){if(Ext.isArray(a))for(var d=0,e=a.length;d<e;d++)a[d]=this.encodeValue(a[d],b,c);else if(Ext.isObject(a))for(d in a)a[d]=this.encodeValue(a[d],d,c);else if((b==="height"||b==="width")&&c.statefulRelativeDimensions===
true)a=this.scaleSizeToPercentage(c,a,b);return a},decodeValue:function(a,b,c){if(Ext.isArray(a))for(var d=0,e=a.length;d<e;d++)a[d]=this.decodeValue(a[d],b,c);else if(Ext.isObject(a))for(d in a)a[d]=this.decodeValue(a[d],d,c);else if((b==="height"||b==="width")&&a<=1)a=this.scaleSizeToBody(c,a,b);return a},scaleSizeToPercentage:function(a,b,c){c=Ext.util.Format.capitalize(c);b=parseFloat((b/window["inner"+c]).toFixed(2));return Math.min(b,1)},scaleSizeToBody:function(a,b,c){c=Ext.util.Format.capitalize(c);
var d=a["min"+c],e=a["max"+c];b=Math.round(b*window["inner"+c]);if(a.minSize||a.maxSize)b=Math.min(Math.max(b,a.minSize||0),a.maxSize||b);else if(d||e)b=Math.min(Math.max(b,d||0),e||b);return b},set:function(a,b){var c=Ext.state.Manager.getComponent(a);container.getSettingsModel().set(this.getStatePath(c),this.encodeValue(b,undefined,c));this.fireEvent("statechange",this,a,b)},get:function(a,b){var c=Ext.state.Manager.getComponent(a),d=container.getSettingsModel().get(this.getStatePath(c),true);if(Ext.isObject(b))d=
Ext.apply(b,d);return this.decodeValue(d,undefined,c)},clear:function(a){var b=Ext.state.Manager.getComponent(a);container.getSettingsModel().restore(this.getStatePath(b));this.fireEvent("statechange",this,a,null)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.RecordFactory={definitions:{},getMessageClassParent:function(a){var b=a.lastIndexOf(".");if(b>0)return a.substr(0,b)},getMessageClassParentDefinition:function(a){a=this.getMessageClassParent(a);if(Ext.isDefined(a))return this.getRecordDefinitionByMessageClass(a)},createRecordDefinition:function(a,b,c){b=new Zarafa.core.data.RecordDefinition({base:undefined,parent:b,createDefaults:c});return this.definitions[a]=b},getRecordDefinitionByCustomType:function(a){var b=this.definitions[a];
if(Ext.isDefined(b))return b;return this.createRecordDefinition(a,undefined)},getRecordDefinitionByObjectType:function(a){var b=this.definitions[a];if(Ext.isDefined(b))return b;return this.createRecordDefinition(a,undefined,{object_type:a})},getRecordDefinitionByMessageClass:function(a){var b=a.toUpperCase(),c=this.definitions[b],d=undefined;if(Ext.isDefined(c))return c;d=this.getMessageClassParentDefinition(b);return this.createRecordDefinition(b,d,{message_class:a})},createRecordObjectByCustomType:function(a,
b,c){return this.getRecordDefinitionByCustomType(a).createRecord(b,c)},createRecordObjectByObjectType:function(a,b,c){return this.getRecordDefinitionByObjectType(a).createRecord(b,c)},createRecordObjectByMessageClass:function(a,b,c){return this.getRecordDefinitionByMessageClass(a).createRecord(b,c)},createRecordObjectByRecordData:function(a,b){if(Ext.isEmpty(a.message_class)){if(!Ext.isEmpty(a.object_type))return this.createRecordObjectByObjectType(a.object_type,a,b)}else return this.createRecordObjectByMessageClass(a.message_class,
a,b)},getRecordClassByCustomType:function(a){return this.getRecordDefinitionByCustomType(a).getType()},getRecordClassByObjectType:function(a){return this.getRecordDefinitionByObjectType(a).getType()},getRecordClassByMessageClass:function(a){return this.getRecordDefinitionByMessageClass(a).getType()},getRecordClassByRecordData:function(a){if(Ext.isDefined(a.message_class))return this.getRecordClassByMessageClass(a.message_class);else if(Ext.isDefined(a.object_type))return this.getRecordClassByObjectType(a.object_type)},
setBaseClassToCustomType:function(a,b){this.getRecordDefinitionByCustomType(a).setBaseClass(b)},setBaseClassToObjectType:function(a,b){this.getRecordDefinitionByObjectType(a).setBaseClass(b)},setBaseClassToMessageClass:function(a,b){this.getRecordDefinitionByMessageClass(a).setBaseClass(b)},setSubStoreToCustomType:function(a,b,c){this.getRecordDefinitionByCustomType(a).setSubStore(b,c)},setSubStoreToObjectType:function(a,b,c){this.getRecordDefinitionByObjectType(a).setSubStore(b,c)},setSubStoreToMessageClass:function(a,
b,c){this.getRecordDefinitionByMessageClass(a).setSubStore(b,c)},addFieldToCustomType:function(a,b){this.getRecordDefinitionByCustomType(a).addField(b)},addFieldToObjectType:function(a,b){this.getRecordDefinitionByObjectType(a).addField(b)},addFieldToMessageClass:function(a,b){this.getRecordDefinitionByMessageClass(a).addField(b)},addDefaultValueToCustomType:function(a,b,c){this.getRecordDefinitionByCustomType(a).addDefaultValue(b,c)},addDefaultValueToObjectType:function(a,b,c){this.getRecordDefinitionByObjectType(a).addDefaultValue(b,
c)},addDefaultValueToMessageClass:function(a,b,c){this.getRecordDefinitionByMessageClass(a).addDefaultValue(b,c)},addListenerToCustomType:function(a,b,c,d,e){this.getRecordDefinitionByCustomType(a).on(b,c,d,e)},addListenerToObjectType:function(a,b,c,d,e){this.getRecordDefinitionByObjectType(a).on(b,c,d,e)},addListenerToMessageClass:function(a,b,c,d,e){this.getRecordDefinitionByMessageClass(a).on(b,c,d,e)}};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.RecordDefinition=Ext.extend(Ext.util.Observable,{parent:undefined,type:undefined,base:undefined,subStores:undefined,fields:undefined,defaults:undefined,createDefaults:undefined,constructor:function(a){a=Ext.applyIf(a,{subStores:{},fields:[],defaults:{}});Ext.apply(this,a);this.addEvents(["createphantom","createrecord"]);Zarafa.core.data.RecordDefinition.superclass.constructor.call(this,a)},createRecord:function(a,b){var c=new (this.getType())(Ext.apply({},this.createDefaults),b,this);
c.phantom&&this.applyDefaultValues(c);Ext.isEmpty(a)||Ext.apply(c.data,a);this.applyFieldDefaultValues(c);c.phantom?this.fireEvent("createphantom",c):this.fireEvent("createrecord",c);return c},getType:function(){if(!Ext.isDefined(this.type)){var a=this.getBaseClass(),b=this.getFields();this.type=Zarafa.core.data.Record.create(b,a)}return this.type},setBaseClass:function(a){this.base=a},getBaseClass:function(){return Ext.isDefined(this.base)?this.base:Ext.isDefined(this.parent)?this.parent.getBaseClass():
Ext.data.Record},setSubStore:function(a,b){this.subStores=Ext.value(this.subStores,{});this.subStores[a]=b},getSubStores:function(){var a={};if(Ext.isDefined(this.parent))a=this.parent.getSubStores();return Ext.apply({},this.subStores||{},a)},addField:function(a){Ext.isArray(a)||(a=[a]);this.fields=this.fields.concat(a)},getFields:function(){var a=[];if(Ext.isDefined(this.parent))a=this.parent.getFields();return a.concat(this.fields)},addDefaultValue:function(a,b){this.defaults[Ext.isString(a)?a:
a.name]=b},applyFieldDefaultValues:function(a){a.fields.each(function(b){if(Ext.isDefined(b.defaultValue)&&!Ext.isDefined(a.data[b.name]))a.data[b.name]=b.defaultValue})},applyDefaultValues:function(a){Ext.isDefined(this.parent)&&this.parent.applyDefaultValues(a);for(var b in this.defaults)a.data[b]=this.defaults[b]},fireEvent:function(){Ext.isDefined(this.parent)&&this.parent.fireEvent.apply(this.parent,arguments);Zarafa.core.data.RecordDefinition.superclass.fireEvent.apply(this,arguments)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.Record={create:function(a,b){var c=Ext.extend(b||Ext.data.Record,{}),d=c.prototype;d.fields=new Ext.util.MixedCollection(false,function(e){return e.name});this.addFields(d,a||[]);c.getField=function(e){return d.fields.get(e)};return c},addFields:function(a,b){for(var c=0,d=b.length;c<d;c++)Ext.isArray(b[c])?this.addFields(a,b[c]):a.fields.add(new Ext.data.Field(b[c]))}};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.Notifications={newMail:"newMail",objectCreated:"objectCreated",objectDeleted:"objectDeleted",objectModified:"objectModified"};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.NotificationResolver=Ext.extend(Ext.util.Observable,{constructor:function(a){a=a||{};Ext.apply(this,a);Zarafa.core.data.NotificationResolver.superclass.constructor.call(this,a)},getHandlerForResponse:function(a,b){var c;if(!Ext.isObject(b))return null;c=a==Zarafa.core.ModuleNames.getListName("hierarchy")?this.getHandlersForIPFResponse(b):this.getHandlersForIPMResponse(b);return Ext.isArray(c)?c.length>1?new Zarafa.core.data.CompositeResponseHandler({handlers:c}):c[0]:c},getHandlersForIPFResponse:function(a){var b=
[],c=[];c=a.folders;if(Ext.isDefined(c)&&!Ext.isEmpty(c.item))b=b.concat(Ext.pluck(c.item,"store_entryid"));c=Zarafa.core.data.IPFStoreMgr.getStoresForStores(b);Ext.isDefined(a.newmail)&&c.push(container.getHierarchyStore());if(Ext.isArray(c)){a=[];b=0;for(var d=c.length;b<d;b++)a.push(new Zarafa.hierarchy.data.HierarchyNotificationResponseHandler({store:c[b],reader:c[b].reader,notifyObject:c[b]}));return a}else return new Zarafa.hierarchy.data.HierarchyNotificationResponseHandler({store:c,reader:c.reader,
notifyObject:c})},getHandlersForIPMResponse:function(a){var b=[],c=a.newobject;if(Ext.isDefined(c)&&Ext.isArray(c.item))b=b.concat(Ext.pluck(c.item,"entryid"));c=a.update;if(Ext.isDefined(c)&&Ext.isArray(c.item))b=b.concat(Ext.pluck(c.item,"parent_entryid"));a=a["delete"];if(Ext.isDefined(a)&&Ext.isArray(a.item))b=b.concat(Ext.pluck(a.item,"parent_entryid"));b=Zarafa.core.data.IPMStoreMgr.getStoresForFolders(b);if(Ext.isArray(b)){a=[];c=0;for(var d=b.length;c<d;c++)a.push(new Zarafa.core.data.IPMNotificationResponseHandler({store:b[c],
reader:b[c].reader,notifyObject:b[c]}));return a}else return new Zarafa.core.data.IPMNotificationResponseHandler({store:b,reader:b.reader,notifyObject:b})}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.NoSyncStore=Ext.extend(Ext.util.Observable,{recordType:undefined,fields:undefined,hasMultiSort:false,sortToggle:undefined,sortField:undefined,sortDir:"ASC",sortInfo:undefined,constructor:function(a){a=a||{};Ext.apply(this,a);if(this.recordType)this.fields=this.recordType.prototype.fields;this.addEvents("add","remove","update","clear");this.sortToggle={};if(this.sortField)this.setDefaultSort(this.sortField,this.sortDir);else this.sortInfo&&this.setDefaultSort(this.sortInfo.field,this.sortInfo.direction);
Zarafa.core.data.NoSyncStore.superclass.constructor.call(this,a);this.initEvents();this.initData()},initData:function(){this.data=new Ext.util.MixedCollection(false);this.data.getKey=function(a){return a.id};this.removed=[];this.modified=[]},initEvents:function(){this.on({scope:this,add:this.createRecords,remove:this.destroyRecord,clear:this.onClear})},destroy:function(){if(!this.isDestroyed){this.clearData();this.data=null;this.purgeListeners();this.isDestroyed=true}},add:function(a){a=[].concat(a);
if(!(a.length<1)){for(var b=0,c=a.length;b<c;b++)a[b].join(this);b=this.data.length;this.data.addAll(a);this.snapshot&&this.snapshot.addAll(a);this.fireEvent("add",this,a,b)}},remove:function(a,b){Ext.isArray(a)&&Ext.each(a,function(d){this.remove(d,b)},this);var c=this.data.indexOf(a);this.snapshot&&this.snapshot.remove(a);if(c>-1){a.join(null);this.data.removeAt(c);this.modified.remove(a);b!==true&&this.fireEvent("remove",this,a,c)}},removeAt:function(a,b){this.remove(this.getAt(a),b)},removeAll:function(a){var b=
[];this.each(function(c){b.push(c)});this.clearData();this.snapshot&&this.snapshot.clear();this.modified=[];this.removed=[];a!==true&&this.fireEvent("clear",this,b)},removeIf:function(a,b){this.each(function(c){if(a.call(b||this,c))this.remove(c)},this)},insert:function(a,b){b=[].concat(b);for(var c=0,d=b.length;c<d;c++){this.data.insert(a,b[c]);b[c].join(this)}this.snapshot&&this.snapshot.addAll(b);this.fireEvent("add",this,b,a)},indexOf:function(a){return this.data.indexOf(a)},indexOfId:function(a){return this.data.indexOfKey(a)},
getAt:function(a){return this.data.itemAt(a)},getRange:function(a,b){return this.data.getRange(a,b)},getCount:function(){return this.data.length},getTotalCount:function(){return this.getCount()},each:function(a,b){this.data.each(a,b)},getModifiedRecords:function(){return this.modified},getRemovedRecords:function(){return this.removed},afterEdit:function(a){this.modified.indexOf(a)==-1&&this.modified.push(a);this.fireEvent("update",this,a,Ext.data.Record.EDIT)},afterReject:function(a){this.modified.remove(a);
this.fireEvent("update",this,a,Ext.data.Record.REJECT)},afterCommit:function(a){this.modified.remove(a);this.fireEvent("update",this,a,Ext.data.Record.COMMIT)},commitChanges:function(){var a=this.modified.slice(0);this.modified=[];for(var b=0,c=a.length;b<c;b++)a[b].commit();this.removed=[]},clearData:function(){this.data.each(function(a){a.join(null)});this.data.clear()},createRecords:function(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].phantom&&b[c].isValid()){b[c].markDirty();this.modified.push(b[c])}},
destroyRecord:function(a,b){this.modified.indexOf(b)!=-1&&this.modified.remove(b);b.phantom||this.removed.push(b)},onClear:function(a,b){Ext.each(b,function(c,d){this.destroyRecord(this,c,d)},this)},getSortState:Ext.data.Store.prototype.getSortState,applySort:Ext.data.Store.prototype.applySort,sortData:Ext.data.Store.prototype.sortData,createSortFunction:Ext.data.Store.prototype.createSortFunction,setDefaultSort:Ext.data.Store.prototype.setDefaultSort,sort:Ext.data.Store.prototype.sort,singleSort:Ext.data.Store.prototype.singleSort,
multiSort:Ext.data.Store.prototype.multiSort,sum:Ext.data.Store.prototype.sum,createFilterFn:Ext.data.Store.prototype.createFilterFn,filter:Ext.data.Store.prototype.filter,filterBy:Ext.data.Store.prototype.filterBy,queryBy:Ext.data.Store.prototype.queryBy,find:Ext.data.Store.prototype.find,findExact:Ext.data.Store.prototype.findExact,findBy:Ext.data.Store.prototype.findBy,getById:Ext.data.Store.prototype.getById,clearFilter:Ext.data.Store.prototype.clearFilter,isFiltered:Ext.data.Store.prototype.isFiltered,
collect:Ext.data.Store.prototype.collect,onMetaChange:Ext.data.Store.prototype.onMetaChange});Ext.namespace("Zarafa.core.data");Ext.data.Api.actions.open="open";
Zarafa.core.data.MAPIStore=Ext.extend(Ext.data.GroupingStore,{persistentFilter:true,filterFn:undefined,filterScope:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{autoSave:false,batch:true});this.addEvents("open");Zarafa.core.data.MAPIStore.superclass.constructor.call(this,a);this.data.getKey=this.getRecordKey;this.initEvents()},initEvents:function(){this.on("beforeload",this.onBeforeLoad,this);this.on("exception",this.onError,this);this.on("add",this.onAdd,this);this.on("remove",this.onRemove,
this);this.on("write",this.onWrite,this)},getRecordKey:Ext.util.MixedCollection.prototype.getKey,isExecuting:function(a){return this.proxy.isExecuting(a)},lastExecutionTime:function(a){return this.proxy.lastExecutionTime(a)},reload:function(a){a=Ext.applyIf(a||{},{reload:true});Zarafa.core.data.MAPIStore.superclass.reload.call(this,a)},save:function(a){if(!Ext.isDefined(a))return Zarafa.core.data.MAPIStore.superclass.save.call(this);Ext.isArray(a)||(a=[a]);if(!this.writer)throw new Ext.data.Store.Error("writer-undefined");
for(var b=[],c=[],d=[],e=[],f={},g=0,h=a.length;g<h;g++){var i=a[g];if(this.removed.indexOf(i)>=0)b.push(i);else if(this.modified.indexOf(i)>=0)if(i.isValid())i.phantom?c.push(i):d.push(i)}b.length>0&&e.push(["destroy",b]);c.length>0&&e.push(["create",c]);d.length>0&&e.push(["update",d]);if(h=e.length){b=++this.batchCounter;for(g=0;g<h;++g){a=e[g];f[a[0]]=a[1]}if(this.fireEvent("beforesave",this,f)!==false){for(g=0;g<h;++g){a=e[g];this.doTransaction(a[0],a[1],b)}return b}}return-1},onBeforeLoad:function(){this.isExecuting("open")&&
this.proxy.cancelRequests("open")},onError:function(a,b,c,d,e){if(!Ext.isEmpty(e.error)){a=String.format(_("{0} Error"),Zarafa.core.ErrorType.getName(e.error.type));container.getNotifier().notify("error.json",a,e.error.info.display_message)}},onAdd:function(a,b){this.setRecordsStore(a,b)},onRemove:function(a,b){this.setRecordsStore(undefined,b)},onWrite:function(a,b,c,d,e){Ext.isArray(e)||(e=[e]);a=0;for(b=e.length;a<b;a++){e[a].clearMessageActions();e[a].clearActionResponse()}},setRecordsStore:function(a,
b){b=Ext.isArray(b)?b:[b];Ext.each(b,function(c){c.join(a)},this)},open:function(a,b){try{return this.execute("open",a,b)}catch(c){this.handleException(c);return false}},onOpenRecords:function(a,b,c){if(a===true&&this.indexOf(b)>-1)try{this.reader.update(b,c);b.afterOpen();this.fireEvent("open",this,b,b)}catch(d){this.handleException(d);Ext.isArray(b)&&this.onOpenRecords(a,b,c)}},getByEntryId:function(a){var b=this.findBy(function(c){return Zarafa.core.EntryId.compareEntryIds(a,c.get("entryid"))});
if(b>=0)return this.getAt(b)},filterBy:function(a,b){this.filterFn=a;this.filterScope=b;Zarafa.core.data.MAPIStore.superclass.filterBy.apply(this,arguments)},clearFilter:function(){delete this.filterFn;delete this.filterScope;Zarafa.core.data.MAPIStore.superclass.clearFilter.apply(this,arguments)},loadRecords:function(a,b){Zarafa.core.data.MAPIStore.superclass.loadRecords.apply(this,arguments);if(this.persistentFilter===true&&!this.isDestroyed&&(!b||b.add!==true))this.filterFn&&this.filterBy(this.filterFn,
this.filterScope)}});Ext.reg("zarafa.mapistore",Zarafa.core.data.MAPIStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.MAPIProxy=Ext.extend(Ext.data.DataProxy,{listModuleName:undefined,itemModuleName:undefined,activeRequestMapping:undefined,lastResponseTime:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.core.data.MAPIProxy.superclass.constructor.call(this,a);this.activeRequestMapping={};this.lastResponseTime={}},isExecuting:function(a){return Ext.isEmpty(a)?!Ext.isEmpty(Object.keys(this.activeRequestMapping)):!Ext.isEmpty(this.activeRequestMapping[a])},addRequestId:function(a,b){if(Ext.isDefined(this.activeRequestMapping[a]))this.activeRequestMapping[a].push(b);
else this.activeRequestMapping[a]=[b]},deleteRequestId:function(a){for(var b in this.activeRequestMapping)if(Ext.isArray(this.activeRequestMapping[b])){this.activeRequestMapping[b].remove(a);Ext.isEmpty(this.activeRequestMapping[b])&&delete this.activeRequestMapping[b]}},cancelRequests:function(a){if(this.activeRequestMapping[a]){for(var b=this.activeRequestMapping[a],c=0,d=b.length;c<d;c++)container.getRequest().cancelActiveRequest(b[c]);delete this.activeRequestMapping[a]}},updateExecutionTimestamp:function(a,
b){this.lastResponseTime[a]=b},lastExecutionTime:function(a){return this.lastResponseTime[a]||0},getListModuleName:function(){return this.listModuleName},getItemModuleName:function(){return this.itemModuleName},getResponseHandlerForRequest:Ext.emptyFn,request:function(a,b,c,d,e,f,g){switch(a){case "update":case "create":this.createUpdateAction(a,b,c,d,e,f,g);break;case "destroy":this.destroyAction(a,b,c,d,e,f,g);break;case "read":this.readAction(a,b,c,d,e,f,g);break;case "open":this.openAction(a,
b,c,d,e,f,g);break}},createUpdateAction:function(a,b,c,d,e,f,g){this.doRequests(g.actionType||Zarafa.core.Actions.save,a,b,c,d,e,f,g)},destroyAction:function(a,b,c,d,e,f,g){this.doRequests(g.actionType||Zarafa.core.Actions["delete"],a,b,c,d,e,f,g)},openAction:function(a,b,c,d,e,f,g){this.doRequests(g.actionType||Zarafa.core.Actions.open,a,b,c,d,e,f,g)},readAction:function(a,b,c,d,e,f,g){g.cancelPreviousRequest===true&&this.cancelRequests(g.actionType);var h=this.getListModuleName(b);a=this.getResponseHandlerForRequest(h,
g.actionType,a,b,c,d,e,f,g);c=container.getRequest().singleRequest(h,g.actionType,c,a);this.addRequestId(g.actionType,c)},doRequests:function(a,b,c,d,e,f,g,h){var i=d.jsonData[e.meta.root];Ext.isArray(c)||(c=[c]);Ext.isArray(i)||(i=[i]);h.cancelPreviousRequest===true&&this.cancelRequests(a);container.getRequest().reset();for(var j=0;j<c.length;j++){var k=c[j],m=i[j],l=this.getItemModuleName(k);k=this.getResponseHandlerForRequest(l,a,b,k,d,e,f,g,h);m=container.getRequest().addRequest(l,a,m,k);this.addRequestId(a,
m)}container.getRequest().send()}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.JsonWriter=Ext.extend(Ext.data.JsonWriter,{constructor:function(a){a=a||{};Ext.applyIf(a,{writeAllFields:false,encode:false});Zarafa.core.data.JsonWriter.superclass.constructor.call(this,a)},renderData:function(a){if(Ext.isArray(a))for(var b=0,c=a.length;b<c;b++)this.renderData(a[b]);else Ext.iterate(a,function(d,e){if(Ext.isDate(e))a[d]=Math.floor(e.getTime()/1E3);Ext.isObject(e)&&this.renderData(e)},this)},render:function(a,b,c){Ext.apply(c,b,a);this.renderData(c);Zarafa.core.data.JsonWriter.superclass.render.call(this,
a,b,c)},openRecord:function(a){return this.toIdHash(a)},createRecord:function(a){return this.toPropHash(a)},updateRecord:function(a){return this.toPropHash(a)},destroyRecord:function(a){return this.toIdHash(a)},toIdHash:function(a,b){var c={};Ext.each(a.getIdProps(),function(d){var e=a.get(d);if(b||Ext.isDefined(e))c[d]=e},this);this.addMessageActionsHash(c,a);return c},toPropHash:function(a){var b=this.toIdHash(a,false);b.props=this.toHash.call(this,a);this.removeIdHashFromProps(b,a);for(var c in a.subStores)if(a.supportsSubStore(c)===
true){var d=a.subStores[c];d&&d.writer&&Ext.apply(b,d.writer.toPropHash(a))}this.addMessageActionsHash(b,a);return b},removeIdHashFromProps:function(a,b){Ext.each(b.getIdProps(),function(c){Ext.isDefined(a.props)&&Ext.isDefined(a.props[c])&&delete a.props[c]},this)},addMessageActionsHash:function(a,b){var c=b.getMessageActions(),d={};if(Ext.isDefined(c)){for(var e in c)if(Ext.isDefined(c[e]))d[e]=c[e];a.message_action=d}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.JsonReader=Ext.extend(Ext.data.JsonReader,{efCache:undefined,dynamicRecord:true,constructor:function(a,b){a=Ext.applyIf(a||{},{totalProperty:"count",root:"item",id:"entryid",idProperty:"entryid"});var c=Ext.isDefined(a.successProperty);Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByMessageClass("IPM"));if(Ext.isDefined(a.dynamicRecord))this.dynamicRecord=a.dynamicRecord;if(this.dynamicRecord!==false)this.efCache={};Zarafa.core.data.JsonReader.superclass.constructor.call(this,
a,b);if(!c)this.getSuccess=function(){return true}},buildExtractors:function(){var a=this.meta;Zarafa.core.data.JsonReader.superclass.buildExtractors.call(this);if(a.id||a.idProperty){var b=this.getId;this.getId=function(c){if(c.props){var d=b(c.props);if(!Ext.isEmpty(d))return d}return b(c)}}},getEfMapping:function(a,b,c){if(Ext.isString(a))a=a.toUpperCase();var d=this.efCache[a];if(!Ext.isDefined(d)){d=[];for(var e=0;e<c;e++){var f=b[e];f=!Ext.isEmpty(f.mapping)?f.mapping:f.name;d.push(this.createAccessor.call(this,
f))}this.efCache[a]=d}return d},extractValues:function(a,b,c){var d={};if(Ext.isDefined(a.props)){d=Ext.apply({},a);d.props=this.extractValues(a.props,b,c);return d}if(this.dynamicRecord==true){c=Zarafa.core.data.RecordFactory.getRecordClassByRecordData(a);if(!Ext.isDefined(c))c=this.recordType;b=c.prototype.fields.items;c=c.prototype.fields.length;this.ef=this.getEfMapping(a.message_class||a.object_type,b,c)}for(var e=0;e<c;e++){var f=b[e],g=this.ef[e](a);if(Ext.isDefined(g))d[f.name]=f.convert(g,
a)}return d},extractData:function(a,b){var c=this instanceof Ext.data.JsonReader?"json":"node",d=[];if(this.isData(a)&&!(this instanceof Ext.data.XmlReader))a=[a];if(b===true)for(var e=0;e<a.length;e++){var f=a[e],g=undefined,h=this.getId(f),i=f.props||f;i={message_class:i.message_class,object_type:i.object_type};if(this.dynamicRecord==true)g=Zarafa.core.data.RecordFactory.createRecordObjectByRecordData(i,h);g||(g=new this.recordType({},h));this.moveIdProperties(f,g.baseIdProperties);i=g.fields;h=
i.items;i=i.length;this.update(g,this.extractValues(f,h,i));g[c]=f;d.push(g)}else for(e=0;e<a.length;e++){f=a[e];c=undefined;if(this.dynamicRecord==true)c=Zarafa.core.data.RecordFactory.getRecordClassByRecordData(f.props||f);if(!c)c=this.recordType;this.moveIdProperties(f,c.prototype.baseIdProperties);i=c.prototype.fields;h=i.items;i=i.length;i=this.extractValues(f,h,i);i[this.meta.idProperty]=this.getId(f.props||f);d.push(i)}return d},moveIdProperties:function(a,b){if(Ext.isEmpty(a))return a;if(Ext.isEmpty(a.props))a.props=
{};var c=this.meta.idProperty;if(c)if(Ext.isDefined(a[c])){a.props[c]=a[c];delete a[c]}b&&Ext.each(b,function(d){if(Ext.isDefined(a[d])){a.props[d]=a[d];delete a[d]}},this);return a},realize:function(a,b){if(Ext.isArray(a))for(var c=a.length-1;c>=0;c--)Ext.isArray(b)?this.realize(a.splice(c,1).shift(),b.splice(c,1).shift()):this.realize(a.splice(c,1).shift(),b);else{if(Ext.isArray(b))b=b.shift();if(!this.isData(b))throw new Ext.data.DataReader.Error("realize",a);a.phantom=false;a._phid=a.id;a.id=
this.getId(b);this.update(a,b)}},update:function(a,b){if(Ext.isArray(a))for(var c=0;c<a.length;c++)Ext.isArray(b)?this.update(a[c],b[c]):this.update(a[c],b);else{if(Ext.isArray(b))b=b.shift();if(this.isData(b)){b=this.moveIdProperties(b,a.baseIdProperties);a.data=Ext.apply(a.data,b.props||b);delete b.props;if(b.action_response){a.action_response=b.action_response;delete b.action_response}Ext.iterate(b,function(d,e){if(Ext.isArray(e)||Ext.isObject(e)){var f;if(a.supportsSubStore(d)){if(f=a.getSubStore(d))f.removeAll();
else f=a.createSubStore(d);if(!Ext.isEmpty(e)){f.loadData(e);f.commitChanges();delete b[d]}}}},this)}a.commit()}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMStoreMgr=Ext.extend(Ext.util.Observable,{IPMStores:undefined,constructor:function(){this.IPMStores=new Ext.util.MixedCollection;this.addEvents(["storeexception","beforerecordsave","afterrecordsave","afterrecordupdate","recordremove","afterrecordwrite"]);Zarafa.core.data.IPMStoreMgr.superclass.constructor.call(this)},register:function(a,b){if(!b){a.on("beforesave",this.onBeforeSave,this);a.on("save",this.onSave,this);a.on("update",this.onUpdate,this);a.on("remove",this.onRemove,
this)}a.on("write",this.onWrite,this);a.on("exception",this.onException,this);this.IPMStores.add(a)},unregister:function(a,b){if(!b){a.un("beforesave",this.onBeforeSave,this);a.un("save",this.onSave,this);a.un("update",this.onUpdate,this);a.un("remove",this.onRemove,this)}a.un("write",this.onWrite,this);a.un("exception",this.onException,this);this.IPMStores.remove(a)},getPropagatableRecords:function(a){var b=[];Ext.isArray(a)||(a=[a]);for(var c=0,d=a.length;c<d;c++){var e=a[c];e instanceof Zarafa.core.data.IPMRecord&&
e.hasEventPropagation()&&b.push(e)}return b},onBeforeSave:function(a,b){var c={};for(var d in b){var e=this.getPropagatableRecords(b[d]);Ext.isEmpty(c)||(c[d]=e)}this.fireEvent("beforerecordsave",a,c)},onSave:function(a,b,c){this.fireEvent("afterrecordsave",a,c)},onUpdate:function(a,b,c){b.hasEventPropagation()&&this.fireEvent("afterrecordupdate",a,b,c)},onRemove:function(a,b){b.hasEventPropagation()&&this.fireEvent("recordremove",a,b)},onWrite:function(a,b,c,d,e){e=this.getPropagatableRecords(e);
Ext.isEmpty(e)||this.fireEvent("afterrecordwrite",a,b,c,d,e)},onException:function(a,b,c,d,e,f){var g=Ext.pluck(this.IPMStores.items,"proxy");Ext.isEmpty(g)||this.fireEvent("storeexception",this.IPMStores.get(g.indexOf(a)),a,b,c,d,e,f)},each:function(){this.IPMStores.each.apply(this,arguments)},getStoresForFolders:function(a){var b=[];Ext.isArray(a)||(a=[a]);if(a[0]instanceof Zarafa.core.data.IPFRecord)a=Ext.pluck(a,"id");this.IPMStores.each(function(c){c.containsFolderInLastLoad(a)&&b.push(c)},this);
return b}});Zarafa.core.data.IPMStoreMgr=new Zarafa.core.data.IPMStoreMgr;Ext.namespace("Zarafa.core.data");Zarafa.core.data.IPMRecipientResolveRecordFields=[{name:"user_name"},{name:"display_name"},{name:"address_type"},{name:"smtp_address"},{name:"email_address"},{name:"entryid"},{name:"object_type",type:"int"},{name:"display_type",type:"int"},{name:"display_type_ex",type:"int"},{name:"message_class"},{name:"store_entryid"},{name:"parent_entryid"}];Zarafa.core.data.IPMRecipientResolveRecord=Ext.data.Record.create(Zarafa.core.data.IPMRecipientResolveRecordFields);
Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPFStoreMgr=Ext.extend(Ext.util.Observable,{IPFStores:undefined,constructor:function(){this.IPFStores=new Ext.util.MixedCollection;this.addEvents(["storeexception","beforerecordsave","afterrecordsave","afterrecordupdate","recordremove","afterrecordwrite"]);Zarafa.core.data.IPFStoreMgr.superclass.constructor.call(this)},register:function(a,b){if(!b){a.on("beforesave",this.onBeforeSave,this);a.on("save",this.onSave,this);a.on("update",this.onUpdate,this);a.on("remove",this.onRemove,
this)}a.on("write",this.onWrite,this);a.on("exception",this.onException,this);this.IPFStores.add(a)},unregister:function(a,b){if(!b){a.un("beforesave",this.onBeforeSave,this);a.un("save",this.onSave,this);a.un("update",this.onUpdate,this);a.un("remove",this.onRemove,this)}a.un("write",this.onWrite,this);a.un("exception",this.onException,this);this.IPFStores.remove(a)},getPropagatableRecords:function(a){var b=[];Ext.isArray(a)||(a=[a]);for(var c=0,d=a.length;c<d;c++){var e=a[c];e instanceof Zarafa.core.data.IPFRecord&&
e.hasEventPropagation()&&b.push(e)}return b},onBeforeSave:function(a,b){var c={};for(var d in b){var e=this.getPropagatableRecords(b[d]);Ext.isEmpty(c)||(c[d]=e)}this.fireEvent("beforerecordsave",a,c)},onSave:function(a,b,c){this.fireEvent("afterrecordsave",a,c)},onUpdate:function(a,b,c){b.hasEventPropagation()&&this.fireEvent("afterrecordupdate",a,b,c)},onRemove:function(a,b){b.hasEventPropagation()&&this.fireEvent("recordremove",a,b)},onWrite:function(a,b,c,d,e){e=this.getPropagatableRecords(e);
Ext.isEmpty(e)||this.fireEvent("afterrecordwrite",a,b,c,d,e)},onException:function(a,b,c,d,e,f){var g=Ext.pluck(this.IPFStores.items,"proxy");Ext.isEmpty(g)||this.fireEvent("storeexception",this.IPFStores.get(g.indexOf(a)),a,b,c,d,e,f)},each:function(){this.IPFStores.each.apply(this,arguments)},getStoresForStores:function(a){var b=[];Ext.isArray(a)||(a=[a]);if(a[0]instanceof Zarafa.core.data.IPFRecord)a=Ext.pluck(a,"id");this.IPFStores.each(function(c){c.containsStoreInLastLoad(a)&&b.push(c)},this);
return b}});Zarafa.core.data.IPFStoreMgr=new Zarafa.core.data.IPFStoreMgr;Ext.namespace("Zarafa.core.data");
Zarafa.core.data.DialogMgr=Ext.extend(Ext.util.Observable,{dialogs:undefined,constructor:function(){this.dialogs=new Ext.util.MixedCollection;this.addEvents(["createdialog","destroydialog"]);Zarafa.core.data.DialogMgr.superclass.constructor.call(this)},register:function(a){a.on("show",this.onDialogShow,this);a.on("hide",this.onDialogHide,this);this.dialogs.add(a)},unregister:function(a){a.un("show",this.onDialogShow,this);a.un("hide",this.onDialogHide,this);this.dialogs.remove(a)},onDialogShow:function(a){this.fireEvent("createdialog",
a)},onDialogHide:function(a){this.fireEvent("destroydialog",a)},getDialogInstances:function(a){return this.dialogs.filterBy(function(b){return b instanceof a})}});Zarafa.core.data.DialogMgr=new Zarafa.core.data.DialogMgr;Ext.namespace("Zarafa.core");
Zarafa.core.Util={sortArray:function(a,b,c){var d=new Ext.util.MixedCollection,e=undefined;d.addAll(a);e=Ext.isFunction(c)?c:Ext.isString(c)?function(f,g){return Zarafa.core.Util.numericComparison(f[c],g[c])}:this.numericComparison;d.sort(b,e);return d.getRange()},numericComparison:function(a,b){return a-b},caseSensitiveComparison:function(a,b){return a>b?1:a<b?-1:0},caseInsensitiveComparison:function(a,b){var c=String(a).toUpperCase(),d=String(b).toUpperCase();return Zarafa.core.Util.caseSensitiveComparison(c,
d)},uniqueArray:function(a,b){var c=new Ext.util.MixedCollection;Ext.each(a,function(d){var e=b?d[b]:d;c.containsKey(e)||c.add(e,d)},this);return c.getRange()},trimStringArray:function(a){var b=a;a=[];for(var c=0,d=b.length;c<d;c++)if(Ext.isArray(b[c]))a.push(Zarafa.core.Util.trimStringArray(b[c]));else Ext.isString(b[c])&&!Ext.isEmpty(b[c].trim())&&a.push(b[c].trim());return a},inArray:function(a,b,c,d){for(var e=0,f=a.length;e<f;e++)if(Ext.isArray(a[e])){if(Zarafa.core.Util.inArray(a[e],b,c,d))return true}else if(b)if(d)if(c){if(a[e].indexOf(b.toLowerCase())!=
-1||b.indexOf(a[e].toLowerCase())!=-1)return true}else{if(a[e].indexOf(b)!=-1)return true}else if(c){if(a[e].toLowerCase()===b.toLowerCase())return true}else if(a[e]===b)return true;return false},applyRecursive:function(a,b,c){if(c)a=Zarafa.core.Util.applyRecursive(a,c);if(a&&b&&(Ext.isObject(b)||Ext.isArray(b)))for(var d in b)a[d]=Ext.isDefined(a[d])&&Ext.isObject(a[d])?Zarafa.core.Util.applyRecursive(a[d],b[d]):Ext.isObject(b[d])?Zarafa.core.Util.applyRecursive({},b[d]):b[d];return a},applyIfRecursive:function(a,
b,c){if(c)a=Zarafa.core.Util.applyIfRecursive(a,c);if(a&&b&&(Ext.isObject(b)||Ext.isArray(b)))for(var d in b)if(Ext.isDefined(a[d])&&Ext.isObject(a[d]))a[d]=Zarafa.core.Util.applyIfRecursive(a[d],b[d]);else if(Ext.isObject(b[d]))a[d]=Zarafa.core.Util.applyIfRecursive({},b[d]);else Ext.isDefined(a[d])||(a[d]=b[d]);return a},flattenObject:function(a,b,c){var d={},e="";if(Ext.isEmpty(c))c="";else e=b;if(Ext.isObject(a))for(var f in a)Ext.apply(d,Zarafa.core.Util.flattenObject(a[f],b,c+e+f));else d[c]=
a;return d},explodeObject:function(a,b){var c={};for(var d in a){for(var e=d.split(b),f=c,g=0,h=e.length-1;g<h;g++){var i=e[g];Ext.isDefined(f[i])||(f[i]={});f=f[i]}f[e[e.length-1]]=a[d]}return c},getCaretPosition:function(a){a=a.dom||a;if(document.selection){a.focus();var b=document.selection.createRange().duplicate();b.moveStart("character",-a.value.length);return b.text.length}else if(a.selectionStart||a.selectionStart=="0")return a.selectionStart},getSelectionRange:function(a){a=a.dom||a;if(document.selection){a.focus();
var b=document.selection.createRange().duplicate(),c=b.text;b.moveStart("character",-a.value.length);return{start:b.text.length,end:b.text.length+c.length}}else if(a.selectionStart||a.selectionStart=="0")return{start:a.selectionStart,end:a.selectionEnd}},setCaretPosition:function(a,b){Zarafa.core.Util.setSelectionRange(a,b,b)},setSelectionRange:function(a,b,c){if((a=a.dom||a)&&typeof a=="object"&&a.setSelectionRange){a.focus();a.setSelectionRange(b,c)}else if(a.createTextRange){a=a.createTextRange();
a.collapse(true);a.moveEnd("character",c);a.moveStart("character",b);a.select()}},textboxReplaceSelection:function(a,b){if(a&&typeof a=="object"){if(document.selection){var c=document.selection.createRange();c.text=b;c.collapse(true);c.select()}else if(a.selectionStart||a.selectionStart=="0"){c=a.selectionStart;a.value=a.value.substring(0,c)+b+a.value.substring(a.selectionEnd,a.value.length);a.setSelectionRange(c+b.length,c+b.length)}a.focus()}},validateEmailAddress:function(a){var b=RegExp(/^([^<]*<){0,1}(([a-z0-9\.\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,5})+)>{0,1}$|^\[[^\]]+\]$/i);
return Ext.isString(a)&&a.length>0?b.test(a):false},objToArray:function(a){var b=[];if(Ext.isArray(a))return a;if(!Ext.isObject(a))return b;Ext.iterate(a,function(c,d){b.push(d)},this);return b},mergeListeners:function(a,b,c){a=Ext.value(a,{});var d=b.scope||a.scope;for(var e in b)if(e!=="scope"){var f=b[e].createDelegate(d);a[e]=Ext.isDefined(a[e])?c!==false?a[e].createInterceptor(f):a[e].createSequence(f):f}return a}};Ext.namespace("Zarafa.core");
Zarafa.core.ResponseRouter=Ext.extend(Ext.util.Observable,{responseHandlers:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{responseHandlers:{}});this.addEvents("beforereceive","afterreceive","receiveexception","response");Ext.apply(this,a);Zarafa.core.ResponseRouter.superclass.constructor.call(this,a)},addRequestResponseHandler:function(a,b){this.responseHandlers[a]=b},getRequestResponseHandler:function(a){var b=this.responseHandlers[a];this.removeRequestResponseHandler(a);return b},removeRequestResponseHandler:function(a){delete this.responseHandlers[a]},
getNotificationResponseHandler:function(a,b){return container.getNotificationResolver().getHandlerForResponse(a,b)},receive:function(a){this.fireEvent("beforereceive",a);this.processResponse(a);this.fireEvent("afterreceive",a)},receiveFailure:function(a,b){this.fireEvent("receiveexception",a,b);Ext.isObject(a)&&Ext.iterate(a.zarafa,function(c,d){Ext.iterate(d,function(e){e=this.getRequestResponseHandler(e);Ext.isEmpty(e)||e.responseFailure(b)},this)},this)},resolveResponseHandlers:function(a){var b=
[],c=[];Ext.iterate(a,function(d,e){Ext.iterate(e,function(f,g){var h={moduleName:d,moduleId:f,moduleData:g};h.handler=this.getRequestResponseHandler(f);if(Ext.isEmpty(h.handler)){h.handler=this.getNotificationResponseHandler(d,g);Ext.isEmpty(h.handler)||c.push(h)}else b.push(h)},this)},this);return b.concat(c)},handleResponse:function(a,b,c,d,e){var f=true;if(a.start(b,c,d,e)!==false){Ext.isObject(d)&&Ext.iterate(d,function(g,h){if(a.handle(g,h)===false)f=false},this);a.done(f)}},processResponse:function(a){if(Ext.isEmpty(a.zarafa.error)){var b=
(new Date).getTime();a=this.resolveResponseHandlers(a.zarafa);for(var c=0,d=a.length;c<d;c++){var e=a[c],f=e.moduleName,g=e.moduleId,h=e.moduleData;e=e.handler;this.fireEvent("response",f,g,h,b)!==false&&this.handleResponse(e,f,g,h,b)}}else if((b=a.zarafa.error)&&b.info){a=String.format(_("{0} Error"),Zarafa.core.ErrorType.getName(b.type));container.getNotifier().notify("error.json",a,b.info.display_message)}}});Ext.namespace("Zarafa.core");
if(!window.XMLHttpRequest)window.XMLHttpRequest=function(){if(window.ActiveXObject)for(var a=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0"],b=0;b<a.length;b++)try{return new ActiveXObject(a[b])}catch(c){}};
Zarafa.core.Request=Ext.extend(Ext.util.Observable,function(){var a=0,b=undefined,c=[],d=[],e=undefined;return{url:"zarafa.php",subSystemPrefix:"webapp",asynchronous:true,requestHeaders:{},constructor:function(f){Ext.apply(this,f);e=this.subSystemPrefix+"_"+(new Date).getTime();this.addEvents("beforesend","aftersend");Zarafa.core.Request.superclass.constructor.call(this,f)},setRequestHeader:function(f,g){this.requestHeaders[f]=g},setAsynchronous:function(f){this.asynchronous=f},getRequestId:function(f){return(f||
"z-gen")+ ++a},cancelActiveRequest:function(f){if(d.indexOf(f)>=0||c.indexOf(f)>=0)container.getResponseRouter().addRequestResponseHandler(f,new Zarafa.core.data.DummyResponseHandler)},activateQueuedRequests:function(){d=d.concat(c);c=[]},sendData:function(f,g){var h=new XMLHttpRequest,i=c;if(!container.isParalyzed()){var j=g||this.url;j+="?subsystem="+e;h.open("POST",j,this.asynchronous);h.setRequestHeader("Content-Type","application/json; charset=utf-8;");Ext.iterate(this.requestHeaders,function(m,
l){h.setRequestHeader(m,l)},this);h.onreadystatechange=function(){this.stateChange(h,i)}.createDelegate(this);if(this.fireEvent("beforesend",this,h)!==false){h.requestData=f;this.activateQueuedRequests();h.send(f);try{this.asynchronous==false&&h.onreadystatechange==null&&this.stateChange(h,i)}catch(k){this.stateChange(h,i)}this.fireEvent("aftersend",this,h)}}},stateChange:function(f,g){var h=container.getResponseRouter(),i;if(!container.isParalyzed())if(f.readyState==4){i=0;for(var j=g.length;i<j;i++)d.remove(g[i]);
if(f.status!=200)h.receiveFailure(Ext.decode(f.requestData),f);else if(f.responseText){i=Ext.decode(f.responseText);Ext.isEmpty(i)||Ext.isEmpty(i.zarafa)?h.receiveFailure(Ext.decode(f.requestData),f):h.receive(i)}else h.receiveFailure(Ext.decode(f.requestData),f)}},reset:function(){d=[];c=[];b={zarafa:{}}},addRequest:function(f,g,h,i){if(Ext.isEmpty(b))throw"Request object not initialised. Call reset() first";var j=this.getRequestId(f);c.push(j);Ext.isDefined(i)&&container.getResponseRouter().addRequestResponseHandler(j,
i);h=Ext.value(h,{});Ext.isDefined(b.zarafa[f])||(b.zarafa[f]={});Ext.isDefined(b.zarafa[f][j])||(b.zarafa[f][j]={});b.zarafa[f][j][g]=h;return j},send:function(f){if(Ext.isEmpty(b))throw"Request object not initialised. Call reset() first";if(Ext.isEmpty(c))throw"No requests have been added. Use addRequest()";this.sendData(Ext.encode(b),f);b=undefined},singleRequest:function(f,g,h,i){this.reset();f=this.addRequest(f,g,h,i);this.send();return f}}}());Ext.namespace("Zarafa.core");
Zarafa.core.ModuleNames={ADDRESSBOOK:{list:"addressbooklistmodule",item:"addressbookitemmodule"},"IPM.APPOINTMENT":{list:"appointmentlistmodule",item:"appointmentitemmodule"},"IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}":{list:"appointmentlistmodule",item:"appointmentitemmodule"},"IPM.TASK":{list:"tasklistmodule",item:"taskitemmodule"},"IPM.CONTACT":{list:"contactlistmodule",item:"contactitemmodule"},"IPM.DISTLIST":{list:"contactlistmodule",item:"contactitemmodule"},HIERARCHY:{list:"hierarchymodule",
item:"hierarchymodule"},SETTINGS:{list:"settingsmodule"},"IPM.NOTE":{list:"maillistmodule",item:"createmailitemmodule"},"IPM.STICKYNOTE":{list:"stickynotelistmodule",item:"stickynoteitemmodule"},FREEBUSY:{list:"freebusymodule"},BUSYTIME:{list:"busytimelistmodule"},SUGGESTEMAILADDRESS:{list:"suggestemailaddressmodule",item:"suggestemailaddressmodule"},REMINDER:{list:"reminderlistmodule",item:"reminderlistmodule"},DELEGATES:{list:"delegatesmodule",item:"delegatesmodule"},getModule:function(a,b){a=a.toUpperCase();
var c=this[a];if(!c&&b===true){var d=a.lastIndexOf(".");if(d>0){a=a.substr(0,d);c=this.getModule(a,b)}}return c},getItemName:function(a,b){var c=this.getModule(a,b);if(c)return c.item},getListName:function(a,b){var c=this.getModule(a,b);if(c)return c.list}};Ext.namespace("Zarafa.core");
Zarafa.core.MessageClass={isClass:function(a,b,c){if(Ext.isEmpty(a))return false;a=a.toUpperCase();if(Ext.isArray(b)){for(var d=0,e=b.length;d<e;d++)if(this.isClass(a,b[d],c))return true;return false}return c===true?a.search(b.toUpperCase())==0:a==b.toUpperCase()},isContainerClassCompatible:function(a,b){a=a.toUpperCase();b=b.toUpperCase();if(Ext.isEmpty(b))return true;switch(a){case "IPM.APPOINTMENT":case "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}":return Zarafa.core.ContainerClass.isClass(b,
"IPF.Appointment",true);case "IPM.STICKYNOTE":return Zarafa.core.ContainerClass.isClass(b,"IPF.StickyNote",true);case "IPM.CONTACT":case "IPM.DISTLIST":return Zarafa.core.ContainerClass.isClass(b,"IPF.Contact",true);case "IPM.TASK":return Zarafa.core.ContainerClass.isClass(b,"IPF.Task",true);case "IPM.NOTE":case "REPORT.IPM":case "IPM.SCHEDULE":case "IPM.TASKREQUEST":return this.isClass(b,"IPF.Note",true)&&!this.isClass(b,"IPF.Note.OutlookHomepage",true)}var c=a.lastIndexOf(".");if(c>0){a=a.substr(0,
c);return this.isContainerClassCompatible(a,b)}return false},getDefaultFolderTypeFromMessageClass:function(a){a=a.toUpperCase();switch(a){case "IPM.APPOINTMENT":case "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}":return"calendar";case "IPM.STICKYNOTE":return"note";case "IPM.CONTACT":case "IPM.DISTLIST":return"contact";case "IPM.TASK":return"task";case "IPM.NOTE":case "REPORT.IPM":case "IPM.SCHEDULE":case "IPM.TASKREQUEST":return"inbox"}var b=a.lastIndexOf(".");if(b>0){a=a.substr(0,b);return this.getDefaultFolderTypeFromMessageClass(a)}return""}};
Ext.namespace("Zarafa.core");
Zarafa.core.HTMLParser=function(){var a=/<style[^>]*>[\s\S]*?<\/style[^>]*>/gim,b=/<script[^>]*>[\s\S]*?<\/script[^>]*>/gim,c=/<br\s*?\/*?>/gim,d=/\r{0,1}\n/gim;return{stripStyles:function(e){return!e?e:String(e).replace(a,"")},stripScripts:function(e){return!e?e:String(e).replace(b,"")},br2nl:function(e){return Ext.isEmpty(e)?"":e.replace(c,"\n")},nl2br:function(e){return Ext.isEmpty(e)?"":e.replace(d,"<br />")},convertPlainToHTML:function(e){e=Zarafa.core.HTMLParser.entityEncode(e,"ENT_NOQUOTES");
e='<pre wrap style="white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">'+e+"</pre>";e=e.replace(XRegExp("(?<prefix>^|[^\\p{L}])(?<word>\\*+[\\p{L}, ,\t,0-9]+\\*+)(?<postfix>[^\\p{L}]|$)","gi"),function(f){return f.prefix+"<strong>"+f.word+"</strong>"+f.postfix});e=e.replace(XRegExp("(?<prefix>^|[^\\p{L}])(?<word>_+[\\p{L}, ,\t,0-9]+_+)(?<postfix>[^\\p{L}]|$)","gi"),function(f){return f.prefix+'<span style="text-decoration: underline">'+
f.word+"</span>"+f.postfix});e=e.replace(/\b((?:http|ftp)s?:\/\/|www.)([\w\.\-]+)\.(\w{2,6})(\/[\w\/\-\_\.\,\?\=\&\!\:\;\%\#\|]+)*\b/ig,'<a href="$&" target="_blank">$&</a>');e=e.replace(/\b[\w\.\-\+\"\\\$\!\%\(\)]+@[\w\!\$\&\*\-\=\^\`\|\~\#\%\'\+\/\?\_\{\}\(\)\.]+\.(\w{2,6})\b/ig,'<a href="mailto:$&">$&</a>');e=e.replace(/(<a href\=\"www)/ig,'<a href="http://www');return e=Zarafa.core.HTMLParser.nl2br(e)},convertHTMLToPlain:function(e){e=Zarafa.core.HTMLParser.br2nl(e);e=e.replace(/<[\/]?(?:select)[^>]*>/gim,
"\n");e=e.replace(/<[\/]?(?:option)[^>]*>/gim,"\t");e=e.replace(/<(?:hr)[^>]*>/gim,"\n-----------\n");e=e.replace(/<[\/]?(?:h[123456]|div|p|pre|title)[^>]*>/gim,"\n\n");e=e.replace(/<[\/]?(?:ul|ol|dl|dt|textarea|img)[^>]*>/gim,"\n");e=e.replace(/<[\/]?(?:dd|li)[^>]*>/gim,"\t");e=e.replace(/<[\/]?(?:table)[^>]*>/gim,"\n\n");e=e.replace(/<[\/]?(?:caption|tr)[^>]*>/gim,"\n");e=e.replace(/<[\/]?(?:th|td)[^>]*>/gim,"\t");e=e.replace(/<a[^>]* href=[\'\"]?([^\s\'\">]*)[^>]*>([\s\S]*?)<\/a[^>]*>/gim,"$2 &lt;$1&gt;");
e=Zarafa.core.HTMLParser.stripStyles(e);e=Zarafa.core.HTMLParser.stripScripts(e);e=e.replace(/<!--[\s\S]*?--\>/gim,"");e=Zarafa.core.HTMLParser.stripUnwantedTags(e);e=Ext.util.Format.htmlDecode(e);e=e.replace(/[&][#0-9a-z]*[;]/gim,"");e=e.replace(/\s*?\n(\s*?\n)+/gm,"\n\n");return e=e.replace(/\t*$/gm,"")},stripUnwantedTags:function(e,f){var g=e.match(/(<\/?[^>]+>)/gi),h="",i="",j=-1,k=false;f||(f=[]);if(g&&g.length>0)for(var m=0,l=g.length;m<l;m++){h=g[m].toString();k=false;for(var n=0,o=f.length;n<
o;n++){i=f[n].toLowerCase();j=-1;if(j!==0)j=h.toLowerCase().indexOf("<"+i+">");if(j!==0)j=h.toLowerCase().indexOf("<"+i+" ");if(j!==0)j=h.toLowerCase().indexOf("</"+i);if(j==0){k=true;break}}if(k!==true)e=e.split(h).join("")}return e},hasExternalContent:function(e){if(!Ext.isString(e))return false;if(e.search(/(src|background)\s*=\s*([\'\"])*?\s*(https*:[^ \'\"]*)([\'\"])*/igm)!==-1)return true;if(e.search(/(style)\s*=(\S*)(url)\(([\'\"]*?)\s*(https*:.*[^\'\"])([\'\"]*?)\)/igm)!==-1)return true;return false},
blockExternalContent:function(e){if(!Ext.isString(e))return e;if(!Zarafa.core.HTMLParser.hasExternalContent(e))return e;e=e.replace(/(src|background)\s*=\s*([\'\"])*?\s*(https*:[^ \'\"]*)\s*([\'\"])*/igm,"$1=$2$4");return e=e.replace(/(style)\s*=(\S*)(url)\(([\'\"]*?)\s*(https*:.*[^\'\"])([\'\"]*?)\)/igm,"$1=$2$3($4$6)")},getHTMLTranslationTable:function(e,f){e||(e="HTML_SPECIALCHARS");f||(f="ENT_COMPAT");var g={};g["38"]="&amp;";if(e==="HTML_ENTITIES"){g["94"]="&circ;";g["126"]="&tilde;";g["130"]=
"&sbquo;";g["131"]="&fnof;";g["132"]="&bdquo;";g["133"]="&hellip;";g["134"]="&dagger;";g["135"]="&Dagger;";g["136"]="&circ;";g["137"]="&permil;";g["138"]="&Scaron;";g["139"]="&lsaquo;";g["140"]="&OElig;";g["145"]="&lsquo;";g["146"]="&rsquo;";g["147"]="&ldquo;";g["148"]="&rdquo;";g["149"]="&bull;";g["150"]="&ndash;";g["151"]="&mdash;";g["152"]="&tilde;";g["153"]="&trade;";g["154"]="&scaron;";g["155"]="&rsaquo;";g["156"]="&oelig;";g["159"]="&Yuml;";g["160"]="&nbsp;";g["161"]="&iexcl;";g["162"]="&cent;";
g["163"]="&pound;";g["164"]="&curren;";g["165"]="&yen;";g["166"]="&brvbar;";g["167"]="&sect;";g["168"]="&uml;";g["169"]="&copy;";g["170"]="&ordf;";g["171"]="&laquo;";g["172"]="&not;";g["173"]="&shy;";g["174"]="&reg;";g["175"]="&macr;";g["176"]="&deg;";g["177"]="&plusmn;";g["178"]="&sup2;";g["179"]="&sup3;";g["180"]="&acute;";g["181"]="&micro;";g["182"]="&para;";g["183"]="&middot;";g["184"]="&cedil;";g["185"]="&sup1;";g["186"]="&ordm;";g["187"]="&raquo;";g["188"]="&frac14;";g["189"]="&frac12;";g["190"]=
"&frac34;";g["191"]="&iquest;";g["192"]="&Agrave;";g["193"]="&Aacute;";g["194"]="&Acirc;";g["195"]="&Atilde;";g["196"]="&Auml;";g["197"]="&Aring;";g["198"]="&AElig;";g["199"]="&Ccedil;";g["200"]="&Egrave;";g["201"]="&Eacute;";g["202"]="&Ecirc;";g["203"]="&Euml;";g["204"]="&Igrave;";g["205"]="&Iacute;";g["206"]="&Icirc;";g["207"]="&Iuml;";g["208"]="&ETH;";g["209"]="&Ntilde;";g["210"]="&Ograve;";g["211"]="&Oacute;";g["212"]="&Ocirc;";g["213"]="&Otilde;";g["214"]="&Ouml;";g["215"]="&times;";g["216"]=
"&Oslash;";g["217"]="&Ugrave;";g["218"]="&Uacute;";g["219"]="&Ucirc;";g["220"]="&Uuml;";g["221"]="&Yacute;";g["222"]="&THORN;";g["223"]="&szlig;";g["224"]="&agrave;";g["225"]="&aacute;";g["226"]="&acirc;";g["227"]="&atilde;";g["228"]="&auml;";g["229"]="&aring;";g["230"]="&aelig;";g["231"]="&ccedil;";g["232"]="&egrave;";g["233"]="&eacute;";g["234"]="&ecirc;";g["235"]="&euml;";g["236"]="&igrave;";g["237"]="&iacute;";g["238"]="&icirc;";g["239"]="&iuml;";g["240"]="&eth;";g["241"]="&ntilde;";g["242"]=
"&ograve;";g["243"]="&oacute;";g["244"]="&ocirc;";g["245"]="&otilde;";g["246"]="&ouml;";g["247"]="&divide;";g["248"]="&oslash;";g["249"]="&ugrave;";g["250"]="&uacute;";g["251"]="&ucirc;";g["252"]="&uuml;";g["253"]="&yacute;";g["254"]="&thorn;";g["255"]="&yuml;";g["264"]="&#264;";g["265"]="&#265;";g["338"]="&OElig;";g["339"]="&oelig;";g["352"]="&Scaron;";g["353"]="&scaron;";g["372"]="&#372;";g["373"]="&#373;";g["374"]="&#374;";g["375"]="&#375;";g["376"]="&Yuml;";g["402"]="&fnof;";g["710"]="&circ;";
g["732"]="&tilde;";g["913"]="&Alpha;";g["914"]="&Beta;";g["915"]="&Gamma;";g["916"]="&Delta;";g["917"]="&Epsilon;";g["918"]="&Zeta;";g["919"]="&Eta;";g["920"]="&Theta;";g["921"]="&Iota;";g["922"]="&Kappa;";g["923"]="&Lambda;";g["924"]="&Mu;";g["925"]="&Nu;";g["926"]="&Xi;";g["927"]="&Omicron;";g["928"]="&Pi;";g["929"]="&Rho;";g["931"]="&Sigma;";g["932"]="&Tau;";g["933"]="&Upsilon;";g["934"]="&Phi;";g["935"]="&Chi;";g["936"]="&Psi;";g["937"]="&Omega;";g["945"]="&alpha;";g["946"]="&beta;";g["947"]=
"&gamma;";g["948"]="&delta;";g["949"]="&epsilon;";g["950"]="&zeta;";g["951"]="&eta;";g["952"]="&theta;";g["953"]="&iota;";g["954"]="&kappa;";g["955"]="&lambda;";g["956"]="&mu;";g["957"]="&nu;";g["958"]="&xi;";g["959"]="&omicron;";g["960"]="&pi;";g["961"]="&rho;";g["962"]="&sigmaf;";g["963"]="&sigma;";g["964"]="&tau;";g["965"]="&upsilon;";g["966"]="&phi;";g["967"]="&chi;";g["968"]="&psi;";g["969"]="&omega;";g["977"]="&thetasym;";g["978"]="&upsih;";g["982"]="&piv;";g["8194"]="&ensp;";g["8195"]="&emsp;";
g["8201"]="&thinsp;";g["8204"]="&zwnj;";g["8205"]="&zwj;";g["8206"]="&lrm;";g["8207"]="&rlm;";g["8211"]="&ndash;";g["8212"]="&mdash;";g["8216"]="&lsquo;";g["8217"]="&rsquo;";g["8218"]="&sbquo;";g["8220"]="&ldquo;";g["8221"]="&rdquo;";g["8222"]="&bdquo;";g["8224"]="&dagger;";g["8225"]="&Dagger;";g["8226"]="&bull;";g["8230"]="&hellip;";g["8240"]="&permil;";g["8242"]="&prime;";g["8243"]="&Prime;";g["8249"]="&lsaquo;";g["8250"]="&rsaquo;";g["8254"]="&oline;";g["8260"]="&frasl;";g["8364"]="&euro;";g["8472"]=
"&weierp;";g["8465"]="&image;";g["8476"]="&real;";g["8482"]="&trade;";g["8501"]="&alefsym;";g["8592"]="&larr;";g["8593"]="&uarr;";g["8594"]="&rarr;";g["8595"]="&darr;";g["8596"]="&harr;";g["8629"]="&crarr;";g["8656"]="&lArr;";g["8657"]="&uArr;";g["8658"]="&rArr;";g["8659"]="&dArr;";g["8660"]="&hArr;";g["8704"]="&forall;";g["8706"]="&part;";g["8707"]="&exist;";g["8709"]="&empty;";g["8711"]="&nabla;";g["8712"]="&isin;";g["8713"]="&notin;";g["8715"]="&ni;";g["8719"]="&prod;";g["8721"]="&sum;";g["8722"]=
"&minus;";g["8727"]="&lowast;";g["8729"]="&#8729;";g["8730"]="&radic;";g["8733"]="&prop;";g["8734"]="&infin;";g["8736"]="&ang;";g["8743"]="&and;";g["8744"]="&or;";g["8745"]="&cap;";g["8746"]="&cup;";g["8747"]="&int;";g["8756"]="&there4;";g["8764"]="&sim;";g["8773"]="&cong;";g["8776"]="&asymp;";g["8800"]="&ne;";g["8801"]="&equiv;";g["8804"]="&le;";g["8805"]="&ge;";g["8834"]="&sub;";g["8835"]="&sup;";g["8836"]="&nsub;";g["8838"]="&sube;";g["8839"]="&supe;";g["8853"]="&oplus;";g["8855"]="&otimes;";g["8869"]=
"&perp;";g["8901"]="&sdot;";g["8968"]="&lceil;";g["8969"]="&rceil;";g["8970"]="&lfloor;";g["8971"]="&rfloor;";g["9001"]="&lang;";g["9002"]="&rang;";g["9642"]="&#9642;";g["9643"]="&#9643;";g["9674"]="&loz;";g["9702"]="&#9702;";g["9824"]="&spades;";g["9827"]="&clubs;";g["9829"]="&hearts;";g["9830"]="&diams;"}if(f!=="ENT_NOQUOTES")g["34"]="&quot;";if(f==="ENT_QUOTES")g["39"]="&#39;";g["60"]="&lt;";g["62"]="&gt;";var h,i={};for(h in g)i[String.fromCharCode(h)]=g[h];return i},entityDecode:function(e,f){var g=
Zarafa.core.HTMLParser.getHTMLTranslationTable("HTML_ENTITIES",f),h="",i="";for(h in g){i=g[h];e=e.split(i).join(h)}return e=e.split("&#039;").join("'")},entityEncode:function(e,f){var g=Zarafa.core.HTMLParser.getHTMLTranslationTable("HTML_ENTITIES",f),h="",i="";for(h in g){i=g[h];e=e.split(h).join(i)}return e=e.split("'").join("&#039;")},inlineImgOutlookToZarafa:function(e,f,g){return e=e.replace(/src\s*=\s*[\"\']([^\"\']*)[\"\']/igm,function(h,i){if(i){var j=i.match(/(?:cid:|attachCid=)([^"\'\&]*)/);
if(j&&j.length>1)return'src="'+window.location.pathname+"?load=download_attachment&attachCid="+j[1]+"&store="+f+"&entryid="+g+'&openType=inline"';return'src="'+i+'"'}else return h})},inlineImgZarafaToOutlook:function(e){return e=e.replace(/src\s*=\s*[\"\']([^\"\']*)[\"\']/igm,function(f,g){if(g){var h=g.match(/(?:attachCid=)(\\?[^"\'\&]*)/);if(h&&h.length>1)return'src="cid:'+h[1]+'"';return'src="'+g+'"'}else return f})}}}();Ext.namespace("Zarafa.core");
Zarafa.core.Events={listeners:{},registerListener:function(a,b,c){if(b=Zarafa.core.Events.listeners[a.id])b.push(c);else Zarafa.core.Events.listeners[a.id]=[c]},unregisterListener:function(a,b){var c=Zarafa.core.Events.listeners[a.id];if(c)for(var d=0,e=c.length;d<e;d++)if(c[d].el===b){c.splice(d,1);c.length===0&&delete Zarafa.core.Events.listeners[a.id]}},getListener:function(a,b){var c=Zarafa.core.Events.listeners[a.id];if(c)for(var d=0,e=c.length;d<e;d++){var f=c[d];if(f.el===b)return f}},addPasteEventHandler:function(a,
b,c,d,e){var f=Zarafa.core.Events.getListener(a,b);if(!Ext.isDefined(f)){var g=!Ext.isFunction(b.on);f=new Ext.util.Observable;f.field=a;f.el=b;f.hasFocus=a.hasFocus;f.originalValue=a.getValue();f.addEvents("paste");if(Ext.isOpera)g?b.addEventListener("keyup",this.onPasteKeyUp.createDelegate(f)):a.mon(b,"keyup",this.onPasteKeyUp,f);else g?b.addEventListener("paste",this.onPaste.createDelegate(f)):a.mon(b,"paste",this.onPaste,f);g?b.addEventListener("mouseover",this.onPasteMouseOver.createDelegate(f)):
a.mon(b,"mouseover",this.onPasteMouseOver,f);a.mon(a,"blur",this.onPasteBlur,f);Zarafa.core.Events.registerListener(a,b,f)}f.addListener("paste",c,d,e)},removePasteEventHandler:function(a,b,c,d){var e=Zarafa.core.Events.getListener(a,b);if(Ext.isDefined(e)){e.removeListener("paste",c,d);e.hasListener("paste")||Zarafa.core.Events.unregisterListener(a,b)}},onPasteKeyUp:function(a){a.ctrlKey===true&&a.keyCode===Ext.EventObject.V&&this.fireEvent("paste")},onPaste:function(){Zarafa.core.Events.onPastePoll.call(this,
this.field,this.field.getValue(),5)},onPastePoll:function(a,b,c){if(c!==0)if(a.getValue()===b)Zarafa.core.Events.onPastePoll.defer(1,this,[a,b,--c]);else{this.fireEvent("paste");this.originalValue=this.field.getValue()}},onPasteMouseOver:function(){if(this.hasFocus===false){if(this.originalValue!==this.field.getValue()){this.field.focus();this.fireEvent("paste");this.originalValue=this.field.getValue()}this.hasFocus=true}},onPasteBlur:function(){this.hasFocus=false;this.originalValue=this.field.getValue()}};
Ext.namespace("Zarafa.core");
Zarafa.core.EntryId=function(){var a=Ext.extend(Object,{abFlags:"",guid:"",version:"",type:"",uniqueId:"",server:"",padding:"",MIN_LENGTH:88,name:"EID",length:0,entryId:"",constructor:function(d){if(d){this.entryId=d;this.decomposeEntryId(d)}},decomposeEntryId:function(d){d=d.toUpperCase();this.length=d.length;var e=0;this.abFlags=d.substr(e,8);e=+8;this.guid=d.substr(e,32);e+=32;this.version=d.substr(e,8);e+=8;this.type=d.substr(e,8);e+=8;this.uniqueId=d.substr(e,32);e+=32;d=d.substr(e);for(e=4;e>
0;e--)if(d.substring(d.length-2,d.length)=="00"){this.padding+="00";d=d.substring(0,d.length-2)}else break;this.server=d}}),b=Ext.extend(Object,{abFlags:"",guid:"",version:"",type:"",id:"",server:"",padding:"",MIN_LENGTH:64,name:"EID_V0",length:0,entryId:"",constructor:function(d){if(d){this.entryId=d;this.decomposeEntryId(this.entryId)}},decomposeEntryId:function(d){d=d.toUpperCase();this.length=d.length;var e=0;this.abFlags=d.substr(e,8);e=+8;this.guid=d.substr(e,32);e+=32;this.version=d.substr(e,
8);e+=8;this.type=d.substr(e,8);e+=8;this.id=d.substr(e,8);e+=8;d=d.substr(e);for(e=4;e>0;e--)if(d.substring(d.length-2,d.length)=="00"){this.padding+="00";d=d.substring(0,d.length-2)}else break;this.server=d}}),c=Ext.extend(Object,{flags:"",providerUID:"",version:"",type:"",DLLFileName:"",terminationChar:"",unWrappedEntryId:"",name:"WrappedSEID",length:0,storeEntryId:"",constructor:function(d){if(d){this.storeEntryId=d;this.decomposeEntryId(this.storeEntryId)}},decomposeEntryId:function(d){d=d.toUpperCase();
this.length=d.length;var e=0;this.flags=d.substr(e,8);e+=8;this.providerUID=d.substr(e,32);e+=32;this.version=d.substr(e,2);e+=2;this.type=d.substr(e,2);e+=2;var f=d.slice(e).indexOf("00");this.DLLFileName=d.substr(e,f);e+=f;this.terminationChar=d.substr(e,2);e+=2;this.unWrappedEntryId=d.substr(e);this.unWrappedEntryId=Zarafa.core.EntryId.createEntryIdObj(this.unWrappedEntryId)}});return{createEntryIdObj:function(d){return d.substr(40,8)=="00000000"?new b(d):new a(d)},compareEntryIds:function(d,e){if(!Ext.isString(d)||
!Ext.isString(e))return false;if(d===e)return true;var f=Zarafa.core.EntryId.createEntryIdObj(d),g=Zarafa.core.EntryId.createEntryIdObj(e);if(f.length!=g.length)return false;if(f.abFlags!=g.abFlags)return false;if(f.version!=g.version)return false;if(f.type!=g.type)return false;if(f.name=="EID_V0"){if(f.length<f.MIN_LENGTH)return false;if(f.id!=g.id)return false}else{if(f.length<f.MIN_LENGTH)return false;if(f.uniqueId!=g.uniqueId)return false}return true},createStoreEntryIdObj:function(d){return new c(d)},
compareStoreEntryIds:function(d,e){if(!Ext.isString(d)||!Ext.isString(e))return false;if(d===e)return true;var f=Zarafa.core.EntryId.createStoreEntryIdObj(d),g=Zarafa.core.EntryId.createStoreEntryIdObj(e);f=f.unWrappedEntryId;g=g.unWrappedEntryId;if(f===g)return true;if(f.length<f.MIN_LENGTH||g.length<g.MIN_LENGTH)return false;if(f.guid!=g.guid)return false;if(f.version!=g.version)return false;if(f.type!=g.type)return false;if(f.name=="EID_V0"){if(f.length<f.MIN_LENGTH)return false;if(f.id!=g.id)return false}else{if(f.length<
f.MIN_LENGTH)return false;if(f.uniqueId!=g.uniqueId)return false}return true},isFavoriteFolder:function(d){return Zarafa.core.EntryId.createEntryIdObj(d).abFlags.substr(6,8)=="01"},isOneOffEntryId:function(d){return Zarafa.core.EntryId.createEntryIdObj(d).guid=="812B1FA4BEA310199D6E00DD010F5402"},isFavoriteRootFolder:function(d){return Zarafa.core.EntryId.createEntryIdObj(d).uniqueId=="00000000000000000000000000000002"},isPublicRootFolder:function(d){return Zarafa.core.EntryId.createEntryIdObj(d).uniqueId==
"00000000000000000000000000000003"},isPublicSubtreeFolder:function(d){return Zarafa.core.EntryId.createEntryIdObj(d).uniqueId=="00000000000000000000000000000001"}}}();Ext.namespace("Zarafa.core");
Zarafa.core.DateRange=Ext.extend(Ext.util.Observable,{startDate:null,dueDate:null,allowBlank:false,constructor:function(a){a=a||{};Ext.applyIf(a,{allowBlank:this.allowBlank});a.allowBlank?Ext.applyIf(a,{startDate:null,dueDate:a.startDate?a.startDate.clone():null}):Ext.applyIf(a,{startDate:new Date,dueDate:a.startDate?a.startDate.clone():new Date});Ext.apply(this,a);if(Ext.isDate(this.startDate)&&Ext.isDate(this.dueDate)&&this.getStartTime()>this.getDueTime())throw"Invalid date range, start date is after due date";
this.addEvents("update");Zarafa.core.DateRange.superclass.constructor.call(this)},getStartDate:function(){return this.startDate},getDueDate:function(){return this.dueDate},setStartDate:function(a,b,c){var d=null;a=Ext.isDate(a)?a:null;if(!this.allowBlank&&!Ext.isDate(a))throw"Cannot set DateRange start to undefined";else if(Ext.isDate(this.dueDate)&&Ext.isDate(a)&&a.getTime()>this.getDueTime()&&!b)throw"Cannot set DateRange start date to after its due date";(c=c||Ext.isDate(this.startDate)&&Ext.isDate(a)&&
this.getStartTime()==a.getTime())||(d=this.clone());this.startDate=a;c||this.fireEvent("update",this,d);return this},setDueDate:function(a,b,c){var d=null;a=Ext.isDate(a)?a:null;if(!this.allowBlank&&!Ext.isDate(a))throw"Cannot set DateRange due date to undefined";else if(Ext.isDate(this.startDate)&&Ext.isDate(a)&&a.getTime()<this.getStartTime()&&!b)throw"Cannot set DateRange due date to before its start date";(c=c||Ext.isDate(this.dueDate)&&Ext.isDate(a)&&this.getDueTime()==a.getTime())||(d=this.clone());
this.dueDate=a;c||this.fireEvent("update",this,d);return this},set:function(a,b,c,d){var e=null;a=Ext.isDate(a)?a:null;b=Ext.isDate(b)?b:null;if(!this.allowBlank&&!Ext.isDate(a))throw"Cannot set DateRange start to undefined";if(!this.allowBlank&&!Ext.isDate(b))throw"Cannot set DateRange due date to undefined";if(Ext.isDate(a)&&Ext.isDate(b)&&a.getTime()>b.getTime()&&!c)throw"Invalid date range, start date is after due date";(d=d||Ext.isDate(a)&&Ext.isDate(b)&&a.getTime()==this.getStartTime()&&b.getTime()==
this.getDueTime())||(e=this.clone());this.setStartDate(a,true,true);this.setDueDate(b,true,true);d||this.fireEvent("update",this,e);return this},getStartTime:function(){return Ext.isDate(this.startDate)&&this.startDate.getTime()||this.startDate},getDueTime:function(){return Ext.isDate(this.dueDate)&&this.dueDate.getTime()||this.dueDate},setStartTime:function(a,b,c){var d=null;if(!this.allowBlank&&!a)throw"Cannot set DateRange start to undefined";else if(Ext.isDate(this.dueDate)&&a>this.dueDate.getTime()&&
!b)throw"Cannot set DateRange start date to after its due date";(c=c||this.getStartTime()==a)||(d=this.clone());if(Ext.isEmpty(a))this.startDate=null;else this.startDate.setTime(a);c||this.fireEvent("update",this,d);return this},setDueTime:function(a,b,c){var d=null;if(!this.allowBlank&&!a)throw"Cannot set DateRange due date to undefined";else if(Ext.isDate(this.startDate)&&a<this.startDate.getTime()&&!b)throw"Cannot set DateRange due date to before its start date";(c=c||this.getDueTime()==a)||(d=
this.clone());if(Ext.isEmpty(a))this.dueDate=null;else this.dueDate.setTime(a);c||this.fireEvent("update",this,d);return this},setTime:function(a,b,c,d){var e=null;if(!a||!b){if(!this.allowBlank&&!a)throw"Cannot set DateRange start to undefined";if(!this.allowBlank&&!b)throw"Cannot set DateRange due date to undefined";}else if(a>b&&!c)throw"Invalid date range, start date is after due date";(d=d||a==this.getStartTime()&&b==this.getDueTime())||(e=this.clone());this.setStartTime(a,true,true);this.setDueTime(b,
true,true);d||this.fireEvent("update",this,e);return this},getDuration:function(a){if(Ext.isDate(this.dueDate)&&Ext.isDate(this.startDate))return Date.diff(a||Date.MILLI,this.dueDate,this.startDate);return 0},setDuration:function(a,b){var c=null;if(!Ext.isDate(this.startDate))throw"Cannot set duration when start date is not specified";(b=b||this.getDuration()==a)||(c=this.clone());this.dueDate=new Date(this.getStartTime()+a);b||this.fireEvent("update",this,c);return this},getNumDays:function(){var a=
this.getDuration();if(Ext.isDefined(a))return Math.round(a/864E5);return 0},expand:function(a){var b=this.clone();if(Ext.isDate(this.startDate))this.startDate=new Date(this.getStartTime()-this.getStartTime()%a);if(Ext.isDate(this.dueDate))this.dueDate=new Date(this.getDueTime()+a-this.getDueTime()%a);if(Ext.isDate(this.startDate)||Ext.isDate(this.dueDate))this.fireEvent("update",this,b);return this},clone:function(){return new Zarafa.core.DateRange({startDate:Ext.isDate(this.startDate)?new Date(this.getStartTime()):
undefined,dueDate:Ext.isDate(this.dueDate)?new Date(this.getDueTime()):undefined,allowBlank:this.allowBlank})},equals:function(a){if(!a)return false;if(this.getStartTime()!==a.getStartTime())return false;if(this.getDueTime()!==a.getDueTime())return false;return true},compare:function(a){var b=this.getStartTime()||0,c=a.getStartTime()||0;if(b!==c)return b>c?1:-1;b=this.getDueTime()||0;a=a.getDueTime()||0;if(b!==a)return b>a?1:-1;return 0},isAllDay:function(){return Ext.isDate(this.startDate)&&Ext.isDate(this.dueDate)&&
this.startDate.clearTime(true).getTime()==this.getStartTime()&&this.dueDate.clearTime(true).getTime()==this.getDueTime()},overlaps:function(a){var b=this.getStartTime(),c=this.getDueTime(),d=a.getStartTime();a=a.getDueTime();return b>=d&&b<a||d>=b&&d<c},inside:function(a){if(this.getStartTime()&&a.getStartTime()&&this.getDueTime()&&a.getDueTime())return this.getStartTime()>=a.getStartTime()&&this.getDueTime()<=a.getDueTime();return false},containsDate:function(a){return this.getStartTime()<=a.getTime()&&
this.getDueTime()>a.getTime()},format:function(){var a=this.startDate,b=this.dueDate;if(!Ext.isDate(a)||!Ext.isDate(b))return"";if(b.getHours()==0||b.getMinutes()==0||b.getSeconds()==0){b=b.add(Date.DAY,-1);if(b.getTime()<a.getTime())b=a}if(a.getYear()!=b.getYear())return String.format("{0} - {1}",a.format(_("jS F Y")),b.format(_("jS F Y")));if(a.getMonth()!=b.getMonth())return String.format("{0} - {1} {2}",a.format(_("jS F")),b.format(_("jS F")),a.format(_("Y")));if(a.getDate()!=b.getDate())return String.format("{0} - {1} {2}",
a.format(_("jS")),b.format(_("jS")),a.format(_("F Y")));return a.format(_("jS F Y"))}});Ext.namespace("Zarafa.core");
Zarafa.core.Actions={list:"list",globaladdressbook:"globaladdressbook",hierarchy:"hierarchy",open:"open",item:"item",update:"update",save:"save",copy:"copy","delete":"delete",folder:"folder",set:"set",get:"get",_delete:"delete",search:"search",updatesearch:"updatesearch",stopsearch:"stopsearch",contacts:"contacts",keepalive:"keepalive",newmail:"newmail",addFolder:"add",modifyFolder:"modify",deleteFolder:"delete",emptyFolder:"emptyfolder",readAllMsgs:"readflags",folderProps:"folderprops",checknames:"checknames"};
Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.SentInfoLinks=Ext.extend(Ext.Container,{senderCls:"preview-header-senderbox",ellipsisStringStartLength:30,ellipsisStringEndLength:30,record:undefined,senderTemplate:'<tpl if="!Ext.isEmpty(values.sent_representing_name)"><span class="preview-from"><tpl if="!Ext.isEmpty(values.sender_entryid) && !Ext.isEmpty(values.sent_representing_entryid) && Zarafa.core.EntryId.compareEntryIds(values.sent_representing_entryid, values.sender_entryid) === false"><a href="#" class="emailaddress zarafa-sentinfo-on-behalf"> {sender_name:htmlEncode} &lt;{sender_email_address:htmlEncode}&gt; </a><span>&nbsp;on behalf of&nbsp;</span></tpl><a href="#" class="emailaddress zarafa-sentinfo-link">{sent_representing_name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)}&nbsp;<tpl if="!Ext.isEmpty(values.sent_representing_email_address)">&lt;{sent_representing_email_address:htmlEncode}&gt;</tpl></a></span></tpl><tpl if="!this.isMeeting(values.message_class)"><span class="preview-timestamp"></tpl><tpl if="this.isMeeting(values.message_class)"><span class="preview-timestamp preview-meetingrequest"></tpl><tpl><span class="preview-timestamp-title">'+pgettext("mail.previewpanel",
"Sent")+':</span><tpl if="Ext.isDate(values.message_delivery_time)">{message_delivery_time:date("'+_("l jS F Y G:i")+'")}</tpl><tpl if="!Ext.isDate(values.message_delivery_time)">'+pgettext("mail.previewpanel","None")+"</tpl></span></tpl>",constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.sentinfolinks",border:false,autoScroll:true,anchor:"100%",cls:"preview-header-sentinfo"});Zarafa.common.ui.messagepanel.SentInfoLinks.superclass.constructor.call(this,
a);if(Ext.isString(this.senderTemplate))this.senderTemplate=new Ext.XTemplate(this.senderTemplate,{compiled:true,ellipsisStringStartLength:this.ellipsisStringStartLength,ellipsisStringEndLength:this.ellipsisStringEndLength,isMeeting:function(b){return Zarafa.core.MessageClass.isClass(b,"ipm.schedule.meeting",true)}})},onRender:function(){Zarafa.common.ui.messagepanel.SentInfoLinks.superclass.onRender.apply(this,arguments);this.senderElem=Ext.DomHelper.append(this.el.dom,{tag:"div",cls:this.senderCls})},
update:function(a){if(this.senderElem)if(Ext.isDefined(a)){this.senderTemplate.overwrite(Ext.get(this.senderElem),a.data);Ext.get(this.senderElem).select(".zarafa-sentinfo-link").on("contextmenu",this.onSenderContextMenu,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-on-behalf").on("contextmenu",this.onSenderContextMenu,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-link").on("dblclick",this.onDoubleClick,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-on-behalf").on("dblclick",
this.onDoubleClick,this)}else{Ext.get(this.senderElem).select(".zarafa-sentinfo-link").un("contextmenu",this.onSenderContextMenu,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-on-behalf").un("contextmenu",this.onSenderContextMenu,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-link").un("dblclick",this.onDoubleClick,this);Ext.get(this.senderElem).select(".zarafa-sentinfo-on-behalf").un("dblclick",this.onDoubleClick,this);this.senderElem.innerHTML=""}this.record=a},onSenderContextMenu:function(a,
b){var c=this.convertSenderToRecord(b);Zarafa.common.Actions.openContextMenu(c,a.getXY())},onDoubleClick:function(a,b){var c=this.convertSenderToRecord(b);Zarafa.common.Actions.openViewRecipientDialog(c)},convertSenderToRecord:function(a){var b=undefined;if(Ext.get(a).hasClass("zarafa-sentinfo-link"))b=this.record.getSender();else if(Ext.get(a).hasClass("zarafa-sentinfo-on-behalf"))b=this.record.getSentRepresenting();return b}});Ext.reg("zarafa.sentinfolinks",Zarafa.common.ui.messagepanel.SentInfoLinks);
Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.RecipientLinks=Ext.extend(Ext.DataView,{ellipsisStringStartLength:30,ellipsisStringEndLength:30,fieldLabel:pgettext("mail.previewpanel","Recipients"),recipientType:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recipientlinks",border:false,autoScroll:true,anchor:"100%",cls:"preview-header-recipients",multiSelect:false,overClass:"zarafa-recipient-link-over",itemSelector:"a.zarafa-recipient-link",tpl:new Ext.XTemplate('<tpl if="values.length &gt; 0"><div class="preview-header-recipientbox"><div class="preview-recipient-title">{this.fieldLabel}:</div><div class="preview-recipient-data"><tpl for="."><a href="#" viewIndex="{viewIndex}" class="emailaddress zarafa-recipient-link"><tpl if="!Ext.isEmpty(values.display_name)">{display_name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)}&nbsp;</tpl><tpl if="!Ext.isEmpty(values.smtp_address)">&lt;{smtp_address:htmlEncode}&gt;</tpl><tpl if="Ext.isEmpty(values.smtp_address) && !Ext.isEmpty(values.email_address)">&lt;{email_address:htmlEncode}&gt;</tpl></a><tpl if="xindex &gt; 0 && xindex != xcount"><span>;&nbsp;</span></tpl></tpl></div></div></tpl>',{compiled:true,
fieldLabel:a.fieldLabel||this.fieldLabel,ellipsisStringStartLength:a.ellipsisStringStartLength||this.ellipsisStringStartLength,ellipsisStringEndLength:a.ellipsisStringEndLength||this.ellipsisStringEndLength})});this.fieldLabel=a.fieldLabel||this.fieldLabel;delete a.fieldLabel;Zarafa.common.ui.messagepanel.RecipientLinks.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.common.ui.messagepanel.RecipientLinks.superclass.initComponent.call(this);this.mon(this,"contextmenu",this.onNodeContextMenu,
this);this.mon(this,"dblclick",this.onDoubleClick,this)},setRecord:function(a){if(a){if(a.isOpened()){this.bindStore(a.getRecipientStore());this.setVisible(true)}}else{this.bindStore(null);this.setVisible(false)}},updateIndexes:function(a,b){var c=this.all.elements;a=a||0;b=b||(b===0?0:c.length-1);for(var d=a;d<=b;d++)c[d].viewIndex=c[d].getAttribute("viewIndex")},collectData:function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];if(!Ext.isDefined(this.recipientType)||this.recipientType===e.get("recipient_type"))b[b.length]=
this.prepareData(e.data,e.get("rowid"),e)}return b},prepareData:function(a,b){return Ext.apply({viewIndex:b},a)},getRecords:function(a){for(var b=[],c=0,d=a.length;c<d;c++)b[b.length]=this.store.getAt(this.store.findExact("rowid",parseInt(a[c].viewIndex)));return b},getRecord:function(a){return this.store.getAt(this.store.findExact("rowid",parseInt(a.viewIndex)))},onNodeContextMenu:function(a,b,c,d){Zarafa.common.Actions.openContextMenu(a.getRecord(c),d.getXY(),{model:this.model})},onDoubleClick:function(a,
b,c){Zarafa.common.Actions.openViewRecipientDialog(a.getRecord(c))}});Ext.reg("zarafa.recipientlinks",Zarafa.common.ui.messagepanel.RecipientLinks);Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.MessageHeader=Ext.extend(Ext.Panel,{headerTemplate:'<div class="preview-header-titlebox"><img src="'+Ext.BLANK_IMAGE_URL+'" class="preview-header-collapse preview-header-collapse-minus"/><tpl if="!Ext.isEmpty(values.subject)"><span class="preview-title">{subject:htmlEncode}</span></tpl></div>',collapseElement:undefined,sliding:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,
{xtype:"zarafa.messageheader",autoScroll:true,anchor:"100%",cls:"preview-header",border:false,autoHeight:true,collapsible:true,hideCollapseTool:true,header:true,headerCfg:{cls:"preview-header-title"},items:[{xtype:"zarafa.extrainfolinks"},{xtype:"zarafa.sentinfolinks"},{xtype:"zarafa.recipientlinks",ref:"recipientToLinks",fieldLabel:pgettext("mail.previewpanel","To"),recipientType:Zarafa.core.mapi.RecipientType.MAPI_TO},{xtype:"zarafa.recipientlinks",ref:"recipientCcLinks",fieldLabel:pgettext("mail.previewpanel",
"Cc"),recipientType:Zarafa.core.mapi.RecipientType.MAPI_CC},{xtype:"zarafa.attachmentlinks",ref:"attachmentLinks",fieldLabel:pgettext("mail.previewpanel","Attachments")},container.populateInsertionPoint("previewpanel.toolbar.detaillinks",this)]});Zarafa.common.ui.messagepanel.MessageHeader.superclass.constructor.call(this,a);this.mon(this,"collapse",this.onAfterSlide,this);this.mon(this,"expand",this.onAfterSlide,this);if(Ext.isString(this.headerTemplate))this.headerTemplate=new Ext.XTemplate(this.headerTemplate,
{compiled:true})},onRender:function(){Zarafa.common.ui.messagepanel.MessageHeader.superclass.onRender.apply(this,arguments);this.header&&this.header.selectable()},update:function(a,b){if(Ext.isDefined(this.header)){if(b===true&&this.collapseElement&&(this.collapsed===true||this.sliding===true)){if(this.sliding===true){this.update.defer(10,this,[a,b]);return}this.collapseElement.removeClass("preview-header-collapse-plus");this.expand(false);this.collapseElement.addClass("preview-header-collapse-minus")}this.collapseElement&&
this.mun(this.collapseElement,"click",this.onCollapseClick,this);if(Ext.isDefined(a)){this.headerTemplate.overwrite(this.header.dom,a.data);(this.collapseElement=this.header.child(".preview-header-collapse"))&&this.mon(this.collapseElement,"click",this.onCollapseClick,this)}else this.header.dom.innerHTML=""}if(b){this.recipientToLinks.setRecord(a);this.recipientCcLinks.setRecord(a);this.attachmentLinks.setRecord(a)}},onCollapseClick:function(a){if(this.collapseElement&&a.target.id==this.collapseElement.id&&
this.sliding===false){this.sliding=true;if(this.collapseElement.hasClass("preview-header-collapse-minus")){this.collapseElement.removeClass("preview-header-collapse-minus");this.collapse();this.collapseElement.addClass("preview-header-collapse-plus")}else{this.collapseElement.removeClass("preview-header-collapse-plus");this.expand();this.collapseElement.addClass("preview-header-collapse-minus")}}},onAfterSlide:function(){this.sliding=false}});Ext.reg("zarafa.messageheader",Zarafa.common.ui.messagepanel.MessageHeader);
Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.MessageBody=Ext.extend(Ext.Container,{plaintextTemplate:"<html><body>{body}</body></html>",constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.messagebody",autoScroll:true,anchor:"100%",layout:"fit",autoEl:{tag:"iframe",cls:"preview-iframe",frameborder:0,src:"about:blank"},border:false});Zarafa.common.ui.messagepanel.MessageBody.superclass.constructor.call(this,a);if(Ext.isString(this.plaintextTemplate))this.plaintextTemplate=
new Ext.Template(this.plaintextTemplate,{compiled:true})},update:function(a){var b=this.getEl().dom.contentWindow.document,c="",d;if(!Ext.isEmpty(b.body))b.body.innerHTML="";if(Ext.isDefined(a)){c=a.getBody(true);d=a.get("isHTML");c=c?d===false?this.plaintextTemplate.applyTemplate({body:c}):Zarafa.core.HTMLParser.inlineImgOutlookToZarafa(c,a.get("store_entryid"),a.get("entryid")):""}b.write(c);b.close();this.addCSSLink(b);this.ownerCt.doLayout()},addCSSLink:function(a){var b=a.getElementsByTagName("head")[0];
a=a.createElement("link");a.setAttribute("rel","stylesheet");a.setAttribute("type","text/css");a.setAttribute("href","client/resources/css-extern/style.previewbody.css");b.appendChild(a)},onRender:function(a,b){Zarafa.common.ui.messagepanel.MessageBody.superclass.onRender.call(this,a,b);this.resizeEl=this.positionEl=this.wrap=this.el.wrap({cls:"preview-body"})}});Ext.reg("zarafa.messagebody",Zarafa.common.ui.messagepanel.MessageBody);Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.ExtraInfoLinks=Ext.extend(Ext.Container,{record:undefined,importantInfoString:pgettext("mail.previewpanel","This message was sent with {0} importance."),sensitivityInfoString:pgettext("mail.previewpanel","Please treat this as {0}."),blockStatusInfoString:pgettext("mail.previewpanel","Click here to download pictures. To help protect your privacy, WebApp prevented automatic download of some pictures in this message."),acceptInfoString:pgettext("mail.previewpanel","{0} has accepted."),
tentativeInfoString:pgettext("mail.previewpanel","{0} has tentatively accepted."),declineInfoString:pgettext("mail.previewpanel","{0} has declined."),counterProposalTentativeAcceptedString:pgettext("mail.previewpanel","{0} tentatively accepted and proposed a new time for this meeting."),counterProposalDeclinedString:pgettext("mail.previewpanel","{0} declined and proposed a new time for this meeting."),meetingNotFoundInfoString:pgettext("mail.previewpanel","This meeting is not in the Calendar; it may have been moved or deleted."),
meetingOutDatedInfoString:pgettext("mail.previewpanel","This meeting request was updated after this message was sent. You should open the latest update or open the item from the calendar."),organizerAsAttendeeInfoString:pgettext("mail.previewpanel","As the meeting organizer, you do not need to respond to the meeting"),meetingUpdatedInfoString:pgettext("mail.previewpanel","The meeting was updated after the attendee sent this response"),elapsedTimeInfoString:pgettext("mail.previewpanel","This appointment occurs in the past."),
responseRequiredString:pgettext("mail.previewpanel","Please respond."),meetingUpdatedString:pgettext("mail.previewpanel","This is an update of a previously sent meeting request."),delegatorInfoString:pgettext("mail.previewpanel","Received for {0}."),itemCls:"preview-header-extrainfobox-item",constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.extrainfolinks",cls:"preview-header-extrainfobox"});Zarafa.common.ui.messagepanel.ExtraInfoLinks.superclass.constructor.call(this,
a)},update:function(a){var b=this.getEl();if(Ext.isDefined(b.dom))b.dom.innerHTML="";if(Ext.isDefined(a)){this.record=a;var c=false,d=a.get("sensitivity"),e=a.get("importance");if(Ext.isDefined(d)&&d!=Zarafa.core.mapi.Sensitivity.NONE){c=String.format(this.sensitivityInfoString,Zarafa.core.mapi.Sensitivity.getDisplayName(d));b.createChild({tag:"div",html:c,cls:this.itemCls});c=true}if(Ext.isDefined(e)&&e!=Zarafa.core.mapi.Importance.NORMAL){c=String.format(this.importantInfoString,Zarafa.core.mapi.Importance.getDisplayName(e));
b.createChild({tag:"div",html:c,cls:this.itemCls});c=true}if(this.record instanceof Zarafa.core.data.MessageRecord){if(a.isExternalContentBlocked()){a=b.createChild({tag:"div",html:this.blockStatusInfoString,cls:this.itemCls});this.mon(a,"click",this.onExtraInfoBlockClick,this);a.addClassOnOver("preview-header-extrainfobox-item-over");c=true}if(this.record instanceof Zarafa.calendar.MeetingRequestRecord)c=this.setMeetingInfo(b)===true?true:c}this.setVisible(c);this.doLayout()}else this.setVisible(false)},
onExtraInfoBlockClick:function(a){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.previewpanel.extrainfo"],this.record,{position:a.getXY()})},setMeetingInfo:function(a){var b=this.setMeetingNotFoundInfo(a)===true?true:b;b=this.setDelegatorInfo(a)===true?true:b;if(this.record.isMeetingRequest()){b=this.setMeetingRequestInfo(a)===true?true:b;if(this.record.isRecurringException())b=this.setRecurringMeetingRequestInfo(a)===true?true:b}if(this.record.isMeetingRequestResponse())b=
this.setMeetingResponseInfo(a)===true?true:b;return b},setDelegatorInfo:function(a){var b=false;if(this.record.get("delegated_by_rule")){b=this.record.get("received_representing_name")||this.record.get("received_representing_email_address");a.createChild({tag:"div",html:String.format(this.delegatorInfoString,b),cls:this.itemCls});b=true}return b},setMeetingRequestInfo:function(a){var b=this.record.get("conflictinfo"),c=this.record.isMeetingOutOfDate(),d=this.record.senderIsReceiver(),e=false;if(this.record.senderIsUser())return e;
if(c){a.createChild({tag:"div",html:this.meetingOutDatedInfoString,cls:this.itemCls});e=true}else{if(d){a.createChild({tag:"div",html:this.organizerAsAttendeeInfoString,cls:this.itemCls});e=true}else{this.record.isAppointmentInPast()?a.createChild({tag:"div",html:this.elapsedTimeInfoString,cls:this.itemCls}):a.createChild({tag:"div",html:this.responseRequiredString,cls:this.itemCls});e=true;if(!Ext.isEmpty(b)){a.createChild({tag:"div",html:b,cls:this.itemCls});e=true}}if(this.record.get("updatecounter")>
0){a.createChild({tag:"div",html:this.meetingUpdatedString,cls:this.itemCls});e=true}}return e},setMeetingResponseInfo:function(a){var b=this.record.get("counter_proposal"),c=this.record.get("sent_representing_name"),d=false;if(!Ext.isEmpty(c)){if(this.record.get("meeting_updated")){a.createChild({tag:"div",html:String.format(this.meetingUpdatedInfoString,c),cls:this.itemCls});d=true}if(b)if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent")){a.createChild({tag:"div",html:String.format(this.counterProposalTentativeAcceptedString,
c),cls:this.itemCls});d=true}else{if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg")){a.createChild({tag:"div",html:String.format(this.counterProposalDeclinedString,c),cls:this.itemCls});d=true}}else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Pos")){a.createChild({tag:"div",html:String.format(this.acceptInfoString,c),cls:this.itemCls});d=true}else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent")){a.createChild({tag:"div",html:String.format(this.tentativeInfoString,
c),cls:this.itemCls});d=true}else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg")){a.createChild({tag:"div",html:String.format(this.declineInfoString,c),cls:this.itemCls});d=true}}return d},setMeetingNotFoundInfo:function(a){var b=false;if(this.record.get("appointment_not_found")){a.createChild({tag:"div",html:this.meetingNotFoundInfoString,cls:this.itemCls});b=true}return b},setRecurringMeetingRequestInfo:function(a){var b=this.record.get("recurring_pattern"),c=false;if(b){a.createChild({tag:"div",
html:Ext.util.Format.htmlEncode(b),cls:this.itemCls});c=true}return c}});Ext.reg("zarafa.extrainfolinks",Zarafa.common.ui.messagepanel.ExtraInfoLinks);Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.AttachmentLinks=Ext.extend(Ext.DataView,{ellipsisStringStartLength:20,ellipsisStringEndLength:20,fieldLabel:pgettext("mail.previewpanel","Attachments"),constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.attachmentlinks",border:false,autoScroll:true,anchor:"100%",cls:"preview-header-attachments",multiSelect:false,overClass:"zarafa-attachment-link-over",itemSelector:"a.zarafa-attachment-link",tpl:new Ext.XTemplate('<div class="preview-header-attachmentbox"><span class="preview-attachment-title">{this.fieldLabel}:</span><tpl for="."><a class="zarafa-attachment-link x-zarafa-boxfield-item" href="#" viewIndex="{viewIndex}">{values.name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)} ({values.size:fileSize})</a> </tpl></div>',
{compiled:true,fieldLabel:a.fieldLabel||this.fieldLabel,ellipsisStringStartLength:a.ellipsisStringStartLength||this.ellipsisStringStartLength,ellipsisStringEndLength:a.ellipsisStringEndLength||this.ellipsisStringEndLength})});this.fieldLabel=a.fieldLabel||this.fieldLabel;delete a.fieldLabel;Zarafa.common.ui.messagepanel.AttachmentLinks.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.common.ui.messagepanel.AttachmentLinks.superclass.initComponent.call(this);this.mon(this,"contextmenu",
this.onNodeContextMenu,this);this.mon(this,"click",this.onAttachmentClicked,this)},collectData:function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];if(e.get("hidden")!==true)b[b.length]=this.prepareData(e.data,e.get("attach_num"),e)}return b},setRecord:function(a){if(a&&a.get("hasattach")&&!a.get("hide_attachments")){if(a.isOpened()){this.bindStore(a.getAttachmentStore());this.setVisible(true)}}else{this.bindStore(null);this.setVisible(false)}},updateIndexes:function(a,b){var c=this.all.elements;
a=a||0;b=b||(b===0?0:c.length-1);for(var d=a;d<=b;d++)c[d].viewIndex=c[d].getAttribute("viewIndex")},prepareData:function(a,b){return Ext.apply({viewIndex:b},a)},getRecords:function(a){for(var b=[],c=0,d=a.length;c<d;c++)b[b.length]=this.getRecord(a[c]);return b},getRecord:function(a){return this.store.getAt(this.store.findExact("attach_num",parseInt(a.viewIndex,10)))},onAttachmentClicked:function(a,b,c){if(this.store){a=a.getRecord(c);Zarafa.common.Actions.openViewRecord(a)}},onNodeContextMenu:function(a,
b,c,d){Zarafa.common.Actions.openContextMenu(a.getRecord(c),d.getXY(),{model:this.model})}});Ext.reg("zarafa.attachmentlinks",Zarafa.common.ui.messagepanel.AttachmentLinks);Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.SwitchBorderLayout=Ext.extend(Ext.layout.BorderLayout,{horizontalRegion:undefined,verticalRegion:undefined,switchMap:{north:"west",west:"north",south:"east",east:"south"},orientation:undefined,onLayout:function(a,b){if(this.rendered)Zarafa.common.ui.layout.SwitchBorderLayout.superclass.onLayout.apply(this,arguments);else{var c=[],d,e,f,g=a.items.items,h=g.length;for(d=0;d<h;d++){e=g[d];f=e.region;e.collapsed&&c.push(e);e.collapsed=false;if(!e.rendered){e.render(b,d);e.getPositionEl().addClass("x-border-panel")}this[f]=
f!="center"&&e.split?new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion(this,e.initialConfig,f):new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion(this,e.initialConfig,f);this[f].render(b,e);if(f!="center"){var i=this.switchMap[f];this[i]=this[f].split?new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion(this,e.initialConfig,i):new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion(this,e.initialConfig,i);this[i].render(b,e,true);if(f==="north"||f==="south"){this.horizontalRegion=
i;this.verticalRegion=f}else{this.horizontalRegion=f;this.verticalRegion=i}}}this.rendered=true;c=this.orientation;delete this.orientation;this.setOrientation(c)}},setOrientation:function(a){if(this.orientation!==a){this.orientation=a;if(this.rendered){var b=this[this.horizontalRegion],c=this[this.verticalRegion];switch(a){case Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.OFF:b.split&&b.splitEl.setVisible(false);c.split&&c.splitEl.setVisible(false);b.setVisible(false);c.setVisible(false);
b.panel.collapse(false);break;case Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.HORIZONTAL:default:c.panel.expand(false);b.setVisible(true);c.setVisible(false);b.split&&b.splitEl.setVisible(true);c.split&&c.splitEl.setVisible(false);break;case Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.VERTICAL:b.panel.expand(false);b.setVisible(false);c.setVisible(true);b.split&&b.splitEl.setVisible(false);c.split&&c.splitEl.setVisible(true);break}this.container.doLayout()}}}});
Ext.Container.LAYOUTS["zarafa.switchborder"]=Zarafa.common.ui.layout.SwitchBorderLayout;Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.CollapsibleLayout=Ext.extend(Ext.layout.FitLayout,{resizeItem:undefined,configureItem:function(a){var b=this.container.items.indexOf(a);if(b<2)if(a.collapsible){this.activeItem=a;a.on("collapse",this.onCollapseState,this);a.on("expand",this.onCollapseState,this)}else this.resizeItem=a;Zarafa.common.ui.layout.CollapsibleLayout.superclass.configureItem.call(this,a,b)},onRemove:function(a){if(a.collapsible){a.un("collapse",this.onCollapseState,this);a.un("expand",this.onCollapseState,
this)}a===this.activeItem&&delete this.activeItem;a===this.resizeItem&&delete this.resizeItem;Zarafa.common.ui.layout.CollapsibleLayout.superclass.onRemove.call(this,a)},doResizeItem:function(){if(this.resizeItem&&this.activeItem){var a=this.container.getInnerHeight?this.container.getInnerHeight():this.container.getHeight(),b=this.activeItem.getHeight();this.resizeItem.setHeight(a-b)}},onCollapseState:function(){this.doResizeItem()},onLayout:function(a,b){Zarafa.common.ui.layout.CollapsibleLayout.superclass.onLayout.call(this,
a,b);this.doResizeItem()}});Ext.Container.LAYOUTS["zarafa.collapsible"]=Zarafa.common.ui.layout.CollapsibleLayout;Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.InsertDialog=Ext.extend(Ext.Window,{handler:Ext.emptyFn,scope:undefined,formItems:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Insert"),width:250,modal:true,autoHeight:true,layout:"fit",items:[{xtype:"form",plugins:["zarafa.inputautofocusplugin"],ref:"formPanel",layout:"form",border:false,autoHeight:true,plain:true,bodyStyle:"padding: 10px; background-color: inherit",monitorValid:true,labelWidth:80,labelAlign:"right",defaults:{anchor:"100%"},items:a.formItems,
buttons:[{text:_("Insert"),handler:this.onInsert,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.ui.htmleditor.InsertDialog.superclass.constructor.call(this,a)},formatHTML:function(){return""},onInsert:function(){Ext.isFunction(this.handler)&&this.handler.call(this.scope,this.formatHTML(this.formPanel.getForm().getFieldValues()));this.close()},onCancel:function(){this.close()}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.HtmlEditorPlugin=Ext.extend(Ext.util.Observable,{editor:undefined,buttons:undefined,btnCfg:undefined,tabIndex:undefined,index:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.common.ui.htmleditor.HtmlEditorPlugin.superclass.constructor.call(this,a)},init:function(a){this.buttons=[];this.editor=a;this.editor.on("render",this.onRender,this)},onRender:function(){Ext.isEmpty(this.buttons)||this.addButton(this.buttons);Ext.isEmpty(this.btnCfg)||this.addButton(this.btnCfg)},
addButton:function(a){this.buttons=this.editor.rendered!==true?this.buttons.concat(a):this.buttons.concat(Ext.isDefined(this.index)?this.editor.getToolbar().insertButton(this.index,a):this.editor.getToolbar().addButton(a))},relayBtnCmd:function(a){this.editor.relayBtnCmd(a)}});Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.RowSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,{constructor:function(){Zarafa.common.ui.grid.RowSelectionModel.superclass.constructor.call(this);this.selections=new Ext.util.MixedCollection(false,function(a){var b=a.getStore();if(b&&Ext.isFunction(b.getRecordKey))return b.getRecordKey(a);return a.id})},clearSelections:function(a){if(!this.isLocked()){if(a!==true){var b=this.grid.store;a=this.selections;a.each(function(c){this.deselectRow(b.indexOfId(b.getRecordKey(c)||
c.id))},this);a.clear()}else this.selections.clear();this.last=false}},isSelected:function(a){var b=this.grid.store;a=Ext.isNumber(a)?b.getAt(a):a;b=b.getRecordKey(a)||a.id;return a&&this.selections.key(b)?true:false}});Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.Renderers={importance:function(a,b){if(a>=0)b.css=Zarafa.core.mapi.Importance.getClassName(a);b.css+=" zarafa-grid-empty-cell";return""},icon:function(a,b,c){b.css=Zarafa.common.ui.IconClass.getIconClass(c);b.css+=" zarafa-grid-empty-cell";return""},attachment:function(a,b,c){if(Ext.isDefined(c)&&c.get("hide_attachments")==true)return"";b.css=a==true?"icon_attachment":"icon_noattachment";b.css+=" zarafa-grid-empty-cell";return""},recurrence:function(a,b){b.css=a?"icon_recurring":
"zarafa-grid-empty-cell";return""},reminder:function(a,b){b.css=a?"icon_reminder":"zarafa-grid-empty-cell";return""},flag:function(a,b,c){switch(Zarafa.core.mapi.FlagStatus.get(c.get("flag_status"))){case Zarafa.core.mapi.FlagStatus.completed:b.css="icon_mail_completed";break;case Zarafa.core.mapi.FlagStatus.flagged:b.css="icon_mail_flag_"+Zarafa.core.mapi.FlagIcon.getName(c.get("flag_icon"));break;default:b.css="icon_mail_flag";break}return""},name:function(a,b){b.css="mail_from";if(Ext.isEmpty(a))b.css+=
" zarafa-grid-empty-cell";return Ext.util.Format.htmlEncode(a)},subject:function(a,b){b.css="mail_subject";if(Ext.isEmpty(a))b.css+=" zarafa-grid-empty-cell";return Ext.util.Format.htmlEncode(a)},text:function(a,b){if(Ext.isEmpty(a))b.css="zarafa-grid-empty-cell";return Ext.util.Format.htmlEncode(a)},to:function(a,b){b.css="mail_to";if(Ext.isEmpty(a))b.css+=" zarafa-grid-empty-cell";return Ext.util.Format.htmlEncode(a)},size:function(a,b){b.css="mail_size";if(Ext.isEmpty(a))b.css+=" zarafa-grid-empty-cell";
return Ext.util.Format.fileSize(a)},percentage:function(a,b){b.css="task_percentage";return a*100+"%"},date:function(a,b){b.css="mail_date";return Ext.isDate(a)?a.format(_("l d/m/Y")):_("None")},datetime:function(a,b){b.css="mail_date";return Ext.isDate(a)?a.format(_("l d/m/Y G:i")):_("None")},duration:function(a,b){b.css="mail_duration";return Ext.util.Format.duration(a,1)},durationHours:function(a,b){b.css="mail_duration";return String.format(ngettext("{0} hour","{0} hours",a),a)},folder:function(a){return(a=
container.getHierarchyStore().getFolder(a))?a.get("display_name"):_("Unknown")},busystatus:function(a){return Zarafa.core.mapi.BusyStatus.getDisplayName(a)},label:function(a){return Zarafa.core.mapi.AppointmentLabels.getDisplayName(a)},sensitivity:function(a){return Zarafa.core.mapi.Sensitivity.getDisplayName(a)},meetingstatus:function(a){return Zarafa.core.mapi.MeetingStatus.getDisplayName(a)},recipienttype:function(a,b,c){switch(a){case Zarafa.core.mapi.RecipientType.MAPI_TO:case Zarafa.core.mapi.RecipientType.MAPI_ORIG:if(c.isMeetingOrganizer())return _("Meeting Organizer");
return _("Required Attendee");case Zarafa.core.mapi.RecipientType.MAPI_CC:default:return _("Optional Attendee");case Zarafa.core.mapi.RecipientType.MAPI_BCC:return _("Resource")}},responsestatus:function(a){return Zarafa.core.mapi.ResponseStatus.getDisplayName(a)},dueBy:function(a,b,c){b="";if(Zarafa.core.MessageClass.isClass(c.get("message_class"),"IPM.Task",true))a=c.get("task_duedate");if(!Ext.isDate(a))return b;a=a.getTime();c=(new Date).getTime();b=Math.floor(Math.abs(a-c)/6E4);if(b==0)return _("Now");
else b=Ext.util.Format.duration(b);if(a-c<0)return String.format(_("{0} overdue"),b);return b},taskstatus:function(a){return Zarafa.core.mapi.TaskStatus.getDisplayName(a)}};Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.GridView=Ext.extend(Ext.grid.GroupingView,{disableScrollToTop:undefined,constructor:function(a){Ext.applyIf(a,{enableGrouping:true,enableGroupingMenu:false,groupTextTpl:'{text:htmlEncode} ({values.rs.length} {[ngettext("Item","Items", values.rs.length)]})',disableScrollToTop:true,deferEmptyText:true,emptyText:'<div class="emptytext">'+_("There are no items to show in this view")+"</div>",forceFit:true});Zarafa.common.ui.grid.GridView.superclass.constructor.call(this,a);this.initEvents()},
initEvents:function(){Zarafa.common.ui.grid.GridView.superclass.initEvents.call(this);this.on("rowremoved",this.onRowRemoved,this)},initData:function(){this.ds&&this.ds.un("exception",this.onException,this);Zarafa.common.ui.grid.GridView.superclass.initData.apply(this,arguments);this.ds&&this.ds.on("exception",this.onException,this)},onException:function(a,b,c,d,e){d&&d.actionType==="list"&&this.mainBody.update('<div class="x-grid-empty"><div class="emptytext">'+e.error.info.display_message+"</div></div>")},
onLoad:function(){this.disableScrollToTop!==true&&Ext.isDefined(this.scroller.dom)&&Zarafa.common.ui.grid.GridView.superclass.onLoad.apply(this,arguments)},onDataChange:function(){Zarafa.common.ui.grid.GridView.superclass.onDataChange.apply(this,arguments);this.applyEmptyText()},applyEmptyText:function(){this.grid.store.isExecuting(Zarafa.core.Actions.list)||Zarafa.common.ui.grid.GridView.superclass.applyEmptyText.call(this)},afterRenderUI:function(){Zarafa.common.ui.grid.GridView.superclass.afterRenderUI.apply(this,
arguments);if(this.dragZone){this.dragZone.destroy();this.dragZone=new Zarafa.common.ui.grid.GridDragZone(this.grid,{ddGroup:this.grid.ddGroup||"GridDD"})}},afterRender:function(){Zarafa.common.ui.grid.GridView.superclass.afterRender.apply(this,arguments);var a=this.grid.store;if(this.deferEmptyText===false&&a)if(!a.lastOptions||!Ext.isEmpty(Object.keys(a.lastOptions)))this.applyEmptyText()},onColConfigChange:function(){this.grid.initState();Zarafa.common.ui.grid.GridView.superclass.onColConfigChange.apply(this,
arguments)},onRowRemoved:function(a,b){var c=this.grid.getSelectionModel(),d=this.grid.store.getCount();if(d>0)b<d?c.selectRow(b):c.selectRow(b-1);else{c.clearSelections();c.fireEvent("selectionchange",c)}}});Ext.reg("zarafa.gridview",Zarafa.common.ui.grid.GridView);Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.GridPanel=Ext.extend(Ext.grid.GridPanel,{currentEntryId:undefined,currentStoreEntryId:undefined,constructor:function(a){a=a||{};if(Ext.isEmpty(a.view)){a.viewConfig=Ext.applyIf(a.viewConfig||{},{autoFill:true});Ext.applyIf(a,{view:new Zarafa.common.ui.grid.GridView(a.viewConfig)})}Zarafa.common.ui.grid.GridPanel.superclass.constructor.call(this,a)},initEvents:function(){this.bindColumnModel(this.getColumnModel(),true);this.bindStore(this.getStore(),true);Zarafa.common.ui.grid.GridPanel.superclass.initEvents.call(this);
if(this.loadMask){this.loadMask.destroy();this.loadMask=new Zarafa.common.ui.LoadMask(this.bwrap,Ext.apply({store:this.store},this.initialConfig.loadMask))}this.mon(this,"viewready",this.onViewReady,this)},reconfigure:function(a,b){this.bindColumnModel(b);this.bindStore(a);Zarafa.common.ui.grid.GridPanel.superclass.reconfigure.call(this,a,b)},bindColumnModel:function(a,b){var c=this.getColumnModel();if(b===true||c!==a){if(c){this.mun(c,"beforeconfigchange",this.onBeforeConfigChange,this);this.mun(c,
"configchange",this.onConfigChange,this)}if(a){this.mon(a,"beforeconfigchange",this.onBeforeConfigChange,this);this.mon(a,"configchange",this.onConfigChange,this)}}},bindStore:function(a,b){var c=this.getStore();if(b===true||c!==a){if(c){this.mun(c,"beforeload",this.onStoreBeforeLoad,this);this.mun(c,"load",this.onStoreLoad,this)}if(a){this.mon(a,"beforeload",this.onStoreBeforeLoad,this);this.mon(a,"load",this.onStoreLoad,this);a.lastOptions&&this.onStoreBeforeLoad(a,a.lastOptions)}}},onViewReady:function(){var a=
this.store&&(this.store.isExecuting(Zarafa.core.Actions.list)===true||this.store.isExecuting(Zarafa.core.Actions.search)===true);this.loadMask&&a&&this.loadMask.show()},onStoreBeforeLoad:function(a,b){var c=this.getColumnModel(),d=b.folder,e,f;if(!Ext.isEmpty(d))if(Ext.isArray(d)){e=d[0].get("entryid");f=d[0].get("store_entryid")}else{e=d.get("entryid");f=d.get("store_entryid")}if(this.currentEntryId!==e){this.currentEntryId=e;this.currentStoreEntryId=f;c.setConfig(c.columns,false)}},onStoreLoad:Ext.emptyFn,
onBeforeConfigChange:Ext.emptyFn,onConfigChange:Ext.emptyFn,getDragDropText:function(){var a=this.selModel.getCount();return String.format(ngettext("{0} selected row","{0} selected rows",a),a)},getStateName:function(){var a=this.store.lastOptions,b;if(a&&a.folder){b=a.folder;if(Ext.isArray(b))b=b[0]}return container.getHierarchyStore().getStateName(b,"list")},getState:function(){var a=Zarafa.common.ui.grid.GridPanel.superclass.getState.call(this),b={sort:a.sort};delete a.sort;b[this.getColumnModel().name]=
a;return b},applyState:function(a){if(a){var b={sort:a.sort};delete a.sort;Ext.apply(b,a[this.getColumnModel().name]);Zarafa.common.ui.grid.GridPanel.superclass.applyState.call(this,b)}}});Ext.reg("zarafa.gridpanel",Zarafa.common.ui.grid.GridPanel);Ext.namespace("Zarafa.common.ui.grid");Zarafa.common.ui.grid.PriorityPicker=function(a){a=a||{};Ext.apply(this,a);Zarafa.common.ui.grid.PriorityPicker.superclass.constructor.call(this,arguments)};
Ext.extend(Zarafa.common.ui.grid.PriorityPicker,Ext.form.ComboBox,{triggerAction:"all",mode:"local",lazyRenderer:true,scope:this,store:new Ext.data.ArrayStore({id:0,fields:["value","displayText"],data:[[0,'<span class="importance_combobox icon_importance_nonurgent">'+_("Low")+"</span>"],[1,'<span class="importance_combobox ">'+_("Normal")+"</span>"],[2,'<span class="importance_combobox icon_importance_urgent">'+_("High")+"</span>"]]}),valueField:"value",displayField:"displayText",listeners:{select:function(){this.gridEditor.completeEdit()},
afterrender:function(){this.expand()}}});Ext.reg("prioritypicker",Zarafa.common.ui.grid.PriorityPicker);Zarafa.common.ui.grid.CompleteSpinner=function(a){a=a||{};Ext.apply(this,a);Ext.apply(this,{allowBlank:false,defaultValue:"0",incrementValue:25,enableKeyEvents:true,minValue:"0",maxValue:"100"});Zarafa.common.ui.grid.CompleteSpinner.superclass.constructor.call(this,arguments)};
Ext.extend(Zarafa.common.ui.grid.CompleteSpinner,Ext.ux.form.SpinnerField,{listeners:{spinup:function(){var a=this.incrementValue+(parseInt(this.getEl().dom.value.trim("%"),10)-1);this.maxValue>=a&&this.setValue(a)},spindown:function(){var a=parseInt(this.getEl().dom.value.trim("%"),10)+1-this.incrementValue;this.minValue<=a&&this.setValue(a)},render:function(){this.getEl().dom.value=parseInt(this.value)*100}}});Ext.reg("completespinner",Zarafa.common.ui.grid.CompleteSpinner);Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.GridDragZone=Ext.extend(Ext.grid.GridDragZone,{getDragData:function(a){var b=this.view.findRowIndex(Ext.lib.Event.getTarget(a));if(b!==false){var c=this.grid.selModel;a=new Ext.EventObjectImpl(a);return{grid:this.grid,ddel:this.ddel,rowIndex:b,selections:c.getSelections(),origEvent:a}}return false},onInitDrag:function(){var a=this.dragData;if(a&&a.origEvent){var b=this.grid.selModel;if(!b.isSelected(a.rowIndex)){b.handleMouseDown(this.grid,a.rowIndex,a.origEvent);a.selections=
b.getSelections()}delete this.dragData.origEvent}Zarafa.common.ui.grid.GridDragZone.superclass.onInitDrag.apply(this,arguments)},onMouseUp:function(){var a=this.dragData;if(a&&a.origEvent){a.grid.selModel.handleMouseDown(a.grid,a.rowIndex,a.origEvent);delete a.origEvent}Zarafa.common.ui.grid.GridDragZone.superclass.onMouseUp.apply(this,arguments)}});Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.ColumnModel=Ext.extend(Ext.grid.ColumnModel,{name:"default",constructor:function(a){this.addEvents("beforeconfigchange");Zarafa.common.ui.grid.ColumnModel.superclass.constructor.call(this,a)},setConfig:function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)c.push(Ext.apply({},a[d]));this.fireEvent("beforeconfigchange",this,c)!==false&&Zarafa.common.ui.grid.ColumnModel.superclass.setConfig.call(this,c,b)},setState:function(){Zarafa.common.ui.grid.ColumnModel.superclass.setState.apply(this,
arguments);this.totalWidth=null}});Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.TreeGrid=Ext.extend(Ext.ux.tree.TreeGrid,{autoFill:false,forceFit:false,unselectable:true,initComponent:function(){if(this.rootVisible===true)if(this.root){this.root.attributes.uiProvider=Ext.ux.tree.TreeGridNodeUI;this.root.ui=new this.root.attributes.uiProvider(this.root)}else this.root=new Ext.tree.AsyncTreeNode({text:_("Root"),uiProvider:Ext.ux.tree.TreeGridNodeUI});Zarafa.common.ui.TreeGrid.superclass.initComponent.call(this)},onRender:function(){Zarafa.common.ui.TreeGrid.superclass.onRender.apply(this,
arguments);if(this.autoFill||this.forceFit)this.autoFitColumns(true);this.unselectable&&this.getEl().unselectable()},getScrollOffset:function(){return Ext.num(this.scrollOffset,Ext.getScrollBarWidth())},autoFitColumns:function(a,b){for(var c=this.innerBody.getWidth()-this.getScrollOffset(),d=[],e=0,f=this.columns.length;e<f;e++){var g=this.columns[e];if(!g.hidden){c-=g.width;!g.fixed&&e!==b&&!(a&&g.width)&&d.push(g)}}c=Math.floor(c/d.length);e=0;for(f=d.length;e<f;e++)d[e].width+=c},updateColumnWidths:function(){this.forceFit&&
this.autoFitColumns(false,this.colResizer.hdIndex);Zarafa.common.ui.TreeGrid.superclass.updateColumnWidths.call(this)}});Ext.reg("zarafa.treegrid",Zarafa.common.ui.TreeGrid);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.SplitFieldLabeler=Ext.extend(Ext.util.Observable,{labelCfg:{style:"text-align: left; padding: 3px 3px 3px 3px"},firstLabelCfg:{style:"text-align: left; padding: 0xp 3px 3px 3px"},lastLabelCfg:{style:"text-align: left; padding: 3px 3px 3px 3px"},init:function(a){if(!(!Ext.isDefined(a.items)||!Ext.isDefined(a.fieldLabel)||a.hideLabel===true)){var b=this.createLabelDistribution(a.items,a.fieldLabel);b=this.applyLabelDistribution(a.items,b);this.applyLabelWidths(a.labelWidth,b);if(Ext.isArray(a.items))a.items=
b;else{a.items.clear();a.items.addAll(b);a.innerCt.items.clear();a.innerCt.items.addAll(b)}a.hideLabel=true;delete a.fieldLabel}},createLabelDistribution:function(a,b){var c=[],d=function(e){Ext.isDefined(e.labelSplitter)&&c.push(e.labelSplitter)};Ext.isArray(a)?Ext.each(a,d,this):a.each(d,this);return Zarafa.Translations.MultiSplitTranslation(b,c)},applyLabelDistribution:function(a,b){for(var c=[],d=0;d<b.length;d++){var e=undefined,f=b[d],g=function(h){if(h.labelSplitter===b[d]){e=h;return false}};
Ext.isArray(a)?Ext.each(a,g,this):a.each(g,this);Ext.isDefined(e)?c.push(e):c.push(Ext.apply({},this.labelCfg,{xtype:"label",text:f}))}c[0].xtype=="label"&&Ext.apply(c[0],this.firstLabelCfg);c[c.length-1].xtype=="label"&&Ext.apply(c[c.length-1],this.lastLabelCfg);for(d=0;d<c.length;d++)c[d]=Ext.create(c[d]);return c},applyLabelWidths:function(a,b){if(Ext.isNumber(a)){for(var c=0,d=0;d<b.length;d++)if(b[d].xtype=="label")if((!Ext.isDefined(b[d].width)||b[d].width==0)&&!Ext.isEmpty(b[d].text))c+=b[d].text.length;
else a-=b[d].width;for(d=0;d<b.length;d++)if(b[d].xtype=="label")if((!Ext.isDefined(b[d].width)||b[d].width==0)&&!Ext.isEmpty(b[d].text))b[d].width=Math.round(a*(b[d].text.length/c))}}});Ext.preg("zarafa.splitfieldlabeler",Zarafa.common.ui.SplitFieldLabeler);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.SpinnerPlugin=Ext.extend(Ext.ux.Spinner,{doRender:function(a,b){Zarafa.common.ui.SpinnerPlugin.superclass.doRender.call(this,a,b);this.field.trigger=this.trigger;if(!Ext.isDefined(this.field.getTriggerWidth))this.field.getTriggerWidth=Ext.form.TriggerField.prototype.getTriggerWidth},onTriggerClick:function(a){if(!(this.disabled||this.el.dom.readOnly)){var b=this.getMiddle();a=a.getPageY()<b?"Up":"Down";this.el.focus();this["onSpin"+a]()}},isSpinnable:function(){if(this.disabled||
this.rendered&&this.el.dom.readOnly||!Ext.isDefined(this.field.getValue())){Ext.EventObject.preventDefault();return false}return true}});Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.SpinnerField=Ext.extend(Ext.form.TextField,{actionMode:"wrap",deferHeight:true,autoSize:Ext.emptyFn,onBlur:function(){this.beforeBlur();this.focusClass&&this.el.removeClass(this.focusClass);this.hasFocus=false;if(this.validationEvent!==false&&(this.validateOnBlur||this.validationEvent=="blur"))Ext.isDefined(this.plugins)?Ext.each(this.plugins,function(b){Ext.isFunction(b.validate)&&b.validate()},this):this.validate();var a=this.getValue();String(a)!==String(this.startValue)&&this.fireEvent("change",
this,a,this.startValue);this.fireEvent("blur",this);this.postBlur()},adjustSize:Ext.BoxComponent.prototype.adjustSize,defaultValue:undefined,minValue:undefined,maxValue:undefined,incrementValue:1,alternateIncrementValue:10,getResizeEl:function(){return this.resizeEl||this.wrap},getPositionEl:function(){return this.positionEl||this.wrap},alignErrorIcon:function(){this.wrap&&this.errorIcon.alignTo(this.wrap,"tl-tr",[2,0])},validateBlur:function(){return true}});Ext.reg("zarafa.spinnerfield",Zarafa.common.ui.SpinnerField);
Ext.namespace("Zarafa.common");
Zarafa.common.ui.SimpleProgressIndicator=Ext.extend(Ext.Panel,{busyCls:"icon_progress_busy",successCls:"icon_progress_done_ok",failedCls:"icon_progress_done_fail",resetCls:"x-plain",constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.simpleprogressindicator",layout:"fit",bodyStyle:"padding: 5px;background-color: inherit;"});Zarafa.common.ui.SimpleProgressIndicator.superclass.constructor.call(this,a)},changeCls:function(a){this.currentState&&this.removeClass(this.currentState);this.addClass(a);
this.currentState=a},showBusy:function(){this.changeCls(this.busyCls)},showSuccess:function(){this.changeCls(this.successCls)},showFailed:function(){this.changeCls(this.failedCls)},reset:function(){this.changeCls(this.resetCls)}});Ext.reg("zarafa.simpleprogressindicator",Zarafa.common.ui.SimpleProgressIndicator);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.SearchField=Ext.extend(Ext.form.TwinTriggerField,{searchIndicatorClass:"zarafa-tbar-loading",constructor:function(a){Ext.apply(a,{validationEvent:false,validateOnBlur:false,trigger1Class:"x-form-clear-trigger",trigger2Class:"x-form-search-trigger",hideTrigger1:true});this.addEvents("beforestart","start","beforestop","stop");Zarafa.common.ui.SearchField.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.common.ui.SearchField.superclass.initComponent.call(this);this.on("specialkey",
this.onTriggerSpecialKey,this)},onTriggerSpecialKey:function(a,b){if(b.getKey()==b.ENTER){var c=this.getValue();Ext.isEmpty(c)?this.onTrigger1Click():this.onTrigger2Click()}},onTrigger1Click:function(){if(this.fireEvent("beforestop",this)!==false){this.doStop();this.fireEvent("stop",this)}},onTrigger2Click:function(){if(this.fireEvent("beforestart",this)!==false){this.doStart();this.fireEvent("start",this)}},updateEmptyText:function(a){Ext.isEmpty(this.getRawValue())&&this.setRawValue(a);this.emptyText=
a},doStart:function(){this.el.addClass(["x-item-disabled",this.searchIndicatorClass]);this.getTrigger(0).show()},doStop:function(a){this.el.removeClass(["x-item-disabled",this.searchIndicatorClass]);a!==true&&this.getTrigger(0).hide()}});Ext.reg("zarafa.searchfield",Zarafa.common.ui.SearchField);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.SearchBar=Ext.extend(Ext.Panel,{searchFields:undefined,subfolders:false,context:undefined,model:undefined,errorMsgEmpty:_("Please enter text to start search."),errorMsgCombo:_("Please select search option from combobox."),constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();Ext.applyIf(a,{xtype:"zarafa.searchbar",cls:"zarafa-searchbar",header:true,
hidden:false,border:false,hideBorders:true,collapsible:true,collapsed:true,autoHeight:true,layout:"fit",items:[{xtype:"container",layout:"form",autoHeight:true,style:"padding: 5px; ",items:[{xtype:"combo",fieldLabel:_("Search in"),triggerAction:"all",mode:"local",store:{xtype:"jsonstore",fields:["name","value"],data:a.searchFields},lazyInit:false,forceSelection:true,autoSelect:true,editable:false,valueField:"value",displayField:"name",value:a.searchFields[0].value,ref:"../searchFieldsCombo"},{xtype:"checkbox",
boxLabel:_("subfolders"),checked:a.subfolders,ref:"../subfolderCheckbox",listeners:{scope:this,check:this.subfolderOnCheck}}]}]});this.addEvents("beforesearchstart","searchstart","searchupdate","searchstop","searchfinish");Zarafa.common.ui.SearchBar.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.ui.SearchBar.superclass.initEvents.apply(this,arguments);this.mon(this.model,{folderchange:this.onModelFolderChange,searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,
searchfinished:this.onModelSearchFinished,searchexception:this.onModelSearchException,scope:this});this.onModelFolderChange(this.model,this.model.getFolders())},onRender:function(){Zarafa.common.ui.SearchBar.superclass.onRender.apply(this,arguments);if(this.header){this.header.selectable();this.tools.toggle.unselectable();this.searchTextfield=Ext.create({xtype:"zarafa.searchfield",renderTo:this.header,style:"float: left;",boxMinWidth:100,boxMaxWidth:400,emptyText:this.getEmptySearchText(this.model.getDefaultFolder()),
listeners:{scope:this,beforestart:this.onBeforeStartSearch,start:this.onStartSearch,stop:this.onStopSearch}})}},onResize:function(a){Zarafa.common.ui.SearchBar.superclass.onResize.apply(this,arguments);if(Ext.isDefined(a)){var b=this.tools&&this.tools.toggle?this.tools.toggle.getWidth()+this.tools.toggle.getFrameWidth("rl"):0,c=this.searchTextfield.getEl().getFrameWidth("lr")+2;this.searchTextfield.setWidth(a-b-c)}},getEmptySearchText:function(a){return Ext.isDefined(a)?String.format(_("Search in '{0}'"),
a.get("display_name")):_("Search in folder")},subfolderOnCheck:function(a,b){this.subfolders=b?true:false},onBeforeStartSearch:function(){if(this.fireEvent("beforesearchstart",this)===false)return false;if(Ext.isEmpty(this.searchTextfield.getValue())){container.getNotifier().notify("error.search",_("Error"),this.errorMsgEmpty);return false}if(Ext.isEmpty(this.searchFieldsCombo.getValue())){container.getNotifier().notify("error.search",_("Error"),this.errorMsgCombo);return false}return true},onStartSearch:function(){this.model.startSearch(this.createRestriction(this.searchTextfield.getValue(),
this.searchFieldsCombo.getValue()),this.subfolders)},createRestriction:function(a,b){if(Ext.isEmpty(a)||Ext.isEmpty(b))return[];var c=[],d=[],e=b.split(" "),f=a.split(" ");!Ext.isEmpty(e)&&!Ext.isEmpty(f)&&Ext.each(f,function(g){var h=[];Ext.each(e,function(i){h.push(Zarafa.core.data.RestrictionFactory.dataResContent(i,Zarafa.core.mapi.Restrictions.FL_SUBSTRING|Zarafa.core.mapi.Restrictions.FL_IGNORECASE,g))},this);d.push(Zarafa.core.data.RestrictionFactory.createResOr(h))},this);Ext.isEmpty(d)||
(c=Zarafa.core.data.RestrictionFactory.createResAnd(d));return c},onStopSearch:function(){this.model.stopSearch();this.searchTextfield.focus()},toggleComponents:function(a){this.searchFieldsCombo.setDisabled(!a);this.subfolderCheckbox.setDisabled(!a)},onModelFolderChange:function(a,b){var c=this.model.supportsSearchFolder();this.searchTextfield.updateEmptyText(this.getEmptySearchText(b[0]));this.toggleComponents(c);this.subfolderCheckbox.setValue(c?this.subfolders:false)},onModelSearchStart:function(){this.toggleComponents(false)},
onModelSearchStop:function(){this.searchTextfield.reset();this.searchTextfield.doStop(false);this.toggleComponents(true)},onModelSearchFinished:function(){this.searchTextfield.doStop(true);this.toggleComponents(true)},onModelSearchException:function(a,b,c,d,e,f){!Ext.isEmpty(f)&&!Ext.isEmpty(f.error_message)&&container.getNotifier().notify("error.search",_("Error"),f.error_message);this.searchTextfield.doStop(false);this.searchTextfield.focus();this.toggleComponents(true)}});
Ext.reg("zarafa.searchbar",Zarafa.common.ui.SearchBar);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.PagingToolbar=Ext.extend(Ext.PagingToolbar,{displayRefresh:false,displayInfo:false,initComponent:function(){var a=[this.first=new Ext.Toolbar.Button({tooltip:this.firstText,overflowText:this.firstText,iconCls:"x-tbar-page-first",disabled:true,handler:this.moveFirst,scope:this}),this.prev=new Ext.Toolbar.Button({tooltip:this.prevText,overflowText:this.prevText,iconCls:"x-tbar-page-prev",disabled:true,handler:this.movePrevious,scope:this}),"-",this.beforePageText,this.inputItem=new Ext.form.NumberField({cls:"x-tbar-page-number",
allowDecimals:false,allowNegative:false,enableKeyEvents:true,selectOnFocus:true,submitValue:false,listeners:{scope:this,keydown:this.onPagingKeyDown,blur:this.onPagingBlur}}),this.afterTextItem=new Ext.Toolbar.TextItem({text:String.format(this.afterPageText,1)}),"-",this.next=new Ext.Toolbar.Button({tooltip:this.nextText,overflowText:this.nextText,iconCls:"x-tbar-page-next",disabled:true,handler:this.moveNext,scope:this}),this.last=new Ext.Toolbar.Button({tooltip:this.lastText,overflowText:this.lastText,
iconCls:"x-tbar-page-last",disabled:true,handler:this.moveLast,scope:this})],b=this.items||this.buttons||[];this.items=this.prependButtons?b.concat(a):a.concat(b);delete this.buttons;if(this.displayRefresh){this.items.push("-");this.items.push(this.refresh=new Ext.Toolbar.Button({tooltip:this.refreshText,overflowText:this.refreshText,iconCls:"x-tbar-loading",handler:this.doRefresh,scope:this}))}if(this.displayInfo){this.items.push("->");this.items.push(this.displayItem=new Ext.Toolbar.TextItem({}))}Ext.PagingToolbar.superclass.initComponent.call(this);
this.addEvents("change","beforechange");this.on("afterlayout",this.onFirstLayout,this,{single:true});this.cursor=0;this.bindStore(this.store,true)},bindStore:function(){Zarafa.common.ui.PagingToolbar.superclass.bindStore.apply(this,arguments);this.store?this.mon(this.store,"beforeupdatesearch",this.updateInfo,this):this.mun(this.store,"beforeupdatesearch",this.updateInfo,this)},updateInfo:function(){if(this.displayItem){var a=this.store.getCount();this.displayItem.setText(a==0?this.emptyMsg:String.format(this.displayMsg,
this.cursor+1,this.cursor+a,this.store.getTotalCount()))}},onLoad:function(a,b,c){if(this.rendered){a=this.getParams();this.cursor=c.params&&c.params.restriction&&c.params.restriction[a.restriction.start]?c.params.restriction[a.restriction.start]:0;c=this.getPageData();a=c.activePage;b=c.pages;this.afterTextItem.setText(String.format(this.afterPageText,c.pages));this.inputItem.setValue(a);this.first.setDisabled(a==1);this.prev.setDisabled(a==1);this.next.setDisabled(a==b);this.last.setDisabled(a==
b);this.refresh&&this.refresh.enable();this.updateInfo();this.fireEvent("change",this,c)}else this.dsLoaded=[a,b,c]},onLoadError:function(){this.rendered&&this.refresh&&this.refresh.enable()},getParams:function(){var a=this.paramNames||this.store.paramNames;if(Ext.isDefined(a.start)){a.restriction=a.restriction||{};a.restriction.start=a.start;delete a.start}if(Ext.isDefined(a.limit)){a.restriction=a.restriction||{};a.restriction.limit=a.limit;delete a.limit}return a},doLoad:function(a){var b={restriction:{}},
c=this.getParams();b.restriction[c.restriction.start]=a;b.restriction[c.restriction.limit]=this.pageSize;this.fireEvent("beforechange",this,b)!==false&&this.store.load({folder:this.store.lastOptions.folder,params:b})}});Ext.reg("zarafa.paging",Zarafa.common.ui.PagingToolbar);
Zarafa.common.ui.LoadMask=Ext.extend(Ext.LoadMask,{msg:_("Loading..."),failureMsg:_("Failed"),failureMsgCls:"x-mask-error",onLoad:function(a,b,c){c&&c.actionType===Zarafa.core.Actions.updatesearch||Zarafa.common.ui.LoadMask.superclass.onLoad.apply(this,arguments)},onBeforeLoad:function(a,b){b&&b.actionType===Zarafa.core.Actions.updatesearch||Zarafa.common.ui.LoadMask.superclass.onBeforeLoad.apply(this,arguments)},showError:function(){this.el.unmask(false);this.el.mask(this.failureMsg,this.failureMsgCls)}});
Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.IconClass={getIconClass:function(a){var b=a.get("icon_index"),c=a.get("object_type"),d="";if(b!==Zarafa.core.mapi.IconIndex.appt_recurring&&b!==Zarafa.core.mapi.IconIndex.appt_appointment||!Zarafa.core.MessageClass.isClass(a.get("message_class"),"IPM.Schedule.Meeting",true))d=Zarafa.core.mapi.IconIndex.getClassName(b,"icon");if(Ext.isEmpty(d))switch(c){case Zarafa.core.mapi.ObjectType.MAPI_STORE:case Zarafa.core.mapi.ObjectType.MAPI_FOLDER:d=this.getIconClassFromContainerClass(a);break;
case Zarafa.core.mapi.ObjectType.MAPI_MESSAGE:d=this.getIconClassFromMessageClass(a);break;case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:d=this.getIconClassFromDisplayType(a);break;default:b=a.get("distlist_type");if(Ext.isDefined(b))d=this.getIconClassFromDistlistType(a)}if(c===Zarafa.core.mapi.ObjectType.MAPI_MESSAGE){d+=Ext.isFunction(a.isRead)&&!a.isRead()?" icon_message_unread":" icon_message_read";if(Ext.isFunction(a.isRecurring)&&
a.isRecurring())d+=" icon_message_recurring"}return d},getIconClassFromContainerClass:function(a,b){if(a){if(a.isIPMSubTree()){var c=a.getMAPIStore();if(c.isSharedStore()){c=c.get("folder_type");return c==="all"?"icon_folder_shared_store":"icon_folder_shared_"+c}else return c.isPublicStore()?"icon_folder_public_store":"icon_folder_store"}if(c=a.getDefaultFolderKey())return"icon_folder_default_"+c.toLowerCase();b=b||a.get("container_class")}return Zarafa.core.ContainerClass.isClass(b,"IPF.Note.OutlookHomepage",
true)?"icon_folder_rss":Zarafa.core.ContainerClass.isClass(b,"IPF",true)?"icon_folder_"+b.toLowerCase().split(".")[1]:"icon_folder_note"},getIconClassFromMessageClass:function(a,b){var c=false,d=false;if(a){if(a.get("stubbed"))return"icon_mail_stubbed";c=Ext.isFunction(a.isRecurring)&&a.isRecurring();d=a.get("counter_proposal");b=b||a.get("message_class")}if(b){b=b.toUpperCase();c={"IPM.APPOINTMENT":"icon_appt_appointment","IPM.TASK":"icon_task_normal","IPM.TASKREQUEST":"icon_taskrequest","IPM.TASKREQUEST.DECLINE":"icon_taskrequest_decline",
"IPM.TASKREQUEST.ACCEPT":"icon_taskrequest_accepted","IPM.STICKYNOTE":"icon_note_yellow","IPM.CONTACT":"icon_contact_user","IPM.DISTLIST":"icon_contact_distlist","IPM.DISTLIST.ORGANIZATION":"icon_contact_distlist_organization","IPM.SCHEDULE.MEETING.REQUEST":c?"icon_appt_meeting_recurring":"icon_appt_meeting_single","IPM.SCHEDULE.MEETING.RESP.POS":"icon_appt_meeting_accept","IPM.SCHEDULE.MEETING.RESP.TENT":d?"icon_appt_meeting_newtime":"icon_appt_meeting_tentative","IPM.SCHEDULE.MEETING.RESP.NEG":"icon_appt_meeting_decline",
"IPM.SCHEDULE.MEETING.CANCELED":"icon_appt_meeting_cancel","IPM.NOTE":"icon_mail","REPORT.IPM.NOTE.IPNRN":"icon_mail_read_receipt","REPORT.IPM.NOTE.IPNNRN":"icon_mail_nonread_receipt","REPORT.IPM.NOTE.DR":"icon_mail_delivery_receipt","REPORT.IPM.NOTE.NDR":"icon_mail_nondelivery_receipt","IPM.NOTE.STORAGEQUOTAWARNING":"icon_mail icon_message_unread"};do{d=c[b];if(!Ext.isEmpty(d))return d;d=b.lastIndexOf(".");if(d<=0)break;b=b.substr(0,d)}while(1)}return"icon_message"},getIconClassFromDistlistType:function(a,
b){if(a)b=b||a.get("distlist_type");switch(b){case Zarafa.core.mapi.DistlistType.DL_DIST:case Zarafa.core.mapi.DistlistType.DL_DIST_AB:return"icon_contact_distlist";case Zarafa.core.mapi.DistlistType.DL_USER:case Zarafa.core.mapi.DistlistType.DL_USER2:case Zarafa.core.mapi.DistlistType.DL_USER3:case Zarafa.core.mapi.DistlistType.DL_USER_AB:default:return"icon_contact_user"}},getIconClassFromDisplayType:function(a,b){if(a)b=b||a.get("display_type");switch(b){case Zarafa.core.mapi.DisplayType.DT_ORGANIZATION:return"icon_contact_company";
case Zarafa.core.mapi.DisplayType.DT_DISTLIST:case Zarafa.core.mapi.DisplayType.DT_AGENT:case Zarafa.core.mapi.DisplayTypeEx.DT_SEC_DISTLIST:return"icon_contact_distlist";case Zarafa.core.mapi.DisplayType.DT_REMOTE_MAILUSER:return"icon_contact_gab_user";case Zarafa.core.mapi.DisplayTypeEx.DT_ROOM:return"icon_contact_room";case Zarafa.core.mapi.DisplayTypeEx.DT_EQUIPMENT:return"icon_contact_equipment";case Zarafa.core.mapi.DisplayType.DT_MAILUSER:default:return"icon_contact_user"}}};Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.HtmlEditor=Ext.extend(Ext.form.HtmlEditor,{enableExactFontSize:true,enableLink:true,enableUndoRedo:true,enableImage:true,enableTable:true,enableHR:true,enableSpecialCharacters:true,enableIndentOutdent:true,enableSubSuperScript:true,disablePluginsTabIndex:true,record:undefined,enableSystemContextMenu:false,constructor:function(a){a=a||{};a=Ext.applyIf(a,{enableOverflow:true,enableAlignments:true,enableColors:true,enableFont:true,enableFontSize:false,enableFormat:true,enableLinks:false,
enableLists:true,enableSourceEdit:false,defaultValue:"",value:""});if(Ext.isIE)a.enableUndoRedo=false;Ext.apply(this,a);a.plugins=Ext.value(a.plugins,[]);a.plugins=a.plugins.concat(this.createPlugins());this.addEvents("focus","blur","change");Zarafa.common.ui.HtmlEditor.superclass.constructor.call(this,a)},initEditor:function(){Zarafa.common.ui.HtmlEditor.superclass.initEditor.call(this);var a=this.onEditorEvent.createDelegate(this);Ext.EventManager.on(this.getDoc(),{mouseup:a,mouseout:a,buffer:100});
Ext.EventManager.on(this.el,{blur:this.onBlur,focus:this.onFocus,scope:this});Ext.EventManager.on(this.win,{blur:this.onBlur,focus:this.onFocus,scope:this});a=this.tb.items.map;for(var b in a){var c=a[b];c.initialConfig.disabled&&c.setDisabled(true)}},focus:function(a,b){if(b){this.focusTask=new Ext.util.DelayedTask(this.focus,this,[a,false]);this.focusTask.delay(Ext.isNumber(b)?b:10)}else{this.rendered&&!this.isDestroyed&&Zarafa.common.ui.HtmlEditor.superclass.focus.call(this);return this}},onBlur:function(){if(this.hasFocus===
true){var a=this.getValue();if(a.length!=this.originalValue.length||a!==this.originalValue)this.fireEvent("change",this,a,this.originalValue)}this.hasFocus=false;this.fireEvent("blur",this)},onFocus:function(){if(this.hasFocus!==true){this.originalValue=this.getValue();this.hasFocus=true;this.fireEvent("focus",this)}},onRender:function(a,b){Zarafa.common.ui.HtmlEditor.superclass.onRender.call(this,a,b);this.getToolbar().enableOverflow=this.enableOverflow},initFrame:function(){Zarafa.common.ui.HtmlEditor.superclass.initFrame.apply(this,
arguments);this.enableSystemContextMenu!==true&&Ext.get(this.getEditorBody()).on("contextmenu",Ext.emptyFn,null,{preventDefault:true})},createPlugins:function(){var a=[],b=0,c=this.disablePluginsTabIndex?-1:undefined;this.enableExactFontSize&&!Ext.isSafari2&&a.push({ptype:"zarafa.htmleditor.fontsize",tabIndex:c,index:1});this.enableFormat&&a.push({ptype:"zarafa.htmleditor.strikethrough",tabIndex:c,index:6});if(this.enableSubSuperScript){a.push({ptype:"zarafa.htmleditor.superscript",tabIndex:c,index:8});
a.push({ptype:"zarafa.htmleditor.subscript",tabIndex:c,index:9});b++}if(b>0){a.push({ptype:"zarafa.htmleditor.divider",index:10});b=0}if(this.enableIndentOutdent){a.push({ptype:"zarafa.htmleditor.outdent",tabIndex:c,index:18});a.push({ptype:"zarafa.htmleditor.indent",tabIndex:c,index:19});b++}if(b>0){a.push({ptype:"zarafa.htmleditor.divider",index:20});b=0}a.push({ptype:"zarafa.htmleditor.divider"});if(this.enableLink){a.push({ptype:"zarafa.htmleditor.link",tabIndex:c});a.push({ptype:"zarafa.htmleditor.unlink",
tabIndex:c});b++}if(b>0){a.push({ptype:"zarafa.htmleditor.divider"});b=0}if(this.enableUndoRedo){a.push({ptype:"zarafa.htmleditor.undo",tabIndex:c});a.push({ptype:"zarafa.htmleditor.redo",tabIndex:c});b++}if(b>0){a.push({ptype:"zarafa.htmleditor.divider"});b=0}if(this.enableImage){a.push({ptype:"zarafa.htmleditor.image",tabIndex:c});b++}if(this.enableTable){a.push({ptype:"zarafa.htmleditor.table",tabIndex:c});b++}if(this.enableHR){a.push({ptype:"zarafa.htmleditor.hr",tabIndex:c});b++}if(this.enableSpecialCharacters){a.push({ptype:"zarafa.htmleditor.specialcharacters",
tabIndex:c});b++}if(b>0){a.push({ptype:"zarafa.htmleditor.divider"});b=0}if(this.enableRemoveFormat){a.push({ptype:"zarafa.htmleditor.removeformat",tabIndex:c});b++}b>0&&a.push({ptype:"zarafa.htmleditor.divider"});this.enableWord&&a.push({ptype:"zarafa.htmleditor.word",tabIndex:c});return a},relayInsertAtCursor:function(a){this.focus();this.activated||this.onFirstFocus();this.insertAtCursor(a);this.updateToolbar()},updateToolbar:function(){if(!this.readOnly)if(this.activated){var a=this.tb.items.map,
b=this.getDoc();if(this.enableFont&&!Ext.isSafari2){var c=b.queryCommandValue("FontName");if(c){c=c.toLowerCase();c=c.replace(/\'/g,"");c=c.replace(/, /g,",");var d=c.split(",");c=false;for(var e=0,f=d.length;e<f;e++){for(var g=0,h=this.fontFamilies.length;g<h;g++){var i=this.fontFamilies[g].toLowerCase();if(d[e]===i){c=i;break}}if(c)break}}else c=this.defaultFont.toLowerCase();if(c!=this.fontSelect.dom.value)this.fontSelect.dom.value=c;c=b.queryCommandValue("FontSize")||a.fontSize.defaultFontSize;
if(c!=a.fontSize.el.dom.value)a.fontSize.el.dom.value=c}if(this.enableFormat){a.bold.toggle(b.queryCommandState("bold"));a.italic.toggle(b.queryCommandState("italic"));a.underline.toggle(b.queryCommandState("underline"));a.strikeThrough.toggle(b.queryCommandState("strikeThrough"))}if(this.enableAlignments){a.justifyleft.toggle(b.queryCommandState("justifyleft"));a.justifycenter.toggle(b.queryCommandState("justifycenter"));a.justifyright.toggle(b.queryCommandState("justifyright"))}if(!Ext.isSafari2&&
this.enableLists){a.insertorderedlist.toggle(b.queryCommandState("insertorderedlist"));a.insertunorderedlist.toggle(b.queryCommandState("insertunorderedlist"))}if(this.enableLink){c=false;d=b.getSelection();if(d.rangeCount){d=d.getRangeAt(0);if(!d.collapsed)if(d.startContainer===d.endContainer){c=Ext.fly(d.startContainer);c=c.is("a")||!Ext.isEmpty(c.parent("a"))}else{c=d.cloneContents();c=!Ext.isEmpty(c.querySelector("a"))}}a.unlink.setDisabled(!c)}if(this.enableUndoRedo){a.undo.setDisabled(!b.queryCommandEnabled("undo"));
a.redo.setDisabled(!b.queryCommandEnabled("redo"))}if(this.enableSubSuperScript){a.superscript.toggle(b.queryCommandState("superscript"));a.subscript.toggle(b.queryCommandState("subscript"))}Ext.menu.MenuMgr.hideAll();this.syncValue()}else this.onFirstFocus()},getSelectedText:function(a){var b=this.getDoc(),c="",d=false,e="";if(this.win.getSelection||b.getSelection){(c=this.win.getSelection())||(c=b.getSelection());if(Ext.isEmpty(c.focusNode))return{textContent:""};a=a?c.getRangeAt(0).extractContents():
c.getRangeAt(0).cloneContents();Ext.each(a.childNodes,function(f){if(f.nodeType!==f.TEXT_NODE)d=true});if(d){b=document.createElement("div");b.appendChild(a);e=b.innerHTML;c=this.win.getSelection()+""}else e=c=a.textContent;return{textContent:c,hasHTML:d,html:e}}else if(b.selection){this.win.focus();c=b.selection.createRange();if(c.text!==c.htmlText)d=true;return{textContent:c.text,hasHTML:d,html:c.htmlText}}return{textContent:""}},getValue:function(){var a=Zarafa.common.ui.HtmlEditor.superclass.getValue.call(this);
return a=Zarafa.core.HTMLParser.inlineImgZarafaToOutlook(a)},setValue:function(a){var b=undefined,c=undefined;if(this.record){b=this.record.getMessageAction("action_type");if(this.record.phantom&&(b=="reply"||b=="replyall"||b=="forward")){b=this.record.getMessageAction("source_entryid");c=this.record.getMessageAction("source_store_entryid")}else{b=this.record.get("entryid");c=this.record.get("store_entryid")}if(c&&b)a=Zarafa.core.HTMLParser.inlineImgOutlookToZarafa(a,c,b)}Zarafa.common.ui.HtmlEditor.superclass.setValue.call(this,
a)},bindRecord:function(a){this.record=a}});Ext.reg("zarafa.htmleditor",Zarafa.common.ui.HtmlEditor);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.FieldLabeler=Ext.extend(Ext.util.Observable,{init:function(a){a.onRender=a.onRender.createSequence(this.onRender);a.onResize=this.onResize;a.adjustPosition=this.adjustPosition;a.onDestroy=a.onDestroy.createSequence(this.onDestroy)},onRender:function(){Ext.ux.FieldLabeler.onRender.apply(this,arguments)},onResize:function(a,b){var c=a,d=b;d=a;if(!(this.layout instanceof Ext.layout.FormLayout))if(Ext.isEmpty(this.flex))d+=this.resizeEl.getPadding("l");else c-=this.resizeEl.getPadding("l");
this.innerCt&&this.innerCt.setSize(c,b);Ext.form.Field.prototype.onResize.apply(this,arguments);this.resizeEl&&this.resizeEl.setWidth(b);this.itemCt&&this.itemCt.setWidth(d);if(this.getTriggerWidth){this.wrap.setWidth(c);this.el.setWidth(c-this.getTriggerWidth())}else this.el.setWidth(c);if(this.el.dom.tagName.toLowerCase()=="textarea"){d=this.resizeEl.getHeight(true);if(!this.hideLabels&&this.labelAlign=="top")d-=this.label.getHeight();this.el.setHeight(d)}if(this instanceof Ext.form.ComboBox)if(!isNaN(c)&&
this.isVisible()&&this.list)this.doResize(c);else this.bufferSize=c},adjustPosition:function(a,b){if(this.ownerCt.layout instanceof Ext.layout.HBoxLayout){a=0;this.ownerCt.items.each(function(c){if(c===this)return false;a+=c.getActionEl().getWidth()},this)}return{x:a,y:b}}});Ext.preg("zarafa.fieldlabeler",Zarafa.common.ui.FieldLabeler);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.EditorField=Ext.extend(Ext.Container,{useHtml:true,htmlXtype:"zarafa.htmleditor",plaintextXtype:"zarafa.textarea",htmlName:"",plaintextName:"",componentConfig:undefined,relayedEvents:["change"],enableSystemContextMenu:true,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.editorfield",layout:"card",items:this.getEditors(a)});Ext.apply(this,a);a.activeItem=this.useHtml?0:1;this.addEvents.apply(this,this.relayedEvents);Zarafa.common.ui.EditorField.superclass.constructor.call(this,
a);this.mon(this,"beforerender",this.onBeforeRender,this)},getEditors:function(a){var b=a.componentConfig;if(!Ext.isDefined(b)){b=Ext.apply({},a);delete b.xtype;delete b.layout;delete b.layoutConfig;delete b.useHtml;delete b.htmlXtype;delete b.plaintextXtype;delete b.relayedEvents;delete b.listeners;delete b.ownerCt;delete b.ref}Ext.applyIf(b,{hideMode:"display",ownerCt:this,enableSystemContextMenu:this.enableSystemContextMenu});return[Ext.apply({},{xtype:a.htmlXtype||this.htmlXtype,name:a.htmlName||
this.htmlName},b),Ext.apply({},{xtype:a.plaintextXtype||this.plaintextXtype,name:a.plaintextName||this.plaintextName},b)]},onBeforeRender:function(){Ext.isEmpty(this.relayedEvents)||this.items.each(function(a){this.relayEvents(a,this.relayedEvents)},this)},setRawValue:function(a){return this.getLayout().activeItem.setRawValue(a)},setValue:function(a){return this.getLayout().activeItem.setValue(a)},getRawValue:function(){return this.getLayout().activeItem.getRawValue()},getValue:function(){return this.getLayout().activeItem.getValue()},
focus:function(a,b){this.getLayout().activeItem.focus(a,b)},reset:function(){this.getLayout().activeItem.reset()},enable:function(){this.items.each(function(a){a.enable()})},disable:function(){this.items.each(function(a){a.disable()})},getName:function(){return this.getLayout().activeItem.getName()},setHtmlEditor:function(a,b){if(this.useHtml!==a){var c=this.getLayout(),d=c.activeItem.getValue();this.useHtml=a;c.setActiveItem(a?0:1);if(b!==false&&!Ext.isEmpty(d)){var e;e=a?Zarafa.core.HTMLParser.convertPlainToHTML(d):
Zarafa.core.HTMLParser.convertHTMLToPlain(d);this.fireEvent("change",this,e,d);c.activeItem.setValue(e)}}},isHtmlEditor:function(){return this.useHtml},insertAtCursor:function(a){this.getLayout().activeItem.insertAtCursor(a)},bindRecord:function(a){this.isHtmlEditor()&&this.getLayout().activeItem.bindRecord(a)}});Ext.reg("zarafa.editorfield",Zarafa.common.ui.EditorField);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.DurationField=Ext.extend(Ext.form.NumberField,{stripCharsRe:/[^0-9]+/,allowDecimals:false,allowNegative:false,processValue:function(a){if(this.stripCharsRe)return a.replace(this.stripCharsRe,"");return a},setValue:function(a){a=this.parseValue(a);a=String.format(ngettext("{0} hour","{0} hours",a),a);Ext.form.NumberField.superclass.setValue.call(this,a)}});Ext.reg("zarafa.durationfield",Zarafa.common.ui.DurationField);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.DraggableDataView=Ext.extend(Ext.DataView,{ddGroup:undefined,enableDragDrop:false,enableDrop:false,dropZone:undefined,dropConfig:undefined,enableDrag:false,dragZone:undefined,dragConfig:undefined,onRender:function(){Zarafa.common.ui.DraggableDataView.superclass.onRender.apply(this,arguments);if((this.enableDragDrop||this.enableDrop)&&!this.dropZone)this.dropZone=new Ext.dd.DropZone(this.getEl(),this.dropConfig||{ddGroup:this.ddGroup||"DataDD"});if((this.enableDragDrop||this.enableDrag)&&
!this.dragZone)this.dragZone=new Zarafa.common.ui.DataDragZone(this,this.dragConfig||{ddGroup:this.ddGroup||"DataDD"})},getDragDropText:function(){var a=this.getSelectionCount();return String.format(ngettext("{0} selected item","{0} selected items",a),a)}});Ext.reg("zarafa.draggabledataview",Zarafa.common.ui.DraggableDataView);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.DisplayField=Ext.extend(Ext.form.DisplayField,{renderer:function(a){return a},rawValue:undefined,setRawValue:function(a){this.rawValue=a;return Zarafa.common.ui.DisplayField.superclass.setRawValue.call(this,this.renderer(a))},getRawValue:function(){return this.rawValue}});Ext.reg("zarafa.displayfield",Zarafa.common.ui.DisplayField);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.DateRangeField=Ext.extend(Ext.Container,{startFieldConfig:{},endFieldConfig:{},spacerConfig:undefined,defaultValue:undefined,defaultPeriod:undefined,defaultPeriodType:Date.MINUTE,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.daterangefield",border:false,bodyStyle:"background-color: inherit;",layout:"form"});this.addEvents("change");if(Ext.isDefined(a.defaultValue)){if(!Ext.isDefined(a.defaultPeriod)){a.defaultPeriodType=Date.MINUTE;a.defaultPeriod=a.defaultValue.getDuration(Date.MINUTE)}}else if(Ext.isDefined(a.defaultPeriod)){var b=
new Date,c=b.clone().add(a.defaultPeriodType,a.defaultPeriod);a.defaultValue=new Zarafa.core.DateRange({startDate:b,dueDate:c})}Zarafa.common.ui.DateRangeField.superclass.constructor.call(this,a);this.addFieldItems();this.bindDateRange(this.defaultValue)},addFieldItems:function(){if(Ext.isDefined(this.startFieldConfig)){if(this.layout!=="form")this.startFieldConfig.plugins=Ext.value(this.startFieldConfig.plugins,[]).concat("zarafa.fieldlabeler");this.startFieldConfig.listeners=Zarafa.core.Util.mergeListeners(this.startFieldConfig.listeners,
{change:this.onStartChange,scope:this});this.add(Ext.applyIf(this.startFieldConfig,{ref:"startField",flex:0.5,defaultValue:this.defaultValue?this.defaultValue.getStartDate():undefined,value:this.defaultValue?this.defaultValue.getStartDate():undefined}))}Ext.isDefined(this.spacerConfig)&&this.add(Ext.applyIf(this.spacerConfig,{xtype:"spacer",height:5,width:5}));if(Ext.isDefined(this.endFieldConfig)){if(this.layout!=="form")this.endFieldConfig.plugins=Ext.value(this.endFieldConfig.plugins,[]).concat("zarafa.fieldlabeler");
this.endFieldConfig.listeners=Zarafa.core.Util.mergeListeners(this.endFieldConfig.listeners,{change:this.onEndChange,scope:this});this.add(Ext.applyIf(this.endFieldConfig,{ref:"endField",flex:0.5,defaultValue:this.defaultValue?this.defaultValue.getDueDate():undefined,value:this.defaultValue?this.defaultValue.getDueDate():undefined}))}},bindDateRange:function(a){this.defaultValue&&this.mun(this.defaulValue,"update",this.onDateRangeUpdate,this);var b=this.defaultValue;(this.defaultValue=a)&&this.mon(this.defaultValue,
"update",this.onDateRangeUpdate,this);this.onDateRangeUpdate(a,b)},onStartChange:function(a,b){var c=this.defaultValue,d=this.defaultValue.clone();if(c.getStartDate()!=b){var e=c.getDuration(),f=c.getDueDate().clone();e=b.add(Date.MILLI,e);if(e<b)e=e.add(Date.HOUR,2);if(this.endField.maxValue&&e>this.endField.maxValue)e=this.endField.maxValue;c.set(b.clone(),e.clone());e!=f&&this.endField.setValue(e);this.fireEvent("change",this,c.clone(),d)}},onEndChange:function(a,b){var c=this.defaultValue,d=this.defaultValue.clone();
if(c.getDueDate()!=b){if(b<=c.getStartDate()){var e=c.getStartDate().clone(),f=b.add(this.defaultPeriodType,-this.defaultPeriod);if(this.startField.minValue&&f<this.startField.minValue)f=this.startField.minValue;c.set(f.clone(),b.clone());f!=e&&this.startField.setValue(f)}else c.setDueDate(b.clone());this.fireEvent("change",this,c.clone(),d)}},setValue:function(a){this.bindDateRange(a)},setRawValue:function(a){this.bindDateRange(a)},getValue:function(){return this.defaultValue},getRawValue:function(){return this.defaultValue},
enable:function(){Zarafa.common.ui.DateRangeField.superclass.enable.call(this);this.startField.enable();this.endField.enable()},disable:function(){Zarafa.common.ui.DateRangeField.superclass.disable.call(this);this.startField.disable();this.endField.disable()},onDateRangeUpdate:function(a){if(a)if(this.rendered){this.startField.setValue(a.getStartDate());this.endField.setValue(a.getDueDate())}else{this.items.get(0).defaultValue=a.getStartDate();this.items.get(1).defaultValue=a.getDueDate();this.items.get(0).value=
a.getStartDate();this.items.get(1).value=a.getDueDate()}}});Ext.reg("zarafa.daterangefield",Zarafa.common.ui.DateRangeField);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.DataDragZone=Ext.extend(Ext.dd.DragZone,{view:undefined,ddel:undefined,constructor:function(a,b){b=b||{};this.view=a;Ext.applyIf(b,{ddGroup:"DataDD"});Zarafa.common.ui.DataDragZone.superclass.constructor.call(this,a.getEl(),b);this.scroll=false;this.ddel=document.createElement("div");this.ddel.className="x-data-dd-wrap"},getDragData:function(a){var b=this.view.findItemFromChild(Ext.lib.Event.getTarget(a));if(b){b=this.view.indexOf(b);if(b>=0){a=new Ext.EventObjectImpl(a);return{view:this.view,
ddel:this.ddel,index:b,selections:this.view.getSelectedRecords(),origEvent:a}}return false}},onInitDrag:function(){if(this.dragData&&this.dragData.origEvent){var a=this.dragData.index,b=this.view.getNode(a);if(!this.view.isSelected(a)){this.view.onItemClick(b,a,this.dragData.origEvent);this.dragData.selections=this.view.getSelectedRecords()}delete this.dragData.origEvent}this.ddel.innerHTML=this.view.getDragDropText();this.proxy.update(this.ddel)},afterRepair:function(){this.dragging=false},getRepairXY:function(){return false},
onEndDrag:function(){},onValidDrop:function(){this.hideProxy()},beforeInvalidDrop:function(){}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.common.ui.ContextMainPanelToolbar=Ext.extend(Ext.Toolbar,{context:undefined,model:undefined,paging:undefined,alwaysUseDefaultTitle:false,defaultTitle:_("Zarafa WebApp"),constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();var b=[];b.push({xtype:"label",ref:"panelTitle",cls:"zarafa-grid-header"});b.push({xtype:"zarafa.paging",ref:"pagesToolbar",pageSize:50,store:a.model?a.model.getStore():undefined});Ext.isEmpty(a.paging)||(b=b.concat(a.paging));
b.push({xtype:"tbfill"});b=b.concat([{xtype:"zarafa.toolbarbutton",tooltip:_("Copy/Move"),iconCls:"icon_copy",nonEmptySelectOnly:true,handler:this.onCopyMove,scope:this},{xtype:"zarafa.toolbarbutton",tooltip:_("Delete"),iconCls:"icon_delete",nonEmptySelectOnly:true,handler:this.onDelete,scope:this}]);Ext.isEmpty(a.items)||(b=b.concat(a.items));a.items=b;Zarafa.common.ui.ContextMainPanelToolbar.superclass.constructor.call(this,a);if(Ext.isDefined(a.model)){this.mon(a.model,"folderchange",this.onFolderChange,
this);this.onFolderChange(a.model,a.model.getFolders())}},onFolderChange:function(a,b){this.alwaysUseDefaultTitle||b.length!=1?this.panelTitle.setText(this.defaultTitle):this.panelTitle.setText(b[0].getDisplayName())},onCopyMove:function(){Zarafa.common.Actions.openCopyMoveDialog(this.model.getSelectedRecords())},onDelete:function(){Zarafa.common.Actions.deleteRecords(this.model.getSelectedRecords())},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.model.getSelectedRecords())}});
Ext.reg("zarafa.contextmainpaneltoolbar",Zarafa.common.ui.ContextMainPanelToolbar);Ext.namespace("Zarafa.common.ui");Zarafa.common.ui.ContextMainPanel=Ext.extend(Ext.Panel,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{xtype:"zarafa.contextmainpanel",border:false,cls:"zarafa-panel"});Zarafa.common.ui.ContextMainPanel.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.contextmainpanel",Zarafa.common.ui.ContextMainPanel);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.CompositeField=Ext.extend(Ext.form.CompositeField,{isSingleValued:false,focusClass:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.compositefield"});Ext.apply(this,a);Zarafa.common.ui.CompositeField.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.common.ui.CompositeField.superclass.initComponent.call(this);this.items.addAll(this.innerCt.findBy(function(a){return a.isXType("box")},this));this.innerCt.ownerCt=this},cascade:function(a,b,c){if(a.apply(b||
this,c||[this])!==false)if(this.items)for(var d=this.items instanceof Ext.util.MixedCollection?this.items.items:this.items,e=0,f=d.length;e<f;e++)d[e].cascade?d[e].cascade(a,b,c):a.apply(b||d[e],c||[d[e]]);return this},find:Ext.Container.prototype.find,findBy:Ext.Container.prototype.findBy,findByType:Ext.Container.prototype.findByType});Ext.reg("zarafa.compositefield",Zarafa.common.ui.CompositeField);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.ComboAutoWidth=Ext.extend(Ext.util.Observable,{init:function(a){this.container=a;a.mon(a.store,"load",this.onStoreLoad,this)},onStoreLoad:function(a){var b=this.container,c=0,d=Ext.util.TextMetrics.createInstance(b.el);a.each(function(e){e=d.getWidth(e.get(b.displayField));if(e>c)c=e});if(c>0){c+=this.container.getTriggerWidth();if(b.getWidth()<c)b.listWidth=c}}});Ext.preg("zarafa.comboautowidth",Zarafa.common.ui.ComboAutoWidth);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.CharacterStrip=Ext.extend(Ext.Container,{characterData:["...","123","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],selectedChar:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.characterstrip",layout:{type:"vbox",align:"stretchmax"},border:false,autoWidth:true});this.addEvents("selectionchanged","selectioncleared");Zarafa.common.ui.CharacterStrip.superclass.constructor.call(this,a)},initComponent:function(){this.items=
[];Ext.each(this.characterData,function(a){this.items.push(new Ext.Button({text:a,enableToggle:true,scale:"small",toggleGroup:"chargroup",handler:this.onButtonClick,scope:this,flex:1,pressed:this.selectedChar==a,allowDepress:false,ref:"char_"+a}))},this);Zarafa.common.ui.CharacterStrip.superclass.initComponent.call(this,arguments)},onButtonClick:function(a){if(a.pressed){this.selectedChar=a.getText();this.fireEvent("selectionchanged",this,this.selectedChar)}},clearSelection:function(){this["char_"+
this.selectedChar].toggle(false);this.selectedChar=null;this.fireEvent("selectioncleared",this)}});Ext.reg("zarafa.characterstrip",Zarafa.common.ui.CharacterStrip);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.BoxField=Ext.extend(Ext.form.ComboBox,{boxType:"zarafa.box",boxStore:undefined,boxConfig:undefined,items:undefined,handleInputKey:Ext.EventObject.SEMI_COLON,enableComboBox:true,currentFocus:false,boxFocusEl:undefined,wrapBoxesEl:undefined,inputEl:undefined,boxKeyMap:undefined,inputKeyMap:undefined,minInputFieldWidth:25,inputFieldHeight:20,enableAnim:true,wrapCls:"x-form-text x-zarafa-boxfield",listTextMetric:undefined,inputTextMetric:undefined,listMode:false,boxLimit:undefined,constructor:function(a){a=
a||{};if(a.readOnly===true)a.editable=false;Ext.applyIf(a,{xtype:"zarafa.boxfield",cls:"x-zarafa-boxfield-input",hideTrigger:true,boxMinHeight:22,boxMaxHeight:50,autoHeight:false,autoScroll:true});this.addEvents("boxfocus","boxblur","boxclick","boxdblclick","boxcontextmenu","boxadd","boxremove");Zarafa.common.ui.BoxField.superclass.constructor.call(this,a);Ext.isDefined(this.boxStore)&&this.setBoxStore(this.boxStore,true);this.mon(this,"boxremove",this.onBoxRemove,this);this.mon(this,"boxadd",this.onBoxAdd,
this)},initComponent:function(){Zarafa.common.ui.BoxField.superclass.initComponent.call(this);this.items=new Ext.util.MixedCollection},initEvents:function(){this.mon(this.el,{keydown:this.onKeyDownHandler,scope:this});this.mon(this.getContentTarget(),"click",this.onContainerClick,this);if(this.editable!==false){this.boxKeyMap=this.createBoxKeyMap(this.boxFocusEl);this.inputKeyMap=this.createInputKeyMap(this.el);Zarafa.core.Events.addPasteEventHandler(this,this.el,this.onPaste,this)}this.listMode===
true&&this.mon(this.ownerCt,"afterlayout",this.onParentLayout,this);this.mon(this,"select",this.onSelect,this);Zarafa.common.ui.BoxField.superclass.initEvents.call(this)},setBoxStore:function(a,b){if(!(this.boxStore===a&&b!==true)){if(this.boxStore){this.mun(this.boxStore,"datachanged",this.onBoxStoreDataChanged,this);this.mun(this.boxStore,"add",this.onBoxStoreAdd,this);this.mun(this.boxStore,"remove",this.onBoxStoreRemove,this);this.mun(this.boxStore,"update",this.onBoxStoreUpdate,this);this.mun(this.boxStore,
"clear",this.onBoxStoreClear,this);this.clearBoxes()}if(this.boxStore=Ext.StoreMgr.lookup(a)){this.loadBoxes(this.boxStore);this.mon(this.boxStore,{scope:this,datachanged:this.onBoxStoreDataChanged,add:this.onBoxStoreAdd,remove:this.onBoxStoreRemove,update:this.onBoxStoreUpdate,clear:this.onBoxStoreClear})}}},getBoxStore:function(){return this.boxStore},getListTextMetric:function(){if(!this.listTextMetric)this.listTextMetric=Ext.util.TextMetrics.createInstance(this.innerList);return this.listTextMetric},
getInputTextMetric:function(){if(!this.inputTextMetric)this.inputTextMetric=Ext.util.TextMetrics.createInstance(this.el);return this.inputTextMetric},onTriggerClick:function(){this.enableComboBox===true&&Zarafa.common.ui.BoxField.superclass.onTriggerClick.apply(this,arguments)},doQuery:function(){this.enableComboBox===true&&Zarafa.common.ui.BoxField.superclass.doQuery.apply(this,arguments)},assertValue:function(){this.enableComboBox===true&&Zarafa.common.ui.BoxField.superclass.assertValue.apply(this,
arguments)},onSelect:function(a){this.collapse();this.el.dom.value="";this.sizeInputfield();this.store.removeAll();this.handleSelection(a)},getDesiredListWidth:function(){var a=this.getListTextMetric(),b=0;if(this.innerList.dom.children.length>0)for(var c=0,d=this.innerList.dom.children.length;c<d;c++){var e=Ext.fly(this.innerList.dom.children[c]);e=e.getPadding("lr")+a.getWidth(e.dom.innerHTML);if(e>b)b=e}else b=a.getWidth(this.innerList.dom.innerHTML);return b},onBeforeLoad:function(){Zarafa.common.ui.BoxField.superclass.onBeforeLoad.apply(this,
arguments);this.restrictWidth(this.getDesiredListWidth())},onLoad:function(){if(this.hasFocus&&(this.store.getCount()>0||this.listEmptyText)){var a=this.getDesiredListWidth();a+=this.list.getFrameWidth("lr");a+=Ext.getScrollBarWidth();this.restrictWidth(a)}Zarafa.common.ui.BoxField.superclass.onLoad.apply(this,arguments)},restrictWidth:function(a){var b=this.getEl(),c=this.getResizeEl(),d=b.getOffsetsTo(c),e=c.getWidth(),f=0;b=b.getFrameWidth("b");a=a;if(this.minListWidth>a)a=this.minListWidth;else if(e<
a)a=e;c=c.getWidth()-d[0];if(c<a)f=c-a;if(f>d[0]){a-=f-d[0];f=-d[0]}this.list.setWidth(a);this.innerList.setWidth(a-this.list.getFrameWidth("lr"));this.listAlign=["tl-bl",[f,b]]},onRender:function(a,b){Zarafa.common.ui.BoxField.superclass.onRender.call(this,a,b);Ext.isEmpty(this.wrapCls)||this.wrap.addClass(this.wrapCls);if(this.autoHeight===false)Ext.isDefined(this.height)&&this.wrap.setHeight(this.height);else this.wrap.applyStyles("height: auto;");this.boxFocusEl=this.wrap.createChild({tag:"a",
href:"#",tabindex:-1,style:"position: absolute; left:-10000px; top:-10000px;"});this.wrapBoxesEl=this.el.wrap({tag:"ul"});this.inputEl=this.el.wrap({tag:"li",cls:"x-zarafa-boxfield-input-item"});this.border===false&&this.el.addClass("x-zarafa-boxfield-input-noborder")},updateEditState:function(){Zarafa.common.ui.BoxField.superclass.updateEditState.apply(this,arguments);this.inputEl.setVisible(this.editable);this.items.each(function(a){a.setEditable(this.editable)})},getContentTarget:function(){return this.wrap},
onResize:function(a,b,c,d){Zarafa.common.ui.BoxField.superclass.onResize.call(this,a,b,c,d);this.sizeInputfield();this.sizeContainer()},sizeContainer:function(){if(!this.rendered||this.autoHeight===false)return false;var a=this.getResizeEl(),b=a.getHeight(),c=a.dom.scrollHeight,d=false;if(b>this.boxMaxHeight){a.setHeight(this.boxMaxHeight);if(this.initialConfig.autoScroll!==false){this.setAutoScroll(true);a.scrollTo("top",b)}d=true}else if(c<=b){a.setHeight("auto");this.initialConfig.autoScroll!==
false&&this.setAutoScroll(false);d=true}d===true&&this.ownerCt.ownerCt&&this.ownerCt.ownerCt.doLayout()},onParentLayout:function(){var a=this.getDesiredBoxWidth();Ext.isDefined(a)&&this.items.each(function(b){b.setWidth(a)})},getDesiredBoxWidth:function(){if(this.listMode===true){var a=this.getResizeEl();return a.getWidth()-a.getFrameWidth("lr")-this.el.getFrameWidth("lr")}},sizeInputfield:function(){if(!this.rendered)return false;var a=this.getResizeEl(),b;if(this.listMode===true)b=a.getWidth()-
a.getFrameWidth("lr")-this.el.getFrameWidth("lr");else{b=this.getInputTextMetric();var c=Ext.util.Format.htmlEncode(this.el.dom.value);b=b.getWidth(c);b+=this.minInputFieldWidth;b=Math.min(b,a.getWidth())}this.el.setSize(b,this.inputFieldHeight-this.el.getBorderWidth("tb"));b=a.getHeight();c=a.getHeight();if(this.listMode===true||b!==c)this.sizeContainer();a.scrollTo("top",c)},handleInput:Ext.emptyFn,handleSelection:Ext.emptyFn,convertInputToBox:function(){var a=this.el.getValue();if(!Ext.isEmpty(a)){this.el.dom.value=
"";this.sizeInputfield();this.store.removeAll();this.handleInput(a)}},filterRecords:function(a,b){for(var c=[],d=0,e=b.length;d<e;d++){var f=b[d];this.filterRecord(f)&&c.push(f)}return c},filterRecord:function(){return true},getBoxForRecord:function(a){return this.items.find(function(b){return b.record===a})},beforeBlur:function(){Zarafa.common.ui.BoxField.superclass.beforeBlur.apply(this,arguments);this.convertInputToBox();this.boxBlur()},boxFocus:function(a){this.currentFocus&&this.currentFocus.blur();
(this.currentFocus=a)&&this.currentFocus.focus()},boxBlur:function(){this.currentFocus&&this.currentFocus.blur();this.currentFocus=false},focus:function(a,b){if(b){this.focusTask=new Ext.util.DelayedTask(this.focus,this,[a,false]);this.focusTask.delay(Ext.isNumber(b)?b:10)}else{this.rendered&&!this.isDestroyed&&this.inputFocus(undefined,a);return this}},inputFocus:function(a,b){this.boxBlur();this.el.focus();Ext.isEmpty(a)||Zarafa.core.Util.setCaretPosition(this.el,a);b===true&&this.el.dom.select()},
inputBlur:function(){this.el.blur()},onContainerClick:function(a,b){this.collapse();if(this.editable)b===this.el.dom?this.inputFocus():this.inputFocus(this.el.dom.value.length);else this.currentFocus||this.boxFocus(this.items.last())},createBoxKeyMap:function(a){return new Ext.KeyMap(a,[{key:[Ext.EventObject.ENTER],handler:this.onBoxKeyEnter,scope:this},{key:[Ext.EventObject.UP,Ext.EventObject.PAGE_UP],handler:this.onBoxKeyUp,scope:this},{key:[Ext.EventObject.DOWN,Ext.EventObject.PAGE_DOWN],handler:this.onBoxKeyDown,
scope:this},{key:[Ext.EventObject.LEFT],handler:this.onBoxKeyLeft,scope:this},{key:[Ext.EventObject.RIGHT],handler:this.onBoxKeyRight,scope:this},{key:[Ext.EventObject.HOME],handler:this.onBoxKeyHome,scope:this},{key:[Ext.EventObject.END],handler:this.onBoxKeyEnd,scope:this},{key:[Ext.EventObject.BACKSPACE],handler:this.onBoxKeyBackspace,scope:this},{key:[Ext.EventObject.DELETE],handler:this.onBoxKeyDelete,scope:this}])},onBoxKeyEnter:function(a,b){b.stopEvent();this.doBoxDblClick(this.currentFocus)},
onBoxKeyUp:function(a,b){this.onBoxKeyLeft(a,b)},onBoxKeyDown:function(a,b){this.onBoxKeyRight(a,b)},onBoxKeyLeft:function(a,b){b.stopEvent();var c=this.items.indexOf(this.currentFocus);c!==0&&this.boxFocus(this.items.itemAt(c-1))},onBoxKeyRight:function(a,b){b.stopEvent();var c=this.items.indexOf(this.currentFocus);if(c!==this.items.getCount()-1)this.boxFocus(this.items.itemAt(c+1));else this.editable&&this.inputFocus(0)},onBoxKeyHome:function(a,b){b.stopEvent();var c=this.items.first();c.hasFocus()||
this.boxFocus(c)},onBoxKeyEnd:function(a,b){b.stopEvent();var c=this.items.last();if(c.hasFocus())this.editable&&this.inputFocus(this.el.dom.value.length);else this.boxFocus(c)},onBoxKeyBackspace:function(a,b){b.stopEvent();if(this.editable!==false){var c=this.items.indexOf(this.currentFocus);this.doBoxRemove(this.currentFocus);if(c>0)this.boxFocus(this.items.itemAt(c-1));else this.items.getCount()>0?this.boxFocus(this.items.itemAt(0)):this.inputFocus()}},onBoxKeyDelete:function(a,b){b.stopEvent();
if(this.editable!==false){var c=this.items.indexOf(this.currentFocus);this.doBoxRemove(this.currentFocus);c<this.items.getCount()?this.boxFocus(this.items.itemAt(c)):this.inputFocus(0)}},createInputKeyMap:function(a){return new Ext.KeyMap(a,[{key:[this.handleInputKey],handler:this.onInputKey,scope:this},{key:[Ext.EventObject.ENTER],handler:this.onInputKeyEnter,scope:this},{key:[Ext.EventObject.UP,Ext.EventObject.PAGE_UP],handler:this.onInputKeyUp,scope:this},{key:[Ext.EventObject.LEFT],handler:this.onInputKeyLeft,
scope:this},{key:[Ext.EventObject.HOME],handler:this.onInputKeyHome,scope:this},{key:[Ext.EventObject.BACKSPACE],handler:this.onInputKeyBackspace,scope:this}])},onKeyDownHandler:function(a){if(!a.isSpecialKey()){this.collapse();this.sizeInputfield()}},onInputKey:function(a,b){b.stopEvent();this.convertInputToBox()},onInputKeyEnter:function(a,b){if(!this.isExpanded()){b.stopEvent();this.convertInputToBox()}},onInputKeyUp:function(a,b){this.onInputKeyLeft(a,b)},onInputKeyLeft:function(a,b){var c=Zarafa.core.Util.getSelectionRange(this.el);
if(c.start===0&&c.end===0&&this.items.getCount()>0){b.stopEvent();this.boxFocus(this.items.last())}},onInputKeyHome:function(a,b){var c=Zarafa.core.Util.getSelectionRange(this.el);if(c.start===0&&c.end===0&&this.items.getCount()>0){b.stopEvent();this.boxFocus(this.items.first())}},onInputKeyBackspace:function(a,b){var c=Zarafa.core.Util.getSelectionRange(this.el);if(c.start===0&&c.end===0&&this.items.getCount()>0){b.stopEvent();this.boxFocus(this.items.last())}},onPaste:function(){this.sizeInputfield()},
onBoxStoreDataChanged:function(a){this.clearBoxes();this.loadBoxes(a)},onBoxStoreClear:function(){this.clearBoxes()},onBoxStoreAdd:function(a,b){Ext.isArray(b)||(b=[b]);b=this.filterRecords(a,b);for(var c=0;c<b.length;c++)this.addBox(b[c])},onBoxStoreRemove:function(a,b){this.removeBox(b)},onBoxStoreUpdate:function(a,b){var c=this.getBoxForRecord(b);c&&c.update(b)},doBoxClick:function(a){this.boxFocus(a);this.fireEvent("boxclick",this,a,a.record)},doBoxDblClick:function(a){this.fireEvent("boxdblclick",
this,a,a.record)},doBoxContextMenu:function(a){this.boxFocus(a);this.fireEvent("boxcontextmenu",this,a,a.record)},doBoxFocus:function(a){this.hasFocus!==true&&this.onFocus();this.boxFocusEl.focus();a.getPositionEl().scrollIntoView(this.getContentTarget());this.fireEvent("boxfocus",this,a,a.record)},doBoxBlur:function(a){this.boxFocusEl.blur();this.fireEvent("boxblur",this,a,a.record)},doBoxRemove:function(a){this.fireEvent("boxremove",this,a,a.record)},onBoxRemove:function(a,b,c){this.boxStore.remove(c);
this.sizeContainer();if(this.boxStore.getCount()<this.boxLimit){this.setReadOnly(false);this.inputFocus()}},onBoxAdd:function(){this.sizeContainer();this.boxStore.getCount()>=this.boxLimit&&this.setReadOnly(true)},addBox:function(a){var b={};Ext.apply(b,{xtype:this.boxType,parent:this,record:a,editable:this.editable,width:this.getDesiredBoxWidth()},this.boxConfig);b=Ext.create(b);b.render(this.wrapBoxesEl,this.items.length);this.items.add(b);this.fireEvent("boxadd",this,b,a)},removeBox:function(a){if(a=
this.getBoxForRecord(a)){var b=this.items.indexOf(a);a.doDestroy(this.enableAnim);this.items.remove(a);if(!this.currentFocus||this.currentFocus===a)this.items.getCount()>b?this.boxFocus(this.items.itemAt(b)):this.inputFocus()}},loadBoxes:function(a){a=this.filterRecords(a,a.getRange());for(var b=0;b<a.length;b++)this.addBox(a[b])},clearBoxes:function(){this.items.each(function(a){a.destroy()});this.items.clear()},onDestroy:function(){Zarafa.common.ui.BoxField.superclass.onDestroy.apply(this,arguments);
this.editable!==false&&Zarafa.core.Events.removePasteEventHandler(this,this.el,this.onPaste,this)}});Ext.reg("zarafa.boxfield",Zarafa.common.ui.BoxField);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.Box=Ext.extend(Ext.BoxComponent,{record:undefined,parent:undefined,iconEl:undefined,textEl:undefined,delBtnEl:undefined,editable:true,enableButtons:true,enableIcons:true,hoverCls:"x-zarafa-boxfield-item-hover",focusCls:"x-zarafa-boxfield-item-focus",textCls:"x-zarafa-boxfield-item-text",iconCls:"x-zarafa-boxfield-item-icon",btnCls:"x-zarafa-boxfield-item-close",btnHoverCls:"x-zarafa-boxfield-item-close-hover",textTpl:undefined,isAnimDestroying:false,enableTextSelection:false,ellipsisStringStartLength:30,
ellipsisStringEndLength:30,constructor:function(a){a=a||{};Ext.applyIf(a,{autoEl:{tag:"li",cls:"x-zarafa-boxfield-item"}});Zarafa.common.ui.Box.superclass.constructor.call(this,a);if(Ext.isString(this.textTpl))this.textTpl=new Ext.XTemplate(this.textTpl,{compiled:true,ellipsisStringStartLength:this.ellipsisStringStartLength,ellipsisStringEndLength:this.ellipsisStringEndLength})},onRender:function(a,b){Zarafa.common.ui.Box.superclass.onRender.call(this,a,b);this.enableTextSelection!==true&&this.el.unselectable();
this.enableIcons===true&&this.renderIcons();this.renderBox();this.enableButtons===true&&this.renderButtons();Ext.isDefined(this.record)&&this.update(this.record);this.el.addClassOnOver(this.hoverCls);this.mon(this.el,"click",this.onClick,this);this.mon(this.el,"contextmenu",this.onContextMenu,this);this.mon(this.el,"dblclick",this.onDblClick,this)},afterRender:function(a){Zarafa.common.ui.Box.superclass.afterRender.call(this,a);this.delBtnEl.setVisible(this.editable)},setEditable:function(a){if(this.editable!==
a){this.editable=a;this.delBtnEl.setVisible(this.editable)}},renderIcons:function(){this.iconEl=this.el.createChild({tag:"span",cls:this.iconCls})},renderBox:function(){this.textEl=this.el.createChild({tag:"span",cls:this.textCls})},renderButtons:function(){this.renderRemoveButton()},renderRemoveButton:function(){this.delBtnEl=this.el.createChild({tag:"span",cls:this.btnCls});this.delBtnEl.addClassOnOver(this.btnHoverCls);this.mon(this.delBtnEl,"click",this.onClickRemove,this)},focus:function(){Zarafa.common.ui.Box.superclass.focus.call(this);
this.el.addClass(this.focusCls);this.parent.doBoxFocus(this)},blur:function(){Zarafa.common.ui.Box.superclass.blur.call(this);this.el.removeClass(this.focusCls);this.parent.doBoxBlur(this)},hasFocus:function(){return this.el.hasClass(this.focusCls)},onClickRemove:function(){!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxRemove(this)},onClick:function(a){!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxClick(this);a.stopEvent()},onContextMenu:function(a){!this.isAnimDestroying&&
!this.isDestroying&&this.parent.doBoxContextMenu(this);a.stopEvent()},onDblClick:function(a){!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxDblClick(this);a.stopEvent()},prepareData:function(a){return a.data},prepareIcon:function(a){return Zarafa.common.ui.IconClass.getIconClass(a)},update:function(a){this.textTpl.overwrite(this.textEl,this.prepareData(a));if(this.enableIcons===true){a=this.prepareIcon(a);Ext.isEmpty(a)||this.iconEl.addClass(a)}},onResize:function(a,b,c){if(Ext.isNumber(c)){Ext.isNumber(a)||
(a=c);a-=this.el.getMargins("lr")+this.iconEl.getWidth()+this.iconEl.getFrameWidth("lr")+this.iconEl.getMargins("lr")+this.delBtnEl.getWidth()+this.delBtnEl.getFrameWidth("lr")+this.delBtnEl.getMargins("lr")+this.getResizeEl().getFrameWidth("lr")+this.getResizeEl().getMargins("lr");this.textEl.setWidth(a)}},doDestroy:function(a){if(a===true){this.isAnimDestroying=true;this.getEl().hide({duration:0.2,callback:function(){this.destroy()},scope:this})}else this.destroy()}});Ext.reg("zarafa.box",Zarafa.common.ui.Box);
Ext.namespace("Zarafa.common.restoreitem.dialogs");
Zarafa.common.restoreitem.dialogs.RestoreItemPanel=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.restoreitempanel",layout:"fit",border:false,title:_("Restore Item"),items:[{xtype:"listview",autoHeight:true,autoWidth:true,store:new Zarafa.common.restoreitem.data.RestoreItemStore,columns:[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>'},{dataIndex:"from",
header:_("From")},{dataIndex:"subject",header:_("Subject")},{dataIndex:"deletedOn",header:_("Deleted On")},{dataIndex:"size",header:_("Size")}]}]});Zarafa.common.restoreitem.dialogs.RestoreItemPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.restoreitempanel",Zarafa.common.restoreitem.dialogs.RestoreItemPanel);Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderPanel=Ext.extend(Ext.Panel,{store:undefined,activeReminderTemplate:'<tpl><div><span class="zarafa-reminder-dialog-active-reminder-icon {[Zarafa.common.ui.IconClass.getIconClassFromMessageClass(false, values.message_class)]}"></span><span class="zarafa-reminder-dialog-active-reminder-subject"><tpl if="!Ext.isEmpty(values.subject)">{values.subject:htmlEncodeEllipsis(60)}</tpl><tpl if="Ext.isEmpty(values.subject)">&nbsp;</tpl></span></div><div><span><tpl if="Zarafa.core.ContainerClass.isClass(values.message_class, &quot;IPM.Task&quot;, true)"><tpl if="Ext.isDefined(values.task_duedate)">'+_("Due")+
': {values.task_duedate:date("'+_("l jS F Y")+'")}</tpl><tpl if="Ext.isDefined(values.reminder_time) && !Ext.isDefined(values.task_duedate)">'+_("Reminder time")+': {values.reminder_time:date("'+_("l jS F Y G:i")+'")}</tpl></tpl><tpl if="!Zarafa.core.ContainerClass.isClass(values.message_class, &quot;IPM.Task&quot;, true)"><tpl if="Ext.isDefined(values.reminder_time)">'+_("Start time")+': {values.reminder_time:date("'+_("l jS F Y G:i")+'")}</tpl></tpl></span></div></tpl>',constructor:function(a){a=
a||{};Ext.applyIf(a,{xtype:"zarafa.reminderpanel",layout:{type:"vbox",align:"stretch",pack:"start"},header:false,border:false,defaults:{border:false},items:[this.activeReminderPanel(),this.reminderGrid(a.store),this.reminderAction(),this.reminderSnooze()]});Zarafa.common.reminder.dialogs.ReminderPanel.superclass.constructor.call(this,a);if(Ext.isString(this.activeReminderTemplate))this.activeReminderTemplate=new Ext.XTemplate(this.activeReminderTemplate,{compiled:true})},activeReminderPanel:function(){return{xtype:"panel",
cls:"zarafa-reminder-dialog-active-reminder",layout:"fit",ref:"activeReminder",height:40}},reminderGrid:function(a){return{xtype:"zarafa.remindergrid",ref:"reminderGridView",store:a,border:true,flex:2}},reminderAction:function(){return{xtype:"panel",layout:"fit",height:40,ref:"reminderAction",minButtonWidth:90,buttons:[{text:_("Dismiss All"),handler:this.onDismissAll,ref:"../../dismissAllButton",scope:this},{text:_("Open Item"),handler:this.onOpenItem,ref:"../../openButton",scope:this},{text:_("Dismiss"),
handler:this.onDismiss,ref:"../../dismissButton",scope:this}]}},reminderSnooze:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.ReminderPeriods};return{xtype:"panel",cls:"zarafa-reminder-dialog-snooze",layout:{type:"vbox",align:"stretch",pack:"start"},height:80,ref:"reminderAction",items:[{xtype:"displayfield",value:_("Click Snooze to be reminded again in")+": ",hideLabel:true,height:25,ref:"../snoozeInfoText"},{xtype:"panel",layout:"hbox",border:false,flex:1,
items:[{xtype:"combo",ref:"../../snoozeTimeCombo",name:"snooze",flex:1,store:a,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",value:container.getSettingsModel().get("zarafa/v1/main/reminder/default_snooze_time"),lazyInit:false,forceSelection:true,editable:false},{xtype:"spacer",width:10},{xtype:"button",width:90,text:_("Snooze"),handler:this.onSnooze,ref:"../../snoozeButton",scope:this}]}]}},initEvents:function(){Zarafa.common.reminder.dialogs.ReminderPanel.superclass.initEvents.call(this);
this.mon(this.reminderGridView,"viewready",this.onViewReady,this);this.mon(this.reminderGridView.getSelectionModel(),"selectionchange",this.onSelectionChange,this);this.mon(this.reminderGridView.getSelectionModel(),"selectionchange",this.toggleFields,this)},onViewReady:function(){this.reminderGridView.getSelectionModel().selectFirstRow()},onSelectionChange:function(){var a=this.reminderGridView.getSelectionModel().getSelections(),b=this.activeReminder.getEl();if(Ext.isDefined(b.dom))b.dom.innerHTML=
"";a.length==1?this.activeReminderTemplate.overwrite(b.dom,a[0].data):b.createChild({tag:"div",html:String.format(npgettext("reminder.dialog","{0} reminder is selected.","{0} reminders are selected.",a.length),a.length)});this.doLayout()},toggleFields:function(){var a=this.reminderGridView.getSelectionModel().hasSelection();this.snoozeTimeCombo.setDisabled(!a);this.dismissAllButton.setDisabled(!a);this.dismissButton.setDisabled(!a);this.openButton.setDisabled(!a);this.snoozeButton.setDisabled(!a);
this.snoozeInfoText.setDisabled(!a)},onDismissAll:function(){this.store.dismissReminders(this.store.getRange())},onOpenItem:function(){var a=this.reminderGridView.getSelectionModel().getSelected();a&&Zarafa.common.Actions.openReminderRecord(a)},onDismiss:function(){this.store.dismissReminders(this.reminderGridView.getSelectionModel().getSelections())},onSnooze:function(){this.store.snoozeReminders(this.reminderGridView.getSelectionModel().getSelections(),this.snoozeTimeCombo.getValue())}});
Ext.reg("zarafa.reminderpanel",Zarafa.common.reminder.dialogs.ReminderPanel);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.RecurrenceSubPanel=Ext.extend(Ext.Panel,{record:undefined,recurrenceType:undefined,recurrenceSubtypes:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Zarafa.common.recurrence.dialogs.RecurrenceSubPanel.superclass.constructor.call(this,a)},isSubtype:function(a,b){return a.type===b.type&&a.regen===b.regen},isRecordSubtype:function(a,b){return a.get("recurrence_subtype")===b.type&&a.get("recurrence_regen")===
b.regen},onSubtypeChange:function(a,b){if(b)this.isRecordSubtype(this.record,a.patternValue)||this.updateRecord(this.record)},onSubtypePropertyChange:function(a,b,c){this.isRecordSubtype(this.record,a)&&this.record.set(b.name,c)},updateUI:Ext.emptyFn,updateSubtype:Ext.emptyFn,update:function(a,b){this.record=a;this.updateUI(a,b);if(b){var c=this.findByType("radio");if(a.get("recurrence_type")!==this.recurrenceType){c[0].setValue(true);for(var d in this.recurrenceSubtypes){c=this.recurrenceSubtypes[d];
this.updateSubtype(a,c,true)}}else{Ext.each(c,function(e){e.setValue(this.isRecordSubtype(a,e.patternValue))},this);for(d in this.recurrenceSubtypes){c=this.recurrenceSubtypes[d];this.updateSubtype(a,c,!this.isRecordSubtype(a,c))}}}},updateRecordSubType:Ext.emptyFn,updateRecord:function(a){a.get("recurrence_type")===this.recurrenceType&&Ext.each(this.findByType("radio"),function(b){if(b.getValue()){b=b.patternValue;a.beginEdit();a.set("recurrence_subtype",b.type);a.set("recurrence_regen",b.regen);
this.updateRecordSubType(a,b);a.endEdit();return false}},this)}});Ext.reg("zarafa.recurrencesubpanel",Zarafa.common.recurrence.dialogs.RecurrenceSubPanel);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.RecurrencePanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.recurrencepanel",layout:"form",border:false,defaults:{border:false,bodyStyle:"padding: 10px;"},items:[this.createTimePanel(),this.createRecurrencePanel(),this.createRangePanel()]});Ext.apply(this,a);Zarafa.common.recurrence.dialogs.RecurrencePanel.superclass.constructor.call(this,
a)},createTimePanel:function(){return{xtype:"panel",title:_("Time"),layout:{type:"vbox",align:"stretch"},anchor:"100%",height:90,items:[{xtype:"displayfield",ref:"../timeperiodLabel",htmlEncode:true,hideLabel:true,height:20},{xtype:"panel",layout:"hbox",anchor:"100% 100%",border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"zarafa.timeperiodfield",ref:"../../timeperiodField",layout:"hbox",defaultPeriod:30,defaultPeriodType:Date.MINUTE,flex:0.6,spacerConfig:{width:5},listeners:{change:this.onDurationChange,
scope:this}},{xtype:"spacer",width:5},{xtype:"container",flex:0.4,border:false,style:"background-color: inherit;",items:[{xtype:"checkbox",ref:"../../../alldayCheckbox",name:"alldayevent",boxLabel:_("All Day Event"),handler:this.onToggleAllDay,scope:this}]}]}]}},createRecurrencePanel:function(){return{xtype:"panel",layout:{type:"hbox",align:"stretch"},title:_("Recurrence pattern"),anchor:"100%",height:125,items:[{xtype:"radiogroup",ref:"../recurrencePatternSelect",width:100,border:false,columns:1,
items:[{boxLabel:_("Daily"),name:"pattern",targetId:"card-daily",patternValue:Zarafa.common.recurrence.data.RecurrenceType.DAILY,handler:this.onSwitchRecurrenceView,scope:this},{boxLabel:_("Weekly"),name:"pattern",targetId:"card-weekly",patternValue:Zarafa.common.recurrence.data.RecurrenceType.WEEKLY,handler:this.onSwitchRecurrenceView,scope:this},{boxLabel:_("Monthly"),name:"pattern",targetId:"card-monthly",patternValue:Zarafa.common.recurrence.data.RecurrenceType.MONTHLY,handler:this.onSwitchRecurrenceView,
scope:this},{boxLabel:_("Yearly"),name:"pattern",targetId:"card-yearly",patternValue:Zarafa.common.recurrence.data.RecurrenceType.YEARLY,handler:this.onSwitchRecurrenceView,scope:this}]},{xtype:"panel",ref:"../recurrencePattern",layout:"card",flex:1,border:true,bodyStyle:"background-color: inherit; border-style: none none none solid; padding: 0px 10px 0px 10px",defaults:{border:false,bodyStyle:"background-color: inherit;",autoHeight:true},items:[{xtype:"zarafa.recurrencedailypanel",id:"card-daily"},
{xtype:"zarafa.recurrenceweeklypanel",id:"card-weekly"},{xtype:"zarafa.recurrencemonthlypanel",id:"card-monthly"},{xtype:"zarafa.recurrenceyearlypanel",id:"card-yearly"}]}]}},createRangePanel:function(){return{xtype:"panel",layout:"column",title:_("Range of recurrence"),anchor:"100%",items:[{xtype:"panel",layout:"form",columnWidth:0.4,border:false,items:[{xtype:"datefield",ref:"../../startDateField",name:"recurrence_start",fieldLabel:_("Start"),format:_("d/m/Y"),listeners:{select:this.onUTCFieldChange,
change:this.onUTCFieldChange,scope:this}}]},{xtype:"panel",layout:"form",ref:"../endPatternPanel",columnWidth:0.6,border:false,bodyStyle:"background-color: inherit;",defaults:{anchor:"100%",border:false,bodyStyle:"background-color: inherit;",defaults:{height:25,labelWidth:75}},items:[{xtype:"panel",layout:"hbox",items:[{xtype:"radio",name:"recurrence_term",endTerm:Zarafa.common.recurrence.data.RecurrenceEnd.NEVER,hideLabel:true,width:25,listeners:{check:this.onSwitchRecurrenceTerm,scope:this}},{xtype:"displayfield",
value:_("No end date"),hideLabel:true}]},{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"recurrence_term",endTerm:Zarafa.common.recurrence.data.RecurrenceEnd.N_OCCURENCES,hideLabel:true,width:25,listeners:{check:this.onSwitchRecurrenceTerm,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("End after {A} occurrences"),labelWidth:160,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../../../endOccurencesSpinner",name:"recurrence_numoccur",
labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onFieldChange,scope:this}}]}]},{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"recurrence_term",endTerm:Zarafa.common.recurrence.data.RecurrenceEnd.ON_DATE,hideLabel:true,width:25,listeners:{check:this.onSwitchRecurrenceTerm,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("End by {A}"),labelWidth:80,items:[{xtype:"datefield",ref:"../../../../endOnDateField",name:"recurrence_end",
width:120,labelSplitter:"{A}",format:_("d/m/Y"),listeners:{select:this.onUTCFieldChange,change:this.onUTCFieldChange,scope:this}}]}]}]}]}},updateDurationLabel:function(){if(this.record){var a=Math.floor(this.timeperiodField.getValue().getDuration(Date.MINUTE)),b=Math.floor(a/1440);a%=1440;var c=Math.floor(a/60);a%=60;a=Math.floor(a);var d=_("Occurrence duration: {D} {H} {M}");d=b>0?d.replace("{D}",String.format(ngettext("{0} day","{0} days",b),b)):d.replace("{D} ","");d=c>0?d.replace("{H}",String.format(ngettext("{0} hour",
"{0} hours",c),c)):d.replace("{H} ","");d=a>0?d.replace("{M}",String.format(ngettext("{0} minute","{0} minutes",a),a)):d.replace("{M}","");this.timeperiodLabel.setValue(d)}},onFieldChange:function(a,b){this.record.set(a.getName(),b)},onUTCFieldChange:function(a,b){this.record.set(a.getName(),b.toUTC(true))},onDurationChange:function(a,b){var c=b.getStartDate().getHours()*60+b.getStartDate().getMinutes(),d=c+b.getDuration(Date.MINUTE);this.record.beginEdit();this.record.set("recurrence_startocc",c);
this.record.set("recurrence_endocc",d);this.record.endEdit()},onSwitchRecurrenceTerm:function(a,b){b&&this.record.set("recurrence_term",a.endTerm)},onSwitchRecurrenceView:function(a,b){if(b){this.record.set("recurrence_type",a.patternValue);this.recurrencePattern.getLayout().setActiveItem(a.targetId);this.recurrencePattern.doLayout()}},onToggleAllDay:function(a,b){var c=Math.ceil(this.timeperiodField.getValue().getDuration(Date.MINUTE)/1440);this.record.beginEdit();this.record.set("alldayevent",b);
this.record.set("recurrence_startocc",0);this.record.set("recurrence_endocc",c*1440);this.record.endEdit()},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("alldayevent"))a.get("alldayevent")?this.timeperiodField.disable():this.timeperiodField.enable();if(b===true||a.isModifiedSinceLastUpdate("message_class")){a.isMessageClass("IPM.TaskRequest",true)?this.alldayCheckbox.hide():this.alldayCheckbox.show();c=true}c&&this.doLayout()},update:function(a,b){this.record=a;this.updateUI(a,
b);var c=a.get("recurrence_type");this.recurrencePatternSelect.items.each(function(i){i.setValue(i.patternValue==c)});var d=a.get("recurrence_start")||(new Date).toUTC(true),e=a.get("recurrence_startocc"),f=a.get("recurrence_endocc"),g=d.clone();g.setHours(e/60);g.setMinutes(e%60);e=d.clone();e.setHours(f/60);e.setMinutes(f%60);this.startDateField.setValue(d);this.timeperiodField.getValue().set(g,e);if(b===true||a.isModifiedSinceLastUpdate("recurrence_startocc")||a.isModifiedSinceLastUpdate("recurrence_endocc"))this.updateDurationLabel();
var h=a.get("recurrence_term");Ext.each(this.endPatternPanel.findByType("radio"),function(i){i.setValue(i.endTerm==h)});switch(h){case Zarafa.common.recurrence.data.RecurrenceEnd.NEVER:b===true&&this.endOccurencesSpinner.setValue(10);if(b===true||a.isModifiedSinceLastUpdate("recurrence_start")&&a.get("recurrence_start")>this.endOnDateField.getValue())this.endOnDateField.setValue(a.get("recurrence_start").fromUTC(true));break;case Zarafa.common.recurrence.data.RecurrenceEnd.N_OCCURENCES:if(b===true||
a.isModifiedSinceLastUpdate("recurrence_numoccur"))this.endOccurencesSpinner.setValue(a.get("recurrence_numoccur"));b===true&&this.endOnDateField.setValue(a.get("recurrence_start").fromUTC(true));break;case Zarafa.common.recurrence.data.RecurrenceEnd.ON_DATE:b===true&&this.endOccurencesSpinner.setValue(10);if(b===true||a.isModifiedSinceLastUpdate("recurrence_end"))this.endOnDateField.setValue(a.get("recurrence_end").fromUTC(true));break}this.alldayCheckbox.setValue(a.get("alldayevent"))},updateRecord:function(a){a.beginEdit();
a.set("recurrence_type",this.recurrencePatternSelect.getValue().patternValue);a.set("recurrence_start",this.startDateField.getValue().toUTC(true));Ext.each(this.endPatternPanel.findByType("radio"),function(e){if(e.getValue()){a.set("recurrence_term",e.endTerm);return false}});switch(a.get("recurrence_term")){case Zarafa.common.recurrence.data.RecurrenceEnd.NEVER:a.set("recurrence_numoccur",undefined);a.set("recurrence_end",(new Date("Jan 01 4501")).toUTC(true));break;case Zarafa.common.recurrence.data.RecurrenceEnd.N_OCCURENCES:a.set("recurrence_numoccur",
this.endOccurencesSpinner.getValue());a.set("recurrence_end",(new Date("Jan 01 4501")).toUTC(true));break;case Zarafa.common.recurrence.data.RecurrenceEnd.ON_DATE:a.set("recurrence_numoccur",undefined);a.set("recurrence_end",this.endOnDateField.getValue().toUTC(true));break}a.set("alldayevent",this.alldayCheckbox.getValue());var b=this.timeperiodField.getValue(),c=b.getStartDate().getHours()*60+b.getStartDate().getMinutes();b=c+b.getDuration(Date.MINUTE);a.set("recurrence_startocc",c);a.set("recurrence_endocc",
b);var d=this.startDateField.getValue();d.setHours(c/60);d.setMinutes(c%60);a.set("startdate",d);a.set("commonstart",d);c=d.clone();c.setHours(b/60);c.setMinutes(b%60);a.set("duedate",c);a.set("commonend",c);a.endEdit()}});Ext.reg("zarafa.recurrencepanel",Zarafa.common.recurrence.dialogs.RecurrencePanel);Ext.namespace("Zarafa.common.recurrence.data");
Zarafa.common.recurrence.data.MonthData=[{name:Date.monthNames[0],value:0},{name:Date.monthNames[1],value:44640},{name:Date.monthNames[2],value:84960},{name:Date.monthNames[3],value:129600},{name:Date.monthNames[4],value:172800},{name:Date.monthNames[5],value:217440},{name:Date.monthNames[6],value:260640},{name:Date.monthNames[7],value:305280},{name:Date.monthNames[8],value:348480},{name:Date.monthNames[9],value:393120},{name:Date.monthNames[10],value:437760},{name:Date.monthNames[11],value:480960}];
Ext.namespace("Zarafa.common.recurrence.data");Zarafa.common.recurrence.data.DayRankData=[{name:_("1st"),value:1},{name:_("2nd"),value:2},{name:_("3rd"),value:3},{name:_("4th"),value:4},{name:_("last"),value:5}];Ext.namespace("Zarafa.common.recurrence.data");
Zarafa.common.recurrence.data.DayData=[{name:_("Day"),value:127},{name:_("Weekday"),value:62},{name:_("Weekend Day"),value:65},{name:null,value:0},{name:null,value:0},{name:null,value:0},{name:null,value:0},{name:null,value:0},{name:null,value:0},{name:null,value:0}];
Zarafa.onReady(function(){for(var a=container.getSettingsModel().get("zarafa/v1/main/week_start"),b=3;b<Zarafa.common.recurrence.data.DayData.length;b++){var c=(a+(b-3))%7;Zarafa.common.recurrence.data.DayData[b].name=Date.dayNames[c];Zarafa.common.recurrence.data.DayData[b].value=Math.pow(2,c)}},undefined,{single:true});Ext.namespace("Zarafa.common.recipientfield.data");
Zarafa.common.recipientfield.data.SuggestionListStore=Ext.extend(Ext.data.Store,{actionType:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{batch:true,autoSave:false,remoteSort:true,actionType:Zarafa.core.Actions.list,proxy:new Zarafa.common.recipientfield.data.SuggestionListProxy,writer:new Ext.data.JsonWriter,reader:new Ext.data.JsonReader({root:"result"},Zarafa.common.recipientfield.data.SuggestionListRecord)});Zarafa.common.recipientfield.data.SuggestionListStore.superclass.constructor.call(this,
a)},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isDefined(a.cancelPreviousRequest))a.cancelPreviousRequest=true;if(!Ext.isDefined(a.actionType))a.actionType=this.actionType;Zarafa.common.recipientfield.data.SuggestionListStore.superclass.load.call(this,a)}});Ext.reg("zarafa.suggestionliststore",Zarafa.common.recipientfield.data.SuggestionListStore);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.TimelineView=Ext.extend(Ext.BoxComponent,{model:null,selector:null,headerHeight:50,defaultHourCellWidth:60,bufferTimesViewportWidth:5,daysMap:null,hoursEachDayMap:null,daySpacing:10,borderSpacing:1,blockRowHeight:22,sumBlockRowHeight:10,extraBodyHeight:0,workingHoursStart:0,workingHoursEnd:24,workDays:undefined,blockSelector:"div.x-freebusy-timeline-block",headerDayHeight:0,headerHoursHeight:15,headerSumRowHeight:10,slotDuration:null,dayWidth:null,hourWidth:null,timelineWidth:null,
all:null,userStore:null,blockStore:null,sumBlockStore:null,uniqueBlockId:null,constructor:function(a){a=a||{};a=Ext.applyIf(a,{workingHoursStart:container.getSettingsModel().get("zarafa/v1/main/start_working_hour"),workingHoursEnd:container.getSettingsModel().get("zarafa/v1/main/end_working_hour"),workDays:container.getSettingsModel().get("zarafa/v1/main/working_days")});if(Ext.isEmpty(a.workDays))a.workDays=[0,1,2,3,4,5,6];this.addEvents("bodyscroll","timelinemousedown","timelinemouseup","timelinemousemove",
"rendertimeline","beforerefreshtimeline","afterrefreshtimeline");Zarafa.common.freebusy.ui.TimelineView.superclass.constructor.call(this,a);this.daterange=this.model.getDateRange();this.mon(this.model,"userstorechange",this.onUserStoreChange,this);this.mon(this.model,"blockstorechange",this.onBlockStoreChange,this);this.mon(this.model,"sumblockstorechange",this.onSumBlockStoreChange,this);this.mon(this.model,"showworkinghourschange",this.onShowWorkingHoursChange,this)},initComponent:function(){this.masterTpl=
new Ext.XTemplate('<div class="x-freebusy-header">','<div class="x-freebusy-header-body"></div>','<div class="x-freebusy-sumblockcontainer"></div>',"</div>",'<div class="x-freebusy-body">','<div class="x-freebusy-background"></div>','<div class="x-freebusy-blockcontainer"></div>','<div class="x-freebusy-selectorcontainer"></div>',"</div>",{disableFormats:true});this.headerTemplate=new Ext.XTemplate('<table class="x-freebusy-timeline-day-header" cellpadding="0" cellspacing="{borderSpacing}" style="width: {dayWidth}px">',
'<tr class="x-freebusy-timeline-day">','<td colspan="{numHours}" style="height:{headerDayHeight}px;">',"{dayLabel}","</td>","</tr>",'<tr class="x-freebusy-timeline-hour">','<tpl for="hours">','<td style="width: {parent.hourWidth}px; height:{parent.headerHoursHeight}px;">{label}</td>',"</tpl>","</tr>","</table>",{disableFormats:true});this.headerSumTemplate=new Ext.XTemplate('<table class="x-freebusy-timeline-day-sum" cellpadding="0" cellspacing="{borderSpacing}" style="width: {dayWidth}px">','<tr class="x-freebusy-timeline-hour x-freebusy-timeline-sum">',
'<tpl for="hours">','<td style="width: {parent.hourWidth}px; height:{parent.headerSumRowHeight}px;"></td>',"</tpl>","</tr>","</table>",{disableFormats:true});this.bodyBGTemplate=new Ext.XTemplate('<table class="x-freebusy-timeline-day-body" cellpadding="0" cellspacing="{borderSpacing}" style="width: {dayWidth}px">','<tr class="x-freebusy-timeline-hour">','<tpl for="hours">','<td style="width: {parent.hourWidth}px">&nbsp;</td>',"</tpl>","</tr>","</table>",{disableFormats:true});this.blockTemplate=
new Ext.XTemplate('<tpl for=".">','<div class="x-freebusy-timeline-block x-freebusy-timeline-block-{busyStatusName}" id="{blockId}" style="width: {blockWidth}px; left: {blockLeft}px; top:{blockTop}px; height: {blockHeight}px;"></div>',"</tpl>",{disableFormats:true});this.sumBlockTemplate=new Ext.XTemplate('<tpl for=".">','<div class="x-freebusy-timeline-sumblock x-freebusy-timeline-block-{busyStatusName}" style="width: {blockWidth}px; left: {blockLeft}px; height: {blockHeight}px;"></div>',"</tpl>",
{disableFormats:true});this.uniqueBlockId=Ext.id();this.all=new Ext.CompositeElementLite;Zarafa.common.freebusy.ui.TimelineView.superclass.initComponent.call(this);this.selector&&this.selector.init(this)},onRender:function(){this.autoEl={cls:"x-freebusy-timeline-container"};Zarafa.common.freebusy.ui.TimelineView.superclass.onRender.apply(this,arguments);this.buildDayMapping();this.renderTimeline()},refreshTimeline:function(){this.fireEvent("beforerefreshtimeline",this);var a=this.captureViewportSnapshot();
this.buildDayMapping();this.renderTimeline();this.syncSize();this.restoreViewportSnapshot(a);this.refresh();this.fireEvent("afterrefreshtimeline",this)},captureViewportSnapshot:function(){var a={selectionInView:false,focusDateRange:null,diffOffset:null},b=this.model.getSelectorRange();a.selectionInView=this.getViewedDateRange().overlaps(b);if(a.selectionInView){b=this.findBlockPixelOffset(b.getStartDate().getTime()/1E3);var c=this.bodyElem.getScroll().left,d=Ext.get(this.bodyElem).getViewSize();a.diffOffset=
b-(c+d.width/2)}else a.focusDateRange=this.getFocusDateRange();return a},restoreViewportSnapshot:function(a){if(a.selectionInView){a=this.findTimestampByTimelineXCoord(this.findBlockPixelOffset(this.model.getSelectorRange().getStartDate().getTime()/1E3)-a.diffOffset);a=new Zarafa.core.DateRange({startDate:new Date(a*1E3),dueDate:new Date(a*1E3)})}else a=a.focusDateRange;this.scrollDateIntoView(a)},getFocusDateRange:function(){var a=this.bodyElem.getScroll().left,b=Ext.get(this.bodyElem).getViewSize();
a=(a+b.width/2)/(this.dayWidth+this.daySpacing);b=a%1;a=Math.floor(a);a=this.daysMap[a].timestamp+this.hoursEachDayMap[Math.floor(this.hoursEachDayMap.length*b)].startDayOffset;b=a+this.slotDuration;return new Zarafa.core.DateRange({startDate:new Date(a*1E3),dueDate:new Date(b*1E3)})},getViewedDateRange:function(){var a=this.bodyElem.getScroll().left,b=Ext.get(this.bodyElem).getViewSize();b=a+b.width;a=this.findTimestampByTimelineXCoord(a);b=this.findTimestampByTimelineXCoord(b);return new Zarafa.core.DateRange({startDate:new Date(a*
1E3),dueDate:new Date(b*1E3)})},renderTimeline:function(){this.bodyElem&&this.mun(this.bodyElem,{scope:this,scroll:this.onBodyScroll,mousedown:this.onBodyMouseDown,mousemove:this.onBodyMouseMove,mouseup:this.onBodyMouseUp,contextmenu:this.onBodyContextMenu});this.headerElem&&this.mun(this.headerElem,{scope:this,contextmenu:this.onHeaderContextMenu});this.masterTpl.overwrite(this.el);this.containerElem=Ext.get(this.el.dom);this.headerElem=Ext.get(this.containerElem.dom.firstChild);this.headerBodyElem=
Ext.get(this.headerElem.dom.firstChild);this.headerSumContainer=Ext.get(this.headerElem.dom.childNodes[1]);this.bodyElem=Ext.get(this.containerElem.dom.childNodes[1]);this.bodyBackgroundElem=Ext.get(this.bodyElem.dom.firstChild);this.bodyBlockContainer=Ext.get(this.bodyElem.dom.childNodes[1]);this.bodySelectorContainer=Ext.get(this.bodyElem.dom.childNodes[2]);this.mon(this.bodyElem,{scope:this,scroll:this.onBodyScroll,mousedown:this.onBodyMouseDown,mousemove:this.onBodyMouseMove,mouseup:this.onBodyMouseUp,
contextmenu:this.onBodyContextMenu});this.mon(this.headerElem,{scope:this,contextmenu:this.onHeaderContextMenu});this.layoutTimelineElements();this.fireEvent("rendertimeline",this)},layoutTimelineElements:function(){this.headerBodyElem.setWidth(this.timelineWidth);this.bodyBackgroundElem.setWidth(this.timelineWidth);this.bodyBlockContainer.setWidth(this.timelineWidth);this.headerDayHeight=this.headerHeight-(this.headerSumRowHeight+this.borderSpacing*2)-this.headerHoursHeight;this.headerSumContainer.setTop(this.headerHeight-
(this.headerSumRowHeight+this.borderSpacing));if(Ext.isIE6||Ext.isIE7){this.headerDayHeight-=3;this.bodyBackgroundElem.setStyle("top",-1);this.bodySelectorContainer.setStyle("top",-1)}},afterRender:function(){Zarafa.common.freebusy.ui.TimelineView.superclass.afterRender.apply(this,arguments);this.model.getBlockStore()&&this.bindBlockStore(this.model.getBlockStore(),true);this.model.getSumBlockStore()&&this.bindSumBlockStore(this.model.getSumBlockStore(),true);this.model.getUserStore()&&this.bindUserStore(this.model.getUserStore(),
true)},getBlockTemplateTarget:function(){return this.bodyBlockContainer},getBGTemplateTarget:function(){return this.bodyBackgroundElem},getSelectorContainer:function(){return this.bodySelectorContainer},onResize:function(a,b){this.headerElem.setHeight(this.headerHeight);this.bodyElem.setTop(this.headerHeight);this.bodyElem.setHeight(b-this.headerHeight||0);this.sizeTimelineBackground();this.headerElem.setWidth(this.bodyElem.dom.clientWidth);this.repaintTimeline()},onBodyScroll:function(){this.repaintTimeline();
this.fireEvent("bodyscroll",this.bodyElem.getScroll())},onBodyMouseDown:function(a,b,c){this.fireEvent("timelinemousedown",a,b,c)},onBodyMouseMove:function(a,b,c){this.fireEvent("timelinemousemove",a,b,c)},onBodyMouseUp:function(a,b,c){this.fireEvent("timelinemouseup",a,b,c)},onBodyContextMenu:function(a){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelinebody"],undefined,{position:a.getXY(),model:this.model})},onHeaderContextMenu:function(a){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelineheader"],
undefined,{position:a.getXY(),model:this.model})},sizeTimelineBackground:function(){if(!(this.bodyElem.dom.clientHeight<=0)){var a=this.userStore.getCount()*this.blockRowHeight+this.extraBodyHeight;this.bodyBackgroundElem.setHeight(Math.max(this.bodyElem.dom.clientHeight,a));this.bodySelectorContainer.setHeight(Math.max(this.bodyElem.dom.clientHeight,a));this.bodyElem.scrollTo("top",this.bodyElem.dom.scrollHeight)}},repaintTimeline:function(){this.getBGTemplateTarget();var a=Ext.get(this.bodyElem).getViewSize(),
b=this.bodyElem.getScroll(),c=(this.bufferTimesViewportWidth-1)*a.width;a=b.left+a.width+c/2;b=Math.floor((b.left-c/2)/this.dayWidth);c=Math.ceil(a/this.dayWidth);b=b<0?0:b;c=c<this.daysMap.length?c:this.daysMap.length-1;a=[];for(var d=[],e=0;e<this.daysMap.length;e++)if(e>=b&&e<=c)this.daysMap[e].displayNodeBody||(a[a.length]=e);else if(this.daysMap[e].displayNodeBody)d[d.length]=e;this.renderTimelineDays(a);this.headerElem.scrollTo("left",this.bodyElem.getScroll().left);this.cleanUpTimelineDays(d)},
renderTimelineDays:function(a){for(var b=Ext.get(this.headerBodyElem),c=Ext.get(this.bodyBackgroundElem),d=0;d<a.length;d++){var e=a[d],f="";if(this.daysMap[e].currentDay)f=" x-freebusy-timeline-day-current";var g=c.createChild({cls:"x-freebusy-timeline-day"+f});g.dom.style.left=this.daysMap[e].leftPos+"px";this.bodyBGTemplate.overwrite(g,{dayLabel:this.daysMap[e].label,hours:this.hoursEachDayMap,hourWidth:this.hourWidth,numHours:this.hoursEachDayMap.length,dayWidth:this.dayWidth});f=b.createChild({cls:"x-freebusy-timeline-day"+
f});f.dom.style.left=this.daysMap[e].leftPos+"px";this.headerTemplate.overwrite(f,{dayLabel:this.daysMap[e].label,hours:this.hoursEachDayMap,hourWidth:this.hourWidth,numHours:this.hoursEachDayMap.length,dayWidth:this.dayWidth,headerDayHeight:this.headerDayHeight,headerHoursHeight:this.headerHoursHeight,borderSpacing:this.borderSpacing});this.headerSumTemplate.append(f,{hours:this.hoursEachDayMap,hourWidth:this.hourWidth,numHours:this.hoursEachDayMap.length,dayWidth:this.dayWidth,headerSumRowHeight:this.headerSumRowHeight,
borderSpacing:this.borderSpacing});this.daysMap[e].displayNodeHeader=f;this.daysMap[e].displayNodeBody=g}},cleanUpTimelineDays:function(a){Ext.get(this.bodyBackgroundElem);Ext.get(this.bodyBackgroundElem);for(var b,c=0;c<a.length;c++){var d=a[c];b=this.daysMap[d].displayNodeHeader;Ext.removeNode(b.dom);b=this.daysMap[d].displayNodeBody;Ext.removeNode(b.dom);this.daysMap[d].displayNodeHeader=false;this.daysMap[d].displayNodeBody=false}},scrollDateIntoView:function(a){if(a instanceof Date)a=Math.ceil(a.getTime()/
1E3);else if(a instanceof Zarafa.core.DateRange){var b=a.getStartDate().getTime()/1E3;a=a.getDueDate().getTime()/1E3-b;a=b+a/2}b=Ext.get(this.bodyElem);var c=Ext.get(this.bodyElem).getViewSize();a=this.findBlockPixelOffset(a,true);a-=c.width/2;b.scrollTo("left",a)},buildDayMapping:function(){var a=(new Date).clearTime();this.daysMap=[];this.hoursEachDayMap=[];this.slotDuration=3600;for(var b=86400/this.slotDuration,c=0;c<b;c++){var d=Math.floor(this.workingHoursStart/60),e=Math.ceil(this.workingHoursEnd/
60);if(!this.model.showOnlyWorkingHours()||c>=d&&c<e)this.hoursEachDayMap[this.hoursEachDayMap.length]={label:Date.parseDate(c,"G").format(_("G:i")),startDayOffset:c*this.slotDuration,workingHour:c>=d&&c<e?true:false}}c=this.hoursEachDayMap.length;this.hourWidth=this.defaultHourCellWidth;this.dayWidth=(this.hourWidth+this.borderSpacing)*c+this.borderSpacing;b=this.daterange.getStartDate().clearTime(true);for(c=0;c<this.daterange.getNumDays();c++){d=b.add(Date.DAY,c);e=a.getTime()==d.getTime();for(var f=
false,g=0,h=this.workDays.length;g<h;g++)if(this.workDays[g]==d.getDay()){f=true;break}if(!this.model.showOnlyWorkingHours()||f)this.daysMap.push({label:d.format(_("l jS F Y")),currentDay:e,timestamp:d.getTime()/1E3,displayNodeHeaderBody:false,displayNodeBody:false,leftPos:this.daysMap.length*(this.dayWidth+this.daySpacing)})}this.timelineWidth=(this.dayWidth+this.daySpacing)*this.daysMap.length-this.daySpacing},bindBlockStore:function(a){this.blockStore&&this.mun(this.blockStore,"load",this.onBlockLoad,
this);if(this.blockStore=Ext.StoreMgr.lookup(a)){this.mon(this.blockStore,{scope:this,load:this.onBlockLoad});this.refresh()}},bindSumBlockStore:function(a){this.sumBlockStore&&this.mun(this.sumBlockStore,"load",this.onSumBlocksLoad,this);if(this.sumBlockStore=Ext.StoreMgr.lookup(a)){this.mon(this.sumBlockStore,{scope:this,load:this.onSumBlocksLoad});this.refresh()}},onBlockLoad:function(a,b){if(this.all.getCount()===0)this.refresh();else{var c=this.bufferBlockRender(this.filterRecords(b));this.all.last().insertSibling(c,
"after",true);this.all.elements.push.apply(this.all.elements,c)}},onSumBlocksLoad:function(a,b){a.getCount()==0?this.sumBlockTemplate.overwrite(this.headerSumContainer.dom,[]):this.sumBlockTemplate.overwrite(this.headerSumContainer.dom,this.collectData(b,0,true))},onRemove:function(a,b){this.all.removeElement(this.uniqueBlockId+"-"+b.id,true);this.blockStore.getCount()===0&&this.refresh()},refresh:function(){this.bodyBlockContainer.update("");this.all.clear();if(this.blockStore){var a=this.blockStore.getRange();
if(a.length>0){this.blockTemplate.overwrite(this.bodyBlockContainer.dom,this.collectData(this.filterRecords(a)));this.all.fill(Ext.query(this.blockSelector,this.bodyBlockContainer.dom))}}if(this.sumBlockStore){a=this.sumBlockStore.getRange();a.length>0&&this.sumBlockTemplate.overwrite(this.headerSumContainer.dom,this.collectData(this.filterRecords(a)))}},bufferBlockRender:function(a){var b=document.createElement("div");this.blockTemplate.overwrite(b,this.collectData(a));return Ext.query(this.blockSelector,
b)},collectData:function(a,b,c){for(var d=[],e=0,f=a.length;e<f;e++)d[d.length]=this.prepareData(a[e].data,b+e,a[e],c);return d},prepareData:function(a,b,c,d){a=Ext.apply({},a);a.blockId=this.uniqueBlockId+"-"+c.id;if(a.status!=Zarafa.core.mapi.BusyStatus.UNKNOWN){a.busyStatusName=Zarafa.core.mapi.BusyStatus.getName(a.status)||"busy";a.busyStatusName=a.busyStatusName.toLowerCase()}else a.busyStatusName="blur";b=1;if(d===true)d=this.sumBlockRowHeight;else{d=this.blockRowHeight;c=this.userStore.indexOfId(c.get("userid"));
if(c>=0)b+=c*d}a.blockTop=b;var e=this.daterange.getStartDate().getTime()/1E3;c=this.daterange.getDueDate().getTime()/1E3;var f=parseInt(a.start,10);b=parseInt(a.end,10);if(f<c&&b>e){a.blockHeight=d-2;if(f<e)a.blockLeft=0;else{d=this.findBlockPixelOffset(f,true);a.blockLeft=d}if(b>c)a.blockWidth=this.bodyBackgroundElem.getWidth()-a.blockLeft;else{d=this.findBlockPixelOffset(b,false);a.blockWidth=d-a.blockLeft}}return a},filterRecords:function(a){for(var b=[],c=this.daterange.getStartDate().getTime()/
1E3,d=this.daterange.getDueDate().getTime()/1E3,e=0;e<a.length;e++){var f=parseInt(a[e].get("start"),10),g=parseInt(a[e].get("end"),10);this.filterBlockData(f,g,c,d)&&b.push(a[e])}return b},filterBlockData:function(a,b,c,d){if(a<d&&b>c)if(this.model.showOnlyWorkingHours())if(b-a<=(this.workingHoursStart+(1440-this.workingHoursEnd))*60){c=this.workingHoursStart*60;d=this.workingHoursEnd*60;a=new Date(a*1E3);var e=new Date(b*1E3);b=a.getHours()*60*60+a.getMinutes()*60+a.getSeconds();a=e.getHours()*
60*60+e.getMinutes()*60+e.getSeconds();a=a>c&&a<=d;if(b>=c&&b<d||a)return true}else return true;else return true;return false},findBlockPixelOffset:function(a,b){var c=this.findDayIndexByTimestamp(a,b),d=new Date(a*1E3),e=d.getHours();d=d.getMinutes();e=e==0&&d==0&&!b?this.dayWidth:this.findPixelOffsetStartOfDayBySecs((e*60+d)*60);if(e==-1)e=this.dayWidth+(c<this.daysMap.length-1?this.daySpacing:0);return this.daysMap[c].leftPos+e},findPixelOffsetStartOfDayBySecs:function(a){var b=this.hoursEachDayMap[0].startDayOffset;
if(this.hoursEachDayMap[this.hoursEachDayMap.length-1].startDayOffset+this.slotDuration<a)return-1;if(b>=a)return 0;a=(a-b)/(this.slotDuration*this.hoursEachDayMap.length)*this.dayWidth;return a=Math.round(a)},findDayIndexByTimestamp:function(a,b){Ext.isDefined(b)||(b=true);for(var c=0,d=0;d<this.daysMap.length;d++)if(b&&this.daysMap[d].timestamp<=a)c=d;else if(!b&&this.daysMap[d].timestamp<a)c=d;else break;return c},findTimestampByTimelineXCoord:function(a){var b=a/(this.dayWidth+this.daySpacing);
a=b%1*(this.dayWidth+this.daySpacing)/this.dayWidth;a=a<1?a*this.slotDuration*this.hoursEachDayMap.length+this.hoursEachDayMap[0].startDayOffset:this.hoursEachDayMap[this.hoursEachDayMap.length-1].startDayOffset+this.slotDuration;b=new Date(this.daysMap[Math.floor(b)].timestamp*1E3);var c=Math.floor(a/3600);a=Math.floor(a%3600/60);b.setHours(c);b.setMinutes(a);return Math.floor(b.getTime()/1E3)},bindUserStore:function(a,b){if(this.userStore){this.mun(this.userStore,"datachanged",this.onUserRefresh,
this);this.mun(this.userStore,"add",this.onUserAdd,this);this.mun(this.userStore,"remove",this.onUserRemove,this);this.mun(this.userStore,"clear",this.onUserRefresh,this)}if(this.userStore=Ext.StoreMgr.lookup(a)){this.mon(this.userStore,{scope:this,datachanged:this.onUserRefresh,add:this.onUserAdd,remove:this.onUserRemove,clear:this.onUserRefresh});b||this.sizeTimelineBackground()}},onUserStoreChange:function(a){this.bindUserStore(a);this.refresh();this.sizeTimelineBackground()},onBlockStoreChange:function(a){this.bindBlockStore(a)},
onSumBlockStoreChange:function(a){this.bindSumBlockStore(a)},onShowWorkingHoursChange:function(){this.refreshTimeline()},onUserRefresh:function(){this.refresh();this.sizeTimelineBackground()},onUserAdd:function(){this.sizeTimelineBackground()},onUserRemove:function(){this.refresh();this.sizeTimelineBackground()}});Ext.reg("zarafa.freebusytimelineview",Zarafa.common.freebusy.ui.TimelineView);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.SuggestionListView=Ext.extend(Ext.DataView,{constructor:function(a){a=a||{};var b=a.model?a.model.getSuggestionBlockStore():undefined;Ext.applyIf(a,{deferEmptyText:false,emptyText:'<div class="zarafa-freebusy-suggestionrow zarafa-freebusy-suggestionrow-empty">'+_("No suggestions available")+"</div>",tpl:new Ext.XTemplate('<tpl for=".">','<div class="x-btn zarafa-freebusy-suggestionrow" id="zarafa-freebusy-suggestionrow-{[xindex]}">','<div class="x-btn-small x-btn-icon-small-left">',
'<em class="" unselectable="on">','<button type="button" class=" x-btn-text">','<img class="x-freebusy-suggestionrow-icon" src="'+Ext.BLANK_IMAGE_URL+'" />',"{[this.formatTime(values.start)]} - {[this.formatTime(values.end)]}","</button>","</em>","</div>","</div>","</tpl>",{formatTime:function(c){return(new Date(c*1E3)).format(_("H:i"))}}),store:b,itemSelector:"div.zarafa-freebusy-suggestionrow"});Zarafa.common.freebusy.ui.SuggestionListView.superclass.constructor.call(this,a);this.model.on("suggestionblockstorechange",
this.onSuggestionBlockStoreChange,this)},onSuggestionBlockStoreChange:function(a){this.bindStore(a)}});Ext.reg("zarafa.freebusysuggestionlistview",Zarafa.common.freebusy.ui.SuggestionListView);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.SuggestionListPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"panel",border:true,autoHeight:true,bodyStyle:"background-color: inherit; padding: 3px; border-style: none none solid none;",items:[{xtype:"container",border:false,height:168,width:175,layout:"fit",items:[{xtype:"datepicker",ref:"../../suggestionDate",showToday:false,minDate:a.model?
a.model.getDateRange().getStartDate():null,minText:_("No freebusy information available for this date"),maxDate:a.model?a.model.getDateRange().getDueDate():null,maxText:_("No freebusy information available for this date"),style:"border : none",listeners:{select:this.onDateSelect,scope:this}}]}]},{xtype:"zarafa.freebusysuggestionlistview",bodyStyle:"background-color: inherit;",flex:1,autoScroll:true,model:a.model,listeners:{click:this.onSuggestionClick,scope:this}}]});this.addEvents(["dateselect",
"select"]);Zarafa.common.freebusy.ui.SuggestionListPanel.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.freebusy.ui.SuggestionListPanel.superclass.initEvents.call(this);this.mon(this.model.getDateRange(),"update",this.onDateRangeUpdate,this);this.mon(this.model.getSuggestionRange(),"update",this.onSuggestionRangeUpdate,this)},onSuggestionClick:function(a,b){this.fireEvent("select",this,a.getStore().getAt(b))},onDateSelect:function(a,b){this.model.setSuggestionDate(b);this.fireEvent("dateselect",
this,b)},onDateRangeUpdate:function(a){this.suggestionDate.setMinDate(a.getStartDate());this.suggestionDate.setmaxDate(a.getDueDate())},onSuggestionRangeUpdate:function(a){this.suggestionDate.setValue(a.getStartDate())}});Ext.reg("zarafa.freebusysuggestionlistpanel",Zarafa.common.freebusy.ui.SuggestionListPanel);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.FreebusyPanel=Ext.extend(Ext.Panel,{blockStore:null,userStore:null,model:null,userlistConfig:null,timelineConfig:null,suggestionConfig:null,legendaConfig:null,showUserList:true,showSuggestionList:true,editable:true,showLegenda:true,headerHeight:50,inputfieldHeight:20,initialScrollToCurrentDay:true,initialScrollDone:false,constructor:function(a){a=a||{};var b=a.modelConfig||{};Ext.applyIf(b,{userStore:a.userStore,blockStore:a.blockStore});b=new Zarafa.common.freebusy.data.FreebusyModel(b);
Ext.applyIf(a,{layout:"border",border:true,blockStore:b.getBlockStore(),userStore:b.getUserStore(),model:b,userlistConfig:{},timelineConfig:{},suggestionConfig:{},legendaConfig:{}});Zarafa.common.freebusy.ui.FreebusyPanel.superclass.constructor.call(this,a);this.add([this.createUserListView(),this.createSuggestionView(),this.createTimelineView(),this.createLegendaView()]);this.initFreebusyEvents()},createUserListView:function(){return{xtype:"panel",ref:"userListView",region:"west",layout:"fit",title:_("Select attendees"),
hidden:!this.showUserList,footer:true,footerCfg:{tag:"div",cls:"x-panel-footer"},border:false,width:200,collapsible:true,split:true,collapseMode:"mini",items:[Ext.applyIf(this.userlistConfig,{xtype:"zarafa.freebusyuserlistview",model:this.model,inputFieldHeight:this.editable?this.inputfieldHeight:0,editable:this.editable})]}},createSuggestionView:function(){return{xtype:"panel",ref:"suggestionListView",region:"east",layout:"fit",title:_("Suggested Times"),hidden:!this.showSuggestionList,footer:true,
footerCfg:{tag:"div",cls:"x-panel-footer"},border:false,width:200,collapsible:true,split:true,collapseMode:"mini",items:[Ext.applyIf(this.suggestionConfig,{xtype:"zarafa.freebusysuggestionlistpanel",model:this.model,listeners:{select:this.onSelectSuggestion,dateselect:this.onSuggestionDateSelect,scope:this}})]}},createTimelineView:function(){return Ext.applyIf(this.timelineConfig,{xtype:"zarafa.freebusytimelineview",ref:"timelineView",region:"center",blockStore:this.blockStore,model:this.model,selector:new Zarafa.common.freebusy.data.TimelineSelector,
extraBodyHeight:this.editable?this.inputfieldHeight:0,headerHeight:this.headerHeight,hideNonWorkingHours:true,listeners:{bodyscroll:this.onTimelineScroll,scope:this}})},createLegendaView:function(){return Ext.applyIf(this.legendaConfig,{xtype:"container",region:"south",border:true,style:"margin: 3px 0px 0px 0px; padding: 3px 0px 3px 0px;",layout:"hbox",hidden:!this.showLegenda,autoHeight:true,cls:"x-freebusy-timeline-container x-freebusy-legenda",items:[{xtype:"container",cls:"x-freebusy-timeline-block-busy",
width:25,height:25},{xtype:"displayfield",value:_("Busy"),hideLabel:true,width:100},{xtype:"container",cls:"x-freebusy-timeline-block-tentative",width:25,height:25},{xtype:"displayfield",value:_("Tentative"),hideLabel:true,width:100},{xtype:"container",cls:"x-freebusy-timeline-block-outofoffice",width:25,height:25},{xtype:"displayfield",value:_("Out of Office"),hideLabel:true,width:100},{xtype:"container",cls:"x-freebusy-timeline-block-blur",width:25,height:25},{xtype:"displayfield",value:_("No Information"),
hideLabel:true,width:100}]})},initFreebusyEvents:function(){this.mon(this,"afterlayout",this.onAfterLayout,this)},getModel:function(){return this.model},setEditable:function(a){if(this.editable!==a){this.editable=a;this.userListView.get(0).setEditable(a)}},onAfterLayout:function(){if(this.userListView){var a=this.headerHeight;a-=this.userListView.header.getMargins("tb");a-=this.userListView.header.getBorderWidth("tb");a-=this.userListView.header.getPadding("tb");this.userListView.header.setStyle("height",
a+"px");this.userListView.footer.setStyle("height",Ext.getScrollBarWidth()-2+"px")}if(this.suggestionListView){a=this.headerHeight;a-=this.userListView.header.getMargins("tb");a-=this.userListView.header.getBorderWidth("tb");a-=this.userListView.header.getPadding("tb");this.suggestionListView.header.setStyle("height",a+"px");this.suggestionListView.footer.setStyle("height",Ext.getScrollBarWidth()-2+"px")}if(this.initialScrollToCurrentDay)if(!(this.initialScrollDone||this.timelineView.getWidth()==
0)){this.initialScrollDone=true;this.scrollTimelineToSelection()}},scrollTimelineToSelection:function(){this.timelineView.selector?this.timelineView.selector.scrollTimelineToSelection():this.timelineView.scrollDateIntoView(new Date)},scrollTimelineToDate:function(a){this.timelineView.scrollDateIntoView(a)},onTimelineScroll:function(a){this.userListView.body.scrollTo("top",a.top)},onSelectSuggestion:function(a,b){var c=b.get("start")*1E3,d=b.get("end")*1E3;this.getModel().getSelectorRange().setTime(c,
d)},onSuggestionDateSelect:function(a,b){this.scrollTimelineToDate(b)}});Ext.reg("zarafa.freebusypanel",Zarafa.common.freebusy.ui.FreebusyPanel);Ext.namespace("Zarafa.common.freebusy.data");
Zarafa.common.freebusy.data.TimelineSelector=Ext.extend(Ext.util.Observable,{MOUSE_ON_EDGE_LEFT:1,MOUSE_ON_CENTER:2,MOUSE_ON_EDGE_RIGHT:3,selecting:false,selectionStart:null,selectionEnd:null,selectorRange:null,dragSelectionEdgeArea:10,constructor:function(a){Ext.apply(this,a||{});Zarafa.common.freebusy.data.TimelineSelector.superclass.constructor.call(this,a)},init:function(a){this.parent=a;this.masterTpl=new Ext.XTemplate('<div class="x-freebusy-selector">',"</div>",{disableFormats:true});this.parent.on("rendertimeline",
this.onParentRenderTimeline,this);this.parent.on("timelinemousedown",this.onParentTimelineMouseDown,this);this.parent.on("timelinemousemove",this.onParentTimelineMouseMove,this);this.parent.on("timelinemouseup",this.onParentTimelineMouseUp,this);this.bindSelectorRange(this.parent.model.getSelectorRange(),true)},bindSelectorRange:function(a,b){this.selectorRange&&!b&&this.selectorRange.un("update",this.onSelectorRangeUpdate,this);(this.selectorRange=a)&&this.selectorRange.on({scope:this,update:this.onSelectorRangeUpdate})},
render:function(){var a=this.parent.getSelectorContainer();this.masterTpl.overwrite(a);this.selectorElem=Ext.get(a.dom.firstChild);this.selectorElem.setVisibilityMode(Ext.Element.DISPLAY);this.selectorElem.on("mousemove",this.onMouseMoveSelector,this);this.positionSelector(this.selectorRange)},positionSelector:function(a){if(this.parent.model.getDateRange().overlaps(a)){var b=a.getStartDate().getTime()/1E3;a=a.getDueDate().getTime()/1E3;b=this.parent.findBlockPixelOffset(b,true);this.selectorElem.setLeft(b);
this.selectorElem.setWidth(this.parent.findBlockPixelOffset(a,false)-b);this.selectorElem.setVisible(true)}else this.selectorElem.setVisible(false)},scrollTimelineToSelection:function(){this.parent.scrollDateIntoView(this.selectorRange)},onSelectorRangeUpdate:function(a){this.positionSelector(a);this.selecting||this.scrollTimelineToSelection()},onParentRenderTimeline:function(){this.render()},onParentTimelineMouseDown:function(a,b){if(this.isMouseEventOnScrollbar(a,b))return true;this.selecting=true;
var c=this.parent.bodyElem,d=a.getPageX()-c.getLeft()+c.getScroll().left;c=this.getMousePosition(a.getPageX());d=this.parent.findTimestampByTimelineXCoord(d);switch(c){case this.MOUSE_ON_EDGE_LEFT:c=this.selectorRange.getDueDate();this.selectionStart=c.getTime()/1E3;break;case this.MOUSE_ON_EDGE_RIGHT:d=this.selectorRange.getStartDate();this.selectionStart=d.getTime()/1E3;break;default:d=new Date(d*1E3);d.round(Date.MINUTE,30);this.selectionStart=d.getTime()/1E3;c=d.add(Date.MINUTE,30);this.selectorRange.set(d,
c)}a.preventDefault()},onParentTimelineMouseMove:function(a){if(this.selecting){var b=this.parent.bodyElem;this.selectionEnd=this.parent.findTimestampByTimelineXCoord(a.getPageX()-b.getLeft()+b.getScroll().left);var c=new Date(this.selectionEnd*1E3);c.round(Date.MINUTE,30);this.selectionEnd=c.getTime()/1E3;if(this.selectionStart!=this.selectionEnd){if(this.selectionStart<=this.selectionEnd){b=new Date(this.selectionStart*1E3);c=c}else{b=c;c=new Date(this.selectionStart*1E3)}var d=this.selectorRange.getStartDate().getTime()!=
b.getTime(),e=this.selectorRange.getDueDate().getTime()!=c.getTime();if(d||e)this.selectorRange.set(b,c)}a.preventDefault()}},onParentTimelineMouseUp:function(a){if(this.selecting){this.selecting=false;a.preventDefault()}},onMouseMoveSelector:function(a){if(!this.selecting)switch(this.getMousePosition(a.getPageX())){case this.MOUSE_ON_EDGE_LEFT:case this.MOUSE_ON_EDGE_RIGHT:this.selectorElem.setStyle("cursor","w-resize");break;default:this.selectorElem.setStyle("cursor","")}},getMousePosition:function(a){var b=
this.selectorElem.getXY()[0],c=b+this.selectorElem.getWidth();return Math.abs(a-b)<this.dragSelectionEdgeArea?this.MOUSE_ON_EDGE_LEFT:Math.abs(c-a)<this.dragSelectionEdgeArea?this.MOUSE_ON_EDGE_RIGHT:this.MOUSE_ON_EDGE_CENTER},isMouseEventOnScrollbar:function(a){var b=this.parent.bodyElem.dom;if(a&&a.browserEvent&&b){var c=Ext.get(b).getXY();if(a.browserEvent.clientX-c[0]>b.clientWidth||a.browserEvent.clientY-c[1]>b.clientHeight)return true}return false}});Ext.namespace("Zarafa.common.freebusy.data");
Zarafa.common.freebusy.data.FreebusyModel=Ext.extend(Ext.util.Observable,{nonWorkingHoursHidden:true,daterange:null,selectorRange:null,suggestionRange:null,userStore:null,blockStore:null,sumBlockStore:null,freeBlockStore:null,suggestionBlockStore:null,updatingSelectorRangeExternally:false,constructor:function(a){a=a||{};var b=container.getSettingsModel().get("zarafa/v1/contexts/calendar/freebusy_load_start_offset");b=(new Date).add(Date.DAY,b).clearTime();var c=container.getSettingsModel().get("zarafa/v1/contexts/calendar/freebusy_load_end_offset");
c=(new Date).add(Date.DAY,c).clearTime();var d,e;if(a.selectorRange){d=a.selectorRange.getStartDate();e=a.selectorRange.getDueDate()}else{d=(new Date).ceil(Date.MINUTE,30);e=d.add(Date.MINUTE,30)}Ext.applyIf(a,{userStore:a.userStore||new Zarafa.core.data.IPMRecipientStore,daterange:a.daterange||new Zarafa.core.DateRange({startDate:b,dueDate:c}),selectorRange:new Zarafa.core.DateRange({startDate:d,dueDate:e}),blockStore:a.blockStore||new Zarafa.common.freebusy.data.FreebusyBlockStore,sumBlockStore:a.sumBlockStore||
new Zarafa.common.freebusy.data.FreebusyBlockStore({remoteSort:false}),suggestionBlockStore:a.suggestionBlockStore||new Zarafa.common.freebusy.data.FreebusyBlockStore({remoteSort:false})});Ext.apply(this,a);this.addEvents("showworkinghourschange","userstorechange","blockstorechange","sumblockstorechange","suggestionblockstorechange","daterangechange","selectorrangeupdate");Zarafa.common.freebusy.data.FreebusyModel.superclass.constructor.call(this,a);this.initEvents();this.setDateRange(a.daterange,
true);this.setUserStore(a.userStore,true);this.setSelectorRange(a.selectorRange,true);this.setBlockStore(a.blockStore,true);this.setSumBlockStore(a.sumBlockStore,true);this.setSuggestionBlockStore(a.suggestionBlockStore,true);this.createFreeBlockStore();this.createSuggestionRange()},initEvents:function(){this.on("showworkinghourschange",this.onShowWorkingHoursChange,this);this.on("userstorechange",this.onUserStoreChange,this)},createFreeBlockStore:function(){if(!this.freeBlockStore)this.freeBlockStore=
new Zarafa.common.freebusy.data.FreebusyBlockStore({remoteSort:false});return this.freeBlockStore},createSuggestionRange:function(){if(!this.suggestionRange){this.suggestionRange=new Zarafa.core.DateRange;this.setSuggestionDate(this.selectorRange.getStartDate());this.suggestionRange.on("update",this.onSuggestionRangeUpdate,this,{buffer:5})}return this.suggestionRange},showOnlyWorkingHours:function(){return this.nonWorkingHoursHidden},hideNonWorkingHours:function(a){var b=this.nonWorkingHoursHidden;
this.nonWorkingHoursHidden=a;b!=this.nonWorkingHoursHidden&&this.fireEvent("showworkinghourschange",this.nonWorkingHoursHidden);return this.nonWorkingHoursHidden},getUserStore:function(){return this.userStore},setUserStore:function(a,b){if(!(b!==true&&this.userStore===a)){var c=this.userStore;if(this.userStore){this.userStore.un("resolved",this.onUserResolved,this);this.userStore.un("load",this.onUserLoad,this);this.userStore.un("add",this.onUserAdd,this);this.userStore.un("remove",this.onUserRemove,
this);this.userStore.un("clear",this.onUserClear,this)}(this.userStore=Ext.StoreMgr.lookup(a))&&this.userStore.on({scope:this,resolved:this.onUserResolved,load:this.onUserLoad,add:this.onUserAdd,remove:this.onUserRemove,clear:this.onUserClear});this.fireEvent("userstorechange",this.userStore,c);this.userStore!==c&&c&&c.autoDestroy&&c.destroy();return this.userStore}},getBlockStore:function(){return this.blockStore},setBlockStore:function(a,b){if(!(b!==true&&this.blockStore===a)){var c=this.blockStore;
if(this.blockStore){this.blockStore.un("load",this.onBlockLoad,this);this.blockStore.un("remove",this.onBlockRemove,this,{buffer:100});this.blockStore.un("clear",this.onBlockRemove,this)}if(this.blockStore=Ext.StoreMgr.lookup(a)){this.blockStore.on("load",this.onBlockLoad,this);this.blockStore.on("remove",this.onBlockRemove,this,{buffer:100});this.blockStore.on("clear",this.onBlockRemove,this)}this.fireEvent("blockstorechange",this.blockStore,c);this.blockStore!==c&&c&&c.autoDestroy&&c.destroy();
return this.blockStore}},getSumBlockStore:function(){return this.sumBlockStore},setSumBlockStore:function(a,b){if(!(b!==true&&this.sumBlockStore===a)){var c=this.sumBlockStore;this.sumBlockStore&&this.sumBlockStore.un("load",this.onSumBlockLoad,this,{buffer:5});(this.sumBlockStore=Ext.StoreMgr.lookup(a))&&this.sumBlockStore.on("load",this.onSumBlockLoad,this,{buffer:5});this.fireEvent("sumblockstorechange",this.sumBlockStore,c);this.sumBlockStore!==c&&c&&c.autoDestroy&&c.destroy();return this.sumBlockStore}},
getSuggestionBlockStore:function(){return this.suggestionBlockStore},setSuggestionBlockStore:function(a,b){if(!(b!==true&&this.suggestionBlockStore===a)){var c=this.suggestionBlockStore;this.suggestionBlockStore=Ext.StoreMgr.lookup(a);this.fireEvent("suggestionblockstorechange",this.suggestionBlockStore,c);this.suggestionBlockStore!==c&&c&&c.autoDestroy&&c.destroy();return this.suggestionBlockStore}},getUserCount:function(){return this.userStore.getCount()},addUser:function(a,b){b=Ext.isNumber(b)?
b:Zarafa.core.mapi.RecipientType.MAPI_TO;var c=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{display_name:a,recipient_type:b});this.userStore.add(c);return c},getDateRange:function(){return this.daterange},setDateRange:function(a,b){if(!(b!==true&&this.daterange===a)){var c=this.daterange;this.daterange=a;this.fireEvent("daterangechange",this.daterange,c);return this.daterange}},getSelectorRange:function(){return this.selectorRange},
setSelectorRange:function(a,b){if(!(b!==true&&this.selectorRange===a)){this.selectorRange&&this.selectorRange.un("update",this.onSelectorRangeUpdate,this,{buffer:5});(this.selectorRange=a)&&this.selectorRange.on("update",this.onSelectorRangeUpdate,this,{buffer:5});return this.selectorRange}},selectRange:function(a,b){if(!this.selectorRange.equals(new Zarafa.core.DateRange({startDate:a,dueDate:b})))this.updatingSelectorRangeExternally=true;this.selectorRange.set(a,b)},getSuggestionRange:function(){return this.suggestionRange},
setSuggestionDate:function(a,b){var c=a.clone().clearTime(),d=a.clone().clearTime();if(this.nonWorkingHoursHidden){c=c.add(Date.MINUTE,container.getSettingsModel().get("zarafa/v1/main/start_working_hour"));d=d.add(Date.MINUTE,container.getSettingsModel().get("zarafa/v1/main/end_working_hour"))}else d=d.add(Date.DAY,1);if(this.suggestionRange.getStartTime()!==c.getTime())this.suggestionRange.set(c,d);else Ext.isDefined(b)&&this.suggestionRange.fireEvent("update",this.suggestionRange)},loadFreebusyData:function(a){var b=
this.getDateRange(),c={add:true,actionType:Zarafa.core.Actions.list,params:{users:[],start:b.getStartTime()/1E3,end:b.getDueTime()/1E3}};Ext.isArray(a)||(a=[a]);Ext.each(a,function(d){if(d.isResolved()||d.attemptedToResolve())c.params.users.push({userid:d.id,entryid:d.get("entryid")})});Ext.isEmpty(c.params.users)||this.blockStore.load(c)},onUserResolved:function(a,b){this.loadFreebusyData(b)},onUserLoad:function(a,b){this.loadFreebusyData(b)},onUserAdd:function(a,b){this.loadFreebusyData(b)},onUserRemove:function(a,
b){Ext.each(b,function(c){var d=this.blockStore.getRange();Ext.each(d,function(e){e.get("userid")==c.id&&this.blockStore.remove(e)},this)},this)},onUserClear:function(){this.blockStore.removeAll()},createSumBlock:function(a){return new Zarafa.common.freebusy.data.FreebusyBlockRecord({start:a.get("start"),end:a.get("end"),status:a.get("status")})},createSuggestionBlocks:function(a,b,c,d){var e=[];b-=c;for(a=a;a<=b;a+=d)e.push(new Zarafa.common.freebusy.data.FreebusyBlockRecord({start:a,end:a+c}));
return e},mergeRecordIntoSumBlock:function(a,b){if(a.get("status")!==b.get("status"))return false;var c=a.get("start"),d=a.get("end"),e=b.get("start"),f=b.get("end");if(d<e||f<c)return false;if(e<=c&&d<=f)return true;if(c<e&&f<d){b.set("start",c);b.set("end",d);return true}if(c<e){b.set("start",c);return true}if(f<d){b.set("end",d);return true}return false},mergeBlocksToSumBlockStore:function(a,b,c){var d={};a.sort(function(e,f){return e.get("start")-f.get("start")});Ext.each(a,function(e){var f=
e.get("status");if(f===Zarafa.core.mapi.BusyStatus.UNKNOWN||f===Zarafa.core.mapi.BusyStatus.FREE)return true;if(c===false)f=Zarafa.core.mapi.BusyStatus.BUSY;if(b.getCount()==0){b.add(this.createSumBlock(e));return true}var g=d[f];if(!Ext.isDefined(g)||this.mergeRecordIntoSumBlock(e,g)!==true){e=this.createSumBlock(e);b.add(e);d[f]=e}},this)},mergeSumBlocks:function(a){var b={};a.sort("start","ASC");a.each(function(c){var d=b[c.get("status")];if(Ext.isDefined(d))if(d.get("end")>=c.get("start")){d.set("end",
c.get("end"));a.remove(c);return true}b[c.get("status")]=c},this)},onBlockLoad:function(){this.sumBlockStore.removeAll();if(this.getUserStore().getCount()!=0)this.getUserStore().getCount()==1?Ext.each(this.blockStore.getRange(),function(a){var b=a.get("status");b!==Zarafa.core.mapi.BusyStatus.UNKNOWN&&b!==Zarafa.core.mapi.BusyStatus.FREE&&this.sumBlockStore.add(this.createSumBlock(a))},this):this.mergeBlocksToSumBlockStore(this.blockStore.getRange(),this.sumBlockStore);this.sumBlockStore.sort("status",
"ASC");this.sumBlockStore.fireEvent("load",this.sumBlockStore,this.sumBlockStore.getRange(),{})},onBlockRemove:function(a){this.onBlockLoad(a,a.getRange(),{})},onSumBlockLoad:function(a,b){this.freeBlockStore.removeAll();a.getCount()>0&&this.mergeBlocksToSumBlockStore(b,this.freeBlockStore,false);this.loadSuggestionBlocks()},onShowWorkingHoursChange:function(){this.setSuggestionDate(this.suggestionRange.getStartDate())},onUserStoreChange:function(a){a.fireEvent("load",a,a.getRange())},onSelectorRangeUpdate:function(a,
b){this.updatingSelectorRangeExternally||this.fireEvent("selectorrangeupdate",a,b);this.updatingSelectorRangeExternally=false;this.setSuggestionDate(a.getStartDate(),a.getDuration())},onSuggestionRangeUpdate:function(){this.loadSuggestionBlocks()},loadSuggestionBlocks:function(){this.suggestionBlockStore.removeAll();if(this.freeBlockStore.getCount()>0){var a=this.suggestionRange.getStartTime()/1E3,b=this.suggestionRange.getDueTime()/1E3,c=this.selectorRange.getDuration(Date.SECOND),d=Ext.min([c,1800]);
if(d<=0)d=1800;this.freeBlockStore.each(function(e){var f=e.get("start");e=e.get("end");if(!(e<a||f>b))if(f>b)return false;else{f<=a||this.suggestionBlockStore.add(this.createSuggestionBlocks(a,Ext.min([f,b]),c,d));a=e}},this);a<b&&this.suggestionBlockStore.add(this.createSuggestionBlocks(a,b,c,d))}this.suggestionBlockStore.fireEvent("load",this.suggestionBlockStore,this.suggestionBlockStore.getRange(),{})},checkAttendeesBusyStatus:function(a,b){var c=this.getSumBlockStore();if(!c)return false;var d=
false;a=a.getTime()/1E3;b=b.getTime()/1E3;c.sort("start","ASC");for(var e=0;e<c.getCount();e++){var f=c.getAt(e);if(f.get("end")>a)if(!(f.get("status")===Zarafa.core.mapi.BusyStatus.FREE||f.get("status")===Zarafa.core.mapi.BusyStatus.UNKNOWN)){if(f.get("start")<b)d=true;break}}return d}});Ext.namespace("Zarafa.common.form");
Zarafa.common.form.TextArea=Ext.extend(Ext.form.TextArea,{enableSystemContextMenu:false,onRender:function(){Zarafa.common.form.TextArea.superclass.onRender.apply(this,arguments);this.enableSystemContextMenu&&this.el.addClass("zarafa-contextmenu-enabled")},insertAtCursor:function(a){if(Ext.isIE){this.el.focus();var b=document.selection.createRange();b.text=a;b.moveEnd("character",a.length);b.moveStart("character",a.length)}else{b=this.el.dom.selectionEnd;this.el.dom.value=this.el.dom.value.substring(0,
this.el.dom.selectionStart)+a+this.el.dom.value.substring(b,this.el.dom.value.length);this.el.focus();this.el.dom.setSelectionRange(b+a.length,b+a.length)}}});Ext.reg("zarafa.textarea",Zarafa.common.form.TextArea);Ext.namespace("Zarafa.common.dialogs");
Zarafa.common.dialogs.MessageBox=Ext.apply({},Ext.MessageBox,{initDialog:function(a){var b=Ext.MessageBox.getDialog();b.on("hide",function(c){c.removeAll()},b,{single:true});b.on("destroy",function(c){c.removeAll()},b,{single:true});b.on("beforeshow",function(c){c.add(a)},b,{single:true})},select:function(a,b,c,d,e,f){b=Ext.create({xtype:"displayfield",autoHeight:true,autoWidth:true,value:b,hideLabel:true,htmlEncode:true});var g=Ext.create({xtype:"radiogroup",hideLabel:true,style:"padding-left: 50px;",
columns:1,items:e,value:f});this.initDialog([{xtype:"container",anchor:"100% 100%",items:[b,g]}]);Ext.MessageBox.show({title:a,buttons:Ext.MessageBox.OKCANCEL,fn:function(h){Ext.callback(c,d||window,[h,g.getValue()],1)},minWidth:Ext.MessageBox.minPromptWidth,scope:d,prompt:false,value:f});return this}});Ext.namespace("Zarafa.common.dialogs");
Zarafa.common.dialogs.CopyMovePanel=Ext.extend(Ext.Panel,{record:undefined,objectType:undefined,constructor:function(a){a=a||{};if(a.record){if(!Ext.isArray(a.record))a.record=[a.record];if(!a.objectType)a.objectType=a.record[0].get("object_type")}Ext.applyIf(a,{xtype:"zarafa.copymovepanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",header:true,items:[this.createTreePanel()],buttons:[{text:_("Copy"),handler:this.onCopy,scope:this,ref:"../copyButton",
disabled:true},{text:_("Move"),handler:this.onMove,scope:this,ref:"../moveButton",disabled:true},{text:_("Cancel"),handler:this.onCancel,scope:this}]});Ext.apply(this,a);Zarafa.common.dialogs.CopyMovePanel.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterLayout,this,{single:true})},createTreePanel:function(){return{xtype:"panel",layout:"form",border:false,flex:1,bodyStyle:"background-color: inherit;",items:[{xtype:"displayfield",value:_("Destination folder")+":",hideLabel:true},
{xtype:"zarafa.hierarchytree",border:true,enableDD:false,treeSorter:true,anchor:"100% 90%",ref:"../hierarchyTree",treeSorter:true}]}},onRender:function(a,b){Zarafa.common.dialogs.CopyMovePanel.superclass.onRender.call(this,a,b);this.mon(this.hierarchyTree.getSelectionModel(),"selectionchange",this.onSelectionChange,this);if(this.objectType==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)this.setTitle(String.format(ngettext("There is {0} message selected.","There are {0} messages selected.",this.record.length),
this.record.length));else this.objectType==Zarafa.core.mapi.ObjectType.MAPI_FOLDER&&this.setTitle(String.format(_("Folder '{0}' selected."),Ext.util.Format.htmlEncode(this.record[0].getDisplayName())))},onAfterLayout:function(){var a=this.dialog.getSelectedFolder();a&&this.hierarchyTree.selectFolderInTree(a)},onSelectionChange:function(a,b){if(!Ext.isDefined(b)||b.getFolder().isIPMSubTree()&&this.objectType==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE){this.copyButton.disable();this.moveButton.disable()}else{this.copyButton.enable();
this.moveButton.enable()}},onCopy:function(){var a=this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder(),b=this.record[0].getStore();if(Ext.isDefined(a))if(!Ext.isEmpty(this.record)){Ext.each(this.record,function(c){c.copyTo(a)},this);this.dialog.selectFolder(a);b.save(this.record);this.dialog.close()}},onMove:function(){var a=this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder(),b=this.record[0].getStore();if(Ext.isDefined(a))if(!Ext.isEmpty(this.record)){Ext.each(this.record,
function(c){c.moveTo(a)},this);this.dialog.selectFolder(a);b.save(this.record);this.dialog.close()}},onCancel:function(){this.dialog.close()}});Ext.reg("zarafa.copymovepanel",Zarafa.common.dialogs.CopyMovePanel);Ext.namespace("Zarafa.common.delegates.ui");
Zarafa.common.delegates.ui.DelegatesPanel=Ext.extend(Ext.Panel,{store:undefined,constructor:function(a){a=a||{};if(!a.store)a.store=new Zarafa.common.delegates.data.DelegateStore;Ext.applyIf(a,{xtype:"zarafa.delegatespanel",border:false,layout:{type:"vbox",align:"stretch",pack:"start"},items:this.createPanelItems(a.store)});Zarafa.common.delegates.ui.DelegatesPanel.superclass.constructor.call(this,a)},createPanelItems:function(a){return[{xtype:"displayfield",value:_("Delegates can send items on your behalf. To grant permission to others to access your folders without also giving them sent-on-behalf-of priviledges, go to properties for each folder and change the options on the Permissions Tab."),
fieldClass:"x-form-display-field zarafa-delegates-extrainfo"},{xtype:"container",flex:1,layout:{type:"hbox",align:"stretch",pack:"start"},items:[{xtype:"zarafa.delegatesgrid",ref:"../delegatesGrid",store:a,flex:1},{xtype:"container",width:160,defaults:{width:140},layout:{type:"vbox",align:"center",pack:"start"},items:[{xtype:"button",text:_("Add")+"...",handler:this.onDelegateAdd,ref:"../../addButton",scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("Remove")+"...",disabled:true,ref:"../../removeButton",
handler:this.onDelegateRemove,scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("Permission")+"...",disabled:true,ref:"../../permissionButton",handler:this.onDelegatePermission,scope:this}]}]}]},initEvents:function(){Zarafa.common.delegates.ui.DelegatesPanel.superclass.initEvents.call(this);this.mon(this.store,"add",this.afterDelegateAdd,this);this.mon(this.delegatesGrid.getSelectionModel(),"selectionchange",this.onGridSelectionChange,this)},onDelegateAdd:function(){Zarafa.common.Actions.openABUserSelectionDialog(this.abCallBack.createDelegate(this),
{hide_contacts:true},{hide_users:["contact","system","non_security","room","equipment","non_active"],hide_groups:["non_security"],hide_companies:true})},abCallBack:function(a){a=a.convertToDelegate();this.store.getById(a.get("entryid"))?Ext.Msg.alert(_("Alert"),_("Delegate already exists in the list.")):this.store.add(a)},afterDelegateAdd:function(a,b){if(Ext.isArray(b))for(var c=0,d=b.length;c<d;c++)this.afterDelegateAdd(a,b[c],c);else b.phantom&&this.delegatesGrid.openDelegatePermissions(b)},onGridSelectionChange:function(a){a=
a.hasSelection()===false;this.removeButton.setDisabled(a);this.permissionButton.setDisabled(a)},onDelegateRemove:function(){this.delegatesGrid.removeDelegate()},onDelegatePermission:function(){this.delegatesGrid.openDelegatePermissions()},discardChanges:function(){this.store.load()},saveChanges:function(){this.store.save()}});Ext.reg("zarafa.delegatespanel",Zarafa.common.delegates.ui.DelegatesPanel);Ext.namespace("Zarafa.common.delegates.ui");
Zarafa.common.delegates.ui.DelegatesGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(a){a=a||{};if(!a.store)a.store=new Zarafa.common.delegates.data.DelegateStore;Ext.applyIf(a,{xtype:"zarafa.delegatesgrid",border:true,store:a.store,viewConfig:{forceFit:true,emptyText:"<div class='emptytext'>"+_("No delegate exists")+"</div>"},loadMask:this.initLoadMask(),columns:this.initColumnModel(),selModel:this.initSelectionModel(),listeners:{viewready:this.onViewReady,rowdblclick:this.onRowDblClick,
scope:this}});Zarafa.common.delegates.ui.DelegatesGrid.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.delegates.ui.DelegatesGrid.superclass.initEvents.call(this);this.mon(this.store,"load",this.onViewReady,this,{single:true})},initColumnModel:function(){return[{dataIndex:"display_name",header:_("Name"),renderer:Zarafa.common.ui.grid.Renderers.text}]},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:true})},initLoadMask:function(){return{msg:_("Loading delegates")+
"..."}},onViewReady:function(){this.getSelectionModel().selectFirstRow()},onRowDblClick:function(a,b){this.openDelegatePermissions(a.getStore().getAt(b))},openDelegatePermissions:function(a){(a=a||this.getSelectionModel().getSelected())?Zarafa.common.Actions.openDelegatePermissionDialog(a):Ext.Msg.alert(_("Alert"),_("Please select a delegate."))},removeDelegate:function(){var a=this.getSelectionModel().getSelected();a?this.store.remove(a):Ext.Msg.alert(_("Alert"),_("Please select a delegate."))}});
Ext.reg("zarafa.delegatesgrid",Zarafa.common.delegates.ui.DelegatesGrid);Ext.namespace("Zarafa.common.delegates.dialogs");
Zarafa.common.delegates.dialogs.DelegatePermissionPanel=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.delegatepermissionpanel",labelAlign:"left",items:this.createPanelItems()});Zarafa.common.delegates.dialogs.DelegatePermissionPanel.superclass.constructor.call(this,a)},createPanelItems:function(){return[{xtype:"fieldset",title:_("This delegate has the following permissions"),
autoHeight:true,autoWidth:true,cls:"zarafa-fieldset",labelAlign:"left",items:[this.createComboField("calendar",_("Calendar")),{xtype:"checkbox",boxLabel:_("Delegate receives copies of meeting-related messages sent to me."),ref:"../delegateMeetingRuleCheck",name:"has_meeting_rule",hideLabel:true,checked:false,listeners:{check:this.onDelegateRuleCheck,scope:this}},this.createComboField("tasks",_("Tasks")),this.createComboField("inbox",_("Inbox")),this.createComboField("contacts",_("Contacts")),this.createComboField("notes",
_("Notes")),this.createComboField("journal",_("Journal"))]},{xtype:"checkbox",boxLabel:_("Delegate can see my private items."),ref:"delegatePrivateCheck",name:"can_see_private",hideLabel:true,checked:false,listeners:{check:this.onPrivateCheck,scope:this}}]},createComboField:function(a,b){return{xtype:"combo",name:"rights_"+a,boxMinWidth:200,anchor:"100%",fieldLabel:b,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.delegates.data.DelegatePermissionProfiles},mode:"local",triggerAction:"all",
displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,value:Zarafa.core.mapi.Rights.RIGHTS_NONE,listeners:{select:this.onProfileSelect,scope:this}}},update:function(a,b){this.record=a;this.getForm().loadRecord(a);this.updateUI(a,b)},updateUI:function(a,b){if(b||a.isModifiedSinceLastUpdate("rights_calendar")){var c=a.get("rights_calendar");!c||c===Zarafa.core.mapi.Rights.RIGHTS_NONE||c===Zarafa.core.mapi.Rights.RIGHTS_READONLY?this.delegateMeetingRuleCheck.setDisabled(true):
this.delegateMeetingRuleCheck.setDisabled(false)}},updateRecord:function(a){this.getForm().updateRecord(a)},onProfileSelect:function(a,b){var c=a.name;this.record.beginEdit();this.record.set(c,b.get(a.valueField));if(c==="rights_calendar"){c=this.record.get(c);if(!c||c===Zarafa.core.mapi.Rights.RIGHTS_NONE||c===Zarafa.core.mapi.Rights.RIGHTS_READONLY)this.record.set("has_meeting_rule",false);this.updateUI(this.record,false)}this.record.endEdit()},onDelegateRuleCheck:function(a,b){this.record.set("has_meeting_rule",
b)},onPrivateCheck:function(a,b){this.record.set("can_see_private",b)}});Ext.reg("zarafa.delegatepermissionpanel",Zarafa.common.delegates.dialogs.DelegatePermissionPanel);Ext.namespace("Zarafa.common.checknames.dialogs");
Zarafa.common.checknames.dialogs.CheckNamesPanel=Ext.extend(Ext.Panel,{checkNamesList:undefined,store:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Ext.data.JsonStore({autoDestroy:true,idProperty:"smtp_address",fields:Zarafa.core.data.IPMRecipientResolveRecord,data:[]});Ext.applyIf(a,{xtype:"zarafa.checknamespanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",header:true,items:[{xtype:"displayfield",value:_("Select an address to use")+
":",hideLabel:true},{xtype:"grid",ref:"checkNamesList",flex:1,store:a.store,viewConfig:{forceFit:true},columns:[{dataIndex:"display_name",header:_("Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"smtp_address",header:_("Email"),renderer:Ext.util.Format.htmlEncode}],listeners:{scope:this,viewready:this.onViewReady,dblclick:this.onDblClick},selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),cls:"zarafa-checknames-dialog-filelist"}]});Zarafa.common.checknames.dialogs.CheckNamesPanel.superclass.constructor.call(this,
a)},update:function(a,b){this.setTitle(String.format(_("More than one '{0}' found."),Ext.util.Format.htmlEncode(a.get("display_name"))));this.store.add(b||[])},onViewReady:function(){this.checkNamesList.getSelectionModel().selectFirstRow()},updateRecord:function(a){var b=this.checkNamesList.getSelectionModel().getSelected();if(Ext.isEmpty(b)){Ext.Msg.alert(_("Alert"),_("Please select a recipient"));return false}else a.applyResolveRecord(b)},onDblClick:function(){this.dialog.onOk()}});
Ext.reg("zarafa.checknamespanel",Zarafa.common.checknames.dialogs.CheckNamesPanel);Ext.namespace("Zarafa.common.categories.dialogs");
Zarafa.common.categories.dialogs.CategoriesPanel=Ext.extend(Ext.Panel,{record:undefined,categorySeparator:";",constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.categoriespanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",defaults:{border:false,bodyStyle:"padding-bottom: 5px; background-color: inherit;"},items:[this.createFormCategoriesField(),this.createFormSelectionArea()]});Ext.apply(this,a);Zarafa.common.categories.dialogs.CategoriesPanel.superclass.constructor.call(this,
a)},createFormCategoriesField:function(){return{xtype:"panel",layout:"fit",height:100,title:_("Item belongs to these categories"),items:[{xtype:"textarea",hideLabel:true,ref:"../categoriesTextArea"}]}},createFormSelectionArea:function(){return[{xtype:"panel",layout:{type:"hbox",align:"stretch"},flex:1,title:_("Available categories"),defaults:{border:false,bodyStyle:"background-color: inherit;"},items:[{xtype:"panel",layout:"fit",flex:1,items:this.createCategoriesGrid()}]}]},createCategoriesGrid:function(){var a=
new Ext.grid.CheckboxSelectionModel({singleSelect:false,checkOnly:true,listeners:{selectionchange:this.onSelectionChange,scope:this}});return{xtype:"grid",border:true,enableHdMenu:false,deferRowRender:false,autoExpandColumn:"category",ref:"../../categoriesGrid",viewConfig:{forceFit:true,autoExpandColumn:true,scrollOffset:0},store:new Zarafa.common.categories.data.CategoriesStore,colModel:new Ext.grid.ColumnModel({columns:[a,{id:"category",header:_("Category"),dataIndex:"category",sortable:false,renderer:Ext.util.Format.htmlEncode}]}),
sm:a,listeners:{scope:this,afterrender:this.onAfterRender}}},getCategoriesTextArea:function(){return this.categoriesTextArea},getCategoriesGrid:function(){return this.categoriesGrid},onAfterRender:function(){this.getCategoriesGrid().getSelectionModel().suspendEvents(false);var a=this.getAvailableCategories();Ext.isEmpty(a)||this.getCategoriesGrid().getSelectionModel().selectRecords(a);this.updateCategories(this.getActiveCategories());this.getCategoriesGrid().getSelectionModel().resumeEvents()},getActiveCategories:function(){var a=
[],b=[],c="";Ext.isDefined(this.record)&&Ext.each(this.record,function(d){c=d.get("categories");if(!Ext.isEmpty(c)){b=c.split(this.categorySeparator);for(d=0;d<b.length;d++)a.push(b[d])}},this);a=Zarafa.core.Util.trimStringArray(a);return Zarafa.core.Util.uniqueArray(a)},getAvailableCategories:function(){for(var a=[],b=this.getCategoriesGrid(),c=this.getActiveCategories(),d=0;d<c.length;d++)for(var e=0;e<b.getStore().getCount();e++)if(c[d]==b.getStore().getAt(e).get("category")){a.push(b.getStore().getAt(e));
break}return a},getActiveExtraCategories:function(){for(var a=[],b=this.getCategoriesGrid(),c=this.getActiveCategories(),d=false,e=0;e<c.length;e++){d=false;for(var f=0;f<b.getStore().getCount();f++)if(c[e]==b.getStore().getAt(f).get("category")){d=true;break}d||a.push(c[e])}return Zarafa.core.Util.trimStringArray(a)},onSelectionChange:function(){this.getCategoriesTextArea().setValue("");var a=this.getCategoriesGrid().getSelectionModel().getSelections(),b=[];Ext.each(a,function(c){b.push(c.get("category"))},
this);this.updateCategories(b)},updateCategories:function(a){var b=this.getCategoriesTextArea();this.getCategoriesGrid();var c=b.getValue(),d=[];if(!Ext.isEmpty(a))if(Ext.isEmpty(c,false))d=Ext.isArray(a)?a:[a];else{d=c.split(this.categorySeparator);d=d.concat(a)}a=this.getActiveExtraCategories();if(a.length)for(c=0;c<a.length;c++)d.push(a[c]);d=Zarafa.core.Util.trimStringArray(d);d=Zarafa.core.Util.sortArray(d,"ASC",Zarafa.core.Util.caseInsensitiveComparison);d=Zarafa.core.Util.uniqueArray(d);c=
d.join(this.categorySeparator+" ");if(c.length>0)c+=this.categorySeparator;b.setValue("");b.setValue(c)}});Ext.reg("zarafa.categoriespanel",Zarafa.common.categories.dialogs.CategoriesPanel);Ext.namespace("Zarafa.common.categories.data");
Zarafa.common.categories.data.CategoriesStore=Ext.extend(Ext.data.ArrayStore,{constructor:function(a){a=a||{};var b=[];b=b.concat(container.getSettingsModel().get("zarafa/v1/main/categories"));b=b.concat(container.populateInsertionPoint("main.categories"));for(var c=0;c<b.length;c++)Ext.isArray(b[c])||(b[c]=[b[c]]);Ext.applyIf(a,{fields:["category"],data:b});Ext.apply(this,a);Zarafa.common.categories.data.CategoriesStore.superclass.constructor.call(this,a)}});Ext.reg("zarafa.categoriesstore",Zarafa.common.categories.data.CategoriesStore);
Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachmentsPanel=Ext.extend(Ext.Panel,{maxAttachments:undefined,maxAttachmentSize:undefined,maxAttachmentTotalSize:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");var b=container.getSettingsModel().get("zarafa/v1/main/attachments",true);this.maxAttachments=b.max_attachments;this.maxAttachmentSize=b.max_attachment_size;this.maxAttachmentTotalSize=b.max_attachment_total_size;a=Ext.applyIf(a,
{xtype:"zarafa.attachmentspanel",id:"attachpan",border:false,autoScroll:true,html:'<iframe id="zarafa_attachment_iframedownload" style="display: none"></iframe>',items:[this.initForm(),this.initInfoPanel(),this.initListView(),this.initButtons(),{xtype:"form",ref:"deletionFormPanel",fileUpload:true,border:false,hidden:true}]});Ext.apply(this,a);Zarafa.common.attachment.dialogs.AttachmentsPanel.superclass.constructor.call(this,a)},initForm:function(){return{xtype:"form",ref:"addFormPanel",layout:"column",
fileUpload:true,autoWidth:true,autoHeight:true,border:false,bodyStyle:"padding: 5px;",defaults:{anchor:"95%",border:false,bodyStyle:"padding: 5px;"},items:[{xtype:"fileuploadfield",ref:"fileuploadfield",columnWidth:0.91,emptyText:_("Select a file"),name:"attachments[]",buttonText:_("Browse")+"...",border:false,listeners:{fileselected:this.onFileSelected,scope:this}},{xtype:"zarafa.simpleprogressindicator",columnWidth:0.05,height:20,border:false,ref:"../statusBar"}]}},initInfoPanel:function(){return{xtype:"container",
ref:"infoPanel",style:"padding:5px",tpl:'<tpl if="Ext.isDefined(values.max_attachments)">'+_("Maximum number of attachments")+': {max_attachments}<br /></tpl><tpl if="Ext.isDefined(values.max_attachment_size)">'+_("Maximum attachment size")+': {max_attachment_size:fileSize}<br /></tpl><tpl if="Ext.isDefined(values.max_attachment_total_size)">'+_("Maximum total attachment size")+": {max_attachment_total_size:fileSize}</tpl><br />",data:{max_attachments:this.maxAttachments,max_attachment_size:this.maxAttachmentSize,
max_attachment_total_size:this.maxAttachmentTotalSize}}},initListView:function(){return{xtype:"listview",store:new Ext.data.Store,ref:"filelist",multiSelect:false,singleSelect:true,deferEmptyText:false,emptyText:'<div class="emptytext">'+_("No files to display")+"</div>",reserveScrollOffset:true,height:150,cls:"zarafa-attachments-dialog-filelist",columns:[{header:_("Name"),dataIndex:"name",tpl:"{name:htmlEncode}"},{header:_("Size"),dataIndex:"size",tpl:"{size:fileSize}",width:0.2,align:"right"}],
listeners:{selectionchange:this.onSelectionChange,scope:this}}},initButtons:function(){return{xtype:"container",layout:"hbox",style:"padding:5px",items:[{xtype:"button",ref:"../downloadButton",text:_("Download selected file"),border:false,disabled:true,handler:this.onDownloadAttachment,scope:this},{xtype:"button",ref:"../deleteButton",text:_("Delete selected file"),border:false,disabled:true,handler:this.onDeleteAttachment,scope:this}]}},canUploadFiles:function(a,b){if(Ext.isDefined(this.maxAttachments))if(b.getCount()>=
this.maxAttachments){container.getNotifier().notify("error.attachment",_("Attachment error"),_("Cannot upload attachment, total attachment count has been exceeded"),this.dialog.getEl());return false}if(Ext.isDefined(a)){var c=a[0];c=c.fileSize||c.size;if(Ext.isDefined(this.maxAttachmentSize))if(c>this.maxAttachmentSize){container.getNotifier().notify("error.attachment",_("Attachment error"),_("Cannot upload attachment, attachment size is too big"),this.dialog.getEl());return false}if(Ext.isDefined(this.maxAttachmentTotalSize))if(c+
b.sum("size")>this.maxAttachmentTotalSize){container.getNotifier().notify("error.attachment",_("Attachment error"),_("Cannot upload attachment, total attachment size is too big"),this.dialog.getEl());return}}return true},onSelectionChange:function(a,b){if(Ext.isEmpty(b)){this.deleteButton.disable();this.downloadButton.disable()}else if(b.length===1){this.deleteButton.enable();this.downloadButton.enable()}},onFileSelected:function(a){this.canUploadFiles(a.fileInput.dom.files,this.filelist.store)===
true?this.postForm():a.reset()},onDeleteAttachment:function(){var a=this.filelist.getSelectedRecords();if(!Ext.isEmpty(a)){a=a[0];this.record.getAttachmentStore().remove(a);a=a.isTmpFile()?{deleteattachment:a.get("tmpname"),type:"new"}:{deleteattachment:a.get("attach_num"),type:"attachment"};this.deletionFormPanel.getForm().submit({url:this.record.getAttachmentStore().getUploadAttachmentUrl(),method:"POST",params:a})}},onDownloadAttachment:function(){var a=this.filelist.getSelectedRecords();if(!Ext.isEmpty(a)){a=
a[0].getAttachmentUrl();document.getElementById("zarafa_attachment_iframedownload").contentWindow.location=a}},update:function(a,b){if((this.record=a)&&b===true&&a.isOpened()){this.record.getAttachmentStore().filterBy(function(c){return c.get("hidden")!==true});this.filelist.bindStore(this.record.getAttachmentStore())}},postForm:function(){var a=this.addFormPanel.getForm();if(a.isValid()){this.statusBar.showBusy();a.submit({url:this.record.getAttachmentStore().getUploadAttachmentUrl(),failure:function(b,
c){if(!Ext.isEmpty(c.result.error)&&!Ext.isEmpty(c.result.error.info)){var d=c.result.error.info.display_message?c.result.error.info.display_message:c.result.error.info.original_message;container.getNotifier().notify("error.attachment",_("Error"),d)}this.statusBar.showFailed()},success:function(b,c){if(Ext.isDefined(c.result.files)&&c.result.files[0]!=null&&c.result.files[0]!=""){this.processAttachmentUploadResponse(c.result);this.statusBar.showSuccess()}else this.statusBar.showFailed();this.addFormPanel.fileuploadfield.reset()},
scope:this})}},processAttachmentUploadResponse:function(a){var b=this.record.getAttachmentStore();if(Ext.isArray(a.files))for(var c=0;c<a.files.length;c++){var d=a.files[c];if(d.newfile){var e=Zarafa.core.data.RecordFactory.createRecordObjectByObjectType(Zarafa.core.mapi.ObjectType.MAPI_ATTACH);e.set("tmpname",d.tmpname);e.set("name",d.filename);e.set("size",d.size);b.add(e)}}}});Ext.reg("zarafa.attachmentspanel",Zarafa.common.attachment.dialogs.AttachmentsPanel);Ext.namespace("Zarafa.common");
Zarafa.common.Actions={downloadFrame:undefined,openCopyMoveDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.copymoverecords"],a,{browser:b})},openRecurrenceDialog:function(a,b,c){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.recurrence"],a,{autoSave:Ext.isDefined(b)?b:true,browser:c,modal:true})},openCategoriesDialog:function(a,b,c){Ext.isArray(a)||
(a=[a]);Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.categories"],a,{autoSave:Ext.isDefined(b)?b:true,browser:c,modal:true})},openAttachmentsDialog:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.attachments"],a,{browser:b,modal:true})},openViewRecipientDialog:function(a,b){if(a.isResolved()){if(a.isPersonalContact()){a=a.convertToContactRecord();container.getShadowStore().add(a)}else if(!a.isOneOff()){a=
a.convertToABRecord();container.getShadowStore().add(a)}this.openViewRecord(a,b)}},openDelegatePermissionDialog:function(a){a&&Zarafa.common.Actions.openCreateRecord(a,{modal:true})},openContextMenu:function(a,b,c){var d=Zarafa.core.data.SharedComponentType["common.contextmenu"];c=Ext.applyIf(c||{},{position:b});Zarafa.common.Actions.openRecord(d,a,c)},openViewRecord:function(a,b){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.view"],a,b)},openCreateRecord:function(a,
b){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.create"],a,b)},openRecord:function(a,b,c){if(a=container.getSharedComponent(a,b))if(a.prototype instanceof Zarafa.core.ui.Dialog)Zarafa.core.ui.Dialog.openDialog(a,b,c);else a.prototype instanceof Ext.menu.Menu?(new a(Ext.applyIf(c||{},{records:b}))).showAt(c.position):a.doOpen(b)},openPrintDialog:function(a){if(!Ext.isEmpty(a)){Ext.isArray(a)||(a=[a]);if(a.length>1)Ext.MessageBox.alert(_("print"),_("Printing of multiple items is not allowed at this time"));
else{var b=function(c,d){if(c){if(this!==d)return;c.un("open",b,d)}var e=container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.printer.renderer"],d);if(e)(new e).print(d);else d instanceof Zarafa.core.data.MAPIRecord?Ext.MessageBox.alert(_("print"),_("Printing of this item is not yet available")+"\n"+_("Item type: ")+d.get("message_class")):Ext.MessageBox.alert(_("print"),_("Printing of this view is not yet available"))};if(a[0]instanceof Zarafa.core.data.MAPIRecord&&!a[0].isOpened()){a[0].getStore().on("open",
b,a[0]);a[0].open()}else b(undefined,a[0])}}},openCheckNamesDialog:function(a,b,c){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.checknames"],b,{checkNamesData:a,browser:c,modal:true})},openReminderDialog:function(a,b){var c=container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.dialog.reminder"],a),d=Zarafa.core.data.DialogMgr.getDialogInstances(c);if(d.getCount()===0)a.length>0&&Zarafa.core.ui.Dialog.openDialog(c,a,{browser:b,modal:false});
else if(d.getCount()===1){c=d.first();a.length>0?c.focus():c.close()}},openReminderRecord:function(a,b){if(Ext.isArray(a))Ext.each(a,function(c){this.openReminderRecord(c)},this);else(a=a.convertToIPMRecord())&&Zarafa.common.Actions.openViewRecord(a,b)},openRecurringSelectionDialog:function(a,b,c){var d=_("Recurring Message"),e=_("This is a recurring message. Do you want to open only this occurrence or the series?");if(a.isMessageClass("IPM.Appointment",true))if(a.get("meeting")==Zarafa.core.mapi.MeetingStatus.NONMEETING){d=
_("Recurring Appointment");e=_("This is a recurring appointment. Do you want to open only this occurrence or the series?")}else{d=_("Recurring Meeting Request");e=_("This is a recurring meeting request. Do you want to open only this occurrence or the series?")}else if(a.isMessageClass("IPM.TaskRequest",true)){d=_("Recurring Task Request");e=_("This is a recurring task request. Do you want to open only this occurrence or the series?")}Zarafa.common.dialogs.MessageBox.select(d,e,b,c,[{boxLabel:_("Open this occurrence"),
id:"recurrence_occurence",name:"select",checked:true},{boxLabel:_("Open the series"),id:"recurrence_series",name:"select"}])},deleteRecurringSelectionDialog:function(a,b,c){var d=_("Recurring Message"),e=_("This is a recurring message. Do you want to delete only this occurrence or the series?");if(a.isMessageClass("IPM.Appointment",true))if(a.get("meeting")==Zarafa.core.mapi.MeetingStatus.NONMEETING){d=_("Recurring Appointment");e=_("This is a recurring appointment. Do you want to delete only this occurrence or the series?")}else{d=
_("Recurring Meeting Request");e=_("This is a recurring meeting request. Do you want to delete only this occurrence or the series?")}else if(a.isMessageClass("IPM.TaskRequest",true)){d=_("Recurring Task Request");e=_("This is a recurring task request. Do you want to delete only this occurrence or the series?")}Zarafa.common.dialogs.MessageBox.select(d,e,b,c,[{boxLabel:_("Delete this occurrence"),id:"recurrence_occurence",name:"select",checked:true},{boxLabel:_("Delete the series"),id:"recurrence_series",
name:"select"}])},deleteMeetingRequestConfirmationDialog:function(a,b,c){var d=_("Confirm Delete"),e=_('This "{0}" meeting was already accepted.'),f=_('You have not responded to the meeting request "{0}".');a=a.get("responsestatus")==Zarafa.core.mapi.ResponseStatus.RESPONSE_NOT_RESPONDED?String.format(f,a.get("subject")):String.format(e,a.get("subject"));Zarafa.common.dialogs.MessageBox.select(d,a,b,c,[{boxLabel:_("Delete and send a response to the meeting organizer"),id:"sendResponseOnDelete",name:"select",
checked:true},{boxLabel:_("Delete without sending"),id:"noResponseOnDelete",name:"select"}])},deleteRecords:function(a,b){var c=undefined,d=[];if(!Ext.isEmpty(a)){Ext.isArray(a)||(a=[a]);for(var e=0,f=a.length;e<f;e++){var g=a[e];c=g.getStore();var h=Ext.isFunction(g.isRecurring)&&g.isRecurring()&&b!==false,i=g.get("message_class");if(Zarafa.core.MessageClass.isClass(i,"IPM.Schedule.Meeting",true)||Zarafa.core.MessageClass.isClass(i,"IPM.TaskRequest",true))h=false;if(h)this.deleteRecurringItem(g);
else if(Ext.isFunction(g.isMeeting)&&g.isMeeting()&&!g.isAppointmentInPast()&&!g.isMeetingCanceled())if(g.isMeetingSent())Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("A cancellation message will be sent to all recipients, do you wish to continue?"),icon:Ext.MessageBox.WARNING,fn:this.cancelInvitation,scope:g,buttons:Ext.MessageBox.YESNO});else if(g.isMeetingResponseRequired())Zarafa.common.Actions.deleteMeetingRequestConfirmationDialog(g,this.declineInvitation,g);else{c.remove(g);d.push(g)}else{c.remove(g);
d.push(g)}}Ext.isEmpty(d)||c.save(d)}},deleteRecurringItem:function(a){Zarafa.common.Actions.deleteRecurringSelectionDialog(a,function(b,c){if(b=="ok"){c.id!="recurrence_series"?a.addIdProp("basedate"):a.removeIdProp("basedate");Zarafa.common.Actions.deleteRecords(a,false)}},this)},cancelInvitation:function(a){a=="yes"&&this.cancelInvitation()},declineInvitation:function(a,b){if(a=="ok")this.declineMeeting(b.id=="sendResponseOnDelete"?true:false)},openRestoreDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["common.dialog.restoreitems"],
undefined,{browser:b})},openABUserSelectionDialog:function(a,b,c,d){c=c||{};Ext.applyIf(c,{hide_distlist:true});Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"],undefined,{callback:a,hierarchyRestriction:b,listRestriction:c,browser:d,modal:true})},markAsRead:function(a,b){a=!Ext.isArray(a)?[a]:a;b=!Ext.isDefined(b)?true:b;for(var c=[],d=0,e=a.length;d<e;d++){var f=a[d];if(b!==f.isRead()){f.setReadFlags(b);if(b===true&&f.needsReadReceipt())switch(container.getSettingsModel().get("zarafa/v1/contexts/mail/readreceipt_handling")){case "ask":Ext.MessageBox.confirm("Zarafa WebApp",
_("The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?"),function(g){g=="no"&&f.addMessageAction("read_receipt","noreceipt");f.save()},this);break;case "never":f.addMessageAction("read_receipt","noreceipt");case "always":c.push(f);break}else c.push(f)}}Ext.isEmpty(c)||c[0].store.save(c)},downloadAttachment:function(a){if(!this.downloadFrame)this.downloadFrame=Ext.getBody().createChild({tag:"iframe",cls:"x-hidden"});this.downloadFrame.dom.contentWindow.location=
a.getAttachmentUrl()}};Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.taskpanel",bodyStyle:"background-color: inherit;",border:false,layout:"fit",items:this.createTabPanel()});Zarafa.task.dialogs.TaskPanel.superclass.constructor.call(this,a)},createTabPanel:function(){return[{xtype:"tabpanel",activeTab:0,border:false,bodyStyle:"background-color: inherit;",defaults:{bodyStyle:"background-color: inherit; padding: 5px;"},items:[{xtype:"zarafa.taskgeneraltab"},
{xtype:"zarafa.taskdetailtab"},container.populateInsertionPoint("context.task.taskdialog.tabs",this)]}]}});Ext.reg("zarafa.taskpanel",Zarafa.task.dialogs.TaskPanel);Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskGeneralTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.taskgeneraltab",title:_("Task"),layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",defaults:{border:true,bodyStyle:"background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;"},items:[this.createRecipientPanel(),this.createSubjectPanel(),
this.createInfoPanel(),this.createReminderPanel(),this.createTaskRequestSettingPanel(),this.createAttachmentPanel(),this.createBodyPanel()]});Zarafa.task.dialogs.TaskGeneralTab.superclass.constructor.call(this,a)},createRecipientPanel:function(){return{xtype:"panel",layout:"fit",ref:"recipientPanel",items:[{xtype:"zarafa.compositefield",anchor:"100%",items:[{xtype:"button",text:_("To"),width:100},{xtype:"zarafa.recipientfield",ref:"../../recipientField",flex:1}]}]}},createSubjectPanel:function(){return{xtype:"panel",
layout:"form",items:[{xtype:"textfield",fieldLabel:_("Subject"),anchor:"100%",value:undefined,name:"subject",listeners:{change:this.onPropertyChange,scope:this}}]}},createInfoPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.task.data.TaskStatus.status},b={xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.data.ImportanceFlags.flags};return{xtype:"panel",layout:"hbox",anchor:"100%",ref:"datePanel",items:[{xtype:"zarafa.dateperiodfield",ref:"../dateField",allowBlank:true,
defaultPeriod:container.getSettingsModel().get("zarafa/v1/contexts/task/default_task_period"),width:300,listeners:{change:this.onDateRangeFieldChange,scope:this},startFieldConfig:{fieldLabel:_("Start time"),labelWidth:100},endFieldConfig:{fieldLabel:_("End time"),labelWidth:100}},{xtype:"spacer",width:10},{xtype:"panel",flex:1,border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"combo",anchor:"100%",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Status"),labelWidth:100,width:285,editable:false,
mode:"local",triggerAction:"all",autoSelect:true,store:a,displayField:"name",valueField:"value",value:a.data[0].value,name:"status",listeners:{scope:this,select:this.onStatusSelect}},{xtype:"container",layout:"hbox",anchor:"100%",border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"combo",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Priority"),width:100,editable:false,mode:"local",triggerAction:"all",autoSelect:true,store:b,displayField:"name",valueField:"value",value:b.data[1].value,
name:"importance",listeners:{select:this.onImportanceSelect,scope:this}},{xtype:"spacer",width:10},{xtype:"zarafa.spinnerfield",plugins:["zarafa.fieldlabeler","zarafa.percentspinner"],fieldLabel:_("% Complete"),labelWidth:100,name:"percent_complete",width:70,minValue:0,defaultValue:0,incrementValue:0.25,maxValue:1,listeners:{spin:this.onCompleteSpin,scope:this}}]}]}]}},createReminderPanel:function(){return{xtype:"panel",layout:"fit",ref:"reminderPanel",items:[{xtype:"zarafa.compositefield",items:[{xtype:"checkbox",
name:"reminder",width:100,boxLabel:_("Reminder")+":",handler:this.onToggleReminder,scope:this},{xtype:"zarafa.datetimefield",ref:"../../reminderDate",name:"reminder_time",width:170,timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/task/reminder_time_stepping"),listeners:{change:this.onPropertyChange,scope:this}},{xtype:"spacer",width:10},{hideLabel:true,xtype:"textfield",ref:"../../ownerField",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Owner"),labelWidth:70,readOnly:true,flex:1,
name:"owner",listeners:{change:this.onPropertyChange,scope:this}}]}]}},createTaskRequestSettingPanel:function(){return{layout:"form",ref:"taskRequestSettingPanel",items:[{xtype:"checkbox",boxLabel:_("Keep copy of task in task list"),name:"taskupdates",listeners:{change:this.onPropertyChange,scope:this}},{xtype:"checkbox",boxLabel:_("Send me a status report when task is completed"),name:"tasksoc",listeners:{change:this.onPropertyChange,scope:this}}]}},createAttachmentPanel:function(){return{xtype:"panel",
layout:"fit",items:[{xtype:"container",layout:"hbox",anchor:"100%",items:[{xtype:"button",text:_("Attachments")+":",width:100,handler:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},scope:this},{xtype:"spacer",width:5},{xtype:"zarafa.attachmentfield",ref:"../../attachmentField",flex:1,readOnly:true,hideLabel:true}]}]}},createBodyPanel:function(){return{xtype:"panel",layout:"fit",border:false,flex:1,items:[{xtype:"zarafa.editorfield",ref:"../editorField",
hideLabel:true,flex:1,useHtml:false,listeners:{change:this.onBodyChange,scope:this}}]}},updateUI:function(a,b){var c=a.get("startdate"),d=false;if(Ext.isDate(c)){c=c.clone();d=b||a.isModifiedSinceLastUpdate("startdate")}var e=a.get("duedate"),f=false;if(Ext.isDate(e)){e=e.clone();f=b||a.isModifiedSinceLastUpdate("duedate")}if(d||f)this.dateField.getValue().set(c,e);if(b===true||a.isModified("taskmode")){switch(a.get("taskmode")){case Zarafa.core.mapi.TaskMode.REQUEST:this.recipientPanel.setVisible(true);
this.taskRequestSettingPanel.setVisible(true);this.reminderPanel.setVisible(false);break;case Zarafa.core.mapi.TaskMode.NOTHING:default:this.recipientPanel.setVisible(false);this.taskRequestSettingPanel.setVisible(false);this.reminderPanel.setVisible(true);break}this.doLayout()}if(b===true||a.isModifiedSinceLastUpdate("reminder"))a.get("reminder")?this.reminderDate.enable():this.reminderDate.disable();if(b===true)(c=container.getCurrentContext())&&c.getModel()&&this.ownerField.setReadOnly(!container.getCurrentContext().getModel().getDefaultFolder().getMAPIStore().isPublicStore())},
update:function(a,b){this.record=a;this.updateUI(a,b);if(b&&a.isOpened()){this.recipientField.setRecipientStore(a.getRecipientStore());this.attachmentField.setAttachmentStore(a.getAttachmentStore());this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()))}this.getForm().loadRecord(a)},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);if(this.editorField.isHtmlEditor()){a.set("isHTML",true);a.set("html_body",this.editorField.getValue())}else{a.set("isHTML",false);a.set("body",
this.editorField.getValue())}a.set("flagdueby",a.get("reminder_time"));a.endEdit()},onPropertyChange:function(a,b){!Ext.isEmpty(a.name)&&a.validateValue(b)&&this.record.set(a.name,b)},onImportanceSelect:function(a,b){var c=b.get(a.valueField);!Ext.isEmpty(a.name)&&a.validateValue(c)&&this.record.set(a.name,c)},onBodyChange:function(a,b){this.record.beginEdit();if(a instanceof Ext.form.HtmlEditor){this.record.set("isHTML",true);this.record.set("html_body",b)}else{this.record.set("isHTML",false);this.record.set("body",
b)}this.record.endEdit()},onToggleReminder:function(a,b){this.record.beginEdit();this.record.set("reminder",b);if(b){if(!Ext.isDate(this.record.get("reminder_time"))){var c=this.record.get("duedate"),d=container.getSettingsModel().get("zarafa/v1/contexts/task/default_reminder_time");Ext.isDate(c)||(c=(new Date).add(Date.DAY,1));this.record.set("reminder_time",c.clearTime(true).add(Date.MINUTE,d))}}else this.record.set("reminder_time",null);this.record.endEdit()},onStatusSelect:function(a,b){var c=
b.get(a.valueField);this.record.beginEdit();this.record.set(a.name,c);if(c==Zarafa.core.mapi.TaskStatus.COMPLETE){this.record.set("complete",true);this.record.set("percent_complete",1);this.record.set("date_completed",new Date)}else{if(c===Zarafa.core.mapi.TaskStatus.NOT_STARTED){this.record.set("complete",false);this.record.set("percent_complete",0)}else{this.record.set("complete",false);c=this.record.get("percent_complete");if(c===0)this.record.set("percent_complete",0.25);else c===1&&this.record.set("percent_complete",
0.75)}this.record.set("date_completed",null)}this.record.endEdit()},onCompleteSpin:function(a){a=a.getValue();this.record.beginEdit();if(a>=0&&a<0.1){this.record.set("status",Zarafa.core.mapi.TaskStatus.NOT_STARTED);this.record.set("complete",false);this.record.set("percent_complete",a);this.record.set("date_completed",null)}else if(a>=0.1&&a<1){this.record.set("status",Zarafa.core.mapi.TaskStatus.IN_PROGRESS);this.record.set("complete",false);this.record.set("percent_complete",a);this.record.set("date_completed",
null)}else if(a==1){this.record.set("status",Zarafa.core.mapi.TaskStatus.COMPLETE);this.record.set("complete",true);this.record.set("percent_complete",a);this.record.set("date_completed",new Date)}this.record.endEdit()},onDateRangeFieldChange:function(a,b){this.updateStartDueDate(this.record,b)},updateStartDueDate:function(a,b){var c=b.getStartDate(),d=b.getDueDate();a.beginEdit();if(Ext.isDate(c)){a.set("startdate",c.toUTC(true));a.set("commonstart",c.clone())}else{a.set("startdate",null);a.set("commonstart",
null)}if(Ext.isDate(d)){a.set("duedate",d.toUTC(true));a.set("commonend",d.clone())}else{a.set("duedate",null);a.set("commonend",null)}a.endEdit()}});Ext.reg("zarafa.taskgeneraltab",Zarafa.task.dialogs.TaskGeneralTab);Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskDetailTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.taskdetailtab",title:_("Details"),border:false,bodyStyle:"background-color: inherit;",defaults:{bodyStyle:"background-color: inherit;",border:false,xtype:"panel"},items:[this.createDatePanel(),this.createWorkPanel(),this.createCompanyPanel(),this.createUpdateListPanel()]});Zarafa.task.dialogs.TaskDetailTab.superclass.constructor.call(this,
a)},createDatePanel:function(){return{layout:"form",items:[{xtype:"datefield",format:"d/m/Y",fieldLabel:_("Date Complete"),anchor:"35%",name:"date_completed",listeners:{change:this.onCompleteDateChange,scope:this}}]}},createWorkPanel:function(){return{layout:"column",defaults:{layout:"form",bodyStyle:"background-color: inherit",border:false,xtype:"panel"},items:[{columnWidth:0.35,defaults:{anchor:"100%"},items:[{xtype:"zarafa.durationfield",fieldLabel:_("Total Work"),id:"totalwork",name:"totalwork",
listeners:{change:this.onPropertyChange,scope:this}},{xtype:"zarafa.durationfield",fieldLabel:_("Actual Work"),name:"actualwork",listeners:{change:this.onPropertyChange,scope:this}}]},{columnWidth:0.65,style:"padding-left : 10px;",defaults:{anchor:"100%"},items:[{xtype:"textfield",fieldLabel:_("Mileage"),name:"mileage",listeners:{change:this.onPropertyChange,scope:this}},{xtype:"textfield",fieldLabel:_("Billing Information"),name:"billing_information",listeners:{change:this.onPropertyChange,scope:this}}]}]}},
createCompanyPanel:function(){return{layout:"form",items:[{xtype:"textfield",fieldLabel:_("Companies"),anchor:"100%",name:"companies",listeners:{change:this.onPropertyChange,scope:this}}]}},createUpdateListPanel:function(){return{bodyStyle:"background-color: inherit;padding: 3px 0px 3px 0px; border-style: solid none none none;",border:true,layout:"form",items:[{xtype:"textfield",fieldLabel:_("Update List"),anchor:"100%",readOnly:true,name:"updatelist"},{xtype:"button",width:150,ref:"../createUnassignedCopy",
text:_("Create Unassigned Copy"),name:"create_unassigned_copy"}]}},updateUI:function(a,b){if(b===true||a.isModified("taskstate")){switch(a.get("taskstate")){case Zarafa.core.mapi.TaskState.ACCEPT:this.createUnassignedCopy.setDisabled(false);break;default:this.createUnassignedCopy.setDisabled(true);break}this.doLayout()}},update:function(a,b){this.record=a;this.updateUI(a,b);this.getForm().loadRecord(a)},updateRecord:function(a){this.getForm().updateRecord(a)},onCompleteDateChange:function(a,b){this.record.beginEdit();
if(Ext.isDate(b)){this.record.set("status",Zarafa.core.mapi.TaskStatus.COMPLETE);this.record.set("complete",true);this.record.set("percent_complete",1);this.record.set("date_completed",b)}else{this.record.set("status",Zarafa.core.mapi.TaskStatus.NOT_STARTED);this.record.set("complete",false);this.record.set("percent_complete",0);this.record.set("date_completed",null)}this.record.endEdit()},onPropertyChange:function(a,b){!Ext.isEmpty(a.name)&&a.validateValue(b)&&this.record.set(a.name,b)}});
Ext.reg("zarafa.taskdetailtab",Zarafa.task.dialogs.TaskDetailTab);Ext.namespace("Zarafa.task.data");Zarafa.task.data.SearchFields=[{name:_("All text fields"),value:"PR_SUBJECT 0x8502101E PR_BODY 0x808F001E 0x81D9101E 0x80750040 0x80740040"},{name:_("Subject"),value:"PR_SUBJECT"},{name:_("Categories"),value:"0x8502101E"},{name:_("Body"),value:"PR_BODY"},{name:_("Owner"),value:"0x808F001E"},{name:_("Companies"),value:"0x81D9101E"},{name:_("Due Date"),value:"0x80750040"},{name:_("Start Date"),value:"0x80740040"}];
Ext.namespace("Zarafa.task");Zarafa.task.Actions={openTaskDialog:function(a,b){if(!Ext.isArray(a))if(Ext.isEmpty(a)&&Ext.isDefined(b))a=b.createRecord();if(Ext.isArray(a))a=a[0];Zarafa.common.Actions.openViewRecord(a)},openMailRespondsDialog:function(){alert("reply")}};Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsWidget=Ext.extend(Ext.Panel,{favorite:false,iconCls:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{cls:"zarafa-settings-widget",layout:"form",labelWidth:200});Zarafa.settings.ui.SettingsWidget.superclass.constructor.call(this,a)},update:Ext.emptyFn,updateSettings:Ext.emptyFn});Ext.reg("zarafa.settingswidget",Zarafa.settings.ui.SettingsWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsTreeNodeUI=Ext.extend(Ext.ux.tree.TreeGridNodeUI,{textNode:undefined,valueNode:undefined,renderElements:function(){Zarafa.settings.ui.SettingsTreeNodeUI.superclass.renderElements.apply(this,arguments);this.valueNode=this.elNode.childNodes[1].childNodes[0]},onValueChange:function(a,b){if(this.rendered)this.valueNode.innerHTML=Ext.util.Format.htmlEncode(b)}});Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsTreeNode=Ext.extend(Ext.tree.AsyncTreeNode,{constructor:function(a){this.addEvents("valuechange");Zarafa.settings.ui.SettingsTreeNode.superclass.constructor.call(this,a)},startEdit:function(){this.ownerTree.startEdit(this,1)},isEditable:function(){return this.leaf&&!Ext.isArray(this.attributes.value)},setValue:function(a){var b=this.attributes.value;this.attributes.value=a;this.rendered&&this.ui.onValueChange(this,a,b);this.fireEvent("valuechange",this,a,b)}});
Ext.tree.TreePanel.nodeTypes.setting=Zarafa.settings.ui.SettingsTreeNode;Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsFavoriteTab=Ext.extend(Ext.Container,{context:undefined,title:"",favoriteIndex:100,category:undefined,widget:undefined,iconCls:"zarafa-settings-favorite-tab-icon",constructor:function(a){a=a||{};Ext.applyIf(a,{cls:"zarafa-settings-favorite-tab",html:a.title||this.title});Zarafa.settings.ui.SettingsFavoriteTab.superclass.constructor.call(this,a)},onRender:function(){Zarafa.settings.ui.SettingsFavoriteTab.superclass.onRender.apply(this,arguments);var a=this.getEl();Ext.isEmpty(this.iconCls)||
a.addClass(this.iconCls);if(!Ext.isEmpty(this.cls)){a.addClassOnClick(this.cls+"-click");a.addClassOnFocus(this.cls+"-focus");a.addClassOnOver(this.cls+"-over")}this.mon(a,"click",this.onClick,this)},onClick:function(){if(this.context&&this.category&&this.widget){this.context.setView(this.category.id);this.context.setViewMode(this.widget.id)}}});Ext.reg("zarafa.settingsfavoritetab",Zarafa.settings.ui.SettingsFavoriteTab);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsFavoritePanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Favorite settings"),cls:"zarafa-settings-favorite-panel"});Zarafa.settings.ui.SettingsFavoritePanel.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.settings.ui.SettingsFavoritePanel.superclass.initComponent.apply(this,arguments);for(var a=0,b=this.items.length;a<b;a++){var c=this.items.get(a);c.setVisible(this.isSupportedWidget(c.widget))}},isSupportedWidget:function(a){for(var b=
["Zarafa.calendar.settings","Zarafa.contact.settings","Zarafa.mail.settings","Zarafa.note.settings","Zarafa.settings.settings","Zarafa.task.settings"],c=0,d=b.length;c<d;c++){var e=this.getNamespace(b[c]);if(e)for(var f in e)if(e[f]===a.constructor)return true}return false},getNamespace:function(a){a=a.split(".");for(var b=window,c=0,d=a.length;c<d;c++){b=b[a[c]];if(!Ext.isDefined(b))return false}return b}});Ext.reg("zarafa.settingsfavoritepanel",Zarafa.settings.ui.SettingsFavoritePanel);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsCategoryWidgetPanel=Ext.extend(Ext.Container,{context:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"card"});Zarafa.settings.ui.SettingsCategoryWidgetPanel.superclass.constructor.call(this,a);if(this.context){a=this.context.getModel();this.mon(this.context,"viewchange",this.onViewChange,this);this.mon(this.context,"viewmodechange",this.onViewModeChange,this);this.mon(a,"beforesavesettings",this.onBeforeSaveSettings,this);this.mon(a,"savesettings",this.onSaveSettings,
this);this.mon(a,"discardsettings",this.onDiscardSettings,this)}this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})},onAfterFirstLayout:function(){this.context.setView(this.get(0).id)},onViewChange:function(a,b){var c=this.getLayout();c.setActiveItem(b);c.activeItem.doLayout();c.activeItem.update(a.getModel().getEditableSettingsModel())},onViewModeChange:function(a,b){var c=this.getLayout().activeItem;if(c){var d=c.get(b);d&&c.el.scrollChildIntoView(d.el)}},onBeforeSaveSettings:function(a,
b){this.getLayout().activeItem.updateSettings(b)},onSaveSettings:function(a,b){this.getLayout().activeItem.update(b)},onDiscardSettings:function(a,b){this.getLayout().activeItem.update(b)}});Ext.reg("zarafa.settingscategorywidgetpanel",Zarafa.settings.ui.SettingsCategoryWidgetPanel);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsCategoryTab=Ext.extend(Ext.Container,{context:undefined,title:"",categoryIndex:100,category:undefined,iconCls:"zarafa-settings-category-tab-icon",activeCls:"zarafa-settings-category-tab-active",constructor:function(a){a=a||{};Ext.applyIf(a,{cls:"zarafa-settings-category-tab",html:a.title||this.title});Zarafa.settings.ui.SettingsCategoryTab.superclass.constructor.call(this,a)},isTabForId:function(a){return this.category&&this.category.getId()===a},setActive:function(a){a!==
false?this.getEl().addClass(this.activeCls):this.getEl().removeClass(this.activeCls)},onRender:function(){Zarafa.settings.ui.SettingsCategoryTab.superclass.onRender.apply(this,arguments);var a=this.getEl();Ext.isEmpty(this.iconCls)||a.addClass(this.iconCls);if(!Ext.isEmpty(this.cls)){a.addClassOnClick(this.cls+"-click");a.addClassOnFocus(this.cls+"-focus");a.addClassOnOver(this.cls+"-over")}this.mon(a,"click",this.onClick,this)},onClick:function(){this.context&&this.category&&this.context.setView(this.category.id)}});
Ext.reg("zarafa.settingscategorytab",Zarafa.settings.ui.SettingsCategoryTab);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsCategoryPanel=Ext.extend(Ext.Container,{context:undefined,activeTab:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{cls:"zarafa-settings-category-panel"});Zarafa.settings.ui.SettingsCategoryPanel.superclass.constructor.call(this,a);this.context&&this.mon(this.context,"viewchange",this.onViewChange,this)},onViewChange:function(a,b){var c=this.findBy(function(d){return d.isTabForId(b)});if(this.activeTab){this.activeTab.setActive(false);delete this.activeTab}if(!Ext.isEmpty(c)){this.activeTab=
c[0];this.activeTab.setActive(true)}}});Ext.reg("zarafa.settingscategorypanel",Zarafa.settings.ui.SettingsCategoryPanel);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsCategory=Ext.extend(Ext.Container,{items:undefined,title:"",categoryIndex:100,constructor:function(a){a=a||{};Ext.applyIf(a,{autoScroll:true});Zarafa.settings.ui.SettingsCategory.superclass.constructor.call(this,a)},update:function(){for(var a=this.findByType("zarafa.settingswidget"),b=0,c=a.length;b<c;b++)a[b].update.apply(a[b],arguments)},updateSettings:function(){for(var a=this.findByType("zarafa.settingswidget"),b=0,c=a.length;b<c;b++)a[b].updateSettings.apply(a[b],
arguments)}});Ext.reg("zarafa.settingscategory",Zarafa.settings.ui.SettingsCategory);Ext.namespace("Zarafa.settings.data");
Zarafa.settings.data.SettingsTreeLoader=Ext.extend(Ext.ux.tree.TreeGridLoader,{autoExpandLevel:0,autoExpandFilter:undefined,model:undefined,constructor:function(a){a=a||{};if(!a.directFn)a.directFn=this.directFn.createDelegate(this);Zarafa.settings.data.SettingsTreeLoader.superclass.constructor.call(this,a)},bindModel:function(a,b){if(b||this.model!==a)this.model=a},directFn:function(a,b){var c=this.model.getPath(a),d=this.model.get(c,true),e=[];for(var f in d){var g=!Ext.isObject(d[f])||Ext.isArray(d[f]),
h=(!Ext.isEmpty(c)?c+"/":"")+f,i=false;if(this.autoExpandFilter)if(this.autoExpandFilter.test(h))i=h.split("/").length<this.autoExpandLevel;e.push({nodeType:"setting",text:f,id:h,leaf:g,expanded:!g&&i,value:g?d[f]:undefined,uiProvider:Zarafa.settings.ui.SettingsTreeNodeUI})}b(e,{status:true})}});Ext.namespace("Zarafa.settings.data");
Zarafa.settings.data.SettingsDefaultValue=function(){return{getDefaultValues:function(){return{zarafa:{v1:{main:{default_context:"mail",use_canvas_rendering:true,confirm_close_dialog:true,week_start:1,working_days:[1,2,3,4,5],start_working_hour:540,end_working_hour:1020,categories:[_("Business"),_("Competition"),_("Favorites"),_("Gifts"),_("Goals/Objectives"),_("Holiday"),_("Holiday Cards"),_("Hot Contacts"),_("Ideas"),_("International"),_("Key Customer"),_("Miscellaneous"),_("Personal"),_("Phone Calls"),
_("Status"),_("Strategies"),_("Suppliers"),_("Time & Expenses"),_("VIP"),_("Waiting")],attachments:{max_attachments:undefined,max_attachment_size:undefined,max_attachment_total_size:undefined},search:{updatesearch_timeout:500},notifier:{"default":"messagebox",error:{value:"messagebox"},warning:{value:"messagebox"},info:{value:"popup",reminder:{value:"none"},newmail:{value:"popup"},sent:{value:"dropdown"},saved:{value:"dropdown"},sending:{value:"dialognotifier"},saving:{value:"dialognotifier"},unresolved_recipients:{value:"dialognotifier"},
meeting:{value:"messagebox"}}},reminder:{polling_interval:30,default_snooze_time:5}},contexts:{hierarchy:{polling_interval:300},calendar:{default_merge_state:false,default_zoom_level:30,default_appointment_period:30,default_reminder:true,default_reminder_time:15,default_allday_reminder_time:1080,freebusy_load_start_offset:-7,freebusy_load_end_offset:90,datepicker_show_busy:true},contact:{show_name_dialog:true,show_address_dialog:true},mail:{readreceipt_handling:"ask",always_request_readreceipt:false,
readflag_time:0,from_address_list:[],block_external_content:true,safe_senders_list:[],blocked_senders_list:[],outofoffice:{message:"",set:false,subject:""},signatures:{all:{},new_message:undefined,replyforward_message:undefined},dialogs:{mailcreate:{use_html_editor:true}}},task:{default_task_period:0,default_reminder:false,default_reminder_time:540,reminder_time_stepping:30},today:{num_columns:3}}}}}}}}();Ext.namespace("Zarafa.settings");
Zarafa.settings.SettingsModel=Ext.extend(Ext.util.Observable,{pathSeparator:"/",autoSave:true,defaults:undefined,settings:undefined,editing:false,modified:undefined,restored:undefined,deleted:undefined,constructor:function(a){a=a||{};this.addEvents("set","remove","exception");if(!Ext.isObject(a.defaults))a.defaults=Zarafa.settings.data.SettingsDefaultValue.getDefaultValues();Ext.apply(this,a);Zarafa.settings.SettingsModel.superclass.constructor.call(this,a);this.settings={};this.modified=[];this.restored=
[];this.deleted=[]},initialize:function(a){this.settings=Zarafa.core.Util.applyRecursive({},a,this.defaults)},beginEdit:function(){this.editing=true;this.modified=this.modified||[];this.restored=this.restored||[];this.deleted=this.deleted||[]},endEdit:function(){this.editing=false;if(!Ext.isEmpty(this.modified)||!Ext.isEmpty(this.deleted))this.afterEdit()},afterEdit:function(){Ext.isEmpty(this.restored)||this.fireEvent("set",this,this.restored);this.restored=[];if(!Ext.isEmpty(this.modified)){this.fireEvent("set",
this,this.modified);this.autoSave!==false&&this.save(Zarafa.core.Actions.set,this.modified)}this.modified=[];if(!Ext.isEmpty(this.deleted)){this.fireEvent("remove",this,this.deleted);this.autoSave!==false&&this.save(Zarafa.core.Actions["delete"],this.deleted)}this.deleted=[]},filterDuplicates:function(a,b){for(var c=0,d=b.length;c<d;c++){var e=b[c],f=a,g=-1;if(Ext.isObject(a[0]))f=Ext.pluck(a,"path");for(;(g=f.indexOf(e))>=0;){a.splice(g,1);a!==f&&f.splice(g,1)}}},removeSettings:function(a){Ext.isArray(a)||
(a=[a]);a=Zarafa.core.Util.uniqueArray(a);this.filterDuplicates(this.modified,a);this.filterDuplicates(this.restored,a);this.filterDuplicates(this.deleted,a);this.deleted=this.deleted.concat(a)},restoreSettings:function(a){Ext.isArray(a)||(a=[a]);a=Zarafa.core.Util.uniqueArray(a,"path");var b=Ext.pluck(a,"path");this.filterDuplicates(this.modified,b);this.filterDuplicates(this.restored,b);this.filterDuplicates(this.deleted,b);this.restored=this.restored.concat(a)},setSettings:function(a){Ext.isArray(a)||
(a=[a]);a=Zarafa.core.Util.uniqueArray(a,"path");var b=Ext.pluck(a,"path");this.filterDuplicates(this.modified,b);this.filterDuplicates(this.restored,b);this.filterDuplicates(this.deleted,b);this.modified=this.modified.concat(a)},save:function(a,b){container.getRequest().singleRequest(Zarafa.core.ModuleNames.getListName("settings"),a,{setting:b},new Zarafa.core.data.ProxyResponseHandler({proxy:this,action:Ext.data.Api.actions.update,options:b}))},getSettingsObject:function(a,b){for(var c=a.split(this.pathSeparator),
d=b||this.settings,e=0,f=c.length;e<f;e++){if(Ext.isEmpty(c[e]))break;d=d[c[e]];if(Ext.isEmpty(d))break}return d},removeSettingsObject:function(a,b){var c=a.lastIndexOf(this.pathSeparator),d=a.substring(0,c);c=a.substring(c+1);d=this.getSettingsObject(d,b);var e=[];if(d){var f=d[c];if(Ext.isObject(f)&&!Ext.isDate(f)&&!Ext.isArray(f))for(var g in f){var h=this.removeSettingsObject(a+this.pathSeparator+g,b);e=e.concat(h)}e.push(a);delete d[c]}return e},applySettingsObject:function(a,b,c){var d=[];if(Ext.isObject(b)){d.push({path:a});
for(var e in b)d=d.concat(this.applySettingsObject(a+this.pathSeparator+e,b[e],c))}else{e=a.lastIndexOf(this.pathSeparator);var f=a.substring(0,e);e=a.substring(e+1);c=c||this.settings;if(!Ext.isEmpty(f)){f=f.split(this.pathSeparator);for(var g="",h=0,i=f.length;h<i;h++){var j=f[h];g+=(!Ext.isEmpty(g)?this.pathSeparator:"")+j;if(Ext.isEmpty(c[j]))c[j]={};c=c[j]}}c[e]=Ext.isArray(b)||Ext.isDate(b)?b.clone():b;d.push({path:a,value:b})}return d},getPath:function(a){return Ext.isString(a)?a.replace(/^\/*|\/*$/g,
""):""},set:function(a,b){a=this.getPath(a);var c=this.removeSettingsObject(a,this.settings),d=this.applySettingsObject(a,b,this.settings);Ext.isEmpty(c)||this.removeSettings(c);Ext.isEmpty(d)||this.setSettings(d);this.editing===false&&this.afterEdit()},remove:function(a){a=this.getPath(a);a=this.removeSettingsObject(a,this.settings);Ext.isEmpty(a)||this.removeSettings(a);this.editing===false&&this.afterEdit()},restore:function(a){a=this.getPath(a);var b=this.removeSettingsObject(a,this.settings),
c=this.getSettingsObject(a,this.defaults);a=this.applySettingsObject(a,c,this.settings);Ext.isEmpty(b)||this.removeSettings(b);Ext.isEmpty(a)||this.restoreSettings(a);this.editing===false&&this.afterEdit()},get:function(a,b){a=this.getPath(a);var c=this.getSettingsObject(a,this.settings);if(Ext.isObject(c)){if(b===true)return Zarafa.core.Util.applyRecursive({},c)}else return Ext.isArray(c)||Ext.isDate(c)?c.clone():c}});Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteEditPanel=Ext.extend(Ext.FormPanel,{currentColorCss:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.noteeditpanel",layout:"fit",border:false,items:[{xtype:"textarea",ref:"noteText",layout:"fit",listeners:{change:this.onTextareaChange,scope:this}}]});Zarafa.note.ui.NoteEditPanel.superclass.constructor.call(this,a)},onTextareaChange:function(a){a=a.getValue();this.record.beginEdit();
this.record.set("body",a);this.record.generateSubject();this.record.endEdit()},getTextAreaColor:function(a){var b="";switch(parseInt(a,10)){case Zarafa.core.mapi.IconIndex.note_blue:b="stickynote_dialog_blue";break;case Zarafa.core.mapi.IconIndex.note_green:b="stickynote_dialog_green";break;case Zarafa.core.mapi.IconIndex.note_pink:b="stickynote_dialog_pink";break;case Zarafa.core.mapi.IconIndex.note_yellow:default:b="stickynote_dialog_yellow";break;case Zarafa.core.mapi.IconIndex.note_white:b="stickynote_dialog_white";
break}return b},update:function(a,b){if(a){this.record=a;if(b||a.isModifiedSinceLastUpdate("body"))this.noteText.setValue(a.get("body")||"");if(b||a.isModifiedSinceLastUpdate("icon_index")){this.noteText.removeClass(this.currentColorCss);var c=this.getTextAreaColor(a.get("icon_index"));this.currentColorCss=c;this.noteText.addClass(c)}}else{this.noteText.setValue("");this.noteText.removeClass(this.currentColorCss)}},updateRecord:function(){var a=this.noteText.getValue();this.record.beginEdit();this.record.set("body",
a);this.record.generateSubject();this.record.endEdit()}});Ext.reg("zarafa.noteeditpanel",Zarafa.note.ui.NoteEditPanel);Ext.namespace("Zarafa.note.data");Zarafa.note.data.SearchFields=[{name:_("All text fields"),value:"PR_BODY 0x8502101E"},{name:_("Categories"),value:"0x8502101E"}];Ext.namespace("Zarafa.note");Zarafa.note.Actions={openNoteDialog:function(a,b){if(Ext.isEmpty(a))a=[b.createRecord()];Ext.isArray(a)||(a=[a]);Ext.each(a,function(c){Zarafa.common.Actions.openCreateRecord(c)},this)}};Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailViewPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.mailviewpanel",border:false,cls:"zarafa-mailviewpanel",layout:"zarafa.collapsible",items:[{xtype:"zarafa.messageheader"},{xtype:"zarafa.messagebody"}]});Zarafa.mail.ui.MailViewPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.mailviewpanel",Zarafa.mail.ui.MailViewPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailViewOptionsPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailviewoptionspanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",defaults:{bodyStyle:"padding-top: 5px; padding-left: 6px; padding-right: 5px; background-color: inherit;",border:false},items:[{xtype:"zarafa.mailoptionssettingspanel"},{xtype:"zarafa.mailoptionstrackingpanel"},{xtype:"zarafa.mailoptionsmiscpanel",flex:1}]});Ext.apply(this,
a);Zarafa.mail.dialogs.MailViewOptionsPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.mailviewoptionspanel",Zarafa.mail.dialogs.MailViewOptionsPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailOptionsTrackingPanel=Ext.extend(Ext.form.FormPanel,{record:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.mailoptionstrackingpanel",title:_("Tracking Options"),layout:"form",items:[{xtype:"checkbox",hideLabel:true,ref:"readReceiptCheckbox",boxLabel:_("Request a read receipt for this message."),name:"read_receipt_requested",handler:this.onFieldToggle,scope:this}]});
Zarafa.mail.dialogs.MailOptionsTrackingPanel.superclass.constructor.call(this,a)},onFieldToggle:function(a,b){this.record.set(a.getName(),b)},update:function(a){if(this.record=a){this.getForm().loadRecord(a);!a.phantom&&!a.isUnsent()?this.readReceiptCheckbox.disable():this.readReceiptCheckbox.enable()}else this.readReceiptCheckbox.setValue(false)},updateRecord:function(a){this.getForm().updateRecord(a)}});Ext.reg("zarafa.mailoptionstrackingpanel",Zarafa.mail.dialogs.MailOptionsTrackingPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailOptionsMiscPanel=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.mailoptionsmiscpanel",title:_("Miscellaneous Options"),layout:"form",items:[{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",items:[{xtype:"button",width:100,text:_("Categories"),handler:this.onCategoriesHandler,scope:this},{xtype:"textfield",ref:"../categoriesTextField",
name:"categories",flex:1,listeners:{change:this.onPropertyChange,scope:this}}]},{xtype:"textarea",fieldLabel:_("Internet Headers"),name:"transport_message_headers",readOnly:true,anchor:"0 -32",autoScroll:true,border:false,style:"word-wrap: normal",ref:"headersTextArea"}]});Zarafa.mail.dialogs.MailOptionsMiscPanel.superclass.constructor.call(this,a)},onPropertyChange:function(a,b){Ext.isEmpty(a.name)||this.record.set(a.name,b)},onCategoriesHandler:function(){this.record&&Zarafa.common.Actions.openCategoriesDialog(this.record,
false,this.dialog.isBrowser())},update:function(a){if(this.record=a)this.getForm().loadRecord(a);else{this.categoriesTextField.setValue("");this.headersTextArea.setValue("")}},updateRecord:function(a){this.getForm().updateRecord(a)}});Ext.reg("zarafa.mailoptionsmiscpanel",Zarafa.mail.dialogs.MailOptionsMiscPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailFlagsPanel=Ext.extend(Ext.Panel,{disableFlagColor:false,disableCompleted:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");if(!Ext.isBoolean(a.disableFlagColor))a.disableFlagColor=this.disableFlagColor;if(!Ext.isBoolean(a.disableFlagColor))a.disableCompleted=this.disableCompleted;a=Ext.applyIf(a,{xtype:"zarafa.mailflagspanel",layout:"form",border:false,bodyStyle:"padding: 5px; background-color: inherit;",
items:[this.createFlagColorPanel(a.disableFlagColor),this.createFlagExpirationPanel(),this.createFlagCompletePanel(a.disableCompleted)]});Zarafa.mail.dialogs.MailFlagsPanel.superclass.constructor.call(this,a)},createFlagColorPanel:function(a){var b={xtype:"jsonstore",fields:["name","flagColor"],data:[].concat(Zarafa.mail.data.MailFlags.state[1],Zarafa.mail.data.MailFlags.colors)};return{xtype:"combo",ref:"flagColorCombo",fieldLabel:_("Color of Flag"),anchor:"100%",store:b,mode:"local",triggerAction:"all",
displayField:"name",valueField:"flagColor",lazyInit:false,forceSelection:true,editable:false,disabled:a,listeners:{select:this.onColorSelect,scope:this}}},createFlagExpirationPanel:function(){return{xtype:"zarafa.datetimefield",anchor:"100%",ref:"datetimeField",fieldLabel:_("Enddate"),listeners:{change:this.onDateChange,scope:this}}},createFlagCompletePanel:function(a){return{xtype:"checkbox",ref:"completeCheckbox",fieldLabel:_("Complete"),handler:this.onToggleComplete,scope:this,disabled:a}},update:function(a){if(this.record=
a){a=this.record.get("flag_status")==Zarafa.core.mapi.FlagStatus.completed;var b=this.record.get("flag_icon");if(Ext.isEmpty(b))b=Zarafa.core.mapi.FlagIcon.clear;this.flagColorCombo.setValue(b);b="flag_due_by";if(a)b="flag_complete_time";b=this.record.get(b);Ext.isDate(b)||(b=new Date);this.datetimeField.setValue(b);this.completeCheckbox.setValue(a)}},updateRecord:function(a){var b=this.flagColorCombo.getValue(),c=this.completeCheckbox.getValue();a.beginEdit();a.set("flag_icon",b);var d=this.datetimeField.getValue();
c?a.set("flag_complete_time",d):a.set("flag_due_by",d);if(c)a.set("flag_status",Zarafa.core.mapi.FlagStatus.completed);else b==Zarafa.core.mapi.FlagIcon.clear?a.set("flag_status",Zarafa.core.mapi.FlagStatus.cleared):a.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged);a.endEdit()},onDateChange:function(a,b){this.completeCheckbox.getValue()?this.record.set("flag_complete_time",b):this.record.set("flag_due_by",b)},onColorSelect:function(){var a=this.flagColorCombo.getValue();this.record.set("flag_icon",
a);a==Zarafa.core.mapi.FlagIcon.clear?this.record.set("flag_status",Zarafa.core.mapi.FlagStatus.cleared):this.record.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged)},onToggleComplete:function(a,b){var c=this.datetimeField.getValue(),d=this.flagColorCombo.getValue();this.flagColorCombo.setDisabled(b);if(b){this.record.set("flag_status",Zarafa.core.mapi.FlagStatus.completed);this.record.set("flag_complete_time",c);this.record.set("flag_due_by","");this.record.set("flag_icon",undefined)}else if(d==
Zarafa.core.mapi.FlagIcon.clear){this.record.set("flag_status",Zarafa.core.mapi.FlagStatus.cleared);this.record.set("flag_due_by",c);this.record.set("flag_complete_time","");this.record.set("flag_icon",undefined)}else{this.record.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged);this.record.set("flag_due_by",c);this.record.set("flag_complete_time","")}}});Ext.reg("zarafa.mailflagspanel",Zarafa.mail.dialogs.MailFlagsPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreatePanel=Ext.extend(Ext.form.FormPanel,{model:undefined,use_html_editor:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.mailcreatepanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit; padding: 5px;",defaults:{border:false,labelLength:100,style:"padding-bottom: 2px"},items:[this.initMessageFormPanel(a)]});Zarafa.mail.dialogs.MailCreatePanel.superclass.constructor.call(this,
a)},onRender:function(){Zarafa.mail.dialogs.MailCreatePanel.superclass.onRender.apply(this,arguments);if(this.dialog){this.mon(this.dialog,"bcctoggle",this.onDialogBccToggle,this);this.mon(this.dialog,"fromtoggle",this.onDialogFromToggle,this)}},initMessageFormPanel:function(){var a=[];a.push({xtype:"zarafa.compositefield",hideLabel:true,ref:"fromField",anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,text:_("From")+":",handler:this.onSelectUser,scope:this},{xtype:"zarafa.addressbookboxfield",
ref:"../fromRecipientField",boxType:"zarafa.recipientbox",boxStore:new Zarafa.core.data.IPMRecipientStore({listeners:{add:this.onFromRecipientChanged,resolved:this.onFromRecipientChanged,remove:this.onFromRecipientChanged,scope:this}}),flex:1,boxLimit:1}]},{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,text:_("To")+":",handler:function(){Zarafa.mail.Actions.openRecipientSelectionDialog(this.record,Zarafa.core.mapi.RecipientType.MAPI_TO,
this.dialog.isBrowser())},scope:this},{xtype:"zarafa.recipientfield",ref:"../toRecipientField",flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO}]},{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,text:_("Cc")+":",handler:function(){Zarafa.mail.Actions.openRecipientSelectionDialog(this.record,Zarafa.core.mapi.RecipientType.MAPI_CC,this.dialog.isBrowser())},scope:this},
{xtype:"zarafa.recipientfield",ref:"../ccRecipientField",flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC}]},{xtype:"zarafa.compositefield",ref:"bccField",hideLabel:true,anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,text:_("Bcc")+":",handler:function(){Zarafa.mail.Actions.openRecipientSelectionDialog(this.record,Zarafa.core.mapi.RecipientType.MAPI_BCC,this.dialog.isBrowser())},scope:this},{xtype:"zarafa.recipientfield",
ref:"../bccRecipientField",flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC}]},{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",items:[{xtype:"label",width:100,text:_("Subject")+":",name:"label_subject"},{xtype:"field",flex:1,name:"subject",value:undefined,listeners:{change:this.onChange,scope:this}}]},{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,
border:false,text:_("Attachments")+":",name:"label_attachment",handler:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},scope:this},{xtype:"zarafa.attachmentfield",flex:1,name:"attachment",ref:"../attachmentField",readOnly:true,hideLabel:true,value:undefined}]},{xtype:"zarafa.editorfield",ref:"editorField",hideLabel:true,flex:1,useHtml:false,defaultValue:"",listeners:{change:this.onBodyChange,scope:this}});return a},update:function(a,b){this.record=a;this.getForm().loadRecord(a);
if(b&&a.isOpened()){this.toRecipientField.setRecipientStore(a.getRecipientStore());this.ccRecipientField.setRecipientStore(a.getRecipientStore());this.bccRecipientField.setRecipientStore(a.getRecipientStore());this.attachmentField.setAttachmentStore(a.getAttachmentStore());this.editorField.setHtmlEditor(this.use_html_editor,false);this.editorField.bindRecord(a);this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()))}},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);
if(this.editorField.isHtmlEditor()){a.set("isHTML",true);a.set("html_body",this.editorField.getValue())}else{a.set("isHTML",false);a.set("body",this.editorField.getValue())}a.endEdit()},onChange:function(a,b){this.record.set(a.name,b)},onBodyChange:function(a,b){this.record.beginEdit();if(a instanceof Ext.form.HtmlEditor){this.record.set("isHTML",true);this.record.set("html_body",b)}else{this.record.set("isHTML",false);this.record.set("body",b)}this.record.endEdit()},onDialogBccToggle:function(a,
b){this.bccField.setVisible(b);this.doLayout()},onDialogFromToggle:function(a,b){this.fromField.setVisible(b);this.doLayout()},setSignatureInEditor:function(a){this.editorField.insertAtCursor(this.model.getSignatureData(this.editorField.isHtmlEditor(),a))},onFromRecipientChanged:function(){var a=this.fromRecipientField.getBoxStore(),b=this.record;b.beginEdit();if(a=a.getAt(0)){b.set("sent_representing_name",a.get("display_name"));b.set("sent_representing_email_address",a.get("email_address"));b.set("sent_representing_address_type",
a.get("address_type"));b.set("sent_representing_entryid",a.get("entryid"));b.set("sent_representing_search_key",a.get("search_key"))}else{b.set("sent_representing_name","");b.set("sent_representing_email_address","");b.set("sent_representing_address_type","");b.set("sent_representing_entryid","");b.set("sent_representing_search_key","")}b.endEdit()},onSelectUser:function(){Zarafa.common.Actions.openABUserSelectionDialog(this.abCallBack.createDelegate(this),{hide_contacts:true},{hide_users:["contact",
"system","non_security","room","equipment","non_active"],hide_groups:["non_security"],hide_companies:true},this.dialog.isBrowser())},abCallBack:function(a){var b=this.fromRecipientField.getBoxStore();b.removeAll();b.add(a.convertToRecipient())}});Ext.reg("zarafa.mailcreatepanel",Zarafa.mail.dialogs.MailCreatePanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateOptionsPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailcreateoptionspanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",defaults:{bodyStyle:"padding-top: 5px; padding-left: 6px; padding-right: 5px; background-color: inherit;",border:false},items:[{xtype:"zarafa.mailoptionssettingspanel"},{xtype:"zarafa.mailoptionstrackingpanel"}]});Ext.apply(this,a);Zarafa.mail.dialogs.MailCreateOptionsPanel.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.mailcreateoptionspanel",Zarafa.mail.dialogs.MailCreateOptionsPanel);Ext.namespace("Zarafa.mail.data");
Zarafa.mail.data.Templates={plaintextQuotedTemplate:"\n\n{signatureData} \n \n-----"+_("Original message")+'-----\n<tpl if="!Ext.isEmpty(values.sent_representing_name)">> '+_("From")+':{sent_representing_name:htmlEncode} <tpl if="!Ext.isEmpty(values.sent_representing_email_address)"><{sent_representing_email_address:htmlEncode}></tpl>\n</tpl><tpl if="Ext.isDate(values.message_delivery_time)">> '+_("Sent")+': {message_delivery_time:date("'+_("l jS F Y G:i")+'")}\n</tpl><tpl if="!Ext.isEmpty(values.display_to)">> '+
_("To")+': {display_to}\n</tpl><tpl if="!Ext.isEmpty(values.display_cc)">> '+_("Cc")+": {display_cc}\n</tpl>> "+_("Subject")+": {subject:htmlEncode}\n> \n{body}",htmlQuotedTemplate:"<br /><br />{signatureData}<blockquote style='border-left: 2px solid #325FBA; padding-left: 5px; margin-left: 5px; margin-right: 0px;'>-----"+_("Original message")+'-----<br /><tpl if="!Ext.isEmpty(values.sent_representing_name)"><strong>'+_("From")+':</strong> {sent_representing_name:htmlEncode}&nbsp;<tpl if="!Ext.isEmpty(values.sent_representing_email_address)">&lt;{sent_representing_email_address:htmlEncode}&gt;</tpl><br /></tpl><tpl if="Ext.isDate(values.message_delivery_time)"><strong>'+
_("Sent")+':</strong> {message_delivery_time:date("'+_("l jS F Y G:i")+'")}<br /></tpl><tpl if="!Ext.isEmpty(values.display_to)"><strong>'+_("To")+':</strong> {display_to:htmlEncode}<br /></tpl><tpl if="!Ext.isEmpty(values.display_cc)"><strong>'+_("Cc")+":</strong> {display_cc:htmlEncode}<br /></tpl><strong>"+_("Subject")+":</strong> {subject:htmlEncode}<br /><br />{body}</blockquote>"};Ext.namespace("Zarafa.mail.data");
Zarafa.mail.data.SearchFields=[{name:_("All text fields"),value:"PR_SUBJECT PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS PR_BODY PR_DISPLAY_TO PR_DISPLAY_CC"},{name:_("Subject"),value:"PR_SUBJECT"},{name:_("Sender"),value:"PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS"},{name:_("Body"),value:"PR_BODY"},{name:_("Subject or Sender"),value:"PR_SUBJECT PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS"},
{name:_("To or cc"),value:"PR_DISPLAY_TO PR_DISPLAY_CC"}];Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.ActionTypes={reply:"reply",replyall:"replyall",forward:"forward"};Ext.namespace("Zarafa.mail");
Zarafa.mail.Actions={openMailDialog:function(a,b,c){Ext.each(a,function(d){d.isUnsent()?Zarafa.common.Actions.openCreateRecord(d,{browser:c,model:b.getModel()}):Zarafa.common.Actions.openViewRecord(d,{context:b,browser:c})})},openMailCreateDialog:function(a,b){var c=a.createRecord();Zarafa.common.Actions.openCreateRecord(c,{browser:b,model:a})},openMailRespondsDialog:function(a,b,c,d){Ext.isArray(a)||(a=[a]);for(var e=0;e<a.length;e++){var f=a[e];if(f.isOpened()){f=b.createResponseRecord(f,c);Zarafa.common.Actions.openCreateRecord(f,
{browser:d,model:b})}else{var g=function(h,i){if(this===i){var j=b.createResponseRecord(i,c);Zarafa.common.Actions.openCreateRecord(j,{browser:d,model:b});h.un("open",g,i)}};f.getStore().on("open",g,f);f.open()}}},openMailOptionsDialog:function(a,b,c){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["mail.dialog.options"],a,{autoSave:Ext.isDefined(b)?b:true,browser:c,modal:true})},openMailFlagsDialog:function(a,b,c){if(Ext.isArray(a)&&
!Ext.isEmpty(a))a=a[0];b=Ext.apply({},{autoSave:Ext.isDefined(b)?b:true,browser:c,modal:true});b.autoSave||Ext.apply(b,{disableFlagColor:true,disableCompleted:true});Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["mail.dialog.flags"],a,b)},openRecipientSelectionDialog:function(a,b,c){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.recipientselection"],a,{recipientButtonsCfg:[{text:_("To")+
":",type:Zarafa.core.mapi.RecipientType.MAPI_TO},{text:_("CC")+":",type:Zarafa.core.mapi.RecipientType.MAPI_CC},{text:_("BCC")+":",type:Zarafa.core.mapi.RecipientType.MAPI_BCC}],defaultRecipientType:b,listRestriction:{hide_distlist:true},browser:c,modal:true})}};Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.TreeSorter=Ext.extend(Ext.tree.TreeSorter,{folderProperty:"display_name",storeProperty:"mailbox_owner_name",constructor:function(){Zarafa.hierarchy.ui.TreeSorter.superclass.constructor.apply(this,arguments);this.sortFn=this.hierarchySort.createDelegate(this)},hierarchySort:function(a,b){var c=a.attributes.folder,d=b.attributes.folder,e=c.getMAPIStore(),f=d.getMAPIStore(),g=this.dir&&this.dir.toLowerCase()=="desc",h=this.caseSensitive===true;if(c.isIPMSubTree()){if(e.isDefaultStore())return g?
+1:-1;if(e.isPublicStore())return g?-1:+1}if(d.isIPMSubTree()){if(f.isDefaultStore())return g?-1:+1;if(f.isPublicStore())return g?+1:-1}if(c.isIPMSubTree()&&d.isIPMSubTree()){e=this.compareRecordProp(e,f,this.storeProperty,g,h);if(e!==0)return e}return this.compareRecordProp(c,d,this.folderProperty,g,h)},compareRecordProp:function(a,b,c,d,e){a=e?a.get(c):a.get(c).toLowerCase();b=e?b.get(c):b.get(c).toLowerCase();return a<b?d?+1:-1:a>b?d?-1:+1:0}});Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.TreeEditor=Ext.extend(Ext.tree.TreeEditor,{enableEdit:undefined,constructor:function(a,b,c){b=b||{};c=c||{};b=Ext.applyIf(b,{ignoreNoChange:true});c=Ext.applyIf(c,{cancelOnEsc:true,completeOnEnter:true});Zarafa.hierarchy.ui.TreeEditor.superclass.constructor.call(this,a,b,c);this.mon(this,"beforenodeclick",this.onBeforeNodeClick,this);this.mon(this,"beforestartedit",this.onBeforeStartEdit,this);this.mon(this,"canceledit",this.onEditCancel,this);this.mon(this,"complete",this.onEditComplete,
this)},onBeforeNodeClick:function(){return true},onBeforeStartEdit:function(){if(!this.enableEdit)return false},onEditCancel:function(){this.enableEdit=false},onEditComplete:function(a,b){this.enableEdit=false;var c=a.editNode.getFolder();c.set("display_name",b);c.save()},startEditingNode:function(a){this.enableEdit=true;this.triggerEdit(a)}});Ext.reg("zarafa.foldertreeeditor",Zarafa.hierarchy.ui.TreeEditor);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.Tree=Ext.extend(Ext.tree.TreePanel,{model:undefined,store:undefined,IPMFilter:undefined,nodeConfig:undefined,treeEditor:undefined,loadMask:false,treeSorter:false,ddAutoScrollContainer:false,ddScrollContainer:undefined,defaultOpen:false,constructor:function(a){a=a||{};if(!a.store)a.store=container.getHierarchyStore();Ext.applyIf(a,{rootVisible:false,autoScroll:true,animate:false,border:false,loader:new Zarafa.hierarchy.data.HierarchyTreeLoader({tree:this,store:a.store,nodeConfig:a.nodeConfig}),
root:new Ext.tree.AsyncTreeNode({text:"root",leaf:false,expanded:true,uiProvider:Ext.tree.RootTreeNodeUI})});Zarafa.hierarchy.ui.Tree.superclass.constructor.call(this,a);if(this.treeSorter&&!(this.treeSorter instanceof Ext.tree.TreeSorter))this.treeSorter=new Zarafa.hierarchy.ui.TreeSorter(this,Ext.apply({},this.treeSorter))},initComponent:function(){Zarafa.hierarchy.ui.Tree.superclass.initComponent.apply(this,arguments);if(this.enableDD===true)if(this.ddAutoScrollContainer===true)this.mon(this,"load",
this.autodetectScrollContainer,this);else if(this.ddScrollContainer){this.ddScrollContainer=Ext.Element(this.ddScrollContainer)?this.ddScrollContainer:this.ddScrollContainer.el;this.registerScrollContainer(this.ddScrollContainer)}this.loadMask&&this.mon(this,"render",this.createLoadMask,this)},autodetectScrollContainer:function(){for(var a=this.ownerCt;a&&a.autoScroll!==true;)a=a.ownerCt;if(a)this.registerScrollContainer(a.body||a.el)},registerScrollContainer:function(a){a.ddScrollConfig={vthresh:50,
hthresh:-1,frequency:100,increment:25};Ext.dd.ScrollManager.register(a)},createLoadMask:function(){this.loadMask=new Zarafa.common.ui.LoadMask(this.getEl(),Ext.apply({store:this.store},this.loadMask))},hasFilter:function(){return!Ext.isEmpty(this.IPMFilter)},nodeFilter:function(a){if(Ext.isDefined(this.IPMFilter))return a.isContainerClass(this.IPMFilter,true)&&!a.isInDeletedItems();return true},getAllNodes:function(){return this.getRootNode().childNodes},selectFolderInTree:function(a){(a=this.ensureFolderVisible(a))&&
this.getSelectionModel().select(a)},ensureFolderVisible:function(a){var b=a.get("entryid"),c=this.getNodeById(b);if(!c){a=a.getParentFolder();if(!a)return false;a=this.ensureFolderVisible(a);if(!a)return false;a.expand();c=this.getNodeById(b)}if(c){c.ensureVisible();c=this.getNodeById(b);c.update(true);return c}return false},isFolderOpened:function(a){return a.isIPMSubTree()||this.defaultOpen},updateAll:function(){for(var a=this.getAllNodes(),b=0;b<a.length;b++)a[b].update(true)},beforeDestroy:function(){if(this.rendered&&
this.loadMask){Ext.destroy(this.loadMask);this.loadMask=false}if(this.treeSorter){Ext.destroy(this.treeSorter);this.treeSorter=false}Ext.tree.TreePanel.superclass.beforeDestroy.call(this)}});Ext.reg("zarafa.hierarchytree",Zarafa.hierarchy.ui.Tree);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyTreeDropZone=Ext.extend(Ext.tree.TreeDropZone,{dropAllowedAdd:"x-dd-drop-ok-add",onNodeEnter:function(a,b){this.onDragKeyDown=Zarafa.hierarchy.ui.HierarchyTreeDropZone.prototype.onDragKeyDown.createDelegate({dd:b,dz:this});this.onDragKeyUp=Zarafa.hierarchy.ui.HierarchyTreeDropZone.prototype.onDragKeyUp.createDelegate({dd:b,dz:this});document.addEventListener("keydown",this.onDragKeyDown);document.addEventListener("keyup",this.onDragKeyUp);return Zarafa.hierarchy.ui.HierarchyTreeDropZone.superclass.onNodeEnter.apply(this,
arguments)},onContainerOver:function(a,b){var c=Zarafa.hierarchy.ui.HierarchyTreeDropZone.superclass.onContainerOver.apply(this,arguments);if(c===this.dropAllowed&&b.ctrlKey)c=this.dropAllowedAdd;return c},onNodeOver:function(a,b,c){var d=Zarafa.hierarchy.ui.HierarchyTreeDropZone.superclass.onNodeOver.apply(this,arguments);if(c.ctrlKey)if(d==="x-tree-drop-ok-append")d="x-tree-drop-ok-append-add";else if(d==="x-tree-drop-ok-above")d="x-tree-drop-ok-above-add";else if(d==="x-tree-drop-ok-between")d=
"x-tree-drop-ok-between-add";else if(d==="x-tree-drop-ok-below")d="x-tree-drop-ok-below-add";return d},onNodeOut:function(){document.removeEventListener("keydown",this.onDragKeyDown);document.removeEventListener("keyup",this.onDragKeyUp);return Zarafa.hierarchy.ui.HierarchyTreeDropZone.superclass.onNodeOut.apply(this,arguments)},onDragKeyDown:function(a){if(a.ctrlKey||a.keyCode===Ext.EventObject.CONTROL)if(this.dd.proxy.dropStatus===this.dz.dropAllowed)this.dd.proxy.setStatus(this.dz.dropAllowedAdd);
else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-append")this.dd.proxy.setStatus("x-tree-drop-ok-append-add");else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-above")this.dd.proxy.setStatus("x-tree-drop-ok-above-add");else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-between")this.dd.proxy.setStatus("x-tree-drop-ok-between-add");else this.dd.proxy.dropStatus==="x-tree-drop-ok-below"&&this.dd.proxy.setStatus("x-tree-drop-ok-below-add")},onDragKeyUp:function(a){if(a.ctrlKey||a.keyCode===Ext.EventObject.CONTROL)if(this.dd.proxy.dropStatus===
this.dz.dropAllowedAdd)this.dd.proxy.setStatus(this.dz.dropAllowed);else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-append-add")this.dd.proxy.setStatus("x-tree-drop-ok-append");else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-above-add")this.dd.proxy.setStatus("x-tree-drop-ok-above");else if(this.dd.proxy.dropStatus==="x-tree-drop-ok-between-add")this.dd.proxy.setStatus("x-tree-drop-ok-between");else this.dd.proxy.dropStatus==="x-tree-drop-ok-below-add"&&this.dd.proxy.setStatus("x-tree-drop-ok-below")}});
Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyTreeBottomBar=Ext.extend(Ext.Container,{defaultSelectedSharedFolderType:null,buttonText:_("Open Shared Folders"),constructor:function(a){a=a||{};var b=Ext.util.Format.htmlEncode(a.buttonText||this.buttonText);Ext.applyIf(a,{cls:"zarafa-hierarchy-treepanel-bottombar",layout:"fit",defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.ALL,items:[{cls:"zarafa-hierarchy-treepanel-footer-opensharedfolder",xtype:"button",text:b+"...",handler:this.openSharedFolder.createDelegate(this)}]});
Zarafa.hierarchy.ui.HierarchyTreeBottomBar.superclass.constructor.call(this,a)},openSharedFolder:function(){Zarafa.hierarchy.Actions.openSharedFolderDialog(this.defaultSelectedSharedFolderType)}});Ext.reg("zarafa.hierarchytreebottombar",Zarafa.hierarchy.ui.HierarchyTreeBottomBar);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.FolderNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{renderElements:function(a,b,c,d){this.indentMarkup=a.parentNode?a.parentNode.ui.getChildIndent():"";var e=Ext.isBoolean(b.checked),f,g='<li class="x-tree-node"><div ext:tree-node-id="'+a.id+'" class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on"><span class="x-tree-node-indent">'+this.indentMarkup+'</span><img src="'+this.emptyIcon+'" class="x-tree-ec-icon x-tree-elbow" /><img src="'+(b.icon||this.emptyIcon)+'" class="x-tree-node-icon" unselectable="on" />'+
(e?'<input class="x-tree-node-cb" type="checkbox" '+(b.checked?'checked="checked" />':"/>"):"")+'<a hidefocus="on" class="x-tree-node-anchor" href="'+(b.href?b.href:Ext.isGecko?"":"#")+'" tabIndex="1" '+(b.hrefTarget?' target="'+b.hrefTarget+'"':"")+'><span unselectable="on">'+(a.tpl?a.tpl.apply(b):a.text)+'</span><span class="zarafa-hierarchy-node-counter" unselectable="on"></span></a></div><ul class="x-tree-node-ct" style="display:none;"></ul></li>';this.wrap=d!==true&&a.nextSibling&&(f=a.nextSibling.ui.getEl())?
Ext.DomHelper.insertHtml("beforeBegin",f,g):Ext.DomHelper.insertHtml("beforeEnd",c,g);this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];c=this.elNode.childNodes;this.indentNode=c[0];this.ecNode=c[1];this.iconNode=c[2];d=3;if(e){this.checkbox=c[3];this.checkbox.defaultChecked=this.checkbox.checked;d++}this.anchor=c[d];this.textNode=c[d].firstChild;this.counterNode=c[d].firstChild.nextSibling;e=Ext.get(this.elNode);c=Ext.get(this.iconNode);d=Ext.get(this.wrap);Ext.isEmpty(b.cls)||
e.addClass(b.cls);b.icon&&c.addClass("x-tree-node-inline-icon");b.iconCls&&c.addClass(b.iconCls);Ext.isEmpty(b.containerCls)||d.addClass(b.containerCls);this.updateCounter(a)},updateCounter:function(a){a=a.getFolder();var b=Ext.get(this.elNode),c=Ext.get(this.counterNode);if(Ext.isDefined(a))switch(a.getCounterType()){case Zarafa.hierarchy.data.CounterTypes.TOTAL:b.replaceClass("zarafa-hierarchy-node-unread-count","zarafa-hierarchy-node-total-count");b.addClass("zarafa-hierarchy-node-withcounter");
c.update("("+a.getCounterValue()+")");c.repaint();break;case Zarafa.hierarchy.data.CounterTypes.UNREAD:b.replaceClass("zarafa-hierarchy-node-total-count","zarafa-hierarchy-node-unread-count");b.addClass("zarafa-hierarchy-node-withcounter");c.update("("+a.getCounterValue()+")");c.repaint();break;case Zarafa.hierarchy.data.CounterTypes.NONE:default:b.removeClass(["zarafa-hierarchy-node-total-count","zarafa-hierarchy-node-unread-count"]);b.removeClass("zarafa-hierarchy-node-withcounter");c.update("");
c.repaint();break}},onTextChange:function(a,b){if(this.rendered)this.textNode.innerHTML=a.tpl?a.tpl.apply(a.attributes):b},onIconChange:function(a,b,c){if(this.rendered){a=Ext.get(this.iconNode);Ext.isEmpty(c)?a.addClass(b):a.replaceClass(c,b)}},onContainerClsChange:function(a,b,c){if(this.rendered){a=Ext.get(this.wrap);Ext.isEmpty(c)?a.addClass(b):a.replaceClass(c,b)}},getDDHandles:function(){return[this.iconNode,this.textNode,this.counterNode,this.elNode]}});Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.FolderNode=Ext.extend(Ext.tree.AsyncTreeNode,{folder:undefined,tpl:"{text:htmlEncode}",constructor:function(a){a=a||{};var b=a.folder;Ext.isDefined(b)&&Ext.applyIf(a,{id:b.get("entryid")});Ext.applyIf(a,{containerCls:"zarafa-tree-container",cls:"zarafa-tree-node"});Zarafa.hierarchy.ui.FolderNode.superclass.constructor.call(this,a);if(Ext.isString(this.tpl))this.tpl=new Ext.XTemplate(this.tpl,{compiled:true});b&&this.updateUI(b)},getFolder:function(){return this.attributes.folder},
setChecked:function(a){this.rendered&&this.getUI().toggleCheck(a)},isChecked:function(){var a=this.getUI();return a.checkbox&&a.checkbox.checked},updateUI:function(a){this.attributes.folder=a;this.updateCounterNode(a);this.setText(this.getTextFromFolder(a));this.setIcon(this.getIconFromFolder(a));this.setContainerCls(this.attributes.containerCls);a.get("has_subfolder")||this.removeAll(true)},setIcon:function(a){var b=this.iconCls;this.iconCls=this.attributes.iconCls=a;this.rendered&&this.getUI().onIconChange(this,
a,b)},setContainerCls:function(a){var b=this.containerCls;this.containerCls=this.attributes.containerCls=a;this.rendered&&this.getUI().onContainerClsChange(this,a,b)},updateCounterNode:function(){this.rendered===true&&this.getUI().updateCounter(this)},getIconFromFolder:function(a){return Zarafa.common.ui.IconClass.getIconClass(a)},getTextFromFolder:function(a){return a.getDisplayName()},update:function(a){var b,c="";if(this.ownerTree&&this.ownerTree.model)b=this.ownerTree.model.getFolder(this.getFolder().get("entryid"));
if(Ext.isDefined(b)){this.setChecked(true);if(b=b.getColorScheme())c=b.header}else{this.setChecked(false);c=""}b=this.getUI();if(b.elNode)b.elNode.style.backgroundColor=c;if(a){c=0;for(b=this.childNodes.length;c<b;c++)this.childNodes[c].update(a)}}});Ext.tree.TreePanel.nodeTypes.folder=Zarafa.hierarchy.ui.FolderNode;Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderSizePanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.foldersizepanel",layout:{type:"vbox",align:"stretch"},border:false,items:[this.createFolderSizePanel(),this.createSubfolderSizePanel()]});Zarafa.hierarchy.dialogs.FolderSizePanel.superclass.constructor.call(this,a)},createFolderSizePanel:function(){return{xtype:"form",ref:"folderPanel",autoHeight:true,
border:false,labelWidth:200,items:[{xtype:"zarafa.displayfield",fieldLabel:_("Folder Name"),htmlEncode:true,name:"display_name"},{xtype:"zarafa.displayfield",fieldLabel:_("Size (without subfolders)"),renderer:Ext.util.Format.fileSize,name:"message_size"},{xtype:"zarafa.displayfield",fieldLabel:_("Total size (including subfolders)"),renderer:Ext.util.Format.fileSize,name:"total_message_size"}]}},createSubfolderSizePanel:function(){return{xtype:"grid",ref:"subfolderView",flex:1,store:new Zarafa.hierarchy.data.IPFSubStore,
enableColumnHide:false,border:true,loadMask:{msg:_("Loading subfolder sizes")+"..."},viewConfig:{forceFit:true,deferEmptyText:false,emptyText:'<div class="emptytext">'+_("No subfolders present")+"</div>"},sm:new Ext.grid.RowSelectionModel({singleSelect:true}),columns:[{header:_("Subfolder"),sortable:true,dataIndex:"folder_pathname",renderer:Ext.util.Format.htmlEncode,tooltip:_("Sort by: Name of the subfolder")},{header:_("Size"),sortable:true,dataIndex:"message_size",renderer:Ext.util.Format.fileSize,
width:50,tooltip:_("Sort by: Size (without subfolders)")},{header:_("Total size"),sortable:true,dataIndex:"total_message_size",renderer:Ext.util.Format.fileSize,width:50,tooltip:_("Sort by: Total size (including subfolders)")}]}},update:function(a,b){if(b)if(this.record!==a){this.record=a;this.subfolderView.loadMask.show();this.mon(a.getStore(),"open",this.onOpenFolderSize,this);a.open({actionType:"foldersize",forceLoad:true})}},onOpenFolderSize:function(a,b){if(this.record===b){this.folderPanel.getForm().loadRecord(b);
var c=b.getSubStore("folders"),d=this.subfolderView.getColumnModel();this.subfolderView.reconfigure(c,d);c.sort(d.getDataIndex(0),"ASC");this.mun(a,"open",this.onOpenFolderSize,this);this.subfolderView.loadMask.hide()}}});Ext.reg("zarafa.foldersizepanel",Zarafa.hierarchy.dialogs.FolderSizePanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesPermissionTab=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.folderpropertiespermissiontab",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",items:[this.createUserListPanel(),this.createPermissionPanel()]});Zarafa.hierarchy.dialogs.FolderPropertiesPermissionTab.superclass.constructor.call(this,a);
this.on("activate",this.onActivate,this)},createUserListPanel:function(){return{xtype:"panel",layout:"fit",flex:1,items:[{xtype:"grid",ref:"../userView",store:new Zarafa.hierarchy.data.MAPIFolderPermissionsSubStore,hideHeaders:true,enableHdMenu:false,border:true,viewConfig:{forceFit:true,deferEmptyText:false,emptyText:'<div class="emptytext">'+_("No permissions granted")+"</div>"},sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:this.onUserSelectionChange,scope:this}}),
columns:[{dataIndex:"display_name",header:"&#160;",renderer:Ext.util.Format.htmlEncode}],listeners:{viewready:this.onViewReady,scope:this}}],buttons:[{text:_("Add"),ref:"../../addUserBtn",handler:this.onUserAdd,scope:this},{text:_("Remove"),ref:"../../removeUserBtn",handler:this.onUserRemove,scope:this}]}},createPermissionPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.hierarchy.data.PermissionProfiles};return{xtype:"form",layout:"fit",autoHeight:true,border:false,ref:"permissionsForm",
items:[{xtype:"fieldset",title:_("Permissions"),autoHeight:true,autoWidth:true,cls:"zarafa-fieldset",items:[{xtype:"combo",ref:"../../profileCombo",width:122,fieldLabel:_("Profile"),store:a,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,defaultValue:Zarafa.core.mapi.Rights.RIGHTS_NO_RIGHTS,listeners:{select:this.onProfileSelect,scope:this}},{xtype:"container",layout:"column",items:[{xtype:"checkboxgroup",columnWidth:0.5,
style:"margin-right: 2px;",hideLabel:true,columns:1,items:[{xtype:"checkbox",boxLabel:_("Create items"),rightsValue:Zarafa.core.mapi.Rights.RIGHTS_CREATE},{xtype:"checkbox",boxLabel:_("Read items"),rightsValue:Zarafa.core.mapi.Rights.RIGHTS_READ_ANY},{xtype:"checkbox",boxLabel:_("Create subfolders"),rightsValue:Zarafa.core.mapi.Rights.RIGHTS_CREATE_SUBFOLDER}],listeners:{change:this.onPermissionChecked,scope:this}},{xtype:"checkboxgroup",columnWidth:0.5,style:"margin-left: 2px;",hideLabel:true,columns:1,
items:[{xtype:"checkbox",boxLabel:_("Folder permissions"),rightsValue:Zarafa.core.mapi.Rights.RIGHTS_FOLDER_ACCESS},{xtype:"checkbox",boxLabel:_("Folder visible"),rightsValue:Zarafa.core.mapi.Rights.RIGHTS_FOLDER_VISIBLE}],listeners:{change:this.onPermissionChecked,scope:this}}]},{xtype:"container",layout:"column",items:[{xtype:"fieldset",columnWidth:0.5,cls:"zarafa-fieldset",title:_("Edit items"),items:[{xtype:"radiogroup",columns:1,hideLabel:true,items:[{name:"allowedit",boxLabel:_("None"),hideLabel:true,
rightsValue:Zarafa.core.mapi.Rights.RIGHTS_NONE},{name:"allowedit",boxLabel:_("Own"),hideLabel:true,rightsValue:Zarafa.core.mapi.Rights.RIGHTS_EDIT_OWNED},{name:"allowedit",boxLabel:_("All"),hideLabel:true,rightsValue:Zarafa.core.mapi.Rights.RIGHTS_EDIT_ANY|Zarafa.core.mapi.Rights.RIGHTS_EDIT_OWNED}],listeners:{change:this.onPermissionChecked,scope:this}}]},{xtype:"fieldset",columnWidth:0.5,cls:"zarafa-fieldset",title:_("Delete items"),items:[{xtype:"radiogroup",columns:1,hideLabel:true,items:[{name:"allowdelete",
boxLabel:_("None"),hideLabel:true,rightsValue:Zarafa.core.mapi.Rights.RIGHTS_NONE},{name:"allowdelete",boxLabel:_("Own"),hideLabel:true,rightsValue:Zarafa.core.mapi.Rights.RIGHTS_DELETE_OWNED},{name:"allowdelete",boxLabel:_("All"),hideLabel:true,rightsValue:Zarafa.core.mapi.Rights.RIGHTS_DELETE_ANY|Zarafa.core.mapi.Rights.RIGHTS_DELETE_OWNED}],listeners:{change:this.onPermissionChecked,scope:this}}]}]}]}]}},onUserAdd:function(){Zarafa.common.Actions.openABUserSelectionDialog(this.onUserSelected.createDelegate(this),
{hide_contacts:true},{hide_users:["non_security"],hide_groups:["non_security"],hide_companies:["non_security"]},this.dialog.isBrowser())},onUserSelected:function(a){var b=this.userView.getStore();a=a.convertToUserPermission();if(b.findExact("entryid",a.get("entryid"))<0){b.add(a);this.userView.getSelectionModel().selectRecords([a])}else{b=a.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_MAILUSER?_("User already exists"):_("Group already exists");container.getNotifier().notify("error.permissions",
_("Error"),b,this.getEl())}},onUserRemove:function(){var a=this.userView.getStore(),b=this.userView.getSelectionModel().getSelected();this.selectedUser===b&&this.clearPermissionsForm();a.remove(b)},updateProfileCombo:function(a){this.profileCombo.store.findExact("value",a)>=0?this.profileCombo.setValue(a):this.profileCombo.setValue(null)},loadPermissionToGroup:function(a,b){var c=a.items;a.suspendEvents(false);if(a instanceof Ext.form.RadioGroup){var d=c.get(0),e=c.get(1);c=c.get(2);if((b&c.rightsValue)===
c.rightsValue){d.setValue(false);e.setValue(false);c.setValue(true)}else if((b&e.rightsValue)===e.rightsValue){d.setValue(false);c.setValue(false);e.setValue(true)}else{e.setValue(false);c.setValue(false);d.setValue(true)}}else{d=0;for(e=c.getCount();d<e;d++){var f=c.get(d);Ext.isDefined(f.rightsValue)&&f.setValue((b&f.rightsValue)===f.rightsValue)}}a.resumeEvents()},updatePermissionFromGroup:function(a,b){var c=0,d=0;a.items.each(function(e){if(Ext.isDefined(e.rightsValue)){c|=e.rightsValue;if(e.checked)d|=
e.rightsValue}});return b&~c|d},loadPermissionValue:function(a){this.updateProfileCombo(a);this.permissionsForm.cascade(function(b){b instanceof Ext.form.CheckboxGroup&&this.loadPermissionToGroup(b,a)},this)},updatePermissionValue:function(){var a=0;this.permissionsForm.cascade(function(b){if(b instanceof Ext.form.CheckboxGroup)a=this.updatePermissionFromGroup(b,a)},this);return a},loadPermissionsForm:function(a){this.selectedUser=a;this.removeUserBtn.enable();this.permissionsForm.getForm().items.each(function(b){b.enable()});
this.loadPermissionValue(a.get("rights"))},clearPermissionsForm:function(){this.selectedUser=undefined;this.loadPermissionValue(this.profileCombo.defaultValue);this.removeUserBtn.disable();this.permissionsForm.getForm().items.each(function(a){a.disable()})},onViewReady:function(){this.record&&this.record.isOpened()&&this.record.getSubStore("permissions").getCount()>0&&this.userView.getSelectionModel().selectFirstRow()},onActivate:function(){this.doLayout()},onUserSelectionChange:function(a){a=a.getSelected();
Ext.isEmpty(a)?this.clearPermissionsForm():this.loadPermissionsForm(a)},onProfileSelect:function(a,b){var c=b.get("value");if(c!==null){this.loadPermissionValue(c);this.selectedUser&&this.selectedUser.set("rights",c)}},onPermissionChecked:function(a){if(this.selectedUser){var b=this.selectedUser.get("rights");b=this.updatePermissionFromGroup(a,b);this.selectedUser.set("rights",b)}else b=this.updatePermissionValue();this.updateProfileCombo(b)},update:function(a,b){this.record=a;if(b&&a.isOpened()){var c=
a.getSubStore("permissions");this.userView.reconfigure(c,this.userView.getColumnModel());c.getCount()>0?this.userView.getSelectionModel().selectFirstRow():this.clearPermissionsForm()}},updateRecord:function(){this.selectedUser&&this.selectedUser.set("rights",this.updatePermissionValue())}});Ext.reg("zarafa.folderpropertiespermissiontab",Zarafa.hierarchy.dialogs.FolderPropertiesPermissionTab);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.folderpropertiespanel",border:false,layout:"fit",deferredRender:false,items:[{xtype:"tabpanel",border:false,activeTab:0,deferredRender:false,items:[{xtype:"zarafa.folderpropertiesgeneraltab",title:_("General")},{xtype:"zarafa.folderpropertiespermissiontab",title:_("Permissions")},container.populateInsertionPoint("folderpropertiesdialog.tabs",this)]}]});Zarafa.hierarchy.dialogs.FolderPropertiesPanel.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.folderpropertiespanel",Zarafa.hierarchy.dialogs.FolderPropertiesPanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesGeneralTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.folderpropertiesgeneraltab",border:false,bodyStyle:"background-color: inherit;",defaults:{border:true,bodyStyle:"background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;",xtype:"panel",layout:"form"},items:[this.createNameInfoPanel(),this.createDescriptionInfoPanel(),
this.createContentInfoPanel()]});Zarafa.hierarchy.dialogs.FolderPropertiesGeneralTab.superclass.constructor.call(this,a);this.on("activate",this.onActivate,this)},createNameInfoPanel:function(){return{items:[{xtype:"displayfield",style:"font-size : 20px",name:"display_name",htmlEncode:true,ref:"displayField"}],ref:"nameInfoPanel"}},createDescriptionInfoPanel:function(){return{defaults:{anchor:"100%"},items:[{xtype:"displayfield",fieldLabel:_("Type"),htmlEncode:true,ref:"folderTypeField"},{xtype:"displayfield",
fieldLabel:_("Location"),ref:"locationField",htmlEncode:true},{xtype:"textarea",fieldLabel:_("Description"),flex:1,name:"comment",listeners:{change:this.onFieldChange,scope:this}}],ref:"descriptionPanel"}},createContentInfoPanel:function(){return{border:false,items:[{xtype:"displayfield",fieldLabel:_("Items"),htmlEncode:true,name:"content_count"},{xtype:"displayfield",fieldLabel:_("Unread"),htmlEncode:true,name:"content_unread"},{xtype:"zarafa.displayfield",fieldLabel:_("Size"),renderer:Ext.util.Format.fileSize,
name:"message_size"}],buttonAlign:"left",buttons:[{xtype:"button",text:_("Folder size"),handler:this.onFolderSize,scope:this}]}},onActivate:function(){this.doLayout()},updateUI:function(a,b){var c=false;if(b===true){c=a.get("container_class").substr(4).replace(/\./,"").toLowerCase();this.nameInfoPanel.displayField.label.addClass(String.format("folder-dialog-icon icon_folder_{0}_large",Ext.util.Format.htmlEncode(c)));this.descriptionPanel.folderTypeField.setValue(String.format(_("Folder containing {0} Items"),
Zarafa.common.data.FolderContentTypes.getContentName(a.get("container_class"))));c=true;this.descriptionPanel.locationField.setValue(a.getPath())}c&&this.doLayout()},update:function(a,b){this.record=a;this.updateUI(a,b);this.getForm().loadRecord(a)},updateRecord:function(a){this.getForm().updateRecord(a)},onFieldChange:function(a,b){this.record.set(a.getName(),b)},onFolderSize:function(){Zarafa.hierarchy.Actions.openFolderSizeDialog(this.record,this.dialog.isBrowser())}});
Ext.reg("zarafa.folderpropertiesgeneraltab",Zarafa.hierarchy.dialogs.FolderPropertiesGeneralTab);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.CreateFolderPanel=Ext.extend(Ext.Panel,{parentFolder:undefined,preferredContainerClass:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",items:[this.createPanel()],buttons:[{text:_("Ok"),handler:this.onSubmit,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]});
Zarafa.hierarchy.dialogs.CreateFolderPanel.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterLayout,this,{single:true})},createPanel:function(){return{xtype:"panel",layout:"form",border:false,flex:1,bodyStyle:"background-color: inherit;",defaults:{anchor:"100%",style:"margin-bottom: 10px;"},labelAlign:"top",items:[{xtype:"textfield",fieldLabel:_("Name"),ref:"../newNameField",listeners:{scope:this,specialkey:function(a,b){b.getKey()==b.ENTER&&this.onSubmit()}}},{xtype:"combo",
fieldLabel:_("Folder contains"),typeAhead:true,triggerAction:"all",lazyRender:true,mode:"local",store:new Ext.data.ArrayStore({fields:["value","displayText"],data:[["IPF.Appointment",_("Calendar Items")],["IPF.Note",_("Mail and Post Items")],["IPF.Contact",_("Contacts Items")],["IPF.StickyNote",_("Note Items")],["IPF.Task",_("Task Items")]]}),editable:false,valueField:"value",displayField:"displayText",ref:"../folderListCombo"},{xtype:"zarafa.hierarchytree",fieldLabel:_("Select where to place the folder"),
border:true,forceLayout:true,anchor:"100% 65%",ref:"../hierarchyTree",treeSorter:true}]}},update:function(a){this.record=a},onAfterLayout:function(){this.mon(this.hierarchyTree.getSelectionModel(),"selectionchange",this.onHierarchyNodeSelect,this);if(this.parentFolder){this.hierarchyTree.selectFolderInTree(this.parentFolder);this.folderListCombo.setValue(this.parentFolder.get("container_class"))}},onHierarchyNodeSelect:function(a){if(a=a.getSelectedNode())if(a=a.getFolder())if(this.folderListCombo.findRecord("value",
a.get("container_class")))this.folderListCombo.setValue(a.get("container_class"));else this.preferredContainerClass?this.folderListCombo.setValue(this.preferredContainerClass):this.folderListCombo.setValue(a.get("container_class"));else this.preferredContainerClass&&this.folderListCombo.setValue(this.preferredContainerClass)},onSubmit:function(){if(this.newNameField.getValue().trim().length==0)Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You must specify a name."),buttons:Ext.MessageBox.OK,
icon:Ext.MessageBox.INFO});else{var a=this.hierarchyTree.getSelectionModel().getSelectedNode();if(a){a=a.getFolder();this.record.beginEdit();this.record.set("parent_entryid",a.get("entryid"));this.record.set("store_entryid",a.get("store_entryid"));this.record.set("display_name",this.newNameField.getValue());this.record.set("container_class",this.folderListCombo.getValue());this.record.endEdit();this.dialog.saveRecord()}else Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You must select a destination folder."),
buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}},onCancel:function(){this.dialog.close()}});Ext.reg("zarafa.createfolderpanel",Zarafa.hierarchy.dialogs.CreateFolderPanel);Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyTreeLoader=Ext.extend(Ext.tree.TreeLoader,{tree:undefined,store:undefined,nodeConfig:undefined,constructor:function(a){a=a||{};if(!a.directFn)a.directFn=this.directFn.createDelegate(this);Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.constructor.call(this,a);this.store&&this.store.on({load:this.onHierarchyLoad,remove:this.onHierarchyStoreRemove,addFolder:this.onHierarchyAddFolder,updateFolder:this.onHierarchyUpdateFolder,removeFolder:this.onHierarchyRemoveFolder,
scope:this})},onHierarchyLoad:function(a,b,c){var d=this.tree.getRootNode();c.add!==true&&d.removeAll(true);this.fireEvent("beforeload",this,d,this.directFn)!==false&&this.directFn(d.id,function(e,f){for(var g=0,h=e.length;g<h;g++)if(!d.findChild("folder",e[g].folder)){var i=this.createNode(e[g]);d.appendChild(i)}this.fireEvent("load",this,d,f)}.createDelegate(this))},onHierarchyStoreRemove:function(a,b){var c=this.tree.getRootNode().findChildBy(function(d){return Zarafa.core.EntryId.compareStoreEntryIds(d.attributes.folder.get("store_entryid"),
b.get("store_entryid"))});c&&c.remove(true)},onHierarchyAddFolder:function(a,b,c){if(Ext.isArray(c))for(var d=0,e=c.length;d<e;d++)this.onHierarchyAddFolder(a,b,c[d]);else if(c.phantom!==true)if(this.tree.nodeFilter(c))if(!this.tree.getNodeById(c.get("entryid"))){a=this.getFilteredParentNode(c);b="folder";if(!a){a=this.tree.getRootNode();b="rootfolder"}c=this.createNode(Ext.apply({nodeType:b,folder:c},this.nodeConfig));a.appendChild(c);a.expand()}},onHierarchyUpdateFolder:function(a,b,c){var d=this.tree.getNodeById(c.get("entryid"));
if(d)if(this.tree.nodeFilter(c)){a=d.parentNode;(b=this.getFilteredParentNode(c))||(b=this.tree.getRootNode());a!==b?b.appendChild(d):d.updateUI(c)}else this.onHierarchyRemoveFolder(a,b,c);else this.onHierarchyAddFolder(a,b,c)},onHierarchyRemoveFolder:function(a,b,c){(a=this.tree.getNodeById(c.get("entryid")))&&a.remove(true)},directFn:function(a,b){var c=this.tree.getNodeById(a),d=[];if(c.isRoot){c=this.store.getRange();for(var e=0,f=c.length;e<f;e++){var g=c[e],h=g.getSubtreeFolder();if((!this.tree.hasFilter()||
!g.isSharedStore()||h.isSharedFolder())&&this.tree.nodeFilter(h))d.push(Ext.apply({nodeType:"rootfolder",folder:h},this.nodeConfig));else d=d.concat(this.getFilteredChildNodes(h,"rootfolder"))}}else d=this.getFilteredChildNodes(c.getFolder(),"folder");b(d,{status:true})},getFilteredChildNodes:function(a,b){for(var c=a.getChildren(),d=[],e=0,f=c.length;e<f;e++){var g=c[e];if(this.tree.nodeFilter(g))d.push(Ext.apply({nodeType:b,folder:g},this.nodeConfig));else d=d.concat(this.getFilteredChildNodes(g,
b))}return d},getFilteredParentNode:function(a){a=a.getParentFolder();var b=false;if(a)b=this.tree.nodeFilter(a)?this.tree.getNodeById(a.get("entryid")):this.getFilteredParentNode(a);return b},createNode:function(a){var b=a.folder;if(b){if(a.nodeType==="rootfolder")a.extendedDisplayName=this.tree.hasFilter();a.id=b.get("entryid");a.leaf=!b.get("has_subfolder");a.uiProvider=Zarafa.hierarchy.ui.FolderNodeUI;a.expanded=this.tree.isFolderOpened(b);a.allowDrag=!b.isDefaultFolder()}return Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.createNode.apply(this,
arguments)}});Ext.namespace("Zarafa.hierarchy");
Zarafa.hierarchy.Actions={openFolder:function(a){if(a.get("access")!==0)container.selectFolder(a);else a.isIPMSubTree()||a.isSharedFolder()?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:a.isIPMSubTree()?_("Not enough permissions to open this store, do you want to remove it from the hierarchy?"):_("Not enough permissions to open this folder, do you want to remove it from the hierarchy?"),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.YESNO,fn:this.onFolderPermissionBox,scope:a}):Ext.MessageBox.show({title:_("Zarafa WebApp"),
msg:_("Not enough permissions to open this folder."),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})},onFolderPermissionBox:function(a){if(a==="yes")if(this.isIPMSubTree()){a=container.getHierarchyStore();var b=this.getMAPIStore();a.remove(b);a.save(b)}else{a=this.store;a.remove(this);a.save(this)}},openCreateFolderDialog:function(a){if(!Ext.isDefined(a)){a=container.getHierarchyStore().getDefaultFolder(container.getCurrentContext().name);Ext.isDefined(a)||(a=container.getHierarchyStore().getDefaultFolder("inbox"))}var b=
Zarafa.core.data.RecordFactory.createRecordObjectByObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,{parent_entryid:a.get("entryid"),store_entryid:a.get("store_entryid")});Zarafa.common.Actions.openCreateRecord(b,{parentFolder:a})},openFolderPropertiesDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderproperties"],a,{browser:b})},openFolderSizeDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["hierarchy.dialog.foldersize"],
a,{browser:b})},openSharedFolderDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["hierarchy.dialog.opensharedfolder"],undefined,{defaultSelectedFolderType:a,modal:true,browser:b})}};Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.distlistpanel",border:false,layout:"fit",items:this.createFormPanel()});Zarafa.contact.dialogs.DistlistPanel.superclass.constructor.call(this,a)},createFormPanel:function(){return[{xtype:"tabpanel",activeTab:0,border:false,defaults:{autoHeight:false,frame:true},items:[{xtype:"zarafa.distlistmemberstab"},{xtype:"zarafa.distlistnotestab",autoScroll:false},container.populateInsertionPoint("context.contact.distlistdialog.tabs",
this)]}]}});Ext.reg("zarafa.distlistpanel",Zarafa.contact.dialogs.DistlistPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistNotesTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.distlistnotestab",title:_("Notes"),items:[{xtype:"textarea",hideLabel:true,anchor:"100% 100%",name:"body",listeners:{change:this.onPropertyChange,scope:this}}]});Zarafa.contact.dialogs.DistlistNotesTab.superclass.constructor.call(this,a)},update:function(a){if(!Ext.isEmpty(a)){this.record=
a;this.getForm().loadRecord(this.record)}},updateRecord:function(a){this.getForm().updateRecord(a)},onPropertyChange:function(a,b){this.record.set(a.getName(),b)}});Ext.reg("zarafa.distlistnotestab",Zarafa.contact.dialogs.DistlistNotesTab);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactPhonePanel=Ext.extend(Ext.form.FormPanel,{parser:null,parsedData:null,property:null,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.contactphonepanel",border:false,frame:true,padding:5,items:this.createFormItems()});Zarafa.contact.dialogs.ContactPhonePanel.superclass.constructor.call(this,a)},createFormItems:function(){return[{xtype:"textfield",anchor:"100%",fieldLabel:_("Country/Region code"),
name:"country_code"},{xtype:"textfield",anchor:"100%",fieldLabel:_("City/Area code"),name:"city_code"},{xtype:"textfield",anchor:"100%",fieldLabel:_("Local number"),name:"local_number"},{xtype:"textfield",anchor:"100%",fieldLabel:_("Extension"),name:"extension"}]},update:function(a){if(Ext.isDefined(a)){if(Ext.isEmpty(this.parsedData)&&!Ext.isEmpty(a.get(this.property))){a=this.parser.parseInfo("phone",a.get(this.property));this.parsedData=Ext.apply(this.parsedData||{},a)}this.getForm().setValues(this.parsedData);
this.parsedData=null}},updateRecord:function(a){var b=this.getForm();a.beginEdit();Ext.isDefined(this.parser)&&a.set(this.property,this.parser.combineInfo("phone",b.getValues()));b.updateRecord(a);a.endEdit()}});Ext.reg("zarafa.contactphonepanel",Zarafa.contact.dialogs.ContactPhonePanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactNamePanel=Ext.extend(Ext.form.FormPanel,{parser:null,parsedData:null,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.contactnamepanel",border:false,frame:true,padding:5,items:this.createFormItems()});Zarafa.contact.dialogs.ContactNamePanel.superclass.constructor.call(this,a)},createFormItems:function(){return[{xtype:"combo",fieldLabel:_("Title"),editable:false,name:"display_name_prefix",
mode:"local",triggerAction:"all",store:{xtype:"arraystore",fields:["displayText"],data:Zarafa.contact.data.config.Prefix},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{displayText:htmlEncodeDefaultValue(Zarafa.contact.data.config.NBSP)}</div></tpl>',{compiled:true}),displayField:"displayText",valueField:"displayText"},{xtype:"textfield",anchor:"100%",fieldLabel:_("First"),name:"given_name"},{xtype:"textfield",anchor:"100%",fieldLabel:_("Middle"),name:"middle_name"},{xtype:"textfield",
anchor:"100%",fieldLabel:_("Last"),name:"surname"},{xtype:"combo",fieldLabel:_("Suffix"),editable:false,name:"generation",mode:"local",triggerAction:"all",store:{xtype:"arraystore",fields:["displayText"],data:Zarafa.contact.data.config.Suffix},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{displayText:htmlEncodeDefaultValue(Zarafa.contact.data.config.NBSP)}</div></tpl>',{compiled:true}),displayField:"displayText",valueField:"displayText"},{xtype:"checkbox",boxLabel:_("Show this again when name is incomplete or unclear."),
ref:"settingCheckField",hideLabel:true,checked:container.getSettingsModel().get("zarafa/v1/contexts/contact/show_name_dialog")}]},update:function(a){if(Ext.isDefined(a)){if(Ext.isEmpty(this.parsedData)&&!Ext.isEmpty(a.get("display_name"))){a=this.parser.parseInfo("name",a.get("display_name"));this.parsedData=Ext.apply(this.parsedData||{},a)}this.getForm().setValues(this.parsedData);this.parsedData=null}},updateRecord:function(a){var b=this.getForm();this.settingCheckField.isDirty()&&container.getSettingsModel().set("zarafa/v1/contexts/contact/show_name_dialog",
this.settingCheckField.getValue());a.beginEdit();Ext.isDefined(this.parser)&&a.set("display_name",this.parser.combineInfo("name",b.getValues()));b.updateRecord(a);a.endEdit()}});Ext.reg("zarafa.contactnamepanel",Zarafa.contact.dialogs.ContactNamePanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactDetailTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.contactdetailtab",title:_("Details"),labelWidth:140,defaults:{style:"padding: 2px; margin: 2px;",columnWidth:0.5,height:80,border:false,header:false,xtype:"fieldset"},items:[this.createOfficeFieldset(),this.createOfficeFieldset2(),this.createNameFieldset(),this.createDateFieldset()]});
Zarafa.contact.dialogs.ContactDetailTab.superclass.constructor.call(this,a)},createOfficeFieldset:function(){return{defaultType:"textfield",defaults:{anchor:"100%"},items:[{fieldLabel:_("Department"),name:"department_name",listeners:{scope:this,change:this.onFieldChange}},{fieldLabel:_("Office location"),name:"office_location",listeners:{scope:this,change:this.onFieldChange}},{fieldLabel:_("Profession"),name:"profession",listeners:{scope:this,change:this.onFieldChange}}]}},createOfficeFieldset2:function(){return{defaultType:"textfield",
defaults:{anchor:"100%"},items:[{fieldLabel:_("Manager's name"),name:"manager_name",listeners:{scope:this,change:this.onFieldChange}},{fieldLabel:_("Assistant's name"),name:"assistant",listeners:{scope:this,change:this.onFieldChange}}]}},createNameFieldset:function(){return{defaultType:"textfield",defaults:{anchor:"100%"},items:[{fieldLabel:_("Nickname"),name:"nickname",listeners:{scope:this,change:this.onFieldChange}},{xtype:"combo",fieldLabel:_("Title"),editable:false,name:"display_name_prefix",
mode:"local",triggerAction:"all",store:{xtype:"arraystore",fields:["displayText"],data:Zarafa.contact.data.config.Prefix},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{displayText:htmlEncodeDefaultValue(Zarafa.contact.data.config.NBSP)}</div></tpl>',{compiled:true}),displayField:"displayText",valueField:"displayText",listeners:{scope:this,change:this.onFieldChange}},{xtype:"combo",fieldLabel:_("Suffix"),editable:false,name:"generation",mode:"local",triggerAction:"all",store:{xtype:"arraystore",
fields:["displayText"],data:Zarafa.contact.data.config.Suffix},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{displayText:htmlEncodeDefaultValue(Zarafa.contact.data.config.NBSP)}</div></tpl>',{compiled:true}),displayField:"displayText",valueField:"displayText",listeners:{scope:this,change:this.onFieldChange}}]}},createDateFieldset:function(){return{defaultType:"textfield",defaults:{anchor:"100%"},items:[{fieldLabel:_("Spouse/Partner"),name:"spouse_name",listeners:{scope:this,
change:this.onFieldChange}},{xtype:"datefield",fieldLabel:_("Birthday"),name:"birthday",format:"d/m/Y",listeners:{scope:this,change:this.onFieldChange}},{xtype:"datefield",fieldLabel:_("Anniversary"),name:"wedding_anniversary",format:"d/m/Y",listeners:{scope:this,change:this.onFieldChange}}]}},update:function(a){if(!Ext.isEmpty(a)){this.record=a;this.getForm().loadRecord(a)}},onFieldChange:function(a,b){if(a.validateValue(b)){var c=this.record;c.beginEdit();c.set(a.getName(),b);switch(a.getName()){case "webpage":c.set("business_home_page",
b);break;case "birthday":Ext.isEmpty(b)&&c.set(a.getName(),null);c.set("birthday_eventid",c.get("birthday_eventid"),true);c.set("subject",c.get("subject"),true);c.updateTimezoneInformation();break;case "wedding_anniversary":Ext.isEmpty(b)&&c.set(a.getName(),null);c.set("anniversary_eventid",c.get("anniversary_eventid"),true);c.set("subject",c.get("subject"),true);c.updateTimezoneInformation();break;case "display_name_prefix":case "generation":var d={display_name_prefix:c.get("display_name_prefix"),
given_name:c.get("given_name"),middle_name:c.get("middle_name"),surname:c.get("surname"),generation:c.get("generation")};c.set("display_name",this.getContactParser().combineInfo("name",d));break}c.endEdit()}},getContactParser:function(){return this.dialog.contactParser}});Ext.reg("zarafa.contactdetailtab",Zarafa.contact.dialogs.ContactDetailTab);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactAddressPanel=Ext.extend(Ext.form.FormPanel,{parser:null,property:"",parsedData:null,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.contactaddresspanel",border:false,frame:true,padding:5,items:this.createFormItems(a.property)});Zarafa.contact.dialogs.ContactAddressPanel.superclass.constructor.call(this,a)},createFormItems:function(a){return[{xtype:"textarea",anchor:"100%",
fieldLabel:_("Street"),name:a+"_street"},{xtype:"textfield",anchor:"100%",fieldLabel:_("City"),name:a+"_city"},{xtype:"textfield",anchor:"100%",fieldLabel:_("State/Province"),name:a+"_state"},{xtype:"textfield",anchor:"100%",fieldLabel:_("Zip/Postal code"),name:a+"_postal_code"},{xtype:"textfield",anchor:"100%",fieldLabel:_("Country/Region"),name:a+"_country"},{xtype:"checkbox",boxLabel:_("Show this again when address is incomplete or unclear."),ref:"settingCheckField",hideLabel:true,checked:container.getSettingsModel().get("zarafa/v1/contexts/contact/show_address_dialog")}]},
update:function(a){if(Ext.isDefined(a)){if(Ext.isEmpty(this.parsedData)&&!Ext.isEmpty(a.get(this.property))){a=this.parser.parseInfo("address",a.get(this.property));this.parsedData=Ext.apply(this.parsedData||{},a)}Ext.iterate(this.parsedData,function(b,c){this.parsedData[this.property+"_"+b]=c;delete this.parsedData[b]},this);this.getForm().setValues(this.parsedData);this.parsedData=null}},updateRecord:function(a){var b=this.getForm();this.settingCheckField.isDirty()&&container.getSettingsModel().set("zarafa/v1/contexts/contact/show_address_dialog",
this.settingCheckField.getValue());a.beginEdit();if(Ext.isDefined(this.parser)){var c=b.getValues();Ext.iterate(c,function(d,e){c[d.substr(this.property.length+1)]=e;delete c[d]},this);a.set(this.property,this.parser.combineInfo("address",c))}b.updateRecord(a);a.endEdit()}});Ext.reg("zarafa.contactaddresspanel",Zarafa.contact.dialogs.ContactAddressPanel);Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.SearchFields=[{name:_("All text fields"),value:"PR_DISPLAY_NAME PR_DISPLAY_NAME_PREFIX PR_GENERATION 0x80B5001E PR_COMPANY_NAME 0x8130001E 0x8140001E 0x8150001E 0x80CB001E 0x80CA001E 0x80CC001E"},{name:_("Name"),value:"PR_DISPLAY_NAME PR_DISPLAY_NAME_PREFIX PR_GENERATION"},{name:_("File as"),value:"0x80B5001E"},{name:_("Company"),value:"PR_COMPANY_NAME"},{name:_("Email address"),value:"0x8130001E 0x8140001E 0x8150001E"},{name:_("Phone number"),value:"PR_HOME_TELEPHONE_NUMBER PR_CELLULAR_TELEPHONE_NUMBER business_telephone_number PR_BUSINESS_FAX_NUMBER"},
{name:_("Address"),value:"0x80CB001E 0x80CA001E 0x80CC001E"}];Ext.namespace("Zarafa.contact.data");Zarafa.contact.data.config={Prefix:[[""],[_("Dr.")],[_("Miss")],[_("Mr.")],[_("Mrs.")],[_("Ms.")],[_("Prof.")]],Suffix:[[""],["I"],["II"],["III"],[_("Jr.")],[_("Sr.")]],CR:"\r",LF:"\n",CRLF:"\r\n",SP:" ",NBSP:"\u00a0"};Ext.namespace("Zarafa.contact");
Zarafa.contact.Actions={openDialog:function(a,b){if(Ext.isArray(a))for(var c=0,d=a.length;c<d;c++)Zarafa.contact.Actions.openDialog(a[c],b);else if(a.isMessageClass("IPM.Contact",true))this.openContactDialog(a,false,b);else a.isMessageClass("IPM.DistList",true)&&this.openDistlistDialog(a,false,b)},openContactDialog:function(a,b,c){if(Ext.isArray(a))for(var d=0,e=a.length;d<e;d++)Zarafa.contact.Actions.openContactDialog(a[d],b,c);else{if(Ext.isEmpty(a)&&!Ext.isEmpty(b))a=b.createRecord(undefined,false);
Ext.isEmpty(a)||Zarafa.common.Actions.openCreateRecord(a)}},openDistlistDialog:function(a,b,c){if(Ext.isArray(a))for(var d=0,e=a.length;d<e;d++)Zarafa.contact.Actions.openDistlistDialog(a[d],b,c);else{if(Ext.isEmpty(a)&&!Ext.isEmpty(b))a=b.createRecord(undefined,true);Ext.isEmpty(a)||Zarafa.common.Actions.openCreateRecord(a)}},openEmailDialog:function(a,b){Ext.isArray(a)||(a=[a]);var c=container.getHierarchyStore().getDefaultFolder("drafts");c=container.getContextByFolder(c).getModel().createRecord(c);
for(var d=c.getRecipientStore(),e=0,f=a.length;e<f;e++)a[e].isMessageClass("IPM.DistList",true)||d.add(a[e].convertToRecipient(Zarafa.core.mapi.RecipientType.MAPI_TO,true));d.getCount()>0&&Zarafa.common.Actions.openCreateRecord(c,{browser:b})},openDetailedNameDialog:function(a,b,c){Ext.isEmpty(b)||Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["contact.dialog.contact.namedetails"],b,{parser:a,parsedData:c,modal:true})},openDetailedAddressDialog:function(a,b,c,d){Ext.isEmpty(b)||
Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["contact.dialog.contact.addressdetails"],b,{parser:a,parsedData:c,property:d,modal:true})},openDetailedPhoneDialog:function(a,b,c){Ext.isEmpty(b)||Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["contact.dialog.contact.phonedetails"],b,{parser:a,property:c,modal:true})},openMembersSelectionDialog:function(a,b){if(Ext.isArray(a))for(var c=0,d=a.length;c<d;c++)Zarafa.contact.Actions.openMembersSelectionDialog(a[c],
b);else Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.memberselection"],a,{browser:b,modal:true})},openDistlistExternalMemberDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["contact.dialog.distlist.externalmember"],b,{parentRecord:a,modal:true,browser:false})},openDistlistMember:function(a){if(a){var b;switch(a.get("distlist_type")){case Zarafa.core.mapi.DistlistType.DL_USER:case Zarafa.core.mapi.DistlistType.DL_USER2:case Zarafa.core.mapi.DistlistType.DL_USER3:case Zarafa.core.mapi.DistlistType.DL_DIST:b=
a.convertToContactRecord();break;case Zarafa.core.mapi.DistlistType.DL_USER_AB:case Zarafa.core.mapi.DistlistType.DL_DIST_AB:b=a.convertToAddressBookRecord();break;case Zarafa.core.mapi.DistlistType.DL_EXTERNAL_MEMBER:default:Zarafa.contact.Actions.openDistlistExternalMemberDialog(this.record,a);break}if(b){container.getShadowStore().add(b);Zarafa.common.Actions.openViewRecord(b)}}}};Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.MeetingRequestButtons=Ext.extend(Ext.ButtonGroup,{record:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{hidden:true,forceLayout:true,items:[this.getRemoveFromCalendarButton(),this.getNotCurrentButton(),this.getNoResponseRequiredButton(),this.getAcceptButton(),this.getTentativeButton(),this.getDeclineButton(),this.getProposeNewTimeButton(),this.getViewAllProposalsButton(),this.getAcceptProposalButton(),
this.getCalendarButton()]});Zarafa.calendar.ui.MeetingRequestButtons.superclass.constructor.call(this,a)},update:function(a){if(a instanceof Zarafa.calendar.AppointmentRecord){this.record=a;var b=false,c=false,d=false,e=false,f=false,g=false,h=false,i=false,j=false,k=a.senderIsReceiver(),m=a.get("appointment_not_found"),l=a.senderIsStoreOwner(),n=a.senderIsUser();if(a instanceof Zarafa.calendar.MeetingRequestRecord){c=b=a.isMeetingRequest();e=(d=a.isMeetingRequestResponse())&&a.get("counter_proposal");
f=a.get("appointment_recurring");h=a.get("meeting_updated");i=a.isMeetingRequestCanceled();j=a.isMeetingOutOfDate()}else{b=a.isMeeting();i=a.isMeetingCanceled();f=a.get("recurring");j=(g=a.hasIdProp("basedate"))&&a.get("duedate")<new Date}this.removeFromCalendarButton.setVisible(i&&!m);this.nonCurrentButton.setVisible(c&&j);this.noResponseButton.setVisible(c&&k&&!j);this.acceptButton.setVisible(b&&!k&&!j&&!i&&!l&&!n);this.tentativeButton.setVisible(b&&!k&&!j&&!i&&!l&&!n);this.declineButton.setVisible(b&&
!k&&!j&&!i&&!l&&!n);this.proposeNewTimeButton.setVisible(b&&(!f||g)&&!k&&!j&&!i&&!l&&!n);this.viewProposalsButton.setVisible(e&&!h&&!l);this.acceptProposalButton.setVisible(e&&!h&&!l);this.calendarButton.setVisible((c||d)&&!m);var o=false;this.items.each(function(p){if(p.hidden!==true){o=true;return false}});if(this.xtbHidden!==true)this.setVisible(o);else if(o){this.setVisible(true);this.xtbWidth=this.getPositionEl().dom.parentNode.offsetWidth;this.setVisible(false)}else this.xtbWidth=0;this.ownerCt&&
this.ownerCt.doLayout();if(this.dialog){a=a.getMessageAction("action_type");if(a=="acceptMeetingRequest"||a=="declineMeetingRequest"){this.dialog.close();return false}}}else{this.setVisible(false);if(this.xtbHidden===true)this.xtbWidth=0;this.ownerCt&&this.ownerCt.doLayout()}},getRemoveFromCalendarButton:function(){return{xtype:"button",ref:"removeFromCalendarButton",text:_("Remove From Calendar"),tooltip:{title:_("Remove From Calendar"),text:_("Remove From Calendar")},iconCls:"icon_remove_from_calendar",
handler:this.onRemoveFromCalendar,scope:this}},getNotCurrentButton:function(){return{xtype:"button",ref:"nonCurrentButton",text:_("Not Current"),tooltip:{title:_("Not Current"),text:_("Meeting Request is out of date")},iconCls:"icon_notcurrent_meeting_request",handler:this.onNotCurrent,scope:this}},getNoResponseRequiredButton:function(){return{xtype:"button",ref:"noResponseButton",text:_("No Response Required"),tooltip:{title:_("No Response Required"),text:_("No Response Required")},iconCls:"icon_no_response_required",
handler:this.onNoResponseRequired,scope:this}},getAcceptButton:function(){return{xtype:"button",ref:"acceptButton",text:_("Accept"),tooltip:{title:_("Accept"),text:_("Accept Meeting Request")},iconCls:"icon_accept_meeting_request",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED,handler:this.openSendConfirmationDialog,scope:this}},getTentativeButton:function(){return{xtype:"button",ref:"tentativeButton",text:_("Tentative"),tooltip:{title:_("Tentative"),text:_("Tentatively Accept Meeting Request")},
iconCls:"icon_tentative_meeting_request",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE,handler:this.openSendConfirmationDialog,scope:this}},getDeclineButton:function(){return{xtype:"button",ref:"declineButton",text:_("Decline"),tooltip:{title:_("Decline"),text:_("Decline Meeting Request")},iconCls:"icon_decline_meeting_request",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED,handler:this.openSendConfirmationDialog,scope:this}},getProposeNewTimeButton:function(){return{xtype:"button",
ref:"proposeNewTimeButton",text:_("Propose New Time"),tooltip:{title:_("Propose New Time"),text:_("Propose New Time for Meeting Request")},iconCls:"icon_newtime_meeting_request",handler:this.openProposeNewTimeDialog,scope:this}},getViewAllProposalsButton:function(){return{xtype:"button",ref:"viewProposalsButton",text:_("View All Proposals"),tooltip:{title:_("View All Proposals"),text:_("View All Proposals")},iconCls:"icon_view_all_meeting_request",handler:this.viewAllProposals,scope:this}},getAcceptProposalButton:function(){return{xtype:"button",
ref:"acceptProposalButton",text:_("Accept Proposal"),tooltip:{title:_("Accept Proposal"),text:_("Accept Proposed Time")},iconCls:"icon_accept_proposal",handler:this.acceptProposal,scope:this}},getCalendarButton:function(){return{xtype:"button",ref:"calendarButton",text:_("Calendar"),tooltip:{title:_("Calendar"),text:_("Calendar")},iconCls:"icon_calender",handler:this.showMeetingInCalendar,scope:this}},onNotCurrent:function(){Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This meeting request is out-of-date and will now be deleted."),
icon:Ext.MessageBox.WARNING,record:this.record,fn:this.removeRecordOnOk,scope:this,buttons:Ext.MessageBox.OKCANCEL})},onNoResponseRequired:function(){Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("Your calendar has been updated automatically. This meeting request will now be deleted."),icon:Ext.MessageBox.WARNING,record:this.record,fn:this.removeRecordOnOk,scope:this,buttons:Ext.MessageBox.OKCANCEL})},removeRecordOnOk:function(a){if(a=="ok"){a=this.record.getStore();a.remove(this.record);a.save(this.record)}},
onRemoveFromCalendar:function(){this.record.addMessageAction("action_type","removeFromCalendar");var a=this.record.getStore();a.remove(this.record);a.save(this.record)},openProposeNewTimeDialog:function(){Zarafa.calendar.Actions.openProposeNewTimeDialog(this.record)},openSendConfirmationDialog:function(a){Zarafa.calendar.Actions.openSendConfirmationDialog(this.record,a.responseStatus)},acceptProposal:function(){Zarafa.calendar.Actions.openAppointmentDialogToAcceptProposal(this.record);this.dialog&&
this.dialog.close()},showMeetingInCalendar:function(){Zarafa.calendar.Actions.showMeetingInCalendar(this.record);this.dialog&&this.dialog.close()},viewAllProposals:function(){Zarafa.calendar.Actions.openAppointmentDialogToViewAllProposals(this.record);this.dialog&&this.dialog.close()}});Ext.reg("zarafa.meetingrequestbuttons",Zarafa.calendar.ui.MeetingRequestButtons);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.MeetingInfo=Ext.extend(Ext.Container,{record:undefined,meetingInfoTemplate:'<hr class="preview-title-hr"><table><tpl if="values.counter_proposal"><tr class="preview-proposed"><td class="preview-proposed-title">'+pgettext("mail.previewpanel","Proposed")+':</td><td><tpl if="!Ext.isEmpty(values.proposed_start_date)">{proposed_start_date:date("'+_("l jS F Y G:i")+'")}<span>&nbsp;-&nbsp;</span></tpl><tpl if="!Ext.isEmpty(values.proposed_end_date)">{proposed_end_date:date("'+_("l jS F Y G:i")+
'")}</tpl></td></tr></tpl><tr class="preview-when"><td class="preview-when-title">'+pgettext("mail.previewpanel","When")+':</td><td><tpl if="values.appointment_recurring === true">{appointment_recurring_pattern}</tpl><tpl if="values.appointment_recurring !== true"><tpl if="!Ext.isEmpty(values.appointment_startdate)">{appointment_startdate:date("'+_("l jS F Y G:i")+'")}<span>&nbsp;-&nbsp;</span></tpl><tpl if="!Ext.isEmpty(values.appointment_duedate)">{appointment_duedate:date("'+_("l jS F Y G:i")+
'")}</tpl></tpl></td></tr><tpl if="!Ext.isEmpty(values.appointment_location)"><tr class="preview-location"><td class="preview-location-title">'+pgettext("mail.previewpanel","Location")+":</td><td>{appointment_location:htmlEncode}</td></tr></tpl></table>",constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.meetinginfo",cls:"preview-header-meeting",hidden:true,forceLayout:true});Zarafa.calendar.ui.MeetingInfo.superclass.constructor.call(this,
a);if(Ext.isString(this.meetingInfoTemplate))this.meetingInfoTemplate=new Ext.XTemplate(this.meetingInfoTemplate,{compiled:true})},update:function(a){if(a instanceof Zarafa.calendar.MeetingRequestRecord){this.meetingInfoTemplate.overwrite(Ext.get(this.el.dom),a.data);this.setVisible(true)}else{this.el.dom.innerHTML="";this.setVisible(false)}}});Ext.reg("zarafa.meetinginfo",Zarafa.calendar.ui.MeetingInfo);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.DateRangeSelectionModel=Ext.extend(Ext.util.Observable,{dateRange:undefined,calendarView:undefined,active:false,constructor:function(a){this.addEvents("selectionclear","selectionset","selectionchange");Zarafa.calendar.ui.DateRangeSelectionModel.superclass.constructor.call(this,a)},clearSelections:function(){var a=this.dateRange,b=this.calendarView;this.calendarView=this.dateRange=undefined;this.active=false;this.fireEvent("selectionclear",this,a,b);this.fireEvent("selectionchange",
this,this.dateRange,this.calendarView,this.active)},set:function(a,b){this.dateRange=a;this.calendarView=b;this.active=true;this.fireEvent("selectionset",this,this.dateRange,this.calendarView);this.fireEvent("selectionchange",this,this.dateRange,this.calendarView,this.active)},getDateRange:function(){return this.dateRange},getCalendarView:function(){return this.calendarView},isActive:function(){return this.active}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.DatePicker=Ext.extend(Ext.DatePicker,{store:undefined,folder:undefined,monthStart:undefined,monthEnd:undefined,constructor:function(a){a=a||{};if(!a.store)a.store=new Zarafa.calendar.data.busytime.BusyTimeStore;Zarafa.calendar.ui.DatePicker.superclass.constructor.call(this,a)},afterRender:function(){Zarafa.calendar.ui.DatePicker.superclass.afterRender.call(this);var a=container.getHierarchyStore();this.mon(a,"load",this.onHierarchyLoad,this);this.onHierarchyLoad(a)},onHierarchyLoad:function(a){if(this.folder=
a.getDefaultFolder("calendar")){container.on("contextswitch",this.onContextSwitch,this);this.store.on("load",this.onLoad,this);this.rendered&&this.reloadStore(this.cells.first().dom.firstChild.dateValue,this.cells.last().dom.firstChild.dateValue)}},onLoad:function(a,b){this.clearCells();if(!this.settingIsSet())return false;for(var c=0,d=this.cells.elements.length;c<d;c++){for(var e=Ext.get(this.cells.elements[c]),f=e.dom.firstChild.dateValue,g=false,h=0,i=b.length;h<i;h++){var j=b[h],k=j.get("startdate").clearTime(true).getTime();
if(f==k&&j.get("busystatus")!=Zarafa.core.mapi.BusyStatus.FREE){g=true;break}}g?e.addClass("x-date-busy"):e.removeClass("x-date-busy")}},reloadStore:function(a,b){this.monthStart=this.value.clone();this.monthStart.setDate(1);this.monthEnd=this.monthStart.add(Date.MONTH,1);this.store.load({actionType:Zarafa.core.Actions.list,params:{entryid:this.folder.get("entryid"),store_entryid:this.folder.get("store_entryid"),restriction:{startdate:a/1E3,duedate:b/1E3}}})},onContextSwitch:function(a,b,c){c instanceof
Zarafa.calendar.CalendarContext&&this.reloadStore(this.cells.first().dom.firstChild.dateValue,this.cells.last().dom.firstChild.dateValue)},update:function(a,b){Zarafa.calendar.ui.DatePicker.superclass.update.call(this,a,b);this.folder&&this.dateIsChanged(a)&&this.reloadStore(this.cells.first().dom.firstChild.dateValue,this.cells.last().dom.firstChild.dateValue)},dateIsChanged:function(a){a=a.getTime();return a<this.monthStart.getTime()||this.monthEnd.getTime()<=a},settingIsSet:function(){return container.getSettingsModel().get("zarafa/v1/contexts/calendar/datepicker_show_busy")},
clearCells:function(){this.cells.each(function(a){a.removeClass("x-date-busy")})}});Ext.reg("zarafa.datepicker",Zarafa.calendar.ui.DatePicker);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarViewDragZone=Ext.extend(Ext.dd.DragZone,{calendar:undefined,ddel:undefined,headerMode:false,constructor:function(a,b){b=b||{};this.calendar=a;var c=this.calendar.body;if(b.headerMode===true)c=this.calendar.header;Ext.applyIf(b,{ddGroup:"AppointmentDD"});Zarafa.calendar.ui.CalendarViewDragZone.superclass.constructor.call(this,c,b);this.scroll=false;this.ddel=document.createElement("div");this.ddel.className="x-data-dd-wrap"},getDragData:function(a){var b=this.calendar.selectionModel,
c=new Ext.EventObjectImpl(a),d=this.getAppointmentFromEvent(a);a=this.getDragStateFromEvent(a,d);return{calendar:this.calendar,ddel:this.ddel,selections:b.getSelections(),target:d,state:a,origEvent:c}},b4StartDrag:function(){Zarafa.calendar.ui.CalendarViewDragZone.superclass.b4StartDrag.apply(this,arguments);if(this.calendar.enableDD||this.calendar.enableDrop)this.proxy.hide()},startDrag:function(){Zarafa.calendar.ui.CalendarViewDragZone.superclass.startDrag.apply(this,arguments);if(this.calendar.enableDD||
this.calendar.enableDrop)this.proxy.hide()},onInitDrag:function(){var a=this.dragData;if(a&&a.origEvent){var b=a.target,c=this.calendar.selectionModel;if(!b||!c.isSelected(b.getRecord())){this.calendar.onMouseDown(a.origEvent,b);a.selections=c.getSelections()}delete a.origEvent}this.ddel.innerHTML=this.calendar.getDragDropText();this.proxy.update(this.ddel)},onMouseUp:function(){var a=this.dragData;if(a&&a.origEvent){this.calendar.onMouseDown(a.origEvent,a.target);delete a.origEvent}this.hideProxy();
Zarafa.calendar.ui.CalendarViewDragZone.superclass.onMouseUp.apply(this,arguments)},afterRepair:function(){this.dragging=false},getRepairXY:function(){return false},onEndDrag:function(a,b){this.calendar.onMouseUp(b,a.target)},onValidDrop:function(){this.hideProxy()},beforeInvalidDrop:function(){},getAppointmentFromEvent:function(a){for(var b=this.calendar.appointments,c=0,d=b.length;c<d;c++){var e=b[c];if(this.headerMode!==true){if(e.eventOverBody(a))return e}else if(e.eventOverHeader(a))return e}},
getDragStateFromEvent:function(a,b){return this.headerMode!==true?Ext.isDefined(b)?b.eventOverBodyStartHandle(a)?Zarafa.calendar.data.DragStates.RESIZING_START:b.eventOverBodyDueHandle(a)?Zarafa.calendar.data.DragStates.RESIZING_DUE:Zarafa.calendar.data.DragStates.DRAGGING:Zarafa.calendar.data.DragStates.SELECTING:Ext.isDefined(b)?b.eventOverHeaderStartHandle(a)?Zarafa.calendar.data.DragStates.RESIZING_START:b.eventOverHeaderDueHandle(a)?Zarafa.calendar.data.DragStates.RESIZING_DUE:Zarafa.calendar.data.DragStates.DRAGGING:
Zarafa.calendar.data.DragStates.SELECTING}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarPanel=Ext.extend(Ext.Panel,{context:undefined,model:undefined,store:undefined,loadMaskText:_("Loading")+"...",selectionModel:undefined,rangeSelectionModel:undefined,viewConfig:undefined,view:undefined,constructor:function(a){a=a||{};Ext.apply(this,a,{xtype:"zarafa.calendarpanel",border:false});this.addEvents("beforeappointmentcalendardrop","appointmentcalendardrop","beforeappointmentmove","beforeappointmentresize","beforeappointmentcreate","appointmentmove","appointmentresize",
"appointmentcreate","contextmenu","dblclick","dayclick","dayclick","calendarclose");Zarafa.calendar.ui.CalendarPanel.superclass.constructor.call(this,a)},initComponent:function(){Zarafa.calendar.ui.CalendarPanel.superclass.initComponent.apply(this,arguments);if(!Ext.isDefined(this.model)&&Ext.isDefined(this.context))this.model=this.context.getModel();if(!Ext.isDefined(this.store)&&Ext.isDefined(this.model))this.store=this.model.getStore();if(!Ext.isDefined(this.selectionModel))this.selectionModel=
new Zarafa.calendar.ui.AppointmentSelectionModel;if(!Ext.isDefined(this.rangeSelectionModel))this.rangeSelectionModel=new Zarafa.calendar.ui.DateRangeSelectionModel;this.viewConfig=this.viewConfig||{};Ext.apply(this.viewConfig,{context:this.context,selectionModel:this.selectionModel,rangeSelectionModel:this.rangeSelectionModel});this.view=new Zarafa.calendar.ui.CalendarMultiView(this.viewConfig);this.mon(this.view,"appointmentcalendardrop",this.onAppointmentCalendarDrop,this);this.mon(this.view,"appointmentmove",
this.onAppointmentMove,this);this.mon(this.view,"appointmentresize",this.onAppointmentResize,this);this.mon(this.view,"appointmentcreate",this.onAppointmentCreate,this);this.mon(this.view,"contextmenu",this.onViewContextMenu,this);this.mon(this.view,"dblclick",this.onDoubleClick,this);this.mon(this.view,"dayclick",this.onDayClick,this);this.mon(this.view,"calendarclose",this.onCalendarClose,this);this.store&&this.bindStore(this.store)},onViewContextMenu:function(a,b){this.fireEvent("contextmenu",
a,b);a.stopEvent()},onDoubleClick:function(a,b){this.fireEvent("dblclick",a,b);a.stopEvent()},onDayClick:function(a,b){this.fireEvent("dayclick",a,b)},onCalendarClose:function(a){this.fireEvent("calendarclose",a)},onAppointmentCalendarDrop:function(a,b,c,d,e,f){if(this.fireEvent("beforeappointmentcalendardrop",this,b,c,d,e)!==false){f.ctrlKey?b.copyTo(d):b.moveTo(d);b.save();this.fireEvent("appointmentcalendardrop",this,b,c,d,e)}},onAppointmentMove:function(a,b,c){b.isMeetingSent()&&!b.isAppointmentInPast()&&
b.getMessageAction("send")!==true?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("An update message will be sent to all recipients, do you wish to continue?"),icon:Ext.MessageBox.WARNING,fn:function(d){if(d==="yes"){b.addMessageAction("send",true);this.doAppointmentMove(b,c)}},scope:this,buttons:Ext.MessageBox.YESNO}):this.doAppointmentMove(b,c)},doAppointmentMove:function(a,b){if(this.fireEvent("beforeappointmentmove",this,a,b)!==false){a.beginEdit();var c=b.getStartDate(),d=b.getDueDate();
a.set("alldayevent",b.isAllDay());a.set("startdate",c);a.set("duedate",d);a.set("commonstart",c);a.set("commonend",d);a.set("duration",b.getDuration(Date.MINUTE));if(a.get("reminder")===true){a.set("reminder_time",c);a.set("flagdueby",c.add(Date.MINUTE,-a.get("reminder_minutes")))}if(!a.userIsStoreOwner())(c=container.getHierarchyStore().getByEntryId(a.get("store_entryid")))&&a.setDelegatorInfo(c,true);a.endEdit();a.save();this.fireEvent("appointmentmove",this,a,b)}},onAppointmentResize:function(a,
b,c){b.isMeetingSent()&&!b.isAppointmentInPast()&&b.getMessageAction("send")!==true?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("An update message will be sent to all recipients, do you wish to continue?"),icon:Ext.MessageBox.WARNING,fn:function(d){if(d==="yes"){b.addMessageAction("send",true);this.doAppointmentResize(b,c)}},scope:this,buttons:Ext.MessageBox.YESNO}):this.doAppointmentResize(b,c)},doAppointmentResize:function(a,b){if(this.fireEvent("beforeappointmentresize",this,a,b)!==false){a.beginEdit();
var c=b.getStartDate(),d=b.getDueDate();a.set("alldayevent",b.isAllDay());a.set("startdate",c,true);a.set("duedate",d,true);a.set("commonstart",c);a.set("commonend",d);a.set("duration",b.getDuration(Date.MINUTE));if(a.get("reminder")===true){a.set("reminder_time",c);a.set("flagdueby",c.add(Date.MINUTE,-a.get("reminder_minutes")))}if(!a.userIsStoreOwner())(c=container.getHierarchyStore().getByEntryId(a.get("store_entryid")))&&a.setDelegatorInfo(c,true);a.endEdit();a.save();this.fireEvent("appointmentresize",
this,a,b)}},onAppointmentCreate:function(a,b,c,d){if(this.fireEvent("beforeappointmentcreate",this,b,c,d)!==false){a=this.model.createRecord(b,c);a.set("subject",d);this.store.add(a);a.save();this.fireEvent("appointmentcreate",this,b,a)}},onRender:function(){Zarafa.calendar.ui.CalendarPanel.superclass.onRender.apply(this,arguments);this.view.render(this.body)},onResize:function(){Zarafa.calendar.ui.CalendarPanel.superclass.onResize.apply(this,arguments);this.rendered&&this.view.layout()},afterRender:function(){Zarafa.calendar.ui.CalendarPanel.superclass.afterRender.apply(this,
arguments);this.loadMask=new Zarafa.common.ui.LoadMask(this.body,{msg:this.loadMaskText});this.view.layout()},getView:function(){return this.view},getSelectionModel:function(){return this.selectionModel},getRangeSelectionModel:function(){return this.rangeSelectionModel},bindStore:function(a){this.store=a;if(Ext.isDefined(a)){this.mon(a,"beforeload",this.onBeforeLoad,this);this.mon(a,"load",this.onLoad,this);this.mon(a,"exception",this.onLoadException,this);this.mon(a,"notify",this.onStoreNotify,this)}this.view.bindStore(a)},
releaseStore:function(a){if(!Ext.isDefined(a)){this.mun(a,"beforeload",this.onBeforeLoad,this);this.mun(a,"load",this.onLoad,this);this.mun(a,"exception",this.onLoadException,this);this.mun(a,"notify",this.onStoreNotify,this)}this.view.releaseStore(a);this.store=undefined},onBeforeLoad:function(){this.loadMask&&this.loadMask.show()},onLoad:function(){this.loadMask&&this.loadMask.hide()},onLoadException:function(){this.loadMask&&this.loadMask.hide()},onStoreNotify:function(a,b,c){a=this.getRangeSelectionModel();
if(!Ext.isEmpty(c)&&a.isActive()&&b===Zarafa.core.data.Notifications.objectCreated){b=a.getDateRange();c=c[0];b.getStartTime()===c.get("startdate").getTime()&&b.getDueTime()===c.get("duedate").getTime()&&a.clearSelections()}},destroy:function(){this.view.destroy();Zarafa.calendar.ui.CalendarPanel.superclass.destroy.apply(this,arguments)}});Ext.reg("zarafa.calendarpanel",Zarafa.calendar.ui.CalendarPanel);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarBlockPanel=Ext.extend(Ext.Panel,{context:undefined,model:undefined,selectionModel:undefined,rangeSelectionModel:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.selectionModel))a.selectionModel=new Zarafa.calendar.ui.AppointmentSelectionModel;if(!Ext.isDefined(a.rangeSelectionModel))a.rangeSelectionModel=new Zarafa.calendar.ui.DateRangeSelectionModel;Ext.applyIf(a,{border:false,
layout:"fit",deferredRender:false,items:[{xtype:"zarafa.calendarpanel",ref:"calendarPanel",context:a.context,selectionModel:a.selectionModel,rangeSelectionModel:a.rangeSelectionModel,listeners:{scope:this,contextmenu:this.onContextMenu,dblclick:this.onDblClick,dayclick:this.onDayClick,calendarclose:this.onCalendarClose}}]});Ext.apply(this,a);Zarafa.calendar.ui.CalendarBlockPanel.superclass.constructor.call(this,a);this.mon(this.selectionModel,"selectionchange",this.onSelectionChange,this)},getCalendarPanel:function(){return this.calendarPanel},
onContextMenu:function(a,b){Zarafa.common.Actions.openContextMenu(b,a.getXY())},onDblClick:function(a,b){Zarafa.calendar.Actions.openAppointmentDialog(b,this.model)},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},onDayClick:function(a,b){this.selectionModel.clearSelections();this.rangeSelectionModel.clearSelections();this.context.switchView(Zarafa.calendar.data.Views.BLOCKS,Zarafa.calendar.data.ViewModes.DAYS);this.model.setModeAndDate(Zarafa.calendar.data.DataModes.DAY,
b)},onCalendarClose:function(a){this.model.removeFolder(a)},onAdded:function(a,b){Zarafa.calendar.ui.CalendarBlockPanel.superclass.onAdded.call(this,a,b);this.mon(this.ownerCt,"switchview",this.onSwitchView,this)},onRemoved:function(){this.mun(this.ownerCt,"switchview",this.onSwitchView,this);Zarafa.calendar.ui.CalendarBlockPanel.superclass.onRemoved.call(this)},onSwitchView:function(a,b,c){if(this==b)this.getCalendarPanel().bindStore(this.model.getStore());else this==c&&this.getCalendarPanel().releaseStore(this.model.getStore())}});
Ext.reg("zarafa.calendarblockpanel",Zarafa.calendar.ui.CalendarBlockPanel);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AppointmentSelectionModel=Ext.extend(Ext.grid.AbstractSelectionModel,{singleSelect:true,selections:undefined,constructor:function(a){this.selections=new Ext.util.MixedCollection(false,function(b){var c=b.id;if(Ext.isDate(b.data.basedate))c+=b.data.basedate.getTime();return c});this.addEvents("appointmentselect","appointmentdeselect","selectionclear","selectionchange");Zarafa.calendar.ui.AppointmentSelectionModel.superclass.constructor.call(this,a)},clearSelections:function(){if(!this.isLocked())if(this.selections.getCount()!=
0){this.selections.clear();this.fireEvent("selectionclear",this);this.fireEvent("selectionchange",this,this.getSelections())}},getCount:function(){return this.selections.getCount()},getSelections:function(){return[].concat(this.selections.items)},getSelected:function(){return this.selections.itemAt(0)},hasSelection:function(){return this.selections.length>0},isSelected:function(a){return a&&this.selections.key(this.selections.getKey(a))?true:false},selectRecord:function(a,b){if(!(this.isLocked()||
!Ext.isDefined(a)||b&&this.isSelected(a)))if(a.get("access")!==0){if(!b||this.singleSelect)this.clearSelections();this.selections.add(a);this.fireEvent("appointmentselect",this,a);this.fireEvent("selectionchange",this,this.getSelections())}},deselectRecord:function(a){if(!(this.isLocked()||!Ext.isDefined(a))){this.selections.remove(a);this.fireEvent("appointmentdeselect",this,a);this.fireEvent("selectionchange",this,this.getSelections())}}});Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.TrackingTab=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.trackingtab",layout:{type:"vbox",align:"stretch"},border:false,items:[{xtype:"displayfield",value:_("The following responses for this meeting have been received")+":",hideLabel:true},{xtype:"grid",ref:"responseTrackList",flex:1,border:true,store:new Zarafa.core.data.IPMRecipientStore,viewConfig:{forceFit:true},
columns:[{dataIndex:"display_name",header:_("Name"),renderer:Ext.util.Format.htmlEncode,sortable:true},{dataIndex:"recipient_type",header:_("Attendance"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.recipienttype},{dataIndex:"recipient_trackstatus",header:_("Response"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.responsestatus}]}]});Zarafa.calendar.dialogs.TrackingTab.superclass.constructor.call(this,a)},update:function(a){(a=a.getSubStore("recipients"))&&this.responseTrackList.getStore()!==
a&&this.responseTrackList.reconfigure(a,this.responseTrackList.getColumnModel())}});Ext.reg("zarafa.trackingtab",Zarafa.calendar.dialogs.TrackingTab);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestConfirmationPanel=Ext.extend(Ext.form.FormPanel,{responseType:undefined,acceptInfoString:_("This meeting has been accepted and will be moved to your Calendar. Do you want to include comments with your response?"),tentativeAcceptInfoString:_("This meeting has been tentatively accepted and will be moved to your Calendar. Do you want to include comments with your response?"),declineInfoString:_("This meeting has been declined and will be moved to the Deleted Items folder. Do you want to include comments with your response?"),
constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestconfirmpanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",hideLabels:true,items:[{xtype:"displayfield",value:this.getDisplayText(a.responseType),autoHeight:true,style:"padding-bottom: 10px;"},{xtype:"radio",boxLabel:_("Edit the response before Sending."),name:"sendmrconfirmation",autoHeight:true,listeners:{check:this.onEditResponseChecked,scope:this}},{xtype:"textarea",
name:"responseText",ref:"responseTextField",disabled:true,flex:1},{xtype:"radio",boxLabel:_("Send the response now."),checked:true,name:"sendmrconfirmation",autoHeight:true},{xtype:"radio",boxLabel:_("Don't send a response."),name:"sendmrconfirmation",autoHeight:true}]});Zarafa.calendar.dialogs.SendMeetingRequestConfirmationPanel.superclass.constructor.call(this,a)},getDisplayText:function(a){switch(a){case Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED:return this.acceptInfoString;case Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE:return this.tentativeAcceptInfoString;
case Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED:return this.declineInfoString}return""},onEditResponseChecked:function(a,b){this.responseTextField.setDisabled(!b)},updateRecord:function(a){var b=this.getForm().getFieldValues();a.respondToMeetingRequest(this.responseType,b.responseText,b.sendmrconfirmation[2]!==true)},onResize:function(){Zarafa.calendar.dialogs.SendMeetingRequestConfirmationPanel.superclass.onResize.apply(this,arguments);this.doLayout()}});
Ext.reg("zarafa.sendmeetingrequestconfirmpanel",Zarafa.calendar.dialogs.SendMeetingRequestConfirmationPanel);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestCancellationPanel=Ext.extend(Ext.form.FormPanel,{cancellationInfoString:_("This meeting will be cancelled. Do you want to include comments with your cancellation?"),constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestcancellationpanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",hideLabels:true,items:[{xtype:"displayfield",value:this.cancellationInfoString,autoHeight:true,
style:"padding-bottom: 10px;"},{xtype:"radio",boxLabel:_("Edit the cancellation before Sending."),name:"sendmrcancellation",autoHeight:true,listeners:{check:this.onEditCancellationChecked,scope:this}},{xtype:"textarea",name:"cancellationText",ref:"cancellationTextField",disabled:true,flex:1},{xtype:"radio",boxLabel:_("Send the cancellation now."),checked:true,name:"sendmrcancellation",autoHeight:true}]});Zarafa.calendar.dialogs.SendMeetingRequestCancellationPanel.superclass.constructor.call(this,
a)},onEditCancellationChecked:function(a,b){this.cancellationTextField.setDisabled(!b)},updateRecord:function(a){var b=this.getForm().getFieldValues();a.cancelInvitation(b.cancellationText)},onResize:function(){Zarafa.calendar.dialogs.SendMeetingRequestCancellationPanel.superclass.onResize.apply(this,arguments);this.doLayout()}});Ext.reg("zarafa.sendmeetingrequestcancellationpanel",Zarafa.calendar.dialogs.SendMeetingRequestCancellationPanel);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.FreebusyTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.freebusytab",layout:{type:"vbox",align:"stretch"},border:false,defaults:{border:false},items:[this.createCounterProposalPanel(),this.createFreebusyPanel()]});Zarafa.calendar.dialogs.FreebusyTab.superclass.constructor.call(this,a);this.mon(this,"activate",this.onActivate,this)},createCounterProposalPanel:function(){return{xtype:"zarafa.counterproposalgrid",
ref:"counterproposalpanel",hidden:true,listeners:{scope:this,show:this.onProposalGridVisible}}},createFreebusyPanel:function(){return{xtype:"zarafa.freebusypanel",ref:"freebusyPanel",flex:1,modelConfig:{listeners:{selectorrangeupdate:this.onSelectorRangeUpdate,scope:this}},items:[this.createOptionsPanel()]}},createOptionsPanel:function(){return{xtype:"panel",region:"north",layout:"hbox",cls:"zarafa-freebusy-datetime-toolbar",border:false,autoHeight:true,items:[{xtype:"zarafa.datetimeperiodfield",
ref:"../../datetimePeriod",defaultPeriod:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period"),timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),flex:0.7,layout:"hbox",listeners:{change:this.onDateRangeFieldChange,scope:this},startFieldConfig:{fieldLabel:_("Start time"),labelWidth:100},endFieldConfig:{fieldLabel:_("End time"),labelWidth:100},spacerConfig:{width:10},height:25},{xtype:"spacer",width:10,height:25},{xtype:"checkbox",
ref:"../../workingHoursCheckbox",flex:0.3,height:25,boxLabel:_("Show only working hours"),handler:this.onOnlyWorkingHours,scope:this}]}},onProposalGridVisible:function(){this.doLayout()},onRender:function(a,b){Zarafa.calendar.dialogs.FreebusyTab.superclass.onRender.call(this,a,b);var c=this.freebusyPanel.getModel();this.workingHoursCheckbox.setValue(c.showOnlyWorkingHours());this.mon(c,"showworkinghourschange",this.onShowWorkingHoursChange,this)},onActivate:function(){if(this.record&&!this.record.isMeeting()&&
this.record.get("responsestatus")===Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE){this.record.set("meeting",Zarafa.core.mapi.MeetingStatus.MEETING);this.record.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED)}this.freebusyPanel.scrollTimelineToSelection();this.doLayout()},updateUI:function(a,b){if(b===true||a.isModifiedSinceLastUpdate("alldayevent"))a.get("alldayevent")?this.datetimePeriod.setEnabledTimeSelection(false):this.datetimePeriod.setEnabledTimeSelection(true)},update:function(a,
b){this.record=a;this.updateUI(a,b);this.getForm().loadRecord(a);var c=a.get("startdate"),d=false;if(Ext.isDate(c)){c=c.clone();d=b||a.isModifiedSinceLastUpdate("startdate")}var e=a.get("duedate"),f=false;if(Ext.isDate(e)){e=e.clone();f=b||a.isModifiedSinceLastUpdate("duedate")}if(a.get("alldayevent"))e=e.add(Date.DAY,-1);b===true&&this.freebusyPanel.setEditable(!a.isMeetingReceived());if(d||f)this.datetimePeriod.getValue().set(c,e);if(a.isOpened()){if(b===true||d||f)this.freebusyPanel.getModel().selectRange(a.get("startdate"),
a.get("duedate"));b===true&&this.freebusyPanel.getModel().setUserStore(a.getRecipientStore())}},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);this.updateStartDueDate(a,this.datetimePeriod.getValue());a.endEdit()},onSelectorRangeUpdate:function(a){this.record.beginEdit();this.record.get("alldayevent")===true&&!a.isAllDay()&&this.record.set("alldayevent",false);this.updateStartDueDate(this.record,a);this.record.endEdit()},onDateRangeFieldChange:function(a,b){this.updateStartDueDate(this.record,
b)},updateStartDueDate:function(a,b){var c=b.getStartDate().clone(),d=b.getDueDate().clone();if(a.get("alldayevent")===true){c=c.clearTime();d=d.add(Date.DAY,1).clearTime()}a.beginEdit();a.set("startdate",c);a.set("duedate",d);a.set("commonstart",c);a.set("commonend",d);a.set("duration",(d-c)/6E4);a.endEdit()},onShowWorkingHoursChange:function(a){this.workingHoursCheckbox.setValue(a)},onOnlyWorkingHours:function(a,b){this.freebusyPanel.getModel().hideNonWorkingHours(b)}});
Ext.reg("zarafa.freebusytab",Zarafa.calendar.dialogs.FreebusyTab);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.CounterProposalGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.counterproposalgrid",store:new Ext.data.JsonStore({root:"proposals",fields:["startdate","duedate","duration","display_name"]}),autoHeight:true,maxHeight:300,viewConfig:{forceFit:true},columns:this.initColumnModel(),selModel:this.initSelectionModel()});Zarafa.calendar.dialogs.CounterProposalGrid.superclass.constructor.call(this,
a)},initColumnModel:function(){return[{dataIndex:"startdate",header:_("Proposed Date and Time"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.datetime},{dataIndex:"duration",header:_("Duration"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.duration},{dataIndex:"display_name",header:_("Proposed By"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.text}]},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:true})},initEvents:function(){Zarafa.calendar.dialogs.CounterProposalGrid.superclass.initEvents.call(this);
this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this);this.mon(this,"viewready",this.onViewReady,this)},update:function(a,b){if(a.isOpened())if(this.record!==a){this.record=a;if(a.isMeetingOrganized()&&a.get("counter_proposal")){for(var c=a.getSubStore("recipients"),d={proposals:[]},e=0,f=c.getCount();e<f;e++){var g=c.getAt(e);if(g.isMeetingOrganizer()){var h=a.get("duration")?a.get("duration"):Date.diff(Date.MINUTE,a.get("duedate"),a.get("startdate"));g={display_name:_("Current Meeting Time"),
startdate:a.get("startdate"),duedate:a.get("duedate"),duration:h};d.proposals.push(g)}else if(g.get("proposednewtime")===true){h=Date.diff(Date.MINUTE,g.get("proposednewtime_end"),g.get("proposednewtime_start"));g={display_name:g.get("display_name"),startdate:g.get("proposednewtime_start"),duedate:g.get("proposednewtime_end"),duration:h};d.proposals.push(g)}}this.store.loadData(d);b&&this.getSelectionModel().selectFirstRow();this.setVisible(true)}}},onViewReady:function(){this.getSelectionModel().selectFirstRow()},
onSelectionChange:function(a){var b=a.getSelections();if(!Ext.isEmpty(b)&&b.length==1){this.record.beginEdit();a=b[0].get("startdate");b=b[0].get("duedate");this.record.set("startdate",a);this.record.set("duedate",b);this.record.set("commonstart",a);this.record.set("commonend",b);this.record.set("duration",(b-a)/6E4);this.record.endEdit()}}});Ext.reg("zarafa.counterproposalgrid",Zarafa.calendar.dialogs.CounterProposalGrid);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.AppointmentTab=Ext.extend(Ext.form.FormPanel,{trackingInfoString:pgettext("calendar.dialog","{0} attendees accepted, {1} tentatively accepted, {2} declined."),proposedTimeInfoString:pgettext("calendar.dialog","{0} attendees proposed a new time for this meeting. Click the Scheduling tab for details."),proposeNewTimeInfoString:pgettext("calendar.dialog","You proposed a new time for this meeting on {0}"),acceptedInfoString:pgettext("calendar.dialog","Accepted on {0}"),tentativeInfoString:pgettext("calendar.dialog",
"Tentatively Accepted on {0}"),elapsedTimeInfoString:pgettext("calendar.dialog","This appointment occurs in the past."),responseRequiredString:pgettext("calendar.dialog","Please respond."),noResponseReceivedString:pgettext("calendar.dialog","No responses have been received for this meeting."),meetingCanceledString:pgettext("calendar.dialog","Meeting has been canceled."),meetingUnsentString:pgettext("calendar.dialog","Invitations have not been sent for this meeting."),constructor:function(a){a=a||
{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.appointmenttab",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",defaults:{border:true,bodyStyle:"background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;",autoHeight:true},items:[this.createExtraInfoPanel(),this.createMeetingOrganizerPanel(),this.createRecipientPanel(),this.createInfoPanel(),this.createDatePanel(),
this.createRecurrencePanel(),this.createReminderPanel(),this.createAttachmentsPanel(),this.createBodyPanel()]});Zarafa.calendar.dialogs.AppointmentTab.superclass.constructor.call(this,a);this.mon(this,"activate",this.onActivate,this)},createExtraInfoPanel:function(){return{xtype:"container",cls:"zarafa-calendar-appointment-extrainfo",ref:"extraInfoPanel",autoHeight:true,defaults:{bodyStyle:"background-color: inherit;",border:false},hidden:true}},createMeetingOrganizerPanel:function(){return{xtype:"panel",
ref:"meetingOrganizerPanel",layout:"form",autoHeight:true,border:false,items:[{xtype:"displayfield",ref:"../meetingOrganizerField",fieldLabel:_("Organizer"),htmlEncode:true,flex:1}],hidden:true}},createRecipientPanel:function(){return{xtype:"panel",layout:"fit",ref:"recipientPanel",autoHeight:true,items:[{xtype:"zarafa.compositefield",anchor:"100%",autoHeight:true,items:[{xtype:"button",width:100,text:_("To")+":",handler:this.showRecipientDialog,scope:this},{xtype:"zarafa.recipientfield",ref:"../../recipientField",
flex:1}]}]}},createInfoPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.AppointmentLabels};return{xtype:"panel",layout:"form",autoHeight:true,items:[{xtype:"textfield",name:"subject",fieldLabel:_("Subject"),labelWidth:100,anchor:"100%",listeners:{change:this.onFieldChange,scope:this}},{xtype:"panel",layout:"hbox",border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"textfield",name:"location",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Location"),
labelWidth:100,flex:0.7,listeners:{change:this.onFieldChange,scope:this}},{xtype:"spacer",width:5},{xtype:"combo",name:"label",plugins:["zarafa.fieldlabeler"],flex:0.3,fieldLabel:_("Label"),labelWidth:100,store:a,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,tpl:new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item zarafa-calendar-appointment-{[this.getCSSLabel(values.value)]}">',"{name}","</div>",
"</tpl>",{getCSSLabel:function(b){b=Zarafa.core.mapi.AppointmentLabels.getName(b);b=b.toLowerCase();b=b.replace("_","-");return"label-"+b}}),listeners:{select:this.onFieldSelect,scope:this}}]}]}},createDatePanel:function(){return{xtype:"panel",layout:"hbox",ref:"datePanel",autoHeight:true,items:[{xtype:"zarafa.datetimeperiodfield",ref:"../datetimePeriod",defaultPeriod:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period"),timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),
width:300,listeners:{change:this.onDateRangeFieldChange,scope:this},startFieldConfig:{fieldLabel:_("Start time"),labelWidth:100},endFieldConfig:{fieldLabel:_("End time"),labelWidth:100}},{xtype:"spacer",width:10},{xtype:"panel",border:false,bodyStyle:"background-color: inherit;",items:[{xtype:"checkbox",name:"alldayevent",boxLabel:_("All Day Event"),handler:this.onToggleAllDay,scope:this}]}]}},createRecurrencePanel:function(){return{xtype:"panel",ref:"recurrencePanel",layout:"form",autoHeight:true,
items:[{xtype:"displayfield",ref:"../recurrencePatternField",fieldLabel:_("Recurrence"),htmlEncode:true,flex:1}]}},createReminderPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.ReminderPeriods},b={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.BusyStatus};return{xtype:"panel",layout:"fit",autoHeight:true,items:[{xtype:"zarafa.compositefield",autoHeight:true,items:[{xtype:"checkbox",name:"reminder",boxLabel:_("Reminder")+":",width:100,
bodyStyle:"padding-right: 3px",handler:this.onToggleReminder,scope:this},{xtype:"combo",ref:"../../comboReminder",name:"reminder_minutes",store:a,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,width:150,listeners:{select:this.onFieldSelect,scope:this}},{xtype:"spacer",width:10},{xtype:"combo",ref:"../../comboBusyStatus",name:"busystatus",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Busy Status"),labelWidth:100,width:150,store:b,
mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}}]}]}},createAttachmentsPanel:function(){return{xtype:"panel",layout:"fit",autoHeight:true,items:[{xtype:"container",layout:"hbox",anchor:"100%",autoHeight:true,items:[{xtype:"button",text:_("Attachments")+":",width:100,handler:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},scope:this},
{xtype:"spacer",width:5},{xtype:"zarafa.attachmentfield",ref:"../../attachmentField",flex:1,readOnly:true,hideLabel:true}]}]}},createBodyPanel:function(){return{xtype:"panel",layout:"fit",border:false,flex:1,autoHeight:false,items:[{xtype:"zarafa.editorfield",ref:"../editorField",hideLabel:true,flex:1,useHtml:false,listeners:{change:this.onBodyChange,scope:this}}]}},onActivate:function(){this.doLayout()},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("meeting")){switch(a.get("meeting")){case Zarafa.core.mapi.MeetingStatus.NONMEETING:default:this.dialog.closeOnSave=
true;this.dialog.closeOnSend=false;this.recipientPanel.setVisible(false);break;case Zarafa.core.mapi.MeetingStatus.MEETING:this.dialog.closeOnSave=false;this.dialog.closeOnSend=true;this.recipientPanel.setVisible(true);break;case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED:case Zarafa.core.mapi.MeetingStatus.MEETING_CANCELED:case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED_AND_CANCELED:if(a.get("responsestatus")!=Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE||a.get("responsestatus")!=Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED){this.meetingOrganizerPanel.setVisible(true);
this.recipientPanel.setVisible(false)}break}c=true}if(b===true||a.isModifiedSinceLastUpdate("alldayevent"))a.get("alldayevent")?this.datetimePeriod.setEnabledTimeSelection(false):this.datetimePeriod.setEnabledTimeSelection(true);if(b===true||a.isModifiedSinceLastUpdate("reminder"))a.get("reminder")?this.comboReminder.enable():this.comboReminder.disable();if(b===true||a.isModifiedSinceLastUpdate("recurring")){if(a.get("recurring")&&Ext.isEmpty(a.get("basedate"))){this.datePanel.setVisible(false);this.recurrencePanel.setVisible(true)}else{this.datePanel.setVisible(true);
this.recurrencePanel.setVisible(false);this.recurrencePatternField.setValue("")}c=true}if(b===true||a.isModifiedSinceLastUpdate("reminder"))if(a.get("alldayevent")){this.comboReminder.setValue(container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_allday_reminder_time"));this.comboBusyStatus.setValue(Zarafa.core.mapi.BusyStatus.FREE)}else{this.comboReminder.setValue(container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_reminder_time"));this.comboBusyStatus.setValue(Zarafa.core.mapi.BusyStatus.BUSY)}c&&
this.doLayout()},update:function(a,b){this.record=a;this.updateUI(a,b);this.getForm().loadRecord(a);var c=a.get("startdate"),d=false;if(Ext.isDate(c)){c=c.clone();d=b||a.isModifiedSinceLastUpdate("startdate")}var e=a.get("duedate"),f=false;if(Ext.isDate(e)){e=e.clone();f=b||a.isModifiedSinceLastUpdate("duedate")}if(a.get("alldayevent"))e=e.add(Date.DAY,-1);if(d||f)this.datetimePeriod.getValue().set(c,e);if(b&&a.isOpened()){this.recipientField.setRecipientStore(a.getRecipientStore());this.attachmentField.setAttachmentStore(a.getAttachmentStore());
this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()))}this.updateExtraInfoPanel();if(b===true||a.isModifiedSinceLastUpdate("recurring_pattern"))this.recurrencePatternField.setValue(a.get("recurring_pattern"))},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);this.updateStartDueDate(a,this.datetimePeriod.getValue());a.set("isHTML",this.editorField.isHtmlEditor());if(a.get("reminder")===true){a.set("reminder_time",a.get("startdate"));a.set("flagdueby",a.get("startdate").add(Date.MINUTE,
-a.get("reminder_minutes")))}a.get("isHTML")===true?a.set("html_body",this.editorField.getValue()):a.set("body",this.editorField.getValue());a.endEdit()},onFieldChange:function(a,b){this.record.set(a.getName(),b)},onBodyChange:function(a,b){this.record.beginEdit();if(a instanceof Ext.form.HtmlEditor){this.record.set("isHTML",true);this.record.set("html_body",b)}else{this.record.set("isHTML",false);this.record.set("body",b)}this.record.endEdit()},onFieldSelect:function(a,b){this.record.set(a.getName(),
b.get(a.valueField))},onDateRangeFieldChange:function(a,b){this.updateStartDueDate(this.record,b)},updateStartDueDate:function(a,b){var c=b.getStartDate().clone(),d=b.getDueDate().clone();if(a.get("alldayevent")===true){c=c.clearTime();d=d.add(Date.DAY,1).clearTime()}a.beginEdit();a.set("startdate",c);a.set("duedate",d);a.set("commonstart",c);a.set("commonend",d);a.set("duration",(d-c)/6E4);a.endEdit()},onToggleReminder:function(a,b){this.record.set("reminder",b)},onToggleAllDay:function(a,b){if(this.record.get("alldayevent")!==
b){this.record.beginEdit();this.record.set("alldayevent",b);if(b){this.updateStartDueDate(this.record,this.datetimePeriod.getValue());this.record.set("reminder_minutes",container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_allday_reminder_time"));this.record.set("busystatus",Zarafa.core.mapi.BusyStatus.FREE)}else{var c=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),d=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period"),
e=new Date;if(this.record.get("startdate"))e=this.record.get("startdate").clearTime(true);e=e.ceil(Date.MINUTE,c);c=e.add(Date.MINUTE,d);this.record.set("reminder_minutes",container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_reminder_time"));this.record.set("busystatus",Zarafa.core.mapi.BusyStatus.BUSY);this.record.set("startdate",e);this.record.set("duedate",c);this.record.set("commonstart",e);this.record.set("commonend",c);this.record.set("duration",(c-e)/6E4)}this.record.endEdit()}},
showRecipientDialog:function(){Zarafa.calendar.Actions.openRecipientSelectionDialog(this.record,Zarafa.core.mapi.RecipientType.MAPI_TO,this.dialog.isBrowser())},updateExtraInfoPanel:function(){var a=this.extraInfoPanel.getEl();if(Ext.isDefined(a.dom))a.dom.innerHTML="";var b=this.setOldAppointmentInfo(a);if(this.record.isRecurringOccurence())b=this.setRecurrencePatternInfo(a)===true?true:b;if(this.record.isMeeting())if(!this.record.phantom)if(this.record.isMeetingOrganized())b=this.record.isMeetingSent()?
this.setMeetingResponseInfo(a)===true?true:b:this.setMeetingUnsentInfo(a)===true?true:b;else{var c=this.record.get("responsestatus");c!==Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE&&this.setOrganizerInfo();if(this.record.isMeetingCanceled())b=this.setMeetingCanceledInfo(a)===true?true:b;else if(this.record.isMeetingResponseRequired())b=this.setReplyTimeInfo(c,a)===true?true:b}this.extraInfoPanel.setVisible(b);this.doLayout()},setMeetingResponseInfo:function(a){if(this.record.isMeetingSent())return false;
var b=0,c=0,d=0,e=0;this.record.getRecipientStore().each(function(g){switch(g.get("recipient_trackstatus")){case Zarafa.core.mapi.RecipientTrackStatus.RECIPIENT_TRACKSTATUS_TENTATIVE:c++;break;case Zarafa.core.mapi.RecipientTrackStatus.RECIPIENT_TRACKSTATUS_ACCEPTED:b++;break;case Zarafa.core.mapi.RecipientTrackStatus.RECIPIENT_TRACKSTATUS_DECLINED:d++;break}g.get("proposednewtime")&&e++},this);if(b!==0||c!==0||d!==0){var f=String.format(this.trackingInfoString,b,c,d);a.createChild({tag:"div",html:f});
if(this.record.get("counter_proposal")&&e!==0){f=String.format(this.proposedTimeInfoString,e);a.createChild({tag:"div",html:f})}}else a.createChild({tag:"div",html:this.noResponseReceivedString});return true},setReplyTimeInfo:function(a,b){var c="",d=this.record.get("reply_time"),e=this.record.get("duedate");if(a!==Zarafa.core.mapi.ResponseStatus.RESPONSE_NOT_RESPONDED){d=Ext.isDate(d)?d.format(_("jS F Y G:i")):_("None");if(this.record.get("counter_proposal"))c=String.format(this.proposeNewTimeInfoString,
d);else switch(a){case Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED:c=String.format(this.acceptedInfoString,d);break;case Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE:c=String.format(this.tentativeInfoString,d);break}}else if(Ext.isDate(e)&&e.getTime()>=(new Date).getTime())c=this.responseRequiredString;if(!Ext.isEmpty(c)){b.createChild({tag:"div",html:c});return true}return false},setOldAppointmentInfo:function(a){if(this.record.isAppointmentInPast()){a.createChild({tag:"div",html:this.elapsedTimeInfoString});
return true}return false},setOrganizerInfo:function(){var a=this.record.get("sender_entryid"),b=this.record.get("sent_representing_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b)&&Zarafa.core.EntryId.compareEntryIds(a,b)===false){a=this.record.get("sender_email_address");b=this.record.get("sent_representing_email_address");var c=this.record.get("sender_name"),d=this.record.get("sent_representing_name");if(!Ext.isEmpty(c)&&!Ext.isEmpty(d)){a=c;b=d}this.meetingOrganizerField.setValue(String.format(_("{0} on behalf of {1}"),
a,b))}else this.meetingOrganizerField.setValue(this.record.get("sender_name")||this.record.get("sender_email_address"))},setMeetingCanceledInfo:function(a){a.createChild({tag:"div",html:this.meetingCanceledString});return true},setMeetingUnsentInfo:function(a){a.createChild({tag:"div",html:this.meetingUnsentString});return true},setRecurrencePatternInfo:function(a){a.createChild({tag:"div",html:Ext.util.Format.htmlEncode(this.record.get("recurring_pattern"))});return true}});
Ext.reg("zarafa.appointmenttab",Zarafa.calendar.dialogs.AppointmentTab);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.AppointmentPanel=Ext.extend(Ext.Panel,{activeTab:undefined,enableNotifier:true,constructor:function(a){a=a||{};if(Ext.isDefined(a.activeTab))this.activeTab=a.activeTab;a=Ext.applyIf(a,{xtype:"zarafa.appointmentpanel",border:false,layout:"fit",items:this.createTabPanel(this.activeTab)});Zarafa.calendar.dialogs.AppointmentPanel.superclass.constructor.call(this,a)},createTabPanel:function(a){return[{xtype:"tabpanel",ref:"tabPanel",activeTab:a||0,border:false,plugins:["zarafa.recordcomponentupdaterplugin"],
update:this.onTabPanelUpdate.createDelegate(this),defaults:{bodyStyle:"padding: 5px;"},listeners:{render:this.onTabPanelRender,tabchange:this.onTabPanelChange,scope:this},items:[{xtype:"zarafa.appointmenttab",title:_("Appointment")},{xtype:"zarafa.freebusytab",title:_("Scheduling")},{xtype:"zarafa.trackingtab",title:_("Tracking"),ref:"../trackingTab"},container.populateInsertionPoint("context.calendar.appointmentdialog.tabs",this)]}]},onTabPanelUpdate:function(a){a.isMeetingSent()&&this.tabPanel.unhideTabStripItem(this.trackingTab)},
onTabPanelRender:function(){this.tabPanel.hideTabStripItem(this.trackingTab)},onTabPanelChange:function(a,b){if(b&&b.record){var c=b.record.getRecipientStore();if(c&&c.getCount()>0){this.mon(c,"update",this.onRecipientsChange,this);this.mon(c,"add",this.onRecipientsChange,this);this.mon(c,"remove",this.onRecipientsChange,this);this.mon(c,"datachanged",this.onRecipientsChange,this);if(this.enableNotifier){var d=c.getUnresolvedRecipients();c=c.getInvalidRecipients();if(!Ext.isEmpty(c)||!Ext.isEmpty(d)){container.getNotifier().notify("info.unresolved_recipients",
"",pgettext("calendar.dialog","Not all attendees could be resolved."),this.getEl(),"slideOut");this.enableNotifier=false}}}}},onRecipientsChange:function(){this.enableNotifier=true}});Ext.reg("zarafa.appointmentpanel",Zarafa.calendar.dialogs.AppointmentPanel);Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.SearchFields=[{name:_("All text fields"),value:"PR_SUBJECT PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS PR_BODY PR_DISPLAY_TO PR_DISPLAY_CC"},{name:_("Subject"),value:"PR_SUBJECT"},{name:_("Sender"),value:"PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS"},{name:_("Body"),value:"PR_BODY"},{name:_("Subject or Sender"),value:"PR_SUBJECT PR_SENDER_NAME PR_SENDER_EMAIL_ADDRESS PR_SENT_REPRESENTING_NAME PR_SENT_REPRESENTING_EMAIL_ADDRESS"},
{name:_("To or cc"),value:"PR_DISPLAY_TO PR_DISPLAY_CC"}];Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.ReminderPeriods=[{value:0,name:Ext.util.Format.duration(0)},{value:5,name:Ext.util.Format.duration(5)},{value:10,name:Ext.util.Format.duration(10)},{value:15,name:Ext.util.Format.duration(15)},{value:30,name:Ext.util.Format.duration(30)},{value:60,name:Ext.util.Format.duration(60)},{value:120,name:Ext.util.Format.duration(120)},{value:240,name:Ext.util.Format.duration(240)},{value:480,name:Ext.util.Format.duration(480)},{value:720,name:Ext.util.Format.duration(720)},{value:1080,
name:Ext.util.Format.duration(1080)},{value:1440,name:Ext.util.Format.duration(1440)},{value:2880,name:Ext.util.Format.duration(2880)},{value:4320,name:Ext.util.Format.duration(4320)},{value:5760,name:Ext.util.Format.duration(5760)},{value:7200,name:Ext.util.Format.duration(7200)},{value:10080,name:Ext.util.Format.duration(10080)},{value:20160,name:Ext.util.Format.duration(20160)},{value:40320,name:Ext.util.Format.duration(40320)}];Ext.namespace("Zarafa.calendar");
Zarafa.calendar.Actions={openAppointmentDialog:function(a,b,c,d){if(Ext.isEmpty(a)&&Ext.isDefined(b))a=b.createRecord();if(Ext.isArray(a))a=a[0];d!==true&&a.get("recurring")?Zarafa.common.Actions.openRecurringSelectionDialog(a,function(e,f){if(e=="ok"){a=f.id!=="recurrence_series"?a.convertToOccurenceRecord():a.convertToSeriesRecord();Zarafa.calendar.Actions.openAppointmentDialog(a,b,c,true)}}):Zarafa.common.Actions.openCreateRecord(a,{browser:c})},openAppointmentDialogToAcceptProposal:function(a,
b){if(Ext.isArray(a))a=a[0];var c=a.convertToAppointmentRecord(false);Ext.isDefined(c)?Zarafa.common.Actions.openCreateRecord(c,{useShadowStore:true,browser:b,activeTab:0,startDate:a.get("proposed_start_date"),dueDate:a.get("proposed_end_date"),duration:a.get("proposed_duration")}):container.getNotifier().notify("error",_("Error"),_("Could not accept proposal as this meeting is not available in calendar; It may have been moved or deleted")+".")},openAppointmentDialogToViewAllProposals:function(a,
b){if(Ext.isArray(a))a=a[0];var c=a.convertToAppointmentRecord();Ext.isDefined(c)?Zarafa.common.Actions.openCreateRecord(c,{useShadowStore:true,browser:b,activeTab:1}):container.getNotifier().notify("error",_("Error"),_("Could not view proposal as this meeting is not available in calendar; It may have been moved or deleted")+".")},openMeetingRequestDialog:function(a,b,c,d){if(Ext.isEmpty(a)&&Ext.isDefined(b))a=b.createRecord();if(Ext.isArray(a))a=a[0];if(a.phantom){a.set("meeting",Zarafa.core.mapi.MeetingStatus.MEETING);
a.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED)}Zarafa.calendar.Actions.openAppointmentDialog(a,b,c,d)},openProposeNewTimeDialog:function(a){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.proposenewtimedialog"],a,{autoSave:false,modal:true})},openRecipientSelectionDialog:function(a,b,c){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.recipientselection"],
a,{recipientButtonsCfg:[{text:_("Required")+":",type:Zarafa.core.mapi.RecipientType.MAPI_TO},{text:_("Optional")+":",type:Zarafa.core.mapi.RecipientType.MAPI_CC},{text:_("Resource")+":",type:Zarafa.core.mapi.RecipientType.MAPI_BCC}],defaultRecipientType:b,browser:c,listRestriction:{hide_distlist:true},modal:true})},openSendConfirmationDialog:function(a,b){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestconfirmation"],a,{record:a,responseType:b})},
openSendCancellationDialog:function(a){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestcancellation"],a,{record:a})},showMeetingInCalendar:function(a){var b=a.get("received_representing_entryid")||a.get("received_by_entryid")||a.get("sent_representing_entryid")||a.get("sender_entryid");b=container.getHierarchyStore().getStoreByOwnerEntryId(b);if(Ext.isDefined(b)){b=b.getDefaultFolder("calendar");if(Ext.isDefined(b)){container.selectFolder(b);
var c=container.getCurrentContext();b=c.getModel();c.switchView(Zarafa.calendar.data.Views.BLOCKS,Zarafa.calendar.data.ViewModes.DAYS);a=a.get("appointment_basedate")||a.get("appointment_startdate");b.setDataMode(Zarafa.calendar.data.DataModes.DAY);b.setDate(a)}else container.getNotifier().notify("error",_("Error"),_("Could not open default calendar folder."))}else container.getNotifier().notify("error",_("Error"),_("Could not open store."))}};Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookRecipientPanel=Ext.extend(Ext.Panel,{record:undefined,recipientButtonsCfg:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.addressbookrecipientpanel",border:false,bodyStyle:"padding: 5px;",items:[this.createRecipientSelectionField(a.recipientButtonsCfg)]});Zarafa.addressbook.ui.AddressBookRecipientPanel.superclass.constructor.call(this,a)},createRecipientSelectionField:function(a){if(!Ext.isDefined(a))return{};
Ext.isArray(a)||(a=[a]);var b=[];Ext.each(a,function(c,d){Ext.applyIf(c,{property:"field"+d});b.push({xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",items:[{xtype:"button",width:100,text:c.text,recipientType:c.type,recordType:c.recordType,handler:this.onRecipientButtonPressed,scope:this},{xtype:"zarafa.recipientfield",flex:1,height:50,ref:"../"+c.property,filterRecipientType:c.type,defaultRecipientType:c.type,recordType:c.recordType}]})},this);return b},update:function(a,b){if(a&&b&&a.isOpened()){var c=
a.getRecipientStore();Ext.each(this.recipientButtonsCfg,function(d){this[d.property].setRecipientStore(c)},this)}this.record=a},addRecipients:function(a,b){var c=this.record.getRecipientStore();Ext.each(a,function(d){d=d.convertToRecipient(b);c.add(d)},this)},onRecipientButtonPressed:function(a){this.addRecipients(this.ownerCt.getGridPanel().getSelectedItems(),a.recipientType,a.recordType)}});Ext.reg("zarafa.addressbookrecipientpanel",Zarafa.addressbook.ui.AddressBookRecipientPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookMainPanel=Ext.extend(Ext.Panel,{hierarchyStore:undefined,addressBookStore:undefined,hierarchyRestriction:undefined,listRestriction:undefined,singleSelect:false,constructor:function(a){a=a||{};if(!Ext.isDefined(a.hierarchyStore))a.hierarchyStore=new Zarafa.addressbook.AddressBookHierarchyStore;if(!Ext.isDefined(a.addressBookStore))a.addressBookStore=new Zarafa.addressbook.AddressBookStore;var b=a.items||[];a.items=[this.createHeaderPanel(a.hierarchyStore),this.createViewPanel(a.addressBookStore,
{singleSelect:a.singleSelect||this.singleSelect})].concat(b);Ext.applyIf(a,{xtype:"zarafa.addressbookmainpanel",border:false,bodyStyle:"padding: 5px;",layout:{type:"vbox",align:"stretch"}});Zarafa.addressbook.ui.AddressBookMainPanel.superclass.constructor.call(this,a);this.hierarchyStore.on("load",this.onHierarchyStoreLoad,this);this.on("afterlayout",this.onAfterLayout,this,{single:true})},createHeaderPanel:function(a){var b=new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">',"{depth:indent}{display_name:htmlEncode}",
"</div>","</tpl>",{compiled:true});return{xtype:"panel",height:50,border:false,layout:"hbox",items:[{xtype:"trigger",ref:"../searchText",flex:0.45,plugins:["zarafa.fieldlabeler"],fieldLabel:_("Type Name"),enableKeyEvents:true,triggerClass:"icon_search",triggerScope:this,onTriggerClick:this.onSearchButtonClick.createDelegate(this),wrapFocusClass:"",listeners:{scope:this,keyup:this.onSearchTextFiledKeyUp}},{xtype:"spacer",flex:0.1,height:10},{xtype:"combo",flex:0.45,plugins:["zarafa.fieldlabeler","zarafa.comboautowidth"],
fieldLabel:_("Show Names from the"),labelWidth:150,editable:false,mode:"local",triggerAction:"all",store:a,displayField:"display_name",valueField:"entryid",ref:"../addressBookSelectionCB",tpl:b,autoSelect:true,minListWidth:150,listeners:{select:this.onAddressBookChange,scope:this}}]}},createViewPanel:function(a,b){return Ext.apply(b,{xtype:"zarafa.addressbookviewpanel",hideLabel:true,name:"viewpanel",store:a,border:false,ref:"viewPanel",flex:1})},getGridPanel:function(){return this.viewPanel},onAddressBookChange:function(a,
b){var c={actionType:Zarafa.core.Actions.list,params:{subActionType:b.get("type")=="gab"?Zarafa.core.Actions.globaladdressbook:Zarafa.core.Actions.contacts,entryid:b.get("entryid"),store_entryid:b.get("store_entryid"),restriction:Ext.applyIf({},this.listRestriction)}};if(b.get("type")=="contacts")c.params.groups="yes";this.addressBookStore.load(c)},onAfterLayout:function(){var a;if(!this.hierarchyRestriction||this.hierarchyRestriction.hide_contacts!==true)a={stores:{store:Ext.pluck(container.getHierarchyStore().getStores(),
"id"),folder:[]}};this.hierarchyStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.hierarchy,gab:"all",contacts:a}});this.addressBookStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.globaladdressbook,restriction:Ext.applyIf({},this.listRestriction)}})},onHierarchyStoreLoad:function(){if(Ext.isDefined(this.addressBookSelectionCB))if(this.hierarchyStore.getCount()!=0){var a=this.hierarchyStore.getAt(0).get("entryid");Ext.isDefined(a)&&
this.addressBookSelectionCB.setValue(a)}},onSearchButtonClick:function(){this.addressBookStore.filter("display_name",this.searchText.getValue())},onSearchTextFiledKeyUp:function(a,b){b.getKey()==b.ENTER?this.onSearchButtonClick():this.addressBookStore.filter("display_name",a.getValue(),true)}});Ext.reg("zarafa.addressbookmainpanel",Zarafa.addressbook.ui.AddressBookMainPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.AddressBookMemberPanel=Ext.extend(Ext.Panel,{record:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.addressbookmemberpanel",border:false,bodyStyle:"padding: 5px;",items:[{xtype:"zarafa.compositefield",hideLabel:true,anchor:"100%",items:[{xtype:"button",width:100,text:_("Members")+":",handler:this.onMemberButtonPressed,scope:this},{xtype:"zarafa.memberboxfield",
flex:1,height:50,ref:"../memberField"}]}]});Zarafa.addressbook.dialogs.AddressBookMemberPanel.superclass.constructor.call(this,a)},update:function(a,b){a&&b&&a.isOpened()&&this.memberField.setMemberStore(a.getMemberStore(),b);this.record=a},addMembers:function(a){var b=this.record.getMemberStore();Ext.each(a,function(c){c=c.convertToDistlistMember();b.add(c)},this)},onMemberButtonPressed:function(){this.addMembers(this.ownerCt.getGridPanel().getSelectedItems())}});
Ext.reg("zarafa.addressbookmemberpanel",Zarafa.addressbook.dialogs.AddressBookMemberPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserPhoneTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abuserphonetab",title:_("Phone"),layout:{type:"vbox",align:"stretch"},autoScroll:true,items:[this.createPhonenumberFieldset(),this.createNoteFieldset()]});Zarafa.addressbook.dialogs.ABUserPhoneTab.superclass.constructor.call(this,a)},createPhonenumberFieldset:function(){return{xtype:"fieldset",
title:_("Phone numbers"),border:true,cls:"zarafa-fieldset",layout:"column",columnWidth:1,autoHeight:true,anchor:"100%",items:[{xtype:"container",layout:"form",columnWidth:0.5,border:false,defaults:{anchor:"100%",editable:false,readOnly:true},items:[{xtype:"textfield",fieldLabel:_("Business"),name:"business_telephone_number"},{xtype:"combo",mode:"local",fieldLabel:_("Business2"),store:new Zarafa.addressbook.AddressBookTelephoneNumberSubStore,autoSelect:true,forceSelection:true,lazyInit:false,editable:false,
readOnly:false,triggerAction:"all",displayField:"number",valueField:"number",ref:"../../business2PhoneCombo"},{xtype:"textfield",fieldLabel:_("Fax"),name:"primary_fax_number"},{xtype:"textfield",fieldLabel:_("Assistant"),name:"assistant"}]},{xtype:"container",layout:"form",columnWidth:0.5,border:false,defaults:{anchor:"100%",editable:false,readOnly:true},items:[{xtype:"textfield",fieldLabel:_("Home"),name:"home_telephone_number"},{xtype:"combo",mode:"local",fieldLabel:_("Home2"),store:new Zarafa.addressbook.AddressBookTelephoneNumberSubStore,
forceSelection:true,lazyInit:false,editable:false,readOnly:false,triggerAction:"all",displayField:"number",valueField:"number",ref:"../../home2PhoneCombo"},{xtype:"textfield",fieldLabel:_("Mobile"),name:"mobile_telephone_number"},{xtype:"textfield",fieldLabel:_("Pager"),name:"pager_telephone_number"}]}]}},createNoteFieldset:function(){return[{xtype:"displayfield",value:_("Notes")+":",hideLabel:true},{xtype:"textarea",hideLabel:true,name:"comment",readOnly:true,columnWidth:1,flex:1}]},update:function(a){this.getForm().loadRecord(a);
var b=a.getSubStore("business2_telephone_numbers");if(b&&this.business2PhoneCombo.getStore()!==b){this.business2PhoneCombo.bindStore(b);(b=b.getAt(0))&&this.business2PhoneCombo.setValue(b.get(this.business2PhoneCombo.valueField))}if((a=a.getSubStore("home2_telephone_numbers"))&&this.home2PhoneCombo.getStore()!==a){this.home2PhoneCombo.bindStore(a);(b=a.getAt(0))&&this.home2PhoneCombo.setValue(b.get(this.home2PhoneCombo.valueField))}}});Ext.reg("zarafa.abuserphonetab",Zarafa.addressbook.dialogs.ABUserPhoneTab);
Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserOrganizationTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abuserorganizationtab",title:_("Organization"),selModel:this.initSelectionModel(),layout:{type:"vbox",align:"stretch"},autoScroll:true,items:[this.createManagerFieldset(),this.createDirectReportFieldset()]});Zarafa.addressbook.dialogs.ABUserOrganizationTab.superclass.constructor.call(this,a)},
createManagerFieldset:function(){return[{xtype:"displayfield",value:_("Manager")+":",hideLabel:true},{xtype:"zarafa.abitemgrid",ref:"managerList",autoHeight:true}]},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false})},createDirectReportFieldset:function(){return[{xtype:"displayfield",value:_("Direct reports")+":",hideLabel:true},{xtype:"zarafa.abitemgrid",ref:"reportList",flex:1}]},update:function(a){this.getForm().loadRecord(a);var b=a.getSubStore("ems_ab_manager");
b&&this.managerList.getStore()!==b&&this.managerList.reconfigure(b,this.managerList.getColumnModel());(a=a.getSubStore("ems_ab_reports"))&&this.reportList.getStore()!==a&&this.reportList.reconfigure(a,this.reportList.getColumnModel())}});Ext.reg("zarafa.abuserorganizationtab",Zarafa.addressbook.dialogs.ABUserOrganizationTab);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserGeneralTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abusergeneraltab",title:_("General"),layout:"column",autoScroll:true,items:[this.createNameFieldset(),this.createAddressFieldset(),this.createOfficeFieldset()]});Zarafa.addressbook.dialogs.ABUserGeneralTab.superclass.constructor.call(this,a)},createNameFieldset:function(){return{xtype:"fieldset",
columnWidth:1,border:true,cls:"zarafa-fieldset",title:_("Name"),layout:"column",anchor:"100%",items:[{xtype:"container",layout:"form",columnWidth:0.5,border:false,items:[{xtype:"container",layout:"column",anchor:"100%",border:false,defaults:{anchor:"100%",readOnly:true},items:[{columnWidth:0.7,xtype:"textfield",fieldLabel:_("First"),name:"given_name",plugins:[Ext.ux.FieldLabeler]},{xtype:"spacer",width:6,height:3},{xtype:"textfield",columnWidth:0.3,labelWidth:50,fieldLabel:_("Initial"),name:"initials",
plugins:[Ext.ux.FieldLabeler]}]},{xtype:"container",layout:"column",anchor:"100%",border:false,items:[{xtype:"textfield",columnWidth:0.7,readOnly:true,style:"margin-top: 3px;",fieldLabel:_("Display"),plugins:[Ext.ux.FieldLabeler],name:"display_name"},{xtype:"spacer",width:6,height:3}]}]},{xtype:"container",layout:"form",cls:"zarafa-fieldset-second",columnWidth:0.5,border:false,defaults:{anchor:"100%",readOnly:true},items:[{xtype:"textfield",fieldLabel:_("Last"),name:"surname"},{xtype:"textfield",
fieldLabel:_("Alias"),name:"account"}]}]}},createAddressFieldset:function(){return{xtype:"fieldset",cls:"zarafa-fieldset",defaultType:"textfield",border:false,columnWidth:0.5,defaults:{anchor:"100%",readOnly:true},items:[{xtype:"textarea",fieldLabel:_("Address"),name:"street_address",height:"40px"},{fieldLabel:_("City"),name:"locality"},{fieldLabel:_("State"),name:"state_or_province"},{fieldLabel:_("Zip Code"),name:"postal_code"},{fieldLabel:_("Country"),name:"country"}]}},createOfficeFieldset:function(){return{xtype:"fieldset",
cls:"zarafa-fieldset-second",defaultType:"textfield",border:false,columnWidth:0.5,defaults:{anchor:"100%",readOnly:true},items:[{fieldLabel:_("Title"),name:"title"},{fieldLabel:_("Company"),name:"company_name"},{fieldLabel:_("Department"),name:"department_name"},{fieldLabel:_("Office"),name:"office_location"},{fieldLabel:_("Assistant"),name:"assistant"},{fieldLabel:_("Phone"),name:"business_telephone_number"}]}},update:function(a){Ext.isEmpty(a)||this.getForm().loadRecord(a)}});
Ext.reg("zarafa.abusergeneraltab",Zarafa.addressbook.dialogs.ABUserGeneralTab);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserDetailPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abuserdetailpanel",border:false,activeTab:0,items:[{xtype:"zarafa.abusergeneraltab"},{xtype:"zarafa.abuserorganizationtab"},{xtype:"zarafa.abuserphonetab"},{xtype:"zarafa.abmemberoftab"},{xtype:"zarafa.abemailaddresstab"}]});Zarafa.addressbook.dialogs.ABUserDetailPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.abuserdetailpanel",Zarafa.addressbook.dialogs.ABUserDetailPanel);
Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABMemberOfTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abmemberoftab",title:_("Member Of"),layout:{type:"vbox",align:"stretch"},items:[{xtype:"displayfield",value:_("Group Membership")+":",hideLabel:true},{xtype:"zarafa.abitemgrid",ref:"memberOfList",flex:1}]});Zarafa.addressbook.dialogs.ABMemberOfTab.superclass.constructor.call(this,a)},
update:function(a){this.getForm().loadRecord(a);(a=a.getSubStore("ems_ab_is_member_of_dl"))&&this.memberOfList.getStore()!==a&&this.memberOfList.reconfigure(a,this.memberOfList.getColumnModel())}});Ext.reg("zarafa.abmemberoftab",Zarafa.addressbook.dialogs.ABMemberOfTab);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABItemGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{viewConfig:{forceFit:true},store:new Zarafa.addressbook.AddressBookSubStore,colModel:new Ext.grid.ColumnModel({columns:[{dataIndex:"display_type",header:'<p class="icon_index">&nbsp;</p>',width:25,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{header:_("Display Name"),dataIndex:"display_name",renderer:Ext.util.Format.htmlEncode,sortable:false},{header:_("Email Address"),
dataIndex:"smtp_address",renderer:Ext.util.Format.htmlEncode,sortable:false},{header:_("Account"),dataIndex:"account",renderer:Ext.util.Format.htmlEncode,sortable:false}]})});Zarafa.addressbook.dialogs.ABItemGrid.superclass.constructor.call(this,a);this.mon(this,"rowdblclick",this.onRowDblClick,this)},onRowDblClick:function(a,b){var c=this.getStore().getAt(b);c&&Zarafa.common.Actions.openViewRecord(c)}});Ext.reg("zarafa.abitemgrid",Zarafa.addressbook.dialogs.ABItemGrid);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABGroupGeneralTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abgroupgeneraltab",title:_("General"),layout:"column",autoScroll:true,items:[this.createNameFieldset(),this.createMembersFieldset()]});Zarafa.addressbook.dialogs.ABGroupGeneralTab.superclass.constructor.call(this,a)},createNameFieldset:function(){return{xtype:"fieldset",columnWidth:0.5,
border:false,cls:"zarafa-fieldset",autoHeight:true,items:[{xtype:"textfield",fieldLabel:_("Display Name"),name:"display_name",anchor:"100%",border:false,readOnly:true},{xtype:"textfield",fieldLabel:_("Alias"),name:"account",anchor:"100%",border:false,readOnly:true},{xtype:"displayfield",value:_("Owner")+":",hideLabel:true},{xtype:"zarafa.abitemgrid",ref:"../ownerList",anchor:"100%",bwrapStyle:"width: 100%",autoHeight:true,border:false},{xtype:"displayfield",value:_("Notes")+":",hideLabel:true},{xtype:"textarea",
hideLabel:true,name:"comment",flex:1,anchor:"100%",border:false,readOnly:true}]}},createMembersFieldset:function(){return{xtype:"fieldset",columnWidth:0.5,border:true,title:_("Members"),cls:"zarafa-fieldset",autoHeight:true,items:[{xtype:"zarafa.abitemgrid",autoWidth:true,border:true,height:225,ref:"../groupMembersList",flex:1,readOnly:true}]}},update:function(a){this.getForm().loadRecord(a);var b=a.getSubStore("members");b&&this.groupMembersList.getStore()!==b&&this.groupMembersList.reconfigure(b,
this.groupMembersList.getColumnModel());(a=a.getSubStore("ems_ab_owner"))&&this.ownerList.getStore()!==a&&this.ownerList.reconfigure(a,this.ownerList.getColumnModel())}});Ext.reg("zarafa.abgroupgeneraltab",Zarafa.addressbook.dialogs.ABGroupGeneralTab);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABGroupDetailPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abgroupdetailpanel",border:false,activeTab:0,items:[{xtype:"zarafa.abgroupgeneraltab"},{xtype:"zarafa.abmemberoftab"},{xtype:"zarafa.abemailaddresstab"}]});Zarafa.addressbook.dialogs.ABGroupDetailPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.abgroupdetailpanel",Zarafa.addressbook.dialogs.ABGroupDetailPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABEmailAddressTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.abemailaddresstab",title:_("E-mail Addresses"),layout:{type:"vbox",pack:"start",align:"stretch"},items:[{xtype:"displayfield",value:_("E-mail addresses")+":",hideLabel:true},{xtype:"panel",flex:1,items:[{xtype:"listview",store:new Ext.data.Store,ref:"../emailList",hideHeaders:true,
singleSelect:false,anchor:"100% 100%",columns:[{dataIndex:"address",tpl:"{address:htmlEncode}"}]}]}]});Zarafa.addressbook.dialogs.ABEmailAddressTab.superclass.constructor.call(this,a)},update:function(a){this.getForm().loadRecord(a);(a=a.getSubStore("ems_ab_proxy_addresses"))&&this.emailList.getStore()!==a&&this.emailList.bindStore(a)}});Ext.reg("zarafa.abemailaddresstab",Zarafa.addressbook.dialogs.ABEmailAddressTab);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.Actions={openAddressBook:function(a){Zarafa.core.ui.Dialog.openDialogComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"],undefined,{browser:a})},openDetailsDialog:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];Zarafa.common.Actions.openViewRecord(a,{browser:b})},openMailDialog:function(a,b){Ext.isArray(a)||(a=[a]);var c=container.getHierarchyStore().getDefaultFolder("drafts");c=Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Note",
{store_entryid:c.get("store_entryid"),parent_entryid:c.get("entryid")});for(var d=c.getRecipientStore(),e=0,f=a.length;e<f;e++)d.add(a[e].convertToRecipient(Zarafa.core.mapi.RecipientType.MAPI_TO,true));Zarafa.common.Actions.openCreateRecord(c,{browser:b})}};Ext.namespace("Zarafa");
Zarafa.Translations={msg:_("The quick brown fox jumps over the lazy dog"),SplitTranslation:function(a,b){if(!Ext.isDefined(b))return a;var c=a.indexOf(b);if(c==-1)return a;for(var d=c-1;a[d]==" "&&d>=0;)d--;for(c=c+b.length;a[c]==" "&&c<a.length;)c++;return[a.substr(0,d+1),a.substr(c)]},MultiSplitTranslation:function(a,b){Ext.isArray(b)||(b=[b]);var c=new Ext.util.MixedCollection;c.add(a);for(var d=0;d<b.length;d++)c.each(function(e,f){var g=Zarafa.Translations.SplitTranslation(e,b[d]);if(!Ext.isArray(g))return true;
c.removeAt(f);if(!Ext.isEmpty(g[0])){c.insert(f,g[0]);f++}c.insert(f,b[d]);f++;Ext.isEmpty(g[1])||c.insert(f,g[1]);return false});return c.getRange()}};Ext.apply(Date,{dayNames:[_("Sunday"),_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday")],monthNames:[_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December")]});
Ext.PagingToolbar.tmpPageText=Zarafa.Translations.SplitTranslation(_("Page {A} of {0}"),"{A}");Ext.override(Ext.PagingToolbar,{displayMsg:_("Displaying messages {0} - {1} of {2}"),emptyMsg:_("No messages to display"),beforePageText:Ext.PagingToolbar.tmpPageText[0],afterPageText:Ext.PagingToolbar.tmpPageText[1],firstText:_("First Page"),prevText:_("Previous Page"),nextText:_("Next Page"),lastText:_("Last Page"),refreshText:_("Refresh")});delete Ext.PagingToolbar.tmpPageText;
Ext.override(Ext.DatePicker,{todayText:_("Today"),okText:"&nbsp;"+_("OK")+"&nbsp;",cancelText:_("Cancel"),todayTip:_("{0} (Spacebar)"),minText:_("This date is before the minimum date"),maxText:_("This date is after the maximum date"),format:_("d/m/Y"),disabledDaysText:_("Disabled"),disabledDatesText:_("Disabled"),nextText:_("Next Month (Control+Right)"),prevText:_("Previous Month (Control+Left)"),monthYearText:_("Choose a month (Control+Up/Down to move years)")});
Ext.override(Ext.form.HtmlEditor,{createLinkText:_("Please enter the URL for the link")+":",buttonTips:{bold:{title:_("Bold (Ctrl+B) text"),text:_("Make the selected text bold."),cls:"x-html-editor-tip"},italic:{title:_("Italic (Ctrl+I)"),text:_("Make the selected text italic."),cls:"x-html-editor-tip"},underline:{title:_("Underline (Ctrl+U)"),text:_("Underline the selected text."),cls:"x-html-editor-tip"},increasefontsize:{title:_("Grow Text"),text:_("Increase the font size."),cls:"x-html-editor-tip"},
decreasefontsize:{title:_("Shrink Text"),text:_("Decrease the font size."),cls:"x-html-editor-tip"},backcolor:{title:_("Text Highlight Color"),text:_("Change the background color of the selected text."),cls:"x-html-editor-tip"},forecolor:{title:_("Font Color"),text:_("Change the color of the selected text."),cls:"x-html-editor-tip"},justifyleft:{title:_("Align Text Left"),text:_("Align text to the left."),cls:"x-html-editor-tip"},justifycenter:{title:_("Center Text"),text:_("Center text in the editor."),
cls:"x-html-editor-tip"},justifyright:{title:_("Align Text Right"),text:_("Align text to the right."),cls:"x-html-editor-tip"},insertunorderedlist:{title:_("Bullet List"),text:_("Start a bulleted list."),cls:"x-html-editor-tip"},insertorderedlist:{title:_("Numbered List"),text:_("Start a numbered list."),cls:"x-html-editor-tip"},createlink:{title:_("Hyperlink"),text:_("Make the selected text a hyperlink."),cls:"x-html-editor-tip"},sourceedit:{title:_("Source Edit"),text:_("Switch to source editing mode."),
cls:"x-html-editor-tip"}}});Ext.override(Ext.grid.GridView,{sortAscText:_("Sort Ascending"),sortDescText:_("Sort Descending"),columnsText:_("Columns")});Ext.override(Ext.grid.GroupingView,{groupByText:_("Group By This Field"),showGroupsText:_("Show in Groups"),emptyGroupText:_("(None)")});Ext.MessageBox.buttonText.ok=_("Ok");Ext.MessageBox.buttonText.cancel=_("Cancel");Ext.MessageBox.buttonText.yes=_("Yes");Ext.MessageBox.buttonText.no=_("No");Ext.override(Ext.LoadMask,{msg:_("Loading")+"..."});
Ext.override(Ext.form.ComboBox,{loadingText:_("Loading")+"..."});Ext.override(Ext.form.Field,{invalidText:_("The value in this field is invalid")});Ext.override(Ext.form.TextField,{minLengthText:_("The minimum length for this field is {0}"),maxLengthText:_("The maximum length for this field is {0}"),blankText:_("This field is required")});Ext.override(Ext.form.NumberField,{minText:_("The minimum value for this field is {0}"),maxText:_("The maximum value for this field is {0}"),nanText:_("{0} is not a valid number")});
Ext.override(Ext.form.DateField,{format:_("d/m/Y"),disabledDaysText:_("Disabled"),disabledDatesText:_("Disabled"),minText:_("The date in this field must be equal to or after {0}"),maxText:_("The date in this field must be equal to or before {0}"),invalidText:_("{0} is not a valid date - it must be in the format {1}")});Ext.override(Ext.form.CheckboxGroup,{blankText:_("You must select at least one item in this group")});Ext.override(Ext.form.RadioGroup,{blankText:_("You must select one item in this group")});
Ext.override(Ext.form.TimeField,{minText:_("The time in this field must be equal to or after {0}"),maxText:_("The time in this field must be equal to or before {0}"),invalidText:_("{0} is not a valid time"),format:_("G:i")});Ext.override(Ext.grid.GridView,{sortAscText:_("Sort Ascending"),sortDescText:_("Sort Descending"),columnsText:_("Columns")});Ext.override(Ext.grid.PropertyColumnModel,{nameText:_("Name"),valueText:_("Value"),dateFormat:_("d/m/Y"),trueText:_("true"),falseText:_("false")});
Ext.override(Ext.form.VTypes,{emailText:_('This field should be an e-mail address in the format "user@example.com"'),urlText:String.format(_('This field should be a URL in the format "{0}"'),"http://www.example.com"),alphaText:_("This field should only contain letters and _"),alphanumText:_("This field should only contain letters, numbers and _")});Ext.namespace("Zarafa.common.freebusy.data");
Zarafa.common.freebusy.data.FreebusyBlockRecord=Ext.data.Record.create([{name:"userid"},{name:"start",type:"int"},{name:"end",type:"int"},{name:"status",type:"int"}]);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.ColorSchemes=[{name:"blue",header:"#a5bee7",border:"#5a8ece",borderInner:"#8caede",stripnormal:"#e7eff7",stripworking:"#ffffff",linenormal:"#d6e3f7",lineworking:"#e7eff7",hourline:"#a5bee7"},{name:"green",header:"#b5cfa5",border:"#73a65a",borderInner:"#9cbe8c",stripnormal:"#eff3e7",stripworking:"#ffffff",linenormal:"#deebd6",lineworking:"#eff3e7",hourline:"#b5cfa5"},{name:"pink",header:"#deaebd",border:"#bd6984",borderInner:"#d696ad",stripnormal:"#f7ebef",stripworking:"#ffffff",
linenormal:"#efdbe7",lineworking:"#f7ebef",hourline:"#deaebd"},{name:"purple",header:"#bdaee7",border:"#8c6dce",borderInner:"#ad9ade",stripnormal:"#efebf7",stripworking:"#ffffff",linenormal:"#e7dbf7",lineworking:"#efebf7",hourline:"#bdaee7"},{name:"yellow",header:"#ffe79c",border:"#ffd352",borderInner:"#ffdf84",stripnormal:"#fffbe7",stripworking:"#ffffff",linenormal:"#fff7d6",lineworking:"#fffbe7",hourline:"#ffe79c"},{name:"green2",header:"#a5cfb5",border:"#5aa673",borderInner:"#8cc39c",stripnormal:"#e7f3ef",
stripworking:"#ffffff",linenormal:"#d6ebde",lineworking:"#e7f3ef",hourline:"#a5cfb5"},{name:"ice",header:"#cedbef",border:"#a5bee7",borderInner:"#b5b6bd",stripnormal:"#e7eff7",stripworking:"#ffffff",linenormal:"#dee3ef",lineworking:"#e7eff7",hourline:"#a5bee7"}];
Zarafa.calendar.ui.LabelColorSchemes=[Zarafa.calendar.ui.ColorSchemes[2],Zarafa.calendar.ui.ColorSchemes[0],Zarafa.calendar.ui.ColorSchemes[1],Zarafa.calendar.ui.ColorSchemes[6],Zarafa.calendar.ui.ColorSchemes[4],Zarafa.calendar.ui.ColorSchemes[3],Zarafa.calendar.ui.ColorSchemes[5]];Ext.onReady(function(){Ext.getBody().on("contextmenu",function(a,b){Ext.get(b).hasClass("zarafa-contextmenu-enabled")||a.preventDefault()},null);Ext.QuickTips.init()});
Ext.onReady(function(){container=new Zarafa.core.Container;container.getSettingsModel().initialize(settings);delete settings;container.setUser(user);delete user;container.setLanguages(languages);delete languages;Ext.state.Manager.setProvider(new Zarafa.core.data.SettingsStateProvider);Zarafa.fireReady();Zarafa.core.data.IPMStoreMgr.on("storeexception",onStoreException);container.getResponseRouter().on("receiveexception",onReceiveException);container.getHierarchyStore().on("load",onHierarchyLoad,{single:true});
window.onbeforeunload=function(){container.paralyze()};container.getHierarchyStore().startKeepAlive();container.getReminderStore().initializeReminderInterval();var a=container.getSettingsModel().get("zarafa/v1/main/default_context");(a=container.getContextByName(a))||(a=container.getContextByName("today"));container.switchContext(a);container.getHierarchyStore().load()},{single:true});
function onStoreException(a,b,c,d,e,f,g){if(c==="response")if(Ext.isDefined(g)&&g.error instanceof Error)a=g.error.toString();else{onReceiveException(e,f);return}else if(f&&f.error)switch(f.error.type){case Zarafa.core.ErrorType.MAPI:case Zarafa.core.ErrorType.ZARAFA:case Zarafa.core.ErrorType.GENERAL:a=f.error.info.display_message;break;default:a=_("The server reported an unknown error on your request.");break}else a=_("The server reported an unspecified error on your request.");container.getNotifier().notify("error.store",
_("Error"),a)}function onReceiveException(a,b){var c=Ext.get("loading"),d,e;if(b.status===0){d=_("Error");e=_("The connection was interrupted.")}else if(b.status!==200){d=String.format(_("HTTP {0}"),b.status);e=b.statusText}else{d=_("Error");e=_("Invalid data received from the server")}c?setErrorLoadingMask(d,e):container.getNotifier().notify("error.json",d,e)}
function hideLoadingMask(){var a=Ext.get("loading-mask"),b=Ext.get("loading");if(a&&b){b.fadeOut({duration:0.2,remove:true});a.setOpacity(0.9);a.shift({xy:b.getXY(),width:b.getWidth(),height:b.getHeight(),remove:true,duration:2,opacity:0.1,easing:"bounceOut"})}}function setErrorLoadingMask(a,b){var c=new Ext.Template("<div><b>{title}</b><br />{msg}</div>",{compiled:true,disableFormats:true}),d=Ext.get("loading-message");if(d){d.dom.className="loading-error";c.overwrite(d,{title:a,msg:b})}}
function onHierarchyLoad(a,b){if(Ext.isEmpty(b))setErrorLoadingMask(_("Error"),_("Loading model from server failed"));else{container.getMainPanel();hideLoadingMask()}}
if(document.createElement("canvas").getContext){CanvasRenderingContext2D.prototype.roundedRect=function(a,b,c,d,e){this.beginPath();this.moveTo(a,b+e);this.arc(a+e,b+e,e,Math.PI,3*Math.PI/2,false);this.lineTo(a+c-e,b);this.arc(a+c-e,b+e,e,3*Math.PI/2,0,false);this.lineTo(a+c,b+d-e);this.arc(a+c-e,b+d-e,e,0,Math.PI/2,false);this.lineTo(a+e,b+d);this.arc(a+e,b+d-e,e,Math.PI/2,Math.PI,false);this.lineTo(a,b+e);this.closePath()};CanvasRenderingContext2D.prototype.roundedRect2=function(a,b,c,d,e,f,g,h){this.beginPath();
this.arc(a+e,b+e,e,Math.PI,3*Math.PI/2,false);this.lineTo(a+c-f,b);this.arc(a+c-f,b+f,f,3*Math.PI/2,0,false);this.lineTo(a+c,b+d-g);this.arc(a+c-g,b+d-g,g,0,Math.PI/2,false);this.lineTo(a+h,b+d);this.arc(a+h,b+d-h,h,Math.PI/2,Math.PI,false);this.lineTo(a,b+e);this.closePath()};CanvasRenderingContext2D.prototype.circle=function(a,b,c){this.beginPath();this.arc(a,b,c,0,Math.PI*2,true);this.closePath()};CanvasRenderingContext2D.prototype.fillRoundedRect=function(a,b,c,d,e){this.roundedRect(a,b,c,d,e);
this.fill()};CanvasRenderingContext2D.prototype.strokeRoundedRect=function(a,b,c,d,e){this.roundedRect(a,b,c,d,e);this.fill()};CanvasRenderingContext2D.prototype.strokeLine=function(a,b,c,d){this.beginPath();this.moveTo(a,b);this.lineTo(c,d);this.stroke()};CanvasRenderingContext2D.prototype.setFont=function(a){if(this.fillText)this.font=a;else this.mozTextStyle=a};CanvasRenderingContext2D.prototype.drawText=function(a,b,c,d){if(this.fillText)d?this.fillText(a,b,c,d):this.fillText(a,b,c);else if(this.mozDrawText){this.save();
this.translate(b,c);this.mozDrawText(a);this.restore()}};CanvasRenderingContext2D.prototype.drawWrappedText=function(a,b,c,d,e,f,g,h){a=a.split(" ");var i=this.textWidth(" ");g=g||0;h=h||0;var j=b+g;c=c;for(var k=0,m=a.length;k<m;k++){var l=a[k],n=this.textWidth(l);if(j+n/2>=d&&j!=b){c+=e;if(c>h)g=0;j=b+g;if(c>f)break}this.drawText(l,j,c);j+=n+i}return c};CanvasRenderingContext2D.prototype.textHeight=function(a,b,c){a=a.split(" ");for(var d=this.textWidth(" "),e=0,f=0,g=0,h=a.length;g<h;g++){var i=
this.textWidth(a[g]);if(e+i>=b&&e!=0){e=0;f+=c}e+=i+d}f+=c;return f};CanvasRenderingContext2D.prototype.textWidth=function(a){if(this.measureText)return this.measureText(a).width;if(this.mozMeasureText)return this.mozMeasureText(a);return 0}}Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.WidgetPanel=Ext.extend(Zarafa.core.ui.MainViewSidebar,{settingsPath:"",showDefaultWidgets:undefined,numColumns:3,portal:undefined,constructor:function(a){a=a||{};for(var b=[],c=a.numColumns||this.numColumns,d=0;d<c;d++)b.push(new Ext.ux.PortalColumn({columnWidth:1/c,style:"padding:10px 10px 10px 10px"}));c=[{id:"plus",scope:this,handler:function(){Zarafa.core.ui.widget.WidgetDialog.create({widgetPanel:this})}}];this.portal=new Ext.ux.Portal({items:b,border:false,dropConfig:{ddGroup:"dd.widget"}});
Ext.applyIf(a,{cls:"zarafa-widgetpanel",headerCfg:{cls:"zarafa-main-header x-panel-header"},layout:"fit",tools:c,items:[this.portal]});Zarafa.core.ui.widget.WidgetPanel.superclass.constructor.call(this,a);this.loadWidgets();this.mon(this.portal,{drop:this.onDrop,scope:this})},onDrop:function(a){var b=a.panel;if(b.widgetPanel!=this){b.widgetPanel.removeGuid(b.guid);this.addGuid(b.guid);b.widgetPanel=this}a.source.proxy.hide();b.doLayout(true);b.columnIndex!=a.columnIndex&&b.set("columnIndex",a.columnIndex)},
loadWidgets:function(){var a=container.getSettingsModel(),b=a.get(this.settingsPath+"/guids"),c=[];if(Ext.isDefined(b)){if(!Ext.isEmpty(b)){Ext.each(b.split(/\W+/),function(d){if(!Ext.isEmpty(d)){var e=a.get(Zarafa.core.ui.widget.Widget.settingsPath(d,"__name"));if(e=container.getWidgetByName(e)){e=new e({widgetPanel:this,guid:d});this.portal.get((e.get("columnIndex")||0)%this.numColumns).add(e);c.push(d)}else a.remove(Zarafa.core.ui.widget.Widget.settingsPath(d,""))}},this);a.set(this.settingsPath+
"/guids",c.join(" "))}}else if(Ext.isArray(this.showDefaultWidgets))for(b=0;b<this.showDefaultWidgets.length;b++)this.createWidget(this.showDefaultWidgets[b])},addGuid:function(a){var b=container.getSettingsModel(),c=b.get(this.settingsPath+"/guids")||"";c+=(c==""?"":" ")+a;b.set(this.settingsPath+"/guids",c)},removeGuid:function(a){var b=container.getSettingsModel(),c=b.get(this.settingsPath+"/guids");c=c.replace(a,"");c=c.replace(/\W+/," ");b.set(this.settingsPath+"/guids",c)},createWidget:function(a){var b=
container.getWidgetByName(a);if(b){var c=Zarafa.generateId(32);this.addGuid(c);b=new b({widgetPanel:this,guid:c});b.set("__name",a);this.portal.get(0).add(b);this.doLayout()}},destroyWidget:function(a){this.removeGuid(a.guid);container.getSettingsModel().remove(Zarafa.core.ui.widget.Widget.settingsPath(a.guid,""));a.ownerCt.remove(a,true)}});Ext.reg("zarafa.widgetpanel",Zarafa.core.ui.widget.WidgetPanel);Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.WidgetDialog=Ext.extend(Zarafa.core.ui.Dialog,{widgetPanel:undefined,constructor:function(a){a=a||{};var b=new Ext.XTemplate('<tpl for=".">','<div class="zarafa-widget-item" id="{name}">','<div class="thumb-wrap">','<img src="{icon}">',"</div>","<span>{display_name}</span>","</div>","</tpl>",'<div class="x-clear"></div>'),c=[];container.getWidgets();Ext.each(container.getWidgets(),function(e){c.push({name:e.getName(),display_name:e.getDisplayName(),icon:e.getIconPath()})},this);
var d={xtype:"jsonstore",fields:["name","display_name","icon"],data:c,sortInfo:{field:"display_name",direction:"ASC"}};Ext.applyIf(a,{layout:"fit",border:false,width:400,height:300,title:_("Add widgets"),items:[{xtype:"dataview",store:d,tpl:b,autoScroll:true,singleSelect:true,multiSelect:false,selectedClass:"zarafa-widgets-selectedwidget",overClass:"zarafa-widgets-hoverwidget",itemSelector:"div.zarafa-widget-item",deferEmptyText:false,emptyText:_("No widgets installed."),listeners:{dblclick:this.onWidgetDblClick,
scope:this}}]});Zarafa.core.ui.widget.WidgetDialog.superclass.constructor.call(this,a)},onWidgetDblClick:function(a,b,c){this.widgetPanel&&this.widgetPanel.createWidget(a.getRecord(c).get("name"))}});Zarafa.core.ui.Dialog.register(Zarafa.core.ui.widget.WidgetDialog,"widgetdialog");Ext.namespace("Zarafa.core.ui.notifier");Zarafa.core.ui.notifier.NotifyPlugin=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},notify:Ext.emptyFn});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.Notifier=Ext.extend(Object,{availablePlugins:undefined,constructor:function(a){Ext.apply(this,a);this.availablePlugins={}},registerPlugin:function(a,b){Ext.isDefined(this.availablePlugins[a])||(this.availablePlugins[a]=b)},getPlugin:function(a){var b="zarafa/v1/main/notifier/"+a.replace(".","/")+(a!="default"?"/value":"");b=this.availablePlugins[container.getSettingsModel().get(b)];if(!b&&a!="default"){b=a.lastIndexOf(".");a=b>0?a.substr(0,b):"default";b=this.getPlugin(a)}return b},
notify:function(a,b,c,d,e){a=a.toLowerCase();var f=this.getPlugin(a);f&&f.notify(a,b,c,d,e)}});Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.RecordDialog=Ext.extend(Zarafa.core.ui.Dialog,{autoSave:true,ignoreUpdates:undefined,allowWrite:undefined,useShadowStore:undefined,record:undefined,modalRecord:undefined,recordComponentPlugin:undefined,defaultTitle:_("Zarafa Dialog"),titleProperty:"subject",alwaysUseDefaultTitle:false,showLoadMask:true,loadMask:undefined,showInfoMask:true,savingText:{msg:_("Saving")+"..."},savingDoneText:{title:_("Saved"),msg:_("Saved successfully")},isSaving:false,closeOnSave:false,confirmClose:false,
constructor:function(a){a=a||{};if(a.allowWrite&&a.modal)a.useShadowStore=true;a.confirmClose&&!container.getSettingsModel().get("zarafa/v1/main/confirm_close_dialog")&&delete a.confirmClose;a.plugins=Ext.value(a.plugins,[]);a.plugins.push({ptype:"zarafa.recordcomponentplugin",ignoreUpdates:a.ignoreUpdates,allowWrite:a.allowWrite,useShadowStore:a.useShadowStore});a.plugins.push({ptype:"zarafa.recordcomponentupdaterplugin"});this.addEvents("beforesaverecord","saverecord","aftersaverecord");Zarafa.core.ui.RecordDialog.superclass.constructor.call(this,
a);if(Ext.isString(this.savingText))this.savingText={title:"",msg:this.savingText};if(Ext.isString(this.savingDoneText))this.savingDoneText={title:"",msg:this.savingDoneText};this.initEvents();this.record&&this.setRecord(this.record);this.confirmClose&&this.mon(this,"beforeclose",this.onBeforeClose,this)},initEvents:function(){this.mon(this,"setrecord",this.onSetRecord,this);this.mon(this,"updaterecord",this.onUpdateRecord,this);this.mon(this,"writerecord",this.onWriteRecord,this);this.mon(this,"exceptionrecord",
this.onExceptionRecord,this)},displayLoadMask:function(a){if(this.showLoadMask!==false){if(!this.loadMask)this.loadMask=new Zarafa.common.ui.LoadMask(this.el);a?this.loadMask.showError():this.loadMask.show()}},hideLoadMask:function(){this.showLoadMask!==false&&this.loadMask&&this.loadMask.hide()},displayInfoMask:function(){this.showInfoMask!==false&&container.getNotifier().notify("info.saving",this.savingText.title,this.savingText.msg,this.getEl(),"fadeIn")},hideInfoMask:function(a){if(this.showInfoMask!==
false){container.getNotifier().notify("info.saving",this.savingText.title,this.savingText.msg,this.getEl(),"fadeOut");a!==false&&container.getNotifier().notify("info.saved",this.savingDoneText.title,this.savingDoneText.msg)}},setRecord:function(a){var b;if(this.recordComponentPlugin){if(this.allowWrite===true)if(this.isModal()){this.modalRecord=a;a=a.copy("modal-"+a.id);b=true}this.recordComponentPlugin.setRecord(a,b)}},saveRecord:function(a){if(!(this.allowWrite===false||this.isSaving===true))if(this.fireEvent("beforesaverecord",
this,this.record)!==false){this.fireEvent("saverecord",this,this.record);Ext.isDefined(this.modalRecord)&&this.modalRecord.applyData(this.record,true);if(a!==false){a=this.modalRecord||this.record;if(a.getStore().modified.indexOf(a)<0)this.closeOnSave===true&&this.close();else{this.displayInfoMask();this.isSaving=true;a.save()}}}},deleteRecord:function(){if(this.allowWrite!==false)Zarafa.common.Actions.deleteRecords(this.modalRecord||this.record)},update:function(a,b){a.isOpened()&&this.hideLoadMask();
if(b||this.alwaysUseDefaultTitle===false&&a.isModifiedSinceLastUpdate(this.titleProperty))if(a&&this.alwaysUseDefaultTitle==false){var c=Ext.util.Format.htmlEncode(a.get(this.titleProperty));this.setTitle(Ext.isEmpty(c)?this.defaultTitle:c)}else this.setTitle(this.defaultTitle)},onSetRecord:function(a,b){if(b){b.isOpened()||this.displayLoadMask();this.record=b}},onUpdateRecord:function(a,b){if(this.isSaving===true&&b==Ext.data.Record.COMMIT){this.fireEvent("aftersaverecord",this,this.record);this.isSaving=
false;this.hideInfoMask(true);if(this.closeOnSave){this.close();return false}}},onExceptionRecord:function(a,b){if(b==="open")this.displayLoadMask(true);else{this.isSaving=false;this.hideInfoMask(false)}},onOk:function(){this.saveRecord(this.autoSave);this.closeOnSave!==true&&this.close()},onCancel:function(){this.close()},onWriteRecord:function(a,b){if(b==Ext.data.Api.actions.destroy){this.close();return false}},onBeforeClose:function(){if(this.record&&this.record.store)if(this.record.dirty){Ext.MessageBox.confirm(_("Zarafa WebApp"),
_("You are going to lose all unsaved changes. Are you sure you want to close this window?"),function(a){if(a=="yes"){this.record.reject();this.close()}},this);return false}}});Zarafa.core.ui.Dialog.register(Zarafa.core.ui.RecordDialog,"zarafa.recorddialog");Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.NavigationPanel=Ext.extend(Zarafa.core.ui.MainViewSidebar,{centerPanel:null,allFoldersPanel:null,showFolderList:false,constructor:function(a){this.addEvents(["toggleshowallfolders"]);a=a||{};for(var b=container.populateInsertionPoint("navigation.north",this),c=container.populateInsertionPoint("navigation.center",this),d=container.populateInsertionPoint("navigation.south",this),e=0,f=b.length;e<f;e++)b[e]=Ext.create(b[e]);e=0;for(f=c.length;e<f;e++)c[e]=Ext.create(c[e]);c.unshift(this.getAllFoldersPanel());
e=0;for(f=d.length;e<f;e++)d[e]=Ext.create(d[e]);var g=[];g.push.apply(g,b);g.push({xtype:"container",ref:"centerPanel",cls:"zarafa-navigationpanel-centerpanel",flex:1,layout:"card",activeItem:0,items:c});g.push.apply(g,d);e=0;for(f=g.length;e<f;e++)if(Ext.isEmpty(g[e].cls))g[e].cls="zarafa-navigationpanel-item";else g[e].cls+=" zarafa-navigationpanel-item";Ext.applyIf(a,{border:false,layout:{type:"vbox",align:"stretch"},cls:"zarafa-navigation zarafa-panel zarafa-context-mainpanel",north:b,center:c,
south:d,items:g,headerCfg:{cls:"zarafa-main-header x-panel-header"}});Zarafa.core.ui.NavigationPanel.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})},getAllFoldersPanel:function(){if(!this.allFoldersPanel)this.allFoldersPanel=new Zarafa.core.ui.ContextNavigationPanel({ownerTitle:_("Folders List"),cls:"zarafa-navigationpanel-centerpanel-allfolders",items:[{cls:"zarafa-context-navigation-block",title:_("All Folders"),items:this.getFolderListPanel()}]});
return this.allFoldersPanel},getFolderListPanel:function(){if(!Ext.isDefined(this.folderList))this.folderList=new Zarafa.hierarchy.ui.HierarchyTreePanel({enableDD:true,enableItemDrop:true,showAllFoldersDefaultValue:true});return this.folderList},onContextSwitch:function(a,b,c){this.activeContext=c;this.toggleVisibilityNavigationComponents();this.doLayout();this.setTitle(c.getDisplayName()||_("Folders List"))},toggleVisibilityNavigationComponents:function(){for(var a=0,b=this.items.length;a<b;a++){var c=
this.items.itemAt(a);if(c!==this.centerPanel)!c.navigationContext||c.navigationContext==this.activeContext?c.setVisible(true):c.setVisible(false)}if(this.centerPanel.getLayout().setActiveItem){var d=false;if(!this.showFolderList){a=0;for(b=this.centerPanel.items.length;a<b;a++){c=this.centerPanel.items.itemAt(a);if(c.getContext()==this.activeContext){this.centerPanel.getLayout().setActiveItem(a);d=true;break}}}if(!d){this.showFolderList=true;this.centerPanel.getLayout().setActiveItem(this.getAllFoldersPanel())}}},
setShowFolderList:function(a){if(this.showFolderList!==a){this.showFolderList=a;this.toggleVisibilityNavigationComponents();this.doLayout();this.fireEvent("toggleshowallfolders",this.showFolderList)}},onAfterFirstLayout:function(){this.activeContext=container.getCurrentContext();this.mon(container,"contextswitch",this.onContextSwitch,this);this.onContextSwitch(null,this.activeContext,this.activeContext);this.mon(this,"resize",this.onResizePanel,this)},onResizePanel:function(){this.doLayout()}});
Ext.reg("zarafa.navigationpanel",Zarafa.core.ui.NavigationPanel);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MainToolbar=Ext.extend(Zarafa.core.ui.Toolbar,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.maintoolbar",cls:"zarafa-maintoolbar",height:45});Zarafa.core.ui.MainToolbar.superclass.constructor.call(this,a);this.initButtonGroups()},initButtonGroups:function(){this.addNewItems();this.addActionItems();this.addPrintButton();this.addViewItems();this.addItems([],"main.toolbar.actions.last")},addNewItems:function(){var a=[],b=container.populateInsertionPoint("main.maintoolbar.new.item",
this)||[],c=container.populateInsertionPoint("main.maintoolbar.new.folder",this)||[];b=Zarafa.core.Util.sortArray(b,"ASC","newMenuIndex");c=Zarafa.core.Util.sortArray(c,"ASC","newMenuIndex");b=Zarafa.core.Util.uniqueArray(b,"text");c=Zarafa.core.Util.uniqueArray(c,"text");if(b.length!=0){b[0].hidden=true;b[0].ref="defaultButton";a.push({xtype:"menuitem",iconCls:b[0].iconCls,text:b[0].text,handler:b[0].handler,scope:b[0].scope},"-")}if(c.length!=0){a=a.concat(c);a.push("-")}if(b.length!=0)a=a.concat(b);
this.addItems({xtype:"splitbutton",scale:"large",ref:"newButton",rowspan:2,menu:a,listeners:{render:this.onRenderNewButton,scope:this},iconCls:b[0]?b[0].iconCls:undefined,handler:b[0]?b[0].handler:undefined,scope:b[0]?b[0].scope:undefined})},onRenderNewButton:function(a){a.mon(container,"contextswitch",this.onNewButtonContextSwitch,this);this.onNewButtonContextSwitch(null,container.getCurrentContext(),container.getCurrentContext())},onNewButtonContextSwitch:function(a,b,c){a=this.newButton.menu;b=
a.items.itemAt(0);var d=a.defaultButton,e=a.items.indexOf(d),f=false;if(e>=0){e=e;for(var g=a.items.length;e<g;e++){var h=a.items.itemAt(e);if(f===false&&h.context==c.getName()){f=h;h.setVisible(false)}else h.setVisible(true)}}if(f===false&&d){f=d;d.setVisible(false)}if(f!==false){this.newButton.setIconClass(f.iconCls);this.newButton.setHandler(f.handler,f.scope);b.setText(f.text);b.setIconClass(f.iconCls);b.setHandler(f.handler,f.scope)}},addViewItems:function(){for(var a,b=[],c=container.getContexts(),
d=0,e=c.length;d<e;d++){var f=c[d];a=f.getMainToolbarViewButtons();if(Ext.isArray(a)&&a.length)if(f.groupViewBtns)b.push({xtype:"button",scale:"large",iconCls:"view_icon",tooltip:_("Switch view"),hidden:true,contextName:f.getName(),menu:Zarafa.core.Util.uniqueArray(a,"text"),listeners:{render:this.onRenderViewButton}});else for(var g=0,h=a.length;g<h;g++){var i=Ext.applyIf({xtype:"button",scale:"large",hidden:"true",contextName:f.getName()},a[g]);i.tooltip=i.text;delete i.text;i.listeners=Zarafa.core.Util.mergeListeners(i.listeners,
{render:this.onRenderViewButton});b.push(i)}}this.addItems(b)},onRenderViewButton:function(a){a.mon(container,"contextswitch",function(b,c,d){this.setVisible(this.contextName==d.getName())},a);a.setVisible(a.contextName===container.getCurrentContext().getName())},addPrintButton:function(){for(var a,b=[],c=container.getContexts(),d=0,e=c.length;d<e;d++){var f=c[d];a=f.getMainToolbarPrintButtons();Ext.isArray(a)&&a.length&&b.push({xtype:"splitbutton",scale:"large",iconCls:"icon_print",tooltip:_("Print"),
handler:a[0].handler,scope:a[0].scope,hidden:true,contextName:f.getName(),menu:{xtype:"zarafa.conditionalmenu",items:Zarafa.core.Util.uniqueArray(a,"text")},listeners:{render:this.onRenderPrintButton}})}this.addItems(b)},onRenderPrintButton:function(a){a.mon(container,"contextswitch",function(b,c,d){this.setVisible(this.contextName==d.getName())},a);a.setVisible(a.contextName===container.getCurrentContext().getName())},addActionItems:function(){var a=[];a.push({xtype:"button",scale:"large",overflowText:_("Address Book"),
tooltip:_("Address Book"),iconCls:"icon_addressbook",handler:this.onAddressBook,scope:this});a.push({hidden:true,xtype:"button",scale:"large",overflowText:_("Restore items"),tooltip:_("Restore items"),iconCls:"icon_restore",handler:this.onRestore,scope:this});a.push({xtype:"button",scale:"large",title:_("Refresh"),overflowText:_("Refresh"),tooltip:_("Refresh"),iconCls:"x-tbar-loading",handler:this.onRefresh,scope:this});a.push({hidden:true,xtype:"button",scale:this.enableSearchButton?"small":"large",
text:_("Advanced find"),overflowText:_("Advanced find"),iconCls:"icon_advanced_find"});a.push({hidden:true,xtype:"button",scale:"large",text:_("Rules"),overflowText:_("Rules"),iconCls:"icon_rules"});this.addItems(a,"main.toolbar.actions")},onAddressBook:function(){Zarafa.addressbook.Actions.openAddressBook()},onRestore:function(){Zarafa.common.Actions.openRestoreDialog()},onRefresh:function(){var a=container.getCurrentContext().getModel();a&&a.reload()},onPrint:function(){var a=container.getCurrentContext();
a&&Zarafa.common.Actions.openPrintDialog(a)}});Ext.reg("zarafa.maintoolbar",Zarafa.core.ui.MainToolbar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.DialogToolbar=Ext.extend(Zarafa.core.ui.Toolbar,{insertionPointBase:undefined,enablePop:false,customPop:undefined,actionItems:[],optionItems:[],constructor:function(a){Ext.apply(this,a,{xtype:"zarafa.dialogtoolbar",cls:"zarafa-dialogtoolbar"});this.addEvents("window_before_pop");Zarafa.core.ui.DialogToolbar.superclass.constructor.call(this,a);this.initButtonGroups();this.initPopInOut()},initButtonGroups:function(){var a=this.insertionPointBase+".toolbar";this.addItems(this.actionItems,
a+".actions");this.addItems(this.optionItems,a+".options")},initPopInOut:function(){if(this.enablePop==true){this.add("->");this.customPop!=undefined?this.add(this.customPop):this.add(this.getPopInOutButton())}},getPopInOutButton:function(){return{xtype:"button",scale:"large",scope:this,listeners:{beforerender:{scope:this,fn:this.onBeforeRenderPopInOutButton}},handler:this.handlerPopInOutButton}},onBeforeRenderPopInOutButton:function(a){var b=this.dialog.isBrowser();a.text=b?_("Pop in"):_("Pop out");
a.iconCls=b?"icon_mail_popin":"icon_mail_popout"},handlerPopInOutButton:function(){var a=this.dialog==undefined?undefined:this.dialog.record;if(this.fireEvent("window_before_pop",a)!=false){var b=this.dialog.isBrowser(),c=b?window.opener:window;this.dialog.close();c.Ext.ComponentMgr.types[this.dialog.xtype].create({componentConfig:{record:a},windowConfig:{width:this.dialog.getWidth(),height:this.dialog.getHeight(),browser:!b}})}}});Ext.reg("zarafa.dialogtoolbar",Zarafa.core.ui.DialogToolbar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.ContextContainer=Ext.extend(Zarafa.core.ui.SwitchViewContentContainer,{name:undefined,constructor:function(a){if(a.name)this.name=a.name;var b=[],c=container.populateInsertionPoint(this.name,a.scope),d=container.getCurrentContext();Ext.each(c,function(e){var f=e.context.getName();d&&f===d.getName()&&b.push(e)},this);Ext.applyIf(a,{autoDestroy:true,layout:"card",deferredRender:"false",hideMode:"offsets",size:"auto",border:false,lazyItems:c,items:b,activeItem:0,forceLayout:true});Zarafa.core.ui.ContextContainer.superclass.constructor.call(this,
a);this.init()},init:function(){this.mon(container,"contextswitch",this.switchContext,this)},switchContext:function(a,b,c){a=this.getActiveItem();b=this.findBy(function(e){return e.context===c});var d=true;if(Ext.isEmpty(b))d=false;else{b=b[0];this.layout.setActiveItem(b.id)}this.isVisible()!=d&&this.setVisible(d);if(this.autoClean===true&&a&&a!=b){this.remove(a);delete a}}});Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.RecordComponentUpdaterPlugin=Ext.extend(Object,{rootContainer:undefined,field:undefined,isReady:false,record:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.core.plugins.RecordComponentUpdaterPlugin.superclass.constructor.call(this,a)},init:function(a){this.field=a;if(this.rootContainer)this.hookToRootContainer(this.rootContainer);else a.rootContainer?this.hookToRootContainer(a.rootContainer):this.field.mon(this.field,"beforerender",this.onFirstBeforeRender,this,{single:true});
if(Ext.isDefined(this.field.layout))this.field.mon(this.field,"afterlayout",this.onReadyComponent,this,{single:true});else this.field.rendered!==true?this.field.mon(this.field,"afterrender",this.onReadyComponent,this,{single:true}):this.onReadyComponent(this.field)},hookToRootContainer:function(a){this.rootContainer=a;this.record=a.recordComponentPlugin.getActiveRecord();this.field.mon(a,"setrecord",this.onSetRecord,this);this.field.mon(a,"openrecord",this.onOpenRecord,this);this.field.mon(a,"updaterecord",
this.onUpdateRecord,this);this.field.mon(a,"exceptionrecord",this.onExceptionRecord,this);this.field.mon(a,"beforesaverecord",this.onBeforeSaveRecord,this)},onFirstBeforeRender:function(){for(var a=this.field;!(a.recordComponentPlugin instanceof Zarafa.core.plugins.RecordComponentPlugin);){a=a.ownerCt;if(!Ext.isDefined(a))break}a&&this.hookToRootContainer(a)},onReadyComponent:function(){this.record&&this.field.update(this.record,true);this.isReady=true},onSetRecord:function(a,b){this.record=b;this.isReady===
true&&this.field.update(b,true)},onOpenRecord:function(a,b){this.isReady===true&&this.field.isDestroyed!==true&&this.field.update(b,true)},onUpdateRecord:function(a,b,c){this.isReady===true&&this.field.isDestroyed!==true&&this.field.update(c,false)},onExceptionRecord:function(a,b,c,d,e,f){this.isReady===true&&this.field.isDestroyed!==true&&Ext.isFunction(this.field.doException)&&this.field.doException(a,b,c,d,e,f)},onBeforeSaveRecord:function(a,b){if(this.isReady===true&&this.field.isDestroyed!==
true)if(Ext.isFunction(this.field.updateRecord))return this.field.updateRecord(b);return true}});Ext.preg("zarafa.recordcomponentupdaterplugin",Zarafa.core.plugins.RecordComponentUpdaterPlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.RecordComponentPlugin=Ext.extend(Object,{field:undefined,ignoreUpdates:false,allowWrite:false,isLayoutCalled:false,record:undefined,cheapCopy:undefined,useShadowStore:false,constructor:function(a){a=a||{};if(!Ext.isDefined(a.useShadowStore)){if(a.allowWrite===true)a.useShadowStore=true;if(a.ignoreUpdates===true)a.useShadowStore=true}Ext.apply(this,a);Zarafa.core.plugins.RecordComponentPlugin.superclass.constructor.call(this,a)},init:function(a){this.field=a;a.recordComponentPlugin=
this;this.field.addEvents("beforesetrecord","setrecord","openrecord","updaterecord","exceptionrecord","writerecord");this.field.mon(this.field,"afterlayout",this.onAfterFirstLayout,this,{single:true});this.field.mon(this.field,"close",this.onClose,this)},startShadowRecordEdit:function(a){this.useShadowStore&&container.getShadowStore().add(a)},endShadowRecordEdit:function(a){this.useShadowStore&&container.getShadowStore().remove(a,true)},isRecordInContainer:function(a){return this.allowWrite===true&&
this.useShadowStore===false?this.record&&this.record===a:this.record&&this.record.equals(a)},setRecord:function(a,b){var c=this.record;if(this.record!==a)if(this.isLayoutCalled===false){this.record=a;this.cheapCopy=b}else if(this.field.fireEvent("beforesetrecord",this,a,c)!==false){if(c){c.setUpdateModificationsTracking(false);if(this.ignoreUpdates!==true){this.field.mun(c.getStore(),"update",this.onUpdateRecord,this);this.field.mun(c.getStore(),"write",this.onWrite,this);this.field.mun(c.getStore(),
"exception",this.onExceptionRecord,this)}this.useShadowStore===true&&this.endShadowRecordEdit(c)}if(a){if(this.useShadowStore){if(a.phantom!==true&&b!==true)a=a.copy();this.startShadowRecordEdit(a)}this.record=a;this.record.setUpdateModificationsTracking(true);this.field.fireEvent("setrecord",this,a,c);this.ignoreUpdates!==true&&this.field.mon(a.getStore(),"exception",this.onExceptionRecord,this);if(a.isOpened())this.onOpenRecord(a.getStore(),a);else{this.field.mon(a.getStore(),"open",this.onOpenRecord,
this);a.open()}}else{this.record=a;this.field.fireEvent("setrecord",this,a,c)}}},getActiveRecord:function(){if(this.isLayoutCalled===true)return this.record},onAfterFirstLayout:function(){this.isLayoutCalled=true;if(this.record){var a=this.record;this.record=undefined;this.setRecord(a,this.cheapCopy)}},onOpenRecord:function(a,b){if(this.isRecordInContainer(b)){this.record!==b&&this.record.applyData(b);if(this.ignoreUpdates!==true){this.field.mon(b.getStore(),"update",this.onUpdateRecord,this);this.field.mon(b.getStore(),
"write",this.onWrite,this)}this.field.mun(a,"open",this.onOpenRecord,this);this.field.fireEvent("openrecord",this.field,this.record)}},onUpdateRecord:function(a,b,c){if(this.isRecordInContainer(b)){if(this.record!==b){if(c!==Ext.data.Record.COMMIT)return;this.record.applyData(b)}this.field.fireEvent("updaterecord",this.field,c,this.record)}},onExceptionRecord:function(a,b,c,d,e,f){a=f.sendRecords;if(Ext.isArray(a)&&a.length==1)a=a[0];if(a instanceof Zarafa.core.data.MAPIRecord&&this.isRecordInContainer(a))this.field.fireEvent("exceptionrecord",
b,c,d,e,a,f.error||undefined)},onWrite:function(a,b,c,d,e){e=[].concat(e);for(var f=0,g=e.length;f<g;f++)if(this.record===e[f]){this.field.fireEvent("writerecord",a,b,c,d,e[f]);return}},onClose:function(){this.record&&this.endShadowRecordEdit(this.record)}});Ext.preg("zarafa.recordcomponentplugin",Zarafa.core.plugins.RecordComponentPlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.MarkAsReadPlugin=Ext.extend(Object,{field:undefined,record:undefined,readFlagTimer:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.core.plugins.MarkAsReadPlugin.superclass.constructor.call(this,a)},init:function(a){this.field=a;a.markAsReadPlugin=this;this.field.mon(this.field,"render",this.onRender,this)},onRender:function(){this.field.mon(this.field,"setrecord",this.onSetRecord,this);this.field.mon(this.field,"openrecord",this.onOpenRecord,this);this.field.mon(this.field,
"close",this.onDestroy,this);this.field.mon(this.field,"destroy",this.onDestroy,this)},onSetRecord:function(a,b){this.resetReadFlagTimer();this.record=b instanceof Zarafa.core.data.IPMRecord?b:undefined},onOpenRecord:function(a,b){b&&!b.phantom&&!b.isRead()&&this.startReadFlagTimer()},startReadFlagTimer:function(){if(!this.readFlagTimer){var a=container.getSettingsModel().get("zarafa/v1/contexts/mail/readflag_time")*1E3;this.readFlagTimer=window.setTimeout(this.markAsRead.createDelegate(this),a)}},
resetReadFlagTimer:function(){if(this.readFlagTimer){window.clearTimeout(this.readFlagTimer);delete this.readFlagTimer}},markAsRead:function(){this.record&&Zarafa.common.Actions.markAsRead(this.record);delete this.readFlagTimer},onDestroy:function(){this.resetReadFlagTimer();this.record=undefined}});Ext.preg("zarafa.markasreadplugin",Zarafa.core.plugins.MarkAsReadPlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.InputAutoFocusPlugin=Ext.extend(Object,{autoFocus:undefined,field:undefined,beginFocusEl:undefined,endFocusEl:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.core.plugins.InputAutoFocusPlugin.superclass.constructor.call(this,a)},init:function(a){this.field=a;a.inputAutoFocusPlugin=this;this.field.mon(this.field,"afterrender",this.onAfterRender,this);this.field.mon(this.field,"afterlayout",this.onAfterFirstLayout,this,{single:true});this.field.mon(this.field,"destroy",
this.onDestroy,this)},onAfterRender:function(){this.beginFocusEl=Ext.DomHelper.insertBefore(this.field.el,{tag:"a",href:"#",style:"position: absolute; text-decoration: none; font-height: 1px; width: 1px; height: 1px;"},true);this.beginFocusEl.dom.innerHTML="&nbsp;";this.beginFocusEl.on("focus",this.onLimitFocussed,this);this.endFocusEl=Ext.DomHelper.insertAfter(this.field.el,{tag:"a",href:"#",style:"position: absolute; text-decoration: none; font-height: 1px; width: 1px; height: 1px;"},true);this.endFocusEl.dom.innerHTML=
"&nbsp;";this.endFocusEl.on("focus",this.onLimitFocussed,this);this.field.dialog&&this.field.dialog.extWindow&&this.field.dialog.extWindow.focusEl&&this.field.dialog.extWindow.focusEl.on("focus",this.onDialogFocussed,this)},onAfterFirstLayout:function(){if(Ext.isDefined(this.field.tabEl))this.field.mon(this.field,"activate",this.onActivate,this);else{var a=this.field.findBy(function(d){return Ext.isDefined(d.tabEl)});if(!Ext.isEmpty(a))for(var b=0,c=a.length;b<c;b++)this.field.mon(a[b],"activate",
this.onActivate,this)}},onActivate:function(){this.doAutoFocus.defer(1,this)},onLimitFocussed:function(a,b){this.doCyclicFocus(this.beginFocusEl.dom===b)},onDestroy:function(){this.beginFocusEl.destroy();this.endFocusEl.destroy()},setAutoFocus:function(a){this.autoFocus=a;this.doAutoFocus()},doAutoFocus:function(){var a;if(this.autoFocus)if(Ext.isString(this.autoFocus)){a=this.field[this.autoFocus];if(!a){var b=this.field.findByType(this.autoFocus);Ext.isEmpty(b)||(a=b[0])}a||(a=Ext.get(this.autoFocus))}else{if(Ext.isElement(this.autoFocus)||
Ext.isFunction(this.autoFocus.focus))a=this.autoFocus}else(a=this.findFocusElement(this.field))||(a=this.findFocusElement(this.field,false,true));a&&a.focus.defer(1,a)},doCyclicFocus:function(a){(a=this.findFocusElement(this.field,a,true))&&a.focus.defer(1,a)},findFocusElement:function(a,b,c){var d=[];if(a.topToolbar)d=d.concat(a.topToolbar.items.items);if(a.items)d=d.concat(a.items.items);if(a.buttons)d=d.concat(a.buttons);b&&d.reverse();a=0;for(var e=d.length;a<e;a++){var f=d[a],g;if(this.isContainer(f)){if(f.isVisible())g=
this.findFocusElement(f,b,c)}else if(this.isFocusElement(f,c))g=f;if(g)return g}},isContainer:function(a){return a instanceof Ext.Container||a instanceof Ext.form.CompositeField},isFocusElement:function(a,b){var c=a.btnEl||a.el,d=b===true?/submit|reset|hidden/i:/button|submit|reset|hidden/i,e=b===true?/button|input|textarea|select/i:/input|textarea|select/i;return c.dom.style.height!=="0px"&&c.dom.style.width!=="0px"&&c.dom.style.display!=="none"&&c.dom.style.visibility!=="hidden"&&!c.dom.disabled&&
!c.dom.getAttribute("readonly")&&!d.test(c.dom.type)&&e.test(c.dom.tagName)},onDialogFocussed:function(){this.doAutoFocus()}});Ext.preg("zarafa.inputautofocusplugin",Zarafa.core.plugins.InputAutoFocusPlugin);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.User=Ext.extend(Object,{meta:undefined,constructor:function(a){this.meta=a},getEntryId:function(){return this.meta.entryid},getSearchKey:function(){return this.meta.search_key},getDisplayName:function(){return this.meta.fullname||this.meta.username},getFullName:function(){return this.meta.fullname},getUserName:function(){return this.meta.username},getEmailAddress:function(){return this.meta.email_address},getSMTPAddress:function(){return this.meta.smtp_address}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ShadowStore=Ext.extend(Zarafa.core.data.MAPIStore,{standalone:false,serveronly:true,constructor:function(a){a=a||{};Ext.applyIf(a,{batch:false,proxy:new Zarafa.core.data.ShadowProxy,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader});Zarafa.core.data.ShadowStore.superclass.constructor.call(this,a);if(!this.standalone){Zarafa.core.data.IPMStoreMgr.register(this,this.serveronly);Zarafa.core.data.IPFStoreMgr.register(this,this.serveronly)}},getRecordKey:function(a){var b;
this.eachKey(function(c,d){if(d===a){b=c;return false}});return b||[Ext.data.Record.PREFIX,"-",Ext.data.Record.AUTO_ID++].join("")},reMap:function(a){if(Ext.isArray(a))for(var b=0,c=a.length;b<c;b++)this.reMap(a[b]);else delete a._phid},remove:function(a,b){Ext.isArray(a)&&Ext.each(a,function(d){this.remove(d,b)},this);var c=this.data.indexOf(a);if(c>-1){a.join(null);this.data.removeAt(c)}this.pruneModifiedRecords&&this.modified.remove(a);this.snapshot&&this.snapshot.remove(a);c>-1&&b!==true&&this.fireEvent("remove",
this,a,c)},removeAt:function(a,b){this.remove(this.getAt(a),b)},containsFolderInLastLoad:function(){return false},containsStoreInLastLoad:function(){return false},destroy:function(){if(!this.standalone){Zarafa.core.data.IPMStoreMgr.unregister(this,this.serveronly);Zarafa.core.data.IPFStoreMgr.unregister(this,this.serveronly)}Zarafa.core.data.IPMStore.superclass.destroy.call(this)}});Ext.reg("zarafa.shadowstore",Zarafa.core.data.ShadowStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ShadowProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};Ext.applyIf(a,{listModuleName:Zarafa.core.ModuleNames.getListName("IPM.Note",true),itemModuleName:Zarafa.core.ModuleNames.getItemName("IPM.Note",true)});Zarafa.core.data.ShadowProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){switch(Ext.isArray(d)?d[0].get("object_type"):d.get("object_type")){case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:a=
Zarafa.addressbook.AddressBookResponseHandler;break;case Zarafa.core.mapi.ObjectType.MAPI_STORE:case Zarafa.core.mapi.ObjectType.MAPI_FOLDER:a=Zarafa.hierarchy.data.HierarchyResponseHandler;break;default:a=Zarafa.core.data.IPMResponseHandler;break}return new a({proxy:this,action:c,reader:f,sendRecords:d,options:i,callback:g,scope:h})},getListModuleName:function(a){var b;switch(a.get("object_type")){case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:b=
Zarafa.core.ModuleNames.getListName("addressbook");break;case Zarafa.core.mapi.ObjectType.MAPI_STORE:case Zarafa.core.mapi.ObjectType.MAPI_FOLDER:b=Zarafa.core.ModuleNames.getListName("hierarchy");break;default:a=a.get("message_class");Ext.isEmpty(a)||(b=Zarafa.core.ModuleNames.getListName(a,true));break}return b||this.listModuleName},getItemModuleName:function(a){var b;switch(a.get("object_type")){case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:b=
Zarafa.core.ModuleNames.getItemName("addressbook");break;case Zarafa.core.mapi.ObjectType.MAPI_STORE:case Zarafa.core.mapi.ObjectType.MAPI_FOLDER:b=Zarafa.core.ModuleNames.getListName("hierarchy");break;default:a=a.get("message_class");Ext.isEmpty(a)||(b=Zarafa.core.ModuleNames.getItemName(a,true));break}return b||this.itemModuleName}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.MAPISubStore=Ext.extend(Zarafa.core.data.NoSyncStore,{parentRecord:null,reader:undefined,writer:undefined,persistentFilter:true,filterFn:undefined,filterScope:undefined,constructor:function(a){a=a||{};if(a.reader)if(!a.recordType)a.recordType=a.reader.recordType;this.addEvents("load","datachanged");Zarafa.core.data.MAPISubStore.superclass.constructor.call(this,a)},createRecords:function(a,b,c){var d=this.getParentRecord();d&&d.afterEdit();Zarafa.core.data.MAPISubStore.superclass.createRecords.call(this,
a,b,c)},destroyRecord:function(a,b,c){this.getParentRecord()&&this.getParentRecord().markDirty();Zarafa.core.data.MAPISubStore.superclass.destroyRecord.call(this,a,b,c)},getParentRecord:function(){return this.parentRecord},setParentRecord:function(a){this.parentRecord=a},filterBy:Zarafa.core.data.MAPIStore.prototype.filterBy,clearFilter:Zarafa.core.data.MAPIStore.prototype.clearFilter,loadData:function(a,b){Ext.isDefined(this.reader)&&this.loadRecords(this.reader.readRecords(a),{add:b},true)},loadRecords:function(a,
b,c){if(this.isDestroyed!==true)if(!a||c===false)c!==false&&this.fireEvent("load",this,[],b);else{c=a.records;a=a.totalRecords||c.length;if(!b||b.add!==true){for(var d=0,e=c.length;d<e;d++)c[d].join(this);if(this.snapshot){this.data=this.snapshot;delete this.snapshot}this.clearData();this.data.addAll(c);this.totalLength=a;this.fireEvent("datachanged",this)}else{this.totalLength=Math.max(a,this.data.length+c.length);this.add(c)}this.fireEvent("load",this,c,b);this.persistentFilter===true&&this.filterFn&&
this.filterBy(this.filterFn,this.filterScope)}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.MAPIRecord=Ext.extend(Ext.data.Record,{baseIdProperties:["entryid","store_entryid","parent_entryid"],idProperties:undefined,subStores:undefined,subStoresTypes:undefined,eventPropagation:true,trackUpdateModifications:false,updateModifications:undefined,updateSubStoreModifications:undefined,editingCount:0,constructor:function(a,b,c){Zarafa.core.data.MAPIRecord.superclass.constructor.call(this,a,b);this.idProperties=this.baseIdProperties.clone();this.subStores={};this.subStoresTypes=
{};if(c)this.subStoresTypes=c.getSubStores()},copy:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByRecordData(this.data,a||this.id);a.idProperties=this.idProperties.clone();a.phantom=this.phantom;return a.applyData(this)},applyData:function(a,b){this.beginEdit();this.trackUpdateModifications=a.trackUpdateModifications;for(var c in a.data)Ext.isDate(a.data[c])?this.set(c,a.data[c].clone()):this.set(c,a.data[c]);this.actions=Ext.apply({},a.actions);if(this.idProperties.equals(a.idProperties)){a.isOpened()&&
this.afterOpen();this.mergeSubStores(a.subStores,b)}this.endEdit();return this},save:function(){this.getStore().save(this)},equals:Ext.emptyFn,setEventPropagation:function(a){this.eventPropagation=a},hasEventPropagation:function(){return this.eventPropagation},setUpdateModificationsTracking:function(a){this.trackUpdateModifications=a},getUpdateModificationsTracking:function(){return this.trackUpdateModifications},getStore:function(){return this.store},open:function(a){this.isOpened()&&(!a||a.forceLoad!==
true)||this.store.open(this,a)},afterOpen:function(){this.opened=true;this.createSubStores()},isOpened:function(){return this.opened===true},set:function(a,b,c){c=c;if(!Ext.isDefined(c)){c=this.fields.get(a);c=Ext.isDefined(c)?c.forceProtocol:false}if(this.trackUpdateModifications===true){var d=Ext.isPrimitive(b)?String:Ext.encode;if(c!==true&&d(this.data[a])==d(b))return;if(!this.updateModifications)this.updateModifications={};this.updateModifications[a]=this.data[a]}Zarafa.core.data.MAPIRecord.superclass.set.call(this,
a,b);if(c===true&&this.modified[a]===undefined)this.modified[a]=this.data[a]},afterEdit:function(){Zarafa.core.data.MAPIRecord.superclass.afterEdit.call(this);delete this.updateModifications;delete this.updateSubStoreModifications},afterReject:function(){Zarafa.core.data.MAPIRecord.superclass.afterReject.call(this);delete this.updateModifications;delete this.updateSubStoreModifications},afterCommit:function(){Zarafa.core.data.MAPIRecord.superclass.afterCommit.call(this);delete this.updateModifications;
delete this.updateSubStoreModifications},beginEdit:function(){this.editingCount++;if(this.editingCount<1)this.editingCount=1;if(this.editingCount===1){Zarafa.core.data.MAPIRecord.superclass.beginEdit.call(this);this.updateModifications=this.updateModifications||{};this.updateSubStoreModifications=this.updateSubStoreModifications||{}}},cancelEdit:function(){this.editingCount--;if(this.editingCount<0)this.editingCount=0;if(this.editingCount===0){Zarafa.core.data.MAPIRecord.superclass.cancelEdit.call(this);
delete this.updateModifications;delete this.updateSubStoreModifications}},endEdit:function(){this.editingCount--;if(this.editingCount<0)this.editingCount=0;this.editingCount===0&&Zarafa.core.data.MAPIRecord.superclass.endEdit.call(this)},isModifiedSinceLastUpdate:function(a){return this.trackUpdateModifications===true?!!(this.updateModifications&&this.updateModifications.hasOwnProperty(a)):this.isModified(a)},isSubStoreModifiedSincelastUpdate:function(a){if(this.trackUpdateModifications===true)return!!(this.updateSubStoreModifications&&
this.updateSubStoreModifications.hasOwnProperty(a));else{a=this.getSubStore(a);return!Ext.isEmpty(a.modified)||!Ext.isEmpty(a.removed)}},getSubStoreChangesSinceLastUpdate:function(a){if(this.updateSubStoreModifications&&this.updateSubStoreModifications[a])return this.updateSubStoreModifications[a].changes},getMessageActions:function(){return this.actions},getMessageAction:function(a){return this.actions&&this.actions[a]?this.actions[a]:false},addMessageAction:function(a,b){this.actions=this.actions||
{};this.actions[a]=b;Ext.isDefined(this.store)&&this.store.modified.indexOf(this)==-1&&this.store.modified.push(this)},deleteMessageAction:function(a){if(this.actions!==undefined)this.actions[a]=undefined},hasMessageAction:function(a){return Ext.isDefined(this.actions)&&Ext.isDefined(this.actions[a])},clearMessageActions:function(){delete this.actions},clearActionResponse:function(){delete this.action_response},getActionResponse:function(a){if(this.action_response)return this.action_response[a]},
copyTo:function(a){this.addMessageAction("action_type","copy");this.addMessageAction("destination_parent_entryid",a.get("entryid"));this.addMessageAction("destination_store_entryid",a.get("store_entryid"))},moveTo:function(a){this.addMessageAction("action_type","move");this.addMessageAction("destination_parent_entryid",a.get("entryid"));this.addMessageAction("destination_store_entryid",a.get("store_entryid"))},supportsSubStore:function(a){return Ext.isFunction(this.subStoresTypes[a])},createSubStore:function(a){if(this.supportsSubStore(a)){var b=
this.getSubStore(a);if(!Ext.isDefined(b)){b=this.setSubStore(a,new this.subStoresTypes[a]);b.on("update",this.onSubStoreChange,this);b.on("add",this.onSubStoreChange,this);b.on("remove",this.onSubStoreChange,this);b.on("datachanged",this.onSubStoreChange,this)}return b}},createSubStores:function(){for(var a in this.subStoresTypes)this.getSubStore(a)||this.createSubStore(a)},getSubStore:function(a){return this.subStores[a]},setSubStore:function(a,b){this.subStores[a]=b;b.setParentRecord(this);return b},
mergeSubStore:function(a,b,c){var d=this.getSubStore(a);if(d&&b)if(c!==true){b.each(function(e){var f=d.getById(d.data.getKey(e));if(f)e.dirty&&f.applyData(e);else d.add(e.copy())},this);Ext.isEmpty(b.removed)||Ext.each(b.getRemovedRecords(),function(e){(e=d.getById(d.data.getKey(e)))&&d.remove(e)},this)}else{d.removeAll(true);d.add(b.getRange());d.fireEvent("datachanged",d)}},mergeSubStores:function(a,b){for(var c in a)this.supportsSubStore(c)&&this.mergeSubStore(c,a[c],b)},onSubStoreChange:function(a,
b){for(var c in this.subStores)if(this.subStores[c]===a){if(this.trackUpdateModifications===true){if(!this.updateSubStoreModifications)this.updateSubStoreModifications={};Ext.isDefined(b)||(b=a.getRange());var d=this.updateSubStoreModifications[c];if(d)d.changes=d.changes.concat(b);else{d={store:a,changes:[].concat(b)};this.updateSubStoreModifications[c]=d}}this.dirty=true;this.modified=this.modified||{};this.editing||this.afterEdit();break}},addIdProp:function(a){this.hasIdProp(a)||this.idProperties.push(a)},
hasIdProp:function(a){return this.idProperties.indexOf(a)>-1},removeIdProp:function(a){this.hasIdProp(a)&&this.idProperties.splice(this.idProperties.indexOf(a),1)},getIdProps:function(){return this.idProperties},getDisplayType:function(){var a=this.get("display_type"),b=this.get("display_type_ex");switch(a){case Zarafa.core.mapi.DisplayType.DT_MAILUSER:case Zarafa.core.mapi.DisplayType.DT_DISTLIST:a=b&~Zarafa.core.mapi.DisplayTypeEx.DTE_FLAG_ACL_CAPABLE;break;default:a=a;break}return a}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.JsonRecipientWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getRecipientStore();a={};if(!Ext.isDefined(b))return a;var c=b.getModifiedRecords();b=b.getRemovedRecords();if(c.length>0||b.length>0){a.recipients={};for(var d=0;d<c.length;d++){var e=c[d];this.removeCustomProps(e);var f=e.data;if(!e.isMeetingOrganizer())if(Ext.isEmpty(e.get("rowid"))){if(!Ext.isDefined(a.recipients.add))a.recipients.add=[];a.recipients.add.push(f)}else{if(!Ext.isDefined(a.recipients.modify))a.recipients.modify=
[];a.recipients.modify.push(f)}}for(d=0;d<b.length;d++){e=b[d];f=e.data;if(!e.isMeetingOrganizer()){if(!Ext.isDefined(a.recipients.remove))a.recipients.remove=[];a.recipients.remove.push(f)}}}return a},removeCustomProps:function(a){if(Ext.isArray(a))for(var b=0,c=a.length;b<c;b++)this.removeCustomProps(a[b]);else if(a.isPersonalContact()){a.data.entryid="";a.data.store_entryid="";a.data.parent_entryid="";a.data.message_class=""}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.JsonAttachmentWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getAttachmentStore(),c={};if(!Ext.isDefined(b))return c;c.attachments={};c.attachments.dialog_attachments=b.getId();a=b.getModifiedRecords();b=b.getRemovedRecords();Ext.each(a,function(d){if(d.isInline()){if(!Ext.isDefined(c.attachments.add))c.attachments.add=[];c.attachments.add.push(d)}},this);Ext.each(b,function(d){if(d.isInline()){if(!Ext.isDefined(c.attachments.add))c.attachments.remove=
[];c.attachments.remove.push(d)}},this);return c}});Ext.namespace("Zarafa.core.data");Zarafa.core.data.JsonAttachmentReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=Ext.applyIf(a||{},{id:"attach_num",idProperty:"attach_num"});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.mapi.ObjectType.MAPI_ATTACH));Zarafa.core.data.JsonAttachmentReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.core.data");
Ext.data.Api.actions.open="open";
Zarafa.core.data.IPMStore=Ext.extend(Zarafa.core.data.MAPIStore,{standalone:false,serveronly:false,constructor:function(a){a=a||{};Ext.applyIf(a,{remoteGroup:true});this.addEvents("beforenotify","notify");Zarafa.core.data.IPMStore.superclass.constructor.call(this,a);this.standalone||Zarafa.core.data.IPMStoreMgr.register(this,this.serveronly)},initEvents:function(){Zarafa.core.data.IPMStore.superclass.initEvents.call(this);if(!this.standalone){this.serveronly||Zarafa.core.data.IPMStoreMgr.on("beforerecordsave",this.onExternalSave,
this);Zarafa.core.data.IPMStoreMgr.on("afterrecordwrite",this.onExternalWrite,this)}},getRecordsForUpdateData:function(a,b){var c={records:[],updatedRecords:[]};if(Ext.isDefined(a)){Ext.isArray(a)||(a=[a]);if(b===Ext.data.Api.actions.create)for(var d=0,e=a.length;d<e;d++){var f=a[d],g=this.containsFolderInLastLoad(f.get("parent_entryid"));if(f.store!==this&&g){c.records.push(f.copy());c.updatedRecords.push(f)}}else{d=0;for(e=a.length;d<e;d++){f=a[d];g=this.getByEntryId(f.get("entryid"));if(f.store!==
this&&g){c.records.push(g);c.updatedRecords.push(f)}}}}return c},onExternalSave:function(a,b){var c;if(a!==this){c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.open],Ext.data.Api.actions.open);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectModified,c.records,c.updatedRecords);c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.update],Ext.data.Api.actions.update);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectModified,c.records,c.updatedRecords);
c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.create],Ext.data.Api.actions.create);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectCreated,c.records,c.updatedRecords);c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.destroy],Ext.data.Api.actions.destroy);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectDeleted,c.records,c.updatedRecords)}},onExternalWrite:function(a,b,c,d,e){if(a!==this){c={};c[b]=Ext.isArray(e)?e:[e];this.onExternalSave(a,
c)}},containsFolderInLastLoad:function(a){if(!this.lastOptions)return false;Ext.isArray(a)||(a=[a]);var b=this.lastOptions.folder;if(Ext.isDefined(b)){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++)if(a.indexOf(b[c].get("entryid"))>-1)return true}return false},onNotify:function(a,b,c,d,e){if(this.fireEvent("beforenotify",this,a,b,c,d,e)!==false){var f=this["onNotify"+Ext.util.Format.capitalize(a)];Ext.isFunction(f)&&f.call(this,a,b,c,d,e);this.fireEvent("notify",this,a,b,c,d,e)}},onNotifyObjectdeleted:function(a,
b){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){b[c].setEventPropagation(false);b[c].phantom=true}this.remove(b)},onNotifyObjectmodified:function(a,b,c){Ext.isArray(b)||(b=[b]);a=0;for(var d=b.length;a<d;a++){var e=b[a],f=Ext.isArray(c)?c[a]:c;e.setEventPropagation(false);if(f instanceof Ext.data.Record){e.applyData(f);e.commit()}else this.reader.update(e,f);e.setEventPropagation(true)}},onNotifyObjectcreated:function(a,b,c,d){if(!d||this.lastExecutionTime(Zarafa.core.Actions.list)<d)this.reload()},
destroy:function(){if(!this.standalone){Zarafa.core.data.IPMStoreMgr.un("afterrecordwrite",this.onExternalWrite,this);this.serveronly||Zarafa.core.data.IPMStoreMgr.un("beforerecordsave",this.onExternalSave,this);Zarafa.core.data.IPMStoreMgr.unregister(this,this.serveronly)}Zarafa.core.data.IPMStore.superclass.destroy.call(this)}});Ext.reg("zarafa.ipmstore",Zarafa.core.data.IPMStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMRecipientResolveProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{listModuleName:"resolvenamesmodule",getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.core.data.IPMRecipientResolveResponseHandler({proxy:this,action:Ext.data.Api.actions.read,reader:f,sendRecords:d,options:i,callback:g,scope:h})},request:function(a,b,c,d,e,f,g){switch(a){case Zarafa.core.Actions.checknames:this.readAction(a,b,c,d,e,f,g);break}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.core.data.IPMResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:i,callback:g,scope:h})},readAction:function(a,b,c,d,e,f,g){if(Ext.isDefined(c.start)){c.restriction=c.restriction||{};c.restriction.start=c.start;delete c.start}if(Ext.isDefined(c.limit)){c.restriction=c.restriction||{};c.restriction.limit=c.limit;delete c.limit}if(Ext.isDefined(c.sort)&&
!Ext.isArray(c.sort)){c.sort=[{field:c.sort,direction:c.dir}];delete c.dir}Zarafa.core.data.IPMProxy.superclass.readAction.call(this,a,b,c,d,e,f,g)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPFStore=Ext.extend(Zarafa.core.data.MAPIStore,{standalone:false,serveronly:false,constructor:function(a){a=a||{};this.addEvents("beforenotify","notify");Zarafa.core.data.IPFStore.superclass.constructor.call(this,a);this.standalone||Zarafa.core.data.IPFStoreMgr.register(this,this.serveronly)},initEvents:function(){Zarafa.core.data.IPFStore.superclass.initEvents.call(this);if(!this.standalone){this.serveronly||Zarafa.core.data.IPFStoreMgr.on("beforerecordsave",this.onExternalSave,
this);Zarafa.core.data.IPFStoreMgr.on("afterrecordwrite",this.onExternalWrite,this)}},getRecordsForUpdateData:function(a,b){var c={records:[],updatedRecords:[]};if(Ext.isDefined(a)){Ext.isArray(a)||(a=[a]);if(b===Ext.data.Api.actions.create)for(var d=0,e=a.length;d<e;d++){var f=a[d],g=this.containsStoreInLastLoad(f.get("store_entryid"));if(f.store!==this&&g){c.records.push(f.copy());c.updatedRecords.push(f)}}else{d=0;for(e=a.length;d<e;d++){f=a[d];g=this.getByEntryId(f.get("entryid"));if(g!==this&&
g){c.records.push(g);c.updatedRecords.push(f)}}}}return c},onExternalSave:function(a,b){var c;if(a!==this){c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.open],Ext.data.Api.actions.open);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectModified,c.records,c.updatedRecords);c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.update],Ext.data.Api.actions.update);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectModified,c.records,c.updatedRecords);
c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.create],Ext.data.Api.actions.create);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectCreated,c.records,c.updatedRecords);c=this.getRecordsForUpdateData(b[Ext.data.Api.actions.destroy],Ext.data.Api.actions.destroy);Ext.isEmpty(c.records)||this.onNotify(Zarafa.core.data.Notifications.objectDeleted,c.records,c.updatedRecords)}},onExternalWrite:function(a,b,c,d,e){if(a!==this){c={};c[b]=Ext.isArray(e)?e:[e];this.onExternalSave(a,
c)}},containsStoreInLastLoad:function(){return false},onNotify:function(a,b,c,d,e){if(this.fireEvent("beforenotify",this,a,b,c,d,e)!==false){var f=this["onNotify"+Ext.util.Format.capitalize(a)];Ext.isFunction(f)&&f.call(this,a,b,c,d,e);this.fireEvent("notify",this,a,b,c,d,e)}},destroy:function(){this.standalone||Zarafa.core.data.IPFStoreMgr.unregister(this,this.serveronly);Zarafa.core.data.IPFStore.superclass.destroy.call(this)}});Ext.reg("zarafa.ipfstore",Zarafa.core.data.IPFStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.AbstractResponseHandler=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},responseFailure:Ext.emptyFn,start:Ext.emptyFn,handle:function(a,b){var c=this["do"+Ext.util.Format.capitalize(a)];if(Ext.isFunction(c))return c.call(this,b)},done:Ext.emptyFn});Ext.namespace("Zarafa.core");
Zarafa.core.Plugin=Ext.extend(Zarafa.core.data.StatefulObservable,{name:"",getName:function(){return this.name},registerInsertionPoint:function(a,b,c){if(!this.insertionPoints)this.insertionPoints=[];c||(c=this);this.insertionPoints.push({match:a,createFunction:b,scope:c})},getComponents:function(a){var b=[],c=Ext.toArray(arguments);Ext.each(this.insertionPoints,function(d){if(typeof d.match=="string"&&d.match==a||d.match.constructor&&d.match.constructor==RegExp&&d.match.test(a)){d=d.createFunction.apply(d.scope,
c);if(d==undefined||d==null)d=[];Ext.isArray(d)||(d=[d]);b.push.apply(b,d)}},this);return b},bidSharedComponent:function(){return-1},getSharedComponent:function(){}});Ext.namespace("Zarafa.core");
Zarafa.core.Enum=Ext.extend(Object,{get:function(a){a=parseInt(a,10);for(var b in this)if(this[b]==a)return this[b]},getName:function(a){a=parseInt(a,10);for(var b in this)if(this[b]==a)return b},getValue:function(a){a=this[a];if(Ext.isNumber(a))return a},addProperty:function(a){var b=0;for(var c in this)if(typeof this[c]=="number"){if(c==a)return this[c];if(b<this[c])b=this[c]}b++;return this[a]=b}});Zarafa.core.Enum.create=function(a){return new (Ext.extend(Zarafa.core.Enum,a))};Ext.namespace("Zarafa.core");
Zarafa.core.ContextModel=Ext.extend(Zarafa.core.data.StatefulObservable,{current_data_mode:undefined,store:undefined,folders:undefined,selectedRecords:undefined,defaultFolder:undefined,statefulRecordSelection:false,lastPreviewedRecord:{},lastSelectedRecord:{},isBusySearching:false,constructor:function(a){a=a||{};Ext.applyIf(a,{stateful:true});this.addEvents("previewrecordchange","recordselectionchange","folderchange","datamodechange","beforesearchstart","searchstart","searchupdate","beforesearchstop",
"searchstop","searchfinish","searchexception");Zarafa.core.Context.superclass.constructor.call(this,a);if(this.statefulRecordSelection===true){this.store.on("beforeload",this.onBeforeLoad,this);this.store.on("load",this.onLoad,this)}a=container.getHierarchyStore();a.on("load",this.onHierarchyLoad,this);this.onHierarchyLoad(a)},enable:function(a){this.stateful&&this.initState();this.setFolders(a,true);this.setDataMode(this.getCurrentDataMode(),true)},disable:function(){this.stopSearch();this.store.removeAll(true)},
onBeforeLoad:function(a,b){b&&b.actionType===Zarafa.core.Actions.updatesearch||b.reload!==true&&this.setPreviewRecord(undefined,false)},onLoad:function(a,b,c){if(!(c&&c.actionType===Zarafa.core.Actions.updatesearch)){var d,e=[];if(!Ext.isEmpty(b)){if(c&&c.params){if(b=this.lastPreviewedRecord[c.params.entryid])d=a.getByEntryId(b);if(c=this.lastSelectedRecord[c.params.entryid]){b=0;for(var f=c.length;b<f;b++){var g=a.getByEntryId(c[b]);g&&e.push(g)}}}Ext.isEmpty(e)||this.setSelectedRecords(e,false);
Ext.isDefined(d)&&this.setPreviewRecord(d,false)}}},onHierarchyLoad:function(a){if(a.getCount()!==0)if(!Ext.isEmpty(this.store)&&!Ext.isEmpty(this.store.preferredMessageClass)){var b=Zarafa.core.MessageClass.getDefaultFolderTypeFromMessageClass(this.store.preferredMessageClass);(this.defaultFolder=a.getDefaultFolder(b))&&container.getCurrentContext().getModel()===this&&Ext.isEmpty(this.folders)&&this.addFolder(this.defaultFolder)}},getStore:function(){return this.store},addFolder:function(a){var b=
this.getFolder(a.get("entryid"));if(!Ext.isDefined(b)){this.folders.push(a);this.onFolderChange(this,this.folders);this.fireEvent("folderchange",this,this.folders);this.load();return a}},removeFolder:function(a){a=this.getFolder(a.get("entryid"));if(Ext.isDefined(a)){this.folders.remove(a);Ext.isEmpty(this.folders)&&this.folders.push(this.defaultFolder);this.onFolderChange(this,this.folders);this.fireEvent("folderchange",this,this.folders);this.load();return a}},setFolders:function(a,b){this.folders=
Ext.isArray(a)?a.clone():Ext.isDefined(a)?[a]:[];this.onFolderChange(this,this.folders);this.fireEvent("folderchange",this,this.folders);b!==true&&this.load()},onFolderChange:function(a,b){this.stopSearch();if(this.stateful&&!Ext.isEmpty(b)){var c=b[0];c=container.getHierarchyStore().getState(c,"list");var d=this.store.defaultSortInfo;if(c&&c.sort)d=c.sort;d&&this.store.setDefaultSort(d.field,d.direction)}},getFolders:function(){return this.folders||[]},getDefaultFolder:function(){var a=this.getFolders();
if(Ext.isEmpty(a))if(this.defaultFolder)return this.defaultFolder;else return;return a[0]},getFolder:function(a){var b=undefined;Ext.each(this.getFolders(),function(c){if(Zarafa.core.EntryId.compareEntryIds(c.get("entryid"),a)){b=c;return false}});return b},hasFolder:function(a){if(a instanceof Zarafa.core.data.MAPIRecord)a=a.get("entryid");return Ext.isDefined(this.getFolder(a))},createRecord:Ext.emptyFn,setSelectedRecords:function(a,b){if(!this.selectedRecords||!a||!this.selectedRecords.equals(a)){this.selectedRecords=
a;if(this.statefulRecordSelection===true&&b!==false&&!Ext.isEmpty(a))this.lastSelectedRecord[a[0].get("parent_entryid")]=Ext.pluck(a,"id");this.fireEvent("recordselectionchange",this,a)}},getSelectedRecords:function(){return this.selectedRecords},load:function(a){if(Ext.isEmpty(this.folders)){this.setPreviewRecord(undefined,false);this.store.removeAll(true)}else{a=Ext.applyIf(a||{},{folder:this.folders});this.store.load(a)}},reload:function(){this.store.reload()},setPreviewRecord:function(a,b){if(this.previewRecord!==
a){this.previewRecord=a;if(this.statefulRecordSelection===true&&b!==false&&Ext.isDefined(a))this.lastPreviewedRecord[a.get("parent_entryid")]=a.get("entryid");this.fireEvent("previewrecordchange",this,a)}},getPreviewRecord:function(){return this.previewRecord},setDataMode:function(a,b){if(b===true||this.current_data_mode!==a){var c=this.current_data_mode;this.current_data_mode=a;this.onDataModeChange(this,this.current_data_mode,c);this.fireEvent("datamodechange",this,this.current_data_mode,c)}},onDataModeChange:Ext.emptyFn,
getCurrentDataMode:function(){return this.current_data_mode},clearGrouping:function(){Ext.isEmpty(this.store.groupField)||this.store.clearGrouping()},groupBy:function(a){this.store.groupBy(a)},isSearching:function(){return this.isBusySearching},supportsSearchFolder:function(){var a=this.getDefaultFolder();if(Ext.isEmpty(a))return false;a=a.getMAPIStore();if(!a)return false;return a.hasSearchSupport()},startSearch:function(a,b){var c=this.supportsSearchFolder();c||(b=false);if(this.fireEvent("beforesearchstart",
this,a,b)!==false){this.isBusySearching=true;this.fireEvent("searchstart",this,a,b);this.store.on("exception",this.onSearchException,this);c&&this.store.on("beforeupdatesearch",this.onSearchUpdate,this);this.store.search({folder:this.getFolders(),useSearchFolder:c,subfolders:b,searchRestriction:a})}},stopSearch:function(){if(this.isBusySearching&&this.fireEvent("beforestopsearch",this)!==false){this.store.stopSearch({});this.store.un("exception",this.onSearchException,this);this.store.un("beforeupdatesearch",
this.onSearchUpdate,this);this.isBusySearching=false;this.fireEvent("searchstop",this)}},onSearchUpdate:function(a,b){this.fireEvent("searchupdate",this,a,b);if(!Zarafa.core.mapi.Search.isSearchRunning(b.searchState)){this.store.un("exception",this.onSearchException,this);this.store.un("beforeupdatesearch",this.onSearchUpdate,this);this.fireEvent("searchfinished",this)}},onSearchException:function(a,b,c,d,e,f){this.store.un("exception",this.onSearchException,this);this.store.un("beforeupdatesearch",
this.onSearchUpdate,this);this.isBusySearching=false;this.fireEvent("searchexception",this,a,b,c,d,e,f)},getStateName:function(){var a=this.statefulName;if(!a)if(this.store)a=this.store.preferredMessageClass.match(/(?:IPM\.)?(.*)/)[1].toLowerCase();return"models/"+a},initStateEvents:function(){Zarafa.core.ContextModel.superclass.initStateEvents.call(this);this.on("datamodechange",this.saveState,this,{delay:100})},getState:function(){var a=Zarafa.core.ContextModel.superclass.getState.call(this)||{},
b=this.isSearching();return Ext.apply(a,b?{}:{current_data_mode:this.current_data_mode})}});Ext.namespace("Zarafa.core");
Zarafa.core.ContainerClass={isClass:Zarafa.core.MessageClass.isClass,isMessageClassCompatible:function(a,b){return Zarafa.core.MessageClass.isContainerClassCompatible(b,a)},getDefaultFolderTypeFromContainerClass:function(a){a=a.toUpperCase();switch(a){case "IPF.APPOINTMENT":return"calendar";case "IPF.STICKYNOTE":return"note";case "IPF.CONTACT":return"contact";case "IPF.TASK":return"task";case "IPF.NOTE":return"inbox"}var b=a.lastIndexOf(".");if(b>0){a=a.substr(0,b);return this.getDefaultFolderTypeFromContainerClass(a)}return""}};
Zarafa.core.Container=Ext.extend(Ext.util.Observable,{paralyzed:false,contexts:undefined,plugins:undefined,widgets:undefined,constructor:function(){this.addEvents(["paralyze","beforecontextswitch","contextswitch","aftercontextswitch","folderselect","beforelogout","logout"]);Zarafa.core.Container.superclass.constructor.call(this);this.plugins={};this.contexts=[];this.widgets=[]},logout:function(){if(this.fireEvent("beforelogout")!==false){this.fireEvent("logout");this.doLogout()}},doLogout:function(){window.location=
"index.php?logout"},paralyze:function(){this.paralyzed=true;this.fireEvent("paralyze")},isParalyzed:function(){return this.paralyzed},getUser:function(){return this.userRecord},setUser:function(a){this.userRecord=new Zarafa.core.data.User(a)},getLanguages:function(){return this.languages},setLanguages:function(a){this.languages=a},getCurrentContext:function(){return this.currentContext||this.getContextByName("default")},getRequest:function(){return this.request||(this.request=new Zarafa.core.Request({url:"zarafa.php"}))},
getResponseRouter:function(){return this.responseRouter||(this.responseRouter=new Zarafa.core.ResponseRouter)},getNotificationResolver:function(){return this.notificationResolver||(this.notificationResolver=new Zarafa.core.data.NotificationResolver)},getHierarchyStore:function(){return this.hierarchyStore||(this.hierarchyStore=new Zarafa.hierarchy.data.HierarchyStore)},getSettingsModel:function(){return this.settingsModel||(this.settingsModel=new Zarafa.settings.SettingsModel)},getShadowStore:function(){return this.shadowStore||
(this.shadowStore=new Zarafa.core.data.ShadowStore)},getNotifier:function(){return this.notifier||(this.notifier=new Zarafa.core.ui.notifier.Notifier)},getMainPanel:function(){return this.mainPanel||(this.mainPanel=new Zarafa.core.ui.MainViewport)},getContentPanel:function(){return this.getMainPanel().getContentPanel().getActiveItem()},getNavigationBar:function(){return this.getMainPanel().getNavigationPanel()},getWidgetSideBar:function(){return this.getMainPanel().getWidgetPanel()},getPlugins:function(){return this.plugins},
getContexts:function(){return this.contexts},getWidgets:function(){return this.widgets},getContextByName:function(a){for(var b=this.getContexts(),c,d=0,e=b.length;d<e;d++)if(b[d].getName()===a){c=b[d];break}return c},getPluginByName:function(a){var b=this.getPlugins();if(b)for(var c in b)if(a===b[c].getName())return b[c]},getWidgetByName:function(a){for(var b=this.getWidgets(),c,d=0,e=b.length;d<e;d++)if(b[d].getName()===a){c=b[d];break}return c},populateInsertionPoint:function(){var a=[],b=Ext.toArray(arguments);
if(this.plugins)for(var c in this.plugins){var d=this.plugins[c].getComponents.apply(this.plugins[c],b);Ext.each(d,function(e){e.plugin=this.plugins[c];a.push(e)},this)}return Ext.flatten(a)},registerContext:function(a){this.registerPlugin(a);this.getContexts().push(a)},registerPlugin:function(a){this.getPlugins()[a.getName()]=a},registerWidget:function(a,b,c,d){a.getName=function(){return b};a.getDisplayName=function(){return c||b};a.getIconPath=function(){return d||b};this.getWidgets().push(a)},
switchContext:function(a,b){var c=this.getCurrentContext();if(c!==a&&this.fireEvent("beforecontextswitch",b,c,a)!==false){if(c){c.disable();var d=c.getModel();d&&d.un("folderchange",this.onContextFolderChange,this)}a.enable(b);(d=a.getModel())&&d.on("folderchange",this.onContextFolderChange,this);this.currentContext=a;this.fireEvent("folderselect",b);this.fireEvent("contextswitch",b,c,a);this.fireEvent("aftercontextswitch",b,c,a)}},getContextByFolder:function(a){var b,c,d=this.getContexts();if(d)for(var e=
0,f=d.length;e<f;e++){var g=d[e],h=g.bid(a);if(c===undefined||h>c){c=h;b=g}}return b},selectFolder:function(a){var b=this.getContextByFolder(a);if(this.getCurrentContext()!==b)this.switchContext(b,a);else(b=b.getModel())&&b.setFolders(a)},reloadContext:function(a){var b=this.getCurrentContext(),c=b.getModel();if(Ext.isDefined(c)){a=c.getFolder(a.get("entryid"));if(Ext.isDefined(a)){a=c.getFolders();b.disable();b.enable(a)}}},onContextFolderChange:function(a,b){this.fireEvent("folderselect",b)},getSharedComponent:function(a,
b){var c,d,e=container.getPlugins(),f;if(a&&e){for(var g in e){var h=e[g].bidSharedComponent(a,b);if(d===undefined||h>d){d=h;c=e[g]}}if(c&&d>=0)f=c.getSharedComponent(a,b)}return f},getReminderStore:function(){return this.reminderStore||(this.reminderStore=new Zarafa.common.reminder.data.ReminderStore)}});Ext.namespace("Zarafa.common.ui.messagepanel");
Zarafa.common.ui.messagepanel.ExtraInfoContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};if(a.records)if(Ext.isArray(a.records))a.records=a.records[0];Ext.applyIf(a,{items:[{xtype:"zarafa.conditionalitem",text:_("Download Pictures"),handler:this.showPictures,scope:this},{xtype:"menuseparator"},{xtype:"zarafa.conditionalitem",text:_("Add Sender to Safe Senders List"),handler:this.addSenderToSafeList,scope:this},{xtype:"zarafa.conditionalitem",text:_("Add Domain to Safe Senders List"),
handler:this.addDomainToSafeList,scope:this},{xtype:"menuseparator"},container.populateInsertionPoint("context.common.recipientfield.contextmenu.actions",this)]});Zarafa.common.ui.messagepanel.ExtraInfoContextMenu.superclass.constructor.call(this,a)},showPictures:function(){var a=this.records.calculateBlockStatus();if(a){this.records.set("block_status",a);this.records.save()}},addSenderToSafeList:function(){var a=this.records.get("sent_representing_email_address")||this.records.get("sender_email_address");
if(!Ext.isEmpty(a)){var b=container.getSettingsModel().get("zarafa/v1/contexts/mail/safe_senders_list",true);b=Zarafa.core.Util.objToArray(b);if(Ext.isEmpty(b))b=[a];else b.push(a);container.getSettingsModel().set("zarafa/v1/contexts/mail/safe_senders_list",b);this.records.afterEdit()}},addDomainToSafeList:function(){var a=this.records.get("sent_representing_email_address")||this.records.get("sender_email_address");a=a.substr(a.indexOf("@")+1);if(!Ext.isEmpty(a)){var b=container.getSettingsModel().get("zarafa/v1/contexts/mail/safe_senders_list",
true);b=Zarafa.core.Util.objToArray(b);if(Ext.isEmpty(b))b=[a];else b.push(a);container.getSettingsModel().set("zarafa/v1/contexts/mail/safe_senders_list",b);this.records.afterEdit()}}});Ext.reg("zarafa.extrainfocontextmenu",Zarafa.common.ui.messagepanel.ExtraInfoContextMenu);Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion=Ext.extend(Ext.layout.BorderLayout.Region,{hidden:undefined,oldSize:undefined,setVisible:function(a){var b=this.hidden;this.hidden=a===false;if(b!==this.hidden)if(this.hidden)this.oldSize=this.position==="north"||this.position==="south"?this.panel.getHeight():this.panel.getWidth();else{this.panel.region=this.position;this.position==="north"||this.position==="south"?this.panel.setHeight(this.oldSize||this.panel.height):this.panel.setWidth(this.oldSize||
this.panel.width)}},isVisible:function(){return Ext.isDefined(this.hidden)?!this.hidden:!this.panel.hidden},getSize:function(){return this.restrictSize(Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion.superclass.getSize.call(this))},restrictSize:function(a){var b=this.panel,c=this.layout.center.panel,d=this.targetEl,e=this.splitEl;if(this.position==="north"||this.position==="south"){if(a.height>=d.getHeight()){a.height=b.height?b.height:Math.min(b.maxHeight||0,d.getHeight()-(c.minHeight||c.height));
a.height-=e.dom.offsetHeight}}else if(a.width>=d.getWidth()){a.width=b.width?b.width:Math.min(b.maxWidth||0,d.getWidth()-(c.minWidth||c.width));a.width-=e.dom.offsetWidth}return a}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Word=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{lastValue:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-wordpaste",handler:this.onWordPaste,scope:this,enableToggle:true,pressed:true,tooltip:{title:_("Word Paste"),text:_("Cleanse text pasted from Word or other Rich Text applications"),cls:"x-html-editor-tip"},overflowText:_("Word Paste"),tabIndex:a.tabIndex,listeners:{render:this.onButtonRender,scope:this}}});Zarafa.common.ui.htmleditor.Word.superclass.constructor.call(this,
a)},onButtonRender:function(a){if(a.pressed)this.editor.initialized?this.onWordPaste(a):this.editor.mon(this.editor,"initialize",this.onWordPaste.createDelegate(this,[a]));this.editor.on("beforedestroy",this.onEditorBeforeDestroy,this)},onWordPaste:function(a){if(a.pressed===true){this.lastValue=this.editor.getValue();this.editor.mon(this.editor,"blur",this.onEditorBlur,this);Zarafa.core.Events.addPasteEventHandler(this.editor,this.editor.getEl(),this.onPaste,this);Zarafa.core.Events.addPasteEventHandler(this.editor,
this.editor.getDoc(),this.onPaste,this)}else{Zarafa.core.Events.removePasteEventHandler(this.editor,this.editor.getDoc(),this.onPaste,this);Zarafa.core.Events.removePasteEventHandler(this.editor,this.editor.getEl(),this.onPaste,this);this.editor.mun(this.editor,"blur",this.onEditorBlur,this)}},onPaste:function(){this.editor.suspendEvents();this.editor.getWin().getSelection();var a=this.editor.getValue(),b=a.length,c=this.findValueDiffAt(a,this.lastValue),d=this.findLastValueDiffAt(a,this.lastValue);
this.editor.setValue([a.substr(0,c),this.fixWordPaste(a.substr(c,d-c)),a.substr(d,b)].join(""));this.lastValue=this.editor.getValue();this.editor.resumeEvents()},findValueDiffAt:function(a,b){for(var c=a.length,d=0,e=Math.min(c,b.length);d<e;d++)if(a[d]!=b[d]){for(c=d;c>0;c--)if(a[c]==="<")return c;return 0}return c},findLastValueDiffAt:function(a,b){for(var c=a.length,d=b.length,e=0,f=Math.min(c,d);e<f;e++)if(a[c-e]!=b[d-e]){for(d=e;d>0;d--)if(a[c-d]===">")return c-d+1;return c}return c},fixWordPaste:function(a){Ext.each([/[\r\n]/g,
/<(xml|style|script|title)[^>]*>.*?<\/\1>/ig,/<\/?(meta|link|object|span)[^>]*>/ig,/<\/?[A-Z0-9]*:[A-Z]*[^>]*>/ig,/<![\[-].*?-*>/g,/<\\?\?xml[^>]*>/ig,/<\/?o:p[^>]*>/ig,/<\/?v:[^>]*>/ig,/<\/?o:[^>]*>/ig,/<\/?st1:[^>]*>/ig,/<\/?SPAN[^>]*>/ig,/<\/?FONT[^>]*>/ig,/<\/?STRONG[^>]*>/ig,/<\/?H1[^>]*>/ig,/<\/?H2[^>]*>/ig,/<\/?H3[^>]*>/ig,/<\/?H4[^>]*>/ig,/<\/?H5[^>]*>/ig,/<\/?H6[^>]*>/ig,/<\/?P[^>]*><\/P>/ig,/<!--(.*)--\>/g,/<!--(.*)>/g,/<!(.*)--\>/g,/<w:[^>]*>(.*)<\/w:[^>]*>/g],function(b){a=a.replace(b,
"")});a=a.replace(/(<[^>]*)(on[a-zA-Z0-9]*=[^>]*>)/ig,"$1block$2");a=a.replace(/(<[^>]*)(style|lang|class|type|name|title|id|clear)=[\"\'][^\"\']*[\"\']([^>]*>)/ig,"$1$3");a=a.replace(/<div[^>]*>/ig,'<p style="margin: 0px;">');return a=a.replace(/<\/?div[^>]*>/ig,"</p>")},onEditorBlur:function(){this.lastValue=this.editor.getValue()},onEditorBeforeDestroy:function(){Zarafa.core.Events.removePasteEventHandler(this.editor,this.editor.getDoc(),this.onPaste,this);Zarafa.core.Events.removePasteEventHandler(this.editor,
this.editor.getEl(),this.onPaste,this)}});Ext.preg("zarafa.htmleditor.word",Zarafa.common.ui.htmleditor.Word);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Unlink=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-removelink",itemId:"unlink",handler:this.relayBtnCmd,scope:this,enableToggle:false,disabled:true,tooltip:{title:_("Remove Link"),text:_("Remove Link from the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Remove Link"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Unlink.superclass.constructor.call(this,a)}});
Ext.preg("zarafa.htmleditor.unlink",Zarafa.common.ui.htmleditor.Unlink);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Undo=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-undo",itemId:"undo",handler:this.relayBtnCmd,scope:this,enableToggle:false,disabled:true,tooltip:{title:_("Undo"),text:_("Undo the last change"),cls:"x-html-editor-tip"},overflowText:_("Undo"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Undo.superclass.constructor.call(this,a)}});Ext.preg("zarafa.htmleditor.undo",Zarafa.common.ui.htmleditor.Undo);
Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.TableDialog=Ext.extend(Zarafa.common.ui.htmleditor.InsertDialog,{tableBorderOptions:[["none",_("None")],["1px solid #000",_("Solid Thin")],["2px solid #000",_("Solid Thick")],["1px dashed #000",_("Dashed")],["1px dotted #000",_("Dotted")]],labelFormat:"{0}-{1}",constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Insert Table"),formItems:this.createTablePanel(a)});Zarafa.common.ui.htmleditor.TableDialog.superclass.constructor.call(this,a)},createTablePanel:function(a){a=
new Ext.data.ArrayStore({fields:["css","name"],data:a.tableBorderOptions||this.tableBorderOptions});return[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],allowBlank:false,allowDecimals:false,minValue:1,fieldLabel:_("Rows"),name:"rows",defaultValue:5},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],allowBlank:false,allowDecimals:false,minValue:1,fieldLabel:_("Columns"),name:"cols",defaultValue:5},{xtype:"combo",fieldLabel:_("Border"),name:"border",forceSelection:true,mode:"local",
store:a,triggerAction:"all",value:a.getAt(0).get("css"),displayField:"name",valueField:"css",editable:false},{xtype:"checkbox",fieldLabel:_("Label Cells"),checked:true,name:"showcelltext"}]},formatHTML:function(a){var b="",c=a.rows,d=a.cols;if(c>0&&d>0){var e=Math.floor(100/d),f="&nbsp;",g="border: "+a.border+";";if(a.showcelltext)f=this.labelFormat;b+="<table style='border-collapse: collapse'>";for(a=0;a<c;a++){b+="<tr>";for(var h=0;h<d;h++){b+="<td width='"+e+"%' style='"+g+"'>";b+=String.format(f,
a+1,String.fromCharCode(h+65));b+="</td>"}b+="</tr>"}b+="</table><br />"}return b}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Table=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-table",handler:this.onInsertTable,scope:this,enableToggle:false,tooltip:{title:_("Insert Table"),text:_("Insert Table at the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Insert Table"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Table.superclass.constructor.call(this,a)},onInsertTable:function(){(new Zarafa.common.ui.htmleditor.TableDialog({handler:this.editor.relayInsertAtCursor,
scope:this.editor})).show()}});Ext.preg("zarafa.htmleditor.table",Zarafa.common.ui.htmleditor.Table);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.SuperScript=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-superscript",itemId:"superscript",handler:this.relayBtnCmd,scope:this,enableToggle:true,tooltip:{title:_("Superscript"),text:_("Converts selected text into superscript"),cls:"x-html-editor-tip"},overflowText:_("Superscript"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.SuperScript.superclass.constructor.call(this,a)}});
Ext.preg("zarafa.htmleditor.superscript",Zarafa.common.ui.htmleditor.SuperScript);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.SubScript=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-subscript",itemId:"subscript",handler:this.relayBtnCmd,scope:this,enableToggle:true,tooltip:{title:_("Subscript"),text:_("Converts selected text into subscript"),cls:"x-html-editor-tip"},overflowText:_("Subscript"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.SubScript.superclass.constructor.call(this,a)}});
Ext.preg("zarafa.htmleditor.subscript",Zarafa.common.ui.htmleditor.SubScript);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.StrikeThrough=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-strikethrough",itemId:"strikeThrough",handler:this.relayBtnCmd,scope:this,enableToggle:true,tooltip:{title:_("Strike Through"),text:_("Strike through the selected text"),cls:"x-html-editor-tip"},overflowText:_("Strike Through"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.StrikeThrough.superclass.constructor.call(this,a)}});
Ext.preg("zarafa.htmleditor.strikethrough",Zarafa.common.ui.htmleditor.StrikeThrough);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.SpecialCharactersDialog=Ext.extend(Zarafa.common.ui.htmleditor.InsertDialog,{specialChars:[153],specialCharRange:[[160,256]],constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Insert Special Character"),width:500,formItems:this.createCharPanel(a)});Zarafa.common.ui.htmleditor.SpecialCharactersDialog.superclass.constructor.call(this,a)},createCharPanel:function(a){var b=[];a=a.specialChars||this.specialChars;a.length&&Ext.each(a,function(c,d){b[d]=["&#"+c+";"]},this);
this.specialCharRange.length&&Ext.each(this.specialCharRange,function(c){for(var d=c[0];d<c[1];d++)b.push(["&#"+d+";"])},this);return[{xtype:"dataview",store:new Ext.data.ArrayStore({fields:["char"],data:b}),ref:"../charView",multiSelect:true,tpl:new Ext.XTemplate('<tpl for="."><div class="char-item">{char}</div></tpl><div class="x-clear"></div>'),overClass:"char-over",itemSelector:"div.char-item",refresh:this.onViewRefresh.createDelegate(this),listeners:{dblclick:this.onDblClick,scope:this}}]},onViewRefresh:function(){Ext.DataView.prototype.refresh.apply(this.charView,
arguments);for(var a=this.charView.getNodes(),b=0,c=a.length;b<c;b++)Ext.fly(a[b]).unselectable()},onDblClick:function(){this.onInsert()},formatHTML:function(){for(var a=this.charView.getSelectedRecords(),b="",c=0,d=a.length;c<d;c++)b+=a[c].get("char");return b}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.SpecialCharacters=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-char",handler:this.onInsertChar,scope:this,enableToggle:false,tooltip:{title:_("Insert Special Character"),text:_("Insert Special Character at the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Insert Special Character"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.SpecialCharacters.superclass.constructor.call(this,
a)},onInsertChar:function(){(new Zarafa.common.ui.htmleditor.SpecialCharactersDialog({handler:this.editor.relayInsertAtCursor,scope:this.editor})).show()}});Ext.preg("zarafa.htmleditor.specialcharacters",Zarafa.common.ui.htmleditor.SpecialCharacters);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.RemoveFormat=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-removeFormat",itemId:"removeFormat",handler:this.relayBtnCmd,scope:this,enableToggle:false,tooltip:{title:_("Remove Formatting"),text:_("Remove all HTML formatting on the selected text"),cls:"x-html-editor-tip"},overflowText:_("Remove Formatting"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.RemoveFormat.superclass.constructor.call(this,
a)}});Ext.preg("zarafa.htmleditor.removeformat",Zarafa.common.ui.htmleditor.RemoveFormat);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Redo=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-redo",itemId:"redo",handler:this.relayBtnCmd,scope:this,enableToggle:false,disabled:true,tooltip:{title:_("Redo"),text:_("Redo the last undone change"),cls:"x-html-editor-tip"},overflowText:_("Redo"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Redo.superclass.constructor.call(this,a)}});Ext.preg("zarafa.htmleditor.redo",Zarafa.common.ui.htmleditor.Redo);
Ext.namespace("Zarafa.common.ui.htmleditor");Zarafa.common.ui.htmleditor.Outdent=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-outdent",itemId:"outdent",handler:this.relayBtnCmd,scope:this,enableToggle:false,tooltip:{title:_("Outdent Text"),text:_("Outdent the text"),cls:"x-html-editor-tip"},overflowText:_("Outdent Text"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Outdent.superclass.constructor.call(this,a)}});
Ext.preg("zarafa.htmleditor.outdent",Zarafa.common.ui.htmleditor.Outdent);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.LinkDialog=Ext.extend(Zarafa.common.ui.htmleditor.InsertDialog,{linkTargetOptions:[["_self",_("Default")],["_blank",_("New Window")],["_parent",_("Parent Window")],["_top",_("Entire Window")]],selection:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Insert Link"),formItems:this.createLinkPanel(a)});Zarafa.common.ui.htmleditor.LinkDialog.superclass.constructor.call(this,a)},createLinkPanel:function(a){var b=new Ext.data.ArrayStore({fields:["css","name"],
data:a.linkTargetOptions||this.linkTargetOptions});return[{xtype:"textfield",fieldLabel:_("URL"),allowBlank:false,vtype:"url",name:"href",value:"http://"},{xtype:"textfield",fieldLabel:_("Text"),name:"text",allowBlank:true,value:a.selection?a.selection.textContent:"",disabled:a.selection?a.selection.hasHTML:false},{xtype:"combo",fieldLabel:_("Target"),name:"target",forceSelection:true,mode:"local",store:b,triggerAction:"all",value:b.getAt(0).get("css"),displayField:"name",valueField:"css",editable:false}]},
formatHTML:function(a){var b=a.text;if(this.selection&&this.selection.hasHTML)b=this.selection.html;else{if(Ext.isEmpty(b))b=a.href;b=Ext.util.Format.htmlEncode(b)}delete a.text;var c="<a";Ext.iterate(a,function(d,e){c+=" "+d+'="'+Ext.util.Format.htmlEncode(e)+'"'},this);c+=">"+b+"</a>";return c}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Link=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-createlink",handler:this.onInsertLink,scope:this,enableToggle:false,tooltip:{title:_("Insert Link"),text:_("Insert Link at the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Insert Link"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Link.superclass.constructor.call(this,a)},onInsertLink:function(){(new Zarafa.common.ui.htmleditor.LinkDialog({selection:this.editor.getSelectedText(),
handler:this.editor.relayInsertAtCursor,scope:this.editor})).show()}});Ext.preg("zarafa.htmleditor.link",Zarafa.common.ui.htmleditor.Link);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Indent=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-indent",itemId:"indent",handler:this.relayBtnCmd,scope:this,enableToggle:false,tooltip:{title:_("Indent Text"),text:_("Indent the text"),cls:"x-html-editor-tip"},overflowText:_("Indent Text"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Indent.superclass.constructor.call(this,a)}});Ext.preg("zarafa.htmleditor.indent",Zarafa.common.ui.htmleditor.Indent);
Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.ImageDialog=Ext.extend(Zarafa.common.ui.htmleditor.InsertDialog,{imagePositionOptions:[["",_("Default")],['align: "center"',_("Center")],['align: "left"',_("Left")],['align: "right"',_("Right")],['vertical-align: "bottom"',_("Bottom")],['vertical-align: "middle"',_("Middle")],['vertical-align: "text-top"',_("Text top")],['vertical-align: "text-bottom"',_("Text bottom")],['vertical-align: "baseline"',_("Baseline")]],constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Insert Image"),
formItems:this.createImagePanel(a)});Zarafa.common.ui.htmleditor.ImageDialog.superclass.constructor.call(this,a)},createImagePanel:function(a){a=new Ext.data.ArrayStore({fields:["css","name"],data:a.imagePositionOptions||this.imagePositionOptions});return[{xtype:"textfield",fieldLabel:_("URL"),allowBlank:false,name:"src",vtype:"url",value:"http://"},{xtype:"textfield",fieldLabel:_("Name"),name:"title"},{xtype:"textfield",fieldLabel:_("Alternative"),name:"alt"},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],
fieldLabel:_("Width"),name:"width",minValue:0,defaultValue:50},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],fieldLabel:_("Height"),name:"height",minValue:0,defaultValue:50},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],fieldLabel:_("Border"),name:"border",minValue:0,defaultValue:0},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],fieldLabel:_("VSpace"),name:"vspace",minValue:0,defaultValue:0},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],
fieldLabel:_("HSpace"),name:"hspace",minValue:0,defaultValue:0},{xtype:"combo",fieldLabel:_("Align"),name:"align",forceSelection:true,mode:"local",store:a,triggerAction:"all",value:a.getAt(0).get("css"),displayField:"name",valueField:"css",editable:false}]},formatHTML:function(a){Ext.isEmpty(a.align)||(a.style=a.align);var b="<img";Ext.iterate(a,function(c,d){b+=" "+c+'="'+Ext.util.Format.htmlEncode(d)+'"'},this);b+="/>";return b}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Image=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-image",handler:this.onInsertImage,scope:this,enableToggle:false,tooltip:{title:_("Insert Image"),text:_("Insert Image at the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Insert Image"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.Image.superclass.constructor.call(this,a)},onInsertImage:function(){(new Zarafa.common.ui.htmleditor.ImageDialog({handler:this.editor.relayInsertAtCursor,
scope:this.editor})).show()}});Ext.preg("zarafa.htmleditor.image",Zarafa.common.ui.htmleditor.Image);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.HRDialog=Ext.extend(Zarafa.common.ui.htmleditor.InsertDialog,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{title:_("Horizontal Rule"),formItems:this.createHRPanel(a)});Zarafa.common.ui.htmleditor.HRDialog.superclass.constructor.call(this,a)},createHRPanel:function(){return[{xtype:"displayfield",hideLabel:true,value:_("Enter the width of the Rule in percentage followed by the % sign at the end, or to set a fixed width ommit the % symbol.")+"<br/>&nbsp;"},{xtype:"zarafa.spinnerfield",
plugins:["zarafa.percentspinner"],fieldLabel:_("Width"),name:"hrwidth",allowBlank:false,defaultValue:1,incrementValue:0.1}]},formatHTML:function(a){return'<hr width="'+a.hrwidth*100+'%">'}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.HR=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{iconCls:"x-edit-hr",handler:this.onInsertHR,scope:this,enableToggle:false,tooltip:{title:_("Horizontal Rule"),text:_("Insert Horizontal Rule at the current cursor position"),cls:"x-html-editor-tip"},overflowText:_("Horizontal Rule"),tabIndex:a.tabIndex}});Zarafa.common.ui.htmleditor.HR.superclass.constructor.call(this,a)},onInsertHR:function(){(new Zarafa.common.ui.htmleditor.HRDialog({handler:this.editor.relayInsertAtCursor,
scope:this.editor})).show()}});Ext.preg("zarafa.htmleditor.hr",Zarafa.common.ui.htmleditor.HR);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.FontSize=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{defaultFontSize:2,fontSizes:[[1,"xx-small"],[2,"x-small"],[3,"small"],[4,"medium"],[5,"large"],[6,"x-large"],[7,"xx-large"]],constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{xtype:"tbitem",itemId:"fontSize",defaultFontSize:a.defaultFontSize||this.defaultFontSize,autoEl:{tag:"select",cls:"x-fontsize-select",style:"height: 18px",html:this.createFontSizeOptions()},tooltip:{title:_("Font size"),text:_("Select font size"),
cls:"x-html-editor-tip"},overflowText:_("Font size"),tabIndex:a.tabIndex,listeners:{render:this.onButtonRender,scope:this}}});Zarafa.common.ui.htmleditor.FontSize.superclass.constructor.call(this,a)},createFontSizeOptions:function(){for(var a="",b=this.fontSizes,c=0,d=b.length;c<d;c++){var e=b[c][0],f=b[c][1];a+='<option value="'+e+'" style="font-size:'+f+';"'+(this.defaultFontSize===e?' selected="true">':">")+f+"</option>"}return a},onButtonRender:function(a){var b=a.el;a=0;for(var c=b.dom.childElementCount;a<
c;a++){var d=Ext.util.TextMetrics.measure(b.dom.children[a],"z");b.dom.children[a].text=d.height+"px"}this.editor.mon(b,"change",function(){this.editor.relayCmd("fontsize",b.dom.value);this.editor.deferFocus()},this)}});Ext.preg("zarafa.htmleditor.fontsize",Zarafa.common.ui.htmleditor.FontSize);Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Divider=Ext.extend(Zarafa.common.ui.htmleditor.HtmlEditorPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCfg:{xtype:"tbseparator"}});Zarafa.common.ui.htmleditor.Divider.superclass.constructor.call(this,a)}});Ext.preg("zarafa.htmleditor.divider",Zarafa.common.ui.htmleditor.Divider);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.TimeSpinner=Ext.extend(Zarafa.common.ui.SpinnerPlugin,{format:_("G:i"),alternateIncrementField:Date.HOUR,incrementField:Date.MINUTE,constructor:function(a){Ext.applyIf(this,a);Zarafa.common.ui.TimeSpinner.superclass.constructor.call(this,a)},init:function(a){Zarafa.common.ui.TimeSpinner.superclass.init.call(this,a);if(Ext.isDefined(a.defaultValue)&&!Ext.isDate(a.defaultValue))a.defaultValue=Date.parseDate(a.defaultValue,this.format);if(Ext.isDefined(a.minValue)&&!Ext.isDate(a.minValue))a.minValue=
Date.parseDate(a.minValue,this.format);if(Ext.isDefined(a.maxValue)&&!Ext.isDate(a.maxValue))a.maxValue=Date.parseDate(a.maxValue,this.format);this.dateValue=a.defaultValue;if(Ext.isDate(this.dateValue))a.value=this.dateValue.format(this.format);this.setStringValue=a.setValue.createDelegate(a);this.getStringValue=a.getValue.createDelegate(a);a.setValue=this.setValue.createDelegate(this);a.getValue=this.getValue.createDelegate(this)},setStringValue:Ext.emptyFn,getStringValue:Ext.emptyFn,setValue:function(a){if(!Ext.isDefined(a)||
Ext.isEmpty(a)){this.dateValue=undefined;this.setStringValue("")}else if(Ext.isDate(a)){this.dateValue=a.clone();this.setStringValue(a.format(this.format))}else if(Ext.isDate(this.dateValue)){var b=Date.parseDate(a,this.format);a=this.dateValue.clone();a.setHours(b.getHours());a.setMinutes(b.getMinutes());this.dateValue=a;this.setStringValue(a.format(this.format))}else{this.dateValue=Date.parseDate(a,this.format);this.setStringValue(a)}},getValue:function(){var a=this.getStringValue();if(!(Ext.isEmpty(a)||
!Ext.isDefined(this.dateValue))){a=Date.parseDate(a,this.format);this.dateValue.setHours(a.getHours());this.dateValue.setMinutes(a.getMinutes());return this.dateValue.clone()}},spin:function(a,b){var c;this.field.onFocus();var d=this.field.getValue(),e=b==true?this.field.alternateIncrementValue:this.field.incrementValue,f=b==true?this.alternateIncrementField:this.incrementField;c=d;d=d.add(f,a?-1*e:e);if(!a&&d<=c)d=d.add(Date.HOUR,2);d=!Ext.isDate(d)?this.field.defaultValue:d;d=this.fixBoundries(d);
this.field.setValue(d)},fixPrecision:function(a){return a}});Ext.preg("zarafa.timespinner",Zarafa.common.ui.TimeSpinner);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.TimePeriodField=Ext.extend(Zarafa.common.ui.DateRangeField,{timeFormat:_("G:i"),timeIncrement:30,pluginCfg:undefined,constructor:function(a){a=a||{};a.startFieldConfig=a.startFieldConfig||{};a.startFieldConfig.plugins=Ext.value(a.startFieldConfig.plugins,[]);a.startFieldConfig.plugins.push(Ext.applyIf(a.pluginCfg||{},{ptype:"zarafa.timespinner",format:a.timeFormat||this.timeFormat}));a.startFieldConfig.listeners=Ext.value(a.startFieldConfig.listeners,{});a.startFieldConfig.listeners.spin=
a.startFieldConfig.listeners.spin?a.startFieldConfig.listeners.spin.createInterceptor(this.onStartSpin,this):this.onStartSpin.createDelegate(this);Ext.applyIf(a.startFieldConfig,{xtype:"zarafa.spinnerfield",fieldLabel:_("Start time"),minValue:a.minValue||this.minValue,maxValue:a.maxValue||this.maxValue,incrementValue:a.timeIncrement||this.timeIncrement,alternateIncrementValue:1});a.endFieldConfig=a.endFieldConfig||{};a.endFieldConfig.plugins=Ext.value(a.endFieldConfig.plugins,[]);a.endFieldConfig.plugins.push(Ext.applyIf(a.pluginCfg||
{},{ptype:"zarafa.timespinner",format:a.timeFormat||this.timeFormat}));a.endFieldConfig.listeners=Ext.value(a.endFieldConfig.listeners,{});a.endFieldConfig.listeners.spin=a.endFieldConfig.listeners.spin?a.endFieldConfig.listeners.spin.createInterceptor(this.onEndSpin,this):this.onEndSpin.createDelegate(this);a.endFieldConfig=Ext.applyIf(a.endFieldConfig||{},{xtype:"zarafa.spinnerfield",fieldLabel:_("End time"),minValue:a.minValue||this.minValue,maxValue:a.maxValue||this.maxValue,incrementValue:a.timeIncrement||
this.timeIncrement,alternateIncrementValue:1});Zarafa.common.ui.TimePeriodField.superclass.constructor.call(this,a)},onStartSpin:function(a){this.onStartChange(a.field,a.field.getValue(),a.field.startValue)},onEndSpin:function(a){this.onEndChange(a.field,a.field.getValue(),a.field.startValue)}});Ext.reg("zarafa.timeperiodfield",Zarafa.common.ui.TimePeriodField);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.NumberSpinner=Ext.extend(Zarafa.common.ui.SpinnerPlugin,{allowDecimals:true,decimalSeparator:".",decimalPrecision:2,allowNegative:true,constructor:function(a){Ext.applyIf(this,a);Zarafa.common.ui.NumberSpinner.superclass.constructor.call(this,a)},init:function(a){Zarafa.common.ui.NumberSpinner.superclass.init.call(this,a);if(Ext.isDefined(a.defaultValue)&&Ext.isString(a.defaultValue))a.defaultValue=parseFloat(a.defaultValue);if(Ext.isDefined(a.minValue)){if(Ext.isString(a.minValue))a.minValue=
parseFloat(a.minValue)}else a.minValue=Ext.form.NumberField.minValue;if(Ext.isDefined(a.maxValue)){if(Ext.isString(a.maxValue))a.maxValue=parseFloat(a.maxValue)}else a.maxValue=Ext.form.NumberField.maxValue;if(!Ext.isDefined(a.allowDecimals))a.allowDecimals=this.allowDecimals;if(!Ext.isDefined(a.decimalSeparator))a.decimalSeparator=this.decimalSeparator;if(!Ext.isDefined(a.decimalPrecision))a.decimalPrecision=this.decimalPrecision;if(!Ext.isDefined(a.allowNegative))a.allowNegative=this.allowNegative;
var b="0123456789";if(this.allowDecimals)b+=this.decimalSeparator;if(this.allowNegative)b+="-";a.maskRe=RegExp("["+Ext.escapeRe(b)+"]");a.value=a.defaultValue;this.setStringValue=a.setValue.createDelegate(a);this.getStringValue=a.getValue.createDelegate(a);a.setValue=this.setValue.createDelegate(this);a.getValue=this.getValue.createDelegate(this)},setStringValue:Ext.emptyFn,getStringValue:Ext.emptyFn,setValue:function(a){this.setStringValue(""+this.fixBoundries(a))},getValue:function(){var a=this.getStringValue();
if(!Ext.isEmpty(a))return parseFloat(a)},spin:function(a,b){this.field.onFocus();var c=this.field.getValue();c+=(a?-1:1)*(b==true?this.field.alternateIncrementValue:this.field.incrementValue);c=isNaN(c)?this.defaultValue:c;c=this.fixBoundries(c);this.field.setValue(c)}});Ext.preg("zarafa.numberspinner",Zarafa.common.ui.NumberSpinner);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.ImportanceMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};Ext.applyIf(a,{items:this.createContextImportanceItems()});Zarafa.common.ui.ImportanceMenu.superclass.constructor.call(this,a)},createContextImportanceItems:function(){var a=[];Ext.each(Zarafa.common.data.ImportanceFlags.flags,function(b){a.push({xtype:"zarafa.importancebutton",text:b.name,importanceValue:b.value,iconCls:b.iconCls})},this);return a}});Ext.reg("zarafa.importancemenu",Zarafa.common.ui.ImportanceMenu);
Ext.namespace("Zarafa.common.ui");Zarafa.common.ui.ImportanceButton=Ext.extend(Zarafa.core.ui.menu.ConditionalItem,{importanceValue:1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.importancebutton",handler:function(){this.applyFlag(this.getRecords())},scope:this});Zarafa.common.ui.ImportanceButton.superclass.constructor.call(this,a)},applyFlag:function(a){if(!Ext.isEmpty(a)){var b;Ext.each(a,function(c){b=c.getStore();c.set("importance",this.importanceValue)},this);b.save(a)}}});
Ext.reg("zarafa.importancebutton",Zarafa.common.ui.ImportanceButton);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.EditorTreeGrid=Ext.extend(Zarafa.common.ui.TreeGrid,{clicksToEdit:2,activeEditor:undefined,editing:false,autoEncode:false,constructor:function(a){this.addEvents("beforeedit","afteredit","validateedit");Zarafa.common.ui.EditorTreeGrid.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.ui.EditorTreeGrid.superclass.initEvents.call(this);this.mon(this.colResizer.tracker,"dragstart",this.stopEdit,this,[true]);this.clicksToEdit==1?this.on("click",this.onClickEdit,
this):this.on("dblclick",this.onClickEdit,this)},onClickEdit:function(a,b){if(a.leaf){var c=Ext.get(b.target);if(c.dom.nodeName!=="TD")c=c.parent("td");c=[].slice.call(c.parent("tr").dom.childNodes).indexOf(c.dom);this.startEdit(a,c)}},startEdit:function(a,b){this.stopEdit();if(this.isCellEditable(a,b))if(this.fireEvent("beforeedit",this,a,b)!==false){this.editing=true;var c=this.getCellEditor(a,b);if(c){c.rendered||this.mon(c,{render:this.onEditRender,complete:this.onEditComplete,canceledit:this.stopEdit.createDelegate(this,
[true]),scope:this});Ext.apply(c,{node:a,column:b});this.activeEditor=c;var d=this.preEditValue(a,b);c.startEdit(this.getCell(a,b),d)}}},onEditRender:function(a){a.field.focus();a.field.el.on("mousedown",function(){a.selectSameEditor=true;(function(){delete a.selectSameEditor;a.field.focus()}).defer(50)})},stopEdit:function(a){if(this.editing===true){var b=this.activeEditor;if(b)b[a===true?"cancelEdit":"completeEdit"]();this.activeEditor=null}this.editing=false},onEditComplete:function(a,b,c){var d=
a.node;a=a.column;this.editing=false;this.activeEditor=null;b=this.postEditValue(d,a,b,c);if(String(b)!==String(c))if(this.fireEvent("validateedit",this,d,a,b)!==false){c=this.getColumn(a);d.attributes[c.dataIndex]=b;if(c.tpl){var e={};e[c.dataIndex]=b;this.getCell(d,a).innerHTML=c.tpl.apply(e)}else this.getCell(d,a).innerHTML=b;this.fireEvent("afteredit",this,d,a,b)}},preEditValue:function(a,b){var c=a.attributes[this.getColumn(b).dataIndex];return this.autoEncode&&Ext.isString(c)?Ext.util.Format.htmlDecode(c):
c},postEditValue:function(a,b,c){return this.autoEncode&&Ext.isString(c)?Ext.util.Format.htmlEncode(c):c},isCellEditable:function(a,b){return this.getColumn(b).editable===true},getColumn:function(a){return this.columns[a]},getCell:function(a,b){return a.ui.elNode.childNodes[b].firstChild},getEditor:function(a,b){return this.columns[b].editor},getCellEditor:function(a,b){var c=this.getEditor(a,b);if(c)if(!c.startEdit){if(!c.gridEditor)c.gridEditor=new Ext.grid.GridEditor(c,{cls:"x-grid-editor"});c=
c.gridEditor}return c}});Ext.reg("zarafa.editortreegrid",Zarafa.common.ui.EditorTreeGrid);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.DateTimePeriodField=Ext.extend(Zarafa.common.ui.DateRangeField,{enableTimeSelection:true,dateFormat:_("d/m/Y"),timeFormat:_("G:i"),timeIncrement:30,constructor:function(a){a=a||{};Ext.apply(this,a);a.startFieldConfig=Ext.applyIf(a.startFieldConfig||{},{xtype:"zarafa.datetimefield",fieldLabel:_("Start date"),labelWidth:this.labelWidth,enableTimeSelection:this.enableTimeSelection,dateFormat:this.dateFormat,timeFormat:this.timeFormat,timeIncrement:this.timeIncrement});a.endFieldConfig=
Ext.applyIf(a.endFieldConfig||{},{xtype:"zarafa.datetimefield",fieldLabel:_("End date"),labelWidth:this.labelWidth,enableTimeSelection:this.enableTimeSelection,dateFormat:this.dateFormat,timeFormat:this.timeFormat,timeIncrement:this.timeIncrement});Zarafa.common.ui.DateTimePeriodField.superclass.constructor.call(this,a)},setEnabledTimeSelection:function(a){this.enableTimeSelection=a;if(this.rendered){this.startField.setEnabledTimeSelection(a);this.endField.setEnabledTimeSelection(a)}else{this.get(0).setEnabledTimeSelection(a);
this.get(1).setEnabledTimeSelection(a)}}});Ext.reg("zarafa.datetimeperiodfield",Zarafa.common.ui.DateTimePeriodField);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.DateTimeField=Ext.extend(Zarafa.common.ui.CompositeField,{enableTimeSelection:true,defaultValue:undefined,minValue:undefined,maxValue:undefined,dateFormat:_("d/m/Y"),timeFormat:_("G:i"),timeIncrement:15,constructor:function(a){a=a||{};Ext.apply(this,a);if(Ext.isDefined(this.defaultValue)&&!Ext.isDate(this.defaultValue))this.defaultValue=Date.parseDate(this.defaultValue,this.dateFormat+" "+this.timeFormat);if(Ext.isDefined(this.minValue)&&!Ext.isDate(this.minValue))this.minValue=Date.parseDate(this.minValue,
this.dateFormat+" "+this.timeFormat);if(Ext.isDefined(this.maxValue)&&!Ext.isDate(this.maxValue))this.maxValue=Date.parseDate(this.maxValue,this.dateFormat+" "+this.timeFormat);a=Ext.applyIf(a,{isSingleValued:true,items:[{xtype:"datefield",ref:"dateField",flex:0.6,format:this.dateFormat,value:this.defaultValue,minValue:this.minValue,maxValue:this.maxValue,listeners:{change:this.onDateChange,select:this.onDateSelect,scope:this}},{xtype:"zarafa.spinnerfield",ref:"timeField",flex:0.4,defaultValue:this.defaultValue,
minValue:this.minValue,maxValue:this.maxValue,incrementValue:this.timeIncrement,alternateIncrementValue:1,plugins:[{ptype:"zarafa.timespinner",format:this.timeFormat}],listeners:{change:this.onTimeChange,spin:this.onTimeSpin,scope:this}}]});Ext.apply(this,a);Zarafa.common.ui.DateTimeField.superclass.constructor.call(this,a)},doDateChange:function(a,b){var c,d;if(this.enableTimeSelection){d=this.timeField.getValue();c=this.combineDateAndTime(b,d);d=this.combineDateAndTime(a,d)}else{c=b;d=a}if(Ext.isDefined(d)){if(d>
this.maxValue)d=this.maxValue;else if(d<this.minValue)d=this.minValue;this.timeField.setValue(d);this.fireEvent("change",this,d,c)}},doTimeChange:function(a,b){this.dateField.setValue(a);this.fireEvent("change",this,a,b)},onDateChange:function(a,b,c){this.doDateChange(b,c)},onDateSelect:function(a,b){this.doDateChange(b,a.startValue)},onTimeChange:function(a,b,c){this.doTimeChange(b,c)},onTimeSpin:function(a){var b=a.field.startValue;this.doTimeChange(a.field.getValue(),b)},setValue:function(a){this.dateField.setValue(a);
this.enableTimeSelection&&this.timeField.setValue(a)},setRawValue:function(a){this.dateField.setRawValue(a);this.enableTimeSelection&&this.timeField.setRawValue(a)},getValue:function(){return this.enableTimeSelection?this.timeField.getValue():this.dateField.getValue()},getRawValue:function(){return this.enableTimeSelection?this.timeField.getRawValue():this.dateField.getRawValue()},combineDateAndTime:function(a,b){if(Ext.isDate(a))a=a.format(this.dateFormat);if(Ext.isDate(b))b=b.format(this.timeFormat);
if(Ext.isDefined(a)&&Ext.isDefined(b))return Date.parseDate(a+" "+b,this.dateFormat+" "+this.timeFormat)},setEnabledTimeSelection:function(a){this.enableTimeSelection=a;if(this.rendered){this.timeField.setVisible(a);this.doLayout()}}});Ext.reg("zarafa.datetimefield",Zarafa.common.ui.DateTimeField);Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.DatePeriodField=Ext.extend(Zarafa.common.ui.DateRangeField,{dateFormat:_("d/m/Y"),allowBlank:false,constructor:function(a){a=a||{};a.startFieldConfig=a.startFieldConfig||{};a.startFieldConfig.listeners=Zarafa.core.Util.mergeListeners(a.startFieldConfig.listeners,{select:this.onStartSelect,scope:this});a.startFieldConfig=Ext.applyIf(a.startFieldConfig,{xtype:"datefield",fieldLabel:_("Start date"),labelWidth:this.labelWidth,emptyText:_("None"),format:this.dateFormat,allowBlank:a.allowBlank||
this.allowBlank});a.endFieldConfig=a.endFieldConfig||{};a.endFieldConfig.listeners=Zarafa.core.Util.mergeListeners(a.endFieldConfig.listeners,{select:this.onEndSelect,scope:this});a.endFieldConfig=Ext.applyIf(a.endFieldConfig||{},{xtype:"datefield",fieldLabel:_("End date"),labelWidth:this.labelWidth,emptyText:_("None"),format:this.dateFormat,allowBlank:a.allowBlank||this.allowBlank});a.allowBlank&&!Ext.isDefined(a.defaultValue)&&Ext.applyIf(a,{defaultValue:new Zarafa.core.DateRange({allowBlank:true}),
defaultPeriod:30});Zarafa.common.ui.DatePeriodField.superclass.constructor.call(this,a)},onStartSelect:function(a,b){this.onStartChange(a,b,a.startValue)},onEndSelect:function(a,b){this.onEndChange(a,b,a.startValue)},onStartChange:function(a,b){var c=this.defaultValue,d=this.defaultValue.clone();if(c.getStartDate()!=b){if(Ext.isEmpty(b))c.setStartDate(null);else{var e=c.getDueTime();b=b.clearTime(true);if(e){var f=c.getDuration();if(f!==0){e=b.add(Date.MILLI,f);c.set(b,e)}else b.getTime()>e?c.set(b,
b.clone()):c.setStartDate(b)}else c.set(b,b.clone())}this.fireEvent("change",this,c.clone(),d)}},onEndChange:function(a,b){var c=this.defaultValue,d=this.defaultValue.clone();if(c.getDueDate()!=b){if(Ext.isEmpty(b))c.set(null,null);else{var e=c.getStartTime(),f=c.getDuration();b=b.clearTime(true);if(e&&f!==0&&b.getTime()<e){e=b.add(Date.MILLI,-f);c.set(e,b)}else c.setDueDate(b)}this.fireEvent("change",this,c.clone(),d)}}});Ext.reg("zarafa.dateperiodfield",Zarafa.common.ui.DatePeriodField);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsDelegateWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{settingsContext:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{height:400,title:_("Delegate settings"),layout:{type:"fit"},items:[{xtype:"zarafa.delegatespanel",ref:"delegatesPanel"}]});Zarafa.common.settings.SettingsDelegateWidget.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.settings.SettingsDelegateWidget.superclass.initEvents.call(this);var a=this.settingsContext.getModel();
this.mon(a,"savesettings",this.onSaveSettings,this);this.mon(a,"discardsettings",this.onDiscardSettings,this);this.mon(this.delegatesPanel.store,{add:this.doStoreAdd,remove:this.doStoreRemove,update:this.doStoreUpdate,scope:this})},doStoreAdd:function(){this.settingsContext.getModel().setDirty()},doStoreRemove:function(){this.settingsContext.getModel().setDirty()},doStoreUpdate:function(a,b,c){c!==Ext.data.Record.COMMIT&&this.settingsContext.getModel().setDirty()},onSaveSettings:function(){this.delegatesPanel.saveChanges()},
onDiscardSettings:function(){this.delegatesPanel.discardChanges()}});Ext.reg("zarafa.settingsdelegatewidget",Zarafa.common.settings.SettingsDelegateWidget);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsDelegateCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{settingsContext:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Delegates"),categoryIndex:3,iconCls:"zarafa-settings-category-delegate",items:[{xtype:"zarafa.settingsdelegatewidget",settingsContext:a.settingsContext},container.populateInsertionPoint("context.settings.category.delegate",this)]});Zarafa.common.settings.SettingsDelegateCategory.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.settingsdelegatecategory",Zarafa.common.settings.SettingsDelegateCategory);Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderGridContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.common.reminder.dialog.contextmenu.actions",this),{xtype:"menuseparator"},container.populateInsertionPoint("context.common.reminder.dialog.contextmenu.options",this)]});Zarafa.common.reminder.dialogs.ReminderGridContextMenu.superclass.constructor.call(this,
a)},createContextActionItems:function(){return[{xtype:"zarafa.conditionalitem",text:_("Open"),iconCls:"icon_open",singleSelectOnly:true,handler:this.onContextItemOpen,scope:this}]},onContextItemOpen:function(){Zarafa.common.Actions.openReminderRecord(this.records)}});Ext.reg("zarafa.remindergridcontextmenu",Zarafa.common.reminder.dialogs.ReminderGridContextMenu);Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{store:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.remindergrid",border:true,columns:this.initColumnModel(),selModel:this.initSelectionModel()});Zarafa.common.reminder.dialogs.ReminderGrid.superclass.constructor.call(this,a);this.mon(this,"rowdblclick",this.onRowDblClick,this);this.mon(this,"rowcontextmenu",this.onRowContextMenu,this)},initColumnModel:function(){return[{header:'<p class="icon_index">&nbsp;</p>',
dataIndex:"icon_index",width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,fixed:true,menuDisabled:true},{dataIndex:"subject",renderer:Zarafa.common.ui.grid.Renderers.subject,header:_("Subject"),menuDisabled:true},{dataIndex:"reminder_time",width:150,header:_("Due In"),renderer:Zarafa.common.ui.grid.Renderers.dueBy,menuDisabled:true}]},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({multiSelect:true})},onRowDblClick:function(a,b){var c=this.store.getAt(b);c&&Zarafa.common.Actions.openReminderRecord(c)},
onRowContextMenu:function(a,b,c){a=this.getSelectionModel();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);(b=a.getSelections())&&Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.reminder.remindergrid"],b,{position:c.getXY()})}});Ext.reg("zarafa.remindergrid",Zarafa.common.reminder.dialogs.ReminderGrid);Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderDialog=Ext.extend(Zarafa.core.ui.Dialog,{store:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=container.getReminderStore();a=Ext.applyIf(a,{xtype:"zarafa.reminderdialog",layout:"fit",title:_("Reminders"),border:false,width:350,height:300,items:[{xtype:"zarafa.reminderpanel",store:a.store}]});Zarafa.common.reminder.dialogs.ReminderDialog.superclass.constructor.call(this,a)}});
Zarafa.core.ui.Dialog.register(Zarafa.common.reminder.dialogs.ReminderDialog,"zarafa.reminderdialog");Ext.namespace("Zarafa.common.reminder.data");
Zarafa.common.reminder.data.ReminderProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};var b=Zarafa.core.ModuleNames.getModule("reminder");Ext.applyIf(a,{listModuleName:b.list,itemModuleName:b.item});Zarafa.common.reminder.data.ReminderProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.core.data.IPMResponseHandler({proxy:this,action:c,reader:f,options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.YearlyPanel=Ext.extend(Zarafa.common.recurrence.dialogs.RecurrenceSubPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recurrenceyearlypanel",recurrenceType:Zarafa.common.recurrence.data.RecurrenceType.YEARLY,recurrenceSubtypes:[Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_MONTH,Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_N_WEEKDAY,Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_REGENERATE],defaults:{border:false,bodyStyle:"background-color: inherit;",
height:25},items:[this.createEveryNWeekdayPanel(),this.createEveryMonthPanel(),this.createRegeneratePanel()]});Zarafa.common.recurrence.dialogs.YearlyPanel.superclass.constructor.call(this,a)},createEveryNWeekdayPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"yearly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_MONTH,hideLabel:true,width:25,listeners:{change:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],
fieldLabel:_("Every {A} {B}"),labelWidth:50,columnWidth:1,items:[{xtype:"combo",ref:"../../monthCombo",name:"recurrence_month",labelSplitter:"{A}",width:100,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.recurrence.data.MonthData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onYearlyMonthChange,select:this.onEveryNWeekdayMonthSelect,scope:this}},{xtype:"zarafa.spinnerfield",
plugins:["zarafa.numberspinner"],ref:"../../monthDaySpinner",name:"recurrence_monthday",labelSplitter:"{B}",allowNegative:false,minValue:1,maxValue:31,width:50,listeners:{change:this.onYearlyMonthChange,scope:this}}]}]}},createEveryMonthPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"yearly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_N_WEEKDAY,hideLabel:true,width:25,listeners:{change:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",
plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("The {A} {B} of {C}"),labelWidth:75,columnWidth:1,items:[{xtype:"combo",ref:"../../dayRankCombo",name:"recurrence_nday",labelSplitter:"{A}",width:80,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.recurrence.data.DayRankData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onYearlyNWeekdayChange,scope:this}},{xtype:"combo",
ref:"../../weekdayCombo",name:"recurrence_weekdays",labelSplitter:"{B}",width:100,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.recurrence.data.DayData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onYearlyNWeekdayChange,scope:this}},{xtype:"combo",ref:"../../monthWeekdayCombo",name:"recurrence_month",labelSplitter:"{C}",width:100,store:{xtype:"jsonstore",fields:["name",
"value"],data:Zarafa.common.recurrence.data.MonthData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onYearlyNWeekdayChange,scope:this}}]}]}},createRegeneratePanel:function(){return{xtype:"panel",layout:"column",ref:"regeneratePanel",items:[{xtype:"radio",name:"yearly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_REGENERATE,hideLabel:true,width:25,listeners:{change:this.onSubtypeChange,
scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Regenerate new task {A} year(s) after each task is completed"),labelWidth:400,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../regenNYearsSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onYearlyRegenerateChange,scope:this}}]}]}},onYearlyMonthChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_MONTH,
a,b)},onYearlyNWeekdayChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_N_WEEKDAY,a,b)},onYearlyRegenerateChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.YEARLY_REGENERATE,a,b)},onEveryNWeekdayMonthSelect:function(a,b,c){a=[31,29,31,30,31,30,31,31,30,31,30,31][c];this.monthDaySpinner.getValue()>a&&this.monthDaySpinner.setValue(a);this.monthDaySpinner.maxValue=a},updateEveryNWeekdayValues:function(a,
b){var c,d;if(b){d=a.get("startdate")||new Date;c=this.monthCombo.getStore().getAt(d.getMonth()).get("value");d=d.getDate()}else{c=a.get("recurrence_month");d=a.get("recurrence_monthday")}this.monthCombo.setValue(c);this.monthDaySpinner.setValue(d)},updateEveryMonthValues:function(a,b){var c,d,e;if(b){e=a.get("startdate")||new Date;c=Math.ceil(e.getDate()/7);d=Math.pow(2,e.getDay());e=this.monthWeekdayCombo.getStore().getAt(e.getMonth()).get("value")}else{c=a.get("recurrence_nday");d=a.get("recurrence_weekdays");
e=a.get("recurrence_month")}this.dayRankCombo.setValue(c);this.weekdayCombo.setValue(d);this.monthWeekdayCombo.setValue(e)},updateRegenerateValues:function(a,b){b||a.get("recurrence_everyn");this.regenNYearsSpinner.setValue(1)},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("message_class")){a.isMessageClass("IPM.TaskRequest",true)?this.regeneratePanel.show():this.regeneratePanel.hide();c=true}c&&this.doLayout()},updateSubtype:function(a,b,c){var d=Zarafa.common.recurrence.data.RecurrenceSubtype;
if(this.isSubtype(d.YEARLY_MONTH,b))this.updateEveryNWeekdayValues(a,c);else if(this.isSubtype(d.YEARLY_N_WEEKDAY,b))this.updateEveryMonthValues(a,c);else this.isSubtype(d.YEARLY_REGENERATE,b)&&this.updateRegenerateValues(a,c)},updateRecordSubType:function(a,b){var c=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(c.YEARLY_MONTH,b)){a.set("recurrence_everyn",12);a.set("recurrence_nday",undefined);a.set("recurrence_weekdays",undefined);a.set("recurrence_month",this.monthCombo.getValue());
a.set("recurrence_monthday",this.monthDaySpinner.getValue())}else if(this.isSubtype(c.YEARLY_N_WEEKDAY,b)){a.set("recurrence_everyn",12);a.set("recurrence_nday",this.dayRankCombo.getValue());a.set("recurrence_weekdays",this.weekdayCombo.getValue());a.set("recurrence_month",this.monthWeekdayCombo.getValue());a.set("recurrence_monthday",undefined)}else if(this.isSubtype(c.YEARLY_REGENERATE,b)){a.set("recurrence_everyn",this.regenNYearsSpinner.getValue());a.set("recurrence_nday",undefined);a.set("recurrence_weekdays",
undefined);a.set("recurrence_month",undefined);a.set("recurrence_monthday",1)}}});Ext.reg("zarafa.recurrenceyearlypanel",Zarafa.common.recurrence.dialogs.YearlyPanel);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.WeeklyPanel=Ext.extend(Zarafa.common.recurrence.dialogs.RecurrenceSubPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recurrenceweeklypanel",recurrenceType:Zarafa.common.recurrence.data.RecurrenceType.WEEKLY,recurrenceSubtypes:[Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY_REGENERATE,Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY],defaults:{border:false,bodyStyle:"background-color: inherit;",height:25},items:[this.createEveryNWeeksPanel(),
this.createDaySelectionPanel(),this.createRegeneratePanel()]});Zarafa.common.recurrence.dialogs.WeeklyPanel.superclass.constructor.call(this,a)},createEveryNWeeksPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"weekly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Every {A} week(s) on")+
":",labelWidth:140,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../everyNWeeksSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onWeeklyChange,scope:this}}]}]}},createDaySelectionPanel:function(){var a=container.getSettingsModel().get("zarafa/v1/main/week_start");return{xtype:"checkboxgroup",ref:"weeklyDaySelect",name:"recurrence_weekdays",columns:3,style:"padding-left: 25px",anchor:"100% 100%",
height:"auto",items:[{xtype:"checkbox",boxLabel:Date.dayNames[(a+0)%7],dayValue:Math.pow(2,(a+0)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+1)%7],dayValue:Math.pow(2,(a+1)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+2)%7],dayValue:Math.pow(2,(a+2)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+3)%7],dayValue:Math.pow(2,
(a+3)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+4)%7],dayValue:Math.pow(2,(a+4)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+5)%7],dayValue:Math.pow(2,(a+5)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}},{xtype:"checkbox",boxLabel:Date.dayNames[(a+6)%7],dayValue:Math.pow(2,(a+6)%7),width:250,listeners:{change:this.onWeeklyDayChange,scope:this}}]}},
createRegeneratePanel:function(){return{xtype:"panel",layout:"column",ref:"regeneratePanel",items:[{xtype:"radio",name:"weekly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY_REGENERATE,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Regenerate new task {A} week(s) after each task is completed"),labelWidth:400,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],
ref:"../../regenNWeeksSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onWeeklyRegenerateChange,scope:this}}]}]}},onWeeklyChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY,a,b)},onWeeklyDayChange:function(a,b){var c=this.record.get(a.name);if(b)c|=a.dayValue;else c&=~a.dayValue;this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY,a,c)},onWeeklyRegenerateChange:function(a,
b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY_REGENERATE,a,b*10080)},updateEveryNWeeksValues:function(a,b){this.everyNWeeksSpinner.setValue(b?1:a.get("recurrence_everyn"))},updateDaySelectionValues:function(a,b){var c=a.get("startdate")||new Date,d=b?Math.pow(2,c.getDay()):a.get("recurrence_weekdays");this.weeklyDaySelect.items.each(function(e){e.setValue(!!(e.dayValue&d))})},updateRegenerateValues:function(a,b){this.regenNWeeksSpinner.setValue(b?1:Math.floor(a.get("recurrence_everyn")/
10080))},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("message_class")){a.isMessageClass("IPM.TaskRequest",true)?this.regeneratePanel.show():this.regeneratePanel.hide();c=true}c&&this.doLayout()},updateSubtype:function(a,b,c){var d=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(d.WEEKLY,b)){this.updateEveryNWeeksValues(a,c);this.updateDaySelectionValues(a,c)}else this.isSubtype(d.WEEKLY_REGENERATE,b)&&this.updateRegenerateValues(a,c)},updateRecordSubType:function(a,
b){var c=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(c.WEEKLY,b)){a.set("recurrence_everyn",this.everyNWeeksSpinner.getValue());var d=0;Ext.each(this.weeklyDaySelect.getValue(),function(e){d|=e.dayValue});a.set("recurrence_weekdays",d)}else this.isSubtype(c.WEEKLY_REGENERATE,b)&&a.set("recurrence_everyn",this.regenNWeeksSpinner.getValue()*10080);a.set("recurrence_month",undefined);a.set("recurrence_monthday",undefined);a.set("recurrence_nday",undefined)}});
Ext.reg("zarafa.recurrenceweeklypanel",Zarafa.common.recurrence.dialogs.WeeklyPanel);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.MonthlyPanel=Ext.extend(Zarafa.common.recurrence.dialogs.RecurrenceSubPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recurrencemonthlypanel",recurrenceType:Zarafa.common.recurrence.data.RecurrenceType.MONTHLY,recurrenceSubtypes:[Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_DAY_OF_MONTH,Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_WEEKDAY_OF_MONTH,Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_REGENERATE],defaults:{border:false,
bodyStyle:"background-color: inherit;",height:25},items:[this.createEveryNDayOfMonthPanel(),this.createEveryNWeekDayOfMonthPanel(),this.createRegeneratePanel()]});Zarafa.common.recurrence.dialogs.MonthlyPanel.superclass.constructor.call(this,a)},createEveryNDayOfMonthPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"monthly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_DAY_OF_MONTH,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,
scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Day {A} of every {B} month(s)"),labelWidth:250,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../nthDaySpinner",name:"recurrence_monthday",labelSplitter:"{A}",allowNegative:false,minValue:1,maxValue:31,width:50,listeners:{change:this.onMonthlyNDayOfMonthChange,scope:this}},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../everyNMonthsSpinner",
name:"recurrence_everyn",labelSplitter:"{B}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onMonthlyNDayOfMonthChange,scope:this}}]}]}},createEveryNWeekDayOfMonthPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"monthly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_WEEKDAY_OF_MONTH,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],
fieldLabel:_("The {A} {B} of every {C} month(s)"),labelWidth:200,columnWidth:1,items:[{xtype:"combo",ref:"../../weekdayRankCombo",name:"recurrence_nday",labelSplitter:"{A}",width:80,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.recurrence.data.DayRankData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onMonthlyNWeekdayOfMonthChange,scope:this}},{xtype:"combo",ref:"../../weekdayCombo",
name:"recurrence_weekdays",labelSplitter:"{B}",width:100,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.recurrence.data.DayData},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{change:this.onMonthlyNWeekdayOfMonthChange,scope:this}},{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../weekdayEveryNMonthsSpinner",name:"recurrence_everyn",labelSplitter:"{C}",
allowNegative:false,minValue:1,width:50,listeners:{change:this.onMonthlyNWeekdayOfMonthChange,scope:this}}]}]}},createRegeneratePanel:function(){return{xtype:"panel",layout:"column",ref:"regeneratePanel",items:[{xtype:"radio",name:"monthly_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_REGENERATE,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Regenerate new task {A} month(s) after each task is completed"),
labelWidth:400,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../regenNMonthsSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onMonthlyRegenerateChange,scope:this}}]}]}},onMonthlyNDayOfMonthChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_DAY_OF_MONTH,a,b)},onMonthlyNWeekdayOfMonthChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_N_WEEKDAY_OF_MONTH,
a,b)},onMonthlyRegenerateChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.MONTHLY_REGENERATE,a,b)},updateEveryNDayOfMonthValues:function(a,b){var c=a.get("startdate")||new Date;c=b?c.getDate():a.get("recurrence_monthday");var d=b?1:a.get("recurrence_everyn");this.nthDaySpinner.setValue(c);this.everyNMonthsSpinner.setValue(d)},updateEveryNWeekDayOfMonthValues:function(a,b){var c,d,e;if(b){d=a.get("startdate")||new Date;c=Math.ceil(d.getDate()/7);d=Math.pow(2,
d.getDay());e=1}else{c=a.get("recurrence_nday");d=a.get("recurrence_weekdays");e=a.get("recurrence_everyn")}this.weekdayRankCombo.setValue(c);this.weekdayCombo.setValue(d);this.weekdayEveryNMonthsSpinner.setValue(e)},updateRegenerateValues:function(a,b){this.regenNMonthsSpinner.setValue(b?1:a.get("recurrence_everyn"))},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("message_class")){a.isMessageClass("IPM.TaskRequest",true)?this.regeneratePanel.show():this.regeneratePanel.hide();
c=true}c&&this.doLayout()},updateSubtype:function(a,b,c){var d=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(d.MONTHLY_N_DAY_OF_MONTH,b))this.updateEveryNDayOfMonthValues(a,c);else if(this.isSubtype(d.MONTHLY_N_WEEKDAY_OF_MONTH,b))this.updateEveryNWeekDayOfMonthValues(a,c);else this.isSubtype(d.MONTHLY_REGENERATE,b)&&this.updateRegenerateValues(a,c)},updateRecordSubType:function(a,b){var c=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(c.MONTHLY_N_DAY_OF_MONTH,
b)){a.set("recurrence_monthday",this.nthDaySpinner.getValue());a.set("recurrence_nday",undefined);a.set("recurrence_weekdays",undefined);a.set("recurrence_everyn",this.everyNMonthsSpinner.getValue())}else if(this.isSubtype(c.MONTHLY_N_WEEKDAY_OF_MONTH,b)){a.set("recurrence_monthday",undefined);a.set("recurrence_nday",this.weekdayRankCombo.getValue());a.set("recurrence_weekdays",this.weekdayCombo.getValue());a.set("recurrence_everyn",this.weekdayEveryNMonthsSpinner.getValue())}else if(this.isSubtype(c.MONTHLY_REGENERATE,
b)){a.set("recurrence_monthday",1);a.set("recurrence_nday",undefined);a.set("recurrence_weekdays",undefined);a.set("recurrence_everyn",this.regenNMonthsSpinner.getValue())}a.set("recurrence_month",undefined)}});Ext.reg("zarafa.recurrencemonthlypanel",Zarafa.common.recurrence.dialogs.MonthlyPanel);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.DailyPanel=Ext.extend(Zarafa.common.recurrence.dialogs.RecurrenceSubPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recurrencedailypanel",recurrenceType:Zarafa.common.recurrence.data.RecurrenceType.DAILY,recurrenceSubtypes:[Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_EVERY_N_DAYS,Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_WEEKDAYS,Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_REGENERATE],defaults:{border:false,bodyStyle:"background-color: inherit;",
height:25},items:[this.createEveryNDaysPanel(),this.createEveryWeekdayPanel(),this.createRegeneratePanel()]});Zarafa.common.recurrence.dialogs.DailyPanel.superclass.constructor.call(this,a)},createEveryNDaysPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"daily_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_EVERY_N_DAYS,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],
fieldLabel:_("Every {A} day(s)"),labelWidth:100,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../everyNDaysSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onEveryNDaysChange,scope:this}}]}]}},createEveryWeekdayPanel:function(){return{xtype:"panel",layout:"column",items:[{xtype:"radio",name:"daily_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_WEEKDAYS,hideLabel:true,
width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"displayfield",value:_("Every weekday"),hideLabel:true}]}},createRegeneratePanel:function(){return{xtype:"panel",layout:"column",ref:"regeneratePanel",items:[{xtype:"radio",name:"daily_pattern",patternValue:Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_REGENERATE,hideLabel:true,width:25,listeners:{check:this.onSubtypeChange,scope:this}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Regenerate new task {A} day(s) after each task is completed"),
labelWidth:400,columnWidth:1,items:[{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"],ref:"../../regenNDaysSpinner",name:"recurrence_everyn",labelSplitter:"{A}",allowNegative:false,minValue:1,width:50,listeners:{change:this.onDailyRegenerateChange,scope:this}}]}]}},onEveryNDaysChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_EVERY_N_DAYS,a,b*1440)},onDailyRegenerateChange:function(a,b){this.onSubtypePropertyChange(Zarafa.common.recurrence.data.RecurrenceSubtype.DAILY_REGENERATE,
a,b*1440)},updateEveryNDaysValues:function(a,b){this.everyNDaysSpinner.setValue(b?1:Math.floor(a.get("recurrence_everyn")/1440))},updateRegenerateValues:function(a,b){this.regenNDaysSpinner.setValue(b?1:Math.floor(a.get("recurrence_everyn")/1440))},updateUI:function(a,b){var c=false;if(b===true||a.isModifiedSinceLastUpdate("message_class")){a.isMessageClass("IPM.TaskRequest",true)?this.regeneratePanel.show():this.regeneratePanel.hide();c=true}c&&this.doLayout()},updateSubtype:function(a,b,c){var d=
Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(d.DAILY_EVERY_N_DAYS,b))this.updateEveryNDaysValues(a,c);else this.isSubtype(d.DAILY_REGENERATE,b)&&this.updateRegenerateValues(a,c)},updateRecordSubType:function(a,b){var c=Zarafa.common.recurrence.data.RecurrenceSubtype;if(this.isSubtype(c.DAILY_EVERY_N_DAYS,b))a.set("recurrence_everyn",this.everyNDaysSpinner.getValue()*1440);else if(this.isSubtype(c.DAILY_WEEKDAYS,b))a.set("recurrence_everyn",1);else this.isSubtype(c.DAILY_REGENERATE,
b)&&a.set("recurrence_everyn",this.regenNDaysSpinner.getValue()*1440);a.set("recurrence_weekdays",undefined);a.set("recurrence_month",undefined);a.set("recurrence_monthday",undefined);a.set("recurrence_nday",undefined)}});Ext.reg("zarafa.recurrencedailypanel",Zarafa.common.recurrence.dialogs.DailyPanel);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.ViewRecipientDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,formPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("View recipient"),layout:"fit",width:350,height:100,items:[{xtype:"form",layout:"form",border:false,bodyStyle:"padding: 5px; background-color: inherit;",ref:"formPanel",items:[{xtype:"textfield",fieldLabel:_("Display name"),name:"display_name",anchor:"100%",readOnly:true},{xtype:"textfield",fieldLabel:_("E-mail address"),
name:"smtp_address",anchor:"100%",readOnly:true}],buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.recipientfield.ui.ViewRecipientDialog.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})},onAfterFirstLayout:function(){this.formPanel.getForm().loadRecord(this.record)},onOk:function(){this.close()},onCancel:function(){this.close()}});
Zarafa.core.ui.Dialog.register(Zarafa.common.recipientfield.ui.ViewRecipientDialog,"zarafa.viewrecipientdialog");Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.RecipientContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{editable:true,constructor:function(a){a=a||{};var b=Ext.isDefined(a.editable)?a.editable:this.editable,c=false;if(a.records){if(Ext.isArray(a.records))a.records=a.records[0];c=a.records.isResolved()}Ext.applyIf(a,{items:[{xtype:"zarafa.conditionalitem",text:_("Edit Recipient"),hidden:!b||c,handler:this.editRecipient,scope:this},{xtype:"zarafa.conditionalitem",text:_("Show Details"),hidden:!c,handler:this.openDetailsDialog,
scope:this},{xtype:"zarafa.conditionalitem",text:_("Send e-mail"),handler:this.emailRecipient,scope:this},{xtype:"menuseparator"},container.populateInsertionPoint("context.common.recipientfield.contextmenu.actions",this)]});Zarafa.common.recipientfield.ui.RecipientContextMenu.superclass.constructor.call(this,a)},editRecipient:function(){Zarafa.common.Actions.openCreateRecord(this.records)},openDetailsDialog:function(){Zarafa.common.Actions.openViewRecipientDialog(this.records)},emailRecipient:function(){var a=
container.getHierarchyStore().getDefaultFolder("drafts");a=Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Note",{store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid")});var b=a.getRecipientStore(),c=this.records.copy();c.set("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_TO);b.add(c);Zarafa.common.Actions.openCreateRecord(a)}});Ext.reg("zarafa.recipientcontextmenu",Zarafa.common.recipientfield.ui.RecipientContextMenu);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.RecipientBox=Ext.extend(Zarafa.common.ui.Box,{validCls:"x-zarafa-boxfield-recipient-item-resolved",ambiguousCls:"x-zarafa-boxfield-recipient-item-ambiguous",pendingCls:"x-zarafa-boxfield-recipient-item-pending",invalidCls:"x-zarafa-boxfield-recipient-item-invalid",constructor:function(a){a=a||{};Ext.applyIf(a,{cls:"x-zarafa-boxfield-recipient-item",textTpl:'<tpl if="!Ext.isEmpty(values.display_name)">{display_name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)}</tpl>'});
Zarafa.common.recipientfield.ui.RecipientBox.superclass.constructor.call(this,a)},prepareData:function(a){var b={};b.display_name=a.get("display_name");b.smtp_address=a.get("smtp_address")||a.get("email_address");b.object_type=a.get("object_type");b.entryid=a.get("entryid");return b},prepareIcon:function(a){if(a.isResolved()||a.attemptedToResolve()&&a.isValidSMTP())return Zarafa.common.recipientfield.ui.RecipientBox.superclass.prepareIcon.apply(this,arguments)},doUpdate:function(){this.update(this.record)},
isValidRecord:function(a){return a.isResolved()||a.attemptedToResolve()&&a.isValidSMTP()},update:function(a){Zarafa.common.recipientfield.ui.RecipientBox.superclass.update.apply(this,arguments);if(this.isValidRecord(a)){this.el.removeClass(this.invalidCls);this.el.removeClass(this.pendingCls);this.el.removeClass(this.ambiguousCls);this.el.addClass(this.validCls)}else{if(a.isAmbiguous()){this.el.removeClass(this.invalidCls);this.el.removeClass(this.pendingCls);this.el.addClass(this.ambiguousCls)}else{if(!a.isResolved()&&
!a.attemptedToResolve()){this.el.removeClass(this.invalidCls);this.el.addClass(this.pendingCls)}else{this.el.addClass(this.invalidCls);this.el.removeClass(this.pendingCls)}this.el.removeClass(this.ambiguousCls)}this.el.removeClass(this.validCls)}}});Ext.reg("zarafa.recipientbox",Zarafa.common.recipientfield.ui.RecipientBox);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.EditRecipientDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,formPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Edit recipient"),layout:"fit",width:350,height:100,items:[{xtype:"form",layout:"form",border:false,ref:"formPanel",items:[{xtype:"textfield",fieldLabel:_("Display name"),name:"display_name",anchor:"100%"},{xtype:"textfield",fieldLabel:_("E-mail address"),name:"smtp_address",anchor:"100%"}],buttons:[{text:_("Ok"),handler:this.onOk,
scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.recipientfield.ui.EditRecipientDialog.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})},onAfterFirstLayout:function(){this.formPanel.getForm().loadRecord(this.record)},onOk:function(){this.formPanel.getForm().updateRecord(this.record);this.close()},onCancel:function(){this.close()}});
Zarafa.core.ui.Dialog.register(Zarafa.common.recipientfield.ui.EditRecipientDialog,"zarafa.editrecipientdialog");Ext.namespace("Zarafa.common.recipientfield.data");
Zarafa.common.recipientfield.data.SuggestionListProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};var b=Zarafa.core.ModuleNames.getModule("suggestemailaddress");Ext.applyIf(a,{listModuleName:b.list,itemModuleName:b.item});Zarafa.common.recipientfield.data.SuggestionListProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.common.recipientfield.data.SuggestionListResponseHandler({proxy:this,action:c,reader:f,
options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.common.printer.renderers");
Zarafa.common.printer.renderers.BaseRenderer=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},print:function(a){var b=a&&a.getXType?String.format("print_{0}_{1}",a.getXType(),a.id.replace(/-/g,"_")):"print";if(b=window.open("",b)){b.document.write(this.generateHTML(a));b.document.close();this.postRender(window.document,b.document,a);this.doPrintOnStylesheetLoad.defer(10,this,[b])}},doPrintOnStylesheetLoad:function(a){if(a){var b=a.document.getElementById("csscheck");if((b.currentStyle||
a.getComputedStyle(b,null)).display!=="none")this.doPrintOnStylesheetLoad.defer(10,this,[a]);else{a.print();a.close()}}},generateHTML:function(a){return(new Ext.XTemplate("<html>\n","<head>\n",'<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />\n','<link href="'+this.stylesheetPath+"?"+(new Date).getTime()+'" rel="stylesheet" type="text/css" media="screen,print" />\n',this.generateHeadTemplate(a),"<title>"+this.getTitle(a)+"</title>\n","</head>\n","<body>\n",'<div id="csscheck"></div>\n',
'<div id="pagemargin">\n',this.generateBodyTemplate(a),"</div>\n","</body>\n","</html>")).apply(this.prepareData(a))},generateHeadTemplate:function(){if(!Ext.isEmpty(this.customStylesheetPath))if(Ext.isArray(this.customStylesheetPath)){for(var a="",b=0,c=this.customStylesheetPath.length;b<c;b++)a+='<link href="'+this.customStylesheetPath[b]+"?"+(new Date).getTime()+'" rel="stylesheet" type="text/css" media="screen,print" />\n';return a}else return'<link href="'+this.customStylesheetPath+"?"+(new Date).getTime()+
'" rel="stylesheet" type="text/css" media="screen,print" />';return""},generateBodyTemplate:Ext.emptyFn,prepareData:function(a){a=Ext.apply({},a.data);a.fullname=container.getUser().getDisplayName();return a},postRender:Ext.emptyFn,getTitle:function(a){return typeof a.getTitle=="function"?a.getTitle():a.title||"Printing"},stylesheetPath:"client/resources/css-extern/print.css"});Ext.namespace("Zarafa.common.plugins");
Zarafa.common.plugins.IconDragSelectorPlugin=Ext.extend(Object,{view:undefined,itemRegions:undefined,bodyRegion:undefined,proxy:undefined,tracker:undefined,dragRegion:undefined,constructor:function(a){Ext.apply(this,a);Zarafa.common.plugins.IconDragSelectorPlugin.superclass.constructor.call(this,a)},init:function(a){this.view=a;this.view.mon(this.view,"render",this.onRender,this)},fillRegions:function(){this.itemRegions=[];this.view.all.each(function(a){this.itemRegions.push(a.getRegion())},this);
this.bodyRegion=this.view.el.getRegion()},cancelClick:function(){return false},onBeforeStart:function(a){return this.view.getEl().contains(a.target)&&!Ext.dd.DragDropMgr.dragCurrent},onStart:function(){this.view.mon(this.view,"containerclick",this.cancelClick,this,{single:true});if(this.proxy){this.proxy.dom.parentNode!==this.view.el.dom&&this.view.el.dom.appendChild(this.proxy.dom);this.proxy.setDisplayed("block")}else this.proxy=this.view.el.createChild({cls:"x-view-selector"});this.fillRegions();
this.view.clearSelections()},onDrag:function(){var a=this.tracker.startXY,b=this.tracker.getXY(),c=Math.min(a[0],b[0]),d=Math.min(a[1],b[1]),e=Math.abs(a[0]-b[0]);a=Math.abs(a[1]-b[1]);this.dragRegion.left=c;this.dragRegion.top=d;this.dragRegion.right=c+e;this.dragRegion.bottom=d+a;this.dragRegion.constrainTo(this.bodyRegion);this.proxy.setRegion(this.dragRegion);c=0;for(d=this.itemRegions.length;c<d;c++){e=this.itemRegions[c];if((a=this.dragRegion.intersect(e))&&!e.selected){e.selected=true;this.view.select(c,
true)}else if(!a&&e.selected){e.selected=false;this.view.deselect(c)}}},onEnd:function(){Ext.isIE||this.view.mun(this.view,"containerclick",this.cancelClick,this,{single:true});this.proxy&&this.proxy.setDisplayed(false)},onRender:function(){this.dragRegion=new Ext.lib.Region(0,0,0,0);this.tracker=new Ext.dd.DragTracker({onBeforeStart:this.onBeforeStart.createDelegate(this),onStart:this.onStart.createDelegate(this),onDrag:this.onDrag.createDelegate(this),onEnd:this.onEnd.createDelegate(this)});this.tracker.initEl(this.view.getEl())}});
Ext.preg("zarafa.icondragselectorplugin",Zarafa.common.plugins.IconDragSelectorPlugin);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.FreebusyTimelineHeaderContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{model:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{items:[{xtype:"zarafa.conditionalitem",text:_("Show non-working hours"),showNonWorkingHours:true,hidden:a.model?a.model.showOnlyWorkingHours()===false:false,handler:this.onHeaderContextMenuToggleNonWorkingHours,scope:this},{xtype:"zarafa.conditionalitem",text:_("Hide non-working hours"),showNonWorkingHours:false,hidden:a.model?a.model.showOnlyWorkingHours()===
true:false,handler:this.onHeaderContextMenuToggleNonWorkingHours,scope:this},container.populateInsertionPoint("context.freebusy.timelineheader.contextmenu",this)]});Zarafa.common.freebusy.ui.FreebusyTimelineHeaderContextMenu.superclass.constructor.call(this,a)},onHeaderContextMenuToggleNonWorkingHours:function(a){this.model.hideNonWorkingHours(!a.showNonWorkingHours)}});Ext.reg("zarafa.freebusytimelineheadercontextmenu",Zarafa.common.freebusy.ui.FreebusyTimelineHeaderContextMenu);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.FreebusyTimelineBodyContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{model:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{items:container.populateInsertionPoint("context.freebusy.timelinebody.contextmenu",this)});Zarafa.common.freebusy.ui.FreebusyTimelineBodyContextMenu.superclass.constructor.call(this,a)}});Ext.reg("zarafa.freebusytimelinebodycontextmenu",Zarafa.common.freebusy.ui.FreebusyTimelineBodyContextMenu);Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.FreebusyContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{editable:true,constructor:function(a){a=a||{};var b=Ext.isDefined(a.editable)?a.editable:this.editable,c=false,d=false;if(a.records){if(Ext.isArray(a.records))a.records=a.records[0];c=a.records.isMeetingOrganizer();d=a.records.isResolved()}Ext.applyIf(a,{items:[{xtype:"zarafa.conditionalitem",text:_("Edit recipient"),hidden:!b||d,handler:this.onContextMenuEditRecipientClick,scope:this},{xtype:"zarafa.conditionalitem",
text:_("Show Details"),hidden:!d,handler:this.openDetailsDialog,scope:this},"-",{xtype:"zarafa.conditionalitem",text:_("Required Attendee"),iconCls:"x-freebusy-userlist-recipienttype-required",hidden:!b||c,recipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,handler:this.onRecipientTypeChange,scope:this},{xtype:"zarafa.conditionalitem",text:_("Optional Attendee"),iconCls:"x-freebusy-userlist-recipienttype-optional",hidden:!b||c,recipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,handler:this.onRecipientTypeChange,
scope:this},{xtype:"zarafa.conditionalitem",text:_("Resource"),iconCls:"x-freebusy-userlist-recipienttype-resource",hidden:!b||c,recipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,handler:this.onRecipientTypeChange,scope:this},container.populateInsertionPoint("context.freebusy.userlist.contextmenu",this)]});Zarafa.common.freebusy.ui.FreebusyContextMenu.superclass.constructor.call(this,a)},onContextMenuEditRecipientClick:function(){Zarafa.common.Actions.openCreateRecord(this.records)},openDetailsDialog:function(){Zarafa.common.Actions.openViewRecipientDialog(this.records)},
onRecipientTypeChange:function(a){this.records.set("recipient_type",a.recipientType)}});Ext.reg("zarafa.freebusycontextmenu",Zarafa.common.freebusy.ui.FreebusyContextMenu);Ext.namespace("Zarafa.common.freebusy.data");
Zarafa.common.freebusy.data.FreebusyProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};Ext.applyIf(a,{listModuleName:Zarafa.core.ModuleNames.getListName("freebusy")});Zarafa.common.freebusy.data.FreebusyProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.common.freebusy.data.FreebusyResponseHandler({proxy:this,action:c,reader:f,options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.common.freebusy.data");
Zarafa.common.freebusy.data.FreebusyBlockStore=Ext.extend(Ext.data.Store,{constructor:function(a){a=a||{};Ext.applyIf(a,{batch:true,autoSave:false,writer:new Ext.data.JsonWriter,remoteSort:true,proxy:new Zarafa.common.freebusy.data.FreebusyProxy,reader:new Ext.data.JsonReader({root:"item"},Zarafa.common.freebusy.data.FreebusyBlockRecord)});Zarafa.common.freebusy.data.FreebusyBlockStore.superclass.constructor.call(this,a)}});Ext.reg("zarafa.freebusyblockstore",Zarafa.common.freebusy.data.FreebusyBlockStore);
Ext.namespace("Zarafa.common.dialogs");
Zarafa.common.dialogs.CopyMoveDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,last_selected_folder:undefined,constructor:function(a){a=a||{};var b,c;if(a.record){if(!Ext.isArray(a.record))a.record=[a.record];c=a.record[0].get("object_type");switch(c){case Zarafa.core.mapi.ObjectType.MAPI_FOLDER:b=_("Copy/Move Folder");break;case Zarafa.core.mapi.ObjectType.MAPI_MESSAGE:default:b=_("Copy/Move Messages");break}}Ext.applyIf(a,{xtype:"zarafa.copymovedialog",layout:"fit",title:b,width:300,height:350,
items:[{xtype:"zarafa.copymovepanel",record:a.record,objectType:c}]});Zarafa.common.dialogs.CopyMoveDialog.superclass.constructor.call(this,a)},getSelectedFolder:function(){if(this.last_selected_folder)return this.last_selected_folder;else if(!Ext.isEmpty(this.record)){var a=container.getHierarchyStore(),b=this.record[0];if(b.get("container_class"))return a.getDefaultFolderFromContainerClass(b.get("container_class"));else if(b.get("message_class"))return a.getDefaultFolderFromMessageClass(b.get("message_class"))}},
selectFolder:function(a){this.last_selected_folder=a;this.stateful!==false&&this.saveState()},getState:function(){var a=Zarafa.common.dialogs.CopyMoveDialog.superclass.getState.call(this);if(this.last_selected_folder)a.last_selected_folder=this.last_selected_folder.get("entryid");return a},applyState:function(a){if(a&&a.last_selected_folder){this.last_selected_folder=container.getHierarchyStore().getFolder(a.last_selected_folder);delete a.last_selected_folder}Zarafa.common.dialogs.CopyMoveDialog.superclass.applyState.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.common.dialogs.CopyMoveDialog,"zarafa.copymovedialog");Ext.namespace("Zarafa.common.delegates.data");
Zarafa.common.delegates.data.JsonDelegateReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=a||{};Ext.applyIf(a,{id:"entryid",idProperty:"entryid",dynamicRecord:false});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DELEGATE));Zarafa.common.delegates.data.JsonDelegateReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.common.delegates.data");
Zarafa.common.delegates.data.DelegateStore=Ext.extend(Zarafa.core.data.MAPIStore,{actionType:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{autoLoad:true,actionType:Zarafa.core.Actions.list,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.common.delegates.data.JsonDelegateReader,proxy:new Zarafa.core.data.IPMProxy({listModuleName:Zarafa.core.ModuleNames.getListName("DELEGATES"),itemModuleName:Zarafa.core.ModuleNames.getItemName("DELEGATES")})});Zarafa.common.delegates.data.DelegateStore.superclass.constructor.call(this,
a)},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isDefined(a.cancelPreviousRequest))a.cancelPreviousRequest=true;Ext.applyIf(a,{actionType:this.actionType});return Zarafa.common.delegates.data.DelegateStore.superclass.load.call(this,a)}});Ext.namespace("Zarafa.common.checknames.dialogs");
Zarafa.common.checknames.dialogs.CheckNamesDialog=Ext.extend(Zarafa.core.ui.Dialog,{checkNamesData:undefined,record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.checknamesdialog",layout:"fit",title:_("Check Names"),border:false,width:320,height:300,items:[{xtype:"zarafa.checknamespanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.checknames.dialogs.CheckNamesDialog.superclass.constructor.call(this,
a)},onRender:function(){Zarafa.common.checknames.dialogs.CheckNamesDialog.superclass.onRender.apply(this,arguments);this.get(0).update(this.record,this.checkNamesData)},onOk:function(){this.get(0).updateRecord(this.record)!==false&&this.dialog.close()},onCancel:function(){this.dialog.close()}});Zarafa.core.ui.Dialog.register(Zarafa.common.checknames.dialogs.CheckNamesDialog,"zarafa.checknamesdialog");Ext.namespace("Zarafa.common.categories.dialogs");
Zarafa.common.categories.dialogs.CategoriesDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,autoSave:true,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.categoriesdialog",layout:"fit",title:_("Categories"),width:400,height:400,items:[{xtype:"zarafa.categoriespanel",record:a.record,ref:"categoriesPanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.categories.dialogs.CategoriesDialog.superclass.constructor.call(this,
a)},onOk:function(){var a=this.categoriesPanel.getCategoriesTextArea().getValue();if(!Ext.isEmpty(this.record)){Ext.each(this.record,function(b){b.set("categories",a)},this);this.autoSave&&this.record[0].getStore().save(this.record)}this.close()},onCancel:function(){this.close()}});Zarafa.core.ui.Dialog.register(Zarafa.common.categories.dialogs.CategoriesDialog,"zarafa.categoriesdialog");Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentField=Ext.extend(Zarafa.common.ui.BoxField,{constructor:function(a){a=a||{};Ext.applyIf(a,{boxType:"zarafa.attachmentbox",enableComboBox:false,editable:false,height:30});Zarafa.common.attachment.ui.AttachmentField.superclass.constructor.call(this,a);this.mon(this,"boxdblclick",this.onBoxDblClick,this)},setAttachmentStore:function(){return this.setBoxStore.apply(this,arguments)},getAttachmentStore:function(){return this.getBoxStore()},filterRecord:function(a){return a.get("hidden")!==
true},onBoxDblClick:function(a,b,c){Zarafa.common.Actions.openViewRecord(c)}});Ext.reg("zarafa.attachmentfield",Zarafa.common.attachment.ui.AttachmentField);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{items:[this.createContextActionItems(a.records),container.populateInsertionPoint("common.contextmenu.attachment.actions",this),{xtype:"menuseparator"},container.populateInsertionPoint("common.contextmenu.attachment.options",this)],defaults:{xtype:"zarafa.conditionalitem",hideOnDisabled:false}});
Zarafa.common.attachment.ui.AttachmentContextMenu.superclass.constructor.call(this,a)},createContextActionItems:function(a){var b=container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.view"],a);return[{text:_("Preview"),scope:this,handler:this.onPreviewItem,beforeShow:function(c){!b||b instanceof Zarafa.common.CommonContext?c.setDisabled(true):c.setDisabled(false)}},{text:_("Download"),scope:this,handler:this.onDownloadItem}]},onPreviewItem:function(){Zarafa.common.Actions.openViewRecord(this.records)},
onDownloadItem:function(){Zarafa.common.Actions.downloadAttachment(this.records)}});Ext.reg("zarafa.attachmentcontextmenu",Zarafa.common.attachment.ui.AttachmentContextMenu);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentBox=Ext.extend(Zarafa.common.ui.Box,{constructor:function(a){a=a||{};Ext.applyIf(a,{enableIcons:false,cls:"x-zarafa-boxfield-attachment-item",ellipsisStringStartLength:20,ellipsisStringEndLength:20,textTpl:'<tpl if="!Ext.isEmpty(values.name)">{name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)}</tpl><tpl if="!Ext.isEmpty(values.size)">&nbsp;({values.size:fileSize})</tpl>'});Zarafa.common.attachment.ui.AttachmentBox.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.attachmentbox",Zarafa.common.attachment.ui.AttachmentBox);Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.taskmainpanel",layout:"zarafa.collapsible",items:[{xtype:"zarafa.searchbar",searchFields:Zarafa.task.data.SearchFields,context:a.context},{xtype:"zarafa.switchviewcontentcontainer",ref:"viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.contextmainpaneltoolbar",defaultTitle:_("Tasks"),paging:container.populateInsertionPoint("context.task.toolbar.paging",
this),items:container.populateInsertionPoint("context.task.toolbar.item",this),context:a.context}});Zarafa.task.ui.TaskMainPanel.superclass.constructor.call(this,a)},initViews:function(a){var b=[{xtype:"zarafa.taskgrid",id:"task-grid",context:a}];a=container.populateInsertionPoint("context.task.views",this,a);Ext.each(a,function(c){b.push(c)},this);return b},initEvents:function(){if(Ext.isDefined(this.context)){this.mon(this.context,"viewchange",this.onViewChange,this);this.onViewChange(this.context,
this.context.getCurrentView())}},onViewChange:function(a,b){switch(b){case Zarafa.task.data.Views.SEARCH:case Zarafa.task.data.Views.LIST:this.viewPanel.switchView("task-grid");break}}});Ext.reg("zarafa.taskmainpanel",Zarafa.task.ui.TaskMainPanel);Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskGridView=Ext.extend(Zarafa.common.ui.grid.GridPanel,{model:undefined,completeColumn:undefined,constructor:function(a){a=a||{};this.completeColumn=new Ext.ux.grid.CheckColumn({dataIndex:"complete",header:'<p class="icon_complete">&nbsp;</p>',width:25,fixed:true,id:"complete",onMouseDown:this.onCompleteColumnMouseDown.createDelegate(this),tooltip:_("Sort by: Complete"),editor:{xtype:"checkbox",style:"margin-left: 10px;"}});this.completeColumn.renderer=this.completeColumn.renderer.createSequence(this.completeColumnRenderer);
if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);a.plugins=Ext.value(a.plugins,[]);a.plugins.push(this.completeColumn);Ext.applyIf(a,{xtype:"zarafa.taskgrid",border:false,stateful:true,statefulRelativeDimensions:false,loadMask:this.initLoadMask(),viewConfig:this.initViewConfig(),selModel:this.initSelectionModel(),colModel:this.initColumnModel(this.completeColumn),
enableDragDrop:true,ddGroup:"dd.mapiitem",keys:{key:Ext.EventObject.DELETE,handler:this.onKeyDelete,scope:this}});Zarafa.task.ui.TaskGridView.superclass.constructor.call(this,a)},initViewConfig:function(){return{autoExpandColumn:"subject",enableRowBody:false,getRowClass:this.viewConfigGetRowClass}},initLoadMask:function(){return{msg:_("Loading tasks")+"..."}},initColumnModel:function(a){return new Zarafa.task.ui.TaskGridColumnModel({completeColumn:a})},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false,
listeners:{scope:this,selectionchange:this.onSelectionChange}})},initEvents:function(){Zarafa.task.ui.TaskGridView.superclass.initEvents.call(this);this.mon(this,"cellcontextmenu",this.onCellContextMenu,this);this.mon(this,"rowdblclick",this.onRowDblClick,this);this.mon(this,"rowbodycontextmenu",this.onRowBodyContextMenu,this)},onCompleteColumnMouseDown:function(a,b){if(Ext.fly(b).hasClass(this.completeColumn.createId())){var c=this.store.getAt(this.getView().findRowIndex(b));c.beginEdit();if(c.get("complete")){c.set("status",
Zarafa.core.mapi.TaskStatus.NOT_STARTED);c.set("complete",false);c.set("percent_complete",0);c.set("date_completed",null)}else{c.set("complete",true);c.set("percent_complete",1);c.set("status",Zarafa.core.mapi.TaskStatus.COMPLETE);c.set("date_completed",new Date)}c.endEdit();c.save()}},completeColumnRenderer:function(a,b){b.css+=" zarafa-grid-empty-cell"},onRowDblClick:function(a){Zarafa.task.Actions.openTaskDialog(a.getSelectionModel().getSelections())},onRowBodyContextMenu:function(a,b,c){a=this.getSelectionModel();
a.isSelected(b)||a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY())},onCellContextMenu:function(a,b,c,d){a=this.getSelectionModel();var e=this.getColumnModel();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);b=e.getColumnById(e.getColumnId(c));c=a.getSelections();switch(b.dataIndex){case "importance":Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.importance"],c,{position:d.getXY()});
break;default:Zarafa.common.Actions.openContextMenu(c,d.getXY());break}},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},onKeyDelete:function(){var a=this.getSelectionModel().getSelections();Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)},viewConfigGetRowClass:function(a){var b="",c=a.get("complete"),d=a.get("duedate");if(Ext.isDate(d)&&d.getTime()<(new Date).getTime())b+="zarafa-task-overdue ";if(c)b+="zarafa-task-complete ";a.isRead()||(b+="zarafa-task-unread ");
return b}});Ext.reg("zarafa.taskgrid",Zarafa.task.ui.TaskGridView);Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{completeColumn:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(a.completeColumn),defaults:{sortable:true}});Ext.apply(this,a);Zarafa.task.ui.TaskGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(a){return[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',width:25,tooltip:_("Sort by: Icon"),fixed:true,hideable:false,renderer:Zarafa.common.ui.grid.Renderers.icon,
editor:{xtype:"displayfield",style:"height: 17px;",setValue:function(b){this.addClass(Zarafa.core.mapi.IconIndex.getClassName(b))}}},{dataIndex:"importance",header:'<p class="icon_importance">&nbsp;</p>',width:40,tooltip:_("Sort by: Priority"),fixed:true,renderer:Zarafa.common.ui.grid.Renderers.importance,editor:{xtype:"iconcombo",store:{xtype:"jsonstore",fields:["iconCls","name","value"],data:Zarafa.common.data.ImportanceFlags.flags},triggerAction:"all",mode:"local",valueField:"value",displayField:"name",
iconClsField:"iconCls"}},{header:'<p class="icon_attachment">&nbsp;</p>',dataIndex:"hasattach",width:24,renderer:Zarafa.common.ui.grid.Renderers.attachment,fixed:true,tooltip:_("Sort by: Attachment")},{header:'<p class="icon_recurring">&nbsp;</p>',dataIndex:"recurring",width:24,renderer:Zarafa.common.ui.grid.Renderers.recurrence,fixed:true},{header:'<p class="icon_reminder">&nbsp;</p>',dataIndex:"reminder",width:24,renderer:Zarafa.common.ui.grid.Renderers.reminder,fixed:true,hidden:true},{header:_("Reminder Time"),
dataIndex:"flagdueby",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Reminder Time"),hidden:true},a,{id:"subject",dataIndex:"subject",header:_("Subject"),tooltip:_("Sort by: Subject"),renderer:Zarafa.common.ui.grid.Renderers.subject,editor:{xtype:"textfield"}},{dataIndex:"startdate",header:_("Start Date"),tooltip:_("Sort by: Start Date"),renderer:Zarafa.common.ui.grid.Renderers.date,editor:{xtype:"datefield",emptyText:_("None")}},{dataIndex:"duedate",header:_("Due Date"),
tooltip:_("Sort by: Due Date"),renderer:Zarafa.common.ui.grid.Renderers.date,editor:{xtype:"datefield",emptyText:_("None")}},{dataIndex:"owner",header:_("Owner"),tooltip:_("Sort by: Owner"),renderer:Zarafa.common.ui.grid.Renderers.text,editor:{xtype:"textfield",disabled:true}},{dataIndex:"categories",header:_("Categories"),tooltip:_("Sort by: Categories"),renderer:Zarafa.common.ui.grid.Renderers.text,editor:{allowBlank:true,xtype:"lovcombo",separator:";",hideOnSelect:false,store:{xtype:"zarafa.categoriesstore"},
mode:"local",triggerAction:"all",displayField:"category",valueField:"category"}},{dataIndex:"percent_complete",header:_("% Completed"),width:75,tooltip:_("Sort by: Percent Completed"),renderer:Zarafa.common.ui.grid.Renderers.percentage,editor:{xtype:"zarafa.spinnerfield",minValue:0,defaultValue:0,incrementValue:0.25,maxValue:1,plugins:["zarafa.percentspinner"]}},{header:_("Sensitivity"),dataIndex:"sensitivity",width:160,renderer:Zarafa.common.ui.grid.Renderers.sensitivity,hidden:true},{header:_("Company"),
tooltip:_("Sort by: Company"),dataIndex:"companies",hidden:true,renderer:Zarafa.common.ui.grid.Renderers.text},{header:_("Modification"),dataIndex:"last_modification_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,hidden:true,tooltip:_("Sort by: Modification Time")},{header:_("Date Completed"),dataIndex:"date_completed",width:160,renderer:Zarafa.common.ui.grid.Renderers.date,hidden:true,tooltip:_("Sort by: Date Completed")},{header:_("Status"),dataIndex:"status",width:160,hidden:true,
renderer:Zarafa.common.ui.grid.Renderers.taskstatus,tooltip:_("Sort by: Status")},{header:_("Total Work"),dataIndex:"totalwork",width:160,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.durationHours,tooltip:_("Sort by: Total Work")},{header:_("Actual Work"),dataIndex:"actualwork",width:160,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.durationHours,tooltip:_("Sort by: Actual Work")},{header:_("Organizer"),dataIndex:"sent_representing_name",width:100,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.name,
tooltip:_("Sort by: Organizer")},{header:_("Assigned To"),dataIndex:"display_to",width:100,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.name,tooltip:_("Sort by: Assignee")},{header:_("Mileage"),dataIndex:"mileage",width:100,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.text,tooltip:_("Sort by: Mileage")},{header:_("Billing Information"),dataIndex:"billing_information",width:100,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.text,tooltip:_("Sort by: Billing Information")},{header:_("Size"),
dataIndex:"message_size",width:80,renderer:Zarafa.common.ui.grid.Renderers.size,hidden:true,tooltip:_("Sort by: Size")}]}});Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.task.contextmenu.actions",this),{xtype:"menuseparator"},this.createContextOptionsItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.task.contextmenu.options",this)]});Zarafa.task.ui.TaskContextMenu.superclass.constructor.call(this,a)},createContextActionItems:function(){return[{xtype:"zarafa.conditionalitem",
text:_("Open"),iconCls:"icon_open",singleSelectOnly:true,handler:function(){Zarafa.task.Actions.openTaskDialog(this.records)},scope:this},{hidden:true,xtype:"zarafa.conditionalitem",text:_("Print"),iconCls:"icon_print",handler:function(){Zarafa.common.Actions.openPrintDialog(this.records)},scope:this}]},createContextOptionsItems:function(){return[{xtype:"zarafa.conditionalitem",text:_("Mark Read"),iconCls:"icon_mail icon_message_read",beforeShow:function(a,b){this.onReadFlagItemBeforeShow(a,b,false)},
handler:function(){this.onReadFlagItemClicked(true)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Mark Unread"),iconCls:"icon_mail icon_message_unread",beforeShow:function(a,b){this.onReadFlagItemBeforeShow(a,b,true)},handler:function(){this.onReadFlagItemClicked(false)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Categories"),iconCls:"icon_categories",handler:function(){Zarafa.common.Actions.openCategoriesDialog(this.records,true)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Delete"),
iconCls:"icon_delete",nonEmptySelectOnly:true,handler:this.onContextItemDelete,scope:this}]},onContextItemDelete:function(){var a=undefined;Ext.each(this.records,function(b){a=b.store;a.remove(b)},this);a.save(this.records)},onReadFlagItemBeforeShow:function(a,b,c){var d=0;Ext.each(b,function(e){e.isRead()==c&&d++},this);a.setDisabled(d==0)},onReadFlagItemClicked:function(a){Zarafa.common.Actions.markAsRead(this.records,a)}});Ext.reg("zarafa.taskcontextmenu",Zarafa.task.ui.TaskContextMenu);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsPluginsCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Plugins"),categoryIndex:9998,iconCls:"zarafa-settings-category-plugins",items:container.populateInsertionPoint("context.settings.category.plugins",this)});if(Ext.isEmpty(a.items))a.hidden=true;Zarafa.settings.ui.SettingsPluginsCategory.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingspluginscategory",Zarafa.settings.ui.SettingsPluginsCategory);
Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{constructor:function(a){a=a||{};var b=container.populateInsertionPoint("context.settings.categories",this,a.context);a.context.getModel().getEditableSettingsModel();for(var c=[],d=[],e=0,f=b.length;e<f;e++){var g=Ext.create(b[e]);c.push({xtype:"zarafa.settingscategorytab",title:g.title,categoryIndex:g.categoryIndex,iconCls:g.iconCls,hidden:g.hidden,context:a.context,category:g});if(g.hidden!==true)for(var h=0,i=g.items.length;h<
i;h++){var j=g.items.get(h);j.favorite===true&&d.push({xtype:"zarafa.settingsfavoritetab",title:j.title,favoriteIndex:g.categoryIndex*(h+1),iconCls:j.iconCls,context:a.context,category:g,widget:j})}b[e]=g}c=Zarafa.core.Util.sortArray(c,"ASC","categoryIndex");d=Zarafa.core.Util.sortArray(d,"ASC","favoriteIndex");b=Zarafa.core.Util.sortArray(b,"ASC","categoryIndex");Ext.applyIf(a,{layout:{type:"hbox",align:"stretch"},items:[{xtype:"zarafa.settingscategorypanel",width:200,context:a.context,items:c},
{xtype:"container",flex:1,layout:{type:"vbox",align:"stretch"},items:[{xtype:"container",flex:1,layout:{type:"hbox",align:"stretch"},items:[{xtype:"zarafa.settingscategorywidgetpanel",flex:0.8,context:a.context,items:b},{xtype:"zarafa.settingsfavoritepanel",flex:0.2,context:a.context,items:d}]},{xtype:"container",height:50,layout:{type:"hbox",align:"stretch"},items:[{xtype:"container",cls:"x-panel-btns",flex:0.8,layout:"fit",items:[{xtype:"toolbar",toolbarCls:"x-panel-fbar",enableOverflow:false,toolbarCls:"x-panel-footer",
cls:"x-panel-fbar",flex:0.8,buttonAlign:"right",defaults:{minWidth:Ext.Panel.prototype.minButtonWidth},items:[{xtype:"button",text:_("Apply"),handler:this.onApply,scope:this},{xtype:"button",text:_("Discard"),handler:this.onDiscard,scope:this}]}]},{xtype:"container",flex:0.2}]}]}]});Zarafa.settings.ui.SettingsMainPanel.superclass.constructor.call(this,a)},onApply:function(){this.context&&this.context.getModel().applyChanges()},onDiscard:function(){this.context&&this.context.getModel().discardChanges()}});
Ext.reg("zarafa.settingsmainpanel",Zarafa.settings.ui.SettingsMainPanel);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsGeneralCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{origLanguage:"",constructor:function(a){a=a||{};var b=container.getUser(),c={xtype:"jsonstore",autoDestroy:true,fields:["lang","name"],data:container.getLanguages()},d=container.populateInsertionPoint("main.maintabbar.left",this);d=Zarafa.core.Util.sortArray(d,"ASC","tabOrderIndex");d={xtype:"jsonstore",autoDestroy:true,fields:["context","text"],data:d};Ext.applyIf(a,{title:_("General"),categoryIndex:0,iconCls:"zarafa-settings-category-general",
items:[{xtype:"zarafa.settingswidget",title:String.format(_("Account information - {0}"),b.getDisplayName()),layout:"form",items:[{xtype:"displayfield",fieldLabel:_("Display Name"),value:b.getDisplayName(),htmlEncode:true},{xtype:"displayfield",fieldLabel:_("E-mail"),value:b.getSMTPAddress(),htmlEncode:true},{xtype:"zarafa.compositefield",fieldLabel:_("Language"),items:[{xtype:"combo",name:"zarafa/v1/main/language",ref:"../../languageCombo",width:200,store:c,mode:"local",triggerAction:"all",displayField:"name",
valueField:"lang",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onLanguageSelect,scope:this}},{xtype:"displayfield",ref:"../../languageWarning"}]},{xtype:"combo",fieldLabel:_("Startup folder"),name:"zarafa/v1/main/default_context",ref:"../startupCombo",width:200,store:d,mode:"local",triggerAction:"all",displayField:"text",valueField:"context",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onStartupSelect,scope:this}}]},
container.populateInsertionPoint("context.settings.category.general",this)]});Zarafa.settings.ui.SettingsGeneralCategory.superclass.constructor.call(this,a)},onLanguageSelect:function(a,b){var c=b.get(a.valueField);this.origLanguage!==c?this.languageWarning.setValue(_("This change requires a reload of the WebApp")):this.languageWarning.reset();this.model&&this.model.set(a.name,c)},onStartupSelect:function(a,b){var c=b.get(a.valueField);this.model&&this.model.set(a.name,c)},update:function(a){Zarafa.settings.ui.SettingsGeneralCategory.superclass.update.apply(this,
arguments);this.model=a;this.origLanguage=a.get(this.languageCombo.name);this.languageCombo.setValue(this.origLanguage);this.languageWarning.reset();this.startupCombo.setValue(a.get(this.startupCombo.name))},updateSettings:function(a){Zarafa.settings.ui.SettingsGeneralCategory.superclass.updateSettings.apply(this,arguments);a.beginEdit();a.set(this.languageCombo.name,this.languageCombo.getValue());a.set(this.startupCombo.name,this.startupCombo.getValue());a.endEdit()}});
Ext.reg("zarafa.settingsgeneralcategory",Zarafa.settings.ui.SettingsGeneralCategory);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{settingsModel:undefined,constructor:function(a){a=a||{};var b=false,c=false;if(a.records){if(Ext.isArray(a.records))a.records=a.records[0];b=Ext.isDefined(a.records.isRoot)&&a.records.isRoot;c=a.records.isEditable()}Ext.applyIf(a,{settingsModel:container.getSettingsModel(),items:[{xtype:"zarafa.conditionalitem",text:_("Edit setting"),hidden:b||!c,handler:this.onEditSetting,scope:this},{xtype:"zarafa.conditionalitem",
text:_("Restore to defaults"),hidden:b,handler:this.onRestoreSettings,scope:this},{xtype:"zarafa.conditionalitem",text:_("Delete settings"),hidden:b,handler:this.onDeleteSettings,scope:this},{xtype:"menuseparator"},container.populateInsertionPoint("context.settings.tree.contextmenu.actions",this)]});Zarafa.settings.ui.SettingsContextMenu.superclass.constructor.call(this,a)},onEditSetting:function(){this.records.startEdit()},onRestoreSettings:function(){this.settingsModel.restore(this.records.id)},
onDeleteSettings:function(){this.settingsModel.remove(this.records.id)}});Ext.reg("zarafa.settingscontextmenu",Zarafa.settings.ui.SettingsContextMenu);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsAdvancedCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Advanced"),categoryIndex:9999,iconCls:"zarafa-settings-category-advanced",layout:"fit",autoScroll:false,items:[{xtype:"zarafa.settingswidget",title:_("Advanced settings"),layout:"fit",items:[{xtype:"zarafa.settingstreepanel",ref:"../treePanel"}]}]});Zarafa.settings.ui.SettingsAdvancedCategory.superclass.constructor.call(this,a)},update:function(a){Zarafa.settings.ui.SettingsAdvancedCategory.superclass.update.apply(this,
arguments);this.treePanel.bindModel(a)}});Ext.reg("zarafa.settingsadvancedcategory",Zarafa.settings.ui.SettingsAdvancedCategory);Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.notemainpanel",layout:"zarafa.collapsible",items:[{xtype:"zarafa.searchbar",searchFields:Zarafa.note.data.SearchFields,context:a.context},{xtype:"zarafa.switchviewcontentcontainer",ref:"viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.contextmainpaneltoolbar",defaultTitle:_("Notes"),paging:container.populateInsertionPoint("context.note.toolbar.paging",
this),items:container.populateInsertionPoint("context.note.toolbar.item",this),context:a.context}});Zarafa.note.ui.NoteMainPanel.superclass.constructor.call(this,a)},initViews:function(a){var b=[{xtype:"zarafa.noteiconview",id:"note-iconview",context:a},{xtype:"zarafa.notegridview",id:"note-gridview",context:a}];a=container.populateInsertionPoint("context.note.views",this,a);Ext.each(a,function(c){b.push(c)},this);return b},initEvents:function(){if(Ext.isDefined(this.context)){this.mon(this.context,
"viewchange",this.onViewChange,this);this.onViewChange(this.context,this.context.getCurrentView())}},onViewChange:function(a,b){switch(b){case Zarafa.note.data.Views.ICON:this.viewPanel.switchView("note-iconview");break;case Zarafa.note.data.Views.LIST:case Zarafa.note.data.Views.SEARCH:this.viewPanel.switchView("note-gridview");break}}});Ext.reg("zarafa.notemainpanel",Zarafa.note.ui.NoteMainPanel);Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteIconView=Ext.extend(Zarafa.common.ui.DraggableDataView,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.icondragselectorplugin");Ext.applyIf(a,{xtype:"zarafa.noteiconview",id:"note-iconview",cls:"zarafa-note-iconview",
loadingText:_("Loading notes")+"...",deferEmptyText:false,emptyText:'<div class="emptytext">'+_("There are no items to show in this view")+"</div>",overClass:"zarafa-note-iconview-over",tpl:this.initTemplate(),multiSelect:true,selectedClass:"zarafa-note-iconview-selected",itemSelector:"div.zarafa-note-iconview-thumb",enableDrag:true,ddGroup:"dd.mapiitem"});Zarafa.note.ui.NoteIconView.superclass.constructor.call(this,a);this.initEvents()},initTemplate:function(){return new Ext.XTemplate('<div style="height: 100%; width: 100%; overflow: auto;">',
'<tpl for=".">','<div class="zarafa-note-iconview-thumb {icon_index:this.getTheme}">','<span class="zarafa-note-iconview-subject">{subject:htmlEncode}</span>',"</div>","</tpl>","</div>",{getTheme:function(a){switch(a){case 768:return"notelargeicon_blue";case 769:return"notelargeicon_green";case 770:return"notelargeicon_pink";case 771:return"notelargeicon_yellow";case 772:return"notelargeicon_white";default:return"notelargeicon_yellow"}}})},getMainPanel:function(){return this.ownerCt},initEvents:function(){this.on("contextmenu",
this.onNoteIconContextMenu,this);this.on("dblclick",this.onIconDblClick,this);this.on("selectionchange",this.onSelectionChange,this)},onNoteIconContextMenu:function(a,b,c,d){a.isSelected(c)||a.select(c);Zarafa.common.Actions.openContextMenu(a.getSelectedRecords(),d.getXY())},onIconDblClick:function(a,b){Zarafa.note.Actions.openNoteDialog(this.getStore().getAt(b))},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelectedRecords())}});Ext.reg("zarafa.noteiconview",Zarafa.note.ui.NoteIconView);
Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true}});Ext.apply(this,a);Zarafa.note.ui.NoteGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"subject",header:"Subject",
width:400,tooltip:_("Sort by: Subject"),renderer:Zarafa.common.ui.grid.Renderers.subject},{dataIndex:"creation_time",header:"Created",tooltip:_("Sort by: Created"),width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime},{dataIndex:"body",header:"Body",width:400,tooltip:_("Sort by: Body"),renderer:Ext.util.Format.htmlEncode,hidden:true},{dataIndex:"categories",header:"Categories",width:160,tooltip:_("Sort by: Categories"),renderer:Zarafa.common.ui.grid.Renderers.text},{dataIndex:"color",header:_("Color"),
width:160,tooltip:_("Sort by: Color"),renderer:Ext.util.Format.htmlEncode,hidden:true}]}});Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};if(a.records)if(!Ext.isArray(a.records))a.records=[a.records];Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.note.contextmenu.actions",this),{xtype:"menuseparator"},container.populateInsertionPoint("context.note.contextmenu.options",this)],defaults:{xtype:"zarafa.conditionalitem",hideOnDisabled:false}});Zarafa.note.ui.NoteContextMenu.superclass.constructor.call(this,
a)},createContextActionItems:function(){return[{text:_("Open"),iconCls:"icon_open",scope:this,handler:this.onContextItemOpen,singleSelectOnly:true},{hidden:true,text:_("Print"),iconCls:"icon_print",scope:this,handler:this.onContextItemPrint,singleSelectOnly:true},{xtype:"menuseparator"},{text:_("Categories"),iconCls:"icon_categories",scope:this,handler:this.onContextItemCategories,singleSelectOnly:true},{xtype:"menuseparator"},{text:_("Delete"),iconCls:"icon_delete",scope:this,handler:this.onContextItemDelete}]},
onContextItemOpen:function(){Zarafa.note.Actions.openNoteDialog(this.records)},onContextItemEmail:function(){Zarafa.note.Actions.openNoteEmailDialog(this.records)},onContextItemCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.records)},onContextItemPrint:function(){Zarafa.common.Actions.openPrintDialog(this.records)},onContextItemDelete:function(){var a=this.records[0].getStore();a.remove(this.records);a.save()}});Ext.reg("zarafa.notecontextmenu",Zarafa.note.ui.NoteContextMenu);
Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailPreviewPanelToolbarButtons=Ext.extend(Object,{model:undefined,constructor:function(a){Ext.apply(this,a)},getToolbarButtons:function(){return[{xtype:"zarafa.toolbarbutton",tooltip:_("Copy/Move"),overflowText:_("Copy/Move"),iconCls:"icon_copy",nonEmptySelectOnly:true,handler:this.onCopyMove,model:this.model},{xtype:"zarafa.toolbarbutton",tooltip:_("Delete"),overflowText:_("Delete"),iconCls:"icon_delete",nonEmptySelectOnly:true,handler:this.onDelete,model:this.model}]},onCopyMove:function(){Zarafa.common.Actions.openCopyMoveDialog(this.model.getSelectedRecords())},
onDelete:function(){Zarafa.common.Actions.deleteRecords(this.model.getSelectedRecords())},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.model.getSelectedRecords())}});Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailPreviewPanel=Ext.extend(Zarafa.core.ui.PreviewPanel,{constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{xtype:"zarafa.mailpreviewpanel",cls:"zarafa-previewpanel zarafa-context-mainpanel",width:600,height:400,tbar:{height:33,items:[this.createReplyButton(),this.createReplyAllButton(),this.createForwardButton()]}});Zarafa.mail.ui.MailPreviewPanel.superclass.constructor.call(this,a)},createReplyButton:function(){return{xtype:"button",
tooltip:_("Reply"),overflowText:_("Reply"),iconCls:"icon_replyEmail",responseMode:Zarafa.mail.data.ActionTypes.reply,handler:this.onResponse,scope:this}},createReplyAllButton:function(){return{xtype:"button",tooltip:_("Reply All"),overflowText:_("Reply All"),iconCls:"icon_replyAllEmail",responseMode:Zarafa.mail.data.ActionTypes.replyall,handler:this.onResponse,scope:this}},createForwardButton:function(){return{xtype:"button",tooltip:_("Forward"),overflowText:_("Forward"),iconCls:"icon_forwardEmail",
responseMode:Zarafa.mail.data.ActionTypes.forward,handler:this.onResponse,scope:this}},onResponse:function(a){Zarafa.mail.Actions.openMailRespondsDialog(this.record,this.model,a.responseMode)}});Ext.reg("zarafa.mailpreviewpanel",Zarafa.mail.ui.MailPreviewPanel);Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.mailpanel",layout:"zarafa.switchborder",items:[this.initMailGrid(a),this.initPreviewPanel(a.context)]});Zarafa.mail.ui.MailPanel.superclass.constructor.call(this,a)},initMailGrid:function(a){return{xtype:"panel",layout:"zarafa.collapsible",cls:"zarafa-context-mainpanel",minWidth:200,minHeight:200,region:"center",collapsible:false,split:true,items:[{xtype:"zarafa.searchbar",
ref:"../searchBar",searchFields:Zarafa.mail.data.SearchFields,context:a.context},{xtype:"zarafa.switchviewcontentcontainer",ref:"../viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.contextmainpaneltoolbar",defaultTitle:_("Mail"),height:33,paging:container.populateInsertionPoint("context.mail.toolbar.paging",this),items:container.populateInsertionPoint("context.mail.toolbar.item",this),context:a.context}}},initViews:function(a){var b=[{xtype:"zarafa.mailgrid",flex:1,
id:"mail-grid",anchor:"100%",context:a,ref:"../../mailGrid"}];a=container.populateInsertionPoint("context.mail.views",this,a);Ext.each(a,function(c){b.push(c)},this);return b},initPreviewPanel:function(a){return{xtype:"zarafa.mailpreviewpanel",region:"south",split:true,context:a}},initEvents:function(){if(Ext.isDefined(this.context)){this.mon(this.context,"viewchange",this.onViewChange,this);this.mon(this.context,"viewmodechange",this.onViewModeChange,this);this.onViewChange(this.context,this.context.getCurrentView());
this.onViewModeChange(this.context,this.context.getCurrentViewMode())}},onViewChange:function(a,b){switch(b){case Zarafa.mail.data.Views.LIST:this.viewPanel.switchView("mail-grid");break}},onViewModeChange:function(a,b){var c;switch(b){case Zarafa.mail.data.ViewModes.NO_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.OFF;break;case Zarafa.mail.data.ViewModes.RIGHT_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.HORIZONTAL;break;case Zarafa.mail.data.ViewModes.BOTTOM_PREVIEW:c=
Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.VERTICAL;break;case Zarafa.mail.data.ViewModes.SEARCH:return}var d=this.getLayout();if(Ext.isString(d))this.layoutConfig={orientation:c};else d.setOrientation(c)}});Ext.reg("zarafa.mailpanel",Zarafa.mail.ui.MailPanel);Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailGridContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.mail.contextmenu.actions",this),{xtype:"menuseparator"},this.createContextOptionsItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.mail.contextmenu.options",
this)]});Zarafa.mail.ui.MailGridContextMenu.superclass.constructor.call(this,a)},createContextActionItems:function(){return[{xtype:"zarafa.conditionalitem",text:_("Open"),iconCls:"icon_open",singleSelectOnly:true,handler:this.onContextItemOpen,scope:this},{hidden:false,xtype:"zarafa.conditionalitem",text:_("Print"),iconCls:"icon_print",singleSelectOnly:true,handler:this.onContextItemPrint,scope:this},{xtype:"menuseparator"},{xtype:"zarafa.conditionalitem",text:_("Reply"),iconCls:"icon_replyEmail",
singleSelectOnly:true,handler:function(){Zarafa.mail.Actions.openMailRespondsDialog(this.records,this.model,Zarafa.mail.data.ActionTypes.reply)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Reply All"),iconCls:"icon_replyAllEmail",singleSelectOnly:true,handler:function(){Zarafa.mail.Actions.openMailRespondsDialog(this.records,this.model,Zarafa.mail.data.ActionTypes.replyall)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Forward"),iconCls:"icon_forwardEmail",singleSelectOnly:true,handler:function(){Zarafa.mail.Actions.openMailRespondsDialog(this.records,
this.model,Zarafa.mail.data.ActionTypes.forward)},scope:this}]},createContextOptionsItems:function(){return[{xtype:"zarafa.conditionalitem",text:_("Mark Read"),iconCls:"icon_mail icon_message_read",beforeShow:function(a,b){this.onReadFlagItemBeforeShow(a,b,false)},handler:function(){this.onReadFlagItemClicked(true)},scope:this},{xtype:"zarafa.conditionalitem",text:_("Mark Unread"),iconCls:"icon_mail icon_message_unread",beforeShow:function(a,b){this.onReadFlagItemBeforeShow(a,b,true)},handler:function(){this.onReadFlagItemClicked(false)},
scope:this},{xtype:"zarafa.conditionalitem",text:_("Categories"),iconCls:"icon_categories",handler:function(){Zarafa.common.Actions.openCategoriesDialog(this.records,true)},scope:this},{xtype:"menuseparator"},Zarafa.mail.dialogs.MailFlagsMenu.createMailFlagSubmenu(true),Zarafa.mail.dialogs.MailFlagsMenu.createStateMailFlagButtons(),{xtype:"menuseparator"},{xtype:"zarafa.conditionalitem",text:_("Move to Junk Folder"),iconCls:"icon_junk",handler:this.onContextItemJunk,scope:this},{xtype:"zarafa.conditionalitem",
text:_("Delete"),iconCls:"icon_delete",handler:this.onContextItemDelete,scope:this},{xtype:"menuseparator"},{xtype:"zarafa.conditionalitem",text:_("Options"),iconCls:"icon_openMessageOptions",singleSelectOnly:true,handler:this.onContextItemOptions,scope:this}]},onContextItemOpen:function(){Zarafa.mail.Actions.openMailDialog(this.records,this.context)},onContextItemPrint:function(){Zarafa.common.Actions.openPrintDialog(this.records)},onReadFlagItemBeforeShow:function(a,b,c){var d=0;Ext.each(b,function(e){e.isRead()==
c&&d++},this);a.setDisabled(d==0)},onReadFlagItemClicked:function(a){Zarafa.common.Actions.markAsRead(this.records,a)},onContextItemJunk:function(){var a=container.getHierarchyStore().getDefaultFolder("junk"),b=undefined;Ext.each(this.records,function(c){b=c.store;c.moveTo(a)},this);b.save(this.records)},onContextItemDelete:function(){Zarafa.common.Actions.deleteRecords(this.records)},onContextItemOptions:function(){Zarafa.mail.Actions.openMailOptionsDialog(this.records,true)}});
Ext.reg("zarafa.mailgridcontextmenu",Zarafa.mail.ui.MailGridContextMenu);Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{useCompactView:false,constructor:function(a){a=a||{};this.defaultColumns=this.createDefaultColumns();this.compactColumns=this.createCompactColumns();Ext.applyIf(a,{columns:this.defaultColumns,defaults:{sortable:true}});if(a.useCompactView===true)a.columns=this.compactColumns;Ext.apply(this,a);Zarafa.mail.ui.MailGridColumnModel.superclass.constructor.call(this,a)},createDefaultColumns:function(){return[{header:'<p class="icon_importance">&nbsp;</p>',
dataIndex:"importance",width:24,renderer:Zarafa.common.ui.grid.Renderers.importance,fixed:true,tooltip:_("Sort by: Importance")},{id:"column_icon",header:'<p class="icon_index">&nbsp;</p>',dataIndex:"icon_index",width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,fixed:true,tooltip:_("Sort by: Icon")},{header:'<p class="icon_attachment">&nbsp;</p>',dataIndex:"hasattach",width:24,renderer:Zarafa.common.ui.grid.Renderers.attachment,fixed:true,tooltip:_("Sort by: Attachment")},{header:_("From"),dataIndex:"sent_representing_name",
width:100,renderer:Zarafa.common.ui.grid.Renderers.name,tooltip:_("Sort by: From")},{header:_("To"),dataIndex:"display_to",width:320,renderer:Zarafa.common.ui.grid.Renderers.to,tooltip:_("Sort by: To")},{header:_("Subject"),dataIndex:"subject",width:400,renderer:Zarafa.common.ui.grid.Renderers.subject,tooltip:_("Sort by: Subject")},{header:_("Categories"),dataIndex:"categories",width:160,renderer:Zarafa.common.ui.grid.Renderers.text,hidden:true,tooltip:_("Sort by: Categories")},{header:_("Received"),
dataIndex:"message_delivery_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Received")},{header:_("Sent"),dataIndex:"client_submit_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Sent")},{header:_("Modification"),dataIndex:"last_modification_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,hidden:true,tooltip:_("Sort by: Modification")},{header:_("Size"),dataIndex:"message_size",width:80,renderer:Zarafa.common.ui.grid.Renderers.size,
tooltip:_("Sort by: Size")},{id:"column_flag",header:'<p class="icon_mail_flag">&nbsp;</p>',dataIndex:"flag_status",width:24,renderer:Zarafa.common.ui.grid.Renderers.flag,fixed:true,tooltip:_("Sort by: Flag Status")}]},createCompactColumns:function(){return[{header:'<p class="icon_index">&nbsp;</p>',dataIndex:"icon_index",width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,fixed:true,tooltip:_("Sort by: Icon Index")},{header:_("From"),dataIndex:"sent_representing_name",width:100,renderer:Zarafa.common.ui.grid.Renderers.name,
tooltip:_("Sort by: From")},{header:_("To"),dataIndex:"display_to",width:320,renderer:Zarafa.common.ui.grid.Renderers.to,tooltip:_("Sort by: To")},{header:_("Received"),dataIndex:"message_delivery_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Received")},{header:_("Sent"),dataIndex:"client_submit_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Sent")},{header:'<p class="icon_mail_flag">&nbsp;</p>',dataIndex:"flag_status",
width:24,renderer:Zarafa.common.ui.grid.Renderers.flag,fixed:true,tooltip:_("Sort by: Flag Status")}]},setCompactView:function(a){if(this.useCompactView!==a){if(this.useCompactView=a){this.name="compact";this.defaultColumns=this.config;this.columns=this.compactColumns}else{this.name="default";this.compactColumns=this.config;this.columns=this.defaultColumns}this.setConfig(this.columns,false)}}});Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{context:undefined,model:undefined,senderFolderTypes:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.senderFolderTypes))a.senderFolderTypes=["outbox","sent","drafts"];if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);Ext.applyIf(a,{xtype:"zarafa.mailgrid",border:false,stateful:true,
statefulRelativeDimensions:false,loadMask:this.initLoadMask(),viewConfig:this.initViewConfig(),sm:this.initSelectionModel(),cm:this.initColumnModel(),enableDragDrop:true,ddGroup:"dd.mapiitem",keys:{key:Ext.EventObject.DELETE,handler:this.onKeyDelete,scope:this}});Zarafa.mail.ui.MailGrid.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.mail.ui.MailGrid.superclass.initEvents.call(this);this.mon(this,"cellcontextmenu",this.onCellContextMenu,this);this.mon(this,"rowbodycontextmenu",this.onRowBodyContextMenu,
this);this.mon(this,"cellclick",this.onCellClick,this);this.mon(this,"rowdblclick",this.onRowDblClick,this);this.mon(this.getSelectionModel(),"rowselect",this.onRowSelect,this,{buffer:1});this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this,{buffer:1});this.mon(this.model,"recordselectionchange",this.onRecordSelectionChange,this);this.mon(this.context,"viewmodechange",this.onContextViewModeChange,this);this.onContextViewModeChange(this.context,this.context.getCurrentViewMode())},
initLoadMask:function(){return{msg:_("Loading mail")+"..."}},initViewConfig:function(){return{enableRowBody:true,getRowClass:this.viewConfigGetRowClass,rowSelectorDepth:15}},viewConfigGetRowClass:function(a,b,c){b=a.isRead()?"mail_read":"mail_unread";if(this.enableRowBody){var d={},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 {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}return"x-grid3-row-collapsed "+
b},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false})},initColumnModel:function(){return new Zarafa.mail.ui.MailGridColumnModel},onContextViewModeChange:function(a,b){if(b!==Zarafa.mail.data.ViewModes.SEARCH){var c=b===Zarafa.mail.data.ViewModes.RIGHT_PREVIEW;this.getView().enableRowBody=c;this.getColumnModel().setCompactView(c)}},onBeforeConfigChange:function(a,b){if(this.currentEntryId){for(var c=this.senderFolderTypes.indexOf(container.getHierarchyStore().getByEntryId(this.currentStoreEntryId).getFolder(this.currentEntryId).getDefaultFolderKey())>=
0,d=0,e=b.length;d<e;d++){var f=b[d];if(f.dataIndex=="sent_representing_name")f.hidden=c;else if(f.dataIndex=="display_to")f.hidden=!c;else if(f.dataIndex=="message_delivery_time")f.hidden=c;else if(f.dataIndex=="client_submit_time")f.hidden=!c}Zarafa.mail.ui.MailGrid.superclass.onBeforeConfigChange.apply(this,arguments)}},onCellContextMenu:function(a,b,c,d){a=this.getSelectionModel();var e=this.getColumnModel();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);
b={};if(c>=0)b=e.getColumnById(e.getColumnId(c));c=a.getSelections();switch(b.dataIndex){case "importance":Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.importance"],c,{position:d.getXY()});break;case "flag_status":Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["mail.contextmenu.flags"],c,{position:d.getXY()});break;default:Zarafa.common.Actions.openContextMenu(c,d.getXY(),{context:this.context});break}},onRowBodyContextMenu:function(a,
b,c){this.onCellContextMenu(a,b,-1,c)},onCellClick:function(a,b,c){a=this.getSelectionModel().getSelected();if(Ext.isDefined(a)){b=this.getColumnModel();switch(b.getColumnById(b.getColumnId(c)).dataIndex){case "flag_status":if(a.get("flag_status")==Zarafa.core.mapi.FlagStatus.flagged){a.set("flag_status",Zarafa.core.mapi.FlagStatus.completed);a.set("flag_icon",Zarafa.core.mapi.FlagIcon.clear)}else{a.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged);a.set("flag_icon",Zarafa.core.mapi.FlagIcon.red)}break}a.dirty&&
a.save()}},onRowDblClick:function(){Zarafa.mail.Actions.openMailDialog(this.getSelectionModel().getSelected(),this.context)},onRowSelect:function(a,b,c){b=a.getCount();if(b==0)this.model.setPreviewRecord(undefined);else b==1&&a.getSelected()===c&&this.model.setPreviewRecord(c)},onSelectionChange:function(a){a=a.getSelections();this.model.setSelectedRecords(a);Ext.isEmpty(a)&&this.model.setPreviewRecord(undefined)},onRecordSelectionChange:function(a,b){if(!this.getSelectionModel().hasSelection()&&
!Ext.isEmpty(b)){var c=a.getStore().indexOf(b[0]);this.getSelectionModel().selectRecords(b);this.getView().focusRow(c)}},onKeyDelete:function(){var a=this.getSelectionModel().getSelections();Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)}});Ext.reg("zarafa.mailgrid",Zarafa.mail.ui.MailGrid);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsSignaturesWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{dirtySelectedSignature:false,selectedSignature:undefined,constructor:function(a){a=a||{};var b={xtype:"jsonstore",fields:[{name:"id",type:"int"},{name:"name"},{name:"content"},{name:"isHTML",type:"boolean"}],sortInfo:{field:"id",direction:"ASC"},autoDestroy:true};Ext.applyIf(a,{title:_("Signatures"),favorite:true,iconCls:"zarafa-settings-favorite-signatures",items:[{xtype:"container",layout:"column",items:[{xtype:"grid",
name:"zarafa/v1/contexts/mail/signatures/all",ref:"../signaturesGrid",columnWidth:0.5,height:200,style:"margin-right:10px",store:b,hideHeaders:true,viewConfig:{forceFit:true,deferEmptyText:false,emptyText:'<div class="emptytext">'+_("No signatures configured")+"</div>"},sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{beforerowselect:this.onSignatureBeforeRowSelect,selectionchange:this.onSignatureSelectionChange,scope:this}}),columns:[{dataIndex:"name",header:"&#160;",renderer:Ext.util.Format.htmlEncode}],
buttons:[{text:_("New"),ref:"../../../newSignatureBtn",handler:this.onAddSignature,scope:this},{text:_("Delete"),ref:"../../../delSignatureBtn",handler:this.onDeleteSignature,scope:this}]},{xtype:"container",layout:"form",columnWidth:0.5,labelWidth:200,items:[{xtype:"combo",ref:"../../newMessageCombo",name:"zarafa/v1/contexts/mail/signatures/new_message",fieldLabel:_("Signature for new messages"),anchor:"100%",store:b,mode:"local",triggerAction:"all",displayField:"name",valueField:"id",lazyInit:false,
autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onSignatureComboSelect,scope:this}},{xtype:"combo",ref:"../../replyMessageCombo",name:"zarafa/v1/contexts/mail/signatures/replyforward_message",fieldLabel:_("Signature for replies and forwards"),anchor:"100%",store:b,mode:"local",triggerAction:"all",displayField:"name",valueField:"id",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onSignatureComboSelect,scope:this}}]}]},{xtype:"textfield",
name:"name",fieldLabel:_("Name"),ref:"nameField",anchor:"100%",listeners:{change:this.onFieldChange,scope:this}},{xtype:"zarafa.editorfield",name:"content",ref:"contentField",anchor:"100%",height:300,listeners:{change:this.onFieldChange,scope:this}}],buttons:[{text:_("Save"),ref:"../saveSignatureBtn",handler:this.onSaveSignature,scope:this}]});Zarafa.mail.settings.SettingsSignaturesWidget.superclass.constructor.call(this,a)},initEvents:function(){var a=this.signaturesGrid.getStore();this.mon(a,"add",
this.onGridAddSignature,this);this.mon(a,"remove",this.onGridDelSignature,this);this.mon(a,"update",this.onGridUpdateSignature,this)},onGridAddSignature:function(a,b,c){a=this.newMessageCombo.getStore();var d=this.replyMessageCombo.getStore();Ext.isArray(b)||(b=[b]);for(var e=[],f=[],g=0,h=b.length;g<h;g++){var i;i=Ext.apply({},b[g].data);e.push(new a.recordType(i,b[g].id));i=Ext.apply({},b[g].data);f.push(new d.recordType(i,b[g].id))}a.insert(c+1,e);d.insert(c+1,f);a.getCount()===b.length&&this.newMessageCombo.setValue(a.getAt(0).get("id"));
d.getCount()===b.length&&this.replyMessageCombo.setValue(d.getAt(0).get("id"))},onGridDelSignature:function(a,b){var c=this.newMessageCombo.getStore(),d=this.replyMessageCombo.getStore();Ext.isArray(b)||(b=[b]);for(var e=0,f=b.length;e<f;e++){var g;g=c.getById(b[e].id);c.remove(g);g=d.getById(b[e].id);d.remove(g)}(b=c.getById(this.newMessageCombo.getValue()))||this.newMessageCombo.setValue(0);(b=c.getById(this.replyMessageCombo.getValue()))||this.replyMessageCombo.setValue(0)},onGridUpdateSignature:function(a,
b){var c=this.newMessageCombo.getStore(),d=this.replyMessageCombo.getStore();Ext.isArray(b)||(b=[b]);for(var e=0,f=b.length;e<f;e++){var g;g=c.getById(b[e].id);Ext.apply(g.data,b[e].data);g=d.getById(b[e].id);Ext.apply(g.data,b[e].data)}c.fireEvent("datachanged",c);d.fireEvent("datachanged",d);this.newMessageCombo.setValue(this.newMessageCombo.getValue());this.replyMessageCombo.setValue(this.replyMessageCombo.getValue())},update:function(a){this.model=a;this.doSelectSignature(undefined);var b=a.get(this.signaturesGrid.name,
true),c=[];for(var d in b)c.push(Ext.apply({},b[d],{id:d}));b=this.signaturesGrid.getStore();b.loadData(c);c=[{id:0,name:_("<None>")}].concat(c);b=this.newMessageCombo.getStore();b.loadData(c);d=a.get(this.newMessageCombo.name);b.getById(d)||(d=0);this.newMessageCombo.setValue(d);b=this.replyMessageCombo.getStore();b.loadData(c);c=a.get(this.replyMessageCombo.name);b.getById(c)||(c=0);this.replyMessageCombo.setValue(c);this.contentField.setHtmlEditor(a.get("zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor"),
false);this.mon(a,"set",this.onSettingsSet,this)},updateSettings:function(a){a.beginEdit();this.onSaveSignature();for(var b=this.signaturesGrid.getStore().getRange(),c={},d=0,e=b.length;d<e;d++){var f=b[d];c[f.get("id")]={name:f.get("name"),content:f.get("content"),isHTML:f.get("isHTML")}}a.set(this.signaturesGrid.name,c);b=this.newMessageCombo.getValue();b!==0?a.set(this.newMessageCombo.name,b):a.remove(this.newMessageCombo.name);b=this.replyMessageCombo.getValue();b!==0?a.set(this.replyMessageCombo.name,
b):a.remove(this.replyMessageCombo.name);a.endEdit()},onSettingsSet:function(a,b){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){var e=b[c];e.path==="zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor"&&this.contentField.setHtmlEditor(e.value)}},onSignatureComboSelect:function(a,b){if(this.model){var c=b.get(a.valueField);if(c===0)c=undefined;this.model.get(a.name)!==c&&this.model.set(a.name,c)}},onSignatureBeforeRowSelect:function(a,b,c,d){this.signaturesGrid.focus();if(this.hasDirtySignature()){Ext.MessageBox.show({title:_("Zarafa WebApp"),
msg:_("You have unsaved changes. Do you wish to save the changes?"),icon:Ext.MessageBox.QUESTION,fn:this.onSignatureBeforeRowSelectConfirm.createDelegate(this,[a,b,c,d],1),buttons:Ext.MessageBox.YESNOCANCEL});return false}},onSignatureBeforeRowSelectConfirm:function(a,b,c,d){if(a!=="cancel"){a==="yes"?this.onSaveSignature():this.onRejectSignature();b.selectRow(c,d)}},onSignatureSelectionChange:function(a){this.doSelectSignature(a.getSelected())},doSelectSignature:function(a){if(Ext.isEmpty(a)){delete this.selectedSignature;
this.dirtySelectedSignature=false;this.delSignatureBtn.disable();this.nameField.reset();this.nameField.disable();this.contentField.reset();this.contentField.disable();this.saveSignatureBtn.disable()}else{this.signaturesGrid.getStore();this.selectedSignature=a;this.dirtySelectedSignature=false;this.delSignatureBtn.enable();this.nameField.setValue(a.get("name"));this.nameField.enable();this.contentField.setHtmlEditor(a.get("isHTML"),false);this.contentField.setValue(a.get("content"));this.contentField.enable();
this.saveSignatureBtn.enable();this.contentField.focus()}},onAddSignature:function(){this.signaturesGrid.focus();this.hasDirtySignature()?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You have unsaved changes. Do you wish to save the changes?"),icon:Ext.MessageBox.QUESTION,fn:this.onAddSignatureConfirm.createDelegate(this),buttons:Ext.MessageBox.YESNOCANCEL}):this.doAddSignature()},onAddSignatureConfirm:function(a){if(a!=="cancel"){a==="yes"?this.onSaveSignature():this.onRejectSignature();
this.doAddSignature()}},doAddSignature:function(){var a=this.signaturesGrid.getStore(),b=new a.recordType({id:(new Date).getTime(),name:_("New signature"),content:"",isHTML:this.contentField.isHtmlEditor()});a.add(b);this.model&&this.model.set(this.signaturesGrid.name+"/"+b.get("id"),{name:b.get("name"),content:b.get("content"),isHTML:b.get("isHTML")});this.signaturesGrid.getSelectionModel().selectRecords([b]);this.doSelectSignature(b);b.set("content",this.contentField.getValue())},onDeleteSignature:function(){this.model&&
this.model.remove(this.signaturesGrid.name+"/"+this.selectedSignature.get("id"));var a=this.signaturesGrid.getStore(),b=a.indexOf(this.selectedSignature);a.remove(this.selectedSignature);delete this.selectedSignature;this.dirtySelectedSignature=false;b<a.getCount()?this.signaturesGrid.getSelectionModel().selectRow(b):this.signaturesGrid.getSelectionModel().selectLastRow()},onSaveSignature:function(){var a=this.selectedSignature;if(a){a.set(this.nameField.name,this.nameField.getValue());a.set(this.contentField.name,
this.contentField.getValue());a.set("isHTML",this.contentField.isHtmlEditor());a.commit();this.dirtySelectedSignature=false}},onRejectSignature:function(){var a=this.selectedSignature;if(a){this.nameField.setValue(a.get(this.nameField.name));this.contentField.setValue(a.get(this.contentField.name));this.dirtySelectedSignature=false}},onFieldChange:function(a,b){if(this.selectedSignature)if(this.selectedSignature.get(a.name)!==b)this.dirtySelectedSignature=true},hasDirtySignature:function(){if(this.selectedSignature){if(this.dirtySelectedSignature!==
true){this.onFieldChange(this.nameField,this.nameField.getValue());this.onFieldChange(this.contentField,this.contentField.getValue())}return this.dirtySelectedSignature}else return false}});Ext.reg("zarafa.settingssignatureswidget",Zarafa.mail.settings.SettingsSignaturesWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsOofWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Out of Office Assistant"),favorite:true,iconCls:"zarafa-settings-favorite-oof",items:[{xtype:"radiogroup",name:"zarafa/v1/contexts/mail/outofoffice/set",ref:"oofField",columns:1,hideLabel:true,items:[{xtype:"radio",name:"enableOof",inputValue:"false",boxLabel:_("I am currently in the office")},{xtype:"radio",name:"enableOof",inputValue:"true",boxLabel:_("I am currently out of the office")}],
listeners:{change:this.onRadioChange,scope:this}},{xtype:"textfield",name:"zarafa/v1/contexts/mail/outofoffice/subject",ref:"subjectField",fieldLabel:_("Subject"),emptyText:_("Out of Office"),anchor:"100%",listeners:{change:this.onFieldChange,scope:this}},{xtype:"displayfield",hideLabel:true,value:_("AutoReply only once to each sender with the following text")+":"},{xtype:"textarea",name:"zarafa/v1/contexts/mail/outofoffice/message",ref:"bodyField",hideLabel:true,emptyText:_("User is currently out of office."),
anchor:"100%",listeners:{change:this.onFieldChange,scope:this}}]});Zarafa.mail.settings.SettingsOofWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.oofField.setValue(a.get(this.oofField.name).toString());this.subjectField.setValue(a.get(this.subjectField.name));this.bodyField.setValue(a.get(this.bodyField.name))},updateSettings:function(a){var b=this.oofField.getValue().inputValue==="true",c=this.subjectField.getValue()||this.subjectField.emptyText,d=this.bodyField.getValue()||
this.bodyField.emptyText;a.beginEdit();a.set(this.oofField.name,b);a.set(this.subjectField.name,c);a.set(this.bodyField.name,d);a.endEdit()},onRadioChange:function(a,b){var c=b.inputValue==="true";this.model&&this.model.get(a.name)!==c&&this.model.set(a.name,c);this.subjectField.setDisabled(!c);this.bodyField.setDisabled(!c)},onFieldChange:function(a,b){if(this.model)this.model.set(a.name,b||a.emptyText)}});Ext.reg("zarafa.settingsoofwidget",Zarafa.mail.settings.SettingsOofWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsMailWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b={xtype:"jsonstore",autoDestroy:true,fields:["name","value"],data:[{name:_("Off"),value:Zarafa.mail.data.ViewModes.NO_PREVIEW},{name:_("Right"),value:Zarafa.mail.data.ViewModes.RIGHT_PREVIEW},{name:_("Bottom"),value:Zarafa.mail.data.ViewModes.BOTTOM_PREVIEW}]};Ext.applyIf(a,{title:_("General mail settings"),layout:"form",items:[{xtype:"combo",name:"zarafa/v1/state/contexts/mail/current_view_mode",
ref:"previewCombo",fieldLabel:_("Location preview panel"),width:200,store:b,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onPreviewSelect,scope:this}}]});Zarafa.mail.settings.SettingsMailWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.previewCombo.setValue(a.get(this.previewCombo.name))},updateSettings:function(a){a.set(this.previewCombo.name,this.previewCombo.getValue())},
onPreviewSelect:function(a,b){if(this.model){var c=b.get(a.valueField);this.model.get(a.name)!==c&&this.model.set(a.name,c)}}});Ext.reg("zarafa.settingsmailwidget",Zarafa.mail.settings.SettingsMailWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsMailCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Mail"),categoryIndex:1,iconCls:"zarafa-settings-category-mail",items:[{xtype:"zarafa.settingsmailwidget"},{xtype:"zarafa.settingscomposewidget"},{xtype:"zarafa.settingsincomingmailwidget"},{xtype:"zarafa.settingssignatureswidget"},{xtype:"zarafa.settingsoofwidget"},container.populateInsertionPoint("context.settings.category.mail",this)]});Zarafa.mail.settings.SettingsMailCategory.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.settingsmailcategory",Zarafa.mail.settings.SettingsMailCategory);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsIncomingMailWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Incoming mail"),layout:"form",items:[{xtype:"displayfield",hideLabel:true,value:_("How to respond to requests for read receipts")},{xtype:"radiogroup",name:"zarafa/v1/contexts/mail/readreceipt_handling",ref:"readReceiptGroup",columns:1,hideLabel:true,items:[{xtype:"radio",name:"receiptHandling",inputValue:"always",boxLabel:_("Always send a response")},
{xtype:"radio",name:"receiptHandling",inputValue:"never",boxLabel:_("Never send a response")},{xtype:"radio",name:"receiptHandling",inputValue:"ask",boxLabel:_("Ask me before sending a response")}],listeners:{change:this.onRadioChange,scope:this}}]});Zarafa.mail.settings.SettingsIncomingMailWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.readReceiptGroup.setValue(a.get(this.readReceiptGroup.name))},updateSettings:function(a){a.set(this.readReceiptGroup.name,this.readReceiptGroup.getValue().inputValue)},
onRadioChange:function(a,b){this.model&&this.model.get(a.name)!==b.inputValue&&this.model.set(a.name,b.inputValue)}});Ext.reg("zarafa.settingsincomingmailwidget",Zarafa.mail.settings.SettingsIncomingMailWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsComposeWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b={xtype:"jsonstore",autoDestroy:true,fields:["name","value"],data:[{name:_("HTML"),value:"html"},{name:_("Plain Text"),value:"plain"}]};Ext.applyIf(a,{title:_("Compose mail settings"),layout:"form",items:[{xtype:"combo",name:"zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor",ref:"composerCombo",fieldLabel:_("Compose mail in this format"),width:200,store:b,mode:"local",
triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onComposerSelect,scope:this}},{xtype:"checkbox",name:"zarafa/v1/contexts/mail/always_request_readreceipt",ref:"readBox",boxLabel:_("Always request a read receipt"),hideLabel:true,listeners:{check:this.onFieldChange,scope:this}}]});Zarafa.mail.settings.SettingsComposeWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.composerCombo.setValue(a.get(this.composerCombo.name)?
"html":"plain");this.readBox.setValue(a.get(this.readBox.name))},updateSettings:function(a){a.beginEdit();a.set(this.composerCombo.name,this.composerCombo.getValue()==="html");a.set(this.readBox.name,this.readBox.getValue());a.endEdit()},onComposerSelect:function(a,b){if(this.model){var c=b.get(a.valueField);this.model.get(a.name)!==c&&this.model.set(a.name,c==="html")}},onFieldChange:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)}});
Ext.reg("zarafa.settingscomposewidget",Zarafa.mail.settings.SettingsComposeWidget);Ext.namespace("Zarafa.mail.dialogs");Zarafa.mail.dialogs.MailFlagsMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{colorsOnly:false,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.mailflagsmenu",items:Zarafa.mail.dialogs.MailFlagsMenu.createMailFlagButtons(a.colorsOnly||false)});Zarafa.mail.dialogs.MailFlagsMenu.superclass.constructor.call(this,a)}});
Zarafa.mail.dialogs.MailFlagsMenu.createMailFlagSubmenu=function(a){a=Zarafa.mail.dialogs.MailFlagsMenu.createMailFlagButtons(a);return{xtype:"zarafa.flagbutton",text:_("Set Flag"),overflowText:_("Set Flag"),iconCls:a[0].iconCls,flagStatus:a[0].flagStatus,flagColor:a[0].flagColor,menu:{xtype:"zarafa.conditionalmenu",items:a}}};
Zarafa.mail.dialogs.MailFlagsMenu.createMailFlagButtons=function(a){var b=Zarafa.mail.dialogs.MailFlagsMenu.createColorMailFlagButtons();if(a==false){b.push({xtype:"menuseparator"});b.push(Zarafa.mail.dialogs.MailFlagsMenu.createStateMailFlagButtons())}return b};Zarafa.mail.dialogs.MailFlagsMenu.createColorMailFlagButtons=function(){return Zarafa.mail.dialogs.MailFlagsMenu.convertMailFlagToButton(Zarafa.mail.data.MailFlags.colors)};Zarafa.mail.dialogs.MailFlagsMenu.createStateMailFlagButtons=function(){return Zarafa.mail.dialogs.MailFlagsMenu.convertMailFlagToButton(Zarafa.mail.data.MailFlags.state)};
Zarafa.mail.dialogs.MailFlagsMenu.convertMailFlagToButton=function(a){var b=[];Ext.each(a,function(c){b.push({xtype:"zarafa.flagbutton",text:c.name,iconCls:c.iconCls,flagStatus:c.flagStatus,flagColor:c.flagColor})},this);return b};Ext.reg("zarafa.mailflagsmenu",Zarafa.mail.dialogs.MailFlagsMenu);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.RootFolderNode=Ext.extend(Zarafa.hierarchy.ui.FolderNode,{extendedDisplayName:false,constructor:function(a){a=a||{};var b="zarafa-tree-root-container",c="zarafa-tree-root-node";if(a.folder&&a.folder.isIPMSubTree()){b+=" zarafa-tree-ipm-subtree-container";c+=" zarafa-tree-ipm-subtree-node"}Ext.applyIf(a,{containerCls:b,cls:c,allowDrag:false,draggable:false});Zarafa.hierarchy.ui.RootFolderNode.superclass.constructor.call(this,a);this.on("beforeclick",this.onBeforeClick,this)},onBeforeClick:function(a){if((a=
a.getFolder())&&a.isIPMSubTree())return a.getMAPIStore().isDefaultStore()},getTextFromFolder:function(a){if(this.attributes.extendedDisplayName){var b=a.getMAPIStore();b.getSubtreeFolder();return a.isIPMSubTree()?a.getDisplayName():b.isPublicStore()?String.format(pgettext("hierarchy.tree","{0} in {1}"),a.getDisplayName(),b.get("display_name")):b.isSharedStore()?String.format(pgettext("hierarchy.tree","{0} of {1}"),a.getDisplayName(),b.get("mailbox_owner_name")):a.getDisplayName()}else return Zarafa.hierarchy.ui.RootFolderNode.superclass.getTextFromFolder.call(this,
a)}});Ext.tree.TreePanel.nodeTypes.rootfolder=Zarafa.hierarchy.ui.RootFolderNode;Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyTreePanel=Ext.extend(Zarafa.hierarchy.ui.Tree,{enableItemDrop:false,itemDropZone:undefined,itemDropConfig:undefined,bbarConfig:undefined,showAllFoldersCheckbox:undefined,showAllFoldersDefaultValue:false,constructor:function(a){a=a||{};var b=Ext.isDefined(a.showAllFoldersDefaultValue)?a.showAllFoldersDefaultValue:this.showAllFoldersDefaultValue;Ext.applyIf(a,{xtype:"zarafa.hierarchytreepanel",baseCls:"zarafa-hierarchy-treepanel",flex:1,minHeight:100,stateful:true,tbar:{items:["->",
{xtype:"checkbox",cls:"zarafa-hierarchy-treepanel-showallfolders",ref:"../showAllFoldersCheckbox",plugins:["zarafa.fieldlabeler"],fieldLabel:_("Show all folders"),labelSeparator:" ",checked:b,listeners:{check:this.onCheckShowAllFoldersCheckbox,scope:this}}]},loadMask:true,treeSorter:true,trackMouseOver:true,dragConfig:{ddGroup:"dd.mapifolder"},dropConfig:{ddGroup:"dd.mapifolder",expandDelay:250,allowParentInsert:true},enableItemDrop:true,itemDropConfig:{ddGroup:"dd.mapiitem"},ddAutoScrollContainer:true});
if(!Ext.isDefined(a.bbar)){a.bbarConfig=a.bbarConfig||{};a.bbar=Ext.applyIf(a.bbarConfig,{xtype:"zarafa.hierarchytreebottombar"})}this.addEvents("beforeitemdrop","itemdrop");Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.constructor.call(this,a)},initEvents:function(){this.mon(this,"contextmenu",this.onTreeNodeContextMenu,this);this.mon(this,"click",this.onFolderClicked,this);this.mon(this.store,"remove",this.onStoreRemove,this);this.mon(this.store,"removeFolder",this.onFolderRemove,this);this.mon(container,
"folderselect",this.onFolderSelect,this);var a=this.findParentByType("zarafa.navigationpanel");a&&this.mon(a,"toggleshowallfolders",this.onToggleShowAllFolders,this);this.mon(this.loader,"load",this.onHierarchyLoaderLoad,this);if(this.stateful===true){this.mon(this,"expandnode",this.saveFolderState,this,{buffer:5});this.mon(this,"collapsenode",this.saveFolderState,this,{buffer:5})}if(this.enableDD||this.enableDrop){if(!this.dropZone)this.dropZone=new Zarafa.hierarchy.ui.HierarchyFolderDropZone(this,
this.dropConfig||{ddGroup:this.ddGroup||"TreeDD",appendOnly:this.ddAppendOnly===true});this.mon(this,"nodedrop",this.onNodeDrop,this)}if(this.enableItemDrop){if(!this.itemDropZone)this.itemDropZone=new Zarafa.hierarchy.ui.HierarchyItemDropZone(this,this.itemDropConfig||{ddGroup:this.ddGroup||"TreeDD"});this.mon(this,"itemdrop",this.onItemDrop,this)}Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.initEvents.call(this)},onNodeDrop:function(a){if(Ext.isDefined(a.dropNode)){var b=a.target;switch(a.point){case "above":case "below":b=
a.target.parentNode;break;case "append":default:break}var c=a.dropNode.getFolder();b=b.getFolder();a.rawEvent.ctrlKey?c.copyTo(b):c.moveTo(b);c.save()}},onItemDrop:function(a){if(!Ext.isEmpty(a.dropItem)){var b=a.target,c=Ext.isArray(a.dropItem)?a.dropItem:[a.dropItem];b=b.getFolder();var d=c[0].getStore();if(a.rawEvent.ctrlKey){a=0;for(var e=c.length;a<e;a++)c[a].copyTo(b)}else{a=0;for(e=c.length;a<e;a++)c[a].moveTo(b)}d.save(c)}},onStoreRemove:function(a,b){var c=b.getSubStore("folders"),d=container.getCurrentContext().getModel();
d&&c.each(function(e){d.removeFolder(e)})},onFolderRemove:function(a,b,c){(a=container.getCurrentContext().getModel())&&a.removeFolder(c)},onFolderSelect:function(a){if(Ext.isArray(a))a=a[0];a&&this.selectFolderInTree(a)},onHierarchyLoaderLoad:function(){var a=container.getCurrentContext().getModel();a&&this.onFolderSelect(a.getDefaultFolder())},onTreeNodeContextMenu:function(a,b){Zarafa.common.Actions.openContextMenu(a.getFolder(),b.getXY(),{contextNode:a})},onFolderClicked:function(a){a=a.getFolder();
Zarafa.hierarchy.Actions.openFolder(a)},getTreeEditor:function(){if(!this.treeEditor)this.treeEditor=new Zarafa.hierarchy.ui.TreeEditor(this);return this.treeEditor},startEditingNode:function(a){this.getTreeEditor().startEditingNode(a)},isFolderOpened:function(a){var b;if(this.stateful===true){var c=container.getHierarchyStore().getState(a,"tree");if(c)b=c.is_open}Ext.isDefined(b)||(b=Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.isFolderOpened.call(this,a));return b},saveFolderState:function(a){if(this.stateful===
true&&!a.isRoot){var b=a.getFolder();container.getHierarchyStore().applyState(b,"tree",{is_open:a.expanded})}},onCheckShowAllFoldersCheckbox:function(a,b){container.getNavigationBar().setShowFolderList(b)},onToggleShowAllFolders:function(a){this.suspendEvents(false);this.showAllFoldersCheckbox.setValue(a);this.resumeEvents()},beforeDestroy:function(){this.rendered&&Ext.destroy(this.itemDropZone);Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.beforeDestroy.apply(this,arguments)}});
Ext.reg("zarafa.hierarchytreepanel",Zarafa.hierarchy.ui.HierarchyTreePanel);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyItemDropZone=Ext.extend(Zarafa.hierarchy.ui.HierarchyTreeDropZone,{onNodeDrop:function(a,b,c,d){var e=this.getDropPoint(c,a,b),f=a.node;f.ui.startDrop();if(!this.isValidDropPoint(a,e,b,c,d)){f.ui.endDrop();return false}return this.processDrop(f,d,e,b,c,d.selections)},onContainerDrop:function(a,b,c){if(this.allowContainerDrop&&this.isValidDropPoint({ddel:this.tree.getRootNode().ui.elNode,node:this.tree.getRootNode()},"append",a,b,c)){var d=this.tree.getRootNode();d.ui.startDrop();
return this.processDrop(d,c,"append",a,b,c.selections)}return false},processDrop:function(a,b,c,d,e,f){b={tree:this.tree,target:a,data:b,point:c,source:d,rawEvent:e,dropItem:f,cancel:Ext.isEmpty(f),dropStatus:false};if(this.tree.fireEvent("beforeitemdrop",b)===false||b.cancel===true||Ext.isEmpty(b.dropItem)){a.ui.endDrop();return b.dropStatus}this.completeDrop(b);return true},completeDrop:function(a){a.target.ui.endDrop();this.tree.fireEvent("itemdrop",a)},isValidDropPoint:function(a,b,c,d,e){b=false;
if(a.node&&!Ext.isEmpty(e.selections)){a=a.node.getFolder();e=e.selections[0];if(!a.isIPMSubTree()){b=a.get("entryid");c=e.get("parent_entryid");b=!Zarafa.core.EntryId.compareEntryIds(b,c);if(b===true){b=a.isSpecialFolder("wastebasket");if(b!==true){a=a.get("container_class");e=e.get("message_class");b=Zarafa.core.MessageClass.isContainerClassCompatible(e,a)}}}}return b},getDropPoint:function(){return"append"}});Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyFolderDropZone=Ext.extend(Zarafa.hierarchy.ui.HierarchyTreeDropZone,{constructor:function(a,b){Zarafa.hierarchy.ui.HierarchyFolderDropZone.superclass.constructor.call(this,a,b);this.tree&&this.tree.on("beforenodedrop",this.onBeforeNodeDrop,this)},onBeforeNodeDrop:function(a){if(a.source===this){var b=a.dropNode;if(Ext.isDefined(b)){var c=a.target;switch(a.point){case "above":case "below":c=c.parentNode;break;case "append":default:break}if(b.parentNode===c)return false}}},
getDropPoint:function(a,b){var c=b.node;if(c.isRoot)return c.allowChildren!==false?"append":false;var d=b.ddel,e=Ext.lib.Dom.getY(d);d=e+d.offsetHeight;var f=Ext.lib.Event.getPageY(a),g=c.allowChildren===false;if(this.appendOnly||c.parentNode.allowChildren===false)return g?false:"append";var h=false;this.allowParentInsert||(h=c.hasChildNodes()&&c.isExpanded());c=(d-e)/(g?2:3);return f>=e&&f<e+c?"above":!h&&(g||f>=d-c&&f<=d)?"below":"append"}});Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.ContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{contextNode:undefined,contextTree:undefined,constructor:function(a){a=a||{};if(a.contextNode)a.contextTree=a.contextNode.getOwnerTree();Ext.applyIf(a,{items:[this.createContextMenuItems()],defaults:{xtype:"zarafa.conditionalitem",scope:this}});Zarafa.hierarchy.ui.ContextMenu.superclass.constructor.call(this,a)},createContextMenuItems:function(){return[{text:_("Open"),iconCls:"icon_open",handler:this.onContextItemOpen,
beforeShow:function(a,b){!(b.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||b.isIPMSubTree()&&!b.getMAPIStore().isDefaultStore()?a.setDisabled(true):a.setDisabled(false)}},{xtype:"menuseparator"},{text:_("Copy/Move Folder"),iconCls:"icon_copy",handler:this.onContextCopyMoveFolder,beforeShow:function(a,b){!(b.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||b.isIPMSubTree()||b.isDefaultFolder()?a.setDisabled(true):a.setDisabled(false)}},{text:_("Rename Folder"),iconCls:"icon_folder_rename",
handler:this.onContextItemRenameFolder,beforeShow:function(a,b){!(b.get("access")&Zarafa.core.mapi.Access.ACCESS_MODIFY)||b.isIPMSubTree()||b.isDefaultFolder()||!this.contextTree||!this.contextNode?a.setDisabled(true):a.setDisabled(false)}},{text:_("New Folder"),iconCls:"icon_createFolderColor",handler:this.onContextItemNewFolder,beforeShow:function(a,b){b.get("access")&Zarafa.core.mapi.Access.ACCESS_MODIFY?a.setDisabled(false):a.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Mark All Messages Read"),
iconCls:"icon_mark_all_read",handler:this.onContextItemReadFlags,beforeShow:function(a,b){!(b.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||b.isIPMSubTree()?a.setDisabled(true):a.setDisabled(false)}},{xtype:"menuseparator"},{text:_("Delete Folder"),iconCls:"icon_folder_delete",handler:this.onContextItemDeleteFolder,beforeShow:function(a,b){!(b.get("access")&Zarafa.core.mapi.Access.ACCESS_DELETE)||b.isIPMSubTree()||b.isDefaultFolder()?a.setDisabled(true):a.setDisabled(false)}},{text:_("Empty folder"),
iconCls:"icon_empty_trash",handler:this.onContextItemEmptyFolder,beforeShow:function(a,b){b.get("access")&Zarafa.core.mapi.Access.ACCESS_READ&&b.isSpecialFolder("wastebasket")||b.isSpecialFolder("junk")?a.setDisabled(false):a.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Add to favorites folder"),iconCls:"icon_folder_add_favorite",beforeShow:function(a,b){b.get("access");a.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Close store"),iconCls:"icon_store_close",handler:this.onContextItemCloseStore,
scope:this,beforeShow:function(a,b){b.isIPMSubTree()&&b.getMAPIStore().isSharedStore()?a.setDisabled(false):a.setDisabled(true)}},{text:_("Close folder"),iconCls:"icon_folder_close",handler:this.onContextItemCloseFolder,scope:this,beforeShow:function(a,b){!b.isIPMSubTree()&&b.isSharedFolder()?a.setDisabled(false):a.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Reload"),iconCls:"icon-reload",handler:this.onContextItemReload,scope:this,beforeShow:function(a,b){b.isOwnRoot()?a.setDisabled(false):
a.setDisabled(true)}},{text:_("Properties"),handler:this.onContextItemProperties,iconCls:"icon_openMessageOptions",beforeShow:function(a,b){b.get("access")?a.setDisabled(false):a.setDisabled(true)}}]},onContextItemOpen:function(){this.contextTree&&this.contextTree.selectFolderInTree(this.records);Zarafa.hierarchy.Actions.openFolder(this.records)},onContextCopyMoveFolder:function(){Zarafa.common.Actions.openCopyMoveDialog(this.records)},onContextItemRenameFolder:function(){this.contextTree.startEditingNode(this.contextNode)},
onContextItemNewFolder:function(){Zarafa.hierarchy.Actions.openCreateFolderDialog(this.records)},onContextItemDeleteFolder:function(){var a=this.records.isInDeletedItems()||this.records.getMAPIStore().isPublicStore(),b=a?String.format(_('Are you sure you want to permanently delete all the items and subfolders in the "{0}" folder?'),Ext.util.Format.htmlEncode(this.records.getDisplayName())):String.format(_('Are you sure you want to delete the folder "{0}" and move all of its contents into the Deleted Items folder?'),
Ext.util.Format.htmlEncode(this.records.getDisplayName()));Ext.MessageBox.confirm(_("Zarafa WebApp"),b,function(c){if(c=="yes"){c=this.records.getStore();a?c.remove(this.records):this.records.moveTo(container.getHierarchyStore().getDefaultFolder("wastebasket"));c.save(this.records)}},this)},onContextItemEmptyFolder:function(){Ext.MessageBox.confirm(_("Zarafa WebApp"),String.format(_("Are you sure you want to empty {0}?"),Ext.util.Format.htmlEncode(this.records.getDisplayName())),function(a){if(a==
"yes"){this.records.emptyFolder();this.records.save()}},this)},onContextItemReadFlags:function(){this.records.seadReadFlags();this.records.save()},onContextItemProperties:function(){Zarafa.hierarchy.Actions.openFolderPropertiesDialog(this.records)},onContextItemCloseStore:function(){var a=container.getHierarchyStore(),b=this.records.getMAPIStore();a.remove(b);a.save(b)},onContextItemCloseFolder:function(){var a=this.records.getMAPIStore().getFolderStore();a.remove(this.records);a.save(this.records)},
onContextItemReload:function(){container.getHierarchyStore().reload()}});Ext.reg("zarafa.hierarchycontextmenu",Zarafa.hierarchy.ui.ContextMenu);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.CreateFolderDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{parentFolder:undefined,preferredContainerClass:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.createfolder",layout:"fit",defaultTitle:_("Create New Folder"),alwaysUseDefaultTitle:true,allowWrite:true,ignoreUpdates:false,useShadowStore:true,width:330,height:380,items:[{xtype:"zarafa.createfolderpanel",parentFolder:a.parentFolder,preferredContainerClass:a.preferredContainerClass}]});Zarafa.hierarchy.dialogs.CreateFolderDialog.superclass.constructor.call(this,
a)},onUpdateRecord:function(a,b){Zarafa.hierarchy.dialogs.CreateFolderDialog.superclass.onUpdateRecord.apply(this,arguments);if(b==Ext.data.Record.COMMIT){this.close();return false}}});Zarafa.core.ui.Dialog.register(Zarafa.hierarchy.dialogs.CreateFolderDialog,"zarafa.createfolder");Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.JsonPermissionsWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getSubStore("permissions");a={};if(!Ext.isDefined(b))return a;var c=b.getModifiedRecords();b=b.getRemovedRecords();if(c.length>0||b.length>0){a.permissions={};for(var d=0;d<c.length;d++){var e=c[d],f=e.data;if(e.phantom){if(!Ext.isDefined(a.permissions.add))a.permissions.add=[];a.permissions.add.push(f)}else{if(!Ext.isDefined(a.permissions.modify))a.permissions.modify=[];a.permissions.modify.push(f)}}for(d=
0;d<b.length;d++){e=b[d];f=e.data;if(!Ext.isDefined(a.permissions.remove))a.permissions.remove=[];a.permissions.remove.push(f)}}return a}});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyState=Ext.extend(Zarafa.core.data.StatefulObservable,{constructor:function(a){a=a||{};Ext.applyIf(a,{stateful:true,statefulName:"folders"});Zarafa.hierarchy.data.HierarchyState.superclass.constructor.call(this,a)},getStateNameForFolder:function(a,b){return a?"folders/"+a.get("entryid")+"/"+b:"folders/none/"+b},applyStateForFolder:function(a,b,c){this.statefulName=this.getStateNameForFolder(a,b);(a=this.getStateId())&&Ext.state.Manager.set(a,c)},getStateForFolder:function(a,
b){this.statefulName=this.getStateNameForFolder(a,b);var c=this.getStateId();if(c)return Ext.apply({},Ext.state.Manager.get(c))}});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};var b=Zarafa.core.ModuleNames.getModule("hierarchy");b&&Ext.applyIf(a,{listModuleName:b.list,itemModuleName:b.item});Zarafa.hierarchy.data.HierarchyProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.hierarchy.data.HierarchyResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactmainpanel",layout:"zarafa.collapsible",items:[{xtype:"zarafa.searchbar",searchFields:Zarafa.contact.data.SearchFields,context:a.context},{xtype:"zarafa.switchviewcontentcontainer",ref:"viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.contextmainpaneltoolbar",defaultTitle:_("Contacts"),paging:container.populateInsertionPoint("context.contact.toolbar.paging",
this),items:container.populateInsertionPoint("context.contact.toolbar.item",this),context:a.context}});Zarafa.contact.ui.ContactMainPanel.superclass.constructor.call(this,a)},initViews:function(a){var b=[{xtype:"zarafa.contactgridview",id:"contact-gridview",context:a},{xtype:"zarafa.contactcardpanel",id:"contact-cardview",context:a}];a=container.populateInsertionPoint("context.contact.views",this,a);Ext.each(a,function(c){b.push(c)},this);return b},initEvents:function(){if(Ext.isDefined(this.context)){this.mon(this.context,
"viewchange",this.onViewChange,this);this.onViewChange(this.context,this.context.getCurrentView())}},onViewChange:function(a,b){switch(b){case Zarafa.contact.data.Views.ICON:this.viewPanel.switchView("contact-cardview");break;case Zarafa.contact.data.Views.LIST:case Zarafa.contact.data.Views.SEARCH:this.viewPanel.switchView("contact-gridview");break}}});Ext.reg("zarafa.contactmainpanel",Zarafa.contact.ui.ContactMainPanel);Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactGridView=Ext.extend(Zarafa.common.ui.grid.GridPanel,{context:undefined,model:undefined,store:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);Ext.applyIf(a,{xtype:"zarafa.contactgridview",border:false,stateful:true,statefulRelativeDimensions:false,autoExpandColumn:"fileas",loadMask:this.initLoadMask(),
viewConfig:this.initViewConfig(),selModel:this.initSelectionModel(),colModel:this.initColumnModel(),enableDragDrop:true,ddGroup:"dd.mapiitem",keys:{key:Ext.EventObject.DELETE,handler:this.onKeyDelete,scope:this}});Zarafa.contact.ui.ContactGridView.superclass.constructor.call(this,a)},initViewConfig:function(){return{}},initLoadMask:function(){return{msg:_("Loading contacts")+"..."}},initColumnModel:function(){return new Zarafa.contact.ui.ContactGridColumnModel},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false,
listeners:{scope:this,selectionchange:this.onSelectionChange}})},getMainPanel:function(){return this.ownerCt},initEvents:function(){Zarafa.contact.ui.ContactGridView.superclass.initEvents.apply(this,arguments);this.on("rowcontextmenu",this.onRowContextMenu,this);this.on("rowdblclick",this.onRowDblClick,this)},onRowContextMenu:function(a,b,c){a=this.getSelectionModel();a.isSelected(b)||a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY())},onRowDblClick:function(a){Zarafa.contact.Actions.openDialog(a.getSelectionModel().getSelections())},
onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},onKeyDelete:function(){var a=this.getSelectionModel().getSelections();Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)}});Ext.reg("zarafa.contactgridview",Zarafa.contact.ui.ContactGridView);Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true,width:150}});Ext.apply(this,a);Zarafa.contact.ui.ContactGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:25,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"fileas",id:"fileas",
header:_("File As"),tooltip:_("Sort by: File As"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"display_name",header:_("Full Name"),tooltip:_("Sort by: Full Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"email_address_1",header:_("Email"),hidden:true,tooltip:_("Sort by: Email Address 1"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"email_address_2",header:_("Email 2"),hidden:true,tooltip:_("Sort by: Email Address 2"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"email_address_3",
header:_("Email 3"),hidden:true,tooltip:_("Sort by: Email Address 3"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"home_telephone_number",header:_("Home Phone"),tooltip:_("Sort by: Home Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"cellular_telephone_number",header:_("Mobile Phone"),tooltip:_("Sort by: Mobile Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"categories",header:_("Categories"),tooltip:_("Sort by: Categories"),renderer:Zarafa.common.ui.grid.Renderers.text},{dataIndex:"business_telephone_number",
header:_("Business Phone"),tooltip:_("Sort by: Business Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"business_fax_number",header:_("Business Fax"),tooltip:_("Sort by: Business Fax"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"company_name",header:_("Company Name"),tooltip:_("Sort by: Company Name"),hidden:true,renderer:Ext.util.Format.htmlEncode},{dataIndex:"title",header:_("Job Title"),tooltip:_("Sort by: Job Title"),hidden:true,renderer:Ext.util.Format.htmlEncode},{dataIndex:"department_name",
header:_("Department Name"),hidden:true,tooltip:_("Sort by: Department Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"office_location",header:_("Office Location"),hidden:true,tooltip:_("Sort by: Office Location"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"profession",header:_("Profession"),hidden:true,tooltip:_("Sort by: Profession"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"manager_name",header:_("Manager Name"),hidden:true,tooltip:_("Sort by: Manager Name"),renderer:Ext.util.Format.htmlEncode},
{dataIndex:"assistant",header:_("Assistant's Name"),hidden:true,tooltip:_("Sort by: Assistant's Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"nickname",header:_("Nickname"),hidden:true,tooltip:_("Sort by: Nickname"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"spouse_name",header:_("Spouse/Partner"),hidden:true,tooltip:_("Sort by: Spouse/Partner Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"birthday",header:_("Birthday"),hidden:true,tooltip:_("Sort by: Birthday"),renderer:Zarafa.common.ui.grid.Renderers.date},
{dataIndex:"wedding_anniversary",header:_("Anniversary"),hidden:true,tooltip:_("Sort by: Anniversary"),renderer:Zarafa.common.ui.grid.Renderers.date},{dataIndex:"business_address",header:_("Business Address"),hidden:true,tooltip:_("Sort by: Business Address"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"home_address",header:_("Home Address"),hidden:true,tooltip:_("Sort by: Home Address"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"other_address",header:_("Other Address"),hidden:true,tooltip:_("Sort by: Office Address"),
renderer:Ext.util.Format.htmlEncode},{dataIndex:"mailing_address",header:_("Mailing Address"),hidden:true,tooltip:_("Sort by: Mailing Address"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"im",header:_("IM Address"),hidden:true,tooltip:_("Sort by: IM Address"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"webpage",header:_("Webpage"),hidden:true,tooltip:_("Sort by: Webpage"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"assistant_telephone_number",header:_("Assistant's Phone"),hidden:true,
tooltip:_("Sort by: Assistant's Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"business2_telephone_number",header:_("Business Phone 2"),hidden:true,tooltip:_("Sort by: Business Phone 2"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"callback_telephone_number",header:_("Callback Phone"),hidden:true,tooltip:_("Sort by: Callback"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"car_telephone_number",header:_("Car Phone"),hidden:true,tooltip:_("Sort by: Car Phone"),renderer:Ext.util.Format.htmlEncode},
{dataIndex:"company_telephone_number",header:_("Company Phone"),hidden:true,tooltip:_("Sort by: Company Main Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"home2_telephone_number",header:_("Home Phone 2"),hidden:true,tooltip:_("Sort by: Home Phone 2"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"home_fax_number",header:_("Home Fax"),hidden:true,tooltip:_("Sort by: Home Fax"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"isdn_number",header:_("ISDN"),hidden:true,tooltip:_("Sort by: ISDN"),
renderer:Ext.util.Format.htmlEncode},{dataIndex:"other_telephone_number",header:_("Other Phone"),hidden:true,tooltip:_("Sort by: Other Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"radio_telephone_number",header:_("Radio Phone"),hidden:true,tooltip:_("Sort by: Radio Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"ttytdd_telephone_number",header:_("TTY/TDD Phone"),hidden:true,tooltip:_("Sort by: TTY/TDD Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"telex_telephone_number",
header:_("Telex"),hidden:true,tooltip:_("Sort by: Telex Phone"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"pager_telephone_number",header:_("Pager"),hidden:true,tooltip:_("Sort by: Pager"),renderer:Ext.util.Format.htmlEncode}]}});Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.contact.contextmenu.actions",this),{xtype:"menuseparator"},container.populateInsertionPoint("context.contact.contextmenu.options",this)],defaults:{xtype:"zarafa.conditionalitem",hideOnDisabled:false}});Zarafa.contact.ui.ContactContextMenu.superclass.constructor.call(this,
a)},createContextActionItems:function(){return[{text:_("Open"),iconCls:"icon_open",scope:this,handler:this.onContextItemOpen,singleSelectOnly:true},{text:_("Print"),iconCls:"icon_print",scope:this,handler:this.onContextItemPrint,singleSelectOnly:true},{xtype:"menuseparator"},{text:_("Email message"),iconCls:"icon_sendEmailFromContact",scope:this,handler:this.onContextItemEmail,beforeShow:function(a,b){for(var c=false,d=0,e=b.length;d<e;d++){var f=b[d];if(f.isMessageClass("IPM.Contact",true)&&f.hasEmailAddress()){c=
true;break}}a.setVisible(c)}},{text:_("Categories"),iconCls:"icon_categories",scope:this,handler:this.onContextItemCategories,singleSelectOnly:true},{xtype:"menuseparator"},{text:_("Delete"),iconCls:"icon_delete",scope:this,handler:this.onContextItemDelete}]},onContextItemOpen:function(){Zarafa.contact.Actions.openDialog(this.records)},onContextItemPrint:function(){Zarafa.common.Actions.openPrintDialog(this.records)},onContextItemEmail:function(){Zarafa.contact.Actions.openEmailDialog(this.records)},
onContextItemCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.records,true)},onContextItemDelete:function(){var a;Ext.each(this.records,function(b){a=b.store;a.remove(b)});a.save(this.records)}});Ext.reg("zarafa.contactcontextmenu",Zarafa.contact.ui.ContactContextMenu);Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactCardView=Ext.extend(Zarafa.common.ui.DraggableDataView,{context:undefined,model:undefined,store:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.icondragselectorplugin");Ext.apply(this,a,{xtype:"zarafa.contactcardview",border:false,
loadingText:_("Loading contacts")+"...",deferEmptyText:false,emptyText:'<div class="emptytext">'+_("There are no items to show in this view")+"</div>",tpl:this.initTemplate(),itemSelector:"div.zarafa-contact-cardview-card",multiSelect:true,selectedClass:"zarafa-contact-cardview-selected",enableDrag:true,ddGroup:"dd.mapiitem"});Zarafa.contact.ui.ContactCardView.superclass.constructor.call(this,a);this.initEvents()},initEvents:function(){this.on("dblclick",this.onNodeDblClick,this);this.on("contextmenu",
this.onNodeContextMenu,this);this.on("selectionchange",this.onSelectionChange,this)},onNodeContextMenu:function(a,b,c,d){a.isSelected(c)||a.select(c);Zarafa.common.Actions.openContextMenu(a.getSelectedRecords(),d.getXY())},onNodeDblClick:function(a){Zarafa.contact.Actions.openDialog(a.getSelectedRecords())},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelectedRecords())},initTemplate:function(){var a=['<div class="zarafa-contact-cardview">','<tpl for=".">','<div class="zarafa-contact-cardview-card">',
'<div id="{entryid}" class="x-panel">','<div class="x-panel-tl">','<div class="x-panel-tr">','<div class="x-panel-tc">','<div class="x-panel-header">','<span class="x-panel-header-text">',"{fileas:htmlEncodeUndef}","</span>","</div>","</div>","</div>","</div>",'<div class="x-panel-bwrap">','<div class="x-panel-body zarafa-card-body">',"<p><tpl>{message_class:this.getIcon}</tpl></p>","<div>",'<p class="zarafa-contact-cardview-card-title">{display_name:htmlEncode}</p>',"<p><tpl if=\"values.message_class=='IPM.DistList'\">"+
_("Group")+"</tpl></p>","<p>{company_name:htmlEncodeUndef}</p>","<p>{title:htmlEncodeUndef}</p>","<p>{department_name:htmlEncodeUndef}</p>","<table>",'<tpl if="!Ext.isEmpty(values.business_telephone_number)"><tr><td class="contact-card-label">'+_("Work")+":</td><td>{business_telephone_number:htmlEncode}</td></tr></tpl>",'<tpl if="!Ext.isEmpty(values.business2_telephone_number)"><tr><td class="contact-card-label">'+_("Work")+":</td><td>{business2_telephone_number:htmlEncode}</td></tr></tpl>",'<tpl if="!Ext.isEmpty(values.primary_telephone_number)"><tr><td class="contact-card-label">'+
_("Primary")+":</td><td>{primary_telephone_number:htmlEncode}</td></tr></tpl>",'<tpl if="!Ext.isEmpty(values.cellular_telephone_number)"><tr><td class="contact-card-label">'+_("Mobile")+":</td><td>{cellular_telephone_number:htmlEncode}</td></tr></tpl>",'<tpl if="!Ext.isEmpty(values.home_telephone_number)"><tr><td class="contact-card-label">'+_("Home")+":</td><td>{home_telephone_number:htmlEncode}</td></tr></tpl>","</table>","</div>","</div>","</div>","</div>","</div>","</tpl>","</div>"];return new Ext.XTemplate(a.join(""),
{compiled:true,getIcon:function(b){return b=="IPM.DistList"?'<div class="zarafa-contact-cardview-distlist-card"></div>':'<div class="zarafa-contact-cardview-contact-card"></div>'}})}});Ext.reg("zarafa.contactcardview",Zarafa.contact.ui.ContactCardView);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistMemberGridColumnModel=Ext.extend(Ext.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true}});Zarafa.contact.dialogs.DistlistMemberGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:25,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"display_name",id:"display_name",
header:_("Name"),tooltip:_("Sort by: Name"),renderer:Zarafa.common.ui.grid.Renderers.text},{dataIndex:"email_address",header:_("E-mail Address"),tooltip:_("Sort by: Email Address"),width:350,renderer:Zarafa.common.ui.grid.Renderers.text}]}});Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistExternalMemberDialog=Ext.extend(Zarafa.core.ui.Dialog,{parentRecord:undefined,record:undefined,formPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("New e-mail address"),layout:"fit",items:this.createFormItems()});Zarafa.contact.dialogs.DistlistExternalMemberDialog.superclass.constructor.call(this,a);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})},createFormItems:function(){return[{xtype:"form",layout:"form",border:false,
ref:"formPanel",width:350,height:150,items:[{xtype:"textfield",fieldLabel:_("Name"),name:"display_name",allowBlank:false,blankText:_("This field is required"),anchor:"100%"},{xtype:"textfield",fieldLabel:_("E-mail address"),name:"email_address",anchor:"100%",allowBlank:false,blankText:_("This field is required"),vtype:"email",vtypeText:_("Please input a valid email address!")}],buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]},onAfterFirstLayout:function(){this.record&&
this.formPanel.getForm().loadRecord(this.record)},onOk:function(){var a=this.formPanel.getForm();if(!a.isValid())return false;if(this.record)a.updateRecord(this.record);else{var b=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER);a.updateRecord(b);this.parentRecord.getMemberStore().add(b)}this.close()},onCancel:function(){this.close()}});Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.DistlistExternalMemberDialog,"zarafa.distlistexternalmemberdialog");
Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.dialogs.ContactGeneralTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{labelWidth:140});Ext.applyIf(a,{xtype:"zarafa.contactgeneraltab",title:_("General"),border:false,defaults:{columnWidth:0.5,border:false,xtype:"fieldset"},items:[this.createNameFieldset(a),this.createPhotoFieldset(a),this.createPhoneFieldset(a),this.createEmailFieldset(a),this.createAddressFieldset(a),
this.createAdditionalFieldset(a),this.createAttachmentFieldset(a)]});Zarafa.contact.dialogs.ContactGeneralTab.superclass.constructor.call(this,a)},createNameFieldset:function(a){return{title:_("Name"),defaultType:"zarafa.compositefield",defaults:{anchor:"100%"},items:[{hideLabel:true,items:[{xtype:"button",width:a.labelWidth,text:_("Full Name")+":",name:"message_label_displayname",listeners:{scope:this,click:function(){this.showDetailedNameDialog()}}},{xtype:"textfield",flex:1,name:"message_displayname",
listeners:{scope:this,change:this.onPropertyChange},property:"display_name"}]},{xtype:"textfield",flex:1,name:"message_company",fieldLabel:_("Company"),listeners:{scope:this,change:this.onPropertyChange},property:"company_name"},{xtype:"textfield",flex:1,name:"message_title",fieldLabel:_("Job Title"),listeners:{scope:this,change:this.onPropertyChange},property:"title"},{xtype:"combo",flex:1,name:"message_fileas",fieldLabel:_("File as"),ref:"../fileAsField",editable:false,mode:"local",triggerAction:"all",
lazyInit:false,store:{xtype:"arraystore",fields:["displayText"],data:[]},displayField:"displayText",valueField:"displayText",listeners:{scope:this,change:this.onPropertyChange},property:"fileas"}]}},createPhotoFieldset:function(){return{title:_("Photo"),layout:{type:"hbox",pack:"start"},items:[{xtype:"box",height:100,width:100,autoEl:{tag:"img"},ref:"../contactPhotoBox"},{xtype:"button",text:_("Add Contact Photo"),handler:this.showAttachmentsDialog,scope:this}]}},createPhoneFieldset:function(a){return{title:_("Phone Numbers"),
defaultType:"zarafa.compositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{items:[{xtype:"splitbutton",width:a.labelWidth,text:_("Business")+":",name:"message_label_phonenumber_1",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_1","business_telephone_number")},{xtype:"textfield",flex:1,name:"message_phonenumber_1",listeners:{scope:this,change:this.onPropertyChange},property:"business_telephone_number"}]},{items:[{xtype:"splitbutton",width:a.labelWidth,
text:_("Home")+":",name:"message_label_phonenumber_2",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_2","home_telephone_number")},{xtype:"textfield",flex:1,name:"message_phonenumber_2",listeners:{scope:this,change:this.onPropertyChange},property:"home_telephone_number"}]},{items:[{xtype:"splitbutton",width:a.labelWidth,text:_("Business Fax")+":",name:"message_label_phonenumber_3",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_3",
"business_fax_number")},{xtype:"textfield",flex:1,name:"message_phonenumber_3",listeners:{scope:this,change:this.onPropertyChange},property:"business_fax_number"}]},{items:[{xtype:"splitbutton",width:a.labelWidth,text:_("Mobile")+":",name:"message_label_phonenumber_4",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_4","cellular_telephone_number")},{xtype:"textfield",flex:1,name:"message_phonenumber_4",listeners:{scope:this,change:this.onPropertyChange},
property:"cellular_telephone_number"}]}]}},createEmailFieldset:function(a){return{title:_("Email"),defaultType:"textfield",defaults:{anchor:"100%"},items:[{xtype:"zarafa.compositefield",hideLabel:true,items:[{xtype:"splitbutton",width:a.labelWidth,text:_("Email")+":",name:"message_label_email_address",handler:this.openAddressBook,scope:this,menu:this.initEmailButtonMenu("message_email_address","email_address_1")},{xtype:"textfield",flex:1,ref:"../../mailAddressField",name:"message_email_address",
listeners:{scope:this,change:this.onPropertyChange},property:"email_address_1"}]},{flex:1,name:"message_email_displayname",fieldLabel:_("Display name"),ref:"../mailDisplayNameField",listeners:{scope:this,change:this.onPropertyChange},property:"email_address_display_name_1"},{flex:1,fieldLabel:_("Webpage"),name:"message_webpage",listeners:{scope:this,change:this.onPropertyChange},property:"webpage"},{flex:1,fieldLabel:_("IM Address"),name:"message_im",listeners:{scope:this,change:this.onPropertyChange},
property:"im"}]}},createAddressFieldset:function(a){return{title:_("Addresses"),defaultType:"zarafa.compositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{items:[{xtype:"splitbutton",width:a.labelWidth,text:_("Business")+":",name:"message_label_address",handler:this.handleAddressButtonClick,scope:this,menu:this.initAddressButtonMenu("message_address","business_address")},{xtype:"textarea",flex:1,name:"message_address",height:128,listeners:{scope:this,change:this.onPropertyChange},property:"business_address"}]}]}},
createAdditionalFieldset:function(){return{title:_("Additional information"),defaultType:"textarea",defaults:{hideLabel:true,anchor:"100% 100%"},items:[{name:"message_additional",height:120,flex:1,listeners:{scope:this,change:this.onPropertyChange},property:"body"}]}},createAttachmentFieldset:function(a){return{title:_("Attachments"),columnWidth:1,border:false,defaultType:"zarafa.compositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{items:[{xtype:"button",width:a.labelWidth,text:_("Attachments")+
":",name:"message_label_attachments",listeners:{scope:this,click:this.showAttachmentsDialog}},{xtype:"zarafa.attachmentfield",ref:"../../attachmentField",flex:1,readOnly:true,hideLabel:true}]}]}},initPhoneButtonMenu:function(a,b){return{xtype:"menu",listeners:{click:this.onMenuItemSelection,scope:this},defaults:{xtype:"menucheckitem",group:a},items:[{text:_("Assistant"),property:"assistant_telephone_number",checked:b=="assistant_telephone_number"},{text:_("Business"),property:"business_telephone_number",
checked:b=="business_telephone_number"},{text:_("Business 2"),property:"business2_telephone_number",checked:b=="business2_telephone_number"},{text:_("Business Fax"),property:"business_fax_number",checked:b=="business_fax_number"},{text:_("Callback"),property:"callback_telephone_number",checked:b=="callback_telephone_number"},{text:_("Car"),property:"car_telephone_number",checked:b=="car_telephone_number"},{text:_("Company"),property:"company_telephone_number",checked:b=="company_telephone_number"},
{text:_("Home"),property:"home_telephone_number",checked:b=="home_telephone_number"},{text:_("Home 2"),property:"home2_telephone_number",checked:b=="home2_telephone_number"},{text:_("Home Fax"),property:"home_fax_number",checked:b=="home_fax_number"},{text:_("ISDN"),property:"isdn_number",checked:b=="isdn_number"},{text:_("Mobile"),property:"cellular_telephone_number",checked:b=="cellular_telephone_number"},{text:_("Other"),property:"other_telephone_number",checked:b=="other_telephone_number"},{text:_("Other Fax"),
property:"primary_fax_number",checked:b=="primary_fax_number"},{text:_("Pager"),property:"pager_telephone_number",checked:b=="pager_telephone_number"},{text:_("Primary"),property:"primary_telephone_number",checked:b=="primary_telephone_number"},{text:_("Radio"),property:"radio_telephone_number",checked:b=="radio_telephone_number"},{text:_("Telex"),property:"telex_telephone_number",checked:b=="telex_telephone_number"},{text:_("TTY/TDD"),property:"ttytdd_telephone_number",checked:b=="ttytdd_telephone_number"}]}},
initAddressButtonMenu:function(a,b){return{xtype:"menu",listeners:{click:this.onMenuItemSelection,scope:this},defaults:{xtype:"menucheckitem",group:a},items:[{text:_("Home"),property:"home_address",checked:b=="home_address"},{text:_("Business"),property:"business_address",checked:b=="business_address"},{text:_("Other"),property:"other_address",checked:b=="other_address"}]}},initEmailButtonMenu:function(a,b){return{xtype:"menu",listeners:{click:{fn:this.onEmailMenuItemSelection,scope:this}},defaults:{xtype:"menucheckitem",
group:a},items:[{text:_("Email"),property:"email_address_1",checked:b=="email_address_1"},{text:_("Email 2"),property:"email_address_2",checked:b=="email_address_2"},{text:_("Email 3"),property:"email_address_3",checked:b=="email_address_3"}]}},handlePhoneButtonClick:function(a){this.showDetailedPhoneDialog(a.ownerCt.findByType("textfield")[0].property)},handleAddressButtonClick:function(a){this.showDetailedAddressDialog(a.ownerCt.findByType("textarea")[0].property)},openAddressBook:function(){Zarafa.common.Actions.openABUserSelectionDialog(this.abCallBack.createDelegate(this),
false,false,this.dialog.isBrowser())},abCallBack:function(a){var b,c=a.get("address_type")||"SMTP";b=c=="ZARAFA"?a.get("smtp_address"):a.get("email_address");this.mailAddressField.setValue(b);this.record.beginEdit();switch(this.mailAddressField.property){case "email_address_1":this.record.set("email_address_1",b);this.record.set("email_address_type_1",c,true);this.record.set("email_address_display_name_1",a.get("display_name"));break;case "email_address_2":this.record.set("email_address_2",b);this.record.set("email_address_type_2",
c,true);this.record.set("email_address_display_name_2",a.get("display_name"));break;case "email_address_3":this.record.set("email_address_3",b);this.record.set("email_address_type_3",c,true);this.record.set("email_address_display_name_3",a.get("display_name"));break}this.record.endEdit()},update:function(a,b){if(!Ext.isEmpty(a)){this.record=a;var c=this.findBy(function(d){if(d.isXType("field")||d.isXType("zarafa.compositefield"))return true},this);Ext.each(c,function(d){if(d.isXType("zarafa.compositefield")){d=
d.findByType("field",false);Ext.each(d,function(e){Ext.isEmpty(e.property)||e.setValue(a.get(e.property))},this)}else Ext.isEmpty(d.property)||d.setValue(a.get(d.property))},this);if(a.isOpened()){b&&this.attachmentField.setAttachmentStore(a.getAttachmentStore());if(b||a.isSubStoreModifiedSincelastUpdate("attachments"))this.updateContactPhoto()}if(b){this.generateFileAsItems();this.fileAsField.selectByValue(a.get("fileas"),true)}a.isModifiedSinceLastUpdate("fileas")&&this.fileAsField.selectByValue(a.get("fileas"),
true);if(a.isModifiedSinceLastUpdate("display_name")||a.isModifiedSinceLastUpdate("company_name")){this.generateFileAsItems();this.updateFileas()}}},updateContactPhoto:function(){var a=this.record.getAttachmentStore(),b=this.contactPhotoBox.getEl();b&&a.getCount()>0&&Ext.each(a.getRange(),function(c){if(c.isContactPhoto()){Ext.getDom(b).src=c.getInlineImageUrl();return false}},this)},onMenuItemSelection:function(a,b){if(!Ext.isEmpty(b)){var c=a.findParentByType("zarafa.compositefield"),d=c.findByType("splitbutton")[0];
c=c.findByType("textfield")[0];if(!Ext.isEmpty(d)&&!Ext.isEmpty(c)){d.setText(b.initialConfig.text);c.setValue(this.record.get(b.property));c.property=b.property}}},onEmailMenuItemSelection:function(a,b,c){this.onMenuItemSelection(a,b,c);if(!Ext.isEmpty(this.mailDisplayNameField)){a=b.property.replace("email_address","email_address_display_name");this.mailDisplayNameField.setValue(this.record.get(a));this.mailDisplayNameField.property=a}},generateFileAsItems:function(){var a=this.record,b=[];a.get("fileas");
var c=a.get("display_name"),d=a.get("display_name_prefix"),e=a.get("generation");a=a.get("company_name");var f=this.fileAsField.getStore();if(!Ext.isEmpty(c)){c=c.replace(d,"").replace(e,"").replace(",","");c=c.trim().split(RegExp(Zarafa.contact.data.config.SP+"|"+Zarafa.contact.data.config.NBSP,"g"));c=Zarafa.core.Util.trimStringArray(c);d="";if(c.length>0){if(c.length===1)d=c[0];else{b.push([c.join(Zarafa.contact.data.config.NBSP)]);d=c[c.length-1]+","+Zarafa.contact.data.config.NBSP;c.splice(c.length-
1,1);d=d+c.join(Zarafa.contact.data.config.NBSP)}b.push([d])}if(!Ext.isEmpty(a)){b.push([a]);if(!Ext.isEmpty(d)){b.push([d+Zarafa.contact.data.config.NBSP+"("+a+")"]);b.push([a+Zarafa.contact.data.config.NBSP+"("+d+")"])}}}f.loadData(b)},updateFileas:function(){var a=this.fileAsField.getStore(),b=this.fileAsField.selectedIndex;if(a.getCount()<=0)this.record.set("fileas","");else b===-1||b>a.getCount()?this.record.set("fileas",a.getAt(0).get(this.fileAsField.displayField)):this.record.set("fileas",
a.getAt(b).get(this.fileAsField.displayField))},onPropertyChange:function(a,b){if(!Ext.isEmpty(a.property)&&a.validateValue(b)){var c=this.record;c.beginEdit();c.set(a.property,b);switch(a.property){case "fileas":c.set("fileas_selection","-1");break;case "email_address_1":c.set("email_address_type_1","SMTP",true);c.updateAddressbookProps();break;case "email_address_2":c.set("email_address_type_2","SMTP",true);c.updateAddressbookProps();break;case "email_address_3":c.set("email_address_type_3","SMTP",
true);c.updateAddressbookProps();break;case "display_name":var d=function(){var e=this.getContactParser().parseInfo("name",b);c.set("display_name_prefix",e.display_name_prefix);c.set("given_name",e.given_name);c.set("middle_name",e.middle_name);c.set("surname",e.surname);c.set("generation",e.generation);container.getSettingsModel().get("zarafa/v1/contexts/contact/show_name_dialog")==true&&!Ext.isEmpty(b)&&e.incomplete_info===true&&this.showDetailedNameDialog(e)}.defer(1,this);break;case "private":b==
true?c.set("sensitivity",Zarafa.core.mapi.Sensitivity.PRIVATE):c.set("sensitivity",Zarafa.core.mapi.Sensitivity.NONE);break;case "home_address":case "other_address":case "business_address":d=function(){var e=this.getContactParser().parseInfo("address",b),f=a.property;c.set(f+"_street",e.street);c.set(f+"_city",e.city);c.set(f+"_state",e.state);c.set(f+"_postal_code",e.postal_code);c.set(f+"_country",e.country);container.getSettingsModel().get("zarafa/v1/contexts/contact/show_address_dialog")==true&&
!Ext.isEmpty(b)&&e.incomplete_info===true&&this.showDetailedAddressDialog(a.property,e)}.defer(1,this);break}c.endEdit()}},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);a.updateSubject();a.updateAddressbookProps();a.endEdit()},showAttachmentsDialog:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record)},showDetailedNameDialog:function(a){Zarafa.contact.Actions.openDetailedNameDialog(this.getContactParser(),this.record,a)},showDetailedAddressDialog:function(a,b){Zarafa.contact.Actions.openDetailedAddressDialog(this.getContactParser(),
this.record,b,a)},showDetailedPhoneDialog:function(a){Zarafa.contact.Actions.openDetailedPhoneDialog(this.getContactParser(),this.record,a)},getContactParser:function(){return this.dialog.contactParser}});Ext.reg("zarafa.contactgeneraltab",Zarafa.contact.dialogs.ContactGeneralTab);Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.JsonMemberWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getMemberStore();a={};if(!Ext.isDefined(b))return a;b=b.getRange();a.members=[];for(var c=0;c<b.length;c++)a.members.push(b[c].data);return a}});Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.ContactDetailsParser=Ext.extend(Object,{prefixOptions:Zarafa.contact.data.config.Prefix,suffixOptions:Zarafa.contact.data.config.Suffix,CR:Zarafa.contact.data.config.CR,LF:Zarafa.contact.data.config.LF,CRLF:Zarafa.contact.data.config.CRLF,SP:Zarafa.contact.data.config.SP,NBSP:Zarafa.contact.data.config.NBSP,constructor:function(a){a=a||{};Ext.apply(this,a);Zarafa.contact.data.ContactDetailsParser.superclass.constructor.call(this,a)},parseInfo:function(a,b){if(!Ext.isString(b))return null;
switch(a){case "name":return this.parseNameInfo(b);case "phone":return this.parsePhoneInfo(b);case "address":return this.parseAddressInfo(b);default:return null}},parseNameInfo:function(a){var b={display_name_prefix:"",given_name:"",middle_name:"",surname:"",generation:"",incomplete_info:false};a=a.split(RegExp(this.SP+"|"+this.NBSP,"g"));a=Zarafa.core.Util.trimStringArray(a);switch(a.length){case 4:var c=a.shift();b.display_name_prefix=Zarafa.core.Util.inArray(this.prefixOptions,c,true)?c:"";var d=
a.pop();b.generation=Zarafa.core.Util.inArray(this.suffixOptions,d,true)?d:"";b.given_name=!Ext.isEmpty(b.display_name_prefix)?a.shift():c;b.surname=!Ext.isEmpty(b.generation)?a.pop():d;b.middle_name=!Ext.isEmpty(a.length)?a.shift():"";break;case 3:c=a.shift();b.display_name_prefix=Zarafa.core.Util.inArray(this.prefixOptions,c,true)?c:"";d=a.pop();b.generation=Zarafa.core.Util.inArray(this.suffixOptions,d,true)?d:"";if(Ext.isEmpty(b.display_name_prefix)&&Ext.isEmpty(b.generation)){b.given_name=c;
b.middle_name=a.shift();b.surname=d}else if(!Ext.isEmpty(b.display_name_prefix)&&Ext.isEmpty(b.generation)){b.given_name=a.shift();b.surname=d}else if(Ext.isEmpty(b.display_name_prefix)&&!Ext.isEmpty(b.generation)){b.given_name=c;b.surname=a.shift()}else if(!Ext.isEmpty(b.display_name_prefix)&&!Ext.isEmpty(b.generation))b.surname=a.shift();break;case 2:c=a.shift();b.display_name_prefix=Zarafa.core.Util.inArray(this.prefixOptions,c,true)?c:"";d=a.pop();b.generation=Zarafa.core.Util.inArray(this.suffixOptions,
d,true)?d:"";if(Ext.isEmpty(b.display_name_prefix)&&Ext.isEmpty(b.generation)){b.given_name=c;b.surname=d}else if(Ext.isEmpty(b.display_name_prefix)&&!Ext.isEmpty(b.generation)){b.surname=c;b.incomplete_info=true}else if(!Ext.isEmpty(b.display_name_prefix)&&Ext.isEmpty(b.generation)){b.surname=d;b.incomplete_info=true}break;case 1:b.given_name=a.shift();b.incomplete_info=true;break;default:c=a.shift();b.display_name_prefix=Zarafa.core.Util.inArray(this.prefixOptions,c,true)?c:"";d=a.pop();b.generation=
Zarafa.core.Util.inArray(this.suffixOptions,d,true)?d:"";b.given_name=!Ext.isEmpty(b.display_name_prefix)?a.shift():c;b.surname=!Ext.isEmpty(b.display_name_prefix)?a.pop():d;b.middle_name=a.join(this.NBSP);break}return b},parsePhoneInfo:function(a){for(var b={country_code:"",city_code:"",local_number:"",extension:""},c=["x","/"],d=0,e=c.length;d<e;d++){var f=c[d],g=a.indexOf(f);if(g>=0){b.extension=a.slice(g);a=a.replace(b.extension,"");b.extension=b.extension.replace(f,"").trim();break}}c=RegExp("(\\+|0{2})[^"+
this.SP+"|"+this.NBSP+"]+");d=RegExp("(^|"+this.SP+"|"+this.NBSP+")\\(?0\\)?[^0|"+this.SP+"|"+this.NBSP+"]+");if((e=a.match("\\((.{2,})\\)"))&&e.length===2){f=e[1].trim();if(f.match(c))b.country_code=f;else b.city_code=f;a=a.replace(e[0]," ")}else a=a.replace(RegExp("([^"+this.SP+"|"+this.NBSP+"])\\((.)\\)([^"+this.SP+"|"+this.NBSP+"])"),"$1 $2$3");a=a.split(RegExp(this.SP+"|"+this.NBSP+"|-","g"));a=Zarafa.core.Util.trimStringArray(a);if(a.length>1&&!b.country_code&&a[0].match(c))b.country_code=a.shift();
if(a.length>1&&!b.city_code&&a[0].match(d))b.city_code=a.shift();b.local_number=a.join(this.NBSP);return b},parseAddressInfo:function(a){var b=false,c={street:"",country:"",postal_code:"",city:"",state:"",incomplete_info:false};a=a.split(RegExp(this.CR+"|"+this.LF+"|"+this.CRLF,"g"));a=Zarafa.core.Util.trimStringArray(a);switch(a.length){default:c.country=a.pop();b=a.pop();c.street=a.join(this.CRLF);c.incomplete_info=false;break;case 2:c.street=a.shift();b=a.shift();c.incomplete_info=true;break;case 1:b=
a.shift();c.incomplete_info=true;break}if(b!==false){a=b.split(RegExp(this.SP+"|"+this.NBSP,"g"));a=Zarafa.core.Util.trimStringArray(a);if(Ext.isNumber(parseInt(a[0])))c.postal_code=a.shift();else if(Ext.isNumber(parseInt(a[a.length-1])))c.postal_code=a.pop();if(a.length>1){c.state=a.pop();c.city=a.join(this.NBSP)}else if(a.length===1)c.city=a.shift()}return c},combineInfo:function(a,b){if(!Ext.isObject(b))return null;switch(a){case "name":return this.combineNameInfo(b);case "phone":return this.combinePhoneInfo(b);
case "address":return this.combineAddressInfo(b);default:return null}},combineNameInfo:function(a){var b=!Ext.isEmpty(a.display_name_prefix)?a.display_name_prefix+this.NBSP:"";b+=!Ext.isEmpty(a.given_name)?a.given_name+this.NBSP:"";b+=!Ext.isEmpty(a.middle_name)?a.middle_name+this.NBSP:"";b+=!Ext.isEmpty(a.surname)?a.surname+this.NBSP:"";b+=!Ext.isEmpty(a.generation)?a.generation:"";return b.trim()},combinePhoneInfo:function(a){var b=!Ext.isEmpty(a.country_code)?a.country_code+this.NBSP:"";b+=!Ext.isEmpty(a.city_code)?
"("+a.city_code+")"+this.NBSP:"";b+=!Ext.isEmpty(a.local_number)?a.local_number+this.NBSP:"";b+=!Ext.isEmpty(a.extension)?"x"+this.NBSP+a.extension:"";return b.trim()},combineAddressInfo:function(a){var b="";Ext.isEmpty(a.street)||(b+=a.street);if(b[b.length-1]!==this.LF)b+=this.CRLF;if(!Ext.isEmpty(a.city)){if(b[b.length-1]!==this.LF)b+=this.NBSP;b+=a.city}if(!Ext.isEmpty(a.state)){if(b[b.length-1]!==this.LF)b+=this.NBSP;b+=a.state}if(!Ext.isEmpty(a.postal_code)){if(b[b.length-1]!==this.LF)b+=this.NBSP;
b+=a.postal_code}if(b[b.length-1]!==this.LF)b+=this.CRLF;Ext.isEmpty(a.country)||(b+=a.country);return b.trim()}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.TimeStripView=Ext.extend(Zarafa.core.ui.View,{timeDifference:0,name:"",textTemplate:"<div>{0}&nbsp;<sup>00</sup></div>",leftOffset:0,width:0,header:undefined,body:undefined,bodyElements:undefined,bodyLines:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"timestrip"});Zarafa.calendar.ui.TimeStripView.superclass.constructor.call(this,a)},setLeftMargin:function(a){this.leftOffset=a},setWidth:function(a){this.width=a},render:function(a){this.createDiv(this.parentView.scrollable,
"body",this.getClassName("body"));this.bodyElements=[];this.bodyLines=[];for(var b=this.parentView.numHours,c=0;c<b;c++){this.createDiv(this.body,"bodyElements",this.getClassName("element"));this.createDiv(this.body,"bodyLines",this.getClassName("line"))}this.createDiv(this.parentView.header,"header",this.getClassName("header"));this.header.dom.innerHTML=this.name;Zarafa.calendar.ui.TimeStripView.superclass.render.call(this,a);this.generateText()},setVisible:function(a){if(this.rendered){this.body.setVisible(a);
this.header.setVisible(a)}},generateText:function(){if(this.rendered)for(var a=0,b=this.bodyElements.length;a<b;a++)this.bodyElements[a].dom.innerHTML=String.format(this.textTemplate,(new Date(0,0,0,(a+Math.floor(this.timeDifference)+24)%24)).format(_("G")))},onLayout:function(){if(this.rendered){this.body.setLeftTop(this.leftOffset,0);this.body.setSize(this.width,this.parentView.getHourHeight()*this.parentView.numHours);for(var a=Math.round(this.timeDifference)-this.timeDifference,b=0,c=this.bodyElements.length;b<
c;b++){this.bodyElements[b].setSize(this.width,this.parentView.getHourHeight());this.bodyElements[b].setLeftTop(0,this.parentView.getHourHeight()*(b+a))}b=0;for(c=this.bodyLines.length;b<c;b++){this.bodyLines[b].setSize(this.width,1);this.bodyLines[b].setLeftTop(0,this.parentView.getHourHeight()*(b+a)-1)}this.header.setWidth(this.width);this.header.setLeft(this.leftOffset);this.header.setBottom(0);Zarafa.calendar.ui.TimeStripView.superclass.onLayout.call(this)}},setTimeDifference:function(a){this.timeDifference=
a;this.generateText();this.layout()},setName:function(a){this.name=a;this.generateText()}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.TextEditView=Ext.extend(Zarafa.core.ui.View,{dateRange:undefined,minimumHeight:32,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"textedit"});this.addEvents("textentered","cancelled");Zarafa.calendar.ui.TextEditView.superclass.constructor.call(this,a)},setDateRange:function(a){this.dateRange=a},getDateRange:function(){return this.dateRange},isVisible:function(){return this.visible},render:function(a){this.create("textarea",this.parentView.getCalendarBody(),
"body",this.getClassName("body"));this.create("textarea",this.parentView.getCalendarHeader(),"header",this.getClassName("header"));Ext.each([this.body,this.header],function(b){this.mon(b,"keypress",this.onKeyPress,this);this.mon(b,"keydown",this.onKeyPress,this);this.mon(b,"blur",this.onBlur,this)},this);Zarafa.calendar.ui.TextEditView.superclass.render.call(this,a);this.hide()},makeElementsVisible:function(a,b){Ext.each(a,function(c){c.dom.style.display=b?"inline":"none"},this)},hide:function(){if(this.rendered){this.makeElementsVisible([this.body,
this.header],false);this.visible=false}},show:function(){if(this.rendered){this.visible=true;this.layout()}},onKeyPress:function(a){a.keyCode==a.ESC&&this.hide();if(a.keyCode==a.RETURN){var b=a.browserEvent.target.value;a.browserEvent.target.value="";this.hide();this.fireEvent("textentered",this,b)}},onBlur:function(a){var b=this.parentView.isHeaderRange(this.getDateRange());if(b&&a.target==this.header.dom||!b&&a.target==this.body.dom){this.hide();this.fireEvent("cancelled",this)}},layoutInBody:function(){this.makeElementsVisible(this.header,
false);var a=this.parentView.dateRangeToBodyBounds(this.dateRange);if(a.length==0)this.makeElementsVisible(this.body,false);else{this.makeElementsVisible(this.body,true);this.body.setLeftTop(a[0].left,a[0].top);this.body.setSize(a[0].right-a[0].left,a[0].bottom-a[0].top)}},layoutInHeader:function(){this.makeElementsVisible(this.body,false);var a=this.parentView.dateRangeToHeaderBounds(this.dateRange,this.slot);this.makeElementsVisible(this.header,true);this.header.setLeftTop(a.left,a.top);this.header.setSize(a.right-
a.left,this.minimumHeight)},onLayout:function(){if(this.rendered){if(this.visible)this.parentView.isHeaderRange(this.getDateRange())?this.layoutInHeader():this.layoutInBody();else this.makeElementsVisible([this.body,this.header],false);Zarafa.calendar.ui.TextEditView.superclass.onLayout.call(this)}},select:function(){if(this.rendered){this.show();this.parentView.isHeaderRange(this.getDateRange())?this.header.dom.select():this.body.dom.select()}}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.IconCache={getDashedImage:function(){var a=new Image;a.src="data:image/gif;base64,R0lGODlhCAAIAIABAP///wAAACH5BAEKAAEALAAAAAAIAAgAAAIPhIN2qRgKHIwPslZxpq8AADs=";return function(){return a}}(),getPrivateIcon:function(){var a=new Image;a.src="data:image/gif;base64,R0lGODlhDAALAPcAAAQCBPz+/AAAAAAAAG/g+Bnl5wASEgAAADsCZx0ABAAA1AAAdwCY0ADltBU50QB3dwyk/wDl/wAS/wAA/wBTywIbtABM0QAAdwDgDAPltQAS0QAAd7QCEOQAABIAAAAAAHmUDwjlAIISAHwAAAAAAAAAAAEAAAAAAFYAHAAAtQAA0QAAd7yMAOPlABISAAAAAHM0AACHAADRAAB3ANy4AOQIABKSAAAAABgPAO4AAJAAAHwAAHAAqAUA5pEAEnwAAP8A4/8A6v8AkP8AfG2YAAXlAJE5FXx3ABXNGAqrAIK6AHzcAAAA0AAAZhUAewAAAGDIDwPlAAASAAAAABCYAALlABo5AAB3AED0AGPlABUSAAAAAAAWmACI5QDRAQB3AH4AAgDwAAD9AMB/AAD09ADl5QASEgAAAP9aKv+I2P/R0f93d/+06P/l5v8SEv8AAAAqGACI7gDRkAB3fAAAcAAABQAAkQAAfAC4/wAI/xWS/wAA/+wAEuTwnxIAgAAAfGIUAAkAAIIAAHwAAEABAGMAABUAAAAAANsABwUAAIIAAHwAAKAAAAwAAFAAAAAAAEAQAGMAQAEAFQAAAGwAAAAAAAAAAAAAACjLAOSwABIAAAAAAAAEAADmAAASAAAAAJyDAPcqABKCAAB8ABgAGO4An5AAgHwAfHAA/wUA/5EA/3wA//8AEv8An/8AgP8AfG0pSAW3AJGSAHx8AEoYSPYAAIAAAHwAAAC+gAA+7RWCEgB8AAD//wD//wD//wD//0AAAGMAABUAAAAAAADoMAHl5wASEgAAAAC+jgA+2ACCSwB8AFecEPb354ASEnwAABQYe+bu8BKQTgB8AEAARGO35xWSEgB8AET/vuX/PhL/ggD/fAYY+B0A50wAEgAAAOK+tuU+/xKC/wB8f+EssOXn5xISEgAAAAPdAAA/AACCAAB8AOEWvuU/PhKCggB8fJQAAOUAABIAAAAAAOEwy+UAsBIwAAAAAMAAABsAAEwAAAAAAOEcR+XmuxISRwAAACH5BAEAAAEALAAAAAAMAAsABwgtAAMIHBgAgEGCBAEMVIhQoUGHDQtKZLiw4EGKAjFinPgwokSEHw9GFAmSJMiAADs=";
return function(){return a}}(),getRecurringIcon:function(){var a=new Image;a.src="data:image/gif;base64,R0lGODlhCwALAIAAAAAAAP///yH5BAEAAAEALAAAAAALAAsAAAIXjA2nB7kNHWKyKRnsopdl/l3RlmGbWQAAOw==";return function(){return a}}(),getExceptionIcon:function(){var a=new Image;a.src="data:image/gif;base64,R0lGODlhCwALAIAAAAAAAP///yH5BAEAAAEALAAAAAALAAsAAAIXjA13iawA4wsJLmevonrx2jmNJFLlVhYAOw==";return function(){return a}}(),getMeetingIcon:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAHRSURBVCiRnZNNa1pBFIafuc4dGxdSibaIgg2kKZSCItKNuHRhf4H9WInLLov5Af4GweX9A125cRPINhREIUWK2Un01uIm4tfccKeL4BdtF83AYQ7nzHvOe17OCGMMjz3WxnEcZ+U4zpP9pOM4f1Tej4kPn78agLPodwbT1xgjtg9fxa758evNAXg/JgGOw6csFt94FjlDqSOUrZBSMv95xcsXb7n37tGeRmvNfH7FcfiU6d3NjvZSvscSNpawsCyLQCDA0+QXAoEAwhII8WBL+XHLQgJM724eJZj89O6ITCbz38But/vQGWA8HmPbNp7nYds26/UaKSVa6+29yadSqR1tACkl0WiU0WhEvV4HwPf9f5oxZgdeLpfc3t6yWq0Ih8Pkcjm01lSrVUKhEABaa5rNJovFgk6ns1NbKUUikUApRTAYpFKpkE6nqdVq9Pt9XNfl/PycZDJJsVhEKbXrbIxhMpmwWVfbtsnn8wghaDQaeJ5HqVQim80SiUQOZ47H4wdqGmPo9XoMh0PK5TKz2YzBYEA8Ht+CRbvddn3ff74PbLVaFAoFTk5OyGazGGO2Il1eXuK6LhcXF4i//apyuWxisdiB4psCvu/jeR6TyYTf1e/eakeXUAkAAAAASUVORK5CYII=";
return function(){return a}}(),getReminderIcon:function(){var a=new Image;a.src="data:image/gif;base64,R0lGODlhEgAMAPcAAAQCBPz+/AAAQQAAfk8AAB4A8AAA/QAAf5i/bB495AA/EgB3AABzWgC0iBVBQQB+fg4gLADj5AASEgAAAAAsKgIAiAAAQQAAfgAADAEAAACFAACBAIi+2OKU1BJBewB+AOkt7OW01IFBe3x+AABEFAADAAEIAAAAAFYgAQAAAAAAAAAAAJC+AOEDABI9AAAAAHMSAAAAAAAAAAACALAAEOIAABIAAAAAABieAO4CAJAAAHwAAHABAAUAAJEAAHwAAP/YAP/xAP8SAP8AAG0QAAX3AJFFAHwAAIUgAecAAIEAAHwAAABONQBvNhV0MgAgNWBhIAMgJQBmIABpAIBsEOll6RsAEgAAAJAMV2UABBUARAAAfgAAMAAAiAAAQQAAfn5g/wBj/wBQ/8AA/wABKgAAiAAAQQAAfv9gm/9juP9QQf8Afv+QAP/jAP8SAP8AAACYoADVnABBRQB+AABEjgADAwAIQAAAAAAgDAAAABUAAAAAAPK+YGsDngA9gAAAfMASUOIA1RIAFQACAJ8BAOsAAIEAAHwAAErYB+PjAIESAHwAAMBFAHbVAFBBAAB+AJBEAGUD0AEIFQAAAGwgAAAAAAAAAAAAAPzyAOFrABIAAAAAADTYAADjAAASAMAAAPiFAPcrABKDAAB8ABgAaO4AnpAAgHwAfHAA/wUA/5EA/3wA//8AYP8Anv8AgP8AfG0APgUBAJEAAHwAAErpPvQrAICDAHx8AAD8SADj6xUSEgAAAADE/wAr/wCD/wB8/5AAAGUAABUAAAAAAABQBAHV5QAVEgAAAAA0vgBkOwCDTAB8AFf/5PT/5ID/Enz/AOgAd+PlEBISTwAAAJBtGGVk5RWDEgB8AOMMNOoUZJBPg3wAfOzUxuIy5RJPEgAAADgAwAAB/wAA/wAAfzj8iADj5QASEgAAAAIAUAAB1QAAFQAAAAGINABkZACDgwB8fMwBUAUA1U4AFZ8AADAA8gAAawAAAAAAAACgAACcAABFAAAAANhs6dTkznsSRwAAACH5BAEAAAEALAAAAAASAAwABwg9AAMIHEiwYEEABxEeJKhQIICGDg0qfPhwIMSFFg0GoLhR4saKGBlq7HiRJMaSEzN21JjSIsWJL0c65GgwIAA7";
return function(){return a}}()};Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarTabView=Ext.extend(Zarafa.core.ui.View,{title:undefined,folder:undefined,tabBackground:undefined,tab:undefined,tabLeft:undefined,tabRight:undefined,tabContents:undefined,tabText:undefined,mergeIcon:undefined,separateIcon:undefined,closeIcon:undefined,bottomOffset:0,leftOffset:0,width:0,selected:true,showMergeIcon:false,showSeparateIcon:false,showCloseIcon:false,constructor:function(a){a=a||{};var b=undefined;if(a.folder){b=a.folder.getMAPIStore();b.getSubtreeFolder();b=
b.isSharedStore()?a.folder.isDefaultFolder()?b.get("mailbox_owner_name"):String.format(pgettext("calendar.tab","{0} of {1}"),a.folder.getDisplayName(),b.get("mailbox_owner_name")):b.isPublicStore()?String.format(pgettext("calendar.tab","{0} in {1}"),a.folder.getDisplayName(),b.get("display_name")):a.folder.getDisplayName()}Ext.applyIf(a,{baseCls:"zarafa-calendar",title:b?Ext.util.Format.htmlEncode(b):undefined,themeCls:a.folder?a.folder.getColorTheme():undefined});this.addEvents("merge","separate",
"close","click");Zarafa.calendar.ui.CalendarTabView.superclass.constructor.call(this,a)},getDesiredWidth:function(){if(!this.rendered)return 0;return this.getMinimumWidth()+this.tabLeft.getWidth()+this.tabText.textMetrics.getWidth(this.title)+this.tabText.getMargins("lr")},getMinimumWidth:function(){if(!this.rendered)return 0;var a=this.tabRight.getWidth()+this.tabContents.getPadding("lr");if(this.showCloseIcon)a+=this.closeIcon.getWidth()+this.closeIcon.getMargins("lr");if(this.showMergeIcon)a+=
this.mergeIcon.getWidth()+this.mergeIcon.getMargins("lr");if(this.showSeparateIcon)a+=this.separateIcon.getWidth()+this.separateIcon.getMargins("lr");return a},setBottomMargin:function(a){this.bottomOffset=a},setLeftMargin:function(a){this.leftOffset=a},setWidth:function(a){this.width=a},setSelected:function(a,b){if(b===true||this.selected!==a){var c=this.getBaseClassName()+"-tab-selected";if(a===true){this.tabBackground.addClass(c);this.tabContents.addClass(c)}else{this.tabBackground.removeClass(c);
this.tabContents.removeClass(c)}}this.selected=a},setShowMergeIcon:function(a){this.showMergeIcon=a},setShowSeparateIcon:function(a){this.showSeparateIcon=a},setShowCloseIcon:function(a){this.showCloseIcon=a},applyCSSClassNames:function(){this.tabBackground.dom.className=this.getClassName("tab","background");this.tabLeft.dom.className=this.getClassName("tab-leftside");this.tab.dom.className=this.getClassName("tab-body");this.tabRight.dom.className=this.getClassName("tab-rightside");this.tabContents.dom.className=
this.getClassName("tab","contents");this.mergeIcon.dom.className=this.getClassName("tab-icon","merge");this.tabText.dom.className=this.getClassName("tab-title");this.closeIcon.dom.className=this.getClassName("tab-icon","close");this.separateIcon.dom.className=this.getClassName("tab-icon","separate");this.selected&&this.setSelected(this.selected,true)},onLayout:function(){this.applyCSSClassNames();var a=this.parentView.getTabHeight()-this.tab.getHeight()-this.bottomOffset,b=this.width-this.getMinimumWidth(),
c=this.leftOffset;this.tabLeft.setLeftTop(c,a);c+=this.tabLeft.getWidth();this.tab.setLeftTop(c,a);this.tab.setWidth(this.width-this.tabLeft.getWidth()-this.tabRight.getWidth());c+=this.tab.getWidth();this.tabRight.setLeftTop(c,a);this.tabContents.setLeftTop(this.leftOffset,a);this.tabContents.setWidth(this.width);c=this.leftOffset+this.tabContents.getPadding("l");if(this.showMergeIcon){this.mergeIcon.setLeftTop(c,a);c+=this.mergeIcon.getWidth()+this.mergeIcon.getMargins("lr")}this.mergeIcon.setVisible(this.showMergeIcon);
this.tabText.setLeftTop(c,a-1);this.tabText.setWidth(b);if(this.tabText.dom.innerHTML!=this.title)this.tabText.dom.innerHTML=this.title;c+=b+this.tabText.getMargins("lr");if(this.showCloseIcon){this.closeIcon.setLeftTop(c,a);c+=this.closeIcon.getWidth()+this.closeIcon.getMargins("lr")}this.closeIcon.setVisible(this.showCloseIcon);this.showSeparateIcon&&this.separateIcon.setLeftTop(c,a);this.separateIcon.setVisible(this.showSeparateIcon);Zarafa.calendar.ui.CalendarTabView.superclass.onLayout.call(this)},
render:function(a){this.createDiv(this.parentView.tabArea,"tabBackground");this.createDiv(this.parentView.tabArea,"tabContents");this.createDiv(this.tabBackground,"tabLeft");this.createDiv(this.tabBackground,"tabRight");this.createDiv(this.tabBackground,"tab");this.createDiv(this.tabContents,"tabText");this.createDiv(this.tabContents,"mergeIcon");this.createDiv(this.tabContents,"separateIcon");this.createDiv(this.tabContents,"closeIcon");this.mon(this.mergeIcon,"click",this.onMerge,this);this.mon(this.separateIcon,
"click",this.onSeparate,this);this.mon(this.closeIcon,"click",this.onClose,this);this.mon(this.tabText,"click",this.onClick,this);this.tabText.textMetrics=Ext.util.TextMetrics.createInstance(this.tabText);this.applyCSSClassNames();Zarafa.calendar.ui.CalendarTabView.superclass.render.call(this,a)},onMerge:function(){this.fireEvent("merge",this.folder)},onSeparate:function(){this.fireEvent("separate",this.folder)},onClose:function(){this.fireEvent("close",this.folder)},onClick:function(){this.fireEvent("click",
this.folder)}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarPanelToolbar=Ext.extend(Zarafa.common.ui.ContextMainPanelToolbar,{constructor:function(a){a=a||{};a.paging=a.paging||[];a.paging.push({xtype:"toolbar",ref:"dateToolbar",items:[{xtype:"button",iconCls:"x-tbar-page-prev",handler:this.onPrevious,scope:this},{xtype:"tbseparator"},{xtype:"tbtext",ref:"../text"},{xtype:"tbseparator"},{xtype:"button",iconCls:"x-tbar-page-next",handler:this.onNext,scope:this}]});Zarafa.calendar.ui.CalendarPanelToolbar.superclass.constructor.call(this,a)},
initComponent:function(){Zarafa.calendar.ui.CalendarPanelToolbar.superclass.initComponent.call(this);if(this.model){this.mon(this.model,"daterangechange",this.onDateRangeChange,this);this.mon(this.model,"datamodechange",this.onDataModeChange,this);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:true})}},onAfterFirstLayout:function(){if(this.model){this.text.setText(this.model.getDateRangeText());var a=this.model.getCurrentDataMode();this.onDataModeChange(this.model,a,a)}},onDataModeChange:function(a,
b){if(b===Zarafa.calendar.data.DataModes.ALL||b===Zarafa.calendar.data.DataModes.SEARCH){this.pagesToolbar.setVisible(true);this.dateToolbar.setVisible(false)}else{this.pagesToolbar.setVisible(false);this.dateToolbar.setVisible(true)}this.doLayout()},onDateRangeChange:function(a){this.text.setText(a.getDateRangeText())},onNext:function(){this.model.nextDate()},onPrevious:function(){this.model.previousDate()}});Ext.reg("zarafa.calendarpaneltoolbar",Zarafa.calendar.ui.CalendarPanelToolbar);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarMultiView=Ext.extend(Zarafa.core.ui.View,{context:undefined,tabAreaHeight:32,headerTextHeight:22,headerItemHeight:21,headerLineHeight:1,calendarGap:4,numHours:24,timeStripWidth:52,timeStripGap:0,zoomLevel:30,model:undefined,timeStripShift:1,firstWorkingHour:540,lastWorkingHour:1020,workingDays:undefined,forceHTML:undefined,constructor:function(a){a=a||{};if(Ext.isDefined(a.context)){if(!Ext.isDefined(a.zoomLevel))a.zoomLevel=a.context.getZoomLevel();if(!Ext.isDefined(a.model))a.model=
a.context.getModel()}if(!Ext.isDefined(a.firstWorkingHour))a.firstWorkingHour=container.getSettingsModel().get("zarafa/v1/main/start_working_hour");if(!Ext.isDefined(a.lastWorkingHour))a.lastWorkingHour=container.getSettingsModel().get("zarafa/v1/main/end_working_hour");if(!Ext.isDefined(a.workingDays))a.workingDays=container.getSettingsModel().get("zarafa/v1/main/working_days");a=Ext.applyIf(a,{baseCls:"zarafa-calendar",timeUnitHeight:23,minHeaderDayTextWidth:110,showBorder:false,borderWidth:3,showTimeStrips:true});
this.addEvents("appointmentcalendardrop","appointmentmove","appointmentresize","appointmentcreate","contextmenu","dblclick","dayclick","calendarclose");Zarafa.calendar.ui.CalendarMultiView.superclass.constructor.call(this,a)},init:function(){Zarafa.calendar.ui.CalendarMultiView.superclass.init.call(this);this.calendars=[];this.timeStrips=[];if(Ext.isDefined(this.context)){this.mon(this.context,"viewmodechange",this.onViewModeChanged,this);this.mon(this.context,"zoomchange",this.onZoomLevelChanged,
this)}Ext.isDefined(this.model)&&this.mon(this.model,"foldermergestatechanged",this.onFolderMergestateChanged,this);this.addTimeStrip()},getSelectionModel:function(){return this.selectionModel},getRangeSelectionModel:function(){return this.rangeSelectionModel},getDateRange:function(){return this.model.dateRange},getTabHeight:function(){return this.showBorder?this.tabAreaHeight:0},addTimeStrip:function(a,b){var c=new Zarafa.calendar.ui.TimeStripView({timeDifference:a||0,name:b||""});this.addChildView(c);
this.timeStrips.splice(0,0,c);if(this.rendered){c.render(this.container);this.layout()}},removeTimeStrip:function(a){for(var b=0,c;c=this.timeStrips[b];b++)if(c.name==a){this.timeStrips.splice(b,1);this.removeChildView(c,true);break}this.layout()},onViewModeChanged:function(a,b){var c=Zarafa.supportsCanvas()&&!this.forceHTML?Zarafa.calendar.ui.canvas:Zarafa.calendar.ui.html;if(this.rendered){switch(b){case Zarafa.calendar.data.ViewModes.DAYS:this.showTimeStrips=true;this.calendarViewConstructor=c.CalendarDaysView;
this.container.addClass("zarafa-calendar-daysview");this.container.removeClass("zarafa-calendar-boxview");break;case Zarafa.calendar.data.ViewModes.BOX:this.showTimeStrips=false;this.calendarViewConstructor=c.CalendarBoxView;this.container.removeClass("zarafa-calendar-daysview");this.container.addClass("zarafa-calendar-boxview");break;default:this.showTimeStrips=false;this.container.removeClass("zarafa-calendar-daysview");this.container.removeClass("zarafa-calendar-boxview")}c=this.calendars.clone();
for(var d=0,e=c.length;d<e;d++){var f=c[d],g=f.getFolders();g.length>0&&this.createCalendarView(f.groupId,g).setSelectedFolder(f.selectedFolder);this.removeCalendarView(f)}this.store&&this.store.lastOptions&&!this.store.isExecuting("list")&&this.onLoad(this.store,this.store.getRange(),this.store.lastOptions)}},onZoomLevelChanged:function(a,b){this.zoomLevel=b;this.layout()},onFolderMergestateChanged:function(){this.manageCalendarViews()},onAppointmentCalendarDrop:function(a,b,c,d,e){this.fireEvent("appointmentcalendardrop",
this,c,b.getSelectedFolder(),a.getSelectedFolder(),d,e)},onAppointmentMove:function(a,b,c,d){this.fireEvent("appointmentmove",this,b,c,d)},onAppointmentResize:function(a,b,c,d){this.fireEvent("appointmentresize",this,b,c,d)},onAppointmentCreate:function(a,b,c){this.fireEvent("appointmentcreate",this,a.getSelectedFolder(),b,c)},onContextMenu:function(a,b){if(b){if(b.get("access")===0)return;this.selectionModel.selectRecord(b,false)}else this.selectionModel.clearSelections();b&&b.phantom!==true&&this.rangeSelectionModel.clearSelections();
this.fireEvent("contextmenu",a,b)},onDoubleClick:function(a,b){if(b&&b.phantom!==true){if(b.get("access")===0)return;this.selectionModel.selectRecord(b,false);this.rangeSelectionModel.clearSelections()}this.fireEvent("dblclick",a,b)},onDayClick:function(a,b){this.fireEvent("dayclick",a,b)},getHourHeight:function(){return 60/this.zoomLevel*this.timeUnitHeight},getBorderWidth:function(){return this.showBorder?this.borderWidth:0},getTabAreaHeight:function(){return this.showBorder?this.tabAreaHeight:
0},getHeaderAreaHeight:function(){for(var a=0,b=0,c;c=this.calendars[b];b++)a=Math.max(a,c.getDesiredHeaderHeight());return a},render:function(a){if(!this.rendered){a.addClass(this.getClassName("body"));this.createDiv(a,"tab",this.getClassName("tabarea"));this.createDiv(a,"header",this.getClassName("header"));this.createDiv(a,"scrollable",this.getClassName("scrollable",undefined,"zoom-"+this.zoomLevel+"m"));this.createDiv(a,"bottom",this.getClassName("bottomarea"));this.createDiv(a,"headerLine",this.getClassName("headerLine"));
Zarafa.calendar.ui.CalendarMultiView.superclass.render.call(this,a);this.renderChildren();this.onViewModeChanged(this.context,this.context.getCurrentViewMode())}},bindStore:function(a){if(this.store!=a){Ext.isDefined(a)&&this.mon(a,{scope:this,beforeload:this.onBeforeLoad,load:this.onLoad,add:this.onAdd,remove:this.onRemove,update:this.onUpdate});(this.store=a)&&a.lastOptions&&!a.isExecuting("list")&&this.onLoad(a,a.getRange(),a.lastOptions)}},releaseStore:function(a){if(Ext.isDefined(a)){this.mun(a,
"beforeload",this.onBeforeLoad,this);this.mun(a,"load",this.onLoad,this);this.mun(a,"add",this.onAdd,this);this.mun(a,"remove",this.onRemove,this);this.mun(a,"update",this.onUpdate,this)}a&&a.autoDestroy&&a.destroy();this.store=undefined},resizeAreas:function(){var a=this.getTabHeight(),b=a+this.getHeaderAreaHeight(),c=this.container.getHeight()-b-this.getBorderWidth();if(this.showTimeStrips)c=Math.min(c,this.getHourHeight()*this.numHours);var d=c+b;this.tab.setLeftTop(0,0);this.tab.setSize(this.container.getWidth(),
a);this.header.setLeftTop(0,a);this.header.setSize(this.container.getWidth(),this.getHeaderAreaHeight());this.scrollable.setLeftTop(0,b);this.scrollable.setSize(this.container.getWidth(),c);this.showTimeStrips&&this.scrollable.scrollTo("top",this.firstWorkingHour/60*this.getHourHeight());this.bottom.setLeftTop(0,d);this.bottom.setSize(this.container.getWidth(),this.getBorderWidth());for(a=0;c=this.timeStrips[a];a++){c.setLeftMargin((this.timeStripWidth+this.timeStripGap)*a-this.timeStripShift);c.setWidth(this.timeStripWidth)}a=
this.showTimeStrips?this.timeStrips.length*this.timeStripWidth+(this.timeStrips.length-1)*this.timeStripGap-this.timeStripShift:0;this.headerLine.setLeftTop(0,b-this.headerLineHeight);this.headerLine.setSize(a,this.headerLineHeight)},onLayout:function(){this.resizeAreas();this.scrollable.dom.style.overflowY=this.showTimeStrips?"scroll":"hidden";this.showTimeStrips||this.scrollable.scrollTo("top",0);for(var a=0,b;b=this.timeStrips[a];a++)b.setVisible(this.showTimeStrips);b=this.showTimeStrips?this.timeStrips.length*
this.timeStripWidth+(this.timeStrips.length-1)*this.timeStripGap-this.timeStripShift:0;var c=(this.scrollable.dom.clientWidth-b-(this.calendars.length-1)*this.calendarGap)/this.calendars.length+this.calendarGap;a=0;for(var d;d=this.calendars[a];a++){var e=Math.round(c*a+b),f=Math.round(c*(a+1)+b-this.calendarGap);d.setCanMerge(a>0);d.setCanClose(this.folders.length>1);d.setLeftMargin(e);d.setWidth(f-e)}},onAfterLayout:function(){this.layoutChildren()},getCalendarViewByFolder:function(a){for(var b=
0,c;c=this.calendars[b];b++)if(c.containsFolder(a))return c},createCalendarView:function(a,b){if(!Ext.isEmpty(b)&&!Ext.isArray(b))b=[b];var c=new this.calendarViewConstructor({selectionModel:this.selectionModel,rangeSelectionModel:this.rangeSelectionModel,enableDD:this.enableDD,groupId:a});this.mon(c,"appointmentcalendardrop",this.onAppointmentCalendarDrop,this);this.mon(c,"appointmentmove",this.onAppointmentMove,this);this.mon(c,"appointmentresize",this.onAppointmentResize,this);this.mon(c,"appointmentcreate",
this.onAppointmentCreate,this);this.mon(c,"contextmenu",this.onContextMenu,this);this.mon(c,"dblclick",this.onDoubleClick,this);this.mon(c,"dayclick",this.onDayClick,this);this.mon(c,"activate",this.onCalendarActivate,this);this.mon(c,"merge",this.onCalendarMerge,this);this.mon(c,"separate",this.onCalendarSeparate,this);this.mon(c,"close",this.onCalendarClose,this);b&&Ext.each(b,function(d){c.addFolder(d)});this.addChildView(c);this.calendars.push(c);this.rendered&&c.render(this.container);return c},
removeCalendarView:function(a){this.calendars.remove(a);this.mun(a,"appointmentcalendardrop",this.onAppointmentCalendarDrop,this);this.mun(a,"appointmentmove",this.onAppointmentMove,this);this.mun(a,"appointmentresize",this.onAppointmentResize,this);this.mun(a,"appointmentcreate",this.onAppointmentCreate,this);this.mun(a,"contextmenu",this.onContextMenu,this);this.mun(a,"dblclick",this.onDoubleClick,this);this.mun(a,"dayclick",this.onDayClick,this);this.mun(a,"activate",this.onCalendarActivate,this);
this.mun(a,"merge",this.onCalendarMerge,this);this.mun(a,"separate",this.onCalendarSeparate,this);this.mun(a,"close",this.onCalendarClose,this);this.removeChildView(a,true)},pruneCalendarViews:function(a){for(var b=this.calendars.clone(),c=0,d;d=b[c];c++){for(var e=d.getFolders().clone(),f=0,g;g=e[f];f++)if(a.indexOf(g)==-1){this.model.removeFolderFromGroup(g,d.groupId);d.removeFolder(g)}this.removeCalendarViewIfEmpty(d);d.isDestroyed||this.updateActiveFolder(d)}},createCalendarViews:function(a){var b=
this.model.getGroupings();for(var c in b){for(var d=b[c],e=[],f=0;f<a.length;f++)d.folders.indexOf(a[f].get("entryid"))>-1&&e.push(a[f]);if(!Ext.isEmpty(e)){f=e[0];var g=this.getCalendarViewByFolder(f);if(g)if(g.folders.length>1){var h=this.createCalendarView(c);this.moveFolder(g,h,f);g=h}else{if(g.groupId!==c)g.groupId=c}else g=this.createCalendarView(c,f);for(f=1;f<e.length;f++){h=e[f];var i=this.getCalendarViewByFolder(h);if(i&&i!==g)this.moveFolder(i,g,h);else i||g.addFolder(h)}g.setSelectedFolder(g.getFolderById(d.active))}}},
sortCalendarViews:function(a){for(var b=[],c=0,d;d=a[c];c++)(d=this.getCalendarViewByFolder(d))&&b.indexOf(d)==-1&&b.push(d);for(c=0;d=b[c];c++)d.sortFolders(a);this.calendars=b},manageCalendarViews:function(){this.pruneCalendarViews(this.folders);this.createCalendarViews(this.folders);this.sortCalendarViews(this.folders)},onBeforeLoad:function(a,b){if(this.rendered){for(var c=0,d=this.calendars.length;c<d;c++)this.calendars[c].beforeAppointmentsLoad(a,b);this.layout()}},onLoad:function(a,b,c){if(this.rendered){this.folders=
c.folder||[];this.showBorder=true;this.manageCalendarViews();for(var d=0,e=this.calendars.length;d<e;d++)this.calendars[d].onAppointmentsLoad(a,b,c);this.layout()}},onAdd:function(a,b,c){if(Ext.isArray(b))for(var d=0,e=b.length;d<e;d++)this.onAdd(a,b[d],c);else{d=0;for(e=this.calendars.length;d<e;d++)this.calendars[d].onAppointmentAdd(a,b,c);b.get("alldayevent")&&this.resizeAreas()}},onRemove:function(a,b,c){if(Ext.isArray(b))for(var d=0,e=b.length;d<e;d++)this.onRemove(a,b[d],c);else{d=0;for(e=this.calendars.length;d<
e;d++)this.calendars[d].onAppointmentRemove(a,b,c);b.get("alldayevent")&&this.resizeAreas()}},onUpdate:function(a,b,c){if(Ext.isArray(b))for(var d=0,e=b.length;d<e;d++)this.onUpdate(a,b[d],c);else{d=0;for(e=this.calendars.length;d<e;d++){var f=this.calendars[d],g=f.containsAppointment(b),h=f.containsFolderId(b.get("parent_entryid"));if(g&&!h)f.onAppointmentRemove(a,b,c);else!g&&h?f.onAppointmentAdd(a,b,c):this.calendars[d].onAppointmentUpdate(a,b,c)}if(b.isModifiedSinceLastUpdate("alldayevent")||
b.get("alldayevent"))this.resizeAreas()}},removeCalendarViewIfEmpty:function(a){a.getFolders().length==0&&this.removeCalendarView(a)},moveFolder:function(a,b,c){b.addFolder(c);for(var d=a.getAppointmentRecords().clone(),e=0,f;f=d[e];e++)if(Zarafa.core.EntryId.compareEntryIds(f.get("parent_entryid"),c.get("entryid"))){a.removeAppointment(f,false);b.addAppointment(f,false)}b.sortFolders(this.folders);a.removeFolder(c);this.removeCalendarViewIfEmpty(a);a.isDestroyed||this.updateActiveFolder(a)},mergeFolder:function(a,
b,c){this.model.mergeFolderToGroup(c,b.groupId,a.groupId);this.moveFolder(a,b,c)},separateFolder:function(a,b){var c=this.createCalendarView(this.model.separateFolderFromGroup(b,a.groupId));this.moveFolder(a,c,b)},updateActiveFolder:function(a){var b=this.model.getGroupings()[a.groupId];b&&b.active&&a.setSelectedFolder(a.getFolderById(b.active))},onCalendarActivate:function(a,b){this.model.activateFolderInGroup(b,a.groupId)},onCalendarMerge:function(a,b){for(var c=-1,d=0,e;e=this.calendars[d];d++)if(e==
a)c=d;if(!(c<1)){this.mergeFolder(a,this.calendars[c-1],b);this.sortCalendarViews(this.folders);this.layout()}},onCalendarSeparate:function(a,b){if(a.getFolders().length!=1){this.separateFolder(a,b);this.sortCalendarViews(this.folders);this.layout()}},onCalendarClose:function(a,b){this.fireEvent("calendarclose",b)}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.calendarmainpanel",layout:"zarafa.collapsible",items:[{xtype:"zarafa.searchbar",searchFields:Zarafa.calendar.data.SearchFields,context:a.context},{xtype:"zarafa.switchviewcontentcontainer",ref:"viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.calendarpaneltoolbar",defaultTitle:_("Calendar"),paging:container.populateInsertionPoint("context.calendar.toolbar.paging",
this),items:container.populateInsertionPoint("context.calendar.toolbar.item",this),context:a.context,model:a.context.getModel()}});Zarafa.calendar.ui.CalendarMainPanel.superclass.constructor.call(this,a)},initViews:function(a){var b=[{xtype:"zarafa.calendarblockpanel",id:"calendar_blocks",context:a},{xtype:"zarafa.calendargrid",id:"calendar_grid",context:a}];a=container.populateInsertionPoint("context.calendar.views",this,a);Ext.each(a,function(c){b.push(c)},this);return b},initEvents:function(){if(Ext.isDefined(this.context)){this.mon(this.context,
"viewchange",this.onViewChange,this);this.onViewChange(this.context,this.context.getCurrentView())}},onViewChange:function(a,b){switch(b){case Zarafa.calendar.data.Views.BLOCKS:default:this.viewPanel.switchView("calendar_blocks");break;case Zarafa.calendar.data.Views.LIST:case Zarafa.calendar.data.Views.SEARCH:this.viewPanel.switchView("calendar_grid");break}}});Ext.reg("zarafa.calendarmainpanel",Zarafa.calendar.ui.CalendarMainPanel);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarGridView=Ext.extend(Zarafa.common.ui.grid.GridPanel,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);a=Ext.applyIf(a,{xtype:"zarafa.calendargrid",overCls:"zarafa-calendar-grid-row-over",border:false,stateful:true,statefulRelativeDimensions:false,loadMask:this.initLoadMask(),
viewConfig:this.initViewConfig(),selModel:this.initSelectionModel(),colModel:this.initColumnModel(),enableDragDrop:true,ddGroup:"dd.mapiitem",keys:{key:Ext.EventObject.DELETE,handler:this.onKeyDelete,scope:this}});Zarafa.calendar.ui.CalendarGridView.superclass.constructor.call(this,a)},initViewConfig:function(){return{forceFit:false,getRowClass:this.getRowClass.createDelegate(this)}},initLoadMask:function(){return{msg:_("Loading appointments")+"..."}},initColumnModel:function(){return new Zarafa.calendar.ui.CalendarGridColumnModel},
initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false})},initEvents:function(){Zarafa.calendar.ui.CalendarGridView.superclass.initEvents.call(this);this.mon(this.model,"foldermergestatechanged",this.onFolderMergestateChanged,this);this.mon(this,"rowcontextmenu",this.onRowContextMenu,this);this.mon(this,"rowdblclick",this.onRowDblClick,this);this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},onFolderMergestateChanged:function(a,b){b?
a.clearGrouping():a.groupBy("parent_entryid")},onRowContextMenu:function(a,b,c){a=this.getSelectionModel();a.isSelected(b)||a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY())},onRowDblClick:function(a){Zarafa.calendar.Actions.openAppointmentDialog(a.getSelectionModel().getSelections())},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},onKeyDelete:function(){var a=this.getSelectionModel().getSelections();Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)},
getRowClass:function(a){return"zarafa-calendar-grid-row zarafa-calendar-grid-"+this.getRecordColorTheme(a)},getRecordColorTheme:function(a){return this.model.getFolder(a.get("parent_entryid")).getColorTheme()}});Ext.reg("zarafa.calendargrid",Zarafa.calendar.ui.CalendarGridView);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true}});Ext.apply(this,a);Zarafa.calendar.ui.CalendarGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[new Ext.ux.grid.CheckColumn({header:_("All Day"),dataIndex:"alldayevent",width:24,fixed:true}),{header:'<p class="icon_index">&nbsp;</p>',dataIndex:"icon_index",width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,
fixed:true},{header:'<p class="icon_recurring">&nbsp;</p>',dataIndex:"recurring",width:24,renderer:Zarafa.common.ui.grid.Renderers.recurrence,fixed:true},{header:_("Subject"),dataIndex:"subject",width:200,renderer:Zarafa.common.ui.grid.Renderers.subject},{header:_("Startdate"),dataIndex:"startdate",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime},{header:_("Enddate"),dataIndex:"duedate",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime},{header:_("Location"),dataIndex:"location",
width:200,renderer:Zarafa.common.ui.grid.Renderers.subject},{header:_("Duration"),dataIndex:"duration",width:160,renderer:Zarafa.common.ui.grid.Renderers.duration},{header:_("Meeting Status"),dataIndex:"meeting",width:160,renderer:Zarafa.common.ui.grid.Renderers.meetingstatus},{header:_("Busy Status"),dataIndex:"busystatus",width:160,renderer:Zarafa.common.ui.grid.Renderers.busystatus,hidden:true},{header:_("Categories"),dataIndex:"categories",width:160,renderer:Zarafa.common.ui.grid.Renderers.text,
hidden:true},{header:_("Created On"),dataIndex:"creation_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,hidden:true},{header:_("Due By"),dataIndex:"duedate",width:160,renderer:Zarafa.common.ui.grid.Renderers.dueBy,hidden:true},{header:_("Label"),dataIndex:"label",width:160,renderer:Zarafa.common.ui.grid.Renderers.label,hidden:true},{header:_("Required Attendee"),dataIndex:"display_to",hidden:true,renderer:Ext.util.Format.htmlEncode},{header:_("Optional Attendee"),dataIndex:"display_cc",
hidden:true,renderer:Ext.util.Format.htmlEncode},{header:_("Resource"),dataIndex:"display_bcc",hidden:true,renderer:Ext.util.Format.htmlEncode},{header:_("Recurring Startdate"),dataIndex:"startdate_recurring",width:160,renderer:Zarafa.common.ui.grid.Renderers.date,hidden:true},{header:_("Recurring Enddate"),dataIndex:"enddate_recurring",width:160,renderer:Zarafa.common.ui.grid.Renderers.date,hidden:true},{header:_("Recurring Pattern"),dataIndex:"recurring_pattern",width:400,renderer:Zarafa.common.ui.grid.Renderers.subject,
hidden:true},{header:_("Reminder"),dataIndex:"reminder",width:24,renderer:Zarafa.common.ui.grid.Renderers.reminder,fixed:true,hidden:true},{header:_("Sensitivity"),dataIndex:"sensitivity",width:160,renderer:Zarafa.common.ui.grid.Renderers.sensitivity,hidden:true},{header:_("Parent folder"),dataIndex:"parent_entryid",width:200,renderer:Zarafa.common.ui.grid.Renderers.folder,hidden:true}]}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{constructor:function(a){a=a||{};if(Ext.isDefined(a.records)&&!Ext.isArray(a.records))a.records=[a.records];a=Ext.applyIf(a,{items:[this.createContextActionItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.calendar.contextmenu.actions",this),{xtype:"menuseparator"},this.createContextOptionsItems(),{xtype:"menuseparator"},container.populateInsertionPoint("context.calendar.contextmenu.options",
this)]});Zarafa.calendar.ui.CalendarContextMenu.superclass.constructor.call(this,a)},createContextActionItems:function(){return[{xtype:"zarafa.conditionalitem",iconCls:"icon_create_appointment",text:_("New Appointment"),beforeShow:this.beforeShowPhantom,meetingRequest:false,handler:this.onCreate,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_create_meeting_request",text:_("New Meeting Request"),beforeShow:this.beforeShowPhantom,meetingRequest:true,handler:this.onCreate,scope:this},{xtype:"zarafa.conditionalitem",
iconCls:"icon_open",text:_("Open"),beforeShow:this.beforeShowNonPhantom,handler:this.onOpen,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_delete",text:_("Delete"),beforeShow:this.beforeShowNonPhantom,handler:this.onDelete,scope:this}]},createContextOptionsItems:function(){return[{xtype:"zarafa.conditionalitem",iconCls:"icon_categories",text:_("Categories"),beforeShow:this.beforeShowNonPhantom,handler:this.onCategories,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_busystatus",
text:_("Show as"),beforeShow:this.beforeShowNonPhantom,menu:{xtype:"zarafa.conditionalmenu",items:this.createBusyStatusItems()}},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel",text:_("Label"),beforeShow:this.beforeShowNonPhantom,menu:{xtype:"zarafa.conditionalmenu",items:this.createLabelItems()}}]},createBusyStatusItems:function(){return[{xtype:"zarafa.conditionalitem",iconCls:"icon_busystatus_free",text:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.FREE),
busyStatus:Zarafa.core.mapi.BusyStatus.FREE,handler:this.onSetBusyStatus,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_busystatus_tentative",text:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.TENTATIVE),busyStatus:Zarafa.core.mapi.BusyStatus.TENTATIVE,handler:this.onSetBusyStatus,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_busystatus_busy",text:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.BUSY),busyStatus:Zarafa.core.mapi.BusyStatus.BUSY,
handler:this.onSetBusyStatus,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_busystatus_outofoffice",text:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.OUTOFOFFICE),busyStatus:Zarafa.core.mapi.BusyStatus.OUTOFOFFICE,handler:this.onSetBusyStatus,scope:this}]},createLabelItems:function(){return[{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_none",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.NONE),labelValue:Zarafa.core.mapi.AppointmentLabels.NONE,
handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_important",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.IMPORTANT),labelValue:Zarafa.core.mapi.AppointmentLabels.IMPORTANT,handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_work",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.WORK),labelValue:Zarafa.core.mapi.AppointmentLabels.WORK,
handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_personal",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PERSONAL),labelValue:Zarafa.core.mapi.AppointmentLabels.PERSONAL,handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_holiday",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.HOLIDAY),labelValue:Zarafa.core.mapi.AppointmentLabels.HOLIDAY,
handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_required",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.REQUIRED),labelValue:Zarafa.core.mapi.AppointmentLabels.REQUIRED,handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_travel_required",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.TRAVEL_REQUIRED),labelValue:Zarafa.core.mapi.AppointmentLabels.TRAVEL_REQUIRED,
handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_prepare_required",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PREPARE_REQUIRED),labelValue:Zarafa.core.mapi.AppointmentLabels.PREPARE_REQUIRED,handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_birthday",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.BIRTHDAY),labelValue:Zarafa.core.mapi.AppointmentLabels.BIRTHDAY,
handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_special_date",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.SPECIAL_DATE),labelValue:Zarafa.core.mapi.AppointmentLabels.SPECIAL_DATE,handler:this.onSetLabel,scope:this},{xtype:"zarafa.conditionalitem",iconCls:"icon_appointmentlabel_phone_interview",text:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PHONE_INTERVIEW),labelValue:Zarafa.core.mapi.AppointmentLabels.PHONE_INTERVIEW,
handler:this.onSetLabel,scope:this}]},beforeShowPhantom:function(a,b){for(var c=false,d=0,e=b.length;d<e;d++)if(b[d].phantom===false)c=true;a.setVisible(!c)},beforeShowNonPhantom:function(a,b){for(var c=false,d=0,e=b.length;d<e;d++)if(b[d].phantom===true)c=true;a.setVisible(!c)},onCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.records,true)},onSetBusyStatus:function(a){var b=undefined,c=this.records;Ext.each(c,function(d){b=d.getStore();d.set("busystatus",a.busyStatus)},this);
b.save(c)},onSetLabel:function(a){var b=undefined,c=this.records;Ext.each(this.records,function(d){b=d.getStore();d.set("label",a.labelValue)},this);b.save(c)},onOpen:function(){Zarafa.calendar.Actions.openAppointmentDialog(this.records,this.model)},onDelete:function(){Zarafa.common.Actions.deleteRecords(this.records)},onCreate:function(a){a.meetingRequest?Zarafa.calendar.Actions.openMeetingRequestDialog(this.records,this.model):Zarafa.calendar.Actions.openAppointmentDialog(this.records,this.model)}});
Ext.reg("zarafa.calendarcontextmenu",Zarafa.calendar.ui.CalendarContextMenu);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AbstractDateRangeView=Ext.extend(Zarafa.core.ui.View,{headerClassName:"",bodyClassName:"",header:undefined,body:undefined,slot:undefined,slotCount:undefined,visible:true,dateRange:undefined,init:function(){Zarafa.calendar.ui.AbstractDateRangeView.superclass.init.call(this);this.body=[]},setDateRange:function(a){this.dateRange=a},getDateRange:function(){return this.dateRange},render:function(a){Zarafa.calendar.ui.AbstractDateRangeView.superclass.render.call(this,a);this.createHeader()},
getHeaderElement:function(){return Ext.get(this.header)},getFirstBodyElement:function(){return this.body[0]},getLastBodyElement:function(){return this.body[this.body.length-1]},setHeaderClass:function(a){this.headerClassName=a},setBodyClass:function(a){this.bodyClassName=a},eventOverBody:function(){return false},eventOverBodyStartHandle:function(){return false},eventOverBodyDueHandle:function(){return false},eventOverHeader:function(){return false},eventOverHeaderStartHandle:function(){return false},
eventOverHeaderDueHandle:function(){return false},setVisible:function(a){this.visible=a;for(var b=0,c=this.elements.length;b<c;b++)this.elements[b].setVisible(a)},isVisible:function(){return this.visible},layoutInHeader:function(){var a=this.parentView.dateRangeToHeaderBounds(this.dateRange,this.slot);this.header.dom.className=this.headerClassName;this.header.setLeftTop(a.left,a.top);this.header.setSize(a.right-a.left,a.bottom-a.top);return a},createHeader:function(){this.createDiv(this.parentView.getCalendarHeader(),
"header");this.mon(this.header,"contextmenu",this.onContextMenu,this);this.mon(this.header,"dblclick",this.onDoubleClick,this)},destroyHeader:function(){this.mun(this.header,"contextmenu",this.onContextMenu,this);this.mun(this.header,"dblclick",this.onDoubleClick,this);this.remove(this.header);this.header=undefined},createBodyElement:function(){var a=this.createDiv(this.parentView.getCalendarBody(),"body");this.mon(a,"contextmenu",this.onContextMenu,this);this.mon(a,"dblclick",this.onDoubleClick,
this);return a},destroyBodyElement:function(){var a=this.body.pop();this.mun(a,"contextmenu",this.onContextMenu,this);this.mun(a,"dblclick",this.onDoubleClick,this);this.remove(a)},destroyBodyElements:function(){for(;this.body.length>0;)this.destroyBodyElement()},layoutBodyElements:function(a){for(var b=0;b<a.length;b++){this.body[b].dom.className=this.bodyClassName;this.body[b].setLeftTop(a[b].left,a[b].top);this.body[b].setSize(a[b].right-a[b].left,a[b].bottom-a[b].top)}},layoutInBody:function(){for(var a=
this.parentView.dateRangeToBodyBounds(this.dateRange);this.body.length<a.length;)this.createBodyElement();for(;this.body.length>a.length;)this.destroyBodyElement();this.layoutBodyElements(a)},onLayout:function(){if(this.visible)if(this.isHeaderRange()){Ext.isDefined(this.body)&&this.destroyBodyElements();this.layoutInHeader()}else{Ext.isDefined(this.header)&&this.destroyHeader();this.layoutInBody()}Zarafa.calendar.ui.AbstractDateRangeView.superclass.onLayout.call(this)},isHeaderRange:function(){return this.parentView.isHeaderRange(this.getDateRange())},
onContextMenu:function(a){this.parentView.fireEvent("contextmenu",a)},onDoubleClick:function(a){this.parentView.fireEvent("dblclick",a)}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AbstractCalendarView=Ext.extend(Zarafa.core.ui.View,{rangeSelectionModel:undefined,selectionModel:undefined,folders:undefined,selectedFolder:undefined,tabs:undefined,selectionView:undefined,textEditView:undefined,appointments:undefined,leftOffset:0,width:0,appointmentBodyLeftMargin:0,appointmentBodyRightMargin:8,appointmentHeaderLeftMargin:6,appointmentHeaderRightMargin:6,body:undefined,header:undefined,headerBorderLeft:undefined,headerBorderRight:undefined,borderLeft:undefined,
borderRight:undefined,borderTop:undefined,borderBottom:undefined,tabArea:undefined,enableDD:false,enableDrag:false,enableDrop:false,ddGroup:"AppointmentDD",bodyDragZone:undefined,bodyDragConfig:undefined,bodyDropZone:undefined,bodyDropConfig:undefined,headerDragZone:undefined,headerDragConfig:undefined,headerDropZone:undefined,headerDropConfig:undefined,groupId:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",themeCls:Zarafa.calendar.ui.ColorSchemes[0].name});this.addEvents("appointmentcalendardrop",
"appointmentmove","appointmentresize","appointmentcreate","contextmenu","dblclick","dayclick","activate","merge","separate","close");Zarafa.calendar.ui.AbstractCalendarView.superclass.constructor.call(this,a)},init:function(){Zarafa.calendar.ui.AbstractCalendarView.superclass.init.call(this);this.folders=[];this.tabs={};this.appointments=[];this.selectionView=new Zarafa.calendar.ui.AppointmentProxy({showTime:true});this.selectionView.setVisible(false);this.addChildView(this.selectionView);this.textEditView=
new Zarafa.calendar.ui.TextEditView;this.mon(this.textEditView,"textentered",this.onTextEntered,this);this.addChildView(this.textEditView);this.mon(this.selectionModel,"appointmentselect",this.onAppointmentSelect,this);this.mon(this.selectionModel,"appointmentdeselect",this.onAppointmentDeselect,this);this.mon(this.selectionModel,"selectionclear",this.onAppointmentSelectionClear,this);this.mon(this.rangeSelectionModel,"selectionchange",this.onRangeSelectionChange,this)},addFolder:function(a){this.folders.push(a);
var b=new Zarafa.calendar.ui.CalendarTabView({parentView:this,folder:a});this.mon(b,"merge",this.onTabMerge,this);this.mon(b,"separate",this.onTabSeparate,this);this.mon(b,"close",this.onTabClose,this);this.mon(b,"click",this.onTabClick,this);this.rendered&&b.render(this.container);this.tabs[a.get("entryid")]=b;this.selectedFolder||this.setSelectedFolder(a)},removeFolder:function(a){return this.removeFolderById(a.get("entryid"))},removeFolderById:function(a){this.folders.remove(this.getFolderById(a));
var b=this.tabs[a];this.mun(b,"merge",this.onTabMerge,this);this.mun(b,"separate",this.onTabSeparate,this);this.mun(b,"close",this.onTabClose,this);this.mun(b,"click",this.onTabClick,this);this.removeChildView(b,true);delete this.tabs[a]},getFolderIds:function(){for(var a=[],b=0,c;c=this.folders[b];b++)a[b]=c.get("entryid");return a},getFolderById:function(a){for(var b=0,c;c=this.folders[b];b++)if(Zarafa.core.EntryId.compareEntryIds(c.get("entryid"),a))return c},getFolders:function(){return this.folders},
setSelectedFolder:function(a){this.selectedFolder=a;this.rendered&&this.layout()},getSelectedFolder:function(){return this.selectedFolder},containsFolder:function(a){return this.containsFolderId(a.get("entryid"))},containsFolderId:function(a){return Ext.isDefined(this.getFolderById(a))},sortFolders:function(a){for(var b=[],c=0,d;d=a[c];c++)this.containsFolderId(d.get("entryid"))&&b.push(d);this.folders=b},getDateRange:function(){return this.parentView.getDateRange()},getStartDate:function(){return this.getDateRange().getStartDate()},
getDueDate:function(){return this.getDateRange().getDueDate()},getDesiredHeaderHeight:function(){return 0},getTabHeight:function(){return this.parentView.getTabHeight()},findAppointment:function(a){for(var b=0,c;c=this.appointments[b];b++)if(c.getRecord().equals(a))return c},containsAppointment:function(a){return Ext.isDefined(this.findAppointment(a))},createAppointment:Ext.emptyFn,addAppointment:function(a,b){var c=this.createAppointment(a);c.render(this.container);this.appointments.push(c);b!==
false&&this.layout()},removeAppointment:function(a,b){var c;if(c=this.findAppointment(a)){this.appointments.remove(c);this.removeChildView(c,true);b!==false&&this.layout();return true}return false},clearAppointments:function(a,b){for(var c=0,d;d=this.appointments[c];c++)this.removeChildView(d,a);c=this.appointments;this.appointments=[];b!==false&&this.layout();return c},getAppointmentRecords:function(){for(var a=[],b=0,c;c=this.appointments[b];b++)a.push(c.getRecord());return a},dateRangeToBodyBounds:function(){return[]},
dateRangeToHeaderBounds:function(){return{left:0,right:0,top:0,bottom:0}},isHeaderRange:function(){return false},setLeftMargin:function(a){this.leftOffset=a},setWidth:function(a){this.width=a},setCanMerge:function(a){this.canMerge=a},setCanClose:function(a){this.canClose=a},screenLocationToDate:Ext.emptyFn,getBorderWidth:function(){return this.parentView.getBorderWidth()},getZoomLevel:function(){return this.parentView.zoomLevel},getCalendarBody:function(){return this.body},getCalendarHeader:function(){return this.header},
appointmentCompare:function(a,b){var c=a.getDateRange().compare(b.getDateRange());return c==0?a.getRecord().get("entryid")>b.getRecord().get("entryid")?1:-1:c},doGreedyColoring:function(a,b){a.sort(this.appointmentCompare);var c=[];if(b)Ext.each(a,function(g){var h=this.getDateRange().getStartTime();c.push({appointment:g,start:Math.floor((g.getDateRange().getStartTime()-h)/Date.dayInMillis),due:Math.ceil((g.getDateRange().getDueTime()-h)/Date.dayInMillis)})},this);else{this.getZoomLevel();Ext.each(a,
function(g){c.push({appointment:g,start:g.getAdjustedDateRange().getStartTime(),due:g.getAdjustedDateRange().getDueTime()})})}for(var d=0;c.length>0;){var e=c.shift();e.appointment.slot=d;e=e.due;for(var f=0;f<c.length;f++)if(c[f].start>=e){c[f].appointment.slot=d;e=c[f].due;c.splice(f,1);f--}d++}Ext.each(a,function(g){g.slotCount=d})},render:function(a){if(!this.rendered){this.createDiv(this.parentView.scrollable,"body");this.createDiv(this.parentView.header,"header");this.mon(this.body,"contextmenu",
this.onBodyContextMenu,this);this.mon(this.header,"contextmenu",this.onHeaderContextMenu,this);this.createDiv(this.parentView.header,"headerBorderLeft");this.createDiv(this.parentView.header,"headerBorderRight");this.createDiv(this.parentView.scrollable,"borderLeft");this.createDiv(this.parentView.scrollable,"borderRight");this.createDiv(this.parentView.tab,"borderTop");this.createDiv(this.parentView.bottom,"borderBottom");this.createDiv(this.parentView.tab,"tabArea");Zarafa.calendar.ui.AbstractCalendarView.superclass.render.call(this,
a);this.renderChildren();this.mon(this.selectionView,"keypress",this.onKeyPress,this);this.mon(this.selectionView,"keydown",this.onKeyPress,this);if(this.enableDD||this.enableDrag){if(!this.bodyDragZone&&this.body)this.bodyDragZone=new Zarafa.calendar.ui.CalendarViewDragZone(this,this.bodyDragConfig||{ddGroup:this.ddGroup||"AppointmentDD",headerMode:false});if(!this.headerDragZone&&this.header)this.headerDragZone=new Zarafa.calendar.ui.CalendarViewDragZone(this,this.headerDragConfig||{ddGroup:this.ddGroup||
"AppointmentDD",headerMode:true})}if(this.enableDD||this.enableDrop){if(!this.bodyDropZone&&this.body){this.bodyDropZone=new Zarafa.calendar.ui.CalendarViewDropZone(this,this.bodyDropConfig||{ddGroup:this.ddGroup||"AppointmentDD",headerMode:false,snapMode:Zarafa.calendar.data.SnapModes.ZOOMLEVEL});this.bodyDropZone.proxy=this.selectionView}if(!this.headerDropZone&&this.header){this.headerDropZone=new Zarafa.calendar.ui.CalendarViewDropZone(this,this.headerDropConfig||{ddGroup:this.ddGroup||"AppointmentDD",
headerMode:true,snapMode:Zarafa.calendar.data.SnapModes.DAY});this.headerDropZone.proxy=this.selectionView}}}},onKeyPress:function(a){if(Ext.form.VTypes.alphanum(String.fromCharCode(a.getKey())))if(this.rangeSelectionModel.isActive()&&this.rangeSelectionModel.getCalendarView()==this&&!this.textEditView.isVisible()){a=this.rangeSelectionModel.getDateRange();this.rangeSelectionModel.clearSelections();this.textEditView.setDateRange(a);this.textEditView.select()}},onTextEntered:function(a,b){Ext.isEmpty(b.trim())||
this.fireEvent("appointmentcreate",this,a.getDateRange(),b)},layoutBorder:function(){if(this.parentView.showBorder){var a=this.container.getHeight()-this.parentView.tabAreaHeight;this.borderTop.dom.className=this.getClassName("border","top");this.borderTop.setLeftTop(this.leftOffset,this.parentView.tab.getHeight()-this.getBorderWidth());this.borderTop.setSize(this.width,this.getBorderWidth());this.borderTop.show();this.headerBorderLeft.dom.className=this.getClassName("border","left");this.headerBorderLeft.setLeftTop(this.leftOffset,
0);this.headerBorderLeft.setSize(this.getBorderWidth(),a);this.headerBorderLeft.show();this.headerBorderRight.dom.className=this.getClassName("border","right");this.headerBorderRight.setLeftTop(this.leftOffset+this.width-this.getBorderWidth(),0);this.headerBorderRight.setSize(this.getBorderWidth(),a);this.headerBorderRight.show();this.borderLeft.dom.className=this.getClassName("border","left");this.borderLeft.setLeftTop(this.leftOffset,0);this.borderLeft.setSize(this.getBorderWidth(),this.parentView.getHourHeight()*
this.parentView.numHours);this.borderLeft.show();this.borderRight.dom.className=this.getClassName("border","right");this.borderRight.setLeftTop(this.leftOffset+this.width-this.getBorderWidth(),0);this.borderRight.setSize(this.getBorderWidth(),this.parentView.getHourHeight()*this.parentView.numHours);this.borderRight.show();this.borderBottom.dom.className=this.getClassName("border","bottom");this.borderBottom.setLeftTop(this.leftOffset,0);this.borderBottom.setSize(this.width,this.getBorderWidth());
this.borderBottom.show()}else{this.borderTop.hide();this.headerBorderLeft.hide();this.headerBorderRight.hide();this.borderLeft.hide();this.borderRight.hide();this.borderBottom.hide()}},layoutTabs:function(){for(var a=0,b=0,c=0,d;d=this.folders[c];c++){var e=this.tabs[d.get("entryid")];e.setSelected(this.selectedFolder==d);e.setShowMergeIcon(this.canMerge);e.setShowSeparateIcon(this.folders.length>1);e.setShowCloseIcon(this.canClose);b+=e.getDesiredWidth()}var f=0;if(b>this.width)f=Math.ceil((b-this.width)/
this.folders.length);for(c=0;d=this.folders[c];c++){e=this.tabs[d.get("entryid")];b=Math.max(e.getMinimumWidth(),e.getDesiredWidth()-f);e.setBottomMargin(this.borderTop.getHeight());e.setLeftMargin(a);e.setWidth(b);e.themeCls=d.getColorTheme();a+=b}},onLayout:function(){if(this.selectedFolder){this.themeCls=this.selectedFolder.getColorTheme();this.colorScheme=this.selectedFolder.getColorScheme()}this.layoutBorder();var a=this.parentView.getHourHeight()*this.parentView.numHours;this.body.dom.className=
this.getClassName("container","body");this.body.setLeftTop(this.leftOffset+this.getBorderWidth(),0);this.body.setSize(this.width-this.getBorderWidth()*2,a);this.header.dom.className=this.getClassName("container","header");this.header.setLeftTop(this.leftOffset+this.getBorderWidth(),0);this.header.setSize(this.width-this.getBorderWidth()*2,this.parentView.getHeaderAreaHeight());this.tabArea.dom.className=this.getClassName("container","tabarea");this.tabArea.setLeftTop(this.leftOffset,0);this.tabArea.setSize(this.width,
this.parentView.getTabAreaHeight());this.parentView.showBorder?this.tabArea.show():this.tabArea.hide();a=0;for(var b;b=this.appointments[a];a++){var c=this.getFolderById(b.getRecord().get("parent_entryid"));b.themeCls=c.getColorTheme();b.colorScheme=c.getColorScheme();b.setActive(c==this.selectedFolder)}Zarafa.calendar.ui.AbstractCalendarView.superclass.onLayout.call(this);this.layoutTabs()},onAfterLayout:function(){this.layoutChildren()},onBodyContextMenu:function(a){var b=a.getXY(),c=this.screenLocationToDate(b[0],
b[1]);b=this.getZoomLevel()*60*1E3;c=c.getTime()-c.getTime()%b;this.rangeSelectionModel.set(new Zarafa.core.DateRange({startDate:new Date(c),dueDate:new Date(c+b)}),this);this.fireEvent("contextmenu",a)},onHeaderContextMenu:function(a){var b=a.getXY();b=this.screenLocationToDate(b[0],b[1]).clearTime();this.rangeSelectionModel.set(new Zarafa.core.DateRange({startDate:b,dueDate:b.add(Date.DAY,1)}),this);this.fireEvent("contextmenu",a)},beforeAppointmentsLoad:function(){this.clearAppointments(true)},
onAppointmentsLoad:function(a,b){this.clearAppointments(true);Ext.each(b,function(c){this.containsFolderId(c.get("parent_entryid"))&&c.isValid()&&this.addAppointment(c,false)},this)},onAppointmentAdd:function(a,b){this.containsFolderId(b.get("parent_entryid"))&&!this.containsAppointment(b)&&b.isValid()&&this.addAppointment(b)},onAppointmentRemove:function(a,b){this.containsAppointment(b)&&this.removeAppointment(b)},onAppointmentUpdate:function(a,b){var c=this.findAppointment(b);if(c){var d=c.getDateRange();
if(d.getStartDate()!==b.get("startdate")||d.getDueDate()!==b.get("duedate")){c.updateDateRange(b);this.layout()}else c.layout()}},onAppointmentSelect:function(a,b){var c=this.findAppointment(b);this.textEditView.isVisible()&&this.textEditView.hide();c&&c.setSelected(true)},onAppointmentDeselect:function(a,b){var c=this.findAppointment(b);this.textEditView.isVisible()&&this.textEditView.hide();c&&c.setSelected(false)},onAppointmentSelectionClear:function(){this.textEditView.isVisible()&&this.textEditView.hide();
for(var a=0,b=this.appointments.length;a<b;a++)this.appointments[a].setSelected(false)},onRangeSelectionChange:function(a,b,c,d){if(this.selectionView){this.textEditView.isVisible()&&this.textEditView.hide();if(d&&c==this){this.selectionView.setDateRange(b);this.selectionView.setVisible(true);this.selectionView.layout()}else if(this.selectionView.isVisible()){this.selectionView.setVisible(false);this.selectionView.layout()}}},onTabMerge:function(a){this.fireEvent("merge",this,a)},onTabSeparate:function(a){this.fireEvent("separate",
this,a)},onTabClose:function(a){this.fireEvent("close",this,a)},onTabClick:function(a){this.setSelectedFolder(a);this.fireEvent("activate",this,a)},getDragDropText:function(){var a=this.selectionModel.getCount();return String.format(ngettext("{0} selected item","{0} selected items",a),a)},onDrop:function(a,b,c,d){this.fireEvent("appointmentcalendardrop",this,b,c.getRecord(),d,a);this.selectionModel.clearSelections()},onMove:function(a,b,c){this.fireEvent("appointmentmove",this,b.getRecord(),c,a);
this.selectionModel.clearSelections()},onResize:function(a,b,c){this.fireEvent("appointmentresize",this,b.getRecord(),c,a);this.selectionModel.clearSelections()},onMouseDown:function(a,b){if(b){var c=b.getRecord();if(a.ctrlKey)this.selectionModel.isSelected(c)?this.selectionModel.deselectRecord(c):this.selectionModel.selectRecord(c,true);else this.selectionModel.selectRecord(c,false);this.rangeSelectionModel.clearSelections()}else{this.selectionModel.clearSelections();c=a.getXY();c=this.screenLocationToDate(c[0],
c[1]).clearTime();this.rangeSelectionModel.set(new Zarafa.core.DateRange({startDate:c,dueDate:c.add(Date.DAY,1)}),this)}},onMouseUp:function(a,b){if(b&&(b.isAllDay()?b.eventOverHeader(a):b.eventOverBody(a)))this.selectionModel.deselectRecord(b.getRecord())},onSelect:function(a,b){this.rangeSelectionModel.set(b,this)},destroy:function(){Ext.destroy(this.bodyDragZone,this.bodyDropZone);Ext.destroy(this.headerDragZone,this.headerDropZone);Zarafa.calendar.ui.AbstractCalendarView.superclass.destroy.call(this)}});
Ext.namespace("Zarafa.calendar.settings");
Zarafa.calendar.settings.SettingsReminderWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Reminder settings"),layout:"form",items:[{xtype:"checkbox",ref:"reminderCheck",boxLabel:_("Enable reminder for new appointments"),hideLabel:true,name:"zarafa/v1/contexts/calendar/default_reminder",listeners:{check:this.onReminderCheck,scope:this}},{xtype:"combo",ref:"timeCombo",fieldLabel:_("Default reminder time"),name:"zarafa/v1/contexts/calendar/default_reminder_time",
store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.ReminderPeriods},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}},{xtype:"combo",ref:"alldayTimeCombo",fieldLabel:_("Default all-day appointment reminder time"),name:"zarafa/v1/contexts/calendar/default_allday_reminder_time",store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.ReminderPeriods},
mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}}]});Zarafa.calendar.settings.SettingsReminderWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;var b=a.get(this.reminderCheck.name);this.reminderCheck.setValue(b);this.timeCombo.setValue(a.get(this.timeCombo.name));this.alldayTimeCombo.setValue(a.get(this.alldayTimeCombo.name));this.timeCombo.setDisabled(!b);
this.alldayTimeCombo.setDisabled(!b)},updateSettings:function(a){a.beginEdit();a.set(this.reminderCheck.name,this.reminderCheck.getValue());a.set(this.timeCombo.name,this.timeCombo.getValue());a.set(this.alldayTimeCombo.name,this.alldayTimeCombo.getValue());a.endEdit()},onReminderCheck:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b);this.timeCombo.setDisabled(!b);this.alldayTimeCombo.setDisabled(!b)},onFieldSelect:function(a,b){if(this.model){var c=b.get(a.valueField);
this.model.get(a.name)!==c&&this.model.set(a.name,c)}}});Ext.reg("zarafa.settingsreminderwidget",Zarafa.calendar.settings.SettingsReminderWidget);Ext.namespace("Zarafa.calendar.settings");
Zarafa.calendar.settings.SettingsOverlayWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b={xtype:"jsonstore",fields:["name","value"],data:[{name:_("Side-by-side mode"),value:"separate"},{name:_("Overlay mode"),value:"merge"}]};Ext.applyIf(a,{title:_("Calendar view settings"),layout:"form",items:[{xtype:"combo",ref:"overlayCombo",fieldLabel:_("View multiple calendars in"),name:"zarafa/v1/contexts/calendar/default_merge_state",store:b,mode:"local",triggerAction:"all",
displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onOpenMethodSelect,scope:this}}]});Zarafa.calendar.settings.SettingsCalendarWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.overlayCombo.setValue(a.get(this.overlayCombo.name)?"merge":"separate")},updateSettings:function(a){a.set(this.overlayCombo.name,this.overlayCombo.getValue()==="merge")},onOpenMethodSelect:function(a,b){if(this.model){var c=
b.get(a.valueField);this.model.get(a.name)!==c&&this.model.set(a.name,c==="merge")}}});Ext.reg("zarafa.settingsoverlaywidget",Zarafa.calendar.settings.SettingsOverlayWidget);Ext.namespace("Zarafa.calendar.settings");
Zarafa.calendar.settings.SettingsCalendarWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};for(var b=[],c=0,d=Date.dayNames.length;c<d;c++)b.push({name:Date.dayNames[c],value:c});b={xtype:"jsonstore",fields:["name","value"],data:b};c={xtype:"jsonstore",fields:["name","value"],data:[{value:5,name:Ext.util.Format.duration(5)},{value:6,name:Ext.util.Format.duration(6)},{value:10,name:Ext.util.Format.duration(10)},{value:15,name:Ext.util.Format.duration(15)},{value:30,
name:Ext.util.Format.duration(30)},{value:60,name:Ext.util.Format.duration(60)}]};Ext.applyIf(a,{title:_("General calendar settings"),layout:"form",items:[{xtype:"combo",ref:"weekStartCombo",fieldLabel:_("First day of the week"),name:"zarafa/v1/main/week_start",store:b,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}},{xtype:"zarafa.timeperiodfield",ref:"workingHourPeriod",
defaultValue:new Zarafa.core.DateRange,defaultPeriod:1,defaultPeriodType:Date.HOUR,labelWidth:200,startFieldConfig:{fieldLabel:_("Start of workday"),name:"zarafa/v1/main/start_working_hour",incrementValue:30,alternateIncrementValue:1,minValue:(new Date).clearTime(),maxValue:(new Date).clearTime().add(Date.HOUR,23)},endFieldConfig:{fieldLabel:_("End of workday"),name:"zarafa/v1/main/end_working_hour",incrementValue:30,alternateIncrementValue:1,minValue:(new Date).clearTime().add(Date.HOUR,1),maxValue:(new Date).clearTime().add(Date.HOUR,
24)},listeners:{change:this.onWorkTimeChange,scope:this}},{xtype:"combo",ref:"zoomLevelCombo",fieldLabel:_("Calendar resolution"),name:"zarafa/v1/contexts/calendar/default_zoom_level",store:c,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,autoSelect:true,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}},{xtype:"checkbox",ref:"boldCheck",boxLabel:_("Show busy dates as bold in the date picker"),hideLabel:true,name:"zarafa/v1/contexts/calendar/datepicker_show_busy",
listeners:{check:this.onBoldCheck,scope:this}}]});Zarafa.calendar.settings.SettingsCalendarWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;var b=(new Date).clearTime();b=b.add(Date.MINUTE,a.get(this.workingHourPeriod.startField.name));var c=(new Date).clearTime();c=c.add(Date.MINUTE,a.get(this.workingHourPeriod.endField.name));this.workingHourPeriod.getValue().set(b,c);this.weekStartCombo.setValue(a.get(this.weekStartCombo.name));this.zoomLevelCombo.setValue(a.get(this.zoomLevelCombo.name));
this.boldCheck.setValue(a.get(this.boldCheck.name))},updateSettings:function(a){var b=this.workingHourPeriod.getValue(),c=b.getStartDate();c=c.getHours()*60+c.getMinutes();b=b.getDueDate();b=b.getHours()*60+b.getMinutes();a.beginEdit();a.set(this.workingHourPeriod.startField.name,c);a.set(this.workingHourPeriod.endField.name,b);a.set(this.weekStartCombo.name,this.weekStartCombo.getValue());a.set(this.zoomLevelCombo.name,this.zoomLevelCombo.getValue());a.set(this.boldCheck.name,this.boldCheck.getValue());
a.endEdit()},onFieldSelect:function(a,b){if(this.model){var c=b.get(a.valueField);this.model.get(a.name)!==c&&this.model.set(a.name,c)}},onWorkTimeChange:function(a,b){if(this.model){var c=b.getStartDate();c=c.getHours()*60+c.getMinutes();var d=b.getDueDate();d=d.getHours()*60+d.getMinutes();this.model.set(this.workingHourPeriod.startField.name,c);this.model.set(this.workingHourPeriod.endField.name,d)}},onBoldCheck:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)}});
Ext.reg("zarafa.settingscalendarwidget",Zarafa.calendar.settings.SettingsCalendarWidget);Ext.namespace("Zarafa.calendar.settings");
Zarafa.calendar.settings.SettingsCalendarCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Calendar"),categoryIndex:2,iconCls:"zarafa-settings-category-calendar",items:[{xtype:"zarafa.settingscalendarwidget"},{xtype:"zarafa.settingsoverlaywidget"},{xtype:"zarafa.settingsreminderwidget"},container.populateInsertionPoint("context.settings.category.calendar",this)]});Zarafa.calendar.settings.SettingsCalendarCategory.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.settingscalendarcategory",Zarafa.calendar.settings.SettingsCalendarCategory);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestConfirmationDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,responseType:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestconfirmdialog",layout:"fit",title:_("Send Meeting Request Confirmation"),modal:true,width:350,height:250,items:[{xtype:"zarafa.sendmeetingrequestconfirmpanel",record:a.record,responseType:a.responseType,ref:"sendMRConfirmationPanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},
{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.calendar.dialogs.SendMeetingRequestConfirmationDialog.superclass.constructor.call(this,a)},onOk:function(){this.sendMRConfirmationPanel.updateRecord(this.record);this.close()},onCancel:function(){this.close()}});Zarafa.core.ui.Dialog.register(Zarafa.calendar.dialogs.SendMeetingRequestConfirmationDialog,"zarafa.sendmeetingrequestconfirmdialog");Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestCancellationDialog=Ext.extend(Zarafa.core.ui.Dialog,{record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestcancellationdialog",layout:"fit",title:_("Send Meeting Request Cancellation"),modal:true,width:350,height:250,items:[{xtype:"zarafa.sendmeetingrequestcancellationpanel",record:a.record,ref:"sendMRCancellationPanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,
scope:this}]}]});Zarafa.calendar.dialogs.SendMeetingRequestCancellationDialog.superclass.constructor.call(this,a)},onOk:function(){this.sendMRCancellationPanel.updateRecord(this.record);this.close()},onCancel:function(){this.close()}});Zarafa.core.ui.Dialog.register(Zarafa.calendar.dialogs.SendMeetingRequestCancellationDialog,"zarafa.sendmeetingrequestcancellationdialog");Ext.namespace("Zarafa.calendar.data.busytime");
Zarafa.calendar.data.busytime.BusyTimeProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};Ext.applyIf(a,{listModuleName:Zarafa.core.ModuleNames.getListName("busytime")});Zarafa.calendar.data.busytime.BusyTimeProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.calendar.data.busytime.BusyTimeResponseHandler({proxy:this,action:c,reader:f,options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.DayLayoutPosition=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},left:0,right:0,date:undefined,today:false,workingDay:false});Ext.namespace("Zarafa.calendar.data");Zarafa.calendar.data.DayBoxConfiguration=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},left:0,right:0,top:0,bottom:0,date:undefined,today:false,workingDay:false,busyStatus:undefined,overflow:false,active:false});Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.AppointmentBounds=Ext.extend(Object,{constructor:function(a){Ext.apply(this,a)},left:0,right:0,top:0,bottom:0,firstBox:false,lastBox:false});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.GABPersonalColumnModel=Ext.extend(Ext.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',sortable:true,tooltip:_("Sort by: Icon"),width:25,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"display_name",id:"displayname",header:_("Display Name"),sortable:true,tooltip:_("Sort by: Display Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"fileas",header:_("File as"),
sortable:true,tooltip:_("Sort by: File As"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"email_address",header:_("Email Address"),sortable:true,hidden:false,tooltip:_("Sort by: Email Address"),renderer:Ext.util.Format.htmlEncode,width:150}]});Zarafa.addressbook.ui.GABPersonalColumnModel.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.GABColumnModel=Ext.extend(Ext.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:[{dataIndex:"icon_index",header:'<p class="icon_index">&nbsp;</p>',sortable:true,tooltip:_("Sort by: Icon"),width:25,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"display_name",id:"displayname",header:_("Display Name"),sortable:true,tooltip:_("Sort by: Display Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"fileas",header:_("File as"),sortable:true,
tooltip:_("Sort by: File As"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"email_address",header:_("Email Address"),sortable:true,hidden:false,tooltip:_("Sort by: Email Address"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"smtp_address",header:_("SMTP Address"),sortable:true,hidden:false,tooltip:_("Sort by: SMTP Address"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"department_name",header:_("Department"),sortable:true,hidden:false,tooltip:_("Sort by: Department"),
renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"office_telephone_number",header:_("Office Phone"),sortable:true,tooltip:_("Sort by: Office Phone"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"office_location",header:_("Location"),sortable:true,tooltip:_("Sort by: Location"),renderer:Ext.util.Format.htmlEncode,width:150,hidden:true},{dataIndex:"primary_fax_number",header:_("Fax"),sortable:true,tooltip:_("Sort by: Fax"),renderer:Ext.util.Format.htmlEncode,width:150}]});Zarafa.addressbook.ui.GABColumnModel.superclass.constructor.call(this,
a)}});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookViewPanel=Ext.extend(Zarafa.common.ui.grid.GridPanel,{singleSelect:false,constructor:function(a){a=a||{};Ext.applyIf(a,{autoExpandColumn:"displayname",autoExpandMin:100,loadMask:true,sm:this.createSelectionModel(a),cm:new Zarafa.addressbook.ui.GABColumnModel,view:new Ext.ux.grid.BufferView({scrollDelay:false})});Zarafa.addressbook.ui.AddressBookViewPanel.superclass.constructor.call(this,a);this.mon(this.getStore(),"load",this.onStoreLoad,this)},onStoreLoad:function(a,
b,c){c&&c.params&&c.params.subActionType==="globaladdressbook"?this.reconfigure(a,new Zarafa.addressbook.ui.GABColumnModel):this.reconfigure(a,new Zarafa.addressbook.ui.GABPersonalColumnModel)},createSelectionModel:function(a){return new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:a.singleSelect})},getSelectedItems:function(){return this.getSelectionModel().getSelections()}});Ext.reg("zarafa.addressbookviewpanel",Zarafa.addressbook.ui.AddressBookViewPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookPanel=Ext.extend(Zarafa.addressbook.ui.AddressBookMainPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.addressbookpanel"});Zarafa.addressbook.ui.AddressBookPanel.superclass.constructor.call(this,a)},onAfterLayout:function(){Zarafa.addressbook.ui.AddressBookPanel.superclass.onAfterLayout.apply(this,arguments);this.mon(this.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,this);this.mon(this.getGridPanel(),"rowcontextmenu",this.onAddressBookRowContextMenu,
this)},onAddressBookRowDblClick:function(a,b){var c=a.getStore().getAt(b);Zarafa.addressbook.Actions.openDetailsDialog(c,this.dialog.isBrowser())},onAddressBookRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.getSelections();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY(),{dialog:this.dialog})}});Ext.reg("zarafa.addressbookpanel",Zarafa.addressbook.ui.AddressBookPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{enableSelect:false,selectHandler:undefined,selectScope:undefined,dialog:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{items:[{xtype:"zarafa.conditionalitem",text:_("Select"),beforeShow:function(b){b.setDisabled(!this.enableSelect)},handler:this.onSelect,scope:this},{xtype:"zarafa.conditionalitem",text:_("Show Details"),singleSelectOnly:true,handler:this.onOpenDetails,scope:this},{xtype:"zarafa.conditionalitem",
text:_("Email Message"),beforeShow:function(b){b.setDisabled(this.enableSelect)},handler:this.onEmailRecipient,scope:this},{xtype:"menuseparator"},container.populateInsertionPoint("context.addressbook.contextmenu.actions",this)]});Zarafa.addressbook.ui.AddressBookContextMenu.superclass.constructor.call(this,a)},onSelect:function(){if(Ext.isFunction(this.selectHandler))this.selectHandler.call(this.selectScope||this,this.records)},onOpenDetails:function(){Zarafa.addressbook.Actions.openDetailsDialog(this.records,
this.dialog?this.dialog.isBrowser():undefined)},onEmailRecipient:function(){Zarafa.addressbook.Actions.openMailDialog(this.records,this.dialog?this.dialog.isBrowser():undefined)}});Ext.reg("zarafa.addressbookcontextmenu",Zarafa.addressbook.ui.AddressBookContextMenu);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.ABUserSelectionPanel=Ext.extend(Zarafa.addressbook.ui.AddressBookMainPanel,{callback:Ext.emptyFn,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abuserselectionpanel",buttons:[{text:_("Ok"),handler:this.onSubmit,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]});Zarafa.addressbook.ui.ABUserSelectionPanel.superclass.constructor.call(this,a)},doCallBack:function(){var a=this.getGridPanel();if(a.getSelectionModel().hasSelection()){this.callback(a.getSelectionModel().getSelections()[0]);
return true}},onAfterLayout:function(){Zarafa.addressbook.ui.ABUserSelectionPanel.superclass.onAfterLayout.apply(this,arguments);this.mon(this.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,this)},onAddressBookRowDblClick:function(){this.doCallBack();this.dialog.close()},onSubmit:function(){this.doCallBack()===true?this.dialog.close():Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You must select a user."),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})},onCancel:function(){this.dialog.close()}});
Ext.reg("zarafa.abuserselectionpanel",Zarafa.addressbook.ui.ABUserSelectionPanel);Ext.namespace("Zarafa.addressbook.dialog");
Zarafa.addressbook.dialog.MemberSelectionPanel=Ext.extend(Zarafa.addressbook.ui.AddressBookMainPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.memberselectionpanel",items:[{xtype:"zarafa.addressbookmemberpanel",ref:"memberPanel"}]});Zarafa.addressbook.dialog.MemberSelectionPanel.superclass.constructor.call(this,a)},onAfterLayout:function(){Zarafa.addressbook.dialog.MemberSelectionPanel.superclass.onAfterLayout.apply(this,arguments);this.mon(this.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,
this);this.mon(this.getGridPanel(),"rowcontextmenu",this.onAddressBookRowContextMenu,this)},onAddressBookRowDblClick:function(a,b){this.memberPanel.addMembers(a.getStore().getAt(b))},onAddressBookRowContextMenu:function(a,b,c){a=a.getSelectionModel();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY(),{enableSelect:true,selectHandler:this.onMemberSelect,selectScope:this,dialog:this.dialog})},
onMemberSelect:function(a){this.memberPanel.addMembers(a)}});Ext.reg("zarafa.memberselectionpanel",Zarafa.addressbook.dialog.MemberSelectionPanel);Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.PopupBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{msgTemplate:'<div class="msg"><div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div><div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>{title}</h3>{message}</div></div></div></div>',msgLifetime:5,slideinDirection:"b",slideoutDirection:"b",messageContainer:{id:"msg-div"},ctCls:"zarafa-notifier-popup-container",itemCls:"zarafa-notifier-popup-item",pendingMessages:undefined,
stackedMessages:undefined,animating:false,constructor:function(a){Zarafa.core.ui.notifier.PopupBoxPlugin.superclass.constructor.call(this,a);this.pendingMessages=[];this.stackedMessages=[];if(Ext.isString(this.msgTemplate))this.msgTemplate=new Ext.XTemplate(this.msgTemplate,{compiled:true});if(!Ext.isElement(this.messageContainer)){this.messageContainer=Ext.DomHelper.insertFirst(Ext.getBody(),this.messageContainer,true);this.messageContainer.addClass(this.ctCls);this.layoutMsgContainer()}},layoutMsgContainer:function(){this.messageContainer.setRight(0);
this.messageContainer.setHeight(0)},notify:function(a,b,c){a=this.msgTemplate.apply({title:b,message:c});a=Ext.DomHelper.append(this.messageContainer,{html:a,style:"visibility: hidden;"},true);a.addClass(this.itemCls);this.pendingMessages.push(a);this.showNextMessage()},updateContainer:function(a,b){var c=this.getNewYPosition(container.getMainPanel().get(0),a);if(b===true)this.messageContainer.shift({height:a,y:c});else{this.messageContainer.setHeight(a);this.messageContainer.setY(c)}},getNewYPosition:function(a,
b){return a.getHeight()-a.bottomBar.getHeight()-b},showNextMessage:function(){var a=container.getMainPanel().get(0),b=this.pendingMessages[0],c=b.getHeight();if(!(this.animating||this.messageContainer.getHeight()+c>a.getHeight())){this.animating=true;this.updateContainer(this.messageContainer.getHeight()+c,true);b.height=c;this.pendingMessages.remove(b);this.stackedMessages.push(b);this.animMessage(b)}},onMessageSlideInComplete:function(){this.animating=false;Ext.isEmpty(this.pendingMessages)||this.showNextMessage()},
onMessagePauseComplete:function(){this.animating=true},onMessageSlideOutComplete:function(){var a=this.stackedMessages.shift();a=this.messageContainer.getHeight()-a.height;this.animating=false;if(a<0)a=0;this.updateContainer(a,false);Ext.isEmpty(this.pendingMessages)||this.showNextMessage()},animMessage:function(a){a.slideIn(this.slideinDirection,{callback:this.onMessageSlideInComplete,scope:this}).pause(this.msgLifetime,{callback:this.onMessagePauseComplete,scope:this}).ghost(this.slideoutDirection,
{remove:true,callback:this.onMessageSlideOutComplete,scope:this})}});Zarafa.onReady(function(){container.getNotifier().registerPlugin("popup",new Zarafa.core.ui.notifier.PopupBoxPlugin)});Ext.namespace("Zarafa.core.ui.notifier");Zarafa.core.ui.notifier.NonePlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{});Zarafa.onReady(function(){container.getNotifier().registerPlugin("none",new Zarafa.core.ui.notifier.NonePlugin)});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.MessageBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notify:function(a,b,c){Ext.isString(c)||(c instanceof Ext.data.Record?c.get("subject"):c.toString());var d;if(a.indexOf("info")==0)d=Ext.MessageBox.INFO;else if(a.indexOf("warning")==0)d=Ext.MessageBox.WARNING;else if(a.indexOf("error")==0)d=Ext.MessageBox.ERROR;Ext.MessageBox.show({title:b,msg:c,icon:d,buttons:Ext.MessageBox.OK})}});
Zarafa.onReady(function(){container.getNotifier().registerPlugin("messagebox",new Zarafa.core.ui.notifier.MessageBoxPlugin)});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.DialogNotifierPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notifierElem:undefined,ctCls:"zarafa-dialog-notifier",notify:function(a,b,c,d,e){if(!Ext.isDefined(this.notifierElem)&&Ext.isDefined(d)&&Ext.isElement(d.dom)){this.notifierElem=Ext.DomHelper.append(d,{tag:"div",html:c},true);this.notifierElem.addClass(this.ctCls);this.layoutMsgContainer(d)}Ext.isDefined(this.notifierElem)&&this.animMessage(this.notifierElem,e)},layoutMsgContainer:function(a){this.notifierElem.setLeft(a.getWidth()/
2-50);this.notifierElem.setTop(0)},animMessage:function(a,b){switch(b){case "fadeIn":a.fadeIn({endOpacity:0.8,easing:"easeOut"});break;case "fadeOut":a.fadeOut({endOpacity:0,easing:"easeOut",duration:0.2,remove:true});this.notifierElem=undefined;break;case "slideOut":a.slideOut("t",{easing:"easeIn",duration:5,remove:true});this.notifierElem=undefined;break}}});Zarafa.onReady(function(){container.getNotifier().registerPlugin("dialognotifier",new Zarafa.core.ui.notifier.DialogNotifierPlugin)});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.ConsolePlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notify:function(a,b,c){if(!Ext.isIE){b=b+": ";b+=Ext.isString(c)?c:c instanceof Ext.data.Record?c.get("subject"):c.toString();if(a.indexOf("info")==0)console.info(b);else if(a.indexOf("warning")==0)console.warn(b);else a.indexOf("error")==0?console.error(b):console.log(b)}}});Zarafa.onReady(function(){container.getNotifier().registerPlugin("console",new Zarafa.core.ui.notifier.ConsolePlugin)});Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MessageDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{sendingText:{msg:_("Sending")+"..."},sendingDoneText:{title:_("Sent"),msg:_("Sent successfully")},isSending:false,closeOnSend:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push({ptype:"zarafa.markasreadplugin"});this.addEvents("beforesendrecord","sendrecord","aftersendrecord");Zarafa.core.ui.MessageDialog.superclass.constructor.call(this,a);if(Ext.isString(this.sendingText))this.sendingText={title:"",
msg:this.sendingText};if(Ext.isString(this.sendingDoneText))this.sendingDoneText={title:"",msg:this.sendingDoneText}},displayInfoMask:function(){if(this.showInfoMask!==false)this.record.hasMessageAction("send")?container.getNotifier().notify("info.sending",this.sendingText.title,this.sendingText.msg,this.getEl(),"fadeIn"):Zarafa.core.ui.MessageDialog.superclass.displayInfoMask.apply(this,arguments)},hideInfoMask:function(a){if(this.showInfoMask!==false)if(this.record.hasMessageAction("send")){container.getNotifier().notify("info.sending",
this.sendingText.title,this.sendingText.msg,this.getEl(),"fadeOut");a!==false&&container.getNotifier().notify("info.sent",this.sendingDoneText.title,this.sendingDoneText.msg)}else Zarafa.core.ui.MessageDialog.superclass.hideInfoMask.apply(this,arguments)},onUpdateRecord:function(a,b,c){var d=this.isSending;Zarafa.core.ui.MessageDialog.superclass.onUpdateRecord.apply(this,arguments);if(b==Ext.data.Record.COMMIT){if(c.hasMessageAction("send")){this.fireEvent("aftersendrecord",this,this.record);this.isSending=
false}if(d&&this.closeOnSend&&c.hasMessageAction("send")){this.close();return false}}},onExceptionRecord:function(){this.isSending=this.isSaving=false;Zarafa.core.ui.MessageDialog.superclass.onExceptionRecord.apply(this,arguments)},sendRecord:function(){if(!(this.allowWrite===false||this.isSending===true))if(this.fireEvent("beforesendrecord",this,this.record)!==false){var a=this.record.getRecipientStore();if(!Ext.isDefined(a)||a.getCount()==0)container.getNotifier().notify("warning.sending","",_("Please specify a recipient"));
else{this.isSending=true;Ext.isEmpty(this.record.get("subject"))?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("Send this message without a subject?"),function(b){if(b=="yes")this.sendRecordResolveRecipients();else this.isSending=false},this):this.sendRecordResolveRecipients()}}},sendRecordResolveRecipients:function(){var a=this.record.getRecipientStore(),b=a.getUnresolvedRecipients(),c=a.getInvalidRecipients();if(Ext.isEmpty(c))if(Ext.isEmpty(b))this.submitRecord();else{a.on("resolved",this.onResolvedRecipients,
this,{single:true});a.resolve(b,{cancelPreviousRequest:true})}else{container.getNotifier().notify("warning.sending","",_("Not all recipients could be resolved"));this.isSending=false}},onResolvedRecipients:function(){var a=this.record.getRecipientStore();if(Ext.isEmpty(a.getInvalidRecipients()))this.submitRecord();else{container.getNotifier().notify("warning.sending","",_("Not all recipients could be resolved"));this.isSending=false}},submitRecord:function(){this.record.addMessageAction("send",true);
this.saveRecord();this.fireEvent("sendrecord",this,this.record)}});Zarafa.core.ui.Dialog.register(Zarafa.core.ui.MessageDialog,"zarafa.messagedialog");Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.TaskStatus=Zarafa.core.Enum.create({NOT_STARTED:0,IN_PROGRESS:1,COMPLETE:2,WAIT_FOR_OTHER_PERSON:3,DEFERRED:4,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.TaskStatus.NOT_STARTED:return _("Not Started");case Zarafa.core.mapi.TaskStatus.IN_PROGRESS:return _("In Progress");case Zarafa.core.mapi.TaskStatus.COMPLETE:return _("Complete");case Zarafa.core.mapi.TaskStatus.WAIT_FOR_OTHER_PERSON:return _("Wait for other person");case Zarafa.core.mapi.TaskStatus.DEFERRED:return _("deferred")}return""}});
Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.TaskState=Zarafa.core.Enum.create({NORMAL:0,OWNER_NEW:1,OWNER:2,ACCEPT:3,DECLINE:4});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.TaskMode=Zarafa.core.Enum.create({NOTHING:0,REQUEST:1,ACCEPT:2,DECLINE:3,UPDATE:4,SELF:5});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.StoreSupportMask=Zarafa.core.Enum.create({STORE_ANSI_OK:131072,STORE_ATTACH_OK:32,STORE_CATEGORIZE_OK:1024,STORE_CREATE_OK:16,STORE_ENTRYID_UNIQUE:1,STORE_HTML_OK:65536,STORE_LOCALSTORE:524288,STORE_MODIFY_OK:8,STORE_MV_PROPS_OK:512,STORE_NOTIFY_OK:256,STORE_OLE_OK:64,STORE_PUBLIC_FOLDERS:16384,STORE_READONLY:2,STORE_RESTRICTION_OK:4096,STORE_RTF_OK:2048,STORE_SEARCH_OK:4,STORE_SORT_OK:8192,STORE_SUBMIT_OK:128,STORE_UNCOMPRESSED_RTF:32768,STORE_UNICODE_OK:262144,hasSearchSupport:function(a){Ext.isNumber(a)||
(a=parseInt(a,10));if(!Ext.isNumber(a))return false;if(a&this.STORE_SEARCH_OK)return true;return false}});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.Sensitivity=Zarafa.core.Enum.create({NONE:0,PERSONAL:1,PRIVATE:2,COMPANY_CONFIDENTIAL:3,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.Sensitivity.NONE:return _("None");case Zarafa.core.mapi.Sensitivity.PERSONAL:return _("Personal");case Zarafa.core.mapi.Sensitivity.PRIVATE:return _("Private");case Zarafa.core.mapi.Sensitivity.COMPANY_CONFIDENTIAL:return _("Confidential")}return""}});
Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.Search=Zarafa.core.Enum.create({SEARCH_RUNNING:1,SEARCH_REBUILD:2,SEARCH_RECURSIVE:4,SEARCH_FOREGROUND:8,STOP_SEARCH:1,RESTART_SEARCH:2,RECURSIVE_SEARCH:4,SHALLOW_SEARCH:8,FOREGROUND_SEARCH:16,BACKGROUND_SEARCH:32,isSearchActive:function(a){Ext.isNumber(a)||(a=parseInt(a,10));if(!Ext.isNumber(a))return false;if(a&this.SEARCH_RUNNING)return true;return false},isSearchRunning:function(a){Ext.isNumber(a)||(a=parseInt(a,10));if(!Ext.isNumber(a))return false;if(a&this.SEARCH_REBUILD&&
a&this.SEARCH_RUNNING)return true;return false}});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.Rights=Zarafa.core.Enum.create({RIGHTS_NONE:0,RIGHTS_READ_ANY:1,RIGHTS_CREATE:2,RIGHTS_EDIT_OWNED:8,RIGHTS_DELETE_OWNED:16,RIGHTS_EDIT_ANY:32,RIGHTS_DELETE_ANY:64,RIGHTS_CREATE_SUBFOLDER:128,RIGHTS_FOLDER_ACCESS:256,RIGHTS_FOLDER_VISIBLE:1024});Zarafa.core.mapi.Rights.RIGHTS_NO_RIGHTS=Zarafa.core.mapi.Rights.RIGHTS_FOLDER_VISIBLE;
Zarafa.core.mapi.Rights.RIGHTS_READONLY=Zarafa.core.mapi.Rights.RIGHTS_NO_RIGHTS|Zarafa.core.mapi.Rights.RIGHTS_READ_ANY;Zarafa.core.mapi.Rights.RIGHTS_SECRETARY=Zarafa.core.mapi.Rights.RIGHTS_READONLY|Zarafa.core.mapi.Rights.RIGHTS_CREATE|Zarafa.core.mapi.Rights.RIGHTS_EDIT_OWNED|Zarafa.core.mapi.Rights.RIGHTS_DELETE_OWNED|Zarafa.core.mapi.Rights.RIGHTS_EDIT_ANY|Zarafa.core.mapi.Rights.RIGHTS_DELETE_ANY;Zarafa.core.mapi.Rights.RIGHTS_FULL_CONTROL=Zarafa.core.mapi.Rights.RIGHTS_SECRETARY|Zarafa.core.mapi.Rights.RIGHTS_CREATE_SUBFOLDER;
Zarafa.core.mapi.Rights.RIGHTS_OWNER=Zarafa.core.mapi.Rights.RIGHTS_FULL_CONTROL|Zarafa.core.mapi.Rights.RIGHTS_FOLDER_ACCESS;Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.Restrictions=Zarafa.core.Enum.create({RES_AND:0,RES_OR:1,RES_NOT:2,RES_CONTENT:3,RES_PROPERTY:4,RES_COMPAREPROPS:5,RES_BITMASK:6,RES_SIZE:7,RES_EXIST:8,RES_SUBRESTRICTION:9,RES_COMMENT:10,FL_FULLSTRING:0,FL_SUBSTRING:1,FL_PREFIX:2,FL_IGNORECASE:65536,FL_IGNORENONSPACE:131072,FL_LOOSE:262144,RELOP_LT:0,RELOP_LE:1,RELOP_GT:2,RELOP_GE:3,RELOP_EQ:4,RELOP_NE:5,RELOP_RE:6,BMR_EQZ:0,BMR_NEZ:1,VALUE:0,RELOP:1,FUZZYLEVEL:2,CB:3,ULTYPE:4,ULMASK:5,ULPROPTAG:6,ULPROPTAG1:7,ULPROPTAG2:8,PROPS:9,
RESTRICTION:10});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.ResponseStatus=Zarafa.core.Enum.create({RESPONSE_NONE:0,RESPONSE_ORGANIZED:1,RESPONSE_TENTATIVE:2,RESPONSE_ACCEPTED:3,RESPONSE_DECLINED:4,RESPONSE_NOT_RESPONDED:5,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED:return _("Meeting organiser");case Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE:return _("No response");case Zarafa.core.mapi.ResponseStatus.RESPONSE_NOT_RESPONDED:return _("Not responded");case Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE:return _("Tentative");
case Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED:return _("Accepted");case Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED:return _("Declined")}return""}});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.RecipientType=Zarafa.core.Enum.create({MAPI_ORIG:0,MAPI_TO:1,MAPI_CC:2,MAPI_BCC:3});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.RecipientTrackStatus=Zarafa.core.Enum.create({RECIPIENT_TRACKSTATUS_NONE:0,RECIPIENT_TRACKSTATUS_TENTATIVE:2,RECIPIENT_TRACKSTATUS_ACCEPTED:3,RECIPIENT_TRACKSTATUS_DECLINED:4});
Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.RecipientFlags=Zarafa.core.Enum.create({recipSendable:1,recipOrganizer:2,recipExceptionalResponse:16,recipExceptionalDeleted:32,recipOriginal:256,recipReserved:512});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.ObjectType=Zarafa.core.Enum.create({MAPI_STORE:1,MAPI_ADDRBOOK:2,MAPI_FOLDER:3,MAPI_ABCONT:4,MAPI_MESSAGE:5,MAPI_MAILUSER:6,MAPI_ATTACH:7,MAPI_DISTLIST:8,MAPI_PROFSECT:9,MAPI_STATUS:10,MAPI_SESSION:11,MAPI_FORMINFO:12});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.MessageFlags=Zarafa.core.Enum.create({MSGFLAG_READ:1,MSGFLAG_UNMODIFIED:2,MSGFLAG_SUBMIT:4,MSGFLAG_UNSENT:8,MSGFLAG_HASATTACH:16,MSGFLAG_FROMME:32,MSGFLAG_ASSOCIATED:64,MSGFLAG_RESEND:128,MSGFLAG_RN_PENDING:256,MSGFLAG_NRN_PENDING:512});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.MeetingType=Zarafa.core.Enum.create({MEETING_NONE:0,MEETING_REQUEST:1,MEETING_FULL_UPDATE:65536,MEETING_INFO_UPDATE:131072,MEETING_OUT_OF_DATE:524288,MEETING_DELEGATED:1048576});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.MeetingStatus=Zarafa.core.Enum.create({NONMEETING:0,MEETING:1,MEETING_RECEIVED:3,MEETING_CANCELED:5,MEETING_RECEIVED_AND_CANCELED:7,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.MeetingStatus.NONMEETING:return"";case Zarafa.core.mapi.MeetingStatus.MEETING:return _("Meeting");case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED:return _("Received");case Zarafa.core.mapi.MeetingStatus.MEETING_CANCELED:case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED_AND_CANCELED:return _("Canceled")}return""}});
Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.MDBProvider=Zarafa.core.Enum.create({ZARAFA_SERVICE_GUID:"ca3d253c27d23c4494fe425fab958c19",ZARAFA_STORE_PUBLIC_GUID:"094a7fd4bdd33c49b2fc3c90bbcb48d4",ZARAFA_STORE_DELEGATE_GUID:"85107c7c6dbc534e9dab8a53f8def808"});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.Importance=Zarafa.core.Enum.create({NONURGENT:0,NORMAL:1,URGENT:2,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.Importance.NONURGENT:return _("Low");case Zarafa.core.mapi.Importance.NORMAL:return _("Normal");case Zarafa.core.mapi.Importance.URGENT:return _("High")}return""},getClassName:function(a,b){if(Ext.isEmpty(b))b="icon_importance";Ext.isNumber(a)||(a=parseInt(a,10));if(!Ext.isNumber(a))return b+"_normal";var c=this.getName(a).toLowerCase();if(!Ext.isEmpty(c))return b+
"_"+c;return b+"_normal"}});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.IconIndex=Zarafa.core.Enum.create({mail_stubbed:2,mail_read:256,mail_unread:257,mail_submitted:258,mail_unsent:259,mail_receipt:260,mail_replied:261,mail_forwarded:262,mail_remote:263,mail_delivery_receipt:264,mail_read_receipt:265,mail_nondelivery_receipt:266,mail_nonread_receipt:267,mail_recall_s:268,mail_recall_f:269,mail_tracking:270,mail_oof:283,mail_recall:284,mail_tracked:304,contact_user:512,contact_distlist:514,note_blue:768,note_green:769,note_pink:770,note_yellow:771,note_white:772,
appt_appointment:1024,appt_recurring:1025,appt_meeting_single:1026,appt_meeting_recurring:1027,appt_meeting_request:1028,appt_meeting_accept:1029,appt_meeting_decline:1030,appt_meeting_tentative:1031,appt_meeting_cancel:1032,appt_meeting_outofdate:1033,appt_meeting_forward:1035,task_normal:1280,task_recurring:1281,task_assignee:1282,task_assigner:1283,journal_conversation:1537,journal_document:1554,journal_email:1538,journal_fax:1545,journal_letter:1548,journal_meeting:1555,journal_meeting_cancel:1556,
journal_meeting_request:1539,journal_meeting_response:1540,journal_access:1552,journal_excel:1550,journal_powerpoint:1551,journal_word:1549,journal_note:1544,journal_phone_call:1546,journal_remote_session:1557,journal_task:1547,journal_task_request:1542,journal_task_response:1543,journal_other:3,getClassName:function(a,b){if(Ext.isEmpty(b))b="icon";Ext.isNumber(a)||(a=parseInt(a,10));if(!Ext.isNumber(a))return"";var c=this.getName(a);if(!Ext.isEmpty(c))return b+"_"+c;return""}});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.FolderExtendedFlags=Zarafa.core.Enum.create({DEFAULT:0,USE_UNREAD_COUNT:1,USE_TOTAL_COUNT:3});Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.FlagStatus=Zarafa.core.Enum.create({cleared:0,completed:1,flagged:2});Zarafa.core.mapi.FlagIcon=Zarafa.core.Enum.create({clear:0,purple:1,orange:2,green:3,yellow:4,blue:5,red:6});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.DistlistType=Zarafa.core.Enum.create({DL_USER:195,DL_USER2:211,DL_USER3:227,DL_EXTERNAL_MEMBER:0,DL_DIST:180,DL_USER_AB:181,DL_DIST_AB:182});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.DisplayTypeEx=Zarafa.core.Enum.create({DTE_FLAG_REMOTE_VALID:2147483648,DTE_FLAG_ACL_CAPABLE:1073741824,DTE_MASK_REMOTE:65280,DTE_MASK_LOCAL:255,DT_ROOM:7,DT_EQUIPMENT:8,DT_SEC_DISTLIST:9,DTE_IS_REMOTE_VALID:function(a){if(!Ext.isNumber(a))return false;return!!(a&Zarafa.core.mapi.DisplayTypeEx.DTE_FLAG_REMOTE_VALID)},DTE_IS_ACL_CAPABLE:function(a){if(!Ext.isNumber(a))return false;return!!(a&Zarafa.core.mapi.DisplayTypeEx.DTE_FLAG_ACL_CAPABLE)},DTE_REMOTE:function(a){if(!Ext.isNumber(a))return a;
return(a&Zarafa.core.mapi.DisplayTypeEx.DTE_MASK_REMOTE)>>8},DTE_LOCAL:function(a){if(!Ext.isNumber(a))return a;return a&Zarafa.core.mapi.DisplayTypeEx.DTE_MASK_LOCAL}});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.DisplayType=Zarafa.core.Enum.create({DT_MAILUSER:0,DT_DISTLIST:1,DT_FORUM:2,DT_AGENT:3,DT_ORGANIZATION:4,DT_PRIVATE_DISTLIST:5,DT_REMOTE_MAILUSER:6,DT_FOLDER:16777216,DT_FOLDER_LINK:33554432,DT_FOLDER_SPECIAL:67108864,DT_MODIFIABLE:65536,DT_GLOBAL:131072,DT_LOCAL:196608,DT_WAN:262144,DT_NOT_SPECIFIC:327680});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.BusyStatus=Zarafa.core.Enum.create({UNKNOWN:-1,FREE:0,TENTATIVE:1,BUSY:2,OUTOFOFFICE:3,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.BusyStatus.UNKNOWN:return _("Unknown");case Zarafa.core.mapi.BusyStatus.FREE:return _("Free");case Zarafa.core.mapi.BusyStatus.TENTATIVE:return _("Tentative");case Zarafa.core.mapi.BusyStatus.BUSY:return _("Busy");case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:return _("Out of Office")}}});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.AttachMethod=Zarafa.core.Enum.create({NO_ATTACHMENT:0,ATTACH_BY_VALUE:1,ATTACH_BY_REFERENCE:2,ATTACH_BY_REF_RESOLVE:3,ATTACH_BY_REF_ONLY:4,ATTACH_EMBEDDED_MSG:5,ATTACH_OLE:6});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.AppointmentLabels=Zarafa.core.Enum.create({NONE:0,IMPORTANT:1,WORK:2,PERSONAL:3,HOLIDAY:4,REQUIRED:5,TRAVEL_REQUIRED:6,PREPARE_REQUIRED:7,BIRTHDAY:8,SPECIAL_DATE:9,PHONE_INTERVIEW:10,getDisplayName:function(a){switch(a){case Zarafa.core.mapi.AppointmentLabels.NONE:return _("None");case Zarafa.core.mapi.AppointmentLabels.IMPORTANT:return _("Important");case Zarafa.core.mapi.AppointmentLabels.WORK:return _("Work");case Zarafa.core.mapi.AppointmentLabels.PERSONAL:return _("Personal");
case Zarafa.core.mapi.AppointmentLabels.HOLIDAY:return _("Holiday");case Zarafa.core.mapi.AppointmentLabels.REQUIRED:return _("Required");case Zarafa.core.mapi.AppointmentLabels.TRAVEL_REQUIRED:return _("Travel Required");case Zarafa.core.mapi.AppointmentLabels.PREPARE_REQUIRED:return _("Preparation Required");case Zarafa.core.mapi.AppointmentLabels.BIRTHDAY:return _("Birthday");case Zarafa.core.mapi.AppointmentLabels.SPECIAL_DATE:return _("Special Date");case Zarafa.core.mapi.AppointmentLabels.PHONE_INTERVIEW:return _("Phone Interview")}}});
Ext.namespace("Zarafa.core.mapi");Zarafa.core.mapi.Access=Zarafa.core.Enum.create({ACCESS_MODIFY:1,ACCESS_READ:2,ACCESS_DELETE:4,ACCESS_CREATE_HIERARCHY:8,ACCESS_CREATE_CONTENTS:16,ACCESS_CREATE_ASSOCIATED:32});Ext.namespace("Zarafa.core.data");Zarafa.core.data.SharedComponentType=Zarafa.core.Enum.create({"common.create":1,"common.view":2,"common.preview":3,"common.contextmenu":4});Ext.namespace("Zarafa.core.data");Zarafa.core.data.RecordCustomObjectType=Zarafa.core.Enum.create({BASE_TYPE:1E3});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ProxyResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{proxy:undefined,reader:undefined,action:undefined,callback:undefined,scope:undefined,options:undefined,sendRecords:undefined,receivedRecords:undefined,receivedTime:undefined,metaData:undefined,responseFailure:function(a,b){if(Ext.isDefined(this.proxy)){b={error:b,sendRecords:this.sendRecords};this.proxy.fireEvent("exception",this.proxy,"response",this.action,this.options,a,b)}},start:function(a,b,c,d){if(!Ext.isDefined(this.proxy))return false;
Ext.isFunction(this.proxy.deleteRequestId)&&this.proxy.deleteRequestId(b);this.receivedRecords=[];this.receivedTime=d;if(!Ext.isEmpty(this.sendRecords)&&!Ext.isArray(this.sendRecords))this.sendRecords=[this.sendRecords];this.metaData={}},handle:function(a,b){try{var c=Zarafa.core.data.ProxyResponseHandler.superclass.handle.call(this,a,b)}catch(d){this.proxy.fireEvent("exception",this.proxy,"response",this.action,this.options,b,{error:d,sendRecords:this.sendRecords});c=false}c!==false&&this.proxy&&
Ext.isFunction(this.proxy.updateExecutionTimestamp)&&this.proxy.updateExecutionTimestamp(a,this.receivedTime);return c},doError:function(a){this.proxy.fireEvent("exception",this.proxy,"remote",this.action,this.options,a,{sendRecords:this.sendRecords});return false},done:function(a){Ext.isFunction(this.callback)&&this.callback.call(this.scope,this.receivedRecords,this.options,a,this.metaData)},correlateRecordFromResponse:function(a){a=this.reader.readResponse(Ext.data.Api.actions.read,a);var b=[];
if(!Ext.isEmpty(a.data)&&!Ext.isEmpty(this.sendRecords))if(this.sendRecords[0].phantom)b.push(a.data[0]);else for(var c=0,d=a.data.length;c<d;c++)for(var e=0,f=this.sendRecords.length;e<f;e++)if(Zarafa.core.EntryId.compareEntryIds(a.data[c].entryid,this.sendRecords[e].get("entryid"))){b.push(a.data[c]);break}return b},readRecordsFromResponse:function(a,b){var c=a[b]||[];Ext.isArray(c)||(c=[c]);var d={count:a.page?a.page.totalrowcount:c.length};d[b]=c;return this.reader.readRecords(d)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ListModuleStore=Ext.extend(Zarafa.core.data.IPMStore,{hasSearch:false,useSearchFolder:false,searchFolderEntryId:undefined,actionType:undefined,restriction:{},subfolders:false,entryId:undefined,storeEntryId:undefined,preferredMessageClass:"IPM.Note",defaultSortInfo:undefined,searchUpdateTimer:undefined,constructor:function(a){a=a||{};a.preferredMessageClass=a.preferredMessageClass||this.preferredMessageClass;var b=Zarafa.core.ModuleNames.getModule(a.preferredMessageClass,true);if(Ext.isEmpty(b)&&
a.preferredMessageClass!=this.preferredMessageClass)b=Zarafa.core.ModuleNames.getModule(this.preferredMessageClass,true);var c=Zarafa.core.data.RecordFactory.getRecordClassByMessageClass(a.preferredMessageClass);Ext.applyIf(a,{remoteSort:true,actionType:Zarafa.core.Actions.list,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader({},c),proxy:new Zarafa.core.data.IPMProxy({listModuleName:b.list,itemModuleName:b.item})});this.addEvents("search","beforeupdatesearch","updatesearch",
"stopsearch");Zarafa.core.data.ListModuleStore.superclass.constructor.call(this,a);this.storeEntryId&&this.setStoreEntryId(this.storeEntryId,false,true);this.entryId&&this.setEntryId(this.entryId,false,true)},setActionType:function(a){this.actionType=a},setFolder:function(a){Ext.each(a,function(b,c){this.setEntryId(b.get("entryid"),c!=0);this.setStoreEntryId(b.get("store_entryid"),c!=0)},this)},setEntryId:function(a,b){if(!Ext.isEmpty(b)&&b){if(Ext.isEmpty(this.entryId))this.entryId=[];if(!Ext.isEmpty(this.entryId)&&
!Ext.isArray(this.entryId))this.entryId=[this.entryId];this.entryId.push(a)}else this.entryId=a},getEntryId:function(){return this.entryId},setSearchEntryId:function(a){this.searchFolderEntryId=a},setStoreEntryId:function(a,b){if(!Ext.isEmpty(b)&&b){if(Ext.isEmpty(this.storeEntryId))this.storeEntryId=[];if(!Ext.isEmpty(this.storeEntryId)&&!Ext.isArray(this.storeEntryId))this.storeEntryId=[this.storeEntryId];this.storeEntryId.push(a)}else this.storeEntryId=a},getStoreEntryId:function(){return this.storeEntryId},
setRestriction:function(a){this.restriction=a},setSearchRestriction:function(a){if(Ext.isEmpty(a))delete this.restriction.search;else this.restriction=Ext.apply(this.restriction||{},{search:a})},setSubfolders:function(a){this.subfolders=a},setUseSearchFolder:function(a){this.useSearchFolder=a},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isDefined(a.cancelPreviousRequest))a.cancelPreviousRequest=true;if(!this.hasSearch)if(Ext.isEmpty(a.folder)){if(Ext.isDefined(a.params.entryid)&&
Ext.isDefined(a.params.store_entryid)){this.setEntryId(a.params.entryid,false);this.setStoreEntryId(a.params.store_entryid,false)}}else this.setFolder(a.folder);Ext.apply(a.params,{entryid:this.hasSearch?this.searchFolderEntryId:this.entryId,store_entryid:this.storeEntryId});Ext.applyIf(a,{actionType:this.actionType});Ext.applyIf(a.params,{restriction:this.restriction});a.actionType==Zarafa.core.Actions.search&&Ext.applyIf(a.params,{use_searchfolder:this.useSearchFolder,subfolders:this.subfolders});
if(a.actionType==Zarafa.core.Actions.updatesearch||a.actionType==Zarafa.core.Actions.stopsearch)delete a.params.restriction;return Zarafa.core.data.ListModuleStore.superclass.load.call(this,a)},reload:function(a){this.hasSearch?this.updateSearch(Ext.applyIf(a||{},this.lastOptions)):Zarafa.core.data.ListModuleStore.superclass.reload.apply(this,arguments)},search:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isEmpty(a.searchRestriction)){this.hasSearch=true;this.setSearchEntryId(this.entryId);
this.isExecuting("list")&&this.proxy.cancelRequests("list");this.setUseSearchFolder(a.useSearchFolder);this.setSubfolders(a.subfolders);if(!Ext.isEmpty(a.searchRestriction)){a.params.restriction={};a.params.restriction.search=a.searchRestriction}this.useSearchFolder&&Ext.apply(a,{actionType:Zarafa.core.Actions.search});this.load(a);this.fireEvent("search",this,a)}},updateSearch:function(a){if(this.hasSearch){Ext.isObject(a)||(a={});Ext.apply(a,{actionType:Zarafa.core.Actions.updatesearch});this.load(a);
this.fireEvent("updatesearch",this,a)}},stopSearch:function(a){if(this.hasSearch){Ext.isObject(a)||(a={});this.isExecuting(Zarafa.core.Actions.updatesearch)&&this.proxy.cancelRequests(Zarafa.core.Actions.updatesearch);var b=this.searchFolderEntryId;Ext.apply(a,{actionType:Zarafa.core.Actions.stopsearch,params:{entryid:b}});if(this.searchUpdateTimer){clearTimeout(this.searchUpdateTimer);delete this.searchUpdateTimer}if(!Ext.isEmpty(b)){this.load(a);this.setSearchEntryId(undefined);this.hasSearch=false;
this.fireEvent("stopsearch",this,a)}}},loadRecords:function(a,b,c,d){if(c!==false)if(d){d.search_meta&&this.updateSearchInfo(d.search_meta,d.page);if(d.page)this.totalLength=d.page.totalrowcount}Zarafa.core.data.ListModuleStore.superclass.loadRecords.apply(this,arguments)},updateSearchInfo:function(a,b){var c={entryId:a.searchfolder_entryid,searchState:parseInt(a.searchstate,10),results:parseInt(a.results,10)};Ext.isEmpty(b)||Ext.apply(c,{page:{start:parseInt(b.start,10),rowCount:parseInt(b.rowcount,
10),totalRowCount:parseInt(b.totalrowcount,10)}});this.fireEvent("beforeupdatesearch",this,c);this.setSearchEntryId(c.entryId);if(Zarafa.core.mapi.Search.isSearchRunning(c.searchState))this.searchUpdateTimer=this.updateSearch.defer(container.getSettingsModel().get("zarafa/v1/main/search/updatesearch_timeout"),this);else delete this.searchUpdateTimer}});Ext.reg("zarafa.listmodulestore",Zarafa.core.data.ListModuleStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMAttachmentStore=Ext.extend(Zarafa.core.data.MAPISubStore,{id:null,constructor:function(a){a=a||{};Ext.applyIf(a,{id:Zarafa.generateId(32),writer:new Zarafa.core.data.JsonAttachmentWriter,reader:new Zarafa.core.data.JsonAttachmentReader});Zarafa.core.data.IPMAttachmentStore.superclass.constructor.call(this,a);this.on("update",this.onAttachmentsChange,this);this.on("add",this.onAttachmentsChange,this);this.on("remove",this.onAttachmentsChange,this);this.on("datachanged",this.onAttachmentsChange,
this)},onAttachmentsChange:function(){if(this.getParentRecord())this.getCount()>0?this.getParentRecord().set("hasattach",true):this.getParentRecord().set("hasattach",false)},getId:function(){return this.id},setId:function(a){this.id=a},getInlineImageUrl:function(a){return this.getAttachmentBaseUrl(a)+"&openType=inline"},getAttachmentUrl:function(a){return this.getAttachmentBaseUrl(a)+"&openType=attachment"},getAttachmentBaseUrl:function(a){var b="index.php?load=download_attachment";b=Ext.urlAppend(b,
"store="+this.getParentRecord().get("store_entryid"));b=Ext.urlAppend(b,"entryid="+this.getAttachmentParentRecordEntryId());b=a.get("attach_num")!=-1?Ext.urlAppend(b,"attachNum[]="+a.get("attach_num")):Ext.urlAppend(b,"attachNum[]="+a.get("tmpname"));return b=Ext.urlAppend(b,"dialog_attachments="+this.getId())},getAttachmentParentRecordEntryId:function(){var a=this.getParentRecord(),b=a.get("entryid")||"";a=a.getMessageActions();if(Ext.isEmpty(b)&&a)switch(a.action_type){case "forward":b=a.source_entryid;
break;case "reply":case "replyall":}return b},getUploadAttachmentUrl:function(){var a="index.php?load=upload_attachment";a+="&store="+this.getParentRecord().get("store_entryid");a+="&entryid="+this.getParentRecord().get("entryid");a+="&dialog_attachments="+this.getId();return a}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPFRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{equals:function(a){if(this.phantom!==a.phantom)return false;return this.phantom?this.id==a.id:Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("entryid"))},isContainerClass:function(a,b){return Zarafa.core.ContainerClass.isClass(this.get("container_class"),a,b)},getChildren:Ext.emptyFn});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.CompositeResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{handlers:undefined,activeHandlers:undefined,start:function(a,b,c,d){this.activeHandlers=[];for(var e=0,f=this.handlers.length;e<f;e++){var g=this.handlers[e];g.start(a,b,c,d)!==false&&this.activeHandlers.push({handler:g,success:true})}return this.activeHandlers.length>0},handle:function(a,b){for(var c=0,d=this.activeHandlers.length;c<d;c++){var e=this.activeHandlers[c];e.success=e.handler.handle(a,b)}},
done:function(){for(var a=0,b=this.activeHandlers.length;a<b;a++){var c=this.activeHandlers[a];c.handler.done(c.success)}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.AbstractNotificationResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{store:undefined,reader:undefined,notifyObject:undefined,notifications:undefined,receivedTime:undefined,start:function(a,b,c,d){if(!Ext.isObject(c)||Ext.isEmpty(this.notifyObject)||!Ext.isFunction(this.notifyObject.onNotify))return false;this.notifications={};this.receivedTime=d},done:function(a){Ext.iterate(this.notifications,function(b,c){Ext.each(c,function(d){this.notifyObject.onNotify(b,d.records,
d.data,this.receivedTime,a)},this)},this)},addNotification:function(a,b,c){b={records:b,data:c};if(Ext.isDefined(this.notifications[a]))if(Ext.isArray(this.notifications[a]))this.notifications[a].push(b);else this.notifications[a]=[this.notifications[a],b];else this.notifications[a]=[b]}});Ext.namespace("Zarafa.core");
Zarafa.core.MultiFolderContextModel=Ext.extend(Zarafa.core.ContextModel,{colorScheme:undefined,default_merge_state:false,groupings:undefined,constructor:function(a){a=a||{};this.addEvents("foldermergestatechanged");Zarafa.core.MultiFolderContextModel.superclass.constructor.call(this,a)},enable:function(){this.groupings=this.groupings||{};Zarafa.core.MultiFolderContextModel.superclass.enable.apply(this,arguments);this.setMergeState(this.getCurrentMergeState(),true)},setMergeState:function(a,b){if(b===
true||this.default_merge_state!==a){this.default_merge_state=a;this.fireEvent("foldermergestatechanged",this,this.default_merge_state)}},getCurrentMergeState:function(){return this.default_merge_state},onFolderChange:function(){Zarafa.core.MultiFolderContextModel.superclass.onFolderChange.apply(this,arguments);this.sortFolders();this.assignColors();this.applyGrouping()},activateFolderInGroup:function(a,b){this.groupings[b].active=a.get("entryid")},mergeFolderToGroup:function(a,b,c){a=a.get("entryid");
if(this.groupings[c]){this.groupings[c].folders.remove(a);if(Ext.isEmpty(this.groupings[c].folders))delete this.groupings[c];else if(this.groupings[c].active==a)this.groupings[c].active=this.groupings[c].folders[0]}this.groupings[b].folders.push(a);return b},separateFolderFromGroup:function(a,b){var c=Ext.id(),d=a.get("entryid");if(this.groupings[b]){this.groupings[b].folders.remove(d);if(Ext.isEmpty(this.groupings[b].folders))delete this.groupings[b];else if(this.groupings[b].active==d)this.groupings[b].active=
this.groupings[b].folders[0]}this.groupings[c]={folders:[d],active:d};return c},removeFolderFromGroup:function(a,b){var c=a.get("entryid");if(this.groupings[b]){this.groupings[b].folders.remove(c);if(Ext.isEmpty(this.groupings[b].folders))delete this.groupings[b];else if(this.groupings[b].active==c)this.groupings[b].active=this.groupings[b].folders[0]}},addItemToGroup:function(a){if(this.default_merge_state){var b=Object.keys(this.groupings);if(Ext.isEmpty(b))this.groupings[Ext.id()]={folders:[a],
active:a};else this.groupings[b[0]].folders.push(a)}else this.groupings[Ext.id()]={folders:[a],active:a}},removeItemFromGroup:function(a){for(var b in this.groupings){var c=this.groupings[b],d=c.folders.indexOf(a);if(d>-1){c.folders.splice(d,1);Ext.isEmpty(c.folders)&&delete this.groupings[b];break}}},applyGrouping:function(){for(var a=[],b=0,c=this.folders.length;b<c;b++)a.push(this.folders[b].get("entryid"));var d=[];for(var e in this.groupings)d=d.concat(this.groupings[e].folders);b=0;for(c=d.length;b<
c;b++){e=d[b];a.indexOf(e)<0?this.removeItemFromGroup(e):a.remove(e)}b=0;for(c=a.length;b<c;b++)this.addItemToGroup(a[b])},getGroupings:function(){return this.groupings},sortFolders:function(){if(this.folders.length!=0)if(this.folders.length>1)this.folders=container.getHierarchyStore().getSortedFolders(this.hasFolder,this)},assignColors:function(){if(Ext.isDefined(this.colorScheme))for(var a=0,b=this.folders.length;a<b;a++)this.folders[a].setColorScheme(this.colorScheme[a%this.colorScheme.length])}});
Ext.namespace("Zarafa.core");Zarafa.core.ErrorType=Zarafa.core.Enum.create({MAPI:1,ZARAFA:2,GENERAL:3});Ext.namespace("Zarafa.core");
Zarafa.core.Context=Ext.extend(Zarafa.core.Plugin,{displayName:undefined,current_view:undefined,current_view_mode:undefined,hasContentPanel:true,groupViewBtns:true,constructor:function(a){a=a||{};Ext.applyIf(a,{stateful:true});this.addEvents(["viewchange","viewmodechange"]);Zarafa.core.Context.superclass.constructor.call(this,a);this.hasContentPanel===true&&this.registerInsertionPoint("main.content",this.createContentPanel,this)},createContentPanel:function(){},getMainToolbarViewButtons:function(){return[]},
getMainToolbarPrintButtons:function(){return[]},switchView:function(a,b,c){this.suspendEvents(true);this.setView(a,c);this.setViewMode(b,c);this.resumeEvents()},setView:function(a,b){if(b===true||this.current_view!==a){var c=this.current_view;this.current_view=a;this.onViewChange(this,this.current_view,c);this.fireEvent("viewchange",this,this.current_view,c)}},onViewChange:Ext.emptyFn,getCurrentView:function(){return this.current_view},setViewMode:function(a,b){if(b===true||this.current_view_mode!==
a){var c=this.current_view_mode;this.current_view_mode=a;this.onViewModeChange(this,this.current_view_mode,c);this.fireEvent("viewmodechange",this,this.current_view_mode,c)}},onViewModeChange:Ext.emptyFn,getCurrentViewMode:function(){return this.current_view_mode},getModel:Ext.emptyFn,enable:function(a){this.stateful&&this.initState();var b=this.getModel();b&&b.enable(a);this.switchView(this.getCurrentView(),this.getCurrentViewMode(),true)},disable:function(){var a=this.getModel();a&&a.disable()},
bid:function(){return-1},getDisplayName:function(){return this.displayName},getStateName:function(){var a=this.statefulName;if(!a)a=this.name;return"contexts/"+a},initStateEvents:function(){Zarafa.core.Context.superclass.initStateEvents.call(this);this.on("viewchange",this.saveState,this,{delay:100});this.on("viewmodechange",this.saveState,this,{delay:100})},getState:function(){var a=Zarafa.core.Context.superclass.getState.call(this)||{},b=this.getModel();b=b&&b.isSearching();return Ext.apply(a,b?
{}:{current_view:this.current_view,current_view_mode:this.current_view_mode})}});Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion=Ext.extend(Ext.layout.BorderLayout.SplitRegion,{hidden:undefined,oldSize:undefined,constructor:function(a,b,c){Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion.superclass.constructor.call(this,a,b,c);this.region=c;this.applyLayout=this.applyLayout.createInterceptor(this.preApplyLayout,this)},setVisible:Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion.prototype.setVisible,isVisible:Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion.prototype.isVisible,
getSize:function(){return this.restrictSize(Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion.superclass.getSize.call(this))},restrictSize:Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion.prototype.restrictSize,render:function(a,b,c){if(c===true){var d=b.id;b.id+="-switch";Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion.superclass.render.apply(this,arguments);b.id=d}else Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion.superclass.render.apply(this,arguments)},
preApplyLayout:function(a){this.splitEl.setPositioning({left:a.x+"px",top:a.y+a.height+"px"})},onSplitMove:function(a,b){var c=this.panel.getSize();this.lastSplitSize=b;if(this.position=="north"||this.position=="south"){this.panel.setSize(c.width,b);this.state.height=b}else{this.panel.setSize(b,c.height);this.state.width=b}this.layout.container.doLayout();this.panel.saveState();return false}});Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.SwitchBorderLayout.Orientation=Zarafa.core.Enum.create({OFF:"off",VERTICAL:"vertical",HORIZONTAL:"horizontal"});Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.PercentSpinner=Ext.extend(Zarafa.common.ui.NumberSpinner,{constructor:function(a){a=a||{};Ext.applyIf(a,{allowDecimals:true,decimalPrecision:4});Zarafa.common.ui.PercentSpinner.superclass.constructor.call(this,a)},init:function(a){if(Ext.isDefined(a.defaultValue)&&Ext.isString(a.defaultValue))a.defaultValue=this.stringToFloat(a.defaultValue);if(Ext.isDefined(a.minValue)){if(Ext.isString(a.minValue))a.minValue=this.stringToFloat(a.minValue)}else a.minValue=0;if(Ext.isDefined(a.maxValue)){if(Ext.isString(a.maxValue))a.maxValue=
this.stringToFloat(a.maxValue)}else a.maxValue=1;Zarafa.common.ui.PercentSpinner.superclass.init.call(this,a);a.value=this.floatToString(a.defaultValue)},stringToFloat:function(a){var b;if(!Ext.isEmpty(a)){b=a.indexOf("%");a=parseFloat(a);if(b)a/=100;return a}},floatToString:function(a){if(Ext.isDefined(a))return a*100+"%"},setValue:function(a){if(!Ext.isEmpty(a)&&Ext.isString(a))a=parseFloat(a)/100;this.setStringValue(this.floatToString(this.fixBoundries(a)))},getValue:function(){var a=this.getStringValue();
if(!Ext.isEmpty(a))return this.stringToFloat(a)}});Ext.preg("zarafa.percentspinner",Zarafa.common.ui.PercentSpinner);Ext.namespace("Zarafa.common.restoreitem.dialogs");
Zarafa.common.restoreitem.dialogs.RestoreItemDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.restoreitemdialog",layout:"fit",defaultTitle:_("Restore Deleted Items"),alwaysUseDefaultTitle:true,width:500,height:300,items:[this.createPanel()]});Zarafa.common.restoreitem.dialogs.RestoreItemDialog.superclass.constructor.call(this,a)},createPanel:function(){return{iconCls:"icon_restore",border:false,tbar:{xtype:"zarafa.dialogtoolbar",insertionPointBase:"common.restoreitemdialog",
actionItems:this.createActionButtons()},xtype:"zarafa.restoreitempanel",layout:"fit"}},getRestoreDialogEditPanel:function(){return this.findByType("zarafa.restoreitempanel")[0]},createActionButtons:function(){return[{xtype:"button",overflowText:_("Restore"),text:_("Restore"),iconCls:"icon_restore",handler:function(){},scope:this},{xtype:"button",overflowText:_("Restore All"),text:_("Restore All"),iconCls:"icon_restore",handler:function(){},scope:this},{xtype:"button",overflowText:_("Permanent Delete"),
text:_("Permanent Delete"),iconCls:"icon_delete",handler:function(){},scope:this},{xtype:"button",overflowText:_("Delete"),text:_("Delete"),iconCls:"icon_delete",handler:function(){},scope:this},{xtype:"radiogroup","float":"right",width:130,items:[{boxLabel:_("message"),name:"restoreitem",inputValue:1,checked:true},{boxLabel:_("folder"),name:"restoreitem",inputValue:2}]}]}});Zarafa.core.ui.Dialog.register(Zarafa.common.restoreitem.dialogs.RestoreItemDialog,"zarafa.restoreitemdialog");Ext.namespace("Zarafa.common.reminder.data");
Zarafa.common.reminder.data.ReminderStore=Ext.extend(Zarafa.core.data.MAPIStore,{actionType:Zarafa.core.Actions.list,lastChecksum:undefined,refreshStore:false,reminderRequestTimer:undefined,constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_REMINDER);Ext.applyIf(a,{proxy:new Zarafa.common.reminder.data.ReminderProxy,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader({dynamicRecord:false},
b)});Zarafa.common.reminder.data.ReminderStore.superclass.constructor.call(this,a)},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isDefined(a.cancelPreviousRequest))a.cancelPreviousRequest=true;Ext.apply(a,{actionType:this.actionType});return Zarafa.common.reminder.data.ReminderStore.superclass.load.call(this,a)},onError:function(a,b,c,d,e,f){Zarafa.common.reminder.data.ReminderStore.superclass.onError.call(a,b,c,d,e,f);this.clearReminderInterval()},initializeReminderInterval:function(){var a=
container.getSettingsModel().get("zarafa/v1/main/reminder/polling_interval");if(Ext.isNumber(a)&&a>0){var b=this;this.reminderRequestTimer=window.setInterval(function(){b.sendReminderRequest()},a*1E3)}},sendReminderRequest:function(){this.load()},resetReminderInterval:function(){this.clearReminderInterval();this.initializeReminderInterval()},clearReminderInterval:function(){if(this.reminderRequestTimer){window.clearInterval(this.reminderRequestTimer);delete this.reminderRequestTimer}},loadRecords:function(a,
b,c){Zarafa.common.reminder.data.ReminderStore.superclass.loadRecords.apply(this,arguments);if(c!==false){var d=a.records,e=Ext.util.JSON.encode(Ext.pluck(d,"id"));if(this.lastChecksum!==e){if(d.length>0){var f=String.format(ngettext("There is {0} reminder","There are {0} reminders",d.length),d.length);container.getNotifier().notify("info.reminder",_("Reminders"),f)}Zarafa.common.Actions.openReminderDialog(d);this.lastChecksum=e}}},dismissReminders:function(a){Ext.each(a,function(b){b.addMessageAction("action_type",
"dismiss")},this);this.remove(a);this.refreshStore=true;this.save(a)},snoozeReminders:function(a,b){Ext.each(a,function(c){c.addMessageAction("action_type","snooze");c.addMessageAction("snoozeTime",b)},this);this.remove(a);this.refreshStore=true;this.save(a)},onWrite:function(a,b,c,d,e){e=[].concat(e);for(var f=0,g=e.length;f<g;f++)if(e[f].getMessageAction("action_type")=="dismiss"||e[f].getMessageAction("action_type")=="snooze")if(this.refreshStore){this.sendReminderRequest();this.resetReminderInterval();
this.refreshStore=false;break}Zarafa.common.reminder.data.ReminderStore.superclass.onWrite.apply(this,arguments)}});Ext.reg("zarafa.reminderstore",Zarafa.common.reminder.data.ReminderStore);Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.RecurrenceDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{editRecurrence:false,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.recurrencedialog",layout:"fit",defaultTitle:_("Appointment Recurrence"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,width:600,height:500,items:[{xtype:"zarafa.recurrencepanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),scope:this,handler:this.onCancel},{text:_("Remove Recurrence"),handler:this.onRemoveRecurrence,
scope:this}]}]});Zarafa.common.recurrence.dialogs.RecurrenceDialog.superclass.constructor.call(this,a);this.mon(this,"beforesetrecord",this.onBeforeSetRecord,this);this.mon(this,"saverecord",this.onSaveRecord,this)},onBeforeSetRecord:function(a,b){if(b.get("recurring"))this.editRecurrence=true;else{var c=b.get("startdate")||new Date,d=b.get("duedate"),e=c.getHours()*60+c.getMinutes();if(!Ext.isEmpty(d)&&Ext.isDate(d))d=e+Date.diff(Date.MINUTE,d,c);else{d=c.clone().add(Date.MINUTE,30);d=d.getHours()*
60+d.getMinutes()}b.beginEdit();b.set("recurring",true);b.set("recurrence_type",Zarafa.common.recurrence.data.RecurrenceType.WEEKLY);b.set("recurrence_subtype",Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY.type);b.set("recurrence_regen",Zarafa.common.recurrence.data.RecurrenceSubtype.WEEKLY.regen);b.set("recurrence_term",Zarafa.common.recurrence.data.RecurrenceEnd.NEVER);b.set("recurrence_start",c.toUTC(true));b.set("recurrence_startocc",e);b.set("recurrence_endocc",d);b.set("recurrence_everyn",
1);b.set("recurrence_weekdays",Math.pow(2,c.getDay()));b.endEdit();this.editRecurrence=false}},onOk:function(){this.record.phantom!==true&&this.editRecurrence===true&&this.record.hasRecurringExceptions()?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("This will discard any exceptions which might have been made for this recurring series. Do you wish to continue?"),function(a){a==="yes"&&Zarafa.common.recurrence.dialogs.RecurrenceDialog.superclass.onOk.apply(this,arguments)},this):Zarafa.common.recurrence.dialogs.RecurrenceDialog.superclass.onOk.apply(this,
arguments)},onSaveRecord:function(a,b){b.set("recurring_reset",true);if(b.get("recurring")){b.updateTimezoneInformation();b.set("recurring_pattern",b.generateRecurringPattern())}else b.set("recurring_pattern","")},setDialogTitle:function(a){if(Ext.isDefined(a))a.isMessageClass("IPM.TaskRequest",true)?this.setTitle(_("Task Recurrence")):this.setTitle(_("Appointment Recurrence"));else this.setTitle("Recurrence")},onSetRecord:function(a,b,c){Zarafa.common.recurrence.dialogs.RecurrenceDialog.superclass.onSetRecord.call(this,
a,b,c);this.setDialogTitle(b)},onRemoveRecurrence:function(){this.record.beginEdit();this.record.set("recurring",false);this.record.set("recurrence_type",Zarafa.common.recurrence.data.RecurrenceType.NONE);this.record.endEdit();Ext.isDefined(this.modalRecord)&&this.modalRecord.applyData(this.record,true);if(this.autoSave!==false){var a=this.modalRecord||this.record;this.displayInfoMask();this.isSaving=true;a.save()}else this.close()}});
Zarafa.core.ui.Dialog.register(Zarafa.common.recurrence.dialogs.RecurrenceDialog,"zarafa.recurrencedialog");Ext.namespace("Zarafa.common.recurrence.data");Zarafa.common.recurrence.data.RecurrenceType=Zarafa.core.Enum.create({NONE:0,DAILY:10,WEEKLY:11,MONTHLY:12,YEARLY:13});Ext.namespace("Zarafa.common.recurrence.data");
Zarafa.common.recurrence.data.RecurrenceSubtype=Zarafa.core.Enum.create({DAILY_EVERY_N_DAYS:{type:0,regen:0},DAILY_WEEKDAYS:{type:1,regen:0},DAILY_REGENERATE:{type:0,regen:1},WEEKLY_REGENERATE:{type:0,regen:1},WEEKLY:{type:1,regen:0},MONTHLY_N_DAY_OF_MONTH:{type:2,regen:0},MONTHLY_N_WEEKDAY_OF_MONTH:{type:3,regen:0},MONTHLY_REGENERATE:{type:2,regen:1},YEARLY_MONTH:{type:2,regen:0},YEARLY_N_WEEKDAY:{type:3,regen:0},YEARLY_REGENERATE:{type:2,regen:1}});Ext.namespace("Zarafa.common.recurrence.data");
Zarafa.common.recurrence.data.RecurrenceEnd=Zarafa.core.Enum.create({NEVER:35,N_OCCURENCES:34,ON_DATE:33});Ext.namespace("Zarafa.common.printer.renderers");
Zarafa.common.printer.renderers.RecordRenderer=Ext.extend(Zarafa.common.printer.renderers.BaseRenderer,{addRow:function(a){var b=Ext.toArray(arguments),c="<tr>";c+='<th valign="top">'+a+(Ext.isEmpty(a)?"":":")+"</th>";for(var d=1,e=b.length;d<e;d++)c+='<td valign="top">'+b[d]+"</td>";c+="</tr>\n";return c},optionalRow:function(a,b,c){var d="";d+='<tpl if="!Ext.isEmpty(values.'+b+')">';d+=this.addRow(a,c);d+="</tpl>";return d},getAttachmentNames:function(a){if(a.get("hasattach")&&!a.get("hide_attachments")){a=
a.getAttachmentStore();for(var b=a.getCount(),c=[],d=0;d<b;d++)a.getAt(d).get("hidden")||c.push(a.getAt(d).get("name"));return c.join("; ")}return""},prepareData:function(a){var b=Zarafa.common.printer.renderers.RecordRenderer.superclass.prepareData(a),c;c=a.get("sensitivity");!Ext.isEmpty(c)&&c==0&&delete b.sensitivity;c=a.get("importance");!Ext.isEmpty(c)&&c==1&&delete b.importance;b.attachment_names=this.getAttachmentNames(a);return b},customStylesheetPath:"client/resources/css-extern/print.record.css"});
Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.UserlistBox=Ext.extend(Zarafa.common.recipientfield.ui.RecipientBox,{constructor:function(a){a=a||{};Ext.applyIf(a,{btnCls:"x-freebusy-userrow-remove",btnHoverCls:"x-freebusy-userrow-remove-hover"});Zarafa.common.freebusy.ui.UserlistBox.superclass.constructor.call(this,a)},prepareIcon:function(a){switch(a.get("recipient_type")){case Zarafa.core.mapi.RecipientType.MAPI_CC:return"x-freebusy-userlist-recipienttype-optional";case Zarafa.core.mapi.RecipientType.MAPI_BCC:return"x-freebusy-userlist-recipienttype-resource";case Zarafa.core.mapi.RecipientType.MAPI_TO:default:if(a.isMeetingOrganizer())return"x-freebusy-userlist-recipienttype-originator";
return"x-freebusy-userlist-recipienttype-required"}},afterRender:function(a){Zarafa.common.freebusy.ui.UserlistBox.superclass.afterRender.call(this,a);this.delBtnEl.setVisible(this.editable)},update:function(a){a.isMeetingOrganizer()&&this.setEditable(false);Zarafa.common.freebusy.ui.UserlistBox.superclass.update.apply(this,arguments)}});Ext.reg("zarafa.userlistbox",Zarafa.common.freebusy.ui.UserlistBox);Ext.namespace("Zarafa.common.delegates.dialogs");
Zarafa.common.delegates.dialogs.DelegatePermissionDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.delegatepermissiondialog",layout:"fit",model:true,allowWrite:true,autoSave:false,useShadowStore:false,width:500,height:300,items:[{xtype:"zarafa.delegatepermissionpanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}],defaultTitle:_("Delegate Permissions"),alwaysUseDefaultTitle:true});
Zarafa.common.delegates.dialogs.DelegatePermissionDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.common.delegates.dialogs.DelegatePermissionDialog,"zarafa.delegatepermissiondialog");Ext.namespace("Zarafa.common.data");
Zarafa.common.data.FolderContentTypes=Zarafa.core.Enum.create({mail:"IPF.NOTE",appointment:"IPF.APPOINTMENT",contact:"IPF.CONTACT",journal:"IPF.JOURNAL",note:"IPF.STICKYNOTE",task:"IPF.TASK",ipmsubtree:"IPM.SUBTREE",getContentName:function(a){switch(a.toUpperCase()){case Zarafa.common.data.FolderContentTypes.mail:return _("Mail and Post");case Zarafa.common.data.FolderContentTypes.appointment:return _("Calendar");case Zarafa.common.data.FolderContentTypes.contact:return _("Contact");case Zarafa.common.data.FolderContentTypes.journal:return _("Journal");
case Zarafa.common.data.FolderContentTypes.note:return _("Note");case Zarafa.common.data.FolderContentTypes.task:return _("Task");default:return a}},getFolderName:function(a){switch(a.toUpperCase()){case Zarafa.common.data.FolderContentTypes.mail:return _("Inbox");case Zarafa.common.data.FolderContentTypes.appointment:return _("Calendar");case Zarafa.common.data.FolderContentTypes.contact:return _("Contact");case Zarafa.common.data.FolderContentTypes.note:return _("Notes");case Zarafa.common.data.FolderContentTypes.task:return _("Task");
case Zarafa.common.data.FolderContentTypes.ipmsubtree:return _("Entire Inbox");default:return a}}});Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachmentsDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.attachmentsdialog",layout:"fit",width:500,height:300,items:[{xtype:"zarafa.attachmentspanel",buttons:[{text:_("Close"),handler:this.onClose,scope:this}]}],defaultTitle:_("Attachments"),useShadowStore:false,alwaysUseDefaultTitle:true,border:false});Zarafa.common.attachment.dialogs.AttachmentsDialog.superclass.constructor.call(this,a)},onClose:function(){this.close()}});
Zarafa.core.ui.Dialog.register(Zarafa.common.attachment.dialogs.AttachmentsDialog,"zarafa.attachmentsdialog");Ext.namespace("Zarafa.task.printer");
Zarafa.task.printer.TaskListViewRenderer=Ext.extend(Zarafa.common.printer.renderers.BaseRenderer,{generateBodyTemplate:function(){var a="";a+='<table id="tasks" class="task-list" cellpadding=0 cellspacing=0>\n';a+='<tr class="nowrap"><th>'+_("Priority")+"</th><th>"+_("% Completed")+'</th><th class="wrap fullwidth">'+_("Subject")+"</th><th>"+_("Owner")+"</th><th>"+_("Due date")+"</th></tr>";a+='<tpl for="tasks"><tr class="nowrap"><td>{values.data.importance:importanceString}</td><td>{values.data.percent_complete:percentage(0)}</td><td class="wrap fullwidth">{values.data.subject:htmlEncode}</td><td>{values.data.owner:htmlEncode}</td><td>{values.data.duedate:date("'+
_("l jS F Y")+'")}</td></tr></tpl>';a+="</table>";a+='<table id="bottom"><tr><td class="nowrap" align=left>{fullname:htmlEncode}</td><td class="nowrap" align=right>{currenttime:date("'+_("l jS F Y G:i")+'")}</td></tr></table>\n';return a},prepareData:function(a){var b=Zarafa.calendar.printer.WorkWeekViewRenderer.superclass.prepareData(a);a=a.getModel();b.currenttime=new Date;b.tasks=a.getStore().getRange();return b},customStylesheetPath:"client/resources/css-extern/print.task.css"});Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.task.taskdialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Ext.apply(this,a);Zarafa.task.dialogs.TaskToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",hidden:true,overflowText:_("Send task to assignee"),
tooltip:{title:_("Send assignment"),text:_("Send task to assignee")},iconCls:"icon_sendEmail",ref:"send",handler:this.onSendTask,scope:this},{xtype:"button",overflowText:_("Save task"),tooltip:{title:_("Save task"),text:_("Save task")},iconCls:"icon_save",handler:this.onSave,scope:this},{xtype:"button",overflowText:_("Add Attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this task")},iconCls:"icon_attachment",handler:this.onAddAttachment,scope:this},{xtype:"button",ref:"markComplete",
overflowText:_("Mark as Complete"),tooltip:{title:_("Mark as Complete"),text:_("Mark this task as complete")},iconCls:"icon_task_complete",handler:this.onComplete,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this item")},iconCls:"icon_delete",handler:this.onDelete,scope:this},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this item")},iconCls:"icon_print",handler:this.onPrint,scope:this},{xtype:"button",
hidden:true,overflowText:_("Check names"),tooltip:{title:_("Check names"),text:_("Check all recipient names")},iconCls:"icon_checkNames",ref:"checkNames",handler:this.onCheckNames,scope:this}]},createOptionButtons:function(){return[{xtype:"button",hidden:true,text:_("Recurrence"),overflowText:_("Recurrence"),tooltip:{title:_("Recurrence"),text:_("Open the recurrence dialog")},iconCls:"icon_recurrence",handler:this.onRecurrence,scope:this},{xtype:"button",hidden:true,text:_("Assign Task"),overflowText:_("Assign Task"),
tooltip:{title:_("Assign Task"),text:_("Assign Task")},iconCls:"icon_create_task_request",ref:"assignTask",handler:this.onAssignment,scope:this},{xtype:"button",hidden:true,text:_("Cancel Assignment"),tooltip:{title:_("Cancel Assignment"),text:_("Cancel assigned attendee for this task")},overflowText:_("Cancel Assignment"),iconCls:"icon_cancel_meeting_request",ref:"cancelAssigmnet",handler:this.onCancelAssignment,scope:this},{xtype:"button",overflowText:_("Categories"),tooltip:{title:_("Categories"),
text:_("Open the categories dialog")},iconCls:"icon_categories",handler:this.onCategories,scope:this},{xtype:"button",overflowText:_("Private"),tooltip:{title:_("Private"),text:_("Mark this appointment as private")},iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSave:function(){this.dialog.saveRecord()},onAddAttachment:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},onCheckNames:function(){this.record.getRecipientStore().resolve(undefined,
{cancelPreviousRequest:true})},onRecurrence:function(){Zarafa.common.Actions.openRecurrenceDialog(this.record,false,this.dialog.isBrowser())},onAssignment:function(){this.record.beginEdit();this.record.set("taskstate",Zarafa.core.mapi.TaskState.OWNER_NEW);this.record.set("taskmode",Zarafa.core.mapi.TaskMode.REQUEST);this.record.endEdit()},onCancelAssignment:function(){this.record.beginEdit();this.record.set("taskstate",Zarafa.core.mapi.TaskState.NORMAL);this.record.set("taskmode",Zarafa.core.mapi.TaskMode.NOTHING);
this.record.endEdit()},onComplete:function(){this.record.beginEdit();this.record.set("complete",true);this.record.set("percent_complete",1);this.record.set("status",Zarafa.core.mapi.TaskStatus.COMPLETE);this.record.set("date_completed",new Date);this.record.endEdit();this.dialog.saveRecord()},onCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.record,false,this.dialog.isBrowser())},onDelete:function(){this.dialog.deleteRecord()},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.record)},
onPrivateGroupToggle:function(a){this.record.beginEdit();this.record.set("private",a.pressed);a.pressed?this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.PRIVATE):this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.NONE);this.record.endEdit()},update:function(a,b){this.record=a;this.deleteBtn.setDisabled(a.phantom===true);if(b===true||a.isModifiedSinceLastUpdate("complete"))this.markComplete.setDisabled(a.get("complete"));if(b===true||a.isModifiedSinceLastUpdate("private"))this.setPrivate.toggle(a.get("private"),
true);if(b===true||a.isModified("taskmode")){switch(a.get("taskmode")){case Zarafa.core.mapi.TaskMode.NOTHING:default:this.send.setVisible(false);this.checkNames.setVisible(false);this.cancelAssigmnet.setVisible(false);break}this.doLayout()}},onSendTask:function(){this.dialog.sendRecord()}});Ext.reg("zarafa.taskdialogtoolbar",Zarafa.task.dialogs.TaskToolbar);Ext.namespace("Zarafa.task.data");Zarafa.task.data.Views=Zarafa.core.Enum.create({LIST:0,SEARCH:1});Ext.namespace("Zarafa.task.data");
Zarafa.task.data.ViewModes=Zarafa.core.Enum.create({NORMAL:0,SEARCH:1});Ext.namespace("Zarafa.task.data");Zarafa.task.data.DataModes=Zarafa.core.Enum.create({ALL:0,ACTIVE:1,NEXT_7_DAYS:2,OVERDUE:3,COMPLETED:4,SEARCH:5});Ext.namespace("Zarafa.task");
Zarafa.task.TaskContextModel=Ext.extend(Zarafa.core.ContextModel,{oldDataMode:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.task.TaskStore;Ext.applyIf(a,{current_data_mode:Zarafa.task.data.DataModes.ALL});Zarafa.task.TaskContextModel.superclass.constructor.call(this,a);this.on({searchstart:this.onSearchStart,searchstop:this.onSearchStop,scope:this})},createRecord:function(a){a=a||this.getDefaultFolder();var b=a.getMAPIStore();return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Task",
{object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid"),icon_index:Zarafa.core.mapi.IconIndex.task_normal,owner:b.isPublicStore()?container.getUser().getFullName():b.get("mailbox_owner_name")})},onDataModeChange:function(a,b,c){Zarafa.task.TaskContextModel.superclass.onDataModeChange.call(this,a,b,c);b!==c&&c===Zarafa.task.data.DataModes.SEARCH&&this.stopSearch();switch(b){case Zarafa.task.data.DataModes.SEARCH:this.store.clearFilter();
break;case Zarafa.task.data.DataModes.ALL:this.store.clearFilter();this.load();break;case Zarafa.task.data.DataModes.ACTIVE:this.store.filterBy(function(f){return f.get("status")!=Zarafa.core.mapi.TaskStatus.COMPLETE},this);this.load();break;case Zarafa.task.data.DataModes.NEXT_7_DAYS:var d=(new Date).clearTime(),e=d.clone().add(Date.DAY,7);this.store.filterBy(function(f){f=f.get("duedate");return f>d&&f<e},this);this.load();break;case Zarafa.task.data.DataModes.OVERDUE:d=(new Date).clearTime();this.store.filterBy(function(f){return f.get("duedate")<
d&&!f.get("complete")},this);this.load();break;case Zarafa.task.data.DataModes.COMPLETED:this.store.filterBy(function(f){return f.get("complete")},this);this.load();break}},onSearchStart:function(){if(this.getCurrentDataMode()!=Zarafa.task.data.DataModes.SEARCH){this.oldDataMode=this.getCurrentDataMode();this.setDataMode(Zarafa.task.data.DataModes.SEARCH)}},onSearchStop:function(){this.getCurrentDataMode()===Zarafa.task.data.DataModes.SEARCH&&this.setDataMode(this.oldDataMode);delete this.oldDataMode}});
Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsTreePanel=Ext.extend(Zarafa.common.ui.EditorTreeGrid,{editors:undefined,model:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.editortreegrid",ref:"treeGrid",border:false,rootVisible:true,enableHdMenu:false,enableSort:true,forceFit:true,loader:new Zarafa.settings.data.SettingsTreeLoader({model:a.model,autoExpandLevel:4,autoExpandFilter:/^\/*(zarafa.*)?$/}),root:new Zarafa.settings.ui.SettingsTreeNode({text:_("Settings"),id:"/",expanded:false}),editors:{"boolean":{xtype:"checkbox"},
number:{xtype:"zarafa.spinnerfield",plugins:["zarafa.numberspinner"]},string:{xtype:"textfield"}},columns:[{id:"setting",header:_("Setting"),dataIndex:"text",tpl:"{text:htmlEncodeUndef}"},{id:"value",header:_("Value"),dataIndex:"value",tpl:"{value:htmlEncodeUndef}",width:250,editable:true}]});Zarafa.settings.ui.SettingsTreePanel.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.settings.ui.SettingsTreePanel.superclass.initEvents.call(this);this.mon(this,"afteredit",this.onAfterEdit,
this);this.mon(this,"contextmenu",this.onContextMenu,this);this.model&&this.bindModel(this.model,true)},bindModel:function(a,b){if(b||this.model!==a){if(this.model){this.mun(this.model,"set",this.onSettingsChange,this);this.mun(this.model,"remove",this.onSettingsRemove,this);this.root.collapse()}if(this.model=a){this.loader.bindModel(this.model);this.mon(this.model,{set:this.onSettingsChange,remove:this.onSettingsRemove,scope:this});this.root.expand()}}else this.root.reload()},onSettingsChange:function(a,
b){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){var e=b[c],f=this.getNodeById(e.path);if(f)f.attributes.value!==e.value&&this.rendered&&f.setValue(e.value);else{f=e.path.lastIndexOf("/");(e=this.getNodeById(e.path.substring(0,f)||"/"))&&e.isLoaded()&&e.reload()}}},onSettingsRemove:function(a,b){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){var e=this.getNodeById(b[c]);e&&e.remove(true)}},onAfterEdit:function(a,b,c,d){this.model.set(b.id,d)},onContextMenu:function(a,b){a.select();
Zarafa.common.Actions.openContextMenu(a,b.getXY(),{settingsModel:this.model})},getEditor:function(a,b){var c=this.getColumn(b).dataIndex;c=typeof a.attributes[c];if(Ext.isDefined(this.editors[c]))return Ext.create(this.editors[c]);else Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:String.format(_("The setting '{0}' can not be edited"),Ext.util.Format.htmlEncode(a.text)),icon:Ext.MessageBox.WARNING,buttons:Ext.MessageBox.OK})},onDestroy:function(){Zarafa.settings.ui.SettingsTreePanel.superclass.onDestroy.call(this);
for(var a in this.editors){var b=this.editors[a];Ext.isFunction(b.destroy)&&b.destroy()}}});Ext.reg("zarafa.settingstreepanel",Zarafa.settings.ui.SettingsTreePanel);Ext.namespace("Zarafa.settings");
Zarafa.settings.SettingsContextModel=Ext.extend(Zarafa.core.ContextModel,{realModel:undefined,editModel:undefined,setlist:undefined,dellist:undefined,dirty:false,constructor:function(a){a=a||{};this.realModel=container.getSettingsModel();this.editModel=new Zarafa.settings.SettingsModel({autoSave:false});Ext.applyIf(a,{stateful:false});this.addEvents("beforesavesettings","savesettings","discardsettings");Zarafa.settings.SettingsContextModel.superclass.constructor.call(this,a);this.editModel.on("set",
this.onSetSetting,this);this.editModel.on("remove",this.onRemoveSetting,this)},enable:function(){Zarafa.settings.SettingsContextModel.superclass.enable.apply(this,arguments);this.editModel.initialize(this.realModel.get(undefined,true))},disable:Ext.emptyFn,getEditableSettingsModel:function(){return this.editModel},hasChanges:function(){return this.dirty},setDirty:function(){this.dirty=true},applyChanges:function(){if(this.fireEvent("beforesavesettings",this,this.editModel)!==false){this.realModel.beginEdit();
if(!Ext.isEmpty(this.setlist))for(var a=0,b=this.setlist.length;a<b;a++){var c=this.setlist[a];Ext.isDefined(c.value)&&this.realModel.set(c.path,c.value)}if(!Ext.isEmpty(this.dellist)){a=0;for(b=this.dellist.length;a<b;a++){c=this.dellist[a];this.realModel.remove(c)}}this.realModel.endEdit();this.dirty=false;delete this.setlist;delete this.dellist;this.fireEvent("savesettings",this,this.editModel)}},discardChanges:function(){this.editModel.initialize(this.realModel.get(undefined,true));this.dirty=
false;delete this.setlist;delete this.dellist;this.fireEvent("discardsettings",this,this.editModel)},setFolders:Ext.emptyFn,onSetSetting:function(a,b){this.dirty=true;this.setlist=Ext.value(this.setlist,[]);this.setlist=this.setlist.concat(b)},onRemoveSetting:function(a,b){this.dirty=true;this.dellist=Ext.value(this.dellist,[]);this.dellist=this.dellist.concat(b)}});Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteGridView=Ext.extend(Zarafa.common.ui.grid.GridPanel,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))a.store=a.model.getStore();a.store=Ext.StoreMgr.lookup(a.store);Ext.applyIf(a,{id:"note-gridview",border:false,autoExpandColumn:"subject",stateful:true,statefulRelativeDimensions:false,loadMask:this.initLoadMask(),viewConfig:this.initViewConfig(),
selModel:this.initSelectionModel(),colModel:this.initColumnModel(),enableDragDrop:true,ddGroup:"dd.mapiitem",keys:{key:Ext.EventObject.DELETE,handler:this.onKeyDelete,scope:this}});Zarafa.note.ui.NoteGridView.superclass.constructor.call(this,a)},initViewConfig:function(){return{}},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:false,listeners:{scope:this,selectionchange:this.onSelectionChange}})},initColumnModel:function(){return new Zarafa.note.ui.NoteGridColumnModel},
getMainPanel:function(){return this.ownerCt},initLoadMask:function(){return{msg:_("Loading Notes")+"..."}},initEvents:function(){Zarafa.note.ui.NoteGridView.superclass.initEvents.call(this);this.on("rowcontextmenu",this.onNoteRowContextMenu,this);this.on("rowdblclick",this.onNoteRowDblClick,this)},onNoteRowContextMenu:function(a,b,c){a=this.getSelectionModel();a.isSelected(b)||a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),c.getXY())},onNoteRowDblClick:function(a){Zarafa.note.Actions.openNoteDialog(a.getSelectionModel().getSelected())},
onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},onKeyDelete:function(){var a=this.getSelectionModel().getSelections();Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)}});Ext.reg("zarafa.notegridview",Zarafa.note.ui.NoteGridView);Ext.namespace("Zarafa.note.dialogs");
Zarafa.note.dialogs.NoteEditToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.note.noteeditdialog",actionItems:this.createActionButtons()});Zarafa.note.dialogs.NoteEditToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",overflowText:_("Save Note"),tooltip:{title:_("Save note"),text:_("Save note")},
iconCls:"icon_save",handler:this.onSaveButton,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this item")},iconCls:"icon_delete",handler:this.onDeleteButton,scope:this},{xtype:"button",overflowText:_("Set Category"),tooltip:{title:_("Categories"),text:_("Open the categories dialog.")},iconCls:"icon_categories",handler:this.onOpenCategories,scope:this},{hidden:true,xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this note")},
iconCls:"icon_print",handler:this.onPrintRecord,scope:this},{xtype:"label",text:_("Color")+":"},{xtype:"combo",width:75,overflowText:_("Color"),ref:"colorCombo",store:{xtype:"arraystore",fields:["icon_index","name"],data:[[768,_("Blue")],[769,_("Green")],[770,_("Pink")],[771,_("Yellow")],[772,_("White")]]},displayField:"name",valueField:"icon_index",mode:"local",editable:false,triggerAction:"all",listeners:{select:this.onComboSelect,scope:this}}]},onSaveButton:function(){this.dialog.saveRecord()},
onDeleteButton:function(){this.dialog.deleteRecord()},onComboSelect:function(a,b){this.record.set("icon_index",b.get("icon_index"))},onOpenCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.record,this.dialog.isBrowser())},onPrintRecord:function(){Zarafa.common.Actions.openPrintDialog(this.record,this.dialog.isBrowser())},update:function(a){this.record=a;this.deleteBtn.setDisabled(a.phantom===true);this.colorCombo.setValue(a.get("icon_index"))},updateRecord:function(a){a.set("icon_index",
this.colorCombo.getValue())}});Ext.reg("zarafa.noteedittoolbar",Zarafa.note.dialogs.NoteEditToolbar);Ext.namespace("Zarafa.note.dialogs");
Zarafa.note.dialogs.NoteEditDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.noteeditdialog",layout:"fit",defaultTitle:_("Make a New Note"),allowWrite:true,confirmClose:true,items:[this.createPanel()]});Zarafa.note.dialogs.NoteEditDialog.superclass.constructor.call(this,a)},createPanel:function(){return{iconCls:"icon_folder_note",border:false,tbar:{xtype:"zarafa.noteedittoolbar"},xtype:"zarafa.noteeditpanel",layout:"fit"}},getNoteEditPanel:function(){return this.findByType("zarafa.noteeditpanel")[0]}});
Zarafa.core.ui.Dialog.register(Zarafa.note.dialogs.NoteEditDialog,"zarafa.noteeditdialog");Ext.namespace("Zarafa.note.data");Zarafa.note.data.Views=Zarafa.core.Enum.create({LIST:0,ICON:1,SEARCH:2});Ext.namespace("Zarafa.note.data");Zarafa.note.data.ViewModes=Zarafa.core.Enum.create({NORMAL:0,GROUP_CATEGORY:1,GROUP_COLOR:2,SEARCH:3});Ext.namespace("Zarafa.note.data");Zarafa.note.data.DataModes=Zarafa.core.Enum.create({ALL:0,LAST_7_DAYS:1,SEARCH:2});Ext.namespace("Zarafa.note");
Zarafa.note.NoteContextModel=Ext.extend(Zarafa.core.ContextModel,{oldDataMode:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.note.NoteStore;Ext.applyIf(a,{current_data_mode:Zarafa.note.data.DataModes.ALL});Zarafa.note.NoteContextModel.superclass.constructor.call(this,a);this.on({searchstart:this.onSearchStart,searchstop:this.onSearchStop,scope:this})},createRecord:function(a){a=a||this.getDefaultFolder();return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.StickyNote",
{object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid")})},onDataModeChange:function(a,b,c){Zarafa.note.NoteContextModel.superclass.onDataModeChange.call(this,a,b,c);b!==c&&c===Zarafa.note.data.DataModes.SEARCH&&this.stopSearch();switch(b){case Zarafa.note.data.DataModes.SEARCH:this.store.clearFilter();break;case Zarafa.note.data.DataModes.ALL:this.store.clearFilter();this.load();break;case Zarafa.note.data.DataModes.LAST_7_DAYS:var d=
(new Date).clearTime().add(Date.DAY,-7);this.store.filterBy(function(e){return e.get("last_modification_time")>d},this);this.load();break}},onSearchStart:function(){if(this.getCurrentDataMode()!=Zarafa.note.data.DataModes.SEARCH){this.oldDataMode=this.getCurrentDataMode();this.setDataMode(Zarafa.note.data.DataModes.SEARCH)}},onSearchStop:function(){this.getCurrentDataMode()===Zarafa.note.data.DataModes.SEARCH&&this.setDataMode(this.oldDataMode);delete this.oldDataMode}});Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.ShowMailToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{context:undefined,model:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{xtype:"mail.showmailtoolbar",insertionPointBase:"context.mail.showmaildialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.mail.dialogs.ShowMailToolbar.superclass.constructor.call(this,
a)},createActionButtons:function(){return[{xtype:"button",rowspan:2,text:_("Reply"),overflowText:_("Reply"),iconCls:"icon_replyEmail",actionType:Zarafa.mail.data.ActionTypes.reply,handler:this.onMailRespondsButton,scope:this},{xtype:"button",text:_("Reply All"),overflowText:_("Reply All"),iconCls:"icon_replyAllEmail",actionType:Zarafa.mail.data.ActionTypes.replyall,handler:this.onMailRespondsButton,scope:this},{xtype:"button",text:_("Forward"),overflowText:_("Forward"),iconCls:"icon_forwardEmail",
actionType:Zarafa.mail.data.ActionTypes.forward,handler:this.onMailRespondsButton,scope:this},{xtype:"button",overflowText:_("Delete this item."),iconCls:"icon_delete",handler:this.onDeleteButton,scope:this}]},createOptionButtons:function(){return[{xtype:"button",overflowText:_("Options"),tooltip:{title:_("Options"),text:_("Open options dialog")},iconCls:"icon_openMessageOptions",handler:this.onMailOptionsButton,scope:this},{xtype:"button",iconCls:"icon_print",overflowText:_("Print"),tooltip:{title:_("Print"),
text:_("Print this email")},handler:this.onPrintButton,scope:this},{xtype:"button",overflowText:_("Set flag"),tooltip:{title:_("Set flag"),text:_("Set flag on this email")},iconCls:"icon_flag_red",handler:this.onSetFlagButton,scope:this}]},update:function(a){this.record=a},onSetFlagButton:function(){Zarafa.mail.Actions.openMailFlagsDialog(this.record,true,this.dialog.isBrowser())},onMailOptionsButton:function(){Zarafa.mail.Actions.openMailOptionsDialog(this.record,true,this.dialog.isBrowser())},onDeleteButton:function(){this.dialog.deleteRecord()},
onPrintButton:function(){Zarafa.common.Actions.openPrintDialog(this.record)},onMailRespondsButton:function(a){Zarafa.mail.Actions.openMailRespondsDialog(this.record,this.model,a.actionType,this.dialog.isBrowser())}});Ext.reg("zarafa.showmailtoolbar",Zarafa.mail.dialogs.ShowMailToolbar);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailViewOptionsDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailviewoptionsdialog",layout:"fit",defaultTitle:_("Message Options"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:a.modal?false:true,width:400,height:400,items:[{xtype:"zarafa.mailviewoptionspanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.mail.dialogs.MailViewOptionsDialog.superclass.constructor.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.mail.dialogs.MailViewOptionsDialog,"zarafa.mailviewoptionsdialog");Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailFlagsDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{disableFlagColor:false,disableCompleted:false,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailflagsdialog",layout:"fit",width:350,height:150,items:[{xtype:"zarafa.mailflagspanel",disableFlagColor:Ext.isBoolean(a.disableFlagColor)?a.disableFlagColor:this.disableFlagColor,disableCompleted:Ext.isBoolean(a.disableCompleted)?a.disableCompleted:this.disableCompleted,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},
{text:_("Cancel"),handler:this.onCancel,scope:this}]}],autoSave:Ext.isDefined(a.modal)?a.modal:true,defaultTitle:_("E-Mail Flags"),alwaysUseDefaultTitle:true,allowWrite:true});Zarafa.mail.dialogs.MailFlagsDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.mail.dialogs.MailFlagsDialog,"zarafa.mailflagsdialog");Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.mailcreatetoolbar",insertionPointBase:"context.mail.mailcreatedialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.mail.dialogs.MailCreateToolbar.superclass.constructor.call(this,a)},onRender:function(){Zarafa.mail.dialogs.MailCreateToolbar.superclass.onRender.apply(this,
arguments);if(this.dialog){this.mon(this.dialog,"bcctoggle",this.onDialogBccToggle,this);this.mon(this.dialog,"fromtoggle",this.onDialogFromToggle,this)}var a=container.getSettingsModel();this.mon(a,"set",this.onSettingsChange,this);this.mon(a,"remove",this.onSettingsChange,this);this.onSettingsChange(a)},createActionButtons:function(){return[{xtype:"button",text:_("Send"),overflowText:_("Send email"),ref:"sendButton",tooltip:{title:_("Send email"),text:_("Send email to recipients")},iconCls:"icon_sendEmail",
handler:this.onSendButton,scope:this},{xtype:"button",overflowText:_("Save email"),tooltip:{title:_("Save email"),text:_("Save email")},iconCls:"icon_saveEmail",handler:this.onSaveButton,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this item")},iconCls:"icon_delete",handler:this.onDeleteButton,scope:this},{xtype:"button",overflowText:_("Add attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this email")},iconCls:"icon_attachment",
handler:this.onAddAttachmentsButton,scope:this},{xtype:"tbseparator"},{xtype:"button",overflowText:_("Check names"),tooltip:{title:_("Check names"),text:_("Check all recipient names")},iconCls:"icon_checkNames",handler:this.onCheckNamesButton,scope:this},{xtype:"button",overflowText:_("Add signature"),tooltip:{title:_("Add signature"),text:_("Add signature to this mail")},iconCls:"icon_addSignature",ref:"signatureButton",scope:this}]},createOptionButtons:function(){return[{xtype:"button",overflowText:_("Options"),
tooltip:{title:_("Options"),text:_("Open options dialog")},iconCls:"icon_openMessageOptions",handler:this.onMailOptionsButton,scope:this},{xtype:"button",overflowText:_("Set flag"),tooltip:{title:_("Set flag"),text:_("Set flag on this email")},iconCls:"icon_flag_red",handler:this.onSetFlagButton,scope:this},{xtype:"button",overflowText:_("High priority"),tooltip:{title:_("High priority"),text:_("Mark this appointment as high priority")},iconCls:"icon_setHighPriority",ref:"highPriority",toggleGroup:"priorityGroup",
importance:Zarafa.core.mapi.Importance.URGENT,handler:this.onPriorityGroupToggle,scope:this},{xtype:"button",overflowText:_("Low priority"),tooltip:{title:_("Low priority"),text:_("Mark this appointment as low priority")},iconCls:"icon_setLowPriority",ref:"lowPriority",toggleGroup:"priorityGroup",importance:Zarafa.core.mapi.Importance.NONURGENT,handler:this.onPriorityGroupToggle,scope:this},{xtype:"button",overflowText:_("Set read receipt"),tooltip:{title:_("Set read receipt"),text:_("Request read receipt from recipients")},
iconCls:"icon_setReadReceipt",enableToggle:true,ref:"readReceiptField",toggleHandler:this.onReadReceiptToggle,scope:this},{xtype:"button",overflowText:_("Show bcc"),tooltip:{title:_("Show Bcc"),text:_("Show Bcc field in which you can specify the people who will recieve this message")},iconCls:"icon_showbcc",ref:"showBcc",enableToggle:true,toggleHandler:this.onBccMenuToggle,scope:this},{xtype:"button",overflowText:_("Show From"),tooltip:{title:_("Show From"),text:_("Show From field, If you have delegate access to another person's account, you can send e-mail that looks like that came from them by entering their name into the From field")},
iconCls:"icon_showfrom",ref:"showFrom",enableToggle:true,toggleHandler:this.onFromMenuToggle,scope:this}]},onSettingsChange:function(a,b){var c=true;if(!Ext.isEmpty(b)){c=false;for(var d=0;d<b.length;d++)if(b[d].path&&b[d].path.indexOf("zarafa/v1/contexts/mail/signatures/all")>=0){c=true;break}}if(c){d=a.get("zarafa/v1/contexts/mail/signatures/all",true);if(!Ext.isEmpty(d)){c=[];for(var e in d)c.push({text:Ext.util.Format.htmlEncode(d[e].name),signatureId:parseInt(e,10)});c.length==0&&c.push({text:_("No signatures configured"),
signatureId:false});if(this.signatureButton.menu){e=this.signatureButton.menu;e.removeAll();e.add(c)}else this.signatureButton.menu=Ext.menu.MenuMgr.get({xtype:"menu",listeners:{click:this.onSignatureSelect,scope:this},items:c})}}},onSignatureSelect:function(a,b){Ext.isNumber(b.signatureId)&&this.dialog.mainPanel.setSignatureInEditor(b.signatureId)},onSendButton:function(){this.dialog.sendRecord()},onSaveButton:function(){this.dialog.saveRecord()},onDeleteButton:function(){this.dialog.deleteRecord()},
onAddAttachmentsButton:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},onCheckNamesButton:function(){this.record.getRecipientStore().resolve(undefined,{cancelPreviousRequest:true})},onMailOptionsButton:function(){Zarafa.mail.Actions.openMailOptionsDialog(this.record,false,this.dialog.isBrowser())},onSetFlagButton:function(){Zarafa.mail.Actions.openMailFlagsDialog(this.record,false,this.dialog.isBrowser())},onPriorityGroupToggle:function(a){a.pressed?this.record.set("importance",
a.importance):this.record.set("importance",Zarafa.core.mapi.Importance.NORMAL)},onBccMenuToggle:function(a,b){this.dialog.toggleBccState(b)},onFromMenuToggle:function(a,b){this.dialog.toggleFromState(b)},onDialogBccToggle:function(a,b){this.showBcc.toggle(b,true)},onDialogFromToggle:function(a,b){this.showFrom.toggle(b,true)},onReadReceiptToggle:function(a){this.record.set("read_receipt_requested",a.pressed)},update:function(a,b){this.record=a;this.deleteBtn.setDisabled(a.phantom===true);if(b===true||
a.isModifiedSinceLastUpdate("importance"))switch(a.get("importance")){case Zarafa.core.mapi.Importance.URGENT:this.highPriority.toggle(true,true);break;case Zarafa.core.mapi.Importance.NONURGENT:this.lowPriority.toggle(true,true);break;default:break}if(b===true||a.isModifiedSinceLastUpdate("read_receipt_requested"))this.readReceiptField.toggle(this.record.get("read_receipt_requested"),true)}});Ext.reg("zarafa.mailcreatetoolbar",Zarafa.mail.dialogs.MailCreateToolbar);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateOptionsDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailcreateoptionsdialog",layout:"fit",defaultTitle:_("Message Options"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:a.modal?false:true,width:320,height:190,items:[{xtype:"zarafa.mailcreateoptionspanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.mail.dialogs.MailCreateOptionsDialog.superclass.constructor.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.mail.dialogs.MailCreateOptionsDialog,"zarafa.mailcreateoptionsdialog");Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.Views=Zarafa.core.Enum.create({LIST:0,SEARCH:1});Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.ViewModes=Zarafa.core.Enum.create({NO_PREVIEW:0,RIGHT_PREVIEW:1,BOTTOM_PREVIEW:2,SEARCH:3});Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.DataModes=Zarafa.core.Enum.create({ALL:0,SEARCH:1});Ext.namespace("Zarafa.mail");
Zarafa.mail.MailContextModel=Ext.extend(Zarafa.core.ContextModel,{oldDataMode:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.mail.MailStore;Ext.applyIf(a,{statefulRecordSelection:true,current_data_mode:Zarafa.mail.data.DataModes.ALL});Zarafa.mail.MailContextModel.superclass.constructor.call(this,a);this.on({searchstart:this.onSearchStart,searchstop:this.onSearchStop,scope:this})},createRecord:function(a){a=a||container.getHierarchyStore().getDefaultFolder("drafts");
var b=this.getSignatureId();return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Note",{store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid"),body:this.getSignatureData(false,b),html_body:this.getSignatureData(true,b),isHTML:true})},createResponseRecord:function(a,b){if(!(Ext.isEmpty(b)||!a)){var c=this.createRecord();c.addMessageAction("action_type",b);c.addMessageAction("source_entryid",a.get("entryid"));c.addMessageAction("source_store_entryid",a.get("store_entryid"));
this.initRecordSubject(c,a,b);this.initRecordBody(c,a,b);this.initRecordRecipients(c,a,b);this.initRecordAttachments(c,a,b);if(!a.userIsStoreOwner()){var d=container.getHierarchyStore().getByEntryId(a.get("store_entryid"));d&&c.setDelegatorInfo(d)}return c}},initRecordSubject:function(a,b,c){var d=undefined;switch(c){case Zarafa.mail.data.ActionTypes.reply:case Zarafa.mail.data.ActionTypes.replyall:d=_("RE");break;case Zarafa.mail.data.ActionTypes.forward:d=_("FW");break;default:d=_("RE");break}a.set("subject",
d+": "+b.get("normalized_subject"));a.set("normalized_subject",b.get("normalized_subject"))},initRecordBody:function(a,b,c){var d=this.getSignatureId(c),e=Ext.apply({},b.data);if(b.isOpened()){var f=b.getRecipientStore(),g=[],h=[];if(f.getCount()>0){f.each(function(i){switch(i.get("recipient_type")){case Zarafa.core.mapi.RecipientType.MAPI_TO:g.push(f.formatRecipient(i));break;case Zarafa.core.mapi.RecipientType.MAPI_CC:h.push(f.formatRecipient(i));break}},this);e.display_to=g.join("; ");e.display_cc=
h.join("; ")}}a.set("isHTML",b.get("isHTML"));c=new Ext.XTemplate(Zarafa.mail.data.Templates.htmlQuotedTemplate,{compiled:true});e.body=b.getBody(true);e.signatureData=this.getSignatureData(true,d);a.set("html_body",c.apply(e));c=new Ext.XTemplate(Zarafa.mail.data.Templates.plaintextQuotedTemplate,{compiled:true});e.body=b.getBody(false);e.signatureData=this.getSignatureData(false,d);e.body=e.body.replace(/^/g,"> ").replace(/\n/g,"\n> ");a.set("body",c.apply(e))},initRecordRecipients:function(a,b,
c){var d=a.getRecipientStore();switch(c){case Zarafa.mail.data.ActionTypes.replyall:var e=[];e.push(b.get("sent_representing_entryid"));e.push(container.getUser().getEntryId());b.getRecipientStore().each(function(f){var g=f.get("entryid");if(e.indexOf(g)==-1||!g){f=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,f.data);f.set("rowid",undefined);d.add(f);e.push(g)}},this);case Zarafa.mail.data.ActionTypes.reply:a={object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,
recipient_type:Zarafa.core.mapi.RecipientType.MAPI_TO};if(Ext.isEmpty(b.get("sent_representing_email_address"))){a.entryid=b.get("sender_entryid");a.display_name=b.get("sender_name");a.email_address=b.get("sender_email_address");a.address_type=b.get("sender_address_type");a.search_key=b.get("sender_search_key")}else{a.entryid=b.get("sent_representing_entryid");a.display_name=b.get("sent_representing_name");a.email_address=b.get("sent_representing_email_address");a.address_type=b.get("sent_representing_address_type");
a.search_key=b.get("sent_representing_search_key")}if(a.address_type=="SMTP"||a.address_type=="ZARAFA")a.smtp_address=a.email_address;b=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,a);d.add(b);break;case Zarafa.mail.data.ActionTypes.forward:break}},initRecordAttachments:function(a,b,c){var d=a.getAttachmentStore();switch(c){case Zarafa.mail.data.ActionTypes.forward:b.getAttachmentStore().each(function(e){d.add(e.copy())},this);
a.set("hasattach",b.get("hasattach"));case Zarafa.mail.data.ActionTypes.replyall:case Zarafa.mail.data.ActionTypes.reply:break}},getSignatureId:function(a){switch(a){case Zarafa.mail.data.ActionTypes.forward:case Zarafa.mail.data.ActionTypes.replyall:case Zarafa.mail.data.ActionTypes.reply:a=container.getSettingsModel().get("zarafa/v1/contexts/mail/signatures/replyforward_message",true);break;default:a=container.getSettingsModel().get("zarafa/v1/contexts/mail/signatures/new_message",true);break}return parseInt(a,
10)},getSignatureData:function(a,b){if(!b)return"";var c=container.getSettingsModel().get("zarafa/v1/contexts/mail/signatures/all/"+b,true);if(Ext.isEmpty(c))return"";c=Ext.apply({},c);var d=c.isHTML;if(a===false){if(d===true)c.content=Zarafa.core.HTMLParser.convertHTMLToPlain(c.content);c.content="\n\n"+c.content}else{if(d===false)c.content=Zarafa.core.HTMLParser.convertPlainToHTML(c.content);c.content="<br /><br /><p>"+c.content+"</p>"}return c.content},onDataModeChange:function(a,b,c){Zarafa.mail.MailContextModel.superclass.onDataModeChange.call(this,
a,b,c);b!==c&&c===Zarafa.mail.data.DataModes.SEARCH&&this.stopSearch();switch(b){case Zarafa.mail.data.DataModes.SEARCH:break;case Zarafa.mail.data.DataModes.ALL:this.load();break}},onSearchStart:function(){if(this.getCurrentDataMode()!=Zarafa.mail.data.DataModes.SEARCH){this.oldDataMode=this.getCurrentDataMode();this.setDataMode(Zarafa.mail.data.DataModes.SEARCH)}},onSearchStop:function(){this.getCurrentDataMode()===Zarafa.mail.data.DataModes.SEARCH&&this.setDataMode(this.oldDataMode);delete this.oldDataMode}});
Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.MultiSelectHierarchyTree=Ext.extend(Zarafa.hierarchy.ui.HierarchyTreePanel,{constructor:function(a){a.nodeConfig=Ext.applyIf(a.nodeConfig||{},{checked:false});Zarafa.hierarchy.ui.MultiSelectHierarchyTree.superclass.constructor.call(this,a);if(Ext.isDefined(this.model)){this.mon(this,"checkchange",this.onTreeNodeCheckChange,this);this.mon(this,"click",this.onTreeNodeClick,this);this.mon(this.model,"folderchange",this.onFolderChange,this)}},onTreeNodeClick:function(a){this.onTreeNodeCheckChange(a,!a.getUI().isChecked())},
onTreeNodeCheckChange:function(a,b){var c=a.getFolder();b?this.model.addFolder(c):this.model.removeFolder(c)},onFolderChange:function(){this.updateAll()}});Ext.reg("zarafa.multiselecthierarchytree",Zarafa.hierarchy.ui.MultiSelectHierarchyTree);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderSizeDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.foldersizedialog",layout:"fit",defaultTitle:_("Folder Size"),allowWrite:true,useShadowStore:true,closeOnSave:true,width:360,height:360,items:[{xtype:"zarafa.foldersizepanel",buttons:[{text:_("Close"),handler:this.close,scope:this}]}]});Zarafa.hierarchy.dialogs.FolderSizeDialog.superclass.constructor.call(this,a)}});
Zarafa.core.ui.Dialog.register(Zarafa.hierarchy.dialogs.FolderSizeDialog,"zarafa.foldersizedialog");Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.folderpropertiesdialog",layout:"fit",defaultTitle:_("Properties"),allowWrite:true,useShadowStore:true,closeOnSave:true,width:425,height:450,items:[{xtype:"zarafa.folderpropertiespanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.hierarchy.dialogs.FolderPropertiesDialog.superclass.constructor.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.hierarchy.dialogs.FolderPropertiesDialog,"zarafa.folderpropertiesdialog");Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.MAPIFolderPermissionsSubStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_USER_PERMISSION);Ext.applyIf(a,{writer:new Zarafa.hierarchy.data.JsonPermissionsWriter,reader:new Zarafa.core.data.JsonReader({root:"item",dynamicRecord:false},b)});Zarafa.hierarchy.data.MAPIFolderPermissionsSubStore.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.IPFSubStore=Ext.extend(Zarafa.core.data.IPFStore,{parentRecord:null,constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER);Ext.applyIf(a,{proxy:new Zarafa.hierarchy.data.HierarchyProxy,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader({},b)});Zarafa.hierarchy.data.IPFSubStore.superclass.constructor.call(this,a);this.on({beforesave:this.onBeforeSave,exception:this.onException,
scope:this})},createRecords:function(a,b,c){var d=this.getParentRecord();d&&d.afterEdit();Zarafa.hierarchy.data.IPFSubStore.superclass.createRecords.call(this,a,b,c)},destroyRecord:function(a,b,c){this.getParentRecord()&&this.getParentRecord().markDirty();Zarafa.hierarchy.data.IPFSubStore.superclass.destroyRecord.call(this,a,b,c)},getParentRecord:function(){return this.parentRecord},setParentRecord:function(a){this.parentRecord=a},onException:function(a,b,c,d,e,f){Ext.isDefined(f)&&Ext.isArray(f.sendRecords)&&
Ext.each(f.sendRecords,function(g){g.clearMessageActions();g.commit()})},containsStoreInLastLoad:function(a){if(this.parentRecord){var b=this.parentRecord.get("store_entryid");return a.indexOf(b)>=0}return false},onNotifyObjectdeleted:function(a,b){Ext.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){b[c].setEventPropagation(false);b[c].phantom=true}this.remove(b)},onNotifyObjectmodified:function(a,b,c){Ext.isArray(b)||(b=[b]);a=0;for(var d=b.length;a<d;a++){var e=b[a],f=Ext.isArray(c)?c[a]:c;
e.setEventPropagation(false);f instanceof Ext.data.Record?e.applyData(f):this.reader.update(e,f);e.setEventPropagation(true)}},onNotifyObjectcreated:function(a,b,c){Ext.isArray(c)||(c=[c]);c[0]instanceof Ext.data.Record?this.loadRecords({records:c},{add:true}):this.loadData({item:c},true)},save:function(){if(this.removed.length){for(var a=[],b=[],c=0,d=this.removed.length;c<d;c++){var e=this.removed[c];e.isSharedFolder()?b.push(e):a.push(e)}if(!Ext.isEmpty(b)){b={close:b};if(this.fireEvent("beforesave",
this,b)!==false){try{var f=++this.batchCounter;this.execute("destroy",b.close,{actionType:"closesharedfolder"},f)}catch(g){this.handleException(g)}this.removed=a}}}Zarafa.hierarchy.data.IPFSubStore.superclass.save.apply(this,arguments)},onBeforeSave:function(a,b){if(!Ext.isEmpty(b.close)){var c=container.getSettingsModel(),d=b.close;c.beginEdit();for(var e=0,f=d.length;e<f;e++){var g=d[e],h=g.getMAPIStore().get("user_name"),i=g.getSharedFolderKey();c.remove("zarafa/v1/contexts/hierarchy/shared_stores/"+
h+"/"+i);g.addIdProp("user_name");g.addIdProp("folder_type");g.removeIdProp("entryid");g.removeIdProp("parent_entryid");g.removeIdProp("store_entryid");g.set("user_name",h);g.set("folder_type",i)}c.endEdit()}}});Ext.reg("zarafa.ipfsubstore",Zarafa.hierarchy.data.IPFSubStore);Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyStore=Ext.extend(Zarafa.core.data.IPFStore,{stateful:true,state:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{standalone:true,proxy:new Zarafa.hierarchy.data.HierarchyProxy,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader({id:"store_entryid",idProperty:"store_entryid"})});this.addEvents("addFolder","removeFolder","updateFolder");Zarafa.hierarchy.data.HierarchyStore.superclass.constructor.call(this,a);this.stateful!==false&&this.initState();
this.on({beforesave:this.onBeforeSave,load:this.onAfterLoad,add:this.onAdd,remove:this.onRemove,scope:this})},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isDefined(a.cancelPreviousRequest))a.cancelPreviousRequest=true;Ext.applyIf(a,{actionType:Zarafa.core.Actions.list});return Zarafa.hierarchy.data.HierarchyStore.superclass.load.call(this,a)},remove:function(a){if(Ext.isArray(a))Ext.each(a,function(b){this.remove(b)},this);else a.isSharedStore()&&Zarafa.hierarchy.data.HierarchyStore.superclass.remove.call(this,
a)},open:function(a,b,c){a=Ext.applyIf({params:{user_name:a,folder_type:b,show_subfolders:c},add:true,actionType:"opensharedfolder",cancelPreviousRequest:false},this.lastOptions);try{return this.execute("read",null,a)}catch(d){this.handleException(d);return false}},loadRecords:function(a,b,c){if(!this.isDestroyed){if(a&&c===true&&b&&b.actionType==="opensharedfolder"){for(var d=a.records,e=[],f=0,g=d.length;f<g;f++){var h=d[f],i=this.getByEntryId(h.get("store_entryid"));i?i.applyData(h):e.push(h)}if(e.length!==
a.records.length){b.add=false;a.records=this.getRange().concat(e);a.totalRecords=a.records.length}}Zarafa.hierarchy.data.HierarchyStore.superclass.loadRecords.call(this,a,b,c)}},hookStoreRecord:function(a){for(var b=0,c=a.length;b<c;b++)a[b].getSubStore("folders").on({add:this.onFolderAdd,remove:this.onFolderRemove,update:this.onFolderUpdate,scope:this})},unhookStoreRecord:function(a){a=a.getSubStore("folders");a.un("add",this.onFolderAdd,this);a.un("remove",this.onFolderRemove,this);a.un("update",
this.onFolderUpdate,this)},onAfterLoad:function(a,b,c){if(c.actionType==="opensharedfolder"){a=container.getSettingsModel();var d=c.params.folder_type||"all",e=c.params.show_subfolders||false;c="zarafa/v1/contexts/hierarchy/shared_stores/"+c.params.user_name;var f=a.get(c,true);if(f&&(f[d]||f.all))return;a.set(c+"/"+d,{folder_type:d,show_subfolders:e})}this.hookStoreRecord(b)},save:function(){if(this.removed.length){var a={close:this.removed};if(this.fireEvent("beforesave",this,a)!==false){try{var b=
++this.batchCounter;this.execute("destroy",a.close,{actionType:"closesharedfolder"},b)}catch(c){this.handleException(c)}this.removed=[]}}Zarafa.hierarchy.data.HierarchyStore.superclass.save.apply(this,arguments)},onBeforeSave:function(a,b){if(!Ext.isEmpty(b.close)){var c=container.getSettingsModel(),d=b.close;c.beginEdit();for(var e=0,f=d.length;e<f;e++){var g=d[e];c.remove("zarafa/v1/contexts/hierarchy/shared_stores/"+g.get("user_name"));g.addIdProp("user_name");g.removeIdProp("store_entryid")}c.endEdit()}},
onAdd:function(a,b){this.hookStoreRecord(b)},onRemove:function(a,b){this.unhookStoreRecord(b)},onFolderAdd:function(a,b,c){this.fireEvent("addFolder",this,a.getParentRecord(),b,c)},onFolderRemove:function(a,b,c){if(b.isSharedFolder())if(a.getCount()===1){a.rejectChanges();this.remove(a.getParentRecord());this.save();return}this.fireEvent("removeFolder",this,a.getParentRecord(),b,c)},onFolderUpdate:function(a,b,c){this.fireEvent("updateFolder",this,a.getParentRecord(),b,c)},getStores:function(){return this.getRange()},
getDefaultStore:function(){var a=this.findExact("mdb_provider",Zarafa.core.mapi.MDBProvider.ZARAFA_SERVICE_GUID);if(a!=-1)return this.getAt(a)},getPublicStore:function(){var a=this.findExact("mdb_provider",Zarafa.core.mapi.MDBProvider.ZARAFA_STORE_PUBLIC_GUID);if(a!=-1)return this.getAt(a)},getDefaultFolder:function(a,b){if(!b){b=this.getDefaultStore();if(!b)return}return b.getDefaultFolder(a)},getStoreByOwnerEntryId:function(a){for(var b=0;b<this.getCount();b++){var c=this.getAt(b);if(Zarafa.core.EntryId.compareEntryIds(c.get("mailbox_owner_entryid"),
a))return c}},getFolder:function(a){for(var b=0,c=this.getCount();b<c;b++){var d=this.getAt(b).getFolderStore();if(d)if(d=d.getByEntryId(a))return d}},getDefaultFolderFromMessageClass:function(a){a=Zarafa.core.MessageClass.getDefaultFolderTypeFromMessageClass(a);if(!Ext.isEmpty(a))return this.getDefaultStore().getDefaultFolder(a)},getDefaultFolderFromContainerClass:function(a){a=Zarafa.core.ContainerClass.getDefaultFolderTypeFromContainerClass(a);if(!Ext.isEmpty(a))return this.getDefaultStore().getDefaultFolder(a)},
collectFolders:function(a,b,c,d){if(!Ext.isFunction(b)||b.call(c||this,d))a.push(d);Ext.each(d.getChildren(),function(e){this.collectFolders(a,b,c,e)},this)},getSortedFolders:function(a,b){for(var c=[],d=this.getStores(),e=0;e<d.length;e++)this.collectFolders(c,a,b,d[e].getSubtreeFolder());return c},getByEntryId:function(a){var b=this.findBy(function(c){return Zarafa.core.EntryId.compareStoreEntryIds(a,c.get("store_entryid"))});if(b>=0)return this.getAt(b)},containsStoreInLastLoad:function(){return false},
onNotifyNewmail:function(a,b,c,d){Ext.isArray(b)||(b=[b]);a=0;for(var e=b.length;a<e;a++)if(!d||b[a].lastExecutionTime(Zarafa.core.Actions.list)<d)b[a].reload();Ext.isEmpty(c)||Ext.each(c.item,function(f){f=String.format(ngettext("There is {0} unread message in the folder {1}","There are {0} unread messages in the folder {1}",f.content_unread),f.content_unread,f.display_name);container.getNotifier().notify("info.newmail",_("New Mail"),f)},this)},startKeepAlive:function(){var a=container.getSettingsModel().get("zarafa/v1/contexts/hierarchy/polling_interval");
Ext.isNumber(a)&&a>0&&container.getRequest().on("aftersend",this.sendKeepAlive,this,{buffer:a*1E3})},sendKeepAlive:function(){var a={params:{},actionType:Zarafa.core.Actions.keepalive};this.proxy.request(Ext.data.Api.actions.read,null,a.params,this.reader,Ext.emptyFn,this,a)},initState:function(){if(!this.state)this.state=new Zarafa.hierarchy.data.HierarchyState},getStateName:function(a,b){if(this.stateful!==false)return this.state.getStateNameForFolder(a,b)},getState:function(a,b){if(this.stateful!==
false)return this.state.getStateForFolder(a,b)},applyState:function(a,b,c){this.stateful!==false&&this.state.applyStateForFolder(a,b,c)}});Ext.reg("zarafa.hierarchystore",Zarafa.hierarchy.data.HierarchyStore);Ext.namespace("Zarafa.hierarchy.data");Zarafa.hierarchy.data.CounterTypes=Zarafa.core.Enum.create({NONE:0,TOTAL:1,UNREAD:2});Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactCardPanel=Ext.extend(Ext.Panel,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{xtype:"zarafa.contactcardpanel",border:false,layout:"border",layoutConfig:{targetCls:""},items:[{xtype:"zarafa.contactcardview",context:a.context,region:"center"},{region:"east",xtype:"zarafa.characterstrip",ref:"characterStrip",selectedChar:a.model.getRestrictionCharacter(),listeners:{selectionchanged:this.onSelectionChanged,
selectioncleared:this.onSelectionCleared,scope:this}}]});Zarafa.contact.ui.ContactCardPanel.superclass.constructor.call(this,a)},onSelectionChanged:function(a,b){this.model.setRestrictionCharacter(b)},onSelectionCleared:function(){this.model.setRestrictionCharacter("")}});Ext.reg("zarafa.contactcardpanel",Zarafa.contact.ui.ContactCardPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistMembersTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.distlistmemberstab",title:_("Members"),layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},defaults:{header:false,margins:{top:5,right:2,bottom:1,left:2},border:false},items:this.getMembersTabItems()});Zarafa.contact.dialogs.DistlistMembersTab.superclass.constructor.call(this,
a)},getMembersTabItems:function(){return[{layout:"form",items:[{xtype:"textfield",name:"subject",fieldLabel:_("Name"),anchor:"100%",listeners:{change:this.onPropertyChange,scope:this}}]},{layout:"table",layoutConfig:{columns:5},items:[{xtype:"button",width:100,text:_("Select Members")+"...",handler:this.showAddressBookDialog,scope:this},{xtype:"spacer",width:7},{xtype:"button",width:100,handler:this.addExternalMember,scope:this,text:_("Add New")+"..."},{xtype:"spacer",width:7},{xtype:"button",width:100,
text:_("Remove")+"...",handler:this.removeMembers,scope:this}]},{xtype:"grid",flex:1,store:new Ext.data.Store({autoDestroy:true}),listeners:{rowdblclick:this.onRowDblClick},ref:"membersGrid",autoExpandColumn:"display_name",colModel:new Zarafa.contact.dialogs.DistlistMemberGridColumnModel}]},update:function(a,b){if(!Ext.isEmpty(a)){this.record=a;this.getForm().loadRecord(a);if(b&&a.isOpened()){a.getMemberStore().sort("fileas","asc");this.membersGrid.reconfigure(a.getMemberStore(),this.membersGrid.colModel)}}},
updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);a.set("fileas",a.get("subject"));a.set("dl_name",a.get("subject"));a.set("display_name",a.get("subject"));a.endEdit()},showAddressBookDialog:function(){Zarafa.contact.Actions.openMembersSelectionDialog(this.record)},addExternalMember:function(){Zarafa.contact.Actions.openDistlistExternalMemberDialog(this.record)},removeMembers:function(){var a=this.record.getMemberStore(),b=this.membersGrid.getSelectionModel().getSelections();a.remove(b)},
onPropertyChange:function(a,b){this.record.set(a.getName(),b)},onRowDblClick:function(a,b){var c=this.getStore().getAt(b);Zarafa.contact.Actions.openDistlistMember(c)}});Ext.reg("zarafa.distlistmemberstab",Zarafa.contact.dialogs.DistlistMembersTab);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistDialogToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.contact.distlistdialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.contact.dialogs.DistlistDialogToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",overflowText:_("Save Distributionlist"),
tooltip:{title:_("Save"),text:_("Save this Distribution list.")},iconCls:"icon_save",handler:this.onSave,scope:this},{xtype:"button",overflowText:_("Add Attachment"),tooltip:{title:_("Add Attachment"),text:_("Add attachments to this contact.")},iconCls:"icon_attachment",handler:this.onAttachments,scope:this},{xtype:"button",hidden:true,overflowText:_("Email message"),tooltip:{title:_("Email message"),text:_("Create a new email message addressed to this contact.")},iconCls:"icon_sendEmailFromContact",
handler:this.onEmail,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete Distributionlist"),tooltip:{title:_("Delete"),text:_("Delete the Distribution list.")},iconCls:"icon_delete",handler:this.onDelete,scope:this},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print distribution list"),text:_("Print this distribution list.")},iconCls:"icon_print",handler:this.onPrint,scope:this}]},createOptionButtons:function(){return[{xtype:"button",overflowText:_("Categories"),tooltip:{title:_("Categories"),
text:_("Open the categories dialog.")},iconCls:"icon_categories",handler:this.onCategories,scope:this},{xtype:"button",overflowText:_("Private"),tooltip:{title:_("Private"),text:_("Mark this Distribution list as private.")},iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSave:function(){this.dialog.saveRecord();this.dialog.close()},onAttachments:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,this.dialog.isBrowser())},
onEmail:function(){Zarafa.contact.Actions.openEmailDialog(this.record,this.dialog.isBrowser())},onDelete:function(){this.dialog.deleteRecord()},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.record)},onCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.record,false,this.dialog.isBrowser())},onPrivateGroupToggle:function(a){this.record.set("private",a.pressed);a.pressed?this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.PRIVATE):this.record.set("sensitivity",
Zarafa.core.mapi.Sensitivity.NONE)},update:function(a,b){this.record=a;this.deleteBtn.setDisabled(a.phantom===true);if(b===true||a.isModified("private"))this.setPrivate.toggle(a.get("private"),true)}});Ext.reg("zarafa.distlistdialogtoolbar",Zarafa.contact.dialogs.DistlistDialogToolbar);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"fit",xtype:"zarafa.distlistdialog",defaultTitle:_("Create Distribution List"),allowWrite:true,items:[this.createPanel()]});Zarafa.contact.dialogs.DistlistDialog.superclass.constructor.call(this,a)},createPanel:function(){return{xtype:"zarafa.distlistpanel",tbar:{xtype:"zarafa.distlistdialogtoolbar"}}}});
Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.DistlistDialog,"zarafa.distlistdialog");Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.contact.contactdialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.contact.dialogs.ContactToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",overflowText:_("Save Contact"),
tooltip:{title:_("Save"),text:_("Save this contact.")},iconCls:"icon_save",handler:this.onSave,scope:this},{xtype:"button",overflowText:_("Add Attachment"),tooltip:{title:_("Add Attachment"),text:_("Add attachments to this contact.")},iconCls:"icon_attachment",handler:this.onAttachments,scope:this},{xtype:"button",overflowText:_("Email message"),tooltip:{title:_("Email message"),text:_("Create a new email message addressed to this contact.")},iconCls:"icon_sendEmailFromContact",handler:this.onEmail,
scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete contact"),text:_("Delete this contact.")},iconCls:"icon_delete",handler:this.onDelete,scope:this},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this contact")},iconCls:"icon_print",handler:this.onPrint,scope:this}]},createOptionButtons:function(){return[{xtype:"button",overflowText:_("Categories"),tooltip:{title:_("Categories"),text:_("Open the categories dialog.")},iconCls:"icon_categories",
handler:this.onCategories,scope:this},{xtype:"button",overflowText:_("Private"),tooltip:{title:_("Private"),text:_("Mark this contact as private.")},iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSave:function(){this.dialog.saveRecord();this.dialog.close()},onDelete:function(){this.dialog.deleteRecord()},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.record)},onAttachments:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,
this.dialog.isBrowser())},onEmail:function(){Zarafa.contact.Actions.openEmailDialog(this.record,this.dialog.isBrowser())},onCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.record,this.dialog.isBrowser())},onPrivateGroupToggle:function(a){this.record.set("private",a.pressed);a.pressed===true?this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.PRIVATE):this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.NONE)},update:function(a,b){this.record=a;this.deleteBtn.setDisabled(a.phantom===
true);if(b===true||a.isModifiedSinceLastUpdate("private"))this.setPrivate.toggle(a.get("private"),true)}});Ext.reg("zarafa.contactdialogtoolbar",Zarafa.contact.dialogs.ContactToolbar);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactPhoneDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{parser:null,property:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactphonedialog",layout:"fit",border:false,defaultTitle:_("Check phone number"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,width:400,height:250,items:[{xtype:"zarafa.contactphonepanel",ref:"mainPanel",parser:a.parser,parsedData:a.parsedData,property:a.property,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},
{text:_("Cancel"),scope:this,handler:this.onCancel}]}]});Zarafa.contact.dialogs.ContactPhoneDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.ContactPhoneDialog,"zarafa.contactphonedialog");Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactpanel",bodyStyle:"background-color: inherit;",border:false,layout:"fit",items:this.createTabPanel()});Zarafa.contact.dialogs.ContactPanel.superclass.constructor.call(this,a)},createTabPanel:function(){return[{xtype:"tabpanel",activeTab:0,border:false,bodyStyle:"background-color: inherit;",defaults:{bodyStyle:"background-color: inherit; padding: 5px;",layout:"column",autoHeight:false},
items:[{xtype:"zarafa.contactgeneraltab"},{xtype:"zarafa.contactdetailtab"},container.populateInsertionPoint("context.contact.contactdialog.tabs")]}]}});Ext.reg("zarafa.contactpanel",Zarafa.contact.dialogs.ContactPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactNameDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{parser:null,parsedData:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactnamedialog",layout:"fit",border:false,defaultTitle:_("Check full name"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,width:400,height:250,items:[{xtype:"zarafa.contactnamepanel",ref:"mainPanel",parser:a.parser,parsedData:a.parsedData,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),scope:this,
handler:this.onCancel}]}]});Zarafa.contact.dialogs.ContactNameDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.ContactNameDialog,"zarafa.contactnamedialog");Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{contactParser:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"fit",xtype:"zarafa.contactdialog",defaultTitle:_("Create Contact"),allowWrite:true,confirmClose:true,items:this.createPanel()});Zarafa.contact.dialogs.ContactDialog.superclass.constructor.call(this,a);this.initContactDetailsParser()},createPanel:function(){return[{xtype:"zarafa.contactpanel",tbar:{xtype:"zarafa.contactdialogtoolbar"}}]},initContactDetailsParser:function(){var a=
container.getSharedComponent(Zarafa.core.data.SharedComponentType["contact.detailsparser"]);if(a)this.contactParser=new a}});Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.ContactDialog,"zarafa.contactdialog");Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactAddressDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{parser:null,property:null,parsedData:null,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",border:false,xtype:"zarafa.contactaddressdialog",defaultTitle:_("Check address"),alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,width:400,height:250,items:[{xtype:"zarafa.contactaddresspanel",ref:"mainPanel",parser:a.parser,parsedData:a.parsedData,property:a.property,buttons:[{text:_("Ok"),handler:this.onOk,
scope:this},{text:_("Cancel"),scope:this,handler:this.onCancel}]}]});Zarafa.contact.dialogs.ContactAddressDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.contact.dialogs.ContactAddressDialog,"zarafa.contactaddressdialog");Ext.namespace("Zarafa.contact.data");Zarafa.contact.data.Views=Zarafa.core.Enum.create({ICON:0,LIST:1,SEARCH:2});Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.ViewModes=Zarafa.core.Enum.create({NORMAL:0,BUSINESS:1,ADDRESS:2,DETAILED:3,PHONE_LIST:4,GROUP_CATEGORY:5,GROUP_COMPANY:6,GROUP_LOCATION:7,SEARCH:8});Ext.namespace("Zarafa.contact.data");Zarafa.contact.data.DataModes=Zarafa.core.Enum.create({ALL:0,CHARACTER_RESTRICT:1,SEARCH:2});Ext.namespace("Zarafa.contact");
Zarafa.contact.ContactContextModel=Ext.extend(Zarafa.core.ContextModel,{current_character:"a",oldDataMode:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.contact.ContactStore;Ext.applyIf(a,{current_data_mode:Zarafa.contact.data.DataModes.ALL});this.addEvents("characterchange");Zarafa.contact.ContactContextModel.superclass.constructor.call(this,a);this.on({searchstart:this.onSearchStart,searchstop:this.onSearchStop,scope:this})},enable:function(){Zarafa.contact.ContactContextModel.superclass.enable.apply(this,
arguments);this.setRestrictionCharacter(this.getRestrictionCharacter(),true)},createRecord:function(a,b){a=a||this.getDefaultFolder();return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass(b?"IPM.Distlist":"IPM.Contact",{object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid"),icon_index:b?Zarafa.core.mapi.IconIndex.contact_distlist:Zarafa.core.mapi.IconIndex.contact_user})},onDataModeChange:function(a,b,c){Zarafa.contact.ContactContextModel.superclass.onDataModeChange.call(this,
a,b,c);b!==c&&c===Zarafa.contact.data.DataModes.SEARCH&&this.stopSearch();switch(b){case Zarafa.contact.data.DataModes.CHARACTER_RESTRICT:this.load({params:{restriction:{search:this.createCharacterRestriction()}}});break;case Zarafa.contact.data.DataModes.ALL:this.load({params:{restriction:{}}});break;case Zarafa.contact.data.DataModes.SEARCH:break}},setRestrictionCharacter:function(a,b){if(b===true||this.current_character!==a){var c=this.current_character;this.current_character=a;this.onCharacterChange(this,
this.current_character,c);this.fireEvent("characterchange",this,this.current_character,c)}},getRestrictionCharacter:function(){return this.current_character},onCharacterChange:function(a,b){if(this.current_data_mode===Zarafa.contact.data.DataModes.CHARACTER_RESTRICT){var c={start:0};if(b)c.restriction={search:this.createCharacterRestriction(b)};this.load({params:c})}},createCharacterRestriction:function(a){var b=Zarafa.core.data.RestrictionFactory,c=Zarafa.core.mapi.Restrictions;if(Ext.isEmpty(a))a=
this.current_character||"...";switch(a){case "...":a={};break;case "123":a=b.createResAnd([b.dataResProperty("0x80B5001E",c.RELOP_GE,"0"),b.dataResProperty("0x80B5001E",c.RELOP_LE,"9")]);break;case "z":a=b.dataResProperty("0x80B5001E",c.RELOP_GE,"z");break;default:var d=String.fromCharCode(a.charCodeAt(0)+1);a=b.createResAnd([b.dataResProperty("0x80B5001E",c.RELOP_GE,a),b.dataResProperty("0x80B5001E",c.RELOP_LE,d)])}return a},initStateEvents:function(){Zarafa.contact.ContactContextModel.superclass.initStateEvents.call(this);
this.on("characterchange",this.saveState,this,{delay:100})},getState:function(){var a=Zarafa.contact.ContactContextModel.superclass.getState.call(this)||{};return Ext.apply(a,{current_character:this.current_character})},onSearchStart:function(){if(this.getCurrentDataMode()!=Zarafa.contact.data.DataModes.SEARCH){this.oldDataMode=this.getCurrentDataMode();this.setDataMode(Zarafa.contact.data.DataModes.SEARCH)}},onSearchStop:function(){this.getCurrentDataMode()===Zarafa.contact.data.DataModes.SEARCH&&
this.setDataMode(this.oldDataMode);delete this.oldDataMode}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AppointmentView=Ext.extend(Zarafa.calendar.ui.AbstractDateRangeView,{timeFormat:_("H:i"),stripVisible:true,stripWidth:6,record:undefined,selected:false,active:false,adjustedDateRange:undefined,init:function(){Zarafa.calendar.ui.AppointmentView.superclass.init.call(this);this.record&&this.updateDateRange(this.record)},updateDateRange:function(a){var b=this.getDateRange(),c=this.getAdjustedDateRange(),d=a.get("startdate");a=a.get("duedate");var e=0;if(b)b.set(d,a);else{b=new Zarafa.core.DateRange({startDate:d,
dueDate:a});this.setDateRange(b)}e=Math.max(b.getDuration(Date.MINUTE),this.parentView.getZoomLevel());a=d.add(Date.MINUTE,e);if(c)c.set(d,a);else{c=new Zarafa.core.DateRange({startDate:d,dueDate:a});this.setAdjustedDateRange(c)}},setAdjustedDateRange:function(a){this.adjustedDateRange=a},getAdjustedDateRange:function(){return this.adjustedDateRange},setSelected:function(a){this.selected=a},isSelected:function(){return this.selected},setActive:function(a){this.active=a},isActive:function(){return this.active},
iconRenderer:function(){var a=[];this.getRecord().get("private")===true&&a.push("private");if(this.getRecord().get("recurring")===true)this.getRecord().get("exception")===true?a.push("exception"):a.push("recurring");return a},mainTextRenderer:function(){return Ext.util.Format.htmlEncode(this.record.get("subject"))},subTextRenderer:function(){var a=this.record.get("location");Ext.isEmpty(a)||(a="("+a+")");return Ext.util.Format.htmlEncode(a)},getId:function(){return this.record.id},getRecord:function(){return this.record},
getBusyStatus:function(){return this.record.get("busystatus")},getBusyStatusName:function(){return Zarafa.core.mapi.BusyStatus.getName(this.getBusyStatus()).toLowerCase()},isAllDay:function(){return this.getDateRange().isAllDay()},getStripWidth:function(){return this.stripVisible?this.stripWidth:0},onContextMenu:function(a){this.parentView.fireEvent("contextmenu",a,this.record)},onDoubleClick:function(a){this.parentView.fireEvent("dblclick",a,this.record)}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AppointmentProxy=Ext.extend(Zarafa.calendar.ui.AbstractDateRangeView,{showTime:false,focusEl:undefined,constructor:function(a){this.addEvents("keypress","keydown","keyup");Zarafa.calendar.ui.AppointmentProxy.superclass.constructor.call(this,a)},setDateRange:function(a){this.dateRange&&this.mun(this.dateRange,"update",this.onDateRangeUpdate,this);Zarafa.calendar.ui.AppointmentProxy.superclass.setDateRange.call(this,a);this.dateRange&&this.mon(this.dateRange,"update",this.onDateRangeUpdate,
this)},render:function(){Zarafa.calendar.ui.AppointmentProxy.superclass.render.apply(this,arguments);this.create({tag:"a",href:"#"},this.container,"focusEl");this.focusEl.relayEvent("keypress",this);this.focusEl.relayEvent("keydown",this);this.focusEl.relayEvent("keyup",this)},setShowTime:function(a){this.showTime=a},layoutInHeader:function(){var a=this.parentView.dateRangeToHeaderBounds(this.getDateRange());this.header.dom.className=this.headerClassName;this.header.setLeftTop(a.left,a.top);this.header.setSize(a.right-
a.left,this.parentView.getAppointmentHeaderheight());return a},createTimeText:function(){var a=this.getDateRange(),b=a.getStartDate();a=a.getDueDate();b=String.format('<span class="zarafa-calendar-dragproxy-time "style="position: absolute; left: 2px; top:2px;">{0}</span>',b.format(_("G:i")));a=String.format('<span class="zarafa-calendar-dragproxy-time "style="position: absolute; left: 2px; bottom:2px;">{0}</span>',a.format(_("G:i")));if(this.body.length===1)this.getFirstBodyElement().dom.innerHTML=
b+a;else if(this.body.length>1){for(var c=1,d=this.body.length-1;c<d;c++)this.body[c].dom.innerHTML="";this.getFirstBodyElement().dom.innerHTML=b;this.getLastBodyElement().dom.innerHTML=a}},clearTimeText:function(){if(this.body.length>0)this.getFirstBodyElement().dom.innerHTML="";if(this.body.length>1)this.getLastBodyElement().dom.innerHTML=""},setVisible:function(a){Zarafa.calendar.ui.AppointmentProxy.superclass.setVisible.call(this,a);if(a){this.setBodyClass("zarafa-calendar-selection zarafa-calendar-selection-dragging");
this.setHeaderClass("zarafa-calendar-selection zarafa-calendar-selection-dragging")}else{this.setBodyClass("zarafa-calendar-selection");this.setHeaderClass("zarafa-calendar-selection")}this.rendered&&this.layout()},onContextMenu:function(a){var b=this.parentView.parentView.model.createRecord(this.parentView.getSelectedFolder(),this.getDateRange());this.parentView.fireEvent("contextmenu",a,b)},onDoubleClick:function(a){var b=this.parentView.parentView.model.createRecord(this.parentView.getSelectedFolder(),
this.getDateRange());this.parentView.fireEvent("dblclick",a,b)},layoutBodyElements:function(a){Zarafa.calendar.ui.AppointmentProxy.superclass.layoutBodyElements.call(this,a);this.showTime?this.createTimeText():this.clearTimeText()},onDateRangeUpdate:function(){this.rendered&&this.isVisible()&&this.layout()},onLayout:function(){if(this.visible){if(this.isHeaderRange()){Ext.isDefined(this.header)||this.createHeader();this.layoutInHeader()}else Ext.isDefined(this.header)&&this.destroyHeader();this.layoutInBody()}Zarafa.calendar.ui.AppointmentProxy.superclass.onLayout.call(this);
this.focusEl.focus()}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AbstractCalendarDaysView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarView,{dayLayoutPositions:[],rowCount:1,shortDayHeaderFormat:_("jS"),longDayHeaderFormat:_("l jS F"),constructor:function(a){a=a||{};Ext.applyIf(a,{appointmentBodyLeftMargin:1});Zarafa.calendar.ui.AbstractCalendarDaysView.superclass.constructor.call(this,a)},getDesiredHeaderHeight:function(){return Math.max(this.rowCount||1,1)*this.parentView.headerItemHeight+this.parentView.headerTextHeight},getAppointmentHeaderheight:function(){return this.header.getHeight()-
this.parentView.headerTextHeight},isHeaderRange:function(a){return a.getDuration(Date.DAY)>=1},getDayHeaderTitle:function(a,b){return a.format(b>=this.parentView.minHeaderDayTextWidth?this.longDayHeaderFormat:this.shortDayHeaderFormat)},calculateDayLayoutPositions:function(){var a=(new Date).clearTime().getTime(),b=this.getDateRange().getStartDate(),c=this.getDateRange().getNumDays(),d=(this.body.getWidth()-1)/c;this.header.getHeight();this.dayLayoutPositions=[];for(var e=0;e<c;e++){var f=b.add(Date.DAY,
e),g=this.parentView.workingDays.indexOf(f.getDay())>=0;this.dayLayoutPositions.push(new Zarafa.calendar.data.DayLayoutPosition({left:Math.round(e*d),right:Math.round((e+1)*d)+1,date:f,today:a==f.getTime(),workingDay:g}))}return this.dayLayoutPositions},locationToDate:function(a,b){var c=this.getDateRange().getNumDays(),d=this.parentView.numHours*this.parentView.getHourHeight(),e;if(a<this.dayLayoutPositions[0].left)e=0;else if(a>this.dayLayoutPositions[c-1].right)e=c-1;else for(c=0;c<this.dayLayoutPositions.length;c++)if(a>=
this.dayLayoutPositions[c].left&&a<=this.dayLayoutPositions[c].right){e=c;break}d=b/d*Date.dayInMillis;return this.getDateRange().getStartDate().add(Date.MILLI,d).add(Date.DAY,e)},screenLocationToDate:function(a,b){return Zarafa.inside(this.header.getBox(),a,b)?this.locationToDate(a-this.header.getX(),0):this.locationToDate(a-this.body.getX(),b-this.body.getY())},getDayColumn:function(a){var b=this.getDateRange().getStartDate();return Math.floor(Date.diff(Date.DAY,a,b))},getDateVerticalPosition:function(a){var b=
a.getTimezoneOffset()*60*1E3;return(a.getTime()-b)%Date.dayInMillis/Date.dayInMillis},getRangeVerticalHeight:function(a){var b=this.parentView.numHours*this.parentView.getHourHeight(),c=a.getDuration();c+=Date.getDSTDiff(a.getStartDate(),a.getDueDate());return c*b/Date.dayInMillis},dateRangeToBodyBounds:function(a,b,c,d){var e=[],f=this.dayLayoutPositions.length,g=this.parentView.numHours*this.parentView.getHourHeight(),h=d?this.appointmentBodyLeftMargin:0;d=d?this.appointmentBodyRightMargin:0;var i=
a.getStartDate(),j=a.getDueDate();b=b||0;c=c||1;if(j.getTime()<=i.getTime())return[];var k=this.getDayColumn(i);a=this.getDayColumn(j);if(a<0||k>=f)return[];i=Math.floor(this.getDateVerticalPosition(i)*g);j=Math.floor(this.getDateVerticalPosition(j)*g);i--;if(k==a){var m=(this.dayLayoutPositions[k].right-this.dayLayoutPositions[k].left-1-d-h)/c,l=this.dayLayoutPositions[k].left+m*b+h;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(l),right:Math.round(l+m),top:i,bottom:j,firstBox:true,
lastBox:true}))}else{if(k>=0){m=(this.dayLayoutPositions[k].right-this.dayLayoutPositions[k].left-1-d-h)/c;l=this.dayLayoutPositions[k].left+m*b+h;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(l),right:Math.round(l+m),top:i,bottom:g,firstBox:true}))}for(k=Math.max(k+1,0);k<=Math.min(a-1,f-1);k++){m=(this.dayLayoutPositions[k].right-this.dayLayoutPositions[k].left-1-d-h)/c;l=this.dayLayoutPositions[k].left+m*b+h;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(l),
right:Math.round(l+m),top:-1,bottom:g}))}if(a<f&&j>0){m=(this.dayLayoutPositions[a].right-this.dayLayoutPositions[a].left-1-d-h)/c;l=this.dayLayoutPositions[a].left+m*b+h;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(l),right:Math.round(l+m),top:-1,bottom:j,lastBox:true}))}}return e},dateRangeToHeaderBounds:function(a,b,c,d){var e=this.dayLayoutPositions.length,f=d?this.appointmentHeaderLeftMargin:0;d=d?this.appointmentHeaderRightMargin:0;var g=this.parentView.headerTextHeight,
h=a.getStartDate();a=a.getDueDate();h=this.getDayColumn(h);var i=this.getDayColumn(a);b=b||0;c=c||this.rowCount;a.clearTime(true).getTime()==a.getTime()&&i--;return h<0&&i>=e?new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[0].left,right:this.dayLayoutPositions[e-1].right,top:g+b*this.parentView.headerItemHeight,bottom:g+(b+c)*this.parentView.headerItemHeight}):h<0?new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[0].left,right:this.dayLayoutPositions[i].right-
d,top:g+b*this.parentView.headerItemHeight,bottom:g+(b+c)*this.parentView.headerItemHeight,lastBox:true}):i>=e?new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[h].left+f,right:this.dayLayoutPositions[e-1].right,top:g+b*this.parentView.headerItemHeight,bottom:g+(b+c)*this.parentView.headerItemHeight,firstBox:true}):new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[h].left+f,right:this.dayLayoutPositions[i].right-d,top:g+b*this.parentView.headerItemHeight,
bottom:g+(b+c)*this.parentView.headerItemHeight,firstBox:true,lastBox:true})},getAppointmentClusters:function(a){a.sort(this.appointmentCompare);for(var b=[],c=[],d=0,e=0,f;f=a[e];e++){var g=f.getDateRange().getStartTime(),h=f.getAdjustedDateRange().getDueTime();if(b.length==0){d=h;b.push(f)}else if(g<d){d=Math.max(h,d);b.push(f)}else{c.push(b);b=[f];d=h}}b.length>0&&c.push(b);return c},calculateBodyOverlaps:function(){var a=[];Ext.each(this.appointments,function(c){this.isHeaderRange(c.getDateRange())||
a.push(c)},this);var b=this.getAppointmentClusters(a);Ext.each(b,function(c){this.doGreedyColoring(c)},this)},calculateHeaderOverlaps:function(){var a=[];Ext.each(this.appointments,function(b){this.isHeaderRange(b.getDateRange())&&a.push(b)},this);this.doGreedyColoring(a,true);this.rowCount=a.length>0?a[0].slotCount:0},onAppointmentsLoad:function(){Zarafa.calendar.ui.AbstractCalendarDaysView.superclass.onAppointmentsLoad.apply(this,arguments);this.calculateBodyOverlaps();this.calculateHeaderOverlaps()},
addAppointment:function(a){Zarafa.calendar.ui.AbstractCalendarDaysView.superclass.addAppointment.apply(this,arguments);a.get("alldayevent")?this.calculateHeaderOverlaps():this.calculateBodyOverlaps()},removeAppointment:function(a){Zarafa.calendar.ui.AbstractCalendarDaysView.superclass.removeAppointment.apply(this,arguments);a.get("alldayevent")?this.calculateHeaderOverlaps():this.calculateBodyOverlaps()},onBeforeLayout:function(){Zarafa.calendar.ui.AbstractCalendarDaysView.superclass.onBeforeLayout.apply(this,
arguments);this.calculateBodyOverlaps();this.calculateHeaderOverlaps()}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AbstractCalendarBoxView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarView,{dayBoxConfigurations:undefined,firstDayOfWeek:1,dayHeaderHeight:20,headerHeight:20,appointmentHeight:20,expandThreshold:20,numDaysInWeek:7,shortDayHeaderFormat:_("l"),longDayHeaderFormat:_("l"),constructor:function(a){a=a||{};if(!Ext.isDefined(a.firstDayOfWeek))a.firstDayOfWeek=container.getSettingsModel().get("zarafa/v1/main/week_start");Ext.applyIf(a,{appointmentBodyLeftMargin:6,appointmentBodyRightMargin:6});
Zarafa.calendar.ui.AbstractCalendarBoxView.superclass.constructor.call(this,a)},getDesiredHeaderHeight:function(){return this.headerHeight},getDayHeaderTitle:function(a,b){return a.format(b>=this.parentView.minHeaderDayTextWidth?this.longDayHeaderFormat:this.shortDayHeaderFormat)},screenLocationToDate:function(a,b){for(var c=a-this.body.getLeft(),d=b-this.body.getTop(),e=0,f;f=this.dayBoxConfigurations[e];e++)if(c>f.left&&c<=f.right&&d>f.top&&d<=f.bottom)return f.date;return null},dateRangeToBodyBounds:function(a,
b,c,d){var e=this.getVisibleDateRange();c=this.getVisibleWeekCount(e);var f=b===undefined;b=b||0;var g=a.getStartDate();a=a.getDueDate();var h=[],i=e.getStartDate();e=d?this.appointmentBodyLeftMargin:0;d=d?this.appointmentBodyRightMargin:0;for(var j=0;j<c;j++){var k=i.add(Date.DAY,this.numDaysInWeek),m=Math.floor(Date.diff(Date.DAY,g,i)),l=Math.ceil(Date.diff(Date.DAY,a,i))-1;m=Math.max(m,0);l=Math.min(l,6);if(m<7&&l>=0){i=this.dayBoxConfigurations[j*7+m];m=this.dayBoxConfigurations[j*7+l];l=i.top+
this.headerHeight+this.appointmentHeight*b;var n=f?i.bottom:l+this.appointmentHeight;if(f||n<i.bottom-this.expandThreshold)h.push({left:i.left+e,right:m.right-d,top:l,bottom:n,firstBox:true,lastBox:true})}i=k;if(i>a)break}return h},findAppointmentsByRange:function(a){for(var b=[],c=0,d;d=this.appointments[c];c++)a.inside(d.getDateRange())&&b.push(d);return b},maxSlotInRange:function(a){for(var b=0,c=0,d;d=this.appointments[c];c++)if(a.overlaps(d.getDateRange()))b=Math.max(b,d.slot);return b},getVisibleDateRange:function(){var a=
this.getStartDate().getPreviousWeekDay(this.firstDayOfWeek),b=this.getDueDate().getNextWeekDay(this.firstDayOfWeek);return new Zarafa.core.DateRange({startDate:a,dueDate:b})},getVisibleWeekCount:function(a){a=a||this.getVisibleDateRange();return Math.round(Date.diff(Date.DAY,a.getDueDate(),a.getStartDate())/7)},calculateDayBoxConfigurations:function(a){a||(a=this.body.getHeight());var b=this.getVisibleDateRange(),c=this.getVisibleWeekCount(b);this.dayBoxConfigurations=[];var d=(this.body.getWidth()-
1)/this.numDaysInWeek;a=(a-1)/c;b=b.getStartDate();for(var e=(new Date).clearTime().getTime(),f=0;f<c;f++)for(var g=0;g<this.numDaysInWeek;g++){var h=0,i=b.add(Date.DAY,f*this.numDaysInWeek+g),j=new Zarafa.core.DateRange({startDate:i,dueDate:i.add(Date.DAY,1)}),k=this.parentView.workingDays.indexOf(i.getDay())>=0,m=this.findAppointmentsByRange(j);Ext.each(m,function(l){l=l.getRecord().get("busystatus");h=Math.max(h,l)});m=Math.floor((Math.round((f+1)*a)+1-Math.round(f*a)-this.headerHeight-this.expandThreshold)/
this.appointmentHeight);this.dayBoxConfigurations.push(new Zarafa.calendar.data.DayBoxConfiguration({left:Math.round(g*d),right:Math.round((g+1)*d)+1,top:Math.round(f*a),bottom:Math.round((f+1)*a)+1,date:i,today:e==i.getTime(),workingDay:k,busyStatus:h,overflow:this.maxSlotInRange(j)>=m,active:i.getTime()>=this.getStartDate().getTime()&&i.getTime()<this.getDueDate().getTime()}))}return this.dayBoxConfigurations},onBodyContextMenu:function(a){var b=a.getXY();b=this.screenLocationToDate(b[0],b[1]);
this.rangeSelectionModel.set(new Zarafa.core.DateRange({startDate:b,dueDate:b.add(Date.DAY,1)}),this);this.fireEvent("contextmenu",a)}});Ext.namespace("Zarafa.calendar.printer");
Zarafa.calendar.printer.DaysViewRenderer=Ext.extend(Zarafa.common.printer.renderers.BaseRenderer,{customStylesheetPath:"client/resources/css-extern/print.calendar.css",timeStyle:"",prepareData:function(a){var b=Zarafa.calendar.printer.DaysViewRenderer.superclass.prepareData(a),c=a.getModel(),d=c.dateRange;a=d.getDuration(Date.DAY);var e=d.getStartDate().clone();d=d.getDueDate().clone();b.currenttime=new Date;b.startdate=e.clone();b.duedate=d.add(Date.DAY,-1);for(var f=0,g=a;f<g;f++){var h="date"+
(f+1);b[h]=b.startdate.add(Date.DAY,f);b[h+"_table_data"]=""}c=c.getStore().getRange();h=e.getDay();f=0;for(g=c.length;f<g;f++){var i=c[f].get("commonstart"),j=c[f].get("commonend");if(Ext.isDate(i)&&Ext.isDate(j)){var k=i;if(i<e)k=e.clone();var m=j;if(j>d)m=d.clone();var l=c[f].get("subject");Ext.isString(l)||(l="");var n,o=i.getDayOfYear()!==j.getDayOfYear()||i.getYear()!==j.getYear();n=o?_("jS F Y G:i"):_("G:i");var p=Math.floor(Date.diff(Date.DAY,m,k)),q=c[f].get("alldayevent");q&&m===j&&p--;
m='<tr class="calendar-'+(q?"allday":"normal")+'">';q||(m+='<td class="nowrap" style="'+this.timeStyle+'">'+i.format(n)+" - "+(o?"<br>":"")+j.format(n)+"</td>");m+='<td class="calendar-item" colspan='+(q?"2":"1")+">"+Ext.util.Format.htmlEncode(l)+"</td></tr>";i=k.getDay();if(i<h)i+=7;i-=h-1;for(j=0;j<=p&&j<a;j++)b["date"+(i+j)+"_table_data"]+=m}}return b},postRender:function(a,b,c){c=c.getModel().dateRange;a=c.getStartDate().clone();c=c.getDueDate().clone();c.setMonth(c.getMonth()+1);new Ext.DatePicker({renderTo:b.getElementById("datepicker_left"),
value:a,showToday:false});new Ext.DatePicker({renderTo:b.getElementById("datepicker_right"),value:c,showToday:false})}});Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.ProposeNewTimeDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{allowWrite:true,xtype:"zarafa.proposenewtimedialog",layout:"fit",title:_("Propose New Time"),width:375,height:200,items:[{xtype:"zarafa.proposenewtimepanel",record:a.record,ref:"proposeNewTimePanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.calendar.dialogs.ProposeNewTimeDialog.superclass.constructor.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.calendar.dialogs.ProposeNewTimeDialog,"zarafa.proposenewtimedialog");Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.AppointmentToolbar=Ext.extend(Zarafa.core.ui.DialogToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.calendar.appointmentdialog",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Ext.apply(this,a);Zarafa.calendar.dialogs.AppointmentToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"zarafa.meetingrequestbuttons"},
{xtype:"button",overflowText:_("Send invitation"),text:_("Send"),tooltip:{title:_("Send invitation"),text:_("Send invitation to recipients")},iconCls:"icon_sendEmail",cls:"button_sendMail",ref:"sendInvitation",handler:this.onSendButton,scope:this},{xtype:"button",overflowText:_("Save & Close"),tooltip:{title:_("Save & Close"),text:_("Save appointment and close dialog")},iconCls:"icon_saveEmail",ref:"saveAppointment",handler:this.onSaveButton,scope:this},{xtype:"button",overflowText:_("Save"),tooltip:{title:_("Save"),
text:_("Save without sending an invitation to recipients")},iconCls:"icon_saveEmail",ref:"saveMeeting",handler:this.onSaveButton,scope:this},{xtype:"button",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this appointment")},iconCls:"icon_delete",ref:"deleteAppointment",handler:this.onDeleteButton,scope:this},{xtype:"button",overflowText:_("Add attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this appointment")},iconCls:"icon_attachment",handler:function(){Zarafa.common.Actions.openAttachmentsDialog(this.record,
this.dialog.isBrowser())},scope:this},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this appointment")},iconCls:"icon_print",handler:function(){Zarafa.common.Actions.openPrintDialog(this.record)},scope:this},{xtype:"button",overflowText:_("Check names"),tooltip:{title:_("Check names"),text:_("Check all recipient names")},iconCls:"icon_checkNames",ref:"checkNames",handler:this.onCheckNamesButton,scope:this}]},createOptionButtons:function(){return[{xtype:"button",text:_("Recurrence"),
overflowText:_("Recurrence"),tooltip:{title:_("Recurrence"),text:_("Open the recurrence dialog")},iconCls:"icon_recurrence",ref:"recurrence",handler:this.onSetRecurrence,scope:this},{xtype:"button",text:_("Invite attendees"),overflowText:_("Invite attendees"),tooltip:{title:_("Invite attendees"),text:_("Invite attendees for this appointment")},iconCls:"icon_invite_attendees",ref:"inviteAttendees",handler:this.onSetMeetingRequest,scope:this},{xtype:"button",text:_("Cancel invitation"),tooltip:{title:_("Cancel invitation"),
text:_("Cancel to invitation")},overflowText:_("Cancel invitation"),iconCls:"icon_cancel_meeting_request",ref:"cancelInvitation",handler:this.onCancelMeetingRequest,scope:this},{xtype:"button",overflowText:_("High priority"),tooltip:{title:_("High priority"),text:_("Mark this appointment as high priority")},iconCls:"icon_setHighPriority",ref:"highPriority",toggleGroup:"priorityGroup",importance:Zarafa.core.mapi.Importance.URGENT,handler:this.onPriorityGroupToggle,scope:this},{xtype:"button",overflowText:_("Low priority"),
tooltip:{title:_("Low priority"),text:_("Mark this appointment as low priority")},iconCls:"icon_setLowPriority",ref:"lowPriority",toggleGroup:"priorityGroup",importance:Zarafa.core.mapi.Importance.NONURGENT,handler:this.onPriorityGroupToggle,scope:this},{xtype:"button",overflowText:_("Categories"),tooltip:{title:_("Categories"),text:_("Open the categories dialog")},iconCls:"icon_categories",handler:this.onCategories,scope:this},{xtype:"button",overflowText:_("Private"),tooltip:{title:_("Private"),
text:_("Mark this appointment as private")},iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSetRecurrence:function(){Zarafa.common.Actions.openRecurrenceDialog(this.record,false,this.dialog.isBrowser())},onSetMeetingRequest:function(){this.record.set("meeting",Zarafa.core.mapi.MeetingStatus.MEETING);this.record.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED)},onCancelMeetingRequest:function(){if(this.record.isMeetingSent())Zarafa.calendar.Actions.openSendCancellationDialog(this.record);
else{this.record.set("meeting",Zarafa.core.mapi.MeetingStatus.NONMEETING);this.record.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE)}},onPriorityGroupToggle:function(a){a.pressed?this.record.set("importance",a.importance):this.record.set("importance",Zarafa.core.mapi.Importance.NORMAL)},onCategories:function(){Zarafa.common.Actions.openCategoriesDialog(this.record,false,this.dialog.isBrowser())},onPrivateGroupToggle:function(a){this.record.set("private",a.pressed);a.pressed?this.record.set("sensitivity",
Zarafa.core.mapi.Sensitivity.PRIVATE):this.record.set("sensitivity",Zarafa.core.mapi.Sensitivity.NONE)},onCheckNamesButton:function(){this.record.getRecipientStore().resolve(undefined,{cancelPreviousRequest:true})},onSendButton:function(){this.dialog.sendRecord()},onSaveButton:function(){this.dialog.saveRecord()},onDeleteButton:function(){this.dialog.deleteRecord()},update:function(a,b){var c=false;this.record=a;this.deleteAppointment.setDisabled(a.phantom===true);if(b===true||a.isModifiedSinceLastUpdate("recurring")){Ext.isEmpty(a.get("basedate"))?
this.recurrence.setVisible(true):this.recurrence.setVisible(false);c=true}if(b===true||a.isModifiedSinceLastUpdate("meeting")){this.insert(0,{xtype:"zarafa.buttongroup",items:container.populateInsertionPoint("context.calendar.appointmentdialog.toolbar.actions",this),ref:"meetingrequestbuttons"});switch(a.get("meeting")){case Zarafa.core.mapi.MeetingStatus.NONMEETING:default:this.sendInvitation.setVisible(false);this.saveAppointment.setVisible(true);this.saveMeeting.setVisible(false);this.deleteAppointment.setVisible(true);
this.checkNames.setVisible(false);this.inviteAttendees.setVisible(true);this.cancelInvitation.setVisible(false);this.meetingrequestbuttons.setVisible(false);break;case Zarafa.core.mapi.MeetingStatus.MEETING:this.sendInvitation.setVisible(true);this.saveAppointment.setVisible(false);this.saveMeeting.setVisible(true);this.deleteAppointment.setVisible(false);this.checkNames.setVisible(true);this.inviteAttendees.setVisible(false);this.cancelInvitation.setVisible(true);this.meetingrequestbuttons.setVisible(false);
break;case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED:case Zarafa.core.mapi.MeetingStatus.MEETING_CANCELED:case Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED_AND_CANCELED:this.sendInvitation.setVisible(false);this.saveAppointment.setVisible(false);this.saveMeeting.setVisible(false);this.deleteAppointment.setVisible(true);this.checkNames.setVisible(false);this.inviteAttendees.setVisible(false);this.cancelInvitation.setVisible(false);this.meetingrequestbuttons.setVisible(this.meetingrequestbuttons.hasVisibleButtons());
break}c=true}if(b===true||a.isModifiedSinceLastUpdate("importance"))switch(a.get("importance")){case Zarafa.core.mapi.Importance.URGENT:this.highPriority.toggle(true,true);break;case Zarafa.core.mapi.Importance.NONURGENT:this.lowPriority.toggle(true,true);break;default:break}if(b===true||a.isModifiedSinceLastUpdate("private"))this.setPrivate.toggle(a.get("private"),true);c===true&&this.doLayout()}});Ext.reg("zarafa.appointmenttoolbar",Zarafa.calendar.dialogs.AppointmentToolbar);Ext.namespace("Zarafa.calendar.data.busytime");
Zarafa.calendar.data.busytime.BusyTimeStore=Ext.extend(Ext.data.Store,{constructor:function(a){a=a||{};Ext.applyIf(a,{batch:true,autoSave:false,remoteSort:false,proxy:new Zarafa.calendar.data.busytime.BusyTimeProxy,reader:new Ext.data.JsonReader({root:"item"},Zarafa.calendar.data.busytime.BusyTimeRecord)});Zarafa.calendar.data.busytime.BusyTimeStore.superclass.constructor.call(this,a)}});Ext.reg("zarafa.busytimestore",Zarafa.calendar.data.busytime.BusyTimeStore);Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.Views=Zarafa.core.Enum.create({BLOCKS:0,LIST:1,SEARCH:2});Ext.namespace("Zarafa.calendar.data");Zarafa.calendar.data.ViewModes=Zarafa.core.Enum.create({DAYS:0,BOX:1,LIST:2,SEARCH:3});Ext.namespace("Zarafa.calendar.data");Zarafa.calendar.data.SnapModes=Zarafa.core.Enum.create({DAY:"day",ZOOMLEVEL:"zoomlevel"});Ext.namespace("Zarafa.calendar.data");Zarafa.calendar.data.DragStates=Zarafa.core.Enum.create({NONE:0,DRAGGING:1,SELECTING:2,RESIZING_START:3,RESIZING_DUE:4});Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.DataModes=Zarafa.core.Enum.create({DAY:0,WORKWEEK:1,WEEK:2,MONTH:3,ALL:4,SEARCH:5});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.MemberBox=Ext.extend(Zarafa.common.recipientfield.ui.RecipientBox,{isValidRecord:function(a){a=a.get("distlist_type");if(Ext.isDefined(Zarafa.core.mapi.DistlistType.getName(a)))return true;return false},prepareData:function(a){var b=Zarafa.addressbook.ui.MemberBox.superclass.prepareData.apply(this,arguments);b.distlist_type=a.get("distlist_type");return b},prepareIcon:function(a){if(this.isValidRecord(a))return Zarafa.common.ui.IconClass.getIconClass(a)}});
Ext.reg("zarafa.memberbox",Zarafa.addressbook.ui.MemberBox);Ext.namespace("Zarafa.addressbook.ui");Zarafa.addressbook.ui.AddressBookBox=Ext.extend(Zarafa.common.recipientfield.ui.RecipientBox,{validDisplayType:undefined,isValidRecord:function(a){return a.isResolved()&&(!Ext.isDefined(this.validDisplayType)||a.get("display_type")===this.validDisplayType)}});Ext.reg("zarafa.addressbookbox",Zarafa.addressbook.ui.AddressBookBox);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.RecipientSelectionDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,recipientButtonsCfg:undefined,hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.receipientselectiondialog",layout:"fit",alwaysUseDefaultTitle:true,defaultTitle:_("Address Book"),useShadowStore:false,alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,items:[{xtype:"zarafa.recipientselectionpanel",
defaultRecipientType:a.defaultRecipientType||this.defaultRecipientType,recipientButtonsCfg:a.recipientButtonsCfg||this.recipientButtonsCfg,hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.addressbook.dialogs.RecipientSelectionDialog.superclass.constructor.call(this,a)}});
Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.RecipientSelectionDialog,"zarafa.receipientselectiondialog");Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.MemberSelectionDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.memberselectiondialog",layout:"fit",alwaysUseDefaultTitle:true,defaultTitle:_("Address Book"),useShadowStore:false,alwaysUseDefaultTitle:true,allowWrite:true,autoSave:false,items:[{xtype:"zarafa.memberselectionpanel",hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction,
buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.addressbook.dialogs.MemberSelectionDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.MemberSelectionDialog,"zarafa.memberselectiondialog");Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.AddressBookDialog=Ext.extend(Zarafa.core.ui.Dialog,{hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.addressbookdialog",layout:"fit",title:_("Address Book"),items:[{xtype:"zarafa.addressbookpanel",listRestriction:a.listRestriction,hierarchyRestriction:a.hierarchyRestriction}]});Zarafa.addressbook.dialogs.AddressBookDialog.superclass.constructor.call(this,a)}});
Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.AddressBookDialog,"zarafa.addressbookdialog");Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserSelectionDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{callback:Ext.emptyFn,hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.abuserselectiondialog",layout:"fit",alwaysUseDefaultTitle:true,defaultTitle:_("Address Book"),items:[{xtype:"zarafa.abuserselectionpanel",hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction,callback:a.callback}]});Zarafa.addressbook.dialogs.ABUserSelectionDialog.superclass.constructor.call(this,
a)}});Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.ABUserSelectionDialog,"zarafa.abuserselectiondialog");Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserDetailDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abuserdetaildialog",layout:"fit",border:false,defaultTitle:_("User details"),titleProperty:"display_name",items:[{xtype:"zarafa.abuserdetailpanel"}]});Zarafa.addressbook.dialogs.ABUserDetailDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.ABUserDetailDialog,"zarafa.abuserdetaildialog");Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABGroupDetailDialog=Ext.extend(Zarafa.core.ui.RecordDialog,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abgroupdetaildialog",layout:"fit",border:false,defaultTitle:_("Group details"),titleProperty:"display_name",items:[{xtype:"zarafa.abgroupdetailpanel"}]});Zarafa.addressbook.dialogs.ABGroupDetailDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.addressbook.dialogs.ABGroupDetailDialog,"zarafa.abgroupdetaildialog");Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookTelephoneNumberSubStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};var b=Ext.data.Record.create([{name:"number",type:"string"}]);Ext.applyIf(a,{reader:new Zarafa.core.data.JsonReader({root:"item",id:"number",idProperty:"number"},b)});Zarafa.addressbook.AddressBookTelephoneNumberSubStore.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookHierarchyProxy=Ext.extend(Zarafa.core.data.IPMProxy,{constructor:function(a){a=a||{};var b=Zarafa.core.ModuleNames.getModule("addressbook");Ext.applyIf(a,{listModuleName:b.list,itemModuleName:b.item});Zarafa.addressbook.AddressBookHierarchyProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,e,f,g,h,i){return new Zarafa.addressbook.AddressBookResponseHandler({proxy:this,action:c,reader:f,options:i,callback:g,scope:h})}});Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookEmailAddressesSubStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};var b=Ext.data.Record.create([{name:"address",type:"string"}]);Ext.applyIf(a,{reader:new Zarafa.core.data.JsonReader({id:"address",idProperty:"address"},b)});Zarafa.addressbook.AddressBookEmailAddressesSubStore.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.DropdownBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.PopupBoxPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{msgTemplate:'<div class="zarafa-dropdown-notifier"><span class="zarafa-dropdown-notifier-title">{title}</span><br/>{message}</div>',messageContainer:{id:"dropdownmsg-div"},ctCls:"zarafa-notifier-dropdown-container",itemCls:"zarafa-notifier-dropdown-item",slideinDirection:"t",slideoutDirection:"t"});Zarafa.core.ui.notifier.DropdownBoxPlugin.superclass.constructor.call(this,
a)},layoutMsgContainer:function(){this.messageContainer.alignTo(Ext.getBody(),"t-t");this.messageContainer.setHeight(0)},getNewYPosition:function(){return 0}});Zarafa.onReady(function(){container.getNotifier().registerPlugin("dropdown",new Zarafa.core.ui.notifier.DropdownBoxPlugin)});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.RestrictionFactory={createResAnd:function(a){var b=[],c=Zarafa.core.mapi.Restrictions.RES_AND,d=[];Ext.each(a,function(e){d.push(e)});b.push(c);b.push(d);return b},createResOr:function(a){var b=[],c=Zarafa.core.mapi.Restrictions.RES_OR,d=[];Ext.each(a,function(e){d.push(e)});b.push(c);b.push(d);return b},createResNot:function(a){var b=[];a=[a];b.push(Zarafa.core.mapi.Restrictions.RES_NOT);b.push(a);return b},createResCompareProps:function(a,b){var c=[],d=Zarafa.core.mapi.Restrictions.RES_COMPAREPROPS,
e={};e[Zarafa.core.mapi.Restrictions.ULPROPTAG1]=a;e[Zarafa.core.mapi.Restrictions.ULPROPTAG2]=b;c.push(d);c.push(e);return c},createResSubRestriction:function(a,b){var c=[],d=Zarafa.core.mapi.Restrictions.RES_SUBRESTRICTION,e={};e[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;e[Zarafa.core.mapi.Restrictions.RESTRICTION]=b;c.push(d);c.push(e);return c},createPropertyObject:function(a,b,c,d){var e=[];if(Ext.isEmpty(c))c=a;e[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;e[Zarafa.core.mapi.Restrictions.VALUE]=
{};e[Zarafa.core.mapi.Restrictions.VALUE][c]=b;Ext.isEmpty(d)||(e[Zarafa.core.mapi.Restrictions.VALUE].type=d);return e},dataResComment:function(a,b){var c=[],d=Zarafa.core.mapi.Restrictions.RES_COMMENT,e={};e[Zarafa.core.mapi.Restrictions.RESTRICTION]=a;e[Zarafa.core.mapi.Restrictions.PROPS]=[];Ext.each(b,function(f){e[Zarafa.core.mapi.Restrictions.PROPS].push(f)});c.push(d);c.push(e);return c},dataResProperty:function(a,b,c,d,e){var f=[],g=Zarafa.core.mapi.Restrictions.RES_PROPERTY,h={};if(Ext.isEmpty(d))d=
a;h[Zarafa.core.mapi.Restrictions.RELOP]=b;h[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;h[Zarafa.core.mapi.Restrictions.VALUE]={};h[Zarafa.core.mapi.Restrictions.VALUE][d]=c;Ext.isEmpty(e)||(h[Zarafa.core.mapi.Restrictions.VALUE].type=e);f.push(g);f.push(h);return f},dataResExist:function(a){var b=[],c=Zarafa.core.mapi.Restrictions.RES_EXIST,d={};d[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;b.push(c);b.push(d);return b},dataResSize:function(a,b,c){var d=[],e=Zarafa.core.mapi.Restrictions.RES_SIZE,
f={};f[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;f[Zarafa.core.mapi.Restrictions.RELOP]=b;f[Zarafa.core.mapi.Restrictions.CB]=c;d.push(e);d.push(f);return d},dataResBitmask:function(a,b,c){var d=[],e=Zarafa.core.mapi.Restrictions.RES_BITMASK,f={};f[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;f[Zarafa.core.mapi.Restrictions.ULTYPE]=b;f[Zarafa.core.mapi.Restrictions.ULMASK]=c;d.push(e);d.push(f);return d},dataResContent:function(a,b,c,d,e){var f=[],g=Zarafa.core.mapi.Restrictions.RES_CONTENT,h={};if(Ext.isEmpty(d))d=
a;h[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]=0;if(Ext.isObject(b))Ext.each(b,function(i){h[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]+=i});else h[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]=b;h[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;h[Zarafa.core.mapi.Restrictions.VALUE]={};h[Zarafa.core.mapi.Restrictions.VALUE][d]=c;Ext.isEmpty(e)||(h[Zarafa.core.mapi.Restrictions.VALUE].type=e);f.push(g);f.push(h);return f}};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.JsonRecipientReader=Ext.extend(Zarafa.core.data.JsonReader,{customObjectType:Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,constructor:function(a,b){a=Ext.applyIf(a||{},{id:"rowid",idProperty:"rowid",dynamicRecord:false});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(a.customObjectType||this.customObjectType));Zarafa.core.data.JsonRecipientReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")},doItem:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse(a))},doUpdate:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse(a))},doSearch:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item");Ext.iterate(a,function(b,c){if(b!="item")this.metaData[b]=
c},this)},doUpdatesearch:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item");Ext.iterate(a,function(b,c){if(b!="item")this.metaData[b]=c},this);Ext.apply(this.options,{add:true})},doStopsearch:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")},doSearch_error:function(a){this.doError(a);return false}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMRecordFields=[{name:"body",type:"string"},{name:"html_body",type:"string"},{name:"isHTML",type:"boolean",defaultValue:false,forceProtocol:true},{name:"entryid"},{name:"creation_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"icon_index",type:"int",defaultValue:-1},{name:"access",type:"number",defaultValue:Zarafa.core.mapi.Access.ACCESS_READ},{name:"message_class",type:"string"},{name:"message_flags",type:"int",defaultValue:Zarafa.core.mapi.MessageFlags.MSGFLAG_UNSENT|
Zarafa.core.mapi.MessageFlags.MSGFLAG_READ},{name:"parent_entryid"},{name:"store_entryid"},{name:"subject"},{name:"object_type",type:"int"},{name:"normalized_subject"},{name:"last_modification_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"hasattach",type:"boolean",defaultValue:false},{name:"display_to"},{name:"display_cc"},{name:"display_bcc"},{name:"sent_representing_name"},{name:"sent_representing_email_address"},{name:"sent_representing_address_type"},{name:"sent_representing_entryid"},
{name:"sent_representing_search_key"},{name:"sender_name"},{name:"sender_email_address"},{name:"sender_address_type"},{name:"sender_entryid"},{name:"sender_search_key"},{name:"message_size",type:"int"},{name:"categories"}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("REPORT.IPM",Zarafa.core.data.IPMRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM",Zarafa.core.data.IPMRecordFields);
Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,Zarafa.core.data.IPMRecordFields);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM","createphantom",function(a){a.afterOpen()});Zarafa.core.data.RecordFactory.addListenerToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,"createphantom",function(a){a.afterOpen()});
Zarafa.core.data.IPMRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{eventPropagation:true,equals:function(a){if(this.phantom!==a.phantom)return false;return this.phantom?this.id==a.id:Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("entryid"))},isMessageClass:function(a,b){return Zarafa.core.MessageClass.isClass(this.get("message_class"),a,b)},getBody:function(a){var b=this.get("isHTML");if(a===false){a=this.get("body");if(Ext.isEmpty(a)&&!Ext.isEmpty(this.get("html_body")))a=Zarafa.core.HTMLParser.convertHTMLToPlain(this.get("html_body"))}else if(b===
false)if(a===true){a=this.get("html_body");if(Ext.isEmpty(a))a=Zarafa.core.HTMLParser.convertPlainToHTML(this.get("body"))}else a=this.get("body");else a=this.get("html_body");return a},isRead:function(){return(this.get("message_flags")&Zarafa.core.mapi.MessageFlags.MSGFLAG_READ)>0},isUnsent:function(){return(this.get("message_flags")&Zarafa.core.mapi.MessageFlags.MSGFLAG_UNSENT)>0},needsReadReceipt:function(){return(this.get("message_flags")&Zarafa.core.mapi.MessageFlags.MSGFLAG_RN_PENDING)===Zarafa.core.mapi.MessageFlags.MSGFLAG_RN_PENDING},
setReadFlags:function(a){var b=this.get("message_flags");this.addMessageAction("action_type","read_flag");a===false?this.set("message_flags",b&~Zarafa.core.mapi.MessageFlags.MSGFLAG_READ):this.set("message_flags",b|Zarafa.core.mapi.MessageFlags.MSGFLAG_READ)},supportsRecipients:function(){return this.supportsSubStore("recipients")},createRecipientStore:function(){return this.createSubStore("recipients")},setRecipientStore:function(a){return this.setSubStore("recipients",a)},getRecipientStore:function(){return this.getSubStore("recipients")},
supportsAttachments:function(){return this.supportsSubStore("attachments")},createAttachmentStore:function(){return this.createSubStore("attachments")},setAttachmentStore:function(a){return this.setSubStore("attachments",a)},getAttachmentStore:function(){return this.getSubStore("attachments")}});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("REPORT.IPM",Zarafa.core.data.IPMRecord);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM",Zarafa.core.data.IPMRecord);
Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,Zarafa.core.data.IPMRecord);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMRecipientResolveResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doChecknames:function(a){this.receivedRecords=[];if(Ext.isDefined(a.resolveresponse))for(var b=0;b<a.resolveresponse.length;b++)this.receivedRecords.push({id:a.resolveresponse[b].id,result:this.readRecordsFromResponse(a.resolveresponse[b],"result")})},readRecordsFromResponse:function(a,b){var c=a[b]||[];Ext.isArray(c)||(c=[c]);var d={};d[b]=c;return this.reader.readRecords(d)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMRecipientRecordFields=[{name:"entryid"},{name:"rowid",type:"int"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER},{name:"display_name"},{name:"display_type",type:"int",defaultValue:Zarafa.core.mapi.DisplayType.DT_MAILUSER},{name:"display_type_ex",type:"int",defaultValue:Zarafa.core.mapi.DisplayType.DT_MAILUSER},{name:"email_address"},{name:"smtp_address"},{name:"address_type",type:"string",defaultValue:"SMTP"},{name:"recipient_type",type:"int"},
{name:"recipient_flags",type:"int"},{name:"recipient_trackstatus",type:"int"},{name:"recipient_trackstatus_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"proposednewtime",type:"boolean",defaultValue:false},{name:"proposednewtime_start",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"proposednewtime_end",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"message_class"}];
Zarafa.core.data.IPMRecipientRecord=Ext.extend(Ext.data.Record,{resolveAttempted:false,resolveAttemptAmbiguous:false,copy:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,this.data,a||this.id);a.phantom=this.phantom;return a.applyData(this)},applyData:function(a){this.beginEdit();Ext.apply(this.data,a.data);Ext.apply(this.modified,a.modified);this.resolveAttempted=a.resolveAttempted;this.resolveAttemptAmbiguous=a.resolveAttemptAmbiguous;
this.dirty=a.dirty;this.endEdit(false);return this},isValid:function(){return this.isMeetingOrganizer()?false:Zarafa.core.data.IPMRecipientRecord.superclass.isValid.call(this)},resolve:function(){this.store&&this.store.resolve(this)},isResolved:function(){return!Ext.isEmpty(this.get("entryid"))},isOneOff:function(){return Zarafa.core.EntryId.isOneOffEntryId(this.get("entryid"))},isValidSMTP:function(){return Zarafa.core.Util.validateEmailAddress(this.get("smtp_address"))},isAmbiguous:function(){return this.resolveAttempted&&
this.resolveAttemptAmbiguous},isPersonalContact:function(){return Zarafa.core.MessageClass.isClass(this.get("message_class"),"IPM.CONTACT",true)},attemptedToResolve:function(){return this.resolveAttempted},isMeetingOrganizer:function(){return(this.get("recipient_flags")&Zarafa.core.mapi.RecipientFlags.recipOrganizer)===Zarafa.core.mapi.RecipientFlags.recipOrganizer},equals:function(a){var b=this.get("smtp_address"),c=a.get("smtp_address");if(Ext.isEmpty(b)||Ext.isEmpty(c)){b=this.get("display_name")||
"";c=a.get("display_name")||""}if(b.toUpperCase()==c.toUpperCase())return true;return false},convertToABRecord:function(){var a=Zarafa.core.mapi.ObjectType.MAPI_MAILUSER;if(!this.isResolved())return false;var b=this.get("entryid"),c=this.get("display_type");switch(c){case Zarafa.core.mapi.DisplayType.DT_MAILUSER:case Zarafa.core.mapi.DisplayType.DT_REMOTE_MAILUSER:a=Zarafa.core.mapi.ObjectType.MAPI_MAILUSER;break;case Zarafa.core.mapi.DisplayType.DT_DISTLIST:case Zarafa.core.mapi.DisplayType.DT_ORGANIZATION:case Zarafa.core.mapi.DisplayType.DT_PRIVATE_DISTLIST:a=
Zarafa.core.mapi.ObjectType.MAPI_DISTLIST;break}return Zarafa.core.data.RecordFactory.createRecordObjectByObjectType(a,{entryid:b,display_type:c,display_type_ex:this.get("display_type_ex")},b)},convertToContactRecord:function(){var a=this.get("entryid");if(a.indexOf("_")>0)a=a.substr(0,a.indexOf("_"));return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Contact",{entryid:a,message_class:"IPM.Contact",object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:this.get("store_entryid"),
parent_entryid:this.get("parent_entryid")},a)},applyResolveRecord:function(a,b){this.beginEdit();var c=a.get("entryid"),d=a.get("message_class");if(!Ext.isEmpty(d)){this.set("message_class",d);if(Zarafa.core.MessageClass.isClass(d,"IPM.CONTACT",true)){this.set("store_entryid",a.get("store_entryid"));this.set("parent_entryid",a.get("parent_entryid"));if(c.indexOf("_")>0)c=c.substr(0,c.indexOf("_"))}}this.set("entryid",c);this.set("display_name",a.get("display_name"));this.set("smtp_address",a.get("smtp_address"));
this.set("email_address",a.get("email_address"));this.set("object_type",a.get("object_type"));this.set("display_type",a.get("display_type"));this.set("display_type_ex",a.get("display_type_ex"));this.set("address_type",a.get("address_type"));this.endEdit();if(!Ext.isDefined(b)||b===false)this.store.fireEvent("resolved",this.store,[this])},getDisplayType:function(){var a=this.get("display_type"),b=this.get("display_type_ex");switch(a){case Zarafa.core.mapi.DisplayType.DT_MAILUSER:case Zarafa.core.mapi.DisplayType.DT_DISTLIST:a=
b&~Zarafa.core.mapi.DisplayTypeEx.DTE_FLAG_ACL_CAPABLE;break;default:a=a;break}return a},endEdit:function(a){this.editing=false;if(a!==false)this.resolveAttemptAmbiguous=this.resolveAttempted=false;this.dirty&&this.afterEdit()}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_RECIPIENT");Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,Zarafa.core.data.IPMRecipientRecord);
Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,Zarafa.core.data.IPMRecipientRecordFields);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMNotificationResponseHandler=Ext.extend(Zarafa.core.data.AbstractNotificationResponseHandler,{doUpdate:function(a){if(a=this.reader.readResponse(Ext.data.Api.actions.read,a)){a=a.data;for(var b=0,c=a.length;b<c;b++){var d=a[b],e=this.store.getByEntryId(d.entryid);Ext.isDefined(e)?this.addNotification(Zarafa.core.data.Notifications.objectModified,e,d):this.addNotification(Zarafa.core.data.Notifications.objectCreated,null,d)}}},doDelete:function(a){a=a.item;Ext.isArray(a)||(a=[a]);
for(var b=0,c=a.length;b<c;b++){var d=a[b],e=this.store.getByEntryId(d.entryid);e&&this.addNotification(Zarafa.core.data.Notifications.objectDeleted,e,d)}},doNewobject:function(a){var b=Ext.pluck(a.item,"entryid");b=Zarafa.core.data.IPMStoreMgr.getStoresForFolders(b);this.addNotification(Zarafa.core.data.Notifications.objectCreated,b,a)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMAttachmentRecordFields=[{name:"object_type",type:"int"},{name:"attach_num",type:"int",defaultValue:-1},{name:"attach_method",type:"int"},{name:"attach_message_class"},{name:"size",type:"int"},{name:"cid"},{name:"filetype"},{name:"hidden",type:"boolean",defaultValue:false},{name:"name"},{name:"tmpname"},{name:"attachment_contactphoto",type:"boolean",defaultValue:false},{name:"attachment_contactphoto_sizex",type:"int"},{name:"attachment_contactphoto_sizey",type:"int"}];
Zarafa.core.data.IPMAttachmentRecord=Ext.extend(Ext.data.Record,{setInline:function(a){this.inline=a},isTmpFile:function(){return this.get("attach_num")==-1},isInline:function(){return this.inline},isRecurrenceException:function(){this.get("attach_message_class");return Zarafa.core.MessageClass.isClass(this.get("attach_message_class"),"IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}")},isContactPhoto:function(){return this.get("attachment_contactphoto")},getInlineImageUrl:function(){return this.store.getInlineImageUrl(this)},
getAttachmentUrl:function(){return this.store.getAttachmentUrl(this)}});Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_ATTACH,Zarafa.core.data.IPMAttachmentRecord);Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_ATTACH,Zarafa.core.data.IPMAttachmentRecordFields);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.DummyResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{start:function(a,b){this.proxy&&Ext.isFunction(this.proxy.deleteRequestId)&&this.proxy.deleteRequestId(b);return false}});Ext.namespace("Zarafa.common.restoreitem.data");Zarafa.common.restoreitem.data.RestoreItemStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){}});Ext.reg("zarafa.restoreitemstore",Zarafa.common.restoreitem.data.RestoreItemStore);Ext.namespace("Zarafa.common.reminder.data");
Zarafa.common.reminder.data.ReminderRecordFields=[{name:"entryid"},{name:"store_entryid"},{name:"parent_entryid"},{name:"message_flags"},{name:"message_class"},{name:"icon_index"},{name:"subject"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE},{name:"location"},{name:"reminder",type:"boolean"},{name:"reminder_minutes",type:"int"},{name:"reminder_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"flagdueby",type:"date",dateFormat:"timestamp",defaultValue:null},
{name:"task_duedate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"task_startdate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"task_resetreminder"},{name:"task_recurring"},{name:"appointment_recurring"},{name:"appointment_startdate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"appointment_enddate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"appointment_startdate_recurring"},{name:"appointment_enddate_recurring"}];
Zarafa.common.reminder.data.ReminderRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{convertToIPMRecord:function(){var a=this.get("entryid"),b=this.get("message_class"),c={};if(Zarafa.core.MessageClass.isClass(b,"IPM.Appointment",true))c={recurring:this.get("appointment_recurring"),startdate:this.get("appointment_startdate"),duedate:this.get("appointment_enddate"),startdate_recurring:this.get("appointment_startdate_recurring"),enddate_recurring:this.get("appointment_enddate_recurring")};else if(Zarafa.core.MessageClass.isClass(b,
"IPM.Task",true))c={startdate:this.get("task_startdate"),duedate:this.get("task_duedate")};else if(!Zarafa.core.MessageClass.isClass(b,"IPM.Note",true)){Ext.MessageBox.alert(_("Info"),_("Not supported at the moment."));return}Ext.applyIf(c,{entryid:a,parent_entryid:this.get("parent_entryid"),store_entryid:this.get("store_entryid"),object_type:this.get("object_type"),message_class:b,message_flags:this.get("message_flags"),subject:this.get("subject"),location:this.get("location"),icon_index:this.get("icon_index"),
reminder:this.get("reminder"),reminder_minutes:this.get("reminder_minutes"),reminder_time:this.get("reminder_time"),flagdueby:this.get("flagdueby")});return Zarafa.core.data.RecordFactory.createRecordObjectByRecordData(c,a)}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_REMINDER");Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_REMINDER,Zarafa.common.reminder.data.ReminderRecord);
Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_REMINDER,Zarafa.common.reminder.data.ReminderRecordFields);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.RecipientField=Ext.extend(Zarafa.common.ui.BoxField,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,filterRecipientType:undefined,delimiterCharacter:";",constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.common.recipientfield.data.SuggestionListStore;Ext.applyIf(a,{boxType:"zarafa.recipientbox",itemSelector:"div.x-zarafa-boxfield-suggestion-item",border:false,minChars:1,listEmptyText:_("No suggestions available"),height:50,tpl:new Ext.XTemplate('<tpl for=".">',
'<div class="x-zarafa-boxfield-suggestion-item x-combo-list-item">',"{values.display_name:htmlEncode} &lt;",'<tpl if="!Ext.isEmpty(values.smtp_address)">{values.smtp_address:htmlEncode}</tpl>','<tpl if="Ext.isEmpty(values.smtp_address)">{values.email_address:htmlEncode}</tpl>',"&gt;","</div>","</tpl>")});Zarafa.common.recipientfield.ui.RecipientField.superclass.constructor.call(this,a);this.mon(this,"boxdblclick",this.onBoxDblClick,this);this.mon(this,"boxcontextmenu",this.onBoxContextMenu,this)},
handleInput:function(a){a=a.split(this.delimiterCharacter);for(var b=[],c=0;c<a.length;c++){var d=a[c].trim();if(!Ext.isEmpty(d)){d=this.boxStore.parseRecipient(d,this.defaultRecipientType);b.push(d)}}b.length>0&&this.boxStore.add(b)},handleSelection:function(a){this.boxStore.add(a.convertToRecipient(this.defaultRecipientType))},setRecipientStore:function(){return this.setBoxStore.apply(this,arguments)},getRecipientStore:function(){return this.getBoxStore()},setBoxStore:function(a,b){if(!(this.boxStore===
a&&b!==true)){if(this.boxStore){this.mun(this.boxStore,"resolved",this.onBoxStoreResolved,this);this.mun(this.boxStore,"beforeresolve",this.onBoxStoreBeforeResolve,this)}Zarafa.common.recipientfield.ui.RecipientField.superclass.setBoxStore.apply(this,arguments);if(this.boxStore){this.mon(this.boxStore,"resolved",this.onBoxStoreResolved,this);this.mon(this.boxStore,"beforeresolve",this.onBoxStoreBeforeResolve,this)}}},onBoxStoreResolved:function(a,b){b=this.filterRecords(this.getBoxStore(),b);for(var c=
0;c<b.length;c++){var d=this.getBoxForRecord(b[c]);d&&d.doUpdate()}},onBoxStoreBeforeResolve:function(a,b){b=this.filterRecords(this.getBoxStore(),b);for(var c=0;c<b.length;c++){var d=this.getBoxForRecord(b[c]);d&&d.doUpdate()}},filterRecord:function(a){return!a.isMeetingOrganizer()&&(!Ext.isDefined(this.filterRecipientType)||a.get("recipient_type")===this.filterRecipientType)},onBoxDblClick:function(a,b,c){c.isResolved()?Zarafa.common.Actions.openViewRecipientDialog(c):Zarafa.common.Actions.openCreateRecord(c)},
onBoxContextMenu:function(a,b,c){Zarafa.common.Actions.openContextMenu(c,b.getEl().getXY(),{editable:b.editable})}});Ext.reg("zarafa.recipientfield",Zarafa.common.recipientfield.ui.RecipientField);Ext.namespace("Zarafa.common.recipientfield.data");Zarafa.common.recipientfield.data.SuggestionListResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){a=a.results||[];Ext.isArray(a)||(a=[a]);this.receivedRecords=this.reader.readRecords({count:a.length,result:a})}});Ext.namespace("Zarafa.common.recipientfield.data");
Zarafa.common.recipientfield.data.SuggestionListRecord=Ext.data.Record.create([{name:"display_name"},{name:"smtp_address"},{name:"email_address"},{name:"address_type"},{name:"count",type:"int"},{name:"last_used",type:"date",dateFormat:"timestamp"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER}]);
Zarafa.common.recipientfield.data.SuggestionListRecord=Ext.extend(Zarafa.common.recipientfield.data.SuggestionListRecord,{convertToRecipient:function(a){return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{object_type:this.get("object_type"),display_name:this.get("display_name"),email_address:this.get("email_address"),smtp_address:this.get("smtp_address"),address_type:this.get("address_type"),recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO})}});
Ext.namespace("Zarafa.common.freebusy.data");Zarafa.common.freebusy.data.FreebusyResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){var b=[];Ext.each(a.users,function(c){Ext.each(c.items,function(d){b.push(Ext.applyIf(d,{userid:c.userid}))})});this.receivedRecords=this.reader.readRecords({count:b.length,item:b})}});Ext.namespace("Zarafa.common.delegates.data");
Zarafa.common.delegates.data.DelegateRecordFields=[{name:"entryid"},{name:"display_name",type:"string"},{name:"can_see_private",type:"boolean",defaultValue:false},{name:"has_meeting_rule",type:"boolean",defaultValue:false},{name:"rights_calendar",type:"number"},{name:"rights_tasks",type:"number"},{name:"rights_inbox",type:"number"},{name:"rights_contacts",type:"number"},{name:"rights_notes",type:"number"},{name:"rights_journal",type:"number"}];
Zarafa.common.delegates.data.DelegateRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{baseIdProperties:["entryid"],copy:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DELEGATE,this.data,a||this.id);a.idProperties=this.idProperties.clone();a.phantom=this.phantom;return a.applyData(this)},applyData:function(a){this.beginEdit();Ext.apply(this.data,a.data);Ext.apply(this.modified,a.modified);this.dirty=a.dirty;this.endEdit();return this},
equals:function(a){return Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("entryid"))},isOpened:function(){return true}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_DELEGATE");Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DELEGATE,Zarafa.common.delegates.data.DelegateRecord);Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DELEGATE,Zarafa.common.delegates.data.DelegateRecordFields);
Ext.namespace("Zarafa.common.delegates.data");Zarafa.common.delegates.data.DelegatePermissionProfiles=[{value:Zarafa.core.mapi.Rights.RIGHTS_OWNER,name:_("Owner")},{value:Zarafa.core.mapi.Rights.RIGHTS_SECRETARY,name:_("Secretary")},{value:Zarafa.core.mapi.Rights.RIGHTS_READONLY,name:_("Only read")},{value:Zarafa.core.mapi.Rights.RIGHTS_NONE,name:_("None")}];Ext.namespace("Zarafa.common.data");
Zarafa.common.data.ImportanceFlags={flags:[{value:Zarafa.core.mapi.Importance.NONURGENT,name:Zarafa.core.mapi.Importance.getDisplayName(Zarafa.core.mapi.Importance.NONURGENT),iconCls:Zarafa.core.mapi.Importance.getClassName(Zarafa.core.mapi.Importance.NONURGENT)},{value:Zarafa.core.mapi.Importance.NORMAL,name:Zarafa.core.mapi.Importance.getDisplayName(Zarafa.core.mapi.Importance.NORMAL),iconCls:Zarafa.core.mapi.Importance.getClassName(Zarafa.core.mapi.Importance.NORMAL)},{value:Zarafa.core.mapi.Importance.URGENT,
name:Zarafa.core.mapi.Importance.getDisplayName(Zarafa.core.mapi.Importance.URGENT),iconCls:Zarafa.core.mapi.Importance.getClassName(Zarafa.core.mapi.Importance.URGENT)}]};Ext.namespace("Zarafa.common");
Zarafa.common.CommonContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"default",hasToolbar:false,hasContentPanel:false});Zarafa.common.CommonContext.superclass.constructor.call(this,a);this.registerInsertionPoint("context.settings.categories",this.createDelegateSettingCategories,this);Zarafa.core.data.SharedComponentType.addProperty("common.dialog.copymoverecords");Zarafa.core.data.SharedComponentType.addProperty("common.dialog.recurrence");Zarafa.core.data.SharedComponentType.addProperty("common.dialog.categories");
Zarafa.core.data.SharedComponentType.addProperty("common.dialog.attachments");Zarafa.core.data.SharedComponentType.addProperty("common.dialog.checknames");Zarafa.core.data.SharedComponentType.addProperty("common.dialog.restoreitems");Zarafa.core.data.SharedComponentType.addProperty("common.dialog.reminder");Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.previewpanel.extrainfo");Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.importance");Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.freebusy");
Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.freebusy.timelinebody");Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.freebusy.timelineheader");Zarafa.core.data.SharedComponentType.addProperty("common.contextmenu.reminder.remindergrid");Zarafa.core.data.SharedComponentType.addProperty("common.printer.renderer")},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.dialog.copymoverecords"]:case Zarafa.core.data.SharedComponentType["common.dialog.recurrence"]:case Zarafa.core.data.SharedComponentType["common.dialog.categories"]:case Zarafa.core.data.SharedComponentType["common.dialog.attachments"]:case Zarafa.core.data.SharedComponentType["common.dialog.checknames"]:case Zarafa.core.data.SharedComponentType["common.dialog.restoreitems"]:case Zarafa.core.data.SharedComponentType["common.dialog.reminder"]:case Zarafa.core.data.SharedComponentType["common.contextmenu.previewpanel.extrainfo"]:case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelinebody"]:case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelineheader"]:case Zarafa.core.data.SharedComponentType["common.contextmenu.importance"]:case Zarafa.core.data.SharedComponentType["common.contextmenu.reminder.remindergrid"]:c=
1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord||b instanceof Zarafa.core.data.IPMAttachmentRecord)c=1;break;case Zarafa.core.data.SharedComponentType["common.create"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=1;else if(b instanceof Zarafa.common.delegates.data.DelegateRecord)c=
1;break;case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=1;else if(b instanceof Zarafa.core.data.IPMAttachmentRecord)c=0;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.dialog.copymoverecords"]:c=Zarafa.common.dialogs.CopyMoveDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.recurrence"]:c=Zarafa.common.recurrence.dialogs.RecurrenceDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.categories"]:c=
Zarafa.common.categories.dialogs.CategoriesDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.attachments"]:c=Zarafa.common.attachment.dialogs.AttachmentsDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.checknames"]:c=Zarafa.common.checknames.dialogs.CheckNamesDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.restoreitems"]:c=Zarafa.common.restoreitem.dialogs.RestoreItemDialog;break;case Zarafa.core.data.SharedComponentType["common.dialog.reminder"]:c=
Zarafa.common.reminder.dialogs.ReminderDialog;break;case Zarafa.core.data.SharedComponentType["common.create"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=Zarafa.common.recipientfield.ui.EditRecipientDialog;else if(b instanceof Zarafa.common.delegates.data.DelegateRecord)c=Zarafa.common.delegates.dialogs.DelegatePermissionDialog;break;case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=Zarafa.common.recipientfield.ui.ViewRecipientDialog;
else if(b instanceof Zarafa.core.data.IPMAttachmentRecord)c=this;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.previewpanel.extrainfo"]:c=Zarafa.common.ui.messagepanel.ExtraInfoContextMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy"]:c=Zarafa.common.freebusy.ui.FreebusyContextMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelinebody"]:c=Zarafa.common.freebusy.ui.FreebusyTimelineBodyContextMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelineheader"]:c=
Zarafa.common.freebusy.ui.FreebusyTimelineHeaderContextMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=Zarafa.common.recipientfield.ui.RecipientContextMenu;else if(b instanceof Zarafa.core.data.IPMAttachmentRecord)c=Zarafa.common.attachment.ui.AttachmentContextMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.importance"]:c=Zarafa.common.ui.ImportanceMenu;break;case Zarafa.core.data.SharedComponentType["common.contextmenu.reminder.remindergrid"]:c=
Zarafa.common.reminder.dialogs.ReminderGridContextMenu;break}return c},doOpen:function(a){Zarafa.common.Actions.downloadAttachment(a)},createDelegateSettingCategories:function(a,b,c){return{xtype:"zarafa.settingsdelegatecategory",settingsContext:c}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.common.CommonContext)});Ext.namespace("Zarafa.today");
Zarafa.today.TodayContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"today"});this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);Zarafa.today.TodayContext.superclass.constructor.call(this,a)},bid:function(a){if(a.isOwnRoot())return 2;return 0},createContentPanel:function(){return{xtype:"zarafa.widgetpanel",title:_("Today"),settingsPath:"zarafa/v1/contexts/today",showDefaultWidgets:["appointments","tasks"],context:this,collapsible:false,
numColumns:container.getSettingsModel().get("zarafa/v1/contexts/today/num_columns")}},getMainToolbarViewButtons:function(){return container.populateInsertionPoint("main.maintoolbar.view.today",this)||[]},createMainTab:function(){return{text:_("Zarafa"),tabOrderIndex:1,context:"today"}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.today.TodayContext)});Ext.namespace("Zarafa.task.printer");
Zarafa.task.printer.TaskRenderer=Ext.extend(Zarafa.common.printer.renderers.RecordRenderer,{generateBodyTemplate:function(a){var b="";b+="<b>{fullname:htmlEncode}</b>\n";b+="<hr>\n";b+="<table>\n";b+=this.addRow(_("Subject"),"{subject:htmlEncode}");b+=this.optionalRow(_("Start"),"startdate",'{startdate:date("'+_("l d/m/Y")+'")}');b+=this.optionalRow(_("Due"),"duedate",'{duedate:date("'+_("l d/m/Y")+'")}');b+=this.optionalRow(_("Priority"),"importance","{importance:importanceString}");b+=this.addRow("",
"");b+=this.addRow(_("Status"),"{status:taskStatusString}");b+=this.addRow(_("Percent complete"),"{percent_complete:percentage(0)}");b+=this.addRow("","");b+=this.addRow(_("Total work"),_("{totalwork} hours"));b+=this.addRow(_("Actual work"),_("{actualwork} hours"));b+=this.addRow("","");b+=this.optionalRow(_("Recurrence pattern"),"recurring_pattern","{recurring_pattern:htmlEncode}");b+=this.optionalRow("","recurring_pattern","");b+=this.addRow(_("Owner"),"{owner:htmlEncode}");b+=this.addRow("","");
b+=this.optionalRow(_("Categories"),"categories","{categories:htmlEncode}");b+=this.optionalRow(_("Attachments"),"attachment_names","{attachment_names:htmlEncode}");b+="</table><br><p>\n";b+=a.getBody(true);b+="</p>\n";return b}});Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskEditDialog=Ext.extend(Zarafa.core.ui.MessageDialog,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",xtype:"zarafa.taskeditdialog",closeOnSave:true,defaultTitle:_("Create Task"),allowWrite:true,confirmClose:true,items:[{xtype:"zarafa.taskpanel",tbar:{xtype:"zarafa.taskdialogtoolbar"}}]});Zarafa.task.dialogs.TaskEditDialog.superclass.constructor.call(this,a)}});Zarafa.core.ui.Dialog.register(Zarafa.task.dialogs.TaskEditDialog,"zarafa.taskeditdialog");Ext.namespace("Zarafa.task.data");
Zarafa.task.data.TaskStatus={status:[{value:Zarafa.core.mapi.TaskStatus.NOT_STARTED,name:Zarafa.core.mapi.TaskStatus.getDisplayName(Zarafa.core.mapi.TaskStatus.NOT_STARTED)},{value:Zarafa.core.mapi.TaskStatus.IN_PROGRESS,name:Zarafa.core.mapi.TaskStatus.getDisplayName(Zarafa.core.mapi.TaskStatus.IN_PROGRESS)},{value:Zarafa.core.mapi.TaskStatus.COMPLETE,name:Zarafa.core.mapi.TaskStatus.getDisplayName(Zarafa.core.mapi.TaskStatus.COMPLETE)},{value:Zarafa.core.mapi.TaskStatus.WAIT_FOR_OTHER_PERSON,name:Zarafa.core.mapi.TaskStatus.getDisplayName(Zarafa.core.mapi.TaskStatus.WAIT_FOR_OTHER_PERSON)},
{value:Zarafa.core.mapi.TaskStatus.DEFERRED,name:Zarafa.core.mapi.TaskStatus.getDisplayName(Zarafa.core.mapi.TaskStatus.DEFERRED)}]};Ext.namespace("Zarafa.task");Zarafa.task.TaskStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){Zarafa.task.TaskStore.superclass.constructor.call(this,{preferredMessageClass:"IPM.Task",defaultSortInfo:{field:"duedate",direction:"desc"}})}});Ext.reg("zarafa.taskstore",Zarafa.task.TaskStore);Ext.namespace("Zarafa.task");
Zarafa.task.TaskContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{name:"task",displayName:_("Task"),current_view:Zarafa.task.data.Views.LIST,current_view_mode:Zarafa.task.data.ViewModes.NORMAL});this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);this.registerInsertionPoint("main.maintoolbar.new.item",this.createToolbarNewTaskButton,this);Zarafa.task.TaskContext.superclass.constructor.call(this,a);
this.registerInsertionPoint("navigation.center",this.createTaskNavigationPanel,this)},getModel:function(){if(!Ext.isDefined(this.model)){this.model=new Zarafa.task.TaskContextModel;this.model.on({searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,scope:this})}return this.model},onModelSearchStart:function(){if(this.getCurrentView()!=Zarafa.task.data.Views.SEARCH&&this.getCurrentViewMode()!=Zarafa.task.data.ViewModes.SEARCH){this.oldView=this.getCurrentView();this.oldViewMode=this.getCurrentViewMode();
this.switchView(Zarafa.task.data.Views.SEARCH,Zarafa.task.data.ViewModes.SEARCH)}},onModelSearchStop:function(){this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},bid:function(a){if(a.isContainerClass("IPF.Task",true))return 1;return-1},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecord&&
b.isMessageClass("IPM.Task",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass("IPM.Task",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE){if(b.isMessageClass(["IPM.Task"],true))c=1}else if(b instanceof Zarafa.task.TaskContext)c=1;break}return c},getSharedComponent:function(a,
b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:c=Zarafa.task.dialogs.TaskEditDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.task.ui.TaskContextMenu;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:c=b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE?Zarafa.task.printer.TaskRenderer:Zarafa.task.printer.TaskListViewRenderer;
break}return c},createTaskNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",cls:"zarafa-context-navigation-block",title:_("My Tasks"),items:[{xtype:"zarafa.hierarchytreepanel",model:this.getModel(),IPMFilter:"IPF.Task",enableDD:true,enableItemDrop:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.TASK,buttonText:_("Open Shared Tasks")}}]}]}},createContentPanel:function(){return{xtype:"zarafa.taskmainpanel",
context:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.task",this)||[];return[{text:_("Simple Tasks"),overflowText:_("Simple Tasks"),iconCls:"task_list_view task_simple_view",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{text:_("Active Tasks"),overflowText:_("Active Tasks"),iconCls:"task_list_view task_active_view",
valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.ACTIVE,handler:this.onContextSelectView,scope:this},{text:_("Next Seven Days"),overflowText:_("Next Seven Days"),iconCls:"task_list_view task_seven_days",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.NEXT_7_DAYS,handler:this.onContextSelectView,scope:this},{text:_("OverDue Tasks"),overflowText:_("OverDue Tasks"),
iconCls:"task_list_view task_overdue_view",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.OVERDUE,handler:this.onContextSelectView,scope:this},{text:_("Completed Tasks"),overflowText:_("Completed Tasks"),iconCls:"task_list_view task_completed_view",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.COMPLETED,handler:this.onContextSelectView,scope:this}].concat(a)},
onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},createToolbarNewTaskButton:function(){return{xtype:"menuitem",text:_("Task"),handler:function(){Zarafa.task.Actions.openTaskDialog(undefined,this.getModel())},iconCls:"icon_createTask",newMenuIndex:4,context:"task",scope:this}},getMainToolbarPrintButtons:function(){var a=container.populateInsertionPoint("main.toolbar.print.task",this)||[];return[{xtype:"zarafa.conditionalitem",
overflowText:_("Print selected task"),iconCls:"icon_print_single_task",text:_("Print selected task"),handler:this.onPrintSelected,hideOnDisabled:false,nonEmptySelectOnly:true,scope:this,beforeShow:function(b){var c=this.getModel().getSelectedRecords();Ext.isDefined(c)||(c=[]);if(b.nonEmptySelectOnly)Ext.isDefined(c)&&Ext.isArray(c)&&c.length==0?b.setDisabled(true):b.setDisabled(false)}},{overflowText:_("Print task list"),iconCls:"icon_print_task_list",text:_("Print task list"),handler:this.onPrintList,
scope:this}].concat(a)},onPrintSelected:function(){var a=this.model.getSelectedRecords();Ext.isEmpty(a)||Ext.isArray(a)&&a.length==0?Ext.MessageBox.alert(_("print"),_("No task selected")):Zarafa.common.Actions.openPrintDialog(a)},onPrintList:function(){var a=container.getCurrentContext();a&&Zarafa.common.Actions.openPrintDialog(a)},createMainTab:function(){return{text:_("Task"),tabOrderIndex:5,context:"task"}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.task.TaskContext)});Ext.namespace("Zarafa.settings");
Zarafa.settings.SettingsContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"settings",stateful:false});Zarafa.settings.SettingsContext.superclass.constructor.call(this,a);this.registerInsertionPoint("main.maintabbar.right",this.createSettingsMainTab,this);this.registerInsertionPoint("context.settings.categories",this.createSettingCategories,this)},getModel:function(){if(!Ext.isDefined(this.model))this.model=new Zarafa.settings.SettingsContextModel;return this.model},
setView:function(a){if(this.current_view!=a)this.getModel().hasChanges()?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("Do you wish to apply the changes?"),icon:Ext.MessageBox.QUESTION,fn:this.applyChanges.createDelegate(this,[a],1),buttons:Ext.MessageBox.YESNOCANCEL}):Zarafa.settings.SettingsContext.superclass.setView.call(this,a)},setViewMode:function(a){var b=this.current_view_mode;this.current_view_mode=a;this.fireEvent("viewmodechange",this,this.current_view_mode,b)},applyChanges:function(a,
b){if(a!=="cancel"){var c=this.getModel();a==="yes"?c.applyChanges():c.discardChanges();Zarafa.settings.SettingsContext.superclass.setView.call(this,b)}},enable:function(){Zarafa.settings.SettingsContext.superclass.enable.apply(this,arguments);container.on("beforecontextswitch",this.onBeforeContextSwitch,this);container.getNavigationBar().collapse()},disable:function(){container.getNavigationBar().expand();container.un("beforecontextswitch",this.onBeforeContextSwitch,this);Zarafa.settings.SettingsContext.superclass.disable.apply(this,
arguments)},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.settings.ui.SettingsTreeNode)c=1;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.settings.ui.SettingsTreeNode)c=Zarafa.settings.ui.SettingsContextMenu;break}return c},createContentPanel:function(){return{xtype:"zarafa.settingsmainpanel",
context:this}},createSettingsMainTab:function(){return{text:_("Settings"),tabOrderIndex:1,context:"settings",handler:function(){container.switchContext(this)},scope:this}},createSettingCategories:function(){return[{xtype:"zarafa.settingsgeneralcategory"},{xtype:"zarafa.settingspluginscategory"},{xtype:"zarafa.settingsadvancedcategory"}]},onBeforeContextSwitch:function(a,b,c){if(this.getModel().hasChanges()){Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("Do you wish to apply the changes?"),icon:Ext.MessageBox.QUESTION,
fn:this.applyChangesContext.createDelegate(this,[a,c],1),buttons:Ext.MessageBox.YESNOCANCEL});return false}},applyChangesContext:function(a,b,c){if(a!=="cancel"){var d=this.getModel();a==="yes"?d.applyChanges():d.discardChanges();container.switchContext(c,b)}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.settings.SettingsContext)});Ext.namespace("Zarafa.note");
Zarafa.note.NoteStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){Zarafa.note.NoteStore.superclass.constructor.call(this,{preferredMessageClass:"IPM.StickyNote",defaultSortInfo:{field:"subject",direction:"asc"}})}});Ext.reg("zarafa.notestore",Zarafa.note.NoteStore);Ext.namespace("Zarafa.note");
Zarafa.note.NoteContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{name:"note",displayName:_("Notes"),current_view:Zarafa.note.data.Views.ICON,current_view_mode:Zarafa.note.data.ViewModes.NORMAL});this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewNoteButton,this);Zarafa.note.NoteContext.superclass.constructor.call(this,a);this.registerInsertionPoint("navigation.center",
this.createNoteNavigationPanel,this)},getModel:function(){if(!Ext.isDefined(this.model)){this.model=new Zarafa.note.NoteContextModel;this.model.on({searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,scope:this})}return this.model},onModelSearchStart:function(){if(this.getCurrentView()!=Zarafa.note.data.Views.SEARCH&&this.getCurrentViewMode()!=Zarafa.note.data.ViewModes.SEARCH){this.oldView=this.getCurrentView();this.oldViewMode=this.getCurrentViewMode();this.switchView(Zarafa.note.data.Views.SEARCH,
Zarafa.note.data.ViewModes.SEARCH)}},onModelSearchStop:function(){this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},bid:function(a){if(a.isContainerClass("IPF.StickyNote",true))return 1;return-1},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass("IPM.StickyNote",
true))c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass("IPM.StickyNote",true))c=1;break}return c},getSharedComponent:function(a){var b;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:b=Zarafa.note.dialogs.NoteEditDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:b=Zarafa.note.ui.NoteContextMenu;break}return b},
createNoteNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",cls:"zarafa-context-navigation-block",title:_("My Notes"),items:[{xtype:"zarafa.hierarchytreepanel",model:this.getModel(),IPMFilter:"IPF.StickyNote",enableDD:true,enableItemDrop:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.NOTE,buttonText:_("Open Shared Notes")}}]}]}},createContentPanel:function(){return{xtype:"zarafa.notemainpanel",context:this}},
createNewNoteButton:function(){return{xtype:"menuitem",text:_("Sticky note"),iconCls:"icon_createNote",newMenuIndex:5,context:"note",handler:function(){Zarafa.note.Actions.openNoteDialog(null,this.getModel())},scope:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.note",this)||[];return[{text:_("Icons"),overflowText:_("Icons"),iconCls:"note_icon_view",valueView:Zarafa.note.data.Views.ICON,valueViewMode:Zarafa.note.data.ViewModes.NORMAL,valueDataMode:Zarafa.note.data.DataModes.ALL,
handler:this.onContextSelectView,scope:this},{text:_("List view"),overflowText:_("List view"),iconCls:"note_list_view",valueView:Zarafa.note.data.Views.LIST,valueViewMode:Zarafa.note.data.ViewModes.NORMAL,valueDataMode:Zarafa.note.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{text:_("List Last Seven Days"),overflowText:_("List Last Seven Days"),iconCls:"task_seven_days",valueView:Zarafa.note.data.Views.LIST,valueViewMode:Zarafa.note.data.ViewModes.NORMAL,valueDataMode:Zarafa.note.data.DataModes.LAST_7_DAYS,
handler:this.onContextSelectView,scope:this},{hidden:true,text:_("List By Category"),overflowText:_("List By Category"),iconCls:"note_list_view",valueView:Zarafa.note.data.Views.LIST,valueViewMode:Zarafa.note.data.ViewModes.GROUP_CATEGORY,valueDataMode:Zarafa.note.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{hidden:true,text:_("List By Color"),overflowText:_("List By Color"),iconCls:"note_list_view",valueView:Zarafa.note.data.Views.LIST,valueViewMode:Zarafa.note.data.ViewModes.GROUP_COLOR,
valueDataMode:Zarafa.note.data.DataModes.ALL,handler:this.onContextSelectView,scope:this}].concat(a)},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},createMainTab:function(){return{text:_("Note"),tabOrderIndex:6,context:"note"}},onViewModeChange:function(a,b){var c=this.getModel();switch(b){case Zarafa.note.data.ViewModes.NORMAL:case Zarafa.note.data.ViewModes.SEARCH:c.clearGrouping();break;case Zarafa.note.data.ViewModes.GROUP_CATEGORY:c.groupBy("categories");
break;case Zarafa.note.data.ViewModes.GROUP_COLOR:c.groupBy("color");break}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.note.NoteContext)});Ext.namespace("Zarafa.mail.printer");
Zarafa.mail.printer.MailRenderer=Ext.extend(Zarafa.common.printer.renderers.RecordRenderer,{generateBodyTemplate:function(a){var b="";b+="<b>{fullname:htmlEncode}</b>\n";b+="<hr>\n";b+="<table>\n";b+=this.addRow(_("From"),"{sender_name:htmlEncode}");b+=this.addRow(_("Sent"),'{message_delivery_time:date("'+_("l jS F Y G:i")+'")}');b+=this.optionalRow(_("To"),"display_to","{display_to:htmlEncode}");b+=this.optionalRow(_("Cc"),"display_cc","{display_cc:htmlEncode}");b+=this.optionalRow(_("Bcc"),"display_bcc",
"{display_bcc:htmlEncode}");b+=this.addRow(_("Subject"),"{subject:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Sensitivity"),"sensitivity","{sensitivity:sensitivityString}");b+=this.optionalRow(_("Importance"),"importance","{importance:importanceString}");b+='<tpl if="!Ext.isEmpty(values.sensitivity) || !Ext.isEmpty(values.importance)">';b+=this.addRow("","");b+="</tpl>";b+=this.optionalRow(_("Attachments"),"attachment_names","{attachment_names:htmlEncode}");b+="</table><br><p>\n";b+=
a.getBody(true);b+="</p>\n";return b}});Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.ShowMailDialog=Ext.extend(Zarafa.core.ui.MessageDialog,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.context))a.model=a.context.getModel();Ext.applyIf(a,{xtype:"zarafa.showmaildialog",layout:"fit",allowWrite:true,items:[this.createPanel(a.context)]});Zarafa.mail.dialogs.ShowMailDialog.superclass.constructor.call(this,a)},createPanel:function(a){return{xtype:"zarafa.mailviewpanel",tbar:{xtype:"zarafa.showmailtoolbar",
context:a}}}});Zarafa.core.ui.Dialog.register(Zarafa.mail.dialogs.ShowMailDialog,"zarafa.showmaildialog");Ext.namespace("Zarafa.mail.dialog");
Zarafa.mail.dialogs.MailFlagsButton=Ext.extend(Zarafa.core.ui.menu.ConditionalItem,{flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.red,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.flagbutton",handler:function(){this.applyFlag(this.getRecords())},scope:this});Ext.applyIf(this,a);Zarafa.mail.dialogs.MailFlagsButton.superclass.constructor.call(this,a)},applyFlag:function(a){if(!Ext.isEmpty(a)){var b;Ext.each(a,function(c){b=c.getStore();c.set("flag_status",
this.flagStatus);c.set("flag_icon",this.flagColor)},this);b.save(a)}}});Ext.reg("zarafa.flagbutton",Zarafa.mail.dialogs.MailFlagsButton);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateDialog=Ext.extend(Zarafa.core.ui.MessageDialog,{model:undefined,showbcc:false,use_html_editor:false,showfrom:false,constructor:function(a){a=a||{};if(!Ext.isDefined(a.use_html_editor))a.use_html_editor=container.getSettingsModel().get("zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor");Ext.applyIf(a,{xtype:"zarafa.mailcreatedialog",layout:"fit",defaultTitle:_("Create E-Mail"),allowWrite:true,closeOnSend:true,confirmClose:true,items:[{xtype:"zarafa.mailcreatepanel",
ref:"mainPanel",model:a.model,use_html_editor:a.use_html_editor,tbar:{xtype:"zarafa.mailcreatetoolbar"}}],savingDoneText:{title:_("Mail Saved"),msg:_("Mail has been saved in draft.")},sendingDoneText:{title:_("Mail Sent"),msg:_("Mail has been sent.")}});this.addEvents("bcctoggle","fromtoggle");Zarafa.mail.dialogs.MailCreateDialog.superclass.constructor.call(this,a)},update:function(a,b){var c=false;if(b){if(!a.userIsStoreOwner()){var d=container.getHierarchyStore().getByEntryId(a.get("store_entryid"));
a.setDelegatorInfo(d)}if(a.get("sent_representing_email_address")){c=true;d=this.mainPanel.fromRecipientField.getBoxStore();var e=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{display_name:a.get("sent_representing_name"),email_address:a.get("sent_representing_email_address"),address_type:a.get("sent_representing_address_type"),entryid:a.get("sent_representing_entryid")});d.removeAll();d.add(e)}this.fireEvent("bcctoggle",this,
this.showbcc);this.fireEvent("fromtoggle",this,this.showfrom||c);if(this.inputAutoFocusPlugin)switch(a.getMessageAction("action_type")){case Zarafa.mail.data.ActionTypes.reply:case Zarafa.mail.data.ActionTypes.replyall:this.inputAutoFocusPlugin.setAutoFocus("zarafa.editorfield");break;case Zarafa.mail.data.ActionTypes.forward:default:this.inputAutoFocusPlugin.setAutoFocus(undefined);break}}else{if(a.isSubStoreModifiedSincelastUpdate("recipients")){d=a.getSubStoreChangesSinceLastUpdate("recipients");
e=false;for(var f=0,g=d.length;f<g;f++)if(d[f].get("recipient_type")===Zarafa.core.mapi.RecipientType.MAPI_BCC){e=true;break}this.fireEvent("bcctoggle",this,this.showbcc||e)}if(a.isModifiedSinceLastUpdate("sent_representing_email_address")){Ext.isEmpty(a.get("sent_representing_email_address"))||(c=true);this.fireEvent("fromtoggle",this,this.showfrom||c)}}Zarafa.mail.dialogs.MailCreateDialog.superclass.update.apply(this,arguments)},initStateEvents:function(){Zarafa.mail.dialogs.MailCreateDialog.superclass.initStateEvents.call(this);
this.on("bcctoggle",this.saveState,this,{delay:100});this.on("fromtoggle",this.saveState,this,{delay:100})},getState:function(){var a=Zarafa.mail.dialogs.MailCreateDialog.superclass.getState.apply(this,arguments);return Ext.apply(a||{},{showbcc:this.showbcc,showfrom:this.showfrom})},toggleBccState:function(a){this.showbcc=a;this.fireEvent("bcctoggle",this,a)},toggleFromState:function(a){this.showfrom=a;this.fireEvent("fromtoggle",this,a)}});
Zarafa.core.ui.Dialog.register(Zarafa.mail.dialogs.MailCreateDialog,"zarafa.mailcreatedialog");Ext.namespace("Zarafa.mail.data");
Zarafa.mail.data.SensitivityFlags={flags:[{value:Zarafa.core.mapi.Sensitivity.NONE,name:Zarafa.core.mapi.Sensitivity.getDisplayName(Zarafa.core.mapi.Sensitivity.NONE)},{value:Zarafa.core.mapi.Sensitivity.PERSONAL,name:Zarafa.core.mapi.Sensitivity.getDisplayName(Zarafa.core.mapi.Sensitivity.PERSONAL)},{value:Zarafa.core.mapi.Sensitivity.PRIVATE,name:Zarafa.core.mapi.Sensitivity.getDisplayName(Zarafa.core.mapi.Sensitivity.PRIVATE)},{value:Zarafa.core.mapi.Sensitivity.COMPANY_CONFIDENTIAL,name:Zarafa.core.mapi.Sensitivity.getDisplayName(Zarafa.core.mapi.Sensitivity.COMPANY_CONFIDENTIAL)}]};
Ext.namespace("Zarafa.mail.data");
Zarafa.mail.data.MailFlags={colors:[{name:_("Red"),iconCls:"icon_flag_red",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.red},{name:_("Blue"),iconCls:"icon_mail_flag_blue",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.blue},{name:_("Yellow"),iconCls:"icon_mail_flag_yellow",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.yellow},{name:_("Green"),iconCls:"icon_mail_flag_green",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,
flagColor:Zarafa.core.mapi.FlagIcon.green},{name:_("Orange"),iconCls:"icon_mail_flag_orange",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.orange},{name:_("Purple"),iconCls:"icon_mail_flag_purple",flagStatus:Zarafa.core.mapi.FlagStatus.flagged,flagColor:Zarafa.core.mapi.FlagIcon.purple}],state:[{name:_("Complete"),iconCls:"icon_flag_complete",flagStatus:Zarafa.core.mapi.FlagStatus.completed,flagColor:Zarafa.core.mapi.FlagIcon.clear},{name:_("None"),iconCls:"icon_mail_flag",
flagStatus:Zarafa.core.mapi.FlagStatus.cleared,flagColor:Zarafa.core.mapi.FlagIcon.clear}]};Ext.namespace("Zarafa.mail");
Zarafa.mail.MailStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){Zarafa.mail.MailStore.superclass.constructor.call(this,{preferredMessageClass:"IPM.Note",defaultSortInfo:{field:"message_delivery_time",direction:"desc"}})},getRecordsForUpdateData:function(a,b){if(!Ext.isDefined(a)||b!==Ext.data.Api.actions.open)return Zarafa.mail.MailStore.superclass.getRecordsForUpdateData.apply(this,arguments);var c={records:[],updatedRecords:[]};Ext.isArray(a)||(a=[a]);for(var d=0,e=a.length;d<
e;d++){var f=a[d];if(f instanceof Zarafa.calendar.MeetingRequestRecord){var g=f.get("goid2");if(Ext.isEmpty(g))return Zarafa.mail.MailStore.superclass.getRecordsForUpdateData.apply(this,arguments);else{var h=-1;do{h=this.findExact("goid2",g,h+1);if(h>=0){var i=this.getAt(h);if(f.equals(i)){c.records.push(this.getAt(h));c.updatedRecords.push(f)}else if(i.isOpened()){i.opened=false;c.records.push(i);c.updatedRecords.push({})}}}while(h!=-1)}}else return Zarafa.mail.MailStore.superclass.getRecordsForUpdateData.apply(this,
arguments)}return c}});Ext.reg("zarafa.mailstore",Zarafa.mail.MailStore);Ext.namespace("Zarafa.mail");
Zarafa.mail.MailContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{name:"mail",displayName:_("Mail"),current_view:Zarafa.mail.data.Views.LIST,current_view_mode:Zarafa.mail.data.ViewModes.RIGHT_PREVIEW});Zarafa.mail.MailContext.superclass.constructor.call(this,a);this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewMailButton,this);this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);
this.registerInsertionPoint("navigation.center",this.createMailNavigationPanel,this);this.registerInsertionPoint("context.settings.categories",this.createSettingCategories,this);a=new Zarafa.mail.ui.MailPreviewPanelToolbarButtons({model:this.getModel()});this.registerInsertionPoint("previewpanel.toolbar.right",a.getToolbarButtons,a);Zarafa.core.data.SharedComponentType.addProperty("mail.dialog.options");Zarafa.core.data.SharedComponentType.addProperty("mail.dialog.flags");Zarafa.core.data.SharedComponentType.addProperty("mail.contextmenu.flags")},
getModel:function(){if(!Ext.isDefined(this.model)){this.model=new Zarafa.mail.MailContextModel;this.model.on({searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,scope:this})}return this.model},onModelSearchStart:function(){if(this.getCurrentView()!=Zarafa.mail.data.Views.SEARCH&&this.getCurrentViewMode()!=Zarafa.mail.data.ViewModes.SEARCH){this.oldView=this.getCurrentView();this.oldViewMode=this.getCurrentViewMode();this.switchView(Zarafa.mail.data.Views.SEARCH,Zarafa.mail.data.ViewModes.SEARCH)}},
onModelSearchStop:function(){this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},bid:function(a){if(a.isContainerClass("IPF.Note",true))return 1;else if(a.isContainerClass("IPF",true))return 0;return-1},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:case Zarafa.core.data.SharedComponentType["common.preview"]:if(b instanceof
Zarafa.core.data.IPMRecord)if(b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)c=b.isMessageClass(["IPM.Note","IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true)?1:0;break;case Zarafa.core.data.SharedComponentType["mail.dialog.options"]:case Zarafa.core.data.SharedComponentType["mail.dialog.flags"]:c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:case Zarafa.core.data.SharedComponentType["mail.contextmenu.flags"]:if(b instanceof Zarafa.core.data.IPMRecord)if(b.get("object_type")==
Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)c=b.isMessageClass(["IPM.Note","IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true)?1:0;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord)if(b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)if(b.isMessageClass(["IPM.Note","REPORT.IPM","REPORT.IPM.Note"],true))c=1;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:c=
Zarafa.mail.dialogs.MailCreateDialog;break;case Zarafa.core.data.SharedComponentType["common.view"]:c=Zarafa.mail.dialogs.ShowMailDialog;break;case Zarafa.core.data.SharedComponentType["mail.dialog.options"]:c=!b||b.phantom||b.isUnsent()?Zarafa.mail.dialogs.MailCreateOptionsDialog:Zarafa.mail.dialogs.MailViewOptionsDialog;break;case Zarafa.core.data.SharedComponentType["mail.dialog.flags"]:c=Zarafa.mail.dialogs.MailFlagsDialog;break;case Zarafa.core.data.SharedComponentType["common.preview"]:c=Zarafa.mail.ui.MailViewPanel;
break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.mail.ui.MailGridContextMenu;break;case Zarafa.core.data.SharedComponentType["mail.contextmenu.flags"]:c=Zarafa.mail.dialogs.MailFlagsMenu;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord)c=Zarafa.mail.printer.MailRenderer;break}return c},createContentPanel:function(){return{xtype:"zarafa.mailpanel",context:this}},createMailNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",
context:this,items:[{xtype:"panel",cls:"zarafa-context-navigation-block",title:_("My Mail"),items:[{xtype:"zarafa.hierarchytreepanel",model:this.getModel(),IPMFilter:"IPF.Note",enableDD:true,enableItemDrop:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.MAIL,buttonText:_("Open Shared Mails")}}]}]}},createNewMailButton:function(){return{xtype:"menuitem",text:_("Email message"),iconCls:"icon_createEmailMessage",newMenuIndex:1,context:"mail",handler:function(){Zarafa.mail.Actions.openMailCreateDialog(this.getModel())},
scope:this}},createSettingCategories:function(){return[{xtype:"zarafa.settingsmailcategory"}]},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.mail",this)||[];return[{overflowText:_("No preview"),iconCls:"icon_previewpanel_off",text:_("No preview"),valueView:Zarafa.mail.data.Views.LIST,valueViewMode:Zarafa.mail.data.ViewModes.NO_PREVIEW,valueDataMode:Zarafa.mail.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{overflowText:_("Right preview"),
iconCls:"icon_previewpanel_right",text:_("Right preview"),valueView:Zarafa.mail.data.Views.LIST,valueViewMode:Zarafa.mail.data.ViewModes.RIGHT_PREVIEW,valueDataMode:Zarafa.mail.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{overflowText:_("Bottom preview"),iconCls:"icon_previewpanel_bottom",text:_("Bottom preview"),valueView:Zarafa.mail.data.Views.LIST,valueViewMode:Zarafa.mail.data.ViewModes.BOTTOM_PREVIEW,valueDataMode:Zarafa.mail.data.DataModes.ALL,handler:this.onContextSelectView,
scope:this}].concat(a)},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},getMainToolbarPrintButtons:function(){var a=container.populateInsertionPoint("main.toolbar.print.mail",this)||[];return[{xtype:"zarafa.conditionalitem",overflowText:_("Print single e-mail"),iconCls:"icon_print_single",text:_("Print single e-mail"),handler:this.onPrintSingle,hideOnDisabled:false,scope:this}].concat(a)},onPrintSingle:function(){if(container.getCurrentContext()){var a=
this.model.getSelectedRecords();Ext.isEmpty(a)||Ext.isArray(a)&&a.length==0?Ext.MessageBox.alert(_("print"),_("No message selected")):Zarafa.common.Actions.openPrintDialog(a)}},onPrintList:function(){var a=container.getCurrentContext();a&&Zarafa.common.Actions.openPrintDialog(a)},createMainTab:function(){return{text:_("Mail"),tabOrderIndex:2,context:"mail"}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.mail.MailContext)});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.UserPermissionsFields=[{name:"entryid"},{name:"display_name"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER},{name:"rights",type:"int",defaultValue:Zarafa.core.mapi.Rights.RIGHTS_NONE}];Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_USER_PERMISSION");Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_USER_PERMISSION,Zarafa.core.data.MAPIRecord);
Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_USER_PERMISSION,Zarafa.hierarchy.data.UserPermissionsFields);Ext.namespace("Zarafa.common.data");
Zarafa.hierarchy.data.SharedFolderTypes={APPOINTMENT:"calendar",CONTACT:"contact",ALL:"all",MAIL:"inbox",NOTE:"note",TASK:"task",folders:[{value:"calendar",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.appointment)},{value:"contact",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.contact)},{value:"all",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.ipmsubtree)},
{value:"inbox",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.mail)},{value:"note",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.note)},{value:"task",name:Zarafa.common.data.FolderContentTypes.getFolderName(Zarafa.common.data.FolderContentTypes.task)}]};Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.PermissionProfiles=[{value:Zarafa.core.mapi.Rights.RIGHTS_FULL_CONTROL,name:_("Full control")},{value:Zarafa.core.mapi.Rights.RIGHTS_OWNER,name:_("Owner")},{value:Zarafa.core.mapi.Rights.RIGHTS_SECRETARY,name:_("Secretary")},{value:Zarafa.core.mapi.Rights.RIGHTS_READONLY,name:_("Only read")},{value:Zarafa.core.mapi.Rights.RIGHTS_NO_RIGHTS,name:_("No rights")},{value:null,name:_("Other")}];Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.MAPIStoreRecordFields=[{name:"store_entryid"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_STORE},{name:"display_name"},{name:"mdb_provider"},{name:"opened_status"},{name:"subtree_entryid"},{name:"store_support_mask",type:"int"},{name:"user_name"},{name:"user_entryid"},{name:"mailbox_owner_entryid"},{name:"mailbox_owner_name"},{name:"default_folder_inbox"},{name:"default_folder_outbox"},{name:"default_folder_sent"},{name:"default_folder_wastebasket"},
{name:"default_folder_favorites"},{name:"default_folder_publicfolders"},{name:"default_folder_calendar"},{name:"default_folder_contact"},{name:"default_folder_drafts"},{name:"default_folder_journal"},{name:"default_folder_note"},{name:"default_folder_task"},{name:"default_folder_junk"},{name:"default_folder_syncissues"},{name:"default_folder_conflicts"},{name:"default_folder_localfailures"},{name:"default_folder_serverfailures"},{name:"shared_folder_all"},{name:"shared_folder_inbox"},{name:"shared_folder_calendar"},
{name:"shared_folder_contact"},{name:"shared_folder_note"},{name:"shared_folder_task"}];Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_STORE,Zarafa.hierarchy.data.MAPIStoreRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_STORE,"folders",Zarafa.hierarchy.data.IPFSubStore);Zarafa.core.data.RecordFactory.addListenerToObjectType(Zarafa.core.mapi.ObjectType.MAPI_STORE,"createphantom",function(a){a.afterOpen()});
Zarafa.hierarchy.data.MAPIStoreRecord=Ext.extend(Zarafa.core.data.IPFRecord,{baseIdProperties:["store_entryid","user_name"],getFolder:function(a){var b=this.getFolderStore();if(b)return b.getByEntryId(a)},hasSearchSupport:function(){if(this.get("store_support_mask"))if(Zarafa.core.mapi.StoreSupportMask.hasSearchSupport(this.get("store_support_mask")))return true;return false},isPublicStore:function(){return this.get("mdb_provider")==Zarafa.core.mapi.MDBProvider.ZARAFA_STORE_PUBLIC_GUID},isDefaultStore:function(){return this.get("mdb_provider")==
Zarafa.core.mapi.MDBProvider.ZARAFA_SERVICE_GUID},isSharedStore:function(){return this.get("mdb_provider")==Zarafa.core.mapi.MDBProvider.ZARAFA_STORE_DELEGATE_GUID},getDefaultFolderKey:function(a){for(var b in this.data)if(b.indexOf("default_folder_")==0&&this.get(b)==a)return b.substring(15)},getDefaultFolder:function(a){if(a=this.get("default_folder_"+a))return this.getFolder(a)},getSharedFolderKey:function(a){for(var b in this.data)if(b.indexOf("shared_folder_")==0&&this.get(b)==a)return b.substring(14)},
getSharedFolder:function(a){if(a=this.get("shared_folder_"+a))return this.getFolder(a)},getSubtreeFolder:function(){return this.getFolder(this.get("subtree_entryid"))},getMessageActions:Ext.emptyFn,addMessageAction:Ext.emptyFn,deleteMessageAction:Ext.emptyFn,clearMessageActions:Ext.emptyFn,copyTo:Ext.emptyFn,moveTo:Ext.emptyFn,getChildren:function(){},supportsFolders:function(){return this.supportsSubStore("folders")},createFolderStore:function(){return this.createSubStore("folders")},setFolderStore:function(a){return this.setSubStore("folders",
a)},getFolderStore:function(){return this.getSubStore("folders")}});Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_STORE,Zarafa.hierarchy.data.MAPIStoreRecord);Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.MAPIFolderSubStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER);Ext.applyIf(a,{reader:new Zarafa.core.data.JsonReader({dynamicRecord:false},b)});Zarafa.hierarchy.data.MAPIFolderSubStore.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")},doFolders:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse({item:a}))},doItem:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse({item:a}))},doUpdate:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse({item:a}))}});
Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyNotificationResponseHandler=Ext.extend(Zarafa.core.data.AbstractNotificationResponseHandler,{doFolders:function(a){var b;a=a.item;if(!Ext.isEmpty(a)){Ext.isArray(a)||(a=[a]);try{b=this.reader.readResponse(Ext.data.Api.actions.read,{item:a})}catch(c){return false}for(var d=0,e=b.data.length;d<e;d++){var f=a[d],g=b.data[d],h=this.store.getByEntryId(g.entryid);if(h)f.folderdelete?this.addNotification(Zarafa.core.data.Notifications.objectDeleted,h,g):this.addNotification(Zarafa.core.data.Notifications.objectModified,
h,g);else f.folderdelete||this.addNotification(Zarafa.core.data.Notifications.objectCreated,null,g)}}},doNewmail:function(a){var b=Ext.pluck(a.item,"entryid");b=Zarafa.core.data.IPMStoreMgr.getStoresForFolders(b);this.addNotification(Zarafa.core.data.Notifications.newMail,b,a)}});Ext.namespace("Zarafa.hierarchy");
Zarafa.hierarchy.HierarchyContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"hierarchy",hasToolbar:false,hasContentPanel:false});Zarafa.hierarchy.HierarchyContext.superclass.constructor.call(this,a);this.registerInsertionPoint("main.maintoolbar.new.folder",this.createNewFolderButton,this);Zarafa.core.data.SharedComponentType.addProperty("hierarchy.dialog.folderproperties");Zarafa.core.data.SharedComponentType.addProperty("hierarchy.dialog.foldersize");Zarafa.core.data.SharedComponentType.addProperty("hierarchy.dialog.opensharedfolder")},
bidSharedComponent:function(a,b){var c=-1;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.MAPIRecord)if(b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_FOLDER)c=1;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderproperties"]:case Zarafa.core.data.SharedComponentType["hierarchy.dialog.foldersize"]:case Zarafa.core.data.SharedComponentType["hierarchy.dialog.opensharedfolder"]:c=
1;break}return c},getSharedComponent:function(a){var b;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:b=Zarafa.hierarchy.dialogs.CreateFolderDialog;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderproperties"]:b=Zarafa.hierarchy.dialogs.FolderPropertiesDialog;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.foldersize"]:b=Zarafa.hierarchy.dialogs.FolderSizeDialog;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.opensharedfolder"]:b=
Zarafa.hierarchy.dialogs.SharedFolderDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:b=Zarafa.hierarchy.ui.ContextMenu;break}return b},createNewFolderButton:function(a){if(Ext.isEmpty(a)||!(a instanceof Zarafa.core.Context))a=this;if(a instanceof Zarafa.core.Context)return[{xtype:"menuitem",text:_("Folder"),iconCls:"icon_createFolder",newMenuIndex:1,handler:this.onCreateFolder,scope:this,handler:this.onCreateFolder}]},onCreateFolder:function(){Zarafa.hierarchy.Actions.openCreateFolderDialog()}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.hierarchy.HierarchyContext)});Ext.namespace("Zarafa.contact.printer");
Zarafa.contact.printer.DistlistRenderer=Ext.extend(Zarafa.common.printer.renderers.RecordRenderer,{generateBodyTemplate:function(a){var b="";b+="<b>{fullname:htmlEncode}</b>\n";b+="<hr>\n";b+="<table>\n";b+=this.optionalRow(_("Full Name"),"display_name","{display_name:htmlEncode}");b+="</table><br><p>\n";b+=_("Members")+"\n";b+="<table>\n";b+='<tpl for="members">\n';b+=this.addRow("","{display_name:htmlEncodeUndef}");b+="</tpl>\n";b+="</table><br><p>\n";b+=a.getBody(true);b+="</p>\n";return b},prepareData:function(a){var b=
Zarafa.contact.printer.DistlistRenderer.superclass.prepareData(a);b.members=Ext.pluck(a.getMemberStore().getRange(),"data");return b}});Ext.namespace("Zarafa.contact.printer");
Zarafa.contact.printer.ContactRenderer=Ext.extend(Zarafa.common.printer.renderers.RecordRenderer,{generateBodyTemplate:function(a){var b="";b+="<b>{fullname:htmlEncode}</b>\n";b+="<hr>\n";b+="<table>\n";b+=this.optionalRow(_("Full Name"),"display_name","{display_name:htmlEncode}");b+=this.optionalRow(_("Last Name"),"surname","{surname:htmlEncode}");b+=this.optionalRow(_("First Name"),"given_name","{given_name:htmlEncode}");b+=this.optionalRow(_("Job Title"),"title","{title:htmlEncode}");b+=this.optionalRow(_("Department"),
"department_name","{department_name:htmlEncode}");b+=this.optionalRow(_("Company"),"company_name","{company_name:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Business Address"),"business_address","{business_address_street:htmlEncode}<br>{business_address_city:htmlEncode} {business_address_state:htmlEncode} {business_address_postal_code:htmlEncode}<br>{business_address_country:htmlEncode}");b+=this.optionalRow(_("IM Address"),"im","{im:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Home Address"),
"home_address","{home_address_street:htmlEncode}<br>{home_address_city:htmlEncode} {home_address_state:htmlEncode} {home_address_postal_code:htmlEncode}<br>{home_address_country:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Business"),"business_telephone_number","{business_telephone_number:htmlEncode}");b+=this.optionalRow(_("Home"),"home_telephone_number","{home_telephone_number:htmlEncode}");b+=this.optionalRow(_("Mobile"),"cellular_telephone_number","{cellular_telephone_number:htmlEncode}");
b+=this.optionalRow(_("Business Fax"),"business_fax_number","{business_fax_number:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("E-mail"),"email_address_1","{email_address_1:htmlEncode}");b+=this.optionalRow(_("E-mail Display As"),"email_address_display_name_1","{email_address_display_name_1:htmlEncode}");b+=this.optionalRow(_("E-mail 2"),"email_address_2","{email_address_2:htmlEncode}");b+=this.optionalRow(_("E-mail 2 Display As"),"email_address_display_name_2","{email_address_display_name_2:htmlEncode}");
b+=this.optionalRow(_("E-mail 3"),"email_address_3","{email_address_3:htmlEncode}");b+=this.optionalRow(_("E-mail 3 Display As"),"email_address_display_name_3","{email_address_display_name_3:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Birthday"),"birthday",'{birthday:date("'+_("jS F Y")+'")}');b+=this.optionalRow(_("Anniversary"),"wedding_anniversary",'{wedding_anniversary:date("'+_("jS F Y")+'")}');b+=this.optionalRow(_("Spouse/Partner"),"spouse_name","{spouse_name:htmlEncode}");b+=
this.optionalRow(_("Profession"),"profession","{profession:htmlEncode}");b+=this.optionalRow(_("Assistent"),"assistent","{assistent:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Categories"),"categories","{categories:htmlEncode}");b+=this.optionalRow(_("Attachments"),"attachment_names","{attachment_names:htmlEncode}");b+="</table><br><p>\n";b+=a.getBody(true);b+="</p>\n";return b}});Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.JsonMemberReader=Ext.extend(Zarafa.core.data.JsonReader,{customObjectType:Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,constructor:function(a,b){a=Ext.applyIf(a||{},{dynamicRecord:false});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(a.customObjectType||this.customObjectType));Zarafa.contact.data.JsonMemberReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.contact");
Zarafa.contact.DistlistMemberFields=[{name:"entryid"},{name:"display_name"},{name:"address_type",type:"string",defaultValue:"SMTP"},{name:"distlist_type",type:"int",defaultValue:Zarafa.core.mapi.DistlistType.DL_EXTERNAL_MEMBER},{name:"email_address"}];
Zarafa.contact.DistlistMemberRecord=Ext.extend(Ext.data.Record,{idProperties:["entryid"],copy:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,this.data,a||this.id);a.idProperties=this.idProperties.clone();a.phantom=this.phantom;return a.applyData(this)},applyData:function(a){this.beginEdit();Ext.apply(this.data,a.data);Ext.apply(this.modified,a.modified);this.dirty=a.dirty;this.endEdit();return this},equals:function(a){return Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),
a.get("entryid"))},convertToAddressBookRecord:function(){var a=this.get("entryid"),b=this.get("distlist_type"),c=Zarafa.core.mapi.ObjectType.MAPI_MAILUSER;if(b==Zarafa.core.mapi.DistlistType.DL_DIST_AB)c=Zarafa.core.mapi.ObjectType.MAPI_DISTLIST;return Zarafa.core.data.RecordFactory.createRecordObjectByObjectType(c,{entryid:a,object_type:c},a)},convertToContactRecord:function(){var a=this.get("entryid"),b="IPM.Contact";if(this.get("distlist_type")===Zarafa.core.mapi.DistlistType.DL_DIST)b="IPM.DistList";
return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass(b,{entryid:a,message_class:b,object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE},a)},isAmbiguous:function(){return false},attemptedToResolve:function(){return true},isResolved:function(){return true}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_DISTLIST_MEMBER");Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,Zarafa.contact.DistlistMemberFields);
Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,Zarafa.contact.DistlistMemberRecord);Ext.namespace("Zarafa.contact");Zarafa.contact.ContactStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){Zarafa.contact.ContactStore.superclass.constructor.call(this,{preferredMessageClass:"IPM.Contact",defaultSortInfo:{field:"fileas",direction:"desc"}})}});Ext.reg("zarafa.contactstore",Zarafa.contact.ContactStore);Ext.namespace("Zarafa.contact");
Zarafa.contact.ContactContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{name:"contact",displayName:_("Contacts"),current_view:Zarafa.contact.data.Views.LIST,current_view_mode:Zarafa.contact.data.ViewModes.NORMAL});this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewContactButton,this);this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewDistributionListButton,this);this.registerInsertionPoint("main.maintabbar.left",
this.createMainTab,this);Zarafa.contact.ContactContext.superclass.constructor.call(this,a);this.registerInsertionPoint("navigation.center",this.createContactNavigationPanel,this);Zarafa.core.data.SharedComponentType.addProperty("contact.detailsparser");Zarafa.core.data.SharedComponentType.addProperty("contact.dialog.contact.namedetails");Zarafa.core.data.SharedComponentType.addProperty("contact.dialog.contact.addressdetails");Zarafa.core.data.SharedComponentType.addProperty("contact.dialog.contact.phonedetails");
Zarafa.core.data.SharedComponentType.addProperty("contact.dialog.distlist.externalmember")},getModel:function(){if(!Ext.isDefined(this.model)){this.model=new Zarafa.contact.ContactContextModel;this.model.on({searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,scope:this})}return this.model},onModelSearchStart:function(){if(this.getCurrentView()!=Zarafa.contact.data.Views.SEARCH&&this.getCurrentViewMode()!=Zarafa.contact.data.ViewModes.SEARCH){this.oldView=this.getCurrentView();this.oldViewMode=
this.getCurrentViewMode();this.switchView(Zarafa.contact.data.Views.SEARCH,Zarafa.contact.data.ViewModes.SEARCH)}},onModelSearchStop:function(){this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass(["IPM.Contact",
"IPM.DistList"],true))c=1;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.namedetails"]:case Zarafa.core.data.SharedComponentType["contact.dialog.contact.addressdetails"]:case Zarafa.core.data.SharedComponentType["contact.dialog.contact.phonedetails"]:case Zarafa.core.data.SharedComponentType["contact.dialog.distlist.externalmember"]:c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass(["IPM.Contact",
"IPM.DistList"],true))c=1;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE){if(b.isMessageClass(["IPM.Contact","IPM.DistList"],true))c=1}else if(b instanceof Zarafa.contact.ContactContext)c=-1;break;case Zarafa.core.data.SharedComponentType["contact.detailsparser"]:c=1;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof
Zarafa.core.data.IPMRecord)if(b.isMessageClass("IPM.Contact",true))c=Zarafa.contact.dialogs.ContactDialog;else if(b.isMessageClass("IPM.DistList",true))c=Zarafa.contact.dialogs.DistlistDialog;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.namedetails"]:c=Zarafa.contact.dialogs.ContactNameDialog;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.addressdetails"]:c=Zarafa.contact.dialogs.ContactAddressDialog;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.phonedetails"]:c=
Zarafa.contact.dialogs.ContactPhoneDialog;break;case Zarafa.core.data.SharedComponentType["contact.dialog.distlist.externalmember"]:c=Zarafa.contact.dialogs.DistlistExternalMemberDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.contact.ui.ContactContextMenu;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:c=b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE?b.isMessageClass("IPM.Contact",
true)?Zarafa.contact.printer.ContactRenderer:Zarafa.contact.printer.DistlistRenderer:undefined;break;case Zarafa.core.data.SharedComponentType["contact.detailsparser"]:c=Zarafa.contact.data.ContactDetailsParser;break}return c},createContactNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",title:_("My Contacts"),cls:"zarafa-context-navigation-block",items:[{xtype:"zarafa.hierarchytreepanel",model:this.getModel(),IPMFilter:"IPF.Contact",enableDD:true,
enableItemDrop:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.CONTACT,buttonText:_("Open Shared Contacts")}}]}]}},bid:function(a){if(a.isContainerClass("IPF.Contact",true))return 1;return-1},createContentPanel:function(){return{xtype:"zarafa.contactmainpanel",context:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.contact",this)||[];return[{text:_("Business Cards"),overflowText:_("Business Cards"),
iconCls:"contact_card_view",valueView:Zarafa.contact.data.Views.ICON,valueViewMode:Zarafa.contact.data.ViewModes.BUSINESS,valueDataMode:Zarafa.contact.data.DataModes.CHARACTER_RESTRICT,handler:this.onContextSelectView,scope:this},{text:_("Phone List"),overflowText:_("Phone List"),iconCls:"contact_list_view",valueView:Zarafa.contact.data.Views.LIST,valueViewMode:Zarafa.contact.data.ViewModes.PHONE_LIST,valueDataMode:Zarafa.contact.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{hidden:true,
text:_("List By Category"),overflowText:_("List By Category"),iconCls:"contact_list_view",valueView:Zarafa.contact.data.Views.LIST,valueViewMode:Zarafa.contact.data.ViewModes.GROUP_CATEGORY,valueDataMode:Zarafa.contact.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{hidden:true,text:_("List By Company"),overflowText:_("List By Company"),iconCls:"contact_list_view",valueView:Zarafa.contact.data.Views.LIST,valueViewMode:Zarafa.contact.data.ViewModes.GROUP_COMPANY,valueDataMode:Zarafa.contact.data.DataModes.ALL,
handler:this.onContextSelectView,scope:this},{hidden:true,text:_("List By Location"),overflowText:_("List By Location"),iconCls:"contact_list_view",valueView:Zarafa.contact.data.Views.LIST,valueViewMode:Zarafa.contact.data.ViewModes.GROUP_LOCATION,valueDataMode:Zarafa.contact.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{hidden:true,text:_("List All Contacts"),overflowText:_("List All Contacts"),iconCls:"contact_list_view",valueView:Zarafa.contact.data.Views.LIST,valueViewMode:Zarafa.contact.data.ViewModes.NORMAL,
valueDataMode:Zarafa.contact.data.DataModes.ALL,handler:this.onContextSelectView,scope:this}].concat(a)},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},createNewContactButton:function(){return{xtype:"menuitem",text:_("Contact"),handler:function(){Zarafa.contact.Actions.openContactDialog(null,this.getModel())},scope:this,iconCls:"icon_createContact",newMenuIndex:3,context:"contact"}},getMainToolbarPrintButtons:function(){var a=
container.populateInsertionPoint("main.toolbar.print.contact",this)||[];return[{xtype:"zarafa.conditionalitem",overflowText:_("Print selected contact"),iconCls:"icon_print_single_contact",text:_("Print selected contact"),handler:this.onPrintSingle,hideOnDisabled:false,nonEmptySelectOnly:true,scope:this,beforeShow:function(b){var c=this.getModel().getSelectedRecords();Ext.isDefined(c)||(c=[]);if(b.nonEmptySelectOnly)Ext.isDefined(c)&&Ext.isArray(c)&&c.length==0?b.setDisabled(true):b.setDisabled(false)}}].concat(a)},
onPrintSingle:function(){var a=container.getCurrentContext();if(a){a=a.getModel().getSelectedRecords();Ext.isEmpty(a)||Ext.isArray(a)&&a.length==0?Ext.MessageBox.alert(_("print"),_("No contact selected")):Zarafa.common.Actions.openPrintDialog(a)}},createNewDistributionListButton:function(){return{xtype:"menuitem",text:_("Distribution list"),handler:function(){Zarafa.contact.Actions.openDistlistDialog(null,this.getModel())},scope:this,iconCls:"icon_createDistributionList",newMenuIndex:3,context:"contact"}},
createMainTab:function(){return{text:_("Contact"),tabOrderIndex:4,context:"contact"}},onViewModeChange:function(a,b){var c=this.getModel();switch(b){case Zarafa.contact.data.ViewModes.SEARCH:case Zarafa.contact.data.ViewModes.NORMAL:c.clearGrouping();break;case Zarafa.contact.data.ViewModes.GROUP_CATEGORY:c.groupBy("categories");break;case Zarafa.contact.data.ViewModes.GROUP_COMPANY:c.groupBy("company_name");break;case Zarafa.contact.data.ViewModes.GROUP_LOCATION:c.groupBy("office_location");break}}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.contact.ContactContext)});Ext.namespace("Zarafa.calendar.ui.html");
Zarafa.calendar.ui.html.CalendarDaysView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarDaysView,{dayHeaders:undefined,dayTitles:undefined,dayStrips:undefined,workDayStrips:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",enableDD:true,ddGroup:"dd.mapiitem"});Zarafa.calendar.ui.html.CalendarDaysView.superclass.constructor.call(this,a)},init:function(){Zarafa.calendar.ui.html.CalendarDaysView.superclass.init.call(this);this.dayHeaders=[];this.dayTitles=[];this.dayStrips=
[];this.workDayStrips=[]},getClassNameForDayPosition:function(a,b){var c=[];b.today&&c.push("today");b.workingDay&&c.push("working");return Zarafa.calendar.ui.html.CalendarBoxView.superclass.getClassName.call(this,a,c)},createAppointment:function(a){return new Zarafa.calendar.ui.html.AppointmentDaysView({parentView:this,record:a})},layoutDayHeader:function(a){for(var b=0;b<this.dayHeaders.length;b++){var c=a[b].date,d=a[b].left,e=a[b].right;this.dayHeaders[b].dom.className=this.getClassNameForDayPosition("header-days",
a[b]);this.dayHeaders[b].setLeftTop(d,0);this.dayHeaders[b].setSize(e-d,this.header.getHeight());this.dayTitles[b].date=c;this.dayTitles[b].dom.className=this.getClassNameForDayPosition("header-days-title",a[b]);this.dayTitles[b].dom.innerHTML=this.getDayHeaderTitle(c,e-d);this.dayTitles[b].setLeftTop(d,0);this.dayTitles[b].setSize(e-d,this.parentView.headerTextHeight)}},layoutDayStrips:function(a){for(var b=this.parentView.getHourHeight()*this.parentView.numHours,c=0;c<this.dayHeaders.length;c++){var d=
a[c].left,e=a[c].right;this.dayStrips[c].dom.className=this.getClassNameForDayPosition("daystrip",a[c]);this.dayStrips[c].setLeftTop(d,0);this.dayStrips[c].setSize(e-d,b);this.dayStrips[c].removeClass("zarafa-calendar-daystrip-working");if(a[c].workingDay){this.workDayStrips[c].show();var f=this.parentView.firstWorkingHour/60*this.parentView.getHourHeight(),g=(this.parentView.lastWorkingHour-this.parentView.firstWorkingHour)/60*this.parentView.getHourHeight();this.workDayStrips[c].dom.className=this.getClassNameForDayPosition("daystrip",
a[c]);this.workDayStrips[c].setLeftTop(d,f);this.workDayStrips[c].setSize(e-d,g)}else this.workDayStrips[c].hide()}},onLayout:function(){Zarafa.calendar.ui.html.CalendarDaysView.superclass.onLayout.call(this);for(var a=this.calculateDayLayoutPositions();this.dayHeaders.length>a.length;){this.dayHeaders.pop().remove(true);var b=this.dayTitles.pop();this.mun(b,"click",this.onDayClick,this);b.remove(true);this.dayStrips.pop().remove(true);this.workDayStrips.pop().remove(true)}for(;this.dayHeaders.length<
a.length;){this.createDiv(this.header,"dayHeaders");b=this.createDiv(this.header,"dayTitles");this.mon(b,"click",this.onDayClick,this);this.createDiv(this.body,"dayStrips");this.createDiv(this.body,"workDayStrips")}this.layoutDayHeader(a);this.layoutDayStrips(a)},onDayClick:function(a,b){this.fireEvent("dayclick",this,Ext.get(b).date)}});Ext.namespace("Zarafa.calendar.ui.html");
Zarafa.calendar.ui.html.CalendarBoxView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarBoxView,{dayHeaders:undefined,tableContainer:undefined,table:undefined,tableHeaderCells:undefined,tableBodyCells:undefined,tableExpandDiv:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",enableDD:true,ddGroup:"dd.mapiitem",bodyDropConfig:{ddGroup:"dd.mapiitem",headerMode:false,snapMode:Zarafa.calendar.data.SnapModes.DAY}});Zarafa.calendar.ui.html.CalendarBoxView.superclass.constructor.call(this,
a)},init:function(){Zarafa.calendar.ui.html.CalendarBoxView.superclass.init.call(this);this.dayHeaders=[]},getClassNameForDayBox:function(a,b){var c=[];c.push(Zarafa.core.mapi.BusyStatus.getName(b.busyStatus).toLowerCase());b.today&&c.push("today");b.workingDay&&c.push("working");b.active&&c.push("active");return Zarafa.calendar.ui.html.CalendarBoxView.superclass.getClassName.call(this,a,c)},render:function(a){Zarafa.calendar.ui.html.CalendarBoxView.superclass.render.call(this,a);this.dayHeaders=
[];this.tableHeaderCells=[];this.tableBodyCells=[];for(this.tableExpandDiv=[];this.dayHeaders.length!=7;)this.createDiv(this.header,"dayHeaders");this.createDiv(this.body,"tableContainer");var b="";a=0;for(var c=this.getVisibleWeekCount();a<c;a++){for(var d="",e="",f=0;f<7;f++){d+="<td></td>";e+="<td><div></div></td>"}b+=String.format("<tr>{0}</tr>",d);b+=String.format("<tr>{0}</tr>",e)}this.tableContainer.dom.innerHTML=String.format("<table>{0}</table>",b);this.table=Ext.get(this.tableContainer.dom.children[0]);
b=this.table.dom.rows;a=0;for(c=b.length;a<c;a++){d=b[a].cells;f=0;for(e=d.length;f<e;f++){var g=Ext.get(d[f]);if((a&1)==0){this.tableHeaderCells.push(g);this.mon(g,"click",this.onDayClick,this)}else{this.tableBodyCells.push(g);g=Ext.get(g.dom.children[0]);this.tableExpandDiv.push(g);this.mon(g,"click",this.onDayClick,this)}}}},createAppointment:function(a){return new Zarafa.calendar.ui.html.AppointmentBoxView({parentView:this,record:a})},layoutDayHeaders:function(a){for(var b=this.getClassName("header-days"),
c=this.header.getHeight(),d=this.getVisibleDateRange().getStartDate(),e=0;e<this.dayHeaders.length;e++){var f=d.add(Date.DAY,e),g=a[e],h=g.right-g.left;this.dayHeaders[e].dom.className=b;this.dayHeaders[e].dom.innerHTML=this.getDayHeaderTitle(f,h);this.dayHeaders[e].setLeftTop(g.left,0);this.dayHeaders[e].setSize(h,c)}},layoutDays:function(a){var b=this.getVisibleWeekCount();this.table.dom.className=this.getClassName("table-days");this.table.dom.cellSpacing=1;for(var c=this.table.dom.cellPadding=
0;c<b;c++)for(var d=0;d<7;d++){var e=d+7*c,f=a[e],g=this.tableHeaderCells[e],h=this.tableBodyCells[e];e=this.tableExpandDiv[e];var i=f.right-f.left-2,j=this.dayHeaderHeight-2,k=f.bottom-f.top-1-this.dayHeaderHeight;g.date=f.date;g.dom.className=this.getClassNameForDayBox("day-header",f);g.dom.innerHTML=f.date.format(_("jS"));g.setSize(i,j);h.dom.className=this.getClassNameForDayBox("day",f);h.setSize(i,k);e.date=f.date;e.dom.className=this.getClassNameForDayBox("day-expandbutton",f);e.setPositioning({left:f.right-
e.getWidth()-e.getMargins("r")+"px",top:f.bottom-e.getHeight()-e.getMargins("b")+"px"});e.setVisible(f.overflow)}},onLayout:function(){this.doGreedyColoring(this.appointments,true);Zarafa.calendar.ui.html.CalendarBoxView.superclass.onLayout.call(this);var a=this.parentView.scrollable.getHeight();this.body.setHeight(a);this.tableContainer.setHeight(a);a=this.calculateDayBoxConfigurations(a);this.layoutDayHeaders(a);this.layoutDays(a)},onDayClick:function(a,b){this.fireEvent("dayclick",this,Ext.get(b).date)}});
Ext.namespace("Zarafa.calendar.ui.html");
Zarafa.calendar.ui.html.AppointmentView=Ext.extend(Zarafa.calendar.ui.AppointmentView,{backgroundImagesEnabled:true,quicktipEnabled:true,quicktipTemplate:new Ext.XTemplate("<b>{subject:htmlEncode}</b><br />",'<tpl if="values.alldayevent != true">',_("Time")+': {values.startdate:date("'+_("H:i")+'")} - {values.duedate:date("'+_("H:i")+'")}<br />',"</tpl>",'<tpl if="!Ext.isEmpty(values.location)">',_("Location")+": {location:htmlEncode}","</tpl>",{compiled:true}),bodyImg:undefined,bodyOutline:undefined,
constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"appointment"});Zarafa.calendar.ui.html.AppointmentView.superclass.constructor.call(this,a);if(this.quicktipEnabled)if(Ext.isString(this.quicktipTemplate))this.quicktipTemplate=new Ext.XTemplate(this.quicktipTemplate,{compiled:true})},init:function(){Zarafa.calendar.ui.html.AppointmentView.superclass.init.call(this);if(this.backgroundImagesEnabled)this.bodyImg=[];this.bodyOutline=[]},getClassName:function(a,b,c){var d=
[];if(Ext.isDefined(b))Ext.isArray(b)||(b=[b]);else b=[];if(c){b.push(this.getBusyStatusName());this.isActive()&&b.push("active");this.isSelected()&&b.push("selected");this.isAllDay()&&b.push("allday");c=Zarafa.core.mapi.AppointmentLabels.getName(this.record.get("label"));c=c.toLowerCase();c=c.replace("_","-");d.push("label-"+c)}return Zarafa.calendar.ui.html.AppointmentView.superclass.getClassName.call(this,a,b,d)},createBodyElement:function(){Zarafa.calendar.ui.html.AppointmentView.superclass.createBodyElement.call(this);
this.backgroundImagesEnabled&&this.createDiv(this.parentView.getCalendarBody(),"bodyImg");this.createDiv(this.parentView.getCalendarBody(),"bodyOutline")},destroyBodyElement:function(){Zarafa.calendar.ui.html.AppointmentView.superclass.destroyBodyElement.call(this);this.backgroundImagesEnabled&&this.remove(this.bodyImg.pop());this.remove(this.bodyOutline.pop())},layoutBodyImages:function(a){for(var b=this.getClassName("bodyimage",undefined,true),c=this.getStripWidth(),d=0;d<a.length;d++){this.bodyImg[d].dom.className=
b;this.bodyImg[d].setLeftTop(a[d].left+c,a[d].top);this.bodyImg[d].setSize(a[d].right-a[d].left-c,a[d].bottom-a[d].top)}},layoutOutline:function(a){for(var b=this.getClassName("body-outline",undefined,true),c=this.getStripWidth(),d=0;d<a.length;d++){this.bodyOutline[d].dom.className=b;this.bodyOutline[d].setLeftTop(a[d].left+c,a[d].top);this.bodyOutline[d].setSize(a[d].right-a[d].left-c,a[d].bottom-a[d].top)}},layoutQuickTip:function(a){var b=this.quicktipTemplate.apply(this.record.data);Ext.isArray(a)||
(a=[a]);for(var c=0,d=a.length;c<d;c++)Ext.QuickTips.register({target:a[c].dom.id,text:b})},elementIsInBody:function(a){var b=a.dom?a.dom.parentNode:a.parentNode;return this.body[this.body.indexOf(Ext.get(a))]||b&&this.elementIsInBody(b)},elementIsInHeader:function(a){var b=a.dom?a.dom.parentNode:a.parentNode;return Ext.get(a)==this.header||b&&this.elementIsInHeader(b)}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.CalendarDaysView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarDaysView,{headerBackgroundCanvas:undefined,headerAppointmentCanvas:undefined,headerSelectionCanvas:undefined,bodyBackgroundCanvas:undefined,bodyAppointmentCanvas:undefined,bodySelectionCanvas:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",colorScheme:Zarafa.calendar.ui.ColorSchemes[0],todayColorLow:"#f79a21",todayColorHigh:"#ffef7b",enableDD:true,ddGroup:"dd.mapiitem"});Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.constructor.call(this,
a)},render:function(a){Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.render.call(this,a);this.create("canvas",this.header,"headerBackgroundCanvas","zarafa-canvas zarafa-canvas-layer-1");this.create("canvas",this.header,"headerAppointmentCanvas","zarafa-canvas zarafa-canvas-layer-2");this.create("canvas",this.header,"headerSelectionCanvas","zarafa-canvas zarafa-canvas-layer-3");this.create("canvas",this.body,"bodyBackgroundCanvas","zarafa-canvas zarafa-canvas-layer-1");this.create("canvas",
this.body,"bodyAppointmentCanvas","zarafa-canvas zarafa-canvas-layer-2");this.create("canvas",this.body,"bodySelectionCanvas","zarafa-canvas zarafa-canvas-layer-3");this.mon(this.getHeaderActionCanvas(),"click",this.onHeaderClick,this);this.mon(this.getHeaderActionCanvas(),"mousemove",this.onHeaderMove,this);this.mon(this.getHeaderActionCanvas(),"dblclick",this.onHeaderDblClick,this);this.mon(this.getHeaderActionCanvas(),"contextmenu",this.onHeaderContextMenu,this);this.mon(this.getBodyActionCanvas(),
"click",this.onBodyClick,this);this.mon(this.getBodyActionCanvas(),"mousemove",this.onBodyMove,this);this.mon(this.getBodyActionCanvas(),"dblclick",this.onBodyDblClick,this);this.mon(this.getBodyActionCanvas(),"contextmenu",this.onBodyContextMenu,this)},createAppointment:function(a){return new Zarafa.calendar.ui.canvas.AppointmentDaysView({parentView:this,record:a,colorScheme:this.colorScheme})},getBodyActionCanvas:function(){return this.bodySelectionCanvas},getBodyAppointmentCanvas:function(){return this.bodyAppointmentCanvas},
getBodySelectionCanvas:function(){return this.bodySelectionCanvas},getHeaderActionCanvas:function(){return this.headerSelectionCanvas},getHeaderAppointmentCanvas:function(){return this.headerAppointmentCanvas},getHeaderSelectionCanvas:function(){return this.headerSelectionCanvas},drawHeader:function(a){var b,c=this.header.getWidth(),d=this.header.getHeight();Zarafa.resizeCanvas(this.headerBackgroundCanvas,c,d);Zarafa.resizeCanvas(this.headerAppointmentCanvas,c,d);Zarafa.resizeCanvas(this.headerSelectionCanvas,
c,d);var e=this.headerBackgroundCanvas.dom.getContext("2d");e.save();e.fillStyle=this.colorScheme.header;e.fillRect(0,0,c,d);e.strokeStyle=this.colorScheme.border;e.strokeRect(0.5,0.5,c-1,d-1);e.strokeStyle=this.colorScheme.border;c=1;for(var f=a.length;c<f;c++){var g=a[c];e.strokeLine(g.left+0.5,0,g.left+0.5,d)}c=0;for(f=a.length;c<f;c++){g=a[c];if(g.today)b=g}if(Ext.isDefined(b)){c=b.left;f=b.right;g=this.parentView.headerTextHeight;b=e.createLinearGradient(0,0,0,g);b.addColorStop(0,this.todayColorHigh);
b.addColorStop(1,this.todayColorLow);e.fillStyle=b;e.fillRect(c,0,f-c-1,g);e.strokeStyle=this.todayColorLow;e.strokeRect(c+0.5,0.5,f-c-1,d)}this.getDateRange().getStartDate().clearTime(true);e.fillStyle="black";c=0;for(f=a.length;c<f;c++){g=a[c];d=g.right-g.left;b=this.getDayHeaderTitle(g.date,d);var h=e.textWidth(b);e.setFont("bold 8pt Arial");e.drawText(b,g.left+(d-h)/2,12)}e.restore()},drawBody:function(a){var b,c=this.parentView.getHourHeight(),d=this.parentView.firstWorkingHour/60*c,e=this.parentView.lastWorkingHour/
60*c;c=this.body.getWidth();var f=this.body.getHeight();Zarafa.resizeCanvas(this.bodyBackgroundCanvas,c,f);Zarafa.resizeCanvas(this.bodyAppointmentCanvas,c,f);Zarafa.resizeCanvas(this.bodySelectionCanvas,c,f);var g=this.bodyBackgroundCanvas.dom.getContext("2d");g.save();g.fillStyle=this.colorScheme.stripnormal;g.fillRect(0,0,c,f);g.fillStyle=this.colorScheme.stripworking;for(var h=0,i=a.length;h<i;h++){var j=a[h];j.workingDay&&g.fillRect(j.left,e,j.right-j.left,d-e)}d=this.parentView.timeUnitHeight;
e=Math.floor(60/this.getZoomLevel());i=Math.round(f/d);for(h=0;h<i;h++){g.strokeStyle=(h+1)%e==0?this.colorScheme.hourline:this.colorScheme.linenormal;j=(h+1)*d-1;g.strokeLine(0,j+0.5,c,j+0.5)}g.strokeStyle=this.colorScheme.border;h=0;for(i=a.length;h<i;h++){j=a[h];g.strokeLine(j.left+0.5,0,j.left+0.5,f);if(j.today)b=j}g.strokeLine(c-0.5,0,c-0.5,f);if(Ext.isDefined(b)){g.strokeStyle=this.todayColorLow;g.strokeLine(b.left+0.5,0,b.left+0.5,f);g.strokeLine(b.right-0.5,0,b.right-0.5,f)}g.restore()},eventInHeader:function(a){var b=
this.getHeaderActionCanvas(),c=a.getPageX()-b.getX();a=a.getPageY()-b.getY();if(a>this.parentView.headerTextHeight)return false;return!Ext.isEmpty(this.screenLocationToDate(c,a))},onBodyMove:function(a){for(var b="default",c=0,d=this.appointments.length;c<d;c++){var e=this.appointments[c];if(e.eventOverBody(a)){b=e.eventOverBodyStartHandle(a)?"n-resize":e.eventOverBodyDueHandle(a)?"s-resize":"move";break}}this.getBodyActionCanvas().dom.style.cursor=b},onHeaderMove:function(a){var b="default";if(this.eventInHeader(a))b=
"pointer";else for(var c=0,d=this.appointments.length;c<d;c++){var e=this.appointments[c];if(e.eventOverHeader(a)){b=e.eventOverHeaderStartHandle(a)?"w-resize":e.eventOverHeaderDueHandle(a)?"e-resize":"move";break}}this.getHeaderActionCanvas().dom.style.cursor=b},onHeaderClick:function(a){var b=a.getXY();b=this.screenLocationToDate(b[0],b[1]);if(this.eventInHeader(a))this.fireEvent("dayclick",this,b);else this.header.contains(a.target)&&this.updateSelectionOnHeaderEvent(a,false)},updateSelectionOnHeaderEvent:function(a,
b){for(var c=undefined,d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverHeader(a)){c=f.getRecord();break}}if(!c){d=a.getXY();d=this.screenLocationToDate(d[0],d[1]);d=new Zarafa.core.DateRange({startDate:d,dueDate:d.add(Date.DAY,1)});this.rangeSelectionModel.set(d,this);if(b!==false)c=this.parentView.model.createRecord(this.selectedFolder,d)}return c},onHeaderDblClick:function(a){var b=this.updateSelectionOnHeaderEvent(a);this.fireEvent("dblclick",a,b)},onHeaderContextMenu:function(a){var b=
this.updateSelectionOnHeaderEvent(a);this.fireEvent("contextmenu",a,b)},updateSelectionOnBodyEvent:function(a,b){for(var c=undefined,d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverBody(a)){c=f.getRecord();break}}if(!c){d=a.getXY();e=this.screenLocationToDate(d[0],d[1]);d=this.getZoomLevel()*60*1E3;e=e.getTime()-e.getTime()%d;d=new Zarafa.core.DateRange({startDate:new Date(e),dueDate:new Date(e+d)});this.rangeSelectionModel.set(d,this);if(b!==false)c=this.parentView.model.createRecord(this.selectedFolder,
d)}return c},onBodyClick:function(a){var b=a.getXY();this.screenLocationToDate(b[0],b[1]);this.body.contains(a.target)&&this.updateSelectionOnBodyEvent(a,false)},onBodyDblClick:function(a){var b=this.updateSelectionOnBodyEvent(a);this.fireEvent("dblclick",a,b)},onBodyContextMenu:function(a){var b=this.updateSelectionOnBodyEvent(a);this.fireEvent("contextmenu",a,b)},onAppointmentDeselect:function(a,b){var c=this.findAppointment(b);Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.onAppointmentDeselect.call(this,
a,b);if(c){var d=(c=c.isHeaderRange())?this.headerSelectionCanvas:this.bodySelectionCanvas;Zarafa.resizeCanvas(d,d.getWidth(),d.getHeight());if(a.hasSelection()){d=0;for(var e=this.appointments.length;d<e;d++){var f=this.appointments[d];c==f.isHeaderRange()&&f.setSelected(f.isSelected())}}}},onAppointmentSelectionClear:function(a){Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.onAppointmentSelectionClear.call(this,a);Zarafa.resizeCanvas(this.bodySelectionCanvas,this.bodySelectionCanvas.getWidth(),
this.bodySelectionCanvas.getHeight());Zarafa.resizeCanvas(this.headerSelectionCanvas,this.headerSelectionCanvas.getWidth(),this.headerSelectionCanvas.getHeight())},onLayout:function(){Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.onLayout.call(this);var a=this.calculateDayLayoutPositions();this.drawHeader(a);this.drawBody(a)}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.CalendarBoxView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarBoxView,{expandButtonRadius:8,expandButtonMargin:2,headerBackgroundCanvas:undefined,bodyBackgroundCanvas:undefined,bodyAppointmentCanvas:undefined,bodySelectionCanvas:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",colorScheme:Zarafa.calendar.ui.ColorSchemes[0],todayColorLow:"#f79a21",todayColorHigh:"#ffef7b",enableDD:true,ddGroup:"dd.mapiitem",bodyDropConfig:{ddGroup:"dd.mapiitem",
headerMode:false,snapMode:Zarafa.calendar.data.SnapModes.DAY}});Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.constructor.call(this,a)},render:function(a){Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.render.call(this,a);this.create("canvas",this.header,"headerBackgroundCanvas","zarafa-canvas zarafa-canvas-layer-1");this.create("canvas",this.body,"bodyBackgroundCanvas","zarafa-canvas zarafa-canvas-layer-1");this.create("canvas",this.body,"bodyAppointmentCanvas","zarafa-canvas zarafa-canvas-layer-2");
this.create("canvas",this.body,"bodySelectionCanvas","zarafa-canvas zarafa-canvas-layer-3");this.mon(this.getBodyActionCanvas(),"mousemove",this.onBodyMove,this);this.mon(this.getBodyActionCanvas(),"click",this.onBodyClick,this);this.mon(this.getBodyActionCanvas(),"dblclick",this.onBodyDblClick,this);this.mon(this.getBodyActionCanvas(),"contextmenu",this.onBodyContextMenu,this)},createAppointment:function(a){return new Zarafa.calendar.ui.canvas.AppointmentBoxView({parentView:this,record:a,colorScheme:this.colorScheme})},
getBodyActionCanvas:function(){return this.bodySelectionCanvas},getBodyAppointmentCanvas:function(){return this.bodyAppointmentCanvas},getBodySelectionCanvas:function(){return this.bodySelectionCanvas},getHeaderActionCanvas:function(){return this.headerSelectionCanvas},drawDayHeaders:function(){var a=this.header.getWidth(),b=this.header.getHeight();Zarafa.resizeCanvas(this.headerBackgroundCanvas,a,b);var c=this.headerBackgroundCanvas.dom.getContext("2d");c.save();c.fillStyle=this.colorScheme.header;
c.fillRect(0,0,a,b);c.strokeStyle=this.colorScheme.border;c.lineWidth=1;c.fillStyle="black";c.setFont("bold 8pt Arial");a=a/this.numDaysInWeek;for(var d=this.getVisibleDateRange().getStartDate(),e=c.lineWidth,f=0;f<this.numDaysInWeek;f++){var g=d.add(Date.DAY,f),h=Math.round(a*f),i=Math.round(a*(f+1))+e-h;g=this.getDayHeaderTitle(g,i);var j=h+(i-c.textWidth(g))/2;c.strokeRect(h+e/2,e/2,i-e,b);c.drawText(g,j,b-4)}c.restore()},drawExpandButton:function(a,b){var c=b.right-b.left-this.expandButtonRadius-
this.expandButtonMargin,d=b.bottom-b.top-this.expandButtonRadius-this.expandButtonMargin;a.circle(c,d,this.expandButtonRadius);a.fillStyle="white";a.fill();a.strokeStyle="black";a.stroke();a.beginPath();for(var e=this.expandButtonRadius-3,f=0;f<4;f++){var g=Math.sin(f*2/3*Math.PI)*e+c,h=Math.cos(f*2/3*Math.PI)*e+d;f==0?a.moveTo(g,h):a.lineTo(g,h)}a.closePath();a.fillStyle="black";a.fill()},drawDayBox:function(a,b){var c=b.right-b.left,d=b.bottom-b.top;a.save();a.translate(b.left,b.top);if(b.today){var e=
a.createLinearGradient(0,0,0,this.dayHeaderHeight);e.addColorStop(0,this.todayColorHigh);e.addColorStop(1,this.todayColorLow);a.fillStyle=e}else a.fillStyle=this.colorScheme.borderInner;a.fillRect(0,0,c,this.dayHeaderHeight);a.fillStyle="black";a.setFont("bold 10pt Arial");a.drawText(b.date.format(_("jS")),2,this.dayHeaderHeight-5);if(b.active)switch(b.busyStatus){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle=this.colorScheme.stripworking;break;case Zarafa.core.mapi.BusyStatus.BUSY:a.fillStyle=
"#d7e2f1";break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=this.colorScheme.stripnormal;break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle="#e7d7ef";break;default:break}else a.fillStyle=this.colorScheme.border;a.fillRect(0,this.dayHeaderHeight,c,d-this.dayHeaderHeight+1);if(b.busyStatus==Zarafa.core.mapi.BusyStatus.TENTATIVE){a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");a.fillRect(0,this.dayHeaderHeight,c,d-this.dayHeaderHeight+1)}e=a.lineWidth;
a.strokeStyle=this.colorScheme.border;a.strokeRect(e/2,e/2,c-e,d-e);b.overflow&&this.drawExpandButton(a,b);a.restore()},drawDays:function(){var a,b=this.body.getWidth(),c=this.body.getHeight();Zarafa.resizeCanvas(this.bodyBackgroundCanvas,b,c);Zarafa.resizeCanvas(this.bodyAppointmentCanvas,b,c);Zarafa.resizeCanvas(this.bodySelectionCanvas,b,c);b=this.bodyBackgroundCanvas.dom.getContext("2d");b.save();c=0;for(var d=this.dayBoxConfigurations.length;c<d;c++){var e=this.dayBoxConfigurations[c];this.drawDayBox(b,
e);if(e.today)a=e}if(Ext.isDefined(a)){c=a.right-a.left;d=a.bottom-a.top;e=b.lineWidth;b.strokeStyle=this.todayColorLow;b.strokeRect(a.left+e/2,a.top+e/2,c-e,d-e)}b.restore()},eventInHeader:function(a){var b=this.getBodyActionCanvas(),c=a.getPageX()-b.getX();a=a.getPageY()-b.getY();b=0;for(var d=this.dayBoxConfigurations.length;b<d;b++){var e=this.dayBoxConfigurations[b];if(c>=e.left&&c<=e.right&&a>=e.top&&a<=e.top+this.dayHeaderHeight)return true}return false},eventInDay:function(a){var b=this.getBodyActionCanvas(),
c=a.getPageX()-b.getX();a=a.getPageY()-b.getY();b=0;for(var d=this.dayBoxConfigurations.length;b<d;b++){var e=this.dayBoxConfigurations[b];if(c>=e.left&&c<=e.right&&a>=e.top&&a<=e.bottom)return true}return false},eventInExpandButton:function(a){var b=this.getBodyActionCanvas(),c=a.getPageX()-b.getX();a=a.getPageY()-b.getY();for(var d=0,e=this.dayBoxConfigurations.length;d<e;d++){b=this.dayBoxConfigurations[d];if(c>=b.left&&c<=b.right&&a>=b.top&&a<=b.bottom){if(!b.overflow)return false;c=b.right-this.expandButtonRadius-
this.expandButtonMargin-c;a=b.bottom-this.expandButtonRadius-this.expandButtonMargin-a;return Math.sqrt(c*c+a*a)<=this.expandButtonRadius}}return false},onBodyMove:function(a){var b="default";if(this.eventInHeader(a)||this.eventInExpandButton(a))b="pointer";else for(var c=0,d=this.appointments.length;c<d;c++){var e=this.appointments[c];if(e.eventOverBody(a)){b=e.eventOverBodyStartHandle(a)?"w-resize":e.eventOverBodyDueHandle(a)?"e-resize":"move";break}}this.getBodyActionCanvas().dom.style.cursor=
b},onBodyClick:function(a){if(this.eventInHeader(a)||this.eventInExpandButton(a)){a=a.getXY();this.fireEvent("dayclick",this,this.screenLocationToDate(a[0],a[1]))}},updateSelectionOnEvent:function(a,b){var c=undefined;if(this.eventInDay(a))for(var d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverBody(a)){c=f.getRecord();break}}if(!c){d=a.getXY();d=this.screenLocationToDate(d[0],d[1]);d=new Zarafa.core.DateRange({startDate:d,dueDate:d.add(Date.DAY,1)});this.rangeSelectionModel.set(d,
this);if(b!==false)c=this.parentView.model.createRecord(this.selectedFolder,d)}return c},onBodyDblClick:function(a){var b=this.updateSelectionOnEvent(a);this.fireEvent("dblclick",a,b)},onBodyContextMenu:function(a){var b=this.updateSelectionOnEvent(a);this.fireEvent("contextmenu",a,b)},onAppointmentDeselect:function(a,b){Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.onAppointmentDeselect.call(this,a,b);Zarafa.resizeCanvas(this.bodySelectionCanvas,this.bodySelectionCanvas.getWidth(),this.bodySelectionCanvas.getHeight());
if(a.hasSelection())for(var c=0,d=this.appointments.length;c<d;c++){var e=this.appointments[c];e.setSelected(e.isSelected())}},onAppointmentSelectionClear:function(a){Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.onAppointmentSelectionClear.call(this,a);Zarafa.resizeCanvas(this.bodySelectionCanvas,this.bodySelectionCanvas.getWidth(),this.bodySelectionCanvas.getHeight())},onLayout:function(){this.doGreedyColoring(this.appointments,true);Zarafa.calendar.ui.html.CalendarBoxView.superclass.onLayout.call(this);
this.body.setHeight(this.parentView.scrollable.getHeight());this.calculateDayBoxConfigurations();this.drawDayHeaders();this.drawDays()}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentView=Ext.extend(Zarafa.calendar.ui.AppointmentView,{dragHandleWidth:6,dragHandleHeight:6,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"appointment",colorScheme:Zarafa.calendar.ui.ColorSchemes[0]});Zarafa.calendar.ui.canvas.AppointmentView.superclass.constructor.call(this,a)},getEventHeaderPosition:function(a){var b=this.parentView.getCalendarHeader();return{x:a.getPageX()-b.getX(),y:a.getPageY()-b.getY()}},getEventBodyPosition:function(a){var b=
this.parentView.getCalendarBody();return{x:a.getPageX()-b.getX(),y:a.getPageY()-b.getY()}},isEventOverElement:function(a,b){return a.x>=b.left&&a.x<=b.right&&a.y>=b.top&&a.y<=b.bottom},drawDragHandle:function(a,b,c){a.save();a.strokeStyle="black";a.fillStyle="white";a.lineWidth=1;a.fillRect(b-2,c-2,4,4);a.strokeRect(b-2,c-2,4,4);a.restore()}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarViewDropZone=Ext.extend(Ext.dd.DropZone,{dropAllowedAdd:"x-dd-drop-ok-add",headerMode:false,snapMode:Zarafa.calendar.data.SnapModes.ZOOMLEVEL,proxy:undefined,state:Zarafa.calendar.data.DragStates.NONE,dateRange:undefined,initDate:undefined,initDateRange:undefined,constructor:function(a,b){b=b||{};this.calendar=a;var c=this.calendar.body;if(b.headerMode===true)c=this.calendar.header;Ext.applyIf(b,{ddGroup:"AppointmentDD"});Zarafa.calendar.ui.CalendarViewDropZone.superclass.constructor.call(this,
c,b)},getTargetFromEvent:function(a){var b=this.el;if(this.headerMode!==true){var c=this.el.parent();if(a.getPageY()<c.getTop()||c.getBottom()<a.getPageY())b=undefined}return b},onNodeEnter:function(a,b,c,d){a=d.selections[0];var e=Zarafa.calendar.data.DragStates;this.state=d.state;if(this.state===e.RESIZING_START||this.state===e.RESIZING_DUE||this.state===e.SELECTING)if(this.calendar!==b.calendar)this.state=e.DRAGGING;if(a){this.initDate=d.state===e.RESIZING_START||d.state===e.DRAGGING?a.get("startdate"):
a.get("duedate");this.initDateRange=new Zarafa.core.DateRange({startDate:a.get("startdate"),dueDate:a.get("duedate")})}else{e=this.calendar.getZoomLevel();this.initDate=this.calendar.screenLocationToDate(c.getPageX(),c.getPageY());if(this.snapMode===Zarafa.calendar.data.SnapModes.DAY){a=this.initDate.clearTime(true);e=a.add(Date.DAY,1)}else{a=this.initDate.clone().floor(Date.MINUTE,e);e=a.add(Date.MINUTE,e)}this.initDateRange=new Zarafa.core.DateRange({startDate:a,dueDate:e})}this.dateRange=this.initDateRange.clone();
this.onDragKeyDown=Zarafa.calendar.ui.CalendarViewDropZone.prototype.onDragKeyDown.createDelegate({dd:b,dz:this});this.onDragKeyUp=Zarafa.calendar.ui.CalendarViewDropZone.prototype.onDragKeyUp.createDelegate({dd:b,dz:this});document.addEventListener("keydown",this.onDragKeyDown);document.addEventListener("keyup",this.onDragKeyUp);this.proxy.setShowTime(this.snapMode===Zarafa.calendar.data.SnapModes.ZOOMLEVEL);this.proxy.setDateRange(this.dateRange);this.updateProxy(c.getXY(),d.selections);if(b.calendar===
this.calendar){b.proxy.hide();this.proxy.setVisible(true)}},onNodeOver:function(a,b,c,d){this.updateProxy(c.getXY(),d.selections);return c.ctrlKey?this.dropAllowedAdd:this.dropAllowed},onNodeOut:function(a,b){document.removeEventListener("keydown",this.onDragKeyDown);document.removeEventListener("keyup",this.onDragKeyUp);delete this.initDate;delete this.initDateRange;this.proxy.setVisible(false);b.proxy.show()},onDragKeyDown:function(a){if(a.ctrlKey||a.keyCode===Ext.EventObject.CONTROL)this.dd.proxy.dropStatus===
this.dz.dropAllowed&&this.dd.proxy.setStatus(this.dz.dropAllowedAdd)},onDragKeyUp:function(a){if(a.ctrlKey||a.keyCode===Ext.EventObject.CONTROL)this.dd.proxy.dropStatus===this.dz.dropAllowedAdd&&this.dd.proxy.setStatus(this.dz.dropAllowed)},onNodeDrop:function(a,b,c,d){a=Zarafa.calendar.data.DragStates;switch(d.state){case a.SELECTING:this.calendar.onSelect(c,this.dateRange);break;case a.DRAGGING:b.calendar!==this.calendar?this.calendar.onDrop(c,b.calendar,d.target,this.dateRange):this.calendar.onMove(c,
d.target,this.dateRange);break;case a.RESIZING_START:case a.RESIZING_DUE:this.calendar.onResize(c,d.target,this.dateRange);break}},updateProxy:function(a,b){var c=!Ext.isEmpty(b)?b[0]:undefined,d=this.calendar.screenLocationToDate(a[0],a[1]),e=this.calendar.getZoomLevel(),f=Zarafa.calendar.data.DragStates,g=this.state===f.SELECTING||this.state===f.DRAGGING||this.state===f.RESIZING_START,h=this.state===f.SELECTING||this.state===f.DRAGGING||this.state===f.RESIZING_DUE,i=this.dateRange.getStartDate(),
j=this.dateRange.getDueDate();if(this.snapMode===Zarafa.calendar.data.SnapModes.DAY)if(g){i=d.clearTime();if(h)j=c?c.get("alldayevent")?i.add(Date.MINUTE,c.get("duration")):i.add(Date.DAY,1):i.add(Date.DAY,1)}else{j=d.add(Date.DAY,1);if(j===i)j=j.add(Date.DAY,1)}else if(g){i=d.floor(Date.MINUTE,e);if(h)j=c?c.get("alldayevent")?i.add(Date.MINUTE,e):i.add(Date.MINUTE,c.get("duration")):i.add(Date.MINUTE,e)}else{j=d.ceil(Date.MINUTE,e);if(j===i)j=j.add(Date.MINUTE,e)}switch(this.state){case f.SELECTING:if(i>
this.initDate){this.dateRange.set(this.initDateRange.getStartDate(),j);this.state=f.RESIZING_DUE}else if(j<this.initDate||this.snapMode===Zarafa.calendar.data.SnapModes.DAY){this.state=f.RESIZING_START;this.dateRange.set(i,this.initDateRange.getDueDate())}break;case f.DRAGGING:this.dateRange.set(i,j);break;case f.RESIZING_START:if(i>=j){this.state=f.RESIZING_DUE;this.dateRange.set(this.initDateRange.getStartDate(),i)}else this.dateRange.setStartDate(i);break;case f.RESIZING_DUE:if(i>=j){this.state=
f.RESIZING_START;this.dateRange.set(j,this.initDateRange.getDueDate())}else this.dateRange.setDueDate(j);break}}});Ext.namespace("Zarafa.calendar.printer");
Zarafa.calendar.printer.WorkWeekViewRenderer=Ext.extend(Zarafa.calendar.printer.DaysViewRenderer,{constructor:function(a){a=a||{};Ext.applyIf(a,{timeStyle:"width:10%;"});Zarafa.calendar.printer.WorkWeekViewRenderer.superclass.constructor.call(this,a)},generateBodyTemplate:function(){var a="";a+='<table class="print-calendar" cellpadding=0 cellspacing=0>\n';a+='<tr style="height:10%;"><td><table id="top">\n';a+='<tr><td align="left" width="60%">{startdate:date("'+_("l jS F Y")+'")} -</td><td align="center" valign="top" width="20%" rowspan=2><div id=datepicker_left></div></td><td align="center" valign="top" width="20%" rowspan=2><div id=datepicker_right></div></td></tr>';
a+='<tr><td align=left>{duedate:date("'+_("l jS F Y")+'")}</tr>';a+="</table></td></tr>\n";a+='<tr style="height:30px;">  <th class="date-header-center">{date1:date("'+_("l jS F")+'")}</th></tr><tr style="height:10%;">  <td valign="top"><table id="date1">{date1_table_data}</table></td></tr><tr style="height:30px;">  <th class="date-header-center">{date2:date("'+_("l jS F")+'")}</th></tr><tr style="height:10%;">  <td valign="top"><table id="date2">{date2_table_data}</table></td></tr><tr style="height:30px;">  <th class="date-header-center">{date3:date("'+
_("l jS F")+'")}</th></tr><tr style="height:10%;">  <td valign="top"><table id="date3">{date3_table_data}</table></td></tr><tr style="height:30px;">  <th class="date-header-center">{date4:date("'+_("l jS F")+'")}</th></tr><tr style="height:10%;">  <td valign="top"><table id="date4">{date4_table_data}</table></td></tr><tr style="height:30px;">  <th class="date-header-center">{date5:date("'+_("l jS F")+'")}</th></tr><tr style="height:10%;">  <td valign="top"><table id="date5">{date5_table_data}</table></td></tr>';
a+="</table>";a+='<table id="bottom"><tr><td class="nowrap" align=left>{fullname:htmlEncode}</td><td class="nowrap" align=right>{currenttime:date("'+_("l jS F Y G:i")+'")}</td></tr></table>\n';return a}});Ext.namespace("Zarafa.calendar.printer");
Zarafa.calendar.printer.WeekViewRenderer=Ext.extend(Zarafa.calendar.printer.DaysViewRenderer,{constructor:function(a){a=a||{};Ext.applyIf(a,{timeStyle:"width:33%;"});Zarafa.calendar.printer.WeekViewRenderer.superclass.constructor.call(this,a)},generateBodyTemplate:function(){var a="";a+='<table class="print-calendar" cellpadding=0 cellspacing=0>\n';a+='<tr style="height:10%;"><td colspan=2><table id="top">\n';a+='<tr><td align="left" width="60%">{startdate:date("'+_("l d/m/Y")+'")} -</td><td align="center" valign="top" width="20%" rowspan=2><div id=datepicker_left></div></td><td align="center" valign="top" width="20%" rowspan=2><div id=datepicker_right></div></td></tr>';
a+='<tr><td align=left>{duedate:date("'+_("l jS F Y")+'")}</tr>';a+="</table></td></tr>\n";a+='<tr style="height:40px;">  <th class="date-header">{date1:date("'+_("l jS F")+'")}</th>  <th class="date-header">{date4:date("'+_("l jS F")+'")}</th></tr><tr style="height:25%;">  <td valign="top"><table id="date1">{date1_table_data}</table></td>  <td valign="top"><table id="date4">{date4_table_data}</table></td></tr><tr style="height:40px;">  <th class="date-header">{date2:date("'+_("l jS F")+'")}</th>  <th class="date-header">{date5:date("'+
_("l jS F")+'")}</th></tr><tr style="height:25%;">  <td valign="top"><table id="date2">{date2_table_data}</table></td>  <td valign="top"><table id="date5">{date5_table_data}</table></td></tr><tr style="height:40px;">  <th class="date-header">{date3:date("'+_("l jS F")+'")}</th>  <th class="date-header">{date6:date("'+_("l jS F")+'")}</th></tr><tr>  <td valign="top" rowspan=3><table id="date4">{date3_table_data}</table></td>  <td valign="top" style="height:15%;"><table id="date6">{date6_table_data}</table></td></tr>  <tr style="height:40px;">  <th class="date-header">{date7:date("'+
_("l jS F")+'")}</th></tr><tr>  <td valign="top"><table id="date7">{date7_table_data}</table></td></tr>';a+="</table>";a+='<table id="bottom"><tr><td class="nowrap" align=left>{fullname:htmlEncode}</td><td class="nowrap" align=right>{currenttime:date("'+_("l jS F Y G:i")+'")}</td></tr></table>\n';return a}});Ext.namespace("Zarafa.calendar.printer");
Zarafa.calendar.printer.MeetingRenderer=Ext.extend(Zarafa.common.printer.renderers.RecordRenderer,{generateBodyTemplate:function(a){var b="";b+="<b>{fullname:htmlEncode}</b>\n";b+="<hr>\n";b+="<table>\n";b+=this.addRow(_("Subject"),"{subject:htmlEncode}");b+=this.optionalRow(_("Location"),"location","{location:htmlEncode}");b+=this.addRow("","");b+=this.addRow(_("Start"),'{startdate:date("'+_("l jS F Y G:i")+'")}');b+=this.addRow(_("End"),'{enddate:date("'+_("l jS F Y G:i")+'")}');b+=this.addRow("",
"");b+=this.optionalRow(_("Recurrence pattern"),"recurring_pattern","{recurring_pattern:htmlEncode}");b+=this.optionalRow("","recurring_pattern","");b+=this.optionalRow(_("Organiser"),"sender_name","{sender_name:htmlEncode}");b+=this.optionalRow(_("Meeting status"),"responsestatus","{responsestatus:responseStatusString}");b+='<tpl if="!Ext.isEmpty(values.sender_name) || !Ext.isEmpty(values.responsestatus)">';b+=this.addRow("","");b+="</tpl>";b+=this.optionalRow(_("Required Attendees"),"display_to",
"{display_to:htmlEncode}");b+=this.optionalRow(_("Optional Attendees"),"display_cc","{display_cc:htmlEncode}");b+=this.optionalRow(_("Resources"),"display_bcc","{display_bcc:htmlEncode}");b+=this.addRow("","");b+=this.optionalRow(_("Sensitivity"),"sensitivity","{sensitivity:sensitivityString}");b+=this.optionalRow(_("Importance"),"importance","{importance:importanceString}");b+='<tpl if="!Ext.isEmpty(values.sensitivity) || !Ext.isEmpty(values.importance)">';b+=this.addRow("","");b+="</tpl>";b+=this.optionalRow(_("Attachments"),
"attachment_names","{attachment_names:htmlEncode}");b+="</table><br><p>\n";b+=a.getBody(true);b+="</p>\n";return b},prepareData:function(a){var b=Zarafa.calendar.printer.MeetingRenderer.superclass.prepareData(a);if(a.isMessageClass("IPM.Schedule",true)){b.startdate=b.appointment_startdate;b.enddate=b.appointment_duedate;b.location=b.appointment_location;b.recurring_pattern=b.appointment_recurring_pattern}else{b.startdate=b.commonstart;b.enddate=b.commonend}return b}});Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.ProposeNewTimePanel=Ext.extend(Ext.Panel,{record:undefined,responseType:Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"zarafa.proposenewtimepanel",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"padding: 5px; background-color: inherit;",defaults:{border:false,bodyStyle:"padding-bottom: 5px; background-color: inherit;"},
items:this.createProposeTimePanel(a.record)});Zarafa.calendar.dialogs.ProposeNewTimePanel.superclass.constructor.call(this,a)},createProposeTimePanel:function(){return[{xtype:"zarafa.datetimeperiodfield",ref:"datetimePeriod",defaultPeriod:30,width:300,startFieldConfig:{name:"startdate",fieldLabel:_("Start time"),labelWidth:100,listeners:{change:this.onFieldChange,scope:this}},endFieldConfig:{name:"duedate",fieldLabel:_("End time"),labelWidth:100,listeners:{change:this.onFieldChange,scope:this}}},
{layout:{type:"hbox",pack:"start",align:"stretch"},items:[{xtype:"label",text:_("Comment")+": ",width:105},{xtype:"textarea",ref:"../comment",flex:1}],flex:1}]},update:function(a){var b;if(a.isMessageClass("IPM.Schedule.Meeting.Request",true)){b=a.get("appointment_startdate");a=a.get("appointment_duedate")}else{b=a.get("startdate");a=a.get("duedate")}b&&a&&this.datetimePeriod.getValue().set(b,a)},updateRecord:function(a){a.proposeNewTimeToMeetingRequest(this.responseType,this.comment.getValue(),this.datetimePeriod.getValue().startDate,
this.datetimePeriod.getValue().dueDate)}});Ext.reg("zarafa.proposenewtimepanel",Zarafa.calendar.dialogs.ProposeNewTimePanel);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.AppointmentDialog=Ext.extend(Zarafa.core.ui.MessageDialog,{startDate:undefined,dueDate:undefined,duration:undefined,activeTab:undefined,constructor:function(a){a=a||{};if(Ext.isDefined(a.activeTab))this.activeTab=a.activeTab;Ext.applyIf(a,{xtype:"zarafa.appointmentdialog",layout:"fit",defaultTitle:_("Appointment"),alwaysUseDefaultTitle:true,allowWrite:true,confirmClose:true,items:[{xtype:"zarafa.appointmentpanel",activeTab:this.activeTab,tbar:{xtype:"zarafa.appointmenttoolbar"}}]});
Zarafa.calendar.dialogs.AppointmentDialog.superclass.constructor.call(this,a)},setDialogTitle:function(a){!Ext.isDefined(a)||a.get("meeting")===Zarafa.core.mapi.MeetingStatus.NONMEETING?this.setTitle(_("Appointment")):this.setTitle(_("Meeting request"))},update:function(a,b){Zarafa.calendar.dialogs.AppointmentDialog.superclass.update.apply(this,arguments);this.setDialogTitle(a);if(a.isOpened()){if(b||a.isModifiedSinceLastUpdate("meeting")){a.updateMeetingRecipients();switch(a.get("meeting")){case Zarafa.core.mapi.MeetingStatus.MEETING:if(!Ext.isDefined(this.initialConfig.closeOnSave))this.closeOnSave=
false;if(!Ext.isDefined(this.initialConfig.closeOnSend))this.closeOnSend=true;break;case Zarafa.core.mapi.MeetingStatus.NONMEETING:default:if(!Ext.isDefined(this.initialConfig.closeOnSave))this.closeOnSave=true;if(!Ext.isDefined(this.initialConfig.closeOnSend))this.closeOnSend=false;break}}a.isSubStoreModifiedSincelastUpdate("recipients")&&this.updateLocation();if(this.startDate&&this.dueDate&&this.duration){a.beginEdit();a.set("startdate",this.startDate);a.set("duedate",this.dueDate);a.set("commonstart",
this.startDate);a.set("commonend",this.dueDate);a.set("duration",this.duration);this.duration=this.dueDate=this.startDate=undefined;a.endEdit()}var c=a.getSubStore("recipients");c&&a.isMeetingOrganized()&&this.mon(c,"resolved",this.setRecipientTypeOnResolve,this)}},updateLocation:function(){var a="";this.record.getSubStore("recipients").each(function(c){if(c.get("display_type_ex")===Zarafa.core.mapi.DisplayTypeEx.DT_ROOM&&c.get("recipient_type")===Zarafa.core.mapi.RecipientType.MAPI_BCC){c=c.get("display_name");
if(!Ext.isEmpty(c)){Ext.isEmpty(a)||(a+="; ");a+=c}}});var b=this.record.get("location");if(b!=a)Ext.isEmpty(b)||a.indexOf(b)>=0?this.record.set("location",a):Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:String.format(_('Do you want to update the location "{0}" with the new location "{1}"?'),Ext.util.Format.htmlEncode(b),Ext.util.Format.htmlEncode(a)),buttons:Ext.Msg.YESNO,icon:Ext.MessageBox.WARNING,fn:this.setLocation,locationSuggestion:a,scope:this})},setLocation:function(a,b,c){a=="yes"&&
this.record.set("location",c.locationSuggestion)},setRecipientTypeOnResolve:function(a,b){for(var c=0;c<b.length;c++){var d=b[c];switch(d.get("display_type_ex")){case Zarafa.core.mapi.DisplayTypeEx.DT_EQUIPMENT:case Zarafa.core.mapi.DisplayTypeEx.DT_ROOM:d.set("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_BCC);break}}},onUpdateRecord:function(a,b,c){c.isMeetingOrganized()&&this.isSending===true&&b==Ext.data.Record.COMMIT&&c.getRecipientStore().findExact("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_BCC)!==
-1&&c.getActionResponse("resources_booked")&&container.getNotifier().notify("info.meeting",_("Zarafa WebApp"),pgettext("calendar.dialog","Resources have been planned."));Zarafa.calendar.dialogs.AppointmentDialog.superclass.onUpdateRecord.apply(this,arguments)},saveRecord:function(){var a=this.record;a.isMeetingSent()&&!a.isAppointmentInPast()&&a.getMessageAction("send")!==true?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("An update message will be sent to all recipients, do you wish to continue?"),
icon:Ext.MessageBox.WARNING,fn:this.sendMeetingUpdate,scope:this,buttons:Ext.MessageBox.YESNO}):Zarafa.calendar.dialogs.AppointmentDialog.superclass.saveRecord.apply(this,arguments)},sendMeetingUpdate:function(a){a=="yes"&&this.sendRecord()},sendRecord:function(){var a=this.findByType("zarafa.freebusypanel")[0];if(!a)return false;if(a.getModel().checkAttendeesBusyStatus(this.record.get("startdate"),this.record.get("duedate"))){Ext.MessageBox.confirm(_("Zarafa WebApp"),_("One or more attendees you have invited are busy. Are you sure to invite?"),
function(b){b=="yes"&&Zarafa.calendar.dialogs.AppointmentDialog.superclass.sendRecord.call(this)},this);return false}else Zarafa.calendar.dialogs.AppointmentDialog.superclass.sendRecord.call(this)}});Zarafa.core.ui.Dialog.register(Zarafa.calendar.dialogs.AppointmentDialog,"zarafa.appointmentdialog");Ext.namespace("Zarafa.calendar.data.busytime");
Zarafa.calendar.data.busytime.BusyTimeResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")}});Ext.namespace("Zarafa.calendar.data.busytime");Zarafa.calendar.data.busytime.BusyTimeRecordFields=[{name:"startdate",type:"date",dateFormat:"timestamp"},{name:"duedate",type:"date",dateFormat:"timestamp"},{name:"busystatus",type:"int",defaultValue:Zarafa.core.mapi.BusyStatus.FREE}];
Zarafa.calendar.data.busytime.BusyTimeRecord=Ext.data.Record.create(Zarafa.calendar.data.busytime.BusyTimeRecordFields);Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.BusyStatus=[{value:Zarafa.core.mapi.BusyStatus.FREE,name:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.FREE)},{value:Zarafa.core.mapi.BusyStatus.TENTATIVE,name:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.TENTATIVE)},{value:Zarafa.core.mapi.BusyStatus.BUSY,name:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.BUSY)},{value:Zarafa.core.mapi.BusyStatus.OUTOFOFFICE,name:Zarafa.core.mapi.BusyStatus.getDisplayName(Zarafa.core.mapi.BusyStatus.OUTOFOFFICE)}];
Ext.namespace("Zarafa.calendar.data");
Zarafa.calendar.data.AppointmentLabels=[{value:Zarafa.core.mapi.AppointmentLabels.NONE,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.NONE)},{value:Zarafa.core.mapi.AppointmentLabels.IMPORTANT,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.IMPORTANT)},{value:Zarafa.core.mapi.AppointmentLabels.WORK,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.WORK)},{value:Zarafa.core.mapi.AppointmentLabels.PERSONAL,
name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PERSONAL)},{value:Zarafa.core.mapi.AppointmentLabels.HOLIDAY,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.HOLIDAY)},{value:Zarafa.core.mapi.AppointmentLabels.REQUIRED,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.REQUIRED)},{value:Zarafa.core.mapi.AppointmentLabels.TRAVEL_REQUIRED,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.TRAVEL_REQUIRED)},
{value:Zarafa.core.mapi.AppointmentLabels.PREPARE_REQUIRED,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PREPARE_REQUIRED)},{value:Zarafa.core.mapi.AppointmentLabels.BIRTHDAY,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.BIRTHDAY)},{value:Zarafa.core.mapi.AppointmentLabels.SPECIAL_DATE,name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.SPECIAL_DATE)},{value:Zarafa.core.mapi.AppointmentLabels.PHONE_INTERVIEW,
name:Zarafa.core.mapi.AppointmentLabels.getDisplayName(Zarafa.core.mapi.AppointmentLabels.PHONE_INTERVIEW)}];Ext.namespace("Zarafa.calendar");
Zarafa.calendar.CalendarContextModel=Ext.extend(Zarafa.core.MultiFolderContextModel,{dateRange:undefined,date:undefined,oldDataMode:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.calendar.AppointmentStore;Ext.applyIf(a,{colorScheme:Zarafa.calendar.ui.ColorSchemes,current_data_mode:Zarafa.calendar.data.DataModes.WORKWEEK});this.date=(new Date).clearTime(true);this.dateRange=new Zarafa.core.DateRange;this.addEvents(["datechange","daterangechange"]);Zarafa.calendar.CalendarContextModel.superclass.constructor.call(this,
a);this.on({searchstart:this.onSearchStart,searchstop:this.onSearchStop,scope:this});this.calculateDateRange(this.date)},enable:function(a){this.default_merge_state=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_merge_state");this.setDate(new Date,false);Zarafa.calendar.CalendarContextModel.superclass.enable.call(this,a)},createRecord:function(a,b){a=a||this.getDefaultFolder();var c=a.getMAPIStore(),d=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),
e=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period");d=(new Date).ceil(Date.MINUTE,d);e=d.add(Date.MINUTE,e);var f=false,g=Zarafa.core.mapi.BusyStatus.BUSY,h=Date.diff(Date.SECOND,e,d),i=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_reminder_time");if(b){d=b.getStartDate();e=b.getDueDate();h=b.getDuration(Date.MINUTE);if(b.isAllDay()){f=true;i=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_allday_reminder_time");
g=Zarafa.core.mapi.BusyStatus.FREE}}return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Appointment",{object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:c.get("store_entryid"),parent_entryid:a.get("entryid"),busystatus:g,startdate:d,duedate:e,commonstart:d,commonend:e,duration:h,reminder:true,reminder_time:d,reminder_minutes:i,flagdueby:d.add(Date.MINUTE,-i),alldayevent:f})},load:function(){this.current_data_mode==Zarafa.calendar.data.DataModes.ALL?Zarafa.calendar.CalendarContextModel.superclass.load.call(this):
Zarafa.calendar.CalendarContextModel.superclass.load.call(this,{params:{restriction:{startdate:this.dateRange.getStartTime()/1E3,duedate:this.dateRange.getDueTime()/1E3}}})},calculateDateRange:function(a,b){var c=this.dateRange.clone();a=a.clearTime(true);switch(this.current_data_mode){case Zarafa.calendar.data.DataModes.SEARCH:break;case Zarafa.calendar.data.DataModes.ALL:break;case Zarafa.calendar.data.DataModes.DAY:this.dateRange.set(a,a.add(Date.DAY,1));break;case Zarafa.calendar.data.DataModes.WORKWEEK:var d=
container.getSettingsModel().get("zarafa/v1/main/week_start"),e=container.getSettingsModel().get("zarafa/v1/main/working_days");e.sort();if(d<=e[e.length-1])for(var f=0,g=e.length;f<g;f++){if(e[f]>=d){d=e[f];e=f==0?1+e[e.length-1]-e[f]:8-(e[f]-e[f-1]);break}}else{d=e[0];e=e[e.length-1]}d=a.getPreviousWeekDay(d);this.dateRange.set(d,d.add(Date.DAY,e));break;case Zarafa.calendar.data.DataModes.WEEK:d=container.getSettingsModel().get("zarafa/v1/main/week_start");d=a.getPreviousWeekDay(d);this.dateRange.set(d,
d.add(Date.DAY,7));break;case Zarafa.calendar.data.DataModes.MONTH:d=a.getFirstDateOfMonth();this.dateRange.set(d,d.add(Date.MONTH,1));break}if(b===true||!c.equals(this.dateRange)){this.current_data_mode!==Zarafa.calendar.data.DataModes.SEARCH&&this.load();this.fireEvent("daterangechange",this,this.dateRange,c)}},setDate:function(a,b){var c=this.date;a=a.clearTime(true);if(!(b!==true&&c.getTime()===a.getTime())){this.date=a;this.fireEvent("datechange",this,a,this.oldDate);this.calculateDateRange(this.date,
b)}},moveDate:function(a){switch(this.current_data_mode){case Zarafa.calendar.data.DataModes.DAY:this.setDate(this.date.add(Date.DAY,1*a));break;case Zarafa.calendar.data.DataModes.WEEK:case Zarafa.calendar.data.DataModes.WORKWEEK:this.setDate(this.date.add(Date.DAY,7*a));break;case Zarafa.calendar.data.DataModes.MONTH:this.setDate(this.date.add(Date.MONTH,1*a));break}},nextDate:function(){this.moveDate(1)},previousDate:function(){this.moveDate(-1)},onDataModeChange:function(a,b,c){Zarafa.calendar.CalendarContextModel.superclass.onDataModeChange.call(this,
a,b,c);b!==c&&c===Zarafa.calendar.data.DataModes.SEARCH&&this.stopSearch();this.calculateDateRange(this.date,true)},setModeAndDate:function(a,b){this.date=b.clearTime(true);this.setDataMode(a,true)},getMonthRangeText:function(){return this.dateRange.getStartDate().format(_("F Y"))},getDateRangeText:function(){return this.current_data_mode==Zarafa.calendar.data.DataModes.MONTH?this.getMonthRangeText():this.dateRange.format()},onSearchStart:function(){if(this.getCurrentDataMode()!=Zarafa.calendar.data.DataModes.SEARCH){this.oldDataMode=
this.getCurrentDataMode();this.setDataMode(Zarafa.calendar.data.DataModes.SEARCH)}},onSearchStop:function(){this.getCurrentDataMode()===Zarafa.calendar.data.DataModes.SEARCH&&this.setDataMode(this.oldDataMode);delete this.oldDataMode}});Ext.namespace("Zarafa.calendar");
Zarafa.calendar.CalendarContext=Ext.extend(Zarafa.core.Context,{default_zoom_level:undefined,oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{name:"calendar",displayName:_("Calendars"),groupViewBtns:false,current_view:Zarafa.calendar.data.Views.BLOCKS,current_view_mode:Zarafa.calendar.data.ViewModes.DAYS});this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewAppointmentButton,this);this.registerInsertionPoint("main.maintoolbar.new.item",this.createNewMeetingRequestButton,
this);this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);this.registerInsertionPoint("main.toolbar.actions.last",this.createMainToolbarButtons,this);this.registerInsertionPoint("navigation.north",this.createDatePicker,this);this.registerInsertionPoint("navigation.center",this.createCalendarNavigationPanel,this);this.registerInsertionPoint("context.settings.categories",this.createSettingCategories,this);this.registerInsertionPoint("previewpanel.toolbar.right",this.getMeetingRequestToolbarButtons,
this);this.registerInsertionPoint("previewpanel.toolbar.detaillinks",this.getMeetingRequestDetailLinks,this);this.registerInsertionPoint("context.mail.showmaildialog.toolbar.actions",this.getMeetingRequestToolbarButtons,this);this.addEvents(["zoomchange"]);Zarafa.calendar.CalendarContext.superclass.constructor.call(this,a);Zarafa.core.data.SharedComponentType.addProperty("calendar.dialogs.proposenewtimedialog");Zarafa.core.data.SharedComponentType.addProperty("calendar.dialogs.sendmeetingrequestconfirmation");
Zarafa.core.data.SharedComponentType.addProperty("calendar.dialogs.sendmeetingrequestcancellation")},enable:function(){this.default_zoom_level=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level");Zarafa.calendar.CalendarContext.superclass.enable.apply(this,arguments)},getModel:function(){if(!Ext.isDefined(this.model)){this.model=new Zarafa.calendar.CalendarContextModel;this.model.on({searchstart:this.onModelSearchStart,searchstop:this.onModelSearchStop,scope:this})}return this.model},
onModelSearchStart:function(){if(this.getCurrentView()!=Zarafa.calendar.data.Views.SEARCH&&this.getCurrentViewMode()!=Zarafa.calendar.data.ViewModes.SEARCH){this.oldView=this.getCurrentView();this.oldViewMode=this.getCurrentViewMode();this.switchView(Zarafa.calendar.data.Views.SEARCH,Zarafa.calendar.data.ViewModes.SEARCH)}},onModelSearchStop:function(){this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},setZoomLevel:function(a,b){if(b===true||this.default_zoom_level!==
a){var c=this.default_zoom_level;this.default_zoom_level=a;this.fireEvent("zoomchange",this,this.default_zoom_level,c)}},getZoomLevel:function(){return this.default_zoom_level},bid:function(a){if(a.isContainerClass("IPF.Appointment",true))return 1;return-1},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==
Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)c=b.isMessageClass(["IPM.Appointment","IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"],true)?1:-1;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestconfirmation"]:case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestcancellation"]:case Zarafa.core.data.SharedComponentType["calendar.dialogs.proposenewtimedialog"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)if(b.isMessageClass(["IPM.Appointment",
"IPM.Schedule.Meeting","IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"],true))c=1;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MESSAGE){if(b.isMessageClass(["IPM.Appointment","IPM.Schedule.Meeting","IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"],true))c=1}else if(b instanceof Zarafa.calendar.CalendarContext)c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof
Zarafa.core.data.MessageRecord&&b.isMessageClass(["IPM.Appointment","IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"],true))c=1;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:case Zarafa.core.data.SharedComponentType["common.view"]:c=Zarafa.calendar.dialogs.AppointmentDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.calendar.ui.CalendarContextMenu;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.proposenewtimedialog"]:c=
Zarafa.calendar.dialogs.ProposeNewTimeDialog;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestconfirmation"]:c=Zarafa.calendar.dialogs.SendMeetingRequestConfirmationDialog;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestcancellation"]:c=Zarafa.calendar.dialogs.SendMeetingRequestCancellationDialog;break;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord)c=Zarafa.calendar.printer.MeetingRenderer;
else switch(b.getModel().getCurrentDataMode()){case Zarafa.calendar.data.DataModes.WORKWEEK:c=Zarafa.calendar.printer.WorkWeekViewRenderer;break;case Zarafa.calendar.data.DataModes.WEEK:c=Zarafa.calendar.printer.WeekViewRenderer;break}break}return c},createCalendarNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",cls:"zarafa-context-navigation-block",title:_("My Calendars"),items:[{xtype:"zarafa.multiselecthierarchytree",model:this.getModel(),IPMFilter:"IPF.Appointment",
multiSelect:true,enableDD:true,enableItemDrop:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.APPOINTMENT,buttonText:_("Open Shared Calendars")}}]}]}},createDatePicker:function(){var a=new Zarafa.calendar.ui.DatePicker({navigationContext:this,showToday:false,width:"100%",handler:function(b,c){this.getModel().setDate(c)},scope:this});this.getModel().on("datechange",function(b,c){this.setValue(c)},a);return a},getMeetingRequestToolbarButtons:function(){return{xtype:"zarafa.meetingrequestbuttons"}},
getMeetingRequestDetailLinks:function(){return{xtype:"zarafa.meetinginfo"}},createContentPanel:function(){return{xtype:"zarafa.calendarmainpanel",context:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.calendar",this)||[];return[{text:_("Day"),iconCls:"icon-calendar-day",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.DAY,handler:this.onContextSelectView,
scope:this},{text:_("Workweek"),iconCls:"icon-calendar-workweek",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.WORKWEEK,handler:this.onContextSelectView,scope:this},{text:_("Week"),iconCls:"icon-calendar-week",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.WEEK,handler:this.onContextSelectView,scope:this},{text:_("Month"),
iconCls:"icon-calendar-month",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.BOX,valueDataMode:Zarafa.calendar.data.DataModes.MONTH,handler:this.onContextSelectView,scope:this},{text:_("List"),iconCls:"icon-calendar-grid",valueView:Zarafa.calendar.data.Views.LIST,valueViewMode:Zarafa.calendar.data.ViewModes.LIST,valueDataMode:Zarafa.calendar.data.DataModes.ALL,handler:this.onContextSelectView,scope:this}].concat(a)},onSwitchToToday:function(){this.getModel().setDate(new Date)},
onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},createMainToolbarButtons:function(){return[{xtype:"button",scale:"large",overflowText:_("Today"),tooltip:_("Today"),iconCls:"icon-calendar-today",handler:this.onSwitchToToday,scope:this,listeners:{afterrender:this.onAfterRenderMainToolbarButtons,scope:this}}]},onAfterRenderMainToolbarButtons:function(a){a.mon(container,"contextswitch",function(b,c,d){this.setVisiblityMainToolbarButton(a,
d)},this);this.setVisiblityMainToolbarButton(a)},setVisiblityMainToolbarButton:function(a,b){b=b||container.getCurrentContext();b===this?a.show():a.hide()},createNewAppointmentButton:function(){return{xtype:"menuitem",text:_("Appointment"),handler:function(){Zarafa.calendar.Actions.openAppointmentDialog(undefined,this.getModel())},scope:this,iconCls:"icon_create_appointment",newMenuIndex:2,context:"calendar"}},createNewMeetingRequestButton:function(){return{xtype:"menuitem",text:_("Meeting request"),
handler:function(){Zarafa.calendar.Actions.openMeetingRequestDialog(undefined,this.getModel())},scope:this,iconCls:"icon_create_meeting_request",newMenuIndex:2}},getMainToolbarPrintButtons:function(){var a=container.populateInsertionPoint("main.toolbar.print.calendar",this)||[];return[{xtype:"zarafa.conditionalitem",overflowText:_("Print selected appointment"),iconCls:"icon_print_single_appt",text:_("Print selected appointment"),handler:this.onPrintSelected,hideOnDisabled:false,nonEmptySelectOnly:true,
scope:this,beforeShow:function(b){var c=this.getModel().getSelectedRecords();Ext.isDefined(c)||(c=[]);if(b.nonEmptySelectOnly)Ext.isDefined(c)&&Ext.isArray(c)&&c.length==0?b.setDisabled(true):b.setDisabled(false)}},{xtype:"zarafa.conditionalitem",overflowText:_("Print overview"),iconCls:"icon_print_view",text:_("Print overview"),handler:this.onPrintView,hideOnDisabled:false,scope:this,beforeShow:function(b){this.getModel().getSelectedRecords();this.getModel().getCurrentDataMode()==Zarafa.calendar.data.DataModes.DAY||
this.getModel().getCurrentDataMode()==Zarafa.calendar.data.DataModes.MONTH?b.setDisabled(true):b.setDisabled(false)}}].concat(a)},onPrintSelected:function(){var a=this.model.getSelectedRecords();Ext.isEmpty(a)||Ext.isArray(a)&&a.length==0?Ext.MessageBox.alert(_("print"),_("No appointment selected")):Zarafa.common.Actions.openPrintDialog(a)},onPrintView:function(){var a=container.getCurrentContext();a&&Zarafa.common.Actions.openPrintDialog(a)},createSettingCategories:function(){return[{xtype:"zarafa.settingscalendarcategory"}]},
createMainTab:function(){return{text:_("Calendar"),tabOrderIndex:3,context:"calendar"}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.calendar.CalendarContext)});Ext.namespace("Zarafa.calendar");
Zarafa.calendar.AppointmentStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.Appointment",defaultSortInfo:{field:"startdate",direction:"desc"}});Zarafa.calendar.AppointmentStore.superclass.constructor.call(this,a)},getRecordKey:function(a){return a.get("recurring")?a.id+""+a.get("basedate"):a.id},destroyRecord:function(a,b,c){if(!(this.removed.indexOf(b)>-1)){if(b.get("recurring")&&!b.hasIdProp("basedate")){var d=[];this.each(function(h){h.id===
b.id&&d.push(h)});for(var e=0,f=d.length;e<f;e++){var g=d[e];this.removed.push(g);this.remove(g);this.removed.remove(g)}}Zarafa.calendar.AppointmentStore.superclass.destroyRecord.call(this,a,b,c)}},getRecordsForUpdateData:function(a,b){if(!Ext.isDefined(a)||b===Ext.data.Api.actions.create)return Zarafa.calendar.AppointmentStore.superclass.getRecordsForUpdateData.apply(this,arguments);var c={records:[],updatedRecords:[]};Ext.isArray(a)||(a=[a]);for(var d=0,e=a.length;d<e;d++){var f=a[d];if(f.get("recurring")===
false){var g=this.getByEntryId(f.get("entryid"));if(g){c.records.push(g);c.updatedRecords.push(f)}}else if(f.hasIdProp("basedate")){g=this.findBy(function(k){return Zarafa.core.EntryId.compareEntryIds(f.get("entryid"),k.get("entryid"))&&Ext.isDate(f.get("basedate"))&&Ext.isDate(k.get("basedate"))&&f.get("basedate").getTime()===k.get("basedate").getTime()});if(g>=0){c.records.push(this.getAt(g));c.updatedRecords.push(f)}}else{g=-1;do{g=this.findBy(function(k){return(b===Ext.data.Api.actions.destroy||
!k.isRecurringException())&&Zarafa.core.EntryId.compareEntryIds(f.get("entryid"),k.get("entryid"))},undefined,g+1);if(g>=0){var h=this.getAt(g),i=f.copy(),j=h.get("basedate");Ext.isDate(j)&&i.set("basedate",j.clone());i.set("startdate",h.get("startdate").clearTime(true).add(Date.MINUTE,f.get("recurrence_startocc")));i.set("duedate",h.get("duedate").clearTime(true).add(Date.MINUTE,f.get("recurrence_endocc")));i.set("commonstart",i.get("startdate").clone());i.set("commonend",i.get("duedate").clone());
i.set("duration",(i.get("duedate")-i.get("startdate"))/6E4);c.records.push(h);c.updatedRecords.push(i)}}while(g!=-1)}}return c}});Ext.reg("zarafa.appointmentstore",Zarafa.calendar.AppointmentStore);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.RecipientSelectionPanel=Ext.extend(Zarafa.addressbook.ui.AddressBookMainPanel,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.recipientselectionpanel",items:[{xtype:"zarafa.addressbookrecipientpanel",recipientButtonsCfg:a.recipientButtonsCfg,ref:"recipientPanel"}]});Zarafa.addressbook.ui.RecipientSelectionPanel.superclass.constructor.call(this,a)},onAfterLayout:function(){Zarafa.addressbook.ui.RecipientSelectionPanel.superclass.onAfterLayout.apply(this,
arguments);this.mon(this.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,this);this.mon(this.getGridPanel(),"rowcontextmenu",this.onAddressBookRowContextMenu,this)},onAddressBookRowDblClick:function(a,b){this.recipientPanel.addRecipients(a.getStore().getAt(b),this.defaultRecipientType)},onAddressBookRowContextMenu:function(a,b,c){a=a.getSelectionModel();if(a.hasSelection()){if(!a.isSelected(b)){a.clearSelections();a.selectRow(b)}}else a.selectRow(b);Zarafa.common.Actions.openContextMenu(a.getSelections(),
c.getXY(),{enableSelect:true,selectHandler:this.onRecipientSelect,selectScope:this,dialog:this.dialog})},onRecipientSelect:function(a){this.recipientPanel.addRecipients(a,this.defaultRecipientType)}});Ext.reg("zarafa.recipientselectionpanel",Zarafa.addressbook.ui.RecipientSelectionPanel);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER);Ext.applyIf(a,{preferredMessageClass:"addressbook",standalone:true,sortInfo:{field:"fileas",direction:"asc"},reader:new Zarafa.core.data.JsonReader({},b)});Zarafa.addressbook.AddressBookStore.superclass.constructor.call(this,a)},getRecordKey:function(a){return a.get("email_index")&&
a.get("email_index")!==-1?a.id+"_"+a.get("email_index"):a.id}});Ext.reg("zarafa.addressbookstore",Zarafa.addressbook.AddressBookStore);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookHierarchyStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(){Zarafa.addressbook.AddressBookHierarchyStore.superclass.constructor.call(this,{preferredMessageClass:"addressbook",standalone:true,proxy:new Zarafa.addressbook.AddressBookHierarchyProxy,sortInfo:{field:"display_name",direction:"desc"}})}});Ext.reg("zarafa.addressbookhierarchystore",Zarafa.addressbook.AddressBookHierarchyStore);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookHierchyRecordFields=[{name:"entryid"},{name:"display_name"},{name:"type"},{name:"store_entryid"},{name:"parent_entryid"},{name:"depth",type:"int",defaultValue:0}];Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_ABCONT,Zarafa.core.data.MAPIRecord);Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_ABCONT,Zarafa.addressbook.AddressBookHierchyRecordFields);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"addressbook",hasToolbar:false,hasContentPanel:false});Zarafa.addressbook.AddressBookContext.superclass.constructor.call(this,a);Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.recipientselection");Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.memberselection");Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.addressbook");
Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.abuserselection")},bidSharedComponent:function(a,b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["addressbook.dialog.memberselection"]:case Zarafa.core.data.SharedComponentType["addressbook.dialog.recipientselection"]:case Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"]:case Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"]:c=1;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:if(b instanceof
Zarafa.addressbook.AddressBookRecord)c=1;break;case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.addressbook.AddressBookRecord){var d=b.get("object_type");if([Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,Zarafa.core.mapi.ObjectType.MAPI_ABCONT].indexOf(d)>=0)c=1}break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["addressbook.dialog.memberselection"]:c=Zarafa.addressbook.dialogs.MemberSelectionDialog;
break;case Zarafa.core.data.SharedComponentType["addressbook.dialog.recipientselection"]:c=Zarafa.addressbook.dialogs.RecipientSelectionDialog;break;case Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"]:c=Zarafa.addressbook.dialogs.AddressBookDialog;break;case Zarafa.core.data.SharedComponentType["common.view"]:switch(b.get("object_type")){case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:c=Zarafa.addressbook.dialogs.ABUserDetailDialog;break;case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:c=
Zarafa.addressbook.dialogs.ABGroupDetailDialog;break;case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:c=Zarafa.addressbook.dialogs.ABGroupDetailDialog;break}break;case Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"]:c=Zarafa.addressbook.dialogs.ABUserSelectionDialog;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.addressbook.ui.AddressBookContextMenu;break}return c}});Zarafa.onReady(function(){container.registerContext(new Zarafa.addressbook.AddressBookContext)});
Ext.namespace("Zarafa.core.data");
Zarafa.core.data.MessageRecordFields=[{name:"received_by_name"},{name:"received_by_email_address"},{name:"received_by_address_type"},{name:"received_by_entryid"},{name:"received_by_search_key"},{name:"received_representing_name"},{name:"received_representing_email_address"},{name:"received_representing_address_type"},{name:"received_representing_entryid"},{name:"received_representing_search_key"},{name:"delegated_by_rule",type:"boolean",defaultValue:false},{name:"message_delivery_time",type:"date",
dateFormat:"timestamp",defaultValue:null},{name:"client_submit_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"transport_message_headers"},{name:"hide_attachments",type:"boolean",defaultValue:false}];
Zarafa.core.data.MessageRecord=Ext.extend(Zarafa.core.data.IPMRecord,{externalContent:false,hasExternalContent:function(a){a=Ext.isDefined(a)?a:this.getBody();if(!this.get("isHTML"))return this.externalContent=false;if(!this.externalContent||this.isModifiedSinceLastUpdate("html_body"))this.externalContent=Zarafa.core.HTMLParser.hasExternalContent(a);return this.externalContent},getBody:function(a){var b=this.get("isHTML"),c=Zarafa.core.data.MessageRecord.superclass.getBody.call(this,a);if(b===true&&
a===true&&!Ext.isEmpty(c)){if(!this.isExternalContentBlocked(c))return c;return Zarafa.core.HTMLParser.blockExternalContent(c)}else return c},isExternalContentBlocked:function(a){a=Ext.isDefined(a)?a:this.getBody();if(Ext.isEmpty(a))return false;if(!container.getSettingsModel().get("zarafa/v1/contexts/mail/block_external_content"))return false;var b=true,c=false,d=this.get("sent_representing_email_address")||this.get("sender_email_address"),e=container.getSettingsModel().get("zarafa/v1/contexts/mail/blocked_senders_list",
true),f=container.getSettingsModel().get("zarafa/v1/contexts/mail/safe_senders_list",true);e=Zarafa.core.Util.objToArray(e);f=Zarafa.core.Util.objToArray(f);if(this.checkBlockStatus()){b=false;c=true}if(!c){if(e.indexOf(d)!=-1)c=b=true;if(f.indexOf(d)!=-1){b=false;c=true}}if(!c){if(Zarafa.core.Util.inArray(e,d,true,true))b=true;if(Zarafa.core.Util.inArray(f,d,true,true))b=false}if(b&&this.hasExternalContent(a))return true;return false},checkBlockStatus:function(){if(this.senderIsUser())return true;
if(!this.get("block_status")||!Ext.isDate(this.get("message_delivery_time")))return false;return this.get("block_status")==this.calculateBlockStatus()},calculateBlockStatus:function(){if(!Ext.isDate(this.get("message_delivery_time")))return 0;var a=25569;a+=this.get("message_delivery_time").getTime()/864E5;a=(a-Math.floor(a))*1E8+3;return a=Math.floor(a)},senderIsReceiver:function(){var a=this.get("sent_representing_entryid")||this.get("sender_entryid"),b=this.get("received_by_entryid");if(!Ext.isEmpty(a)&&
!Ext.isEmpty(b))return Zarafa.core.EntryId.compareEntryIds(a,b);a=this.get("sent_representing_email_address")||this.get("sender_email_address");b=this.get("received_by_email_address");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return a===b;return false},senderIsUser:function(){var a=this.get("sent_representing_entryid")||this.get("sender_entryid"),b=container.getUser().getEntryId();if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return Zarafa.core.EntryId.compareEntryIds(a,b);return false},senderIsStoreOwner:function(){var a=
this.get("sent_representing_entryid")||this.get("sender_entryid"),b=container.getHierarchyStore().getByEntryId(this.get("store_entryid"));if(b){b=b.get("mailbox_owner_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return Zarafa.core.EntryId.compareEntryIds(a,b)}return false},userIsStoreOwner:function(){var a=container.getUser().getEntryId(),b=container.getHierarchyStore().getByEntryId(this.get("store_entryid"));if(b){b=b.get("mailbox_owner_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return Zarafa.core.EntryId.compareEntryIds(a,
b)}return false},setDelegatorInfo:function(a,b){if(a){b=b||false;this.set("sent_representing_name",a.get("mailbox_owner_name"),b);this.set("sent_representing_email_address",a.get("mailbox_owner_name"),b);this.set("sent_representing_address_type","ZARAFA",b);this.set("sent_representing_entryid",a.get("mailbox_owner_entryid"),b)}},getSender:function(){if(!this.get("sender_entryid"))return false;return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,
{smtp_address:this.get("sender_email_address"),display_name:this.get("sender_name"),address_type:this.get("sender_address_type"),entryid:this.get("sender_entryid"),search_key:this.get("sender_search_key")})},getSentRepresenting:function(){if(!this.get("sent_representing_entryid"))return false;return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{smtp_address:this.get("sent_representing_email_address"),display_name:this.get("sent_representing_name"),
address_type:this.get("sent_representing_address_type"),entryid:this.get("sent_representing_entryid"),search_key:this.get("sent_representing_search_key")})}});
Zarafa.core.data.MessageRecordPhantomHandler=function(a){var b=container.getUser();a.beginEdit();a.set("object_type",Zarafa.core.mapi.ObjectType.MAPI_MESSAGE);a.set("sender_name",b.getFullName());a.set("sender_address_type","ZARAFA");a.set("sender_email_address",b.getUserName());a.set("sender_entryid",b.getEntryId());a.set("sender_search_key",b.getSearchKey());if(!a.userIsStoreOwner())(b=container.getHierarchyStore().getByEntryId(a.get("store_entryid")))&&a.setDelegatorInfo(b);a.endEdit()};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMRecipientStore=Ext.extend(Zarafa.core.data.MAPISubStore,{resolveProxy:undefined,resolveReader:undefined,autoResolve:true,customObjectType:Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,constructor:function(a){a=a||{};Ext.applyIf(a,{writer:new Zarafa.core.data.JsonRecipientWriter,reader:new Zarafa.core.data.JsonRecipientReader({customObjectType:a.customObjectType||this.customObjectType})});this.addEvents("beforeresolve","resolved","exception");Zarafa.core.data.IPMRecipientStore.superclass.constructor.call(this,
a);this.resolveProxy=new Zarafa.core.data.IPMRecipientResolveProxy;this.relayEvents(this.resolveProxy,["exception"]);this.resolveReader=new Ext.data.JsonReader({root:"result"},Zarafa.core.data.IPMRecipientResolveRecord);this.on({add:this.onRecipientAdd,update:this.onRecipientUpdate,load:this.onRecipientLoad,exception:this.onResolveException,scope:this})},formatRecipient:function(a){var b="",c=a.get("display_name");a=a.get("smtp_address");Ext.isEmpty(c)||(b+=c);if(!Ext.isEmpty(a)&&c!=a){Ext.isEmpty(b)||
(b+=" ");b+="<"+a+">"}return b},parseRecipient:function(a,b){var c=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(this.customObjectType),d=a.indexOf("<"),e=a.indexOf(">");if(d!=-1&&e==-1||d==-1&&e!=-1)return null;c.beginEdit();if(d!=-1){c.set("display_name",a.substring(0,d-1).trim());c.set("smtp_address",a.substring(d+1,e).trim())}else{c.set("display_name",a);if(Zarafa.core.Util.validateEmailAddress(a)){c.set("smtp_address",a);c.set("object_type",Zarafa.core.mapi.ObjectType.MAPI_MAILUSER)}else c.set("smtp_address",
"")}c.set("recipient_type",b||Zarafa.core.mapi.RecipientType.MAPI_TO);c.endEdit();return c},getResolvedRecipients:function(a){var b=[];a=a||this.data.items;for(var c=0,d=a.length;c<d;c++){var e=a[c];e.isResolved()&&b.push(e)}return b},getUnresolvedRecipients:function(a){var b=[];a=a||this.data.items;for(var c=0,d=a.length;c<d;c++){var e=a[c];if(!e.isResolved()&&(!e.attemptedToResolve()||e.isAmbiguous()))b.push(e)}return b},getInvalidRecipients:function(a){var b=[];a=a||this.data.items;for(var c=0,
d=a.length;c<d;c++){var e=a[c];!e.isResolved()&&e.attemptedToResolve()&&!e.isValidSMTP()&&b.push(e)}return b},resolve:function(a,b){if(Ext.isDefined(a)&&!Ext.isArray(a))a=[a];a=this.getUnresolvedRecipients(a);if(a.length!=0){for(var c=[],d=[],e=0;e<a.length;e++){var f=a[e],g=f.get("display_name").trim(),h=f.get("smtp_address").trim();g=g;Ext.isEmpty(h)||(g=h);d.push({id:f.id,resolvename:g});c.push(f)}d={resolverequests:d};e=Ext.apply({},b,{actionType:Zarafa.core.Actions.checknames,pendingRecords:c,
params:d});this.fireEvent("beforeresolve",this,c);this.resolveProxy.request(Zarafa.core.Actions.checknames,a,d,this.resolveReader,this.onCheckNamesResult,this,e)}},onCheckNamesResult:function(a,b){Ext.isArray(a)||(a=[a]);for(var c=0;c<a.length;c++){var d=a[c];if(!Ext.isEmpty(d.id)){var e=this.getById(d.id);if(!e)break;if(d.result.totalRecords==1)e.applyResolveRecord(d.result.records[0],true);else if(d.result.totalRecords>1){e.resolveAttemptAmbiguous=true;Zarafa.common.Actions.openCheckNamesDialog(d.result.records,
e)}e.resolveAttempted=true}}this.fireEvent("resolved",this,b.pendingRecords)},onRecipientAdd:function(a,b){this.autoResolve&&this.resolve(b)},onRecipientUpdate:function(a,b){this.autoResolve&&this.resolve(b)},onRecipientLoad:function(){this.autoResolve&&this.resolve()},onResolveException:function(a,b,c,d){this.fireEvent("resolved",this,d.pendingRecords)}});Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.RecipientList=Ext.extend(Zarafa.common.recipientfield.ui.RecipientField,{constructor:function(a){a=a||{};Ext.applyIf(a,{boxType:"zarafa.recipientbox",boxConfig:{height:a.inputFieldHeight||this.inputFieldHeight},listMode:true,autoHeight:true,autoScroll:false});Zarafa.common.recipientfield.ui.RecipientList.superclass.constructor.call(this,a)}});Ext.reg("zarafa.recipientlist",Zarafa.common.recipientfield.ui.RecipientList);Ext.namespace("Zarafa.note");
Zarafa.note.NoteRecordFields=[{name:"icon_index",type:"int",defaultValue:Zarafa.core.mapi.IconIndex.note_yellow}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.StickyNote",Zarafa.note.NoteRecordFields);Zarafa.note.NoteRecord=Ext.extend(Zarafa.core.data.IPMRecord,{generateSubject:function(){var a=this.get("body");if(a.length>28)a=Ext.util.Format.substr(a,0,28)+"...";this.set("subject",a);return a}});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.StickyNote",Zarafa.note.NoteRecord);
Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailOptionsSettingsPanel=Ext.extend(Ext.form.FormPanel,{record:undefined,importanceStore:undefined,sensitivityStore:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");if(!a.importanceStore)a.importanceStore={xtype:"jsonstore",fields:["value","name"],data:Zarafa.common.data.ImportanceFlags.flags};if(!a.sensitivityStore)a.sensitivityStore={xtype:"jsonstore",fields:["value","name"],data:Zarafa.mail.data.SensitivityFlags.flags};
Ext.applyIf(a,{xtype:"zarafa.mailoptionssettingspanel",title:_("Message Settings"),layout:"form",items:[{xtype:"combo",fieldLabel:_("Importance"),ref:"importanceCombo",anchor:"100%",name:"importance",store:a.importanceStore,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}},{xtype:"combo",fieldLabel:_("Sensitivity"),ref:"sensitivityCombo",anchor:"100%",name:"sensitivity",store:a.sensitivityStore,
mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}}]});Zarafa.mail.dialogs.MailOptionsSettingsPanel.superclass.constructor.call(this,a)},onFieldSelect:function(a,b){this.record.set(a.getName(),b.get(a.valueField))},update:function(a){if(this.record=a){this.getForm().loadRecord(a);!a.phantom&&!a.isUnsent()?this.sensitivityCombo.disable():this.sensitivityCombo.enable()}else{this.importanceCombo.setValue(1);
this.sensitivityCombo.setValue(0)}},updateRecord:function(a){this.getForm().updateRecord(a);a.get("sensitivity")===Zarafa.core.mapi.Sensitivity.PRIVATE?a.set("private",true):a.set("private",false)}});Ext.reg("zarafa.mailoptionssettingspanel",Zarafa.mail.dialogs.MailOptionsSettingsPanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.SharedFolderPanel=Ext.extend(Ext.Panel,{defaultSelectedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.ALL,store:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"form",border:false,bodyStyle:"padding: 5px; background-color: inherit;",labelWidth:80,flex:1,items:[this.createRecipientField(a.store),this.createFolderTypeCombo(a.defaultSelectedFolderType),this.createSubfolderSelection()]});Zarafa.hierarchy.dialogs.SharedFolderPanel.superclass.constructor.call(this,
a)},createRecipientField:function(a){return{xtype:"zarafa.compositefield",hideLabel:true,style:"margin-top: 10px; margin-bottom: 10px;",anchor:"100%",items:[{xtype:"button",width:80,text:_("Name")+":",handler:this.onSelectUser,scope:this},{xtype:"zarafa.addressbookboxfield",ref:"../userField",boxStore:a,flex:1,boxLimit:1,boxConfig:{validDisplayType:Zarafa.core.mapi.DisplayType.DT_MAILUSER}}]}},createFolderTypeCombo:function(a){return{xtype:"combo",fieldLabel:_("Folder type"),typeAhead:true,triggerAction:"all",
lazyRender:true,mode:"local",style:"margin-bottom: 10px;",anchor:"100%",value:a,store:new Ext.data.JsonStore({fields:["value","name"],data:Zarafa.hierarchy.data.SharedFolderTypes.folders}),lazyInit:false,editable:false,displayField:"name",valueField:"value",ref:"folderTypeCombo",listeners:{select:this.onFolderTypeSelect,scope:this}}},createSubfolderSelection:function(){return{xtype:"checkbox",ref:"checkSubFolders",boxLabel:_("Show subfolders"),anchor:"100%"}},onRender:function(){Zarafa.hierarchy.dialogs.SharedFolderPanel.superclass.onRender.apply(this,
arguments);this.updateSubFolderCheckBox()},onSelectUser:function(){Zarafa.common.Actions.openABUserSelectionDialog(this.abCallBack.createDelegate(this),{hide_contacts:true},{hide_users:["contact","system"],hide_groups:true,hide_companies:true},this.dialog.isBrowser())},abCallBack:function(a){this.store.removeAll();this.store.add(a.convertToRecipient())},onFolderTypeSelect:function(){this.updateSubFolderCheckBox()},updateSubFolderCheckBox:function(){this.checkSubFolders.setDisabled(this.folderTypeCombo.getValue()===
Zarafa.hierarchy.data.SharedFolderTypes.ALL)},getFolderOptions:function(){return{type:this.folderTypeCombo.getValue(),subfolders:this.checkSubFolders.getValue()}}});Ext.reg("zarafa.sharedfolderpanel",Zarafa.hierarchy.dialogs.SharedFolderPanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.SharedFolderDialog=Ext.extend(Zarafa.core.ui.Dialog,{defaultSelectedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.ALL,store:undefined,constructor:function(a){a=a||{};if(!a.store)a.store=new Zarafa.core.data.IPMRecipientStore;a=Ext.applyIf(a,{xtype:"zarafa.sharedfolderdialog",layout:"fit",title:_("Open Shared Folders"),width:330,height:250,items:[{xtype:"zarafa.sharedfolderpanel",ref:"sharedFolderPanel",store:a.store,defaultSelectedFolderType:a.defaultSelectedFolderType||
this.defaultSelectedFolderType,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.hierarchy.dialogs.SharedFolderDialog.superclass.constructor.call(this,a)},onOk:function(){if(this.store&&this.store.getCount()>0){var a=this.store.getAt(0);if(!a.isResolved()&&!a.attemptedToResolve())this.mon(this.store,"resolved",this.onOk,this,{single:true});else if(a.isResolved())if(a.get("display_type")!==Zarafa.core.mapi.DisplayType.DT_MAILUSER)Ext.MessageBox.show({title:_("Zarafa WebApp"),
msg:String.format(_("Username '{0}' is not a valid user."),a.get("display_name")),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK});else if(a.get("email_address")===container.getUser().getEmailAddress())Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("It is not possible to open your own store twice"),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK});else{a=a.get("email_address");var b=this.sharedFolderPanel.getFolderOptions();container.getHierarchyStore().open(a,b.type,b.subfolders)?this.close():
Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This shared folder is already open."),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})}else Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:String.format(_("Username '{0}' could not be resolved."),a.get("display_name")),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})}else Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You must specify a username."),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})},onCancel:function(){this.close()}});
Zarafa.core.ui.Dialog.register(Zarafa.hierarchy.dialogs.SharedFolderDialog,"zarafa.sharedfolderdialog");Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.MAPIFolderRecordFields=[{name:"entryid"},{name:"parent_entryid"},{name:"store_entryid"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_FOLDER},{name:"folder_pathname"},{name:"display_name"},{name:"container_class",type:"string",defaultValue:"IPF.Note"},{name:"content_count",type:"int",defaultValue:0},{name:"content_unread",type:"int",defaultValue:0},{name:"has_subfolder",type:"boolean",defaultValue:false},{name:"comment",type:"string"},{name:"creation_time",
type:"date",dateFormat:"timestamp",defaultValue:null},{name:"message_size",type:"int"},{name:"total_message_size",type:"int"},{name:"deleted_on",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"rights",type:"int"},{name:"access",type:"int"},{name:"extended_flags",type:"int",defaultValue:0}];Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,Zarafa.hierarchy.data.MAPIFolderRecordFields);
Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,"permissions",Zarafa.hierarchy.data.MAPIFolderPermissionsSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,"folders",Zarafa.hierarchy.data.MAPIFolderSubStore);Zarafa.core.data.RecordFactory.addListenerToObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,"createphantom",function(a){a.afterOpen()});
Zarafa.hierarchy.data.MAPIFolderRecord=Ext.extend(Zarafa.core.data.IPFRecord,{colorScheme:undefined,colorTheme:"",getMAPIStore:function(){var a=this.getStore();if(a&&a instanceof Zarafa.hierarchy.data.IPFSubStore)return a.getParentRecord();else{a=container.getHierarchyStore();return a.getByEntryId(this.get("store_entryid"))}},getMAPIFolderStore:function(){var a=this.getMAPIStore();if(a)return a.getSubStore("folders");return false},isSpecialFolder:function(a){return this.getDefaultFolderKey()==a},
isOwnRoot:function(){return this.isIPMSubTree()&&this.getMAPIStore().isDefaultStore()},getSharedFolderKey:function(){return this.getMAPIStore().getSharedFolderKey(this.get("entryid"))},isSharedFolder:function(){return Ext.isDefined(this.getSharedFolderKey())?true:false},getDefaultFolderKey:function(){return this.getMAPIStore().getDefaultFolderKey(this.get("entryid"))},isDefaultFolder:function(){return Ext.isDefined(this.getDefaultFolderKey())?true:false},isIPMSubTree:function(){var a=this.getMAPIStore();
if(a)return Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("subtree_entryid"));return false},getDisplayName:function(){return this.isIPMSubTree()?this.getMAPIStore().get("display_name"):this.get("display_name")},isParentFolder:function(a){return Zarafa.core.EntryId.compareEntryIds(this.get("parent_entryid"),a)},getParentFolder:function(){var a=this.get("parent_entryid");if(!this.isIPMSubTree()&&!Ext.isEmpty(a))return this.getMAPIFolderStore().getByEntryId(a);return false},isInDeletedItems:function(){var a=
this.getMAPIStore();if(a)if(a.isDefaultStore()){a=this.getParentFolder();return!a||a.isIPMSubTree()?false:a.isSpecialFolder("wastebasket")||a.isSpecialFolder("junk")?true:a.isInDeletedItems()}return false},getPath:function(){for(var a="",b=this.getParentFolder();b;){a="\\"+b.getDisplayName()+a;if(b.isIPMSubTree())a="\\"+a;b=b.getParentFolder()}return a},isFavoriteFolder:function(){return this.isSpecialFolder("favorites")},addToFavorites:function(a,b){this.addMessageAction("action_type","addtofavorites");
this.addMessageAction("favorite_name",a);this.addMessageAction("favorite_flags",b)},emptyFolder:function(){this.addMessageAction("action_type","emptyfolder")},seadReadFlags:function(){this.addMessageAction("action_type","readflags")},getChildren:function(a,b){var c=b||[],d=this.get("entryid");Ext.iterate(this.getMAPIFolderStore().getRange(),function(e){if(Zarafa.core.EntryId.compareEntryIds(d,e.get("parent_entryid"))&&!Zarafa.core.EntryId.compareEntryIds(d,e.get("entryid"))){c.push(e);if(a===true&&
e.get("has_subfolder")===true)c=e.getChildren(true,c)}},this);return c},getColorTheme:function(){return this.colorTheme},setColorTheme:function(a){this.colorTheme=a},getColorScheme:function(){return this.colorScheme},setColorScheme:function(a){this.colorScheme=a;this.setColorTheme(a.name)},getCounterType:function(){var a=this.get("extended_flags");if((a&Zarafa.core.mapi.FolderExtendedFlags.DEFAULT)==Zarafa.core.mapi.FolderExtendedFlags.DEFAULT)if((a=this.isSpecialFolder("drafts")||this.isSpecialFolder("outbox")||
this.isSpecialFolder("junk"))&&this.get("content_count")>0)return Zarafa.hierarchy.data.CounterTypes.TOTAL;else{if(!a&&this.get("content_unread")>0)return Zarafa.hierarchy.data.CounterTypes.UNREAD}else if((a&Zarafa.core.mapi.FolderExtendedFlags.USE_UNREAD_COUNT)==Zarafa.core.mapi.FolderExtendedFlags.USE_UNREAD_COUNT&&this.get("content_unread")>0)return Zarafa.hierarchy.data.CounterTypes.UNREAD;else if((a&Zarafa.core.mapi.FolderExtendedFlags.USE_TOTAL_COUNT)==Zarafa.core.mapi.FolderExtendedFlags.USE_TOTAL_COUNT&&
this.get("content_count")>0)return Zarafa.hierarchy.data.CounterTypes.TOTAL;return Zarafa.hierarchy.data.CounterTypes.NONE},getCounterValue:function(a){a||(a=this.getCounterType());switch(a){case Zarafa.hierarchy.data.CounterTypes.TOTAL:return this.get("content_count");case Zarafa.hierarchy.data.CounterTypes.UNREAD:return this.get("content_unread");case Zarafa.hierarchy.data.CounterTypes.NONE:default:return}}});
Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,Zarafa.hierarchy.data.MAPIFolderRecord);Ext.namespace("Zarafa.contact");
Zarafa.contact.DistlistMemberStore=Ext.extend(Zarafa.core.data.MAPISubStore,{customObjectType:Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,constructor:function(a){a=a||{};Ext.applyIf(a,{writer:new Zarafa.contact.data.JsonMemberWriter,reader:new Zarafa.contact.data.JsonMemberReader({customObjectType:a.customObjectType||this.customObjectType})});Zarafa.contact.DistlistMemberStore.superclass.constructor.call(this,a)},parseMember:function(a){var b=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(this.customObjectType),
c=a.indexOf("<"),d=a.indexOf(">");if(c!=-1&&d==-1||c==-1&&d!=-1)return null;b.beginEdit();if(c!=-1){b.set("display_name",a.substring(0,c-1).trim());b.set("email_address",a.substring(c+1,d).trim())}else{b.set("display_name",a);Zarafa.core.Util.validateEmailAddress(a)?b.set("email_address",a):b.set("email_address","")}b.set("address_type","SMTP");b.set("distlist_type",Zarafa.core.mapi.DistlistType.DL_EXTERNAL_MEMBER);b.endEdit();return b}});Ext.namespace("Zarafa.contact");
Zarafa.contact.ContactRecordFields=[{name:"fileas"},{name:"fileas_selection",type:"int",defaultValue:-1},{name:"display_name"},{name:"given_name"},{name:"middle_name"},{name:"surname"},{name:"nickname"},{name:"display_name_prefix"},{name:"generation"},{name:"email_address"},{name:"email_index",type:"number",defaultValue:-1},{name:"email_address_1"},{name:"email_address_display_name_1"},{name:"email_address_display_name_email_1"},{name:"email_address_type_1"},{name:"email_address_entryid_1"},{name:"email_address_2"},
{name:"email_address_display_name_2"},{name:"email_address_display_name_email_2"},{name:"email_address_type_2"},{name:"email_address_entryid_2"},{name:"email_address_3"},{name:"email_address_display_name_3"},{name:"email_address_display_name_email_3"},{name:"email_address_type_3"},{name:"email_address_entryid_3"},{name:"fax_1_email_address"},{name:"fax_1_original_display_name"},{name:"fax_1_address_type"},{name:"fax_1_original_entryid"},{name:"fax_2_email_address"},{name:"fax_2_original_display_name"},
{name:"fax_2_address_type"},{name:"fax_2_original_entryid"},{name:"fax_3_email_address"},{name:"fax_3_original_display_name"},{name:"fax_3_address_type"},{name:"fax_3_original_entryid"},{name:"business_address"},{name:"business_address_street"},{name:"business_address_city"},{name:"business_address_state"},{name:"business_address_postal_code"},{name:"business_address_country"},{name:"home_address"},{name:"home_address_street"},{name:"home_address_city"},{name:"home_address_state"},{name:"home_address_postal_code"},
{name:"home_address_country"},{name:"other_address"},{name:"other_address_street"},{name:"other_address_city"},{name:"other_address_state"},{name:"other_address_postal_code"},{name:"other_address_country"},{name:"mailing_address",type:"int"},{name:"home_telephone_number"},{name:"cellular_telephone_number"},{name:"assistant_telephone_number"},{name:"business_telephone_number"},{name:"business2_telephone_number"},{name:"callback_telephone_number"},{name:"car_telephone_number"},{name:"company_telephone_number"},
{name:"home2_telephone_number"},{name:"isdn_number"},{name:"other_telephone_number"},{name:"pager_telephone_number"},{name:"primary_telephone_number"},{name:"radio_telephone_number"},{name:"telex_telephone_number"},{name:"ttytdd_telephone_number"},{name:"business_fax_number"},{name:"home_fax_number"},{name:"primary_fax_number"},{name:"title"},{name:"company_name"},{name:"department_name"},{name:"office_location"},{name:"profession"},{name:"manager_name"},{name:"assistant"},{name:"nickname"},{name:"spouse_name"},
{name:"birthday",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"wedding_anniversary",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"birthday_eventid"},{name:"anniversary_eventid"},{name:"im"},{name:"business_home_page"},{name:"webpage"},{name:"private",type:"boolean",defaultValue:false},{name:"sensitivity",type:"int",defaultValue:Zarafa.core.mapi.Sensitivity.NONE},{name:"contacts_string"},{name:"contacts"},{name:"message_flags",type:"int",defaultValue:Zarafa.core.mapi.MessageFlags.MSGFLAG_READ},
{name:"address_type",type:"string",defaultValue:"SMTP"},{name:"address_book_long",type:"int",defaultValue:0},{name:"address_book_mv"},{name:"timezone",type:"int"},{name:"timezone_unk",mapping:"unk",type:"int"},{name:"timezone_timezonedst",mapping:"timezonedst",type:"int"},{name:"timezone_dstendmonth",mapping:"dstendmonth",type:"int"},{name:"timezone_dstendweek",mapping:"dstendweek",type:"int"},{name:"timezone_dstendday",mapping:"dstendday",type:"int"},{name:"timezone_dstendhour",mapping:"dstendhour",
type:"int"},{name:"timezone_dststartmonth",mapping:"dststartmonth",type:"int"},{name:"timezone_dststartweek",mapping:"dststartweek",type:"int"},{name:"timezone_dststartday",mapping:"dststartday",type:"int"},{name:"timezone_dststarthour",mapping:"dststarthour",type:"int"}];
Zarafa.contact.ContactRecord=Ext.extend(Zarafa.core.data.IPMRecord,{hasEmailAddress:function(){return!Ext.isEmpty(this.get("email_address_1"))||!Ext.isEmpty(this.get("email_address_2"))||!Ext.isEmpty(this.get("email_address_3"))},convertToRecipient:function(a,b){var c=[];if(b===true){for(var d=1;d<4;d++)if(!Ext.isEmpty(this.get("email_address_"+d))){var e={entryid:this.get("entryid"),store_entryid:this.get("store_entryid"),parent_entryid:this.get("parent_entryid"),object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,
display_name:!Ext.isEmpty(this.get("email_address_display_name_"+d))?this.get("email_address_display_name_"+d):this.get("display_name"),smtp_address:this.get("email_address_"+d),address_type:"SMTP",message_class:"IPM.Contact",recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO};c.push(Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,e))}return c}if(!Ext.isEmpty(this.get("email_address"))){e={entryid:this.get("entryid"),store_entryid:this.get("store_entryid"),
parent_entryid:this.get("parent_entryid"),object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,display_name:!Ext.isEmpty(this.get("email_address_display_name"))?this.get("email_address_display_name"):this.get("display_name"),smtp_address:this.get("email_address"),address_type:"SMTP",message_class:"IPM.Contact",recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO};return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,e)}},
convertToDistlistMember:function(){var a=this.get("entryid");if(a.indexOf("_")>0)a=a.substring(0,a.indexOf("_"));return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,{entryid:a,address_type:this.get("address_type"),distlist_type:Zarafa.core.mapi.DistlistType.DL_USER,display_name:this.get("display_name"),email_address:this.get("email_address")})},updateTimezoneInformation:function(){var a=Date.getTimezoneStruct();this.beginEdit();
this.set("timezone",a.timezone,true);this.set("timezone_timezonedst",a.timezonedst,true);this.set("timezone_dstendmonth",a.dstendmonth,true);this.set("timezone_dstendweek",a.dstendweek,true);this.set("timezone_dstendday",a.dstendday,true);this.set("timezone_dstendhour",a.dstendhour,true);this.set("timezone_dststartmonth",a.dststartmonth,true);this.set("timezone_dststartweek",a.dststartweek,true);this.set("timezone_dststartday",a.dststartday,true);this.set("timezone_dststarthour",a.dststarthour,true);
this.endEdit()},updateSubject:function(){var a=this.get("display_name_prefix"),b=this.get("generation"),c=this.get("display_name"),d=this.get("fileas");Ext.isEmpty(a)||(c=c.replace(a,""));Ext.isEmpty(b)||(c=c.replace(b,""));c=c.trim();if(Ext.isEmpty(d)&&!Ext.isEmpty(c)){a=c.replace(a,"").replace(b,"").replace(",","").trim().split(RegExp(Zarafa.contact.data.config.SP+"|"+Zarafa.contact.data.config.NBSP,"g"));d=a.length===1?a[0]:a.join(Zarafa.contact.data.config.NBSP)}this.beginEdit();this.set("fileas",
d);this.set("subject",c);this.set("normalized_subject",c);this.endEdit()},updateAddressbookProps:function(){var a=0,b=[];this.beginEdit();for(var c=1;c<4;c++)if(Ext.isEmpty(this.get("email_address_"+c))){this.set("email_address_display_name_"+c,"");this.set("email_address_display_name_email_"+c,"");this.set("email_address_type_"+c,"")}else{var d=this.get("fileas")||"";Ext.isEmpty(d)||(d+=" ");d+="("+this.get("email_address_"+c)+")";this.set("email_address_display_name_"+c,d);if(Ext.isEmpty(this.get("email_address_display_name_"+
c))){this.set("email_address_display_name_email_"+c,"");this.set("email_address_type_"+c,"")}else{a+=Math.pow(2,c-1);b.push(c-1);this.set("email_address_display_name_email_"+c,this.get("email_address_"+c))}}if(Ext.isEmpty(this.get("primary_fax_number"))){this.set("fax_1_original_display_name","");this.set("fax_1_address_type","");this.set("fax_1_email_address","")}else{this.set("fax_1_original_display_name",this.get("subject"));this.set("fax_1_address_type","FAX",true);this.set("fax_1_email_address",
this.get("fax_1_original_display_name")+"@"+this.get("primary_fax_number"));a+=32;b.push(5)}if(Ext.isEmpty(this.get("business_fax_number"))){this.set("fax_2_original_display_name","");this.set("fax_2_address_type","");this.set("fax_2_email_address","")}else{this.set("fax_2_original_display_name",this.get("subject"));this.set("fax_2_address_type","FAX",true);this.set("fax_2_email_address",this.get("fax_2_original_display_name")+"@"+this.get("business_fax_number"));a+=8;b.push(3)}if(Ext.isEmpty(this.get("home_fax_number"))){this.set("fax_3_original_display_name",
"");this.set("fax_3_address_type","");this.set("fax_3_email_address","")}else{this.set("fax_3_original_display_name",this.get("subject"));this.set("fax_3_address_type","FAX",true);this.set("fax_3_email_address",this.get("fax_3_original_display_name")+"@"+this.get("home_fax_number"));a+=16;b.push(4)}this.set("address_book_long",a);this.set("address_book_mv",b.sort());this.endEdit()}});Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Contact",Zarafa.contact.ContactRecordFields);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Contact","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Contact",Zarafa.contact.ContactRecord);Ext.namespace("Zarafa.calendar.ui.html");
Zarafa.calendar.ui.html.AppointmentDaysView=Ext.extend(Zarafa.calendar.ui.html.AppointmentView,{bounds:undefined,bodyText:undefined,topHandle:undefined,bottomHandle:undefined,leftHandle:undefined,rightHandle:undefined,headerImg:undefined,headerStrip:undefined,headerText:undefined,bodyStrip:undefined,leftHandleImage:undefined,rightHandleImage:undefined,topHandleImage:undefined,bottomHandleImage:undefined,mainRenderedText:"",subRenderedText:"",init:function(){Zarafa.calendar.ui.html.AppointmentDaysView.superclass.init.call(this);
this.bodyStrip=[]},render:function(a){Zarafa.calendar.ui.html.AppointmentDaysView.superclass.render.call(this,a);this.createDiv(this.parentView.getCalendarBody(),"bodyText");this.createDiv(this.parentView.getCalendarBody(),"topHandle",this.getClassName("draghandle","top"));this.createDiv(this.parentView.getCalendarBody(),"bottomHandle",this.getClassName("draghandle","bottom"));this.createDiv(this.parentView.getCalendarHeader(),"leftHandle",this.getClassName("draghandle","left"));this.createDiv(this.parentView.getCalendarHeader(),
"rightHandle",this.getClassName("draghandle","right"))},setSelected:function(a){Zarafa.calendar.ui.html.AppointmentDaysView.superclass.setSelected.call(this,a);this.updateHandleImages();a&&this.layoutHandleImages(this.bounds);for(var b=0,c=this.elements.length;b<c;b++)a?this.elements[b].addClass("zarafa-calendar-appointment-selected"):this.elements[b].removeClass("zarafa-calendar-appointment-selected")},eventOverBody:function(a){return this.elementIsInBody(a.target)},eventOverBodyStartHandle:function(a){return Ext.get(a.target)==
this.topHandle},eventOverBodyDueHandle:function(a){return Ext.get(a.target)==this.bottomHandle},eventOverHeader:function(a){return this.elementIsInHeader(a.target)},eventOverHeaderStartHandle:function(a){return Ext.get(a.target)==this.leftHandle},eventOverHeaderDueHandle:function(a){return Ext.get(a.target)==this.rightHandle},layoutInHeader:function(){var a=this.getStripWidth();this.bounds=this.parentView.dateRangeToHeaderBounds(this.getDateRange(),this.slot,1,true);this.header.dom.className=this.getClassName("header",
undefined,true);this.header.setLeftTop(this.bounds.left,this.bounds.top);this.header.setSize(this.bounds.right-this.bounds.left-4,this.bounds.bottom-this.bounds.top-4);if(this.backgroundImagesEnabled){this.headerImg.dom.className=this.getClassName("headerimage",undefined,true);this.headerImg.setLeftTop(this.bounds.left+a,this.bounds.top);this.headerImg.setSize(this.bounds.right-this.bounds.left-a,this.bounds.bottom-this.bounds.top)}var b=this.iconRenderer(),c=this.mainRenderedText,d=this.subRenderedText;
this.headerText.dom.className=this.getClassName("header-text",undefined,true);this.headerText.dom.innerHTML="";for(var e=0,f=b.length;e<f;e++)this.headerText.dom.innerHTML+=String.format('<span class="{0}"></span>',this.getClassName("icon",b[e]));this.headerText.dom.innerHTML+=String.format('<span class="{0}">{1}</span>',this.getClassName("maintext"),c);this.headerText.dom.innerHTML+=String.format('<span class="{0}">{1}</span>',this.getClassName("subtext"),d);this.headerText.setLeftTop(this.bounds.left+
a-1,this.bounds.top);this.headerText.setSize(this.bounds.right-this.bounds.left-a+1,this.bounds.bottom-this.bounds.top);this.headerStrip.dom.className=this.getClassName("header-strip",undefined,true);this.headerStrip.setLeftTop(this.bounds.left,this.bounds.top);this.headerStrip.setSize(a,this.bounds.bottom-this.bounds.top);this.leftHandle.setLeftTop(this.bounds.left,this.bounds.top);this.leftHandle.setHeight(this.bounds.bottom-this.bounds.top);this.rightHandle.setLeftTop(this.bounds.right-this.rightHandle.getWidth(),
this.bounds.top);this.rightHandle.setHeight(this.bounds.bottom-this.bounds.top);this.quicktipEnabled&&this.layoutQuickTip(this.header);this.updateHandleImages();this.isSelected()&&this.layoutHandleImages(this.bounds)},createHeader:function(){Zarafa.calendar.ui.html.AppointmentDaysView.superclass.createHeader.call(this);this.backgroundImagesEnabled&&this.createDiv(this.parentView.getCalendarHeader(),"headerImg");this.createDiv(this.parentView.getCalendarHeader(),"headerStrip");this.createDiv(this.parentView.getCalendarHeader(),
"headerText");this.backgroundImagesEnabled&&this.headerImg.setVisible(false)},destroyHeader:function(){Zarafa.calendar.ui.html.AppointmentDaysView.superclass.destroyHeader.call(this);this.backgroundImagesEnabled&&this.remove(this.headerImg);this.remove(this.headerStrip);this.remove(this.headerText)},layoutBodyStrip:function(a){for(var b=this.parentView.getRangeVerticalHeight(this.getDateRange()),c=this.getStripWidth(),d=this.getClassName("body-strip",undefined,true),e=0;e<a.length;e++){this.bodyStrip[e].dom.className=
d;this.bodyStrip[e].setLeftTop(a[e].left,a[e].top);this.bodyStrip[e].setSize(c+1,Math.min(a[e].bottom-a[e].top,b))}},layoutBodyText:function(a){for(var b="",c=this.getStripWidth(),d=this.iconRenderer(),e=this.mainRenderedText,f=this.subRenderedText,g=a.bottom-a.top,h=Ext.util.TextMetrics.measure(this.bodyText,e).height,i=0,j=d.length;i<j;i++)b+=String.format('<span class="{0}"></span>',this.getClassName("icon",d[i]));b+=String.format('<span class="{0}">{1}</span>',this.getClassName("maintext"),e);
b+=String.format('<br/><span class="{0}">{1}</span>',this.getClassName("subtext"),f);if(g<h)b="";this.bodyText.dom.className=this.getClassName("body-text",undefined,true);this.bodyText.dom.innerHTML=b;this.bodyText.setLeftTop(a.left+c,a.top);this.bodyText.setSize(a.right-a.left-c,g)},layoutBodyElements:function(a){var b=a[0],c=a[a.length-1];this.layoutBodyText(b);this.topHandle.setLeftTop(b.left,b.top);this.topHandle.setWidth(b.right-b.left);this.bottomHandle.setLeftTop(c.left,c.bottom-this.bottomHandle.getHeight());
this.bottomHandle.setWidth(c.right-c.left);b=this.getClassName("body",undefined,true);c=this.getStripWidth();for(var d=0;d<a.length;d++){this.body[d].dom.className=b;this.body[d].dom.style.paddingLeft=c+"px";this.body[d].setLeftTop(a[d].left,a[d].top);this.body[d].setSize(a[d].right-a[d].left-4,a[d].bottom-a[d].top-4)}this.backgroundImagesEnabled&&this.layoutBodyImages(a);this.stripVisible&&this.layoutBodyStrip(a);this.quicktipEnabled&&this.layoutQuickTip(this.body);this.updateHandleImages();this.isSelected()&&
this.layoutHandleImages(a);this.layoutOutline(a)},layoutInBody:function(){for(this.bounds=this.parentView.dateRangeToBodyBounds(this.getAdjustedDateRange(),this.slot,this.slotCount,true);this.body.length<this.bounds.length;)this.createBodyElement();for(;this.body.length>this.bounds.length;)this.destroyBodyElement();for(var a=this.stripVisible?this.body.length:0;this.bodyStrip.length<a;)this.createDiv(this.parentView.getCalendarBody(),"bodyStrip");for(;this.bodyStrip.length>a;)this.remove(this.bodyStrip.pop());
Ext.isEmpty(this.bounds)||this.layoutBodyElements(this.bounds)},updateHandleImages:function(){if(this.isSelected())if(this.isHeaderRange()){this.leftHandleImage||this.createDiv(this.parentView.getCalendarHeader(),"leftHandleImage",this.getClassName("draghandle-icon","left"));this.rightHandleImage||this.createDiv(this.parentView.getCalendarHeader(),"rightHandleImage",this.getClassName("draghandle-icon","right"));if(this.topHandleImage){this.remove(this.topHandleImage);delete this.topHandleImage}if(this.bottomHandleImage){this.remove(this.bottomHandleImage);
delete this.bottomHandleImage}}else{if(this.leftHandleImage){this.remove(this.leftHandleImage);delete this.leftHandleImage}if(this.rightHandleImage){this.remove(this.rightHandleImage);delete this.rightHandleImage}this.topHandleImage||this.createDiv(this.parentView.getCalendarBody(),"topHandleImage",this.getClassName("draghandle-icon","top"));this.bottomHandleImage||this.createDiv(this.parentView.getCalendarBody(),"bottomHandleImage",this.getClassName("draghandle-icon","bottom"))}else{if(this.leftHandleImage){this.remove(this.leftHandleImage);
delete this.leftHandleImage}if(this.rightHandleImage){this.remove(this.rightHandleImage);delete this.rightHandleImage}if(this.topHandleImage){this.remove(this.topHandleImage);delete this.topHandleImage}if(this.bottomHandleImage){this.remove(this.bottomHandleImage);delete this.bottomHandleImage}}},layoutHandleImages:function(a){if(this.isHeaderRange()){var b=a.top+Math.floor((a.bottom-a.top)/2),c=this.leftHandleImage.getSize();this.leftHandleImage.setLeftTop(a.left-Math.floor(c.width/2),b-Math.ceil(c.height/
2));this.rightHandleImage.setLeftTop(a.right-Math.ceil(c.width/2),b-Math.ceil(c.height/2))}else{b=a[0];a=a[a.length-1];c=this.topHandleImage.getSize();this.topHandleImage.setLeftTop(b.left+Math.floor((b.right-b.left)/2)-Math.ceil(c.width/2),b.top-Math.floor(c.height/2));this.bottomHandleImage.setLeftTop(a.left+Math.floor((a.right-a.left)/2)-Math.ceil(c.width/2),a.bottom-Math.ceil(c.height/2))}},onLayout:function(){this.mainRenderedText=this.mainTextRenderer();this.subRenderedText=this.subTextRenderer();
Zarafa.calendar.ui.html.AppointmentDaysView.superclass.onLayout.call(this)}});Ext.namespace("Zarafa.calendar.ui.html");
Zarafa.calendar.ui.html.AppointmentBoxView=Ext.extend(Zarafa.calendar.ui.html.AppointmentView,{bounds:undefined,leftMargin:6,rightMargin:6,leftHandle:undefined,rightHandle:undefined,leftHandleImage:undefined,rightHandleImage:undefined,mainRenderedText:"",subRenderedText:"",render:function(a){Zarafa.calendar.ui.html.AppointmentBoxView.superclass.render.call(this,a);this.createDiv(this.parentView.getCalendarBody(),"leftHandle",this.getClassName("draghandle","left"));this.createDiv(this.parentView.getCalendarBody(),
"rightHandle",this.getClassName("draghandle","right"))},setSelected:function(a){Zarafa.calendar.ui.html.AppointmentBoxView.superclass.setSelected.call(this,a);if(a){this.createHandleImages();this.layoutHandleImages(this.bounds)}else this.destroyHandleImages();for(var b=0,c=this.elements.length;b<c;b++)a?this.elements[b].addClass("zarafa-calendar-appointment-selected"):this.elements[b].removeClass("zarafa-calendar-appointment-selected")},eventOverBody:function(a){return this.elementIsInBody(a.target)},
eventOverBodyStartHandle:function(a){return Ext.get(a.target)==this.leftHandle},eventOverBodyDueHandle:function(a){return Ext.get(a.target)==this.rightHandle},layoutInHeader:Ext.emptyFn,createHeader:Ext.emptyFn,destroyHeader:Ext.emptyFn,layoutBodyElements:function(a){var b=a[0],c=a[a.length-1];b.left+=this.leftMargin;c.right-=this.rightMargin;this.leftHandle.setLeftTop(b.left,b.top);this.leftHandle.setHeight(b.bottom-b.top);this.rightHandle.setLeftTop(c.right-this.rightHandle.getWidth(),c.top);this.rightHandle.setHeight(c.bottom-
c.top);b=this.getClassName("body","outline",true);c=this.getStripWidth();for(var d=this.iconRenderer(),e="",f=0,g=d.length;f<g;f++)e+=String.format('<span class="{0}"></span>',this.getClassName("icon",d[f]));e+=String.format('<span class="{0}">{1}</span>',this.getClassName("maintext"),this.mainRenderedText);e+=String.format('<span class="{0}">{1}</span>',this.getClassName("subtext"),this.subRenderedText);for(f=0;f<a.length;f++){this.body[f].dom.className=b;this.body[f].dom.style.paddingLeft=c+"px";
this.body[f].dom.innerHTML=e;this.body[f].setLeftTop(a[f].left,a[f].top);this.body[f].setSize(a[f].right-a[f].left-4,a[f].bottom-a[f].top-4)}this.backgroundImagesEnabled&&this.layoutBodyImages(a);this.quicktipEnabled&&this.layoutQuickTip(this.body);this.layoutOutline(a)},layoutInBody:function(){for(this.bounds=this.parentView.dateRangeToBodyBounds(this.getDateRange(),this.slot);this.body.length<this.bounds.length;)this.createBodyElement();for(;this.body.length>this.bounds.length;)this.destroyBodyElement();
Ext.isEmpty(this.bounds)||this.layoutBodyElements(this.bounds)},createHandleImages:function(){this.leftHandleImage||this.createDiv(this.parentView.getCalendarBody(),"leftHandleImage",this.getClassName("draghandle-icon","left"));this.rightHandleImage||this.createDiv(this.parentView.getCalendarBody(),"rightHandleImage",this.getClassName("draghandle-icon","right"))},destroyHandleImages:function(){if(this.leftHandleImage){this.remove(this.leftHandleImage);delete this.leftHandleImage}if(this.rightHandleImage){this.remove(this.rightHandleImage);
delete this.rightHandleImage}},layoutHandleImages:function(a){var b=a[0];a=a[a.length-1];var c=this.leftHandleImage.getSize();this.leftHandleImage.setLeftTop(b.left-Math.floor(c.width/2),b.top+Math.floor((b.bottom-b.top)/2)-Math.ceil(c.height/2));this.rightHandleImage.setLeftTop(a.right-Math.ceil(c.width/2),a.top+Math.floor((a.bottom-a.top)/2)-Math.ceil(c.height/2))},onLayout:function(){this.mainRenderedText=this.mainTextRenderer();this.subRenderedText=this.subTextRenderer();Zarafa.calendar.ui.html.AppointmentBoxView.superclass.onLayout.call(this)}});
Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentDaysView=Ext.extend(Zarafa.calendar.ui.canvas.AppointmentView,{bounds:undefined,appointmentRadius:5,lineHeight:13,bodyTextTopOffset:2,bodyTextBottomOffset:2,leftPadding:4,iconSpacing:5,mainRenderedText:"",subRenderedText:"",setSelected:function(a){Zarafa.calendar.ui.canvas.AppointmentDaysView.superclass.setSelected.call(this,a);if(a&&!Ext.isEmpty(this.bounds))this.isHeaderRange()?this.drawHeaderSelectionOutline(this.bounds):this.drawBodySelectionOutline(this.bounds)},
eventOverHeaderStartHandle:function(a){if(!this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b={left:this.bounds.left,right:this.bounds.left+this.dragHandleWidth,top:this.bounds.top,bottom:this.bounds.bottom};return this.isEventOverElement(this.getEventHeaderPosition(a),b)},eventOverHeaderDueHandle:function(a){if(!this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b={left:this.bounds.right-this.dragHandleWidth,right:this.bounds.right,top:this.bounds.top,
bottom:this.bounds.bottom};return this.isEventOverElement(this.getEventHeaderPosition(a),b)},eventOverHeader:function(a){if(!this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;return this.isEventOverElement(this.getEventHeaderPosition(a),this.bounds)},eventOverBodyStartHandle:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b=this.bounds[0];return this.isEventOverElement(this.getEventBodyPosition(a),{left:b.left,right:b.right,top:b.top,
bottom:b.top+this.dragHandleHeight})},eventOverBodyDueHandle:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b=this.bounds[this.bounds.length-1];return this.isEventOverElement(this.getEventBodyPosition(a),{left:b.left,right:b.right,top:b.bottom-this.dragHandleHeight,bottom:b.bottom})},eventOverBody:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;a=this.getEventBodyPosition(a);for(var b=0,c=this.bounds.length;b<c;b++)if(this.isEventOverElement(a,
this.bounds[b]))return true;return false},drawHeaderSelectionOutline:function(a){var b=this.parentView.getHeaderSelectionCanvas().dom.getContext("2d"),c=a.left+0.5,d=a.top+0.5,e=a.right-a.left-1,f=a.bottom-a.top-1,g=a.firstBox?this.appointmentRadius:1,h=a.lastBox?this.appointmentRadius:1;b.save();b.lineWidth=1;b.strokeStyle="black";b.roundedRect2(c,d,e,f,g,h,h,g);b.stroke();d+=Math.floor(f/2);a.firstBox&&this.drawDragHandle(b,c,d);a.lastBox&&this.drawDragHandle(b,c+e,d);b.restore()},drawBodySelectionOutline:function(a){var b=
this.parentView.getBodySelectionCanvas().dom.getContext("2d");b.save();b.lineWidth=1;b.strokeStyle="black";for(var c=0,d=a.length;c<d;c++){var e=a[c],f=e.left+0.5,g=e.top+0.5,h=e.right-e.left-1,i=e.bottom-e.top-1,j=e.firstBox?this.appointmentRadius:1,k=e.lastBox?this.appointmentRadius:1;b.roundedRect2(f,g,h,i,j,j,k,k);b.stroke();if(e.firstBox){f+=Math.ceil(h/2);this.drawDragHandle(b,f,g)}if(e.lastBox){e.firstBox||(f+=Math.ceil(h/2));this.drawDragHandle(b,f,g+i)}}b.restore()},drawBodyText:function(a,
b,c,d,e){if(!(d<=0)){for(var f=this.iconRenderer(),g=0,h=c,i=0,j=f.length;i<j;i++){var k=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(f[i])+"Icon"]();a.drawImage(k,b+g,h+this.bodyTextTopOffset+Math.ceil((this.lineHeight-k.height)/2));g+=k.width+this.iconSpacing}if(f.length>0){k=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(f[0])+"Icon"]();h+=k.height}f=a.createLinearGradient(b,c,b+d,c);i=Math.min(1,Math.max(0.1,(d-12)/d));f.addColorStop(0,this.isActive()?"black":this.colorScheme.border);
f.addColorStop(i,this.isActive()?"black":this.colorScheme.border);f.addColorStop(1,"rgba(0,0,0,0)");a.fillStyle=f;a.lineWidth=1;a.setFont("8pt Arial");g=a.drawWrappedText(this.mainRenderedText,b,c+this.lineHeight,d,this.lineHeight,e,g,h);if(g+this.lineHeight<e){a.lineWidth=1;a.setFont("8pt Arial");a.drawWrappedText(this.subRenderedText,b,c+this.lineHeight+g,d,this.lineHeight,e-g)}}},layoutInHeader:function(){this.bounds=this.parentView.dateRangeToHeaderBounds(this.getDateRange(),this.slot,1,true);
var a=this.bounds.right-this.bounds.left,b=this.bounds.bottom-this.bounds.top,c=this.parentView.getHeaderAppointmentCanvas().dom.getContext("2d");c.save();c.translate(this.bounds.left,this.bounds.top);c.lineWidth=1;var d=c.createLinearGradient(0,0,0,b);d.addColorStop(0,this.colorScheme.header);d.addColorStop(1,this.colorScheme.borderInner);c.fillStyle=d;var e=this.bounds.firstBox?this.appointmentRadius:1;d=this.bounds.lastBox?this.appointmentRadius:1;c.roundedRect2(0,0,a,b,e,d,d,e);c.fill();var f=
this.getBusyStatus(),g=this.getStripWidth(),h=c.lineWidth;if(g>0){switch(f){case Zarafa.core.mapi.BusyStatus.FREE:c.fillStyle="white";break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:c.fillStyle=c.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:c.fillStyle="purple";break}c.roundedRect2(h,h,g,b-2*h,e-h,0,0,e-h);c.fill()}c.strokeStyle=this.colorScheme.border;c.roundedRect2(h/2,h/2,a-h,b-h,e,d,d,e);c.stroke();e=this.leftPadding+
g;d=this.iconRenderer();f=0;for(g=d.length;f<g;f++){h=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(d[f])+"Icon"]();c.drawImage(h,e,4+Math.ceil((h.height-this.lineHeight)/2));e+=h.width+5}f=Math.min(1,Math.max(0.1,(a-e)/a));d=c.createLinearGradient(0,0,a,0);d.addColorStop(0,this.isActive()?"black":this.colorScheme.border);d.addColorStop(f,this.isActive()?"black":this.colorScheme.border);d.addColorStop(1,"rgba(0,0,0,0)");c.fillStyle=d;c.save();c.clip();c.lineWidth=1;c.setFont("8pt Arial");
c.drawText(this.mainRenderedText,e,b-6);e+=c.textWidth(this.mainRenderedText+" ");c.lineWidth=1;c.setFont("8pt Arial");c.drawText(this.subRenderedText,e,b-6);c.restore();this.isSelected()&&this.drawHeaderSelectionOutline(this.bounds);c.restore()},drawBodyElement:function(a,b){var c=this.getBusyStatus(),d=b.right-b.left,e=b.bottom-b.top,f=this.parentView.getRangeVerticalHeight(this.getDateRange());a.save();a.translate(b.left,b.top);a.lineWidth=1;var g=a.createLinearGradient(0,0,d,0);g.addColorStop(0,
this.colorScheme.header);g.addColorStop(1,this.colorScheme.borderInner);a.fillStyle=g;var h=b.firstBox?this.appointmentRadius:1,i=b.lastBox?this.appointmentRadius:1,j=this.getStripWidth(),k=f+1<e,m=!k&&j>0,l=k?j:0,n=l+m?j:0;a.fillStyle=g;b.firstBox?a.roundedRect2(l,0,d-l,e,k?0:h,h,i,i):a.roundedRect2(l,0,d-l,e,h,h,i,i);a.fill();if(m){switch(c){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle="white";break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),
"repeat");break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle="purple";break}a.roundedRect2(l,0,j,e,h,0,0,i);a.fill()}a.save();if(k){if(c==Zarafa.core.mapi.BusyStatus.TENTATIVE){a.fillStyle=this.colorScheme.border;a.fillRect(0,0,j,f)}switch(c){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle="white";break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle=
"purple";break}a.fillRect(0,0,j,f);a.translate(0.5,0.5);a.beginPath();a.moveTo(0,0);a.lineTo(d-1-h,0);a.arc(d-1-h,h,h,1.5*Math.PI,0*Math.PI,false);a.lineTo(d-1,e-1-i);a.arc(d-1-i,e-1-i,i,0*Math.PI,0.5*Math.PI,false);a.lineTo(i+l,e-1);a.arc(i+l,e-1-i,i,0.5*Math.PI,1*Math.PI,false);a.lineTo(l,f);a.lineTo(0,f);a.closePath()}else{c=a.lineWidth;a.roundedRect2(l+c/2,c/2,d-c,e-c,h-c/2,h-c/2,i-c/2,i-c/2)}a.strokeStyle=this.colorScheme.border;a.stroke();a.restore();c=a.lineWidth;a.roundedRect2(l+c/2,c/2,d-
c,e-c,h-c/2,h-c/2,i-c/2,i-c/2);a.clip();b.firstBox&&this.drawBodyText(a,n+this.leftPadding,this.bodyTextTopOffset,d-n-this.leftPadding,e-this.bodyTextTopOffset-this.bodyTextBottomOffset);a.restore()},drawBodyElements:function(a){for(var b=this.parentView.getBodyAppointmentCanvas().dom.getContext("2d"),c=0,d=a.length;c<d;c++)this.drawBodyElement(b,a[c]);this.isSelected()&&this.drawBodySelectionOutline(a)},layoutInBody:function(){this.bounds=this.parentView.dateRangeToBodyBounds(this.getAdjustedDateRange(),
this.slot,this.slotCount,true);Ext.isEmpty(this.bounds)||this.drawBodyElements(this.bounds)},onLayout:function(){this.mainRenderedText=Ext.util.Format.htmlDecode(this.mainTextRenderer());this.subRenderedText=Ext.util.Format.htmlDecode(this.subTextRenderer());Zarafa.calendar.ui.canvas.AppointmentView.superclass.onLayout.call(this)}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentBoxView=Ext.extend(Zarafa.calendar.ui.canvas.AppointmentView,{bounds:undefined,appointmentRadius:5,leftPadding:4,lineHeight:12,mainRenderedText:"",subRenderedText:"",setSelected:function(a){Zarafa.calendar.ui.canvas.AppointmentBoxView.superclass.setSelected.call(this,a);a&&!Ext.isEmpty(this.bounds)&&this.drawBodySelectionOutline(this.bounds)},eventOverBodyStartHandle:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b=this.bounds[0];
return this.isEventOverElement(this.getEventBodyPosition(a),{left:b.left,right:b.left+this.dragHandleWidth,top:b.top,bottom:b.bottom})},eventOverBodyDueHandle:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==0)return false;var b=this.bounds[this.bounds.length-1];return this.isEventOverElement(this.getEventBodyPosition(a),{left:b.right-this.dragHandleWidth,right:b.right,top:b.top,bottom:b.bottom})},eventOverBody:function(a){if(this.isHeaderRange()||!this.bounds||this.bounds.length==
0)return false;a=this.getEventBodyPosition(a);for(var b=0,c=this.bounds.length;b<c;b++)if(this.isEventOverElement(a,this.bounds[b]))return true;return false},layoutInHeader:Ext.emptyFn,createHeader:Ext.emptyFn,destroyHeader:Ext.emptyFn,drawBodySelectionOutline:function(a){var b=this.parentView.getBodySelectionCanvas().dom.getContext("2d");b.save();b.lineWidth=1;b.strokeStyle="black";for(var c=0,d=a.length;c<d;c++){var e=a[c],f=e.left+0.5,g=e.top+0.5,h=e.right-e.left-1,i=e.bottom-e.top-1,j=e.firstBox?
this.appointmentRadius:1,k=e.lastBox?this.appointmentRadius:1;b.roundedRect2(f,g,h,i,j,k,k,j);b.stroke();if(e.firstBox){g+=Math.ceil(i/2);this.drawDragHandle(b,f,g)}if(e.lastBox){e.firstBox||(g+=Math.ceil(i/2));this.drawDragHandle(b,f+h,g)}}b.restore()},drawBodyElement:function(a,b){var c=b.right-b.left,d=b.bottom-b.top;a.save();a.translate(b.left,b.top);a.lineWidth=1;var e=a.createLinearGradient(0,0,0,d);e.addColorStop(0,this.colorScheme.stripnormal);e.addColorStop(1,this.colorScheme.border);a.fillStyle=
e;var f=b.firstBox?this.appointmentRadius:1,g=b.lastBox?this.appointmentRadius:1;a.roundedRect2(0,0,c,d,f,g,g,f);a.fill();var h=this.getBusyStatus(),i=this.getStripWidth();switch(h){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle="white";a.roundedRect2(0,0,i,d,f,1,1,f);a.fill();break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");a.roundedRect2(0,0,i,d,f,1,1,f);a.fill();break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:e=
a.createLinearGradient(0,0,0,d);e.addColorStop(0,"#e7d7ef");e.addColorStop(1,"purple");a.fillStyle=e;a.roundedRect2(0,0,i,d,f,1,1,f);a.fill();break;default:break}a.roundedRect2(0.5,0.5,c-1,d-1,f,g,g,f);a.strokeStyle=e;if(this.isAllDay()&&h!=Zarafa.core.mapi.BusyStatus.OUTOFOFFICE)a.strokeStyle=this.colorScheme.border;a.stroke();f=this.leftPadding+i;e=this.iconRenderer();g=0;for(h=e.length;g<h;g++){i=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(e[g])+"Icon"]();a.drawImage(i,f,4+Math.ceil((this.lineHeight-
i.height)/2));f+=i.width+5}a.clip();g=Math.min(1,Math.max(0.1,(c-f)/c));e=a.createLinearGradient(0,0,c,0);e.addColorStop(0,this.isActive()?"black":this.colorScheme.border);e.addColorStop(g,this.isActive()?"black":this.colorScheme.border);e.addColorStop(1,"rgba(0,0,0,0)");a.fillStyle=e;a.lineWidth=1;a.setFont("8pt Arial");a.drawText(this.mainRenderedText,f,d-6);f+=a.textWidth(this.mainRenderedText+" ");a.lineWidth=1;a.setFont("8pt Arial");a.drawText(this.subRenderedText,f,d-6);a.restore()},drawBodyElements:function(a){for(var b=
this.parentView.getBodyAppointmentCanvas().dom.getContext("2d"),c=0,d=a.length;c<d;c++)this.drawBodyElement(b,a[c]);this.isSelected()&&this.drawBodySelectionOutline(a)},layoutInBody:function(){this.bounds=this.parentView.dateRangeToBodyBounds(this.getDateRange(),this.slot,undefined,true);Ext.isEmpty(this.bounds)||this.drawBodyElements(this.bounds)},onLayout:function(){this.mainRenderedText=Ext.util.Format.htmlDecode(this.mainTextRenderer());this.subRenderedText=Ext.util.Format.htmlDecode(this.subTextRenderer());
Zarafa.calendar.ui.canvas.AppointmentBoxView.superclass.onLayout.call(this)}});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.MemberBoxField=Ext.extend(Zarafa.common.recipientfield.ui.RecipientField,{constructor:function(a){a=a||{};Ext.applyIf(a,{boxType:"zarafa.memberbox",enableComboBox:false,editable:true,height:30});Ext.apply(a,{defaultRecipientType:undefined,filterRecipientType:undefined});Zarafa.addressbook.ui.MemberBoxField.superclass.constructor.call(this,a)},setMemberStore:function(){return this.setBoxStore.apply(this,arguments)},getMemberStore:function(){return this.getBoxStore()},filterRecord:function(){return true},
handleInput:function(a){a=a.split(this.delimiterCharacter);for(var b=[],c=0;c<a.length;c++){var d=a[c].trim();if(!Ext.isEmpty(d)){d=this.boxStore.parseMember(d);b.push(d)}}b.length>0&&this.boxStore.add(b)},onBoxDblClick:function(a,b,c){b.isValidRecord(c)&&Zarafa.contact.Actions.openDistlistMember(c)},onBoxContextMenu:Ext.emptyFn});Ext.reg("zarafa.memberboxfield",Zarafa.addressbook.ui.MemberBoxField);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookBoxField=Ext.extend(Zarafa.common.recipientfield.ui.RecipientField,{constructor:function(a){a=a||{};Ext.applyIf(a,{boxType:"zarafa.addressbookbox",enableComboBox:false,editable:true,height:30});Zarafa.addressbook.ui.AddressBookBoxField.superclass.constructor.call(this,a)}});Ext.reg("zarafa.addressbookboxfield",Zarafa.addressbook.ui.AddressBookBoxField);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookSubStore=Ext.extend(Zarafa.addressbook.AddressBookStore,{parentRecord:null,constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER);Ext.applyIf(a,{reader:new Zarafa.core.data.JsonReader({root:"item"},b)});Zarafa.addressbook.AddressBookSubStore.superclass.constructor.call(this,a)},getParentRecord:function(){return this.parentRecord},setParentRecord:function(a){this.parentRecord=a}});Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookResponseHandler=Ext.extend(Zarafa.core.data.IPMResponseHandler,{doList:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")}});Ext.namespace("Zarafa.common.freebusy.ui");
Zarafa.common.freebusy.ui.UserListView=Ext.extend(Zarafa.common.recipientfield.ui.RecipientList,{model:null,constructor:function(a){a=a||{};Ext.applyIf(a,{boxType:"zarafa.userlistbox",wrapCls:"x-form-text x-zarafa-boxfield x-freebusy-userlist-container",border:true});Zarafa.common.freebusy.ui.UserListView.superclass.constructor.call(this,a);if(this.model){this.setRecipientStore(this.model.getUserStore());this.mon(this.model,"userstorechange",this.onUserStoreChange,this)}},onUserStoreChange:function(a){this.setRecipientStore(a)},
filterRecords:function(a,b){for(var c=[],d=0,e=b.length;d<e;d++){var f=b[d];if(!Ext.isDefined(this.filterRecipientType)||f.get("recipient_type")===this.filterRecipientType)c.push(f)}return c},doBoxRemove:function(a){a.record.isMeetingOrganizer()||Zarafa.common.freebusy.ui.UserListView.superclass.doBoxRemove.apply(this,arguments)},onBoxContextMenu:function(a,b,c){Zarafa.common.Actions.openRecord(Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy"],c,{position:b.getEl().getXY(),editable:b.editable})}});
Ext.reg("zarafa.freebusyuserlistview",Zarafa.common.freebusy.ui.UserListView);Ext.namespace("Zarafa.task");
Zarafa.task.TaskRecordFields=[{name:"importance",type:"int",defaultValue:Zarafa.core.mapi.Importance.NORMAL},{name:"message_flags",type:"int",defaultValue:Zarafa.core.mapi.MessageFlags.MSGFLAG_READ},{name:"last_modification_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"recurring",type:"boolean"},{name:"startdate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"duedate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"commonstart",type:"date",dateFormat:"timestamp",
defaultValue:null},{name:"commonend",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"taskstate",type:"int",defaultValue:Zarafa.core.mapi.TaskState.NORMAL},{name:"taskmode",type:"int",defaultValue:Zarafa.core.mapi.TaskMode.NOTHING},{name:"tasksoc",type:"boolean",defaultValue:true},{name:"taskupdates",type:"boolean",defaultValue:true},{name:"reminder",type:"boolean",defaultValue:false},{name:"reminderdate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"owner"},{name:"status",
type:"int",defaultValue:Zarafa.core.mapi.TaskStatus.NOT_STARTED},{name:"percent_complete",type:"float",defaultValue:0},{name:"complete",type:"boolean",defaultValue:false},{name:"sensitivity",type:"int",defaultValue:Zarafa.core.mapi.Sensitivity.NONE},{name:"private",type:"boolean",defaultValue:false},{name:"totalwork",type:"int",defaultValue:0},{name:"actualwork",type:"int",defaultValue:0},{name:"mileage"},{name:"billing_information"},{name:"companies"},{name:"date_completed",type:"date",dateFormat:"timestamp",
defaultValue:null},{name:"reminder",type:"boolean",defaultValue:false},{name:"reminder_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"flagdueby",type:"date",dateFormat:"timestamp",defaultValue:null}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Task",Zarafa.task.TaskRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Task","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Task","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.TaskRequest",Zarafa.task.TaskRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.TaskRequest",Zarafa.core.data.MessageRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.TaskRequest","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.TaskRequest","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.TaskRequest","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Task","createphantom",function(a){a.beginEdit();a.set("reminder",container.getSettingsModel().get("zarafa/v1/contexts/task/default_reminder"));if(a.get("reminder")){var b=(new Date).clearTime().add(Date.MINUTE,container.getSettingsModel().get("zarafa/v1/contexts/task/default_reminder_time"));a.set("reminder_time",b)}a.endEdit()});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Task",Zarafa.core.data.MessageRecord);
Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.TaskRequest",Zarafa.core.data.MessageRecord);Ext.namespace("Zarafa.mail");
Zarafa.mail.MailRecordFields=[{name:"importance",type:"int",defaultValue:Zarafa.core.mapi.Importance.NORMAL},{name:"private",type:"boolean",defaultValue:false},{name:"sensitivity",type:"int",defaultValue:Zarafa.core.mapi.Sensitivity.NONE},{name:"read_receipt_requested",type:"boolean",defaultValue:false},{name:"flag_status"},{name:"flag_icon"},{name:"reply_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"reply_requested"},{name:"response_requested"},{name:"reminder_set",type:"boolean",
defaultValue:false},{name:"reminder_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"flag_request"},{name:"flag_due_by",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"flag_complete_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"block_status",type:"int",defaultValue:undefined},{name:"stubbed",type:"boolean",defaultValue:false}];
Zarafa.mail.MailRecordPhantomHandler=function(a){var b=container.getSettingsModel().get("zarafa/v1/contexts/mail/always_request_readreceipt");a.set("read_receipt_requested",b)};Zarafa.core.data.RecordFactory.addFieldToMessageClass("REPORT.IPM.Note",Zarafa.mail.MailRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("REPORT.IPM.Note",Zarafa.core.data.MessageRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("REPORT.IPM.Note","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("REPORT.IPM.Note","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Note",Zarafa.mail.MailRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Note",Zarafa.core.data.MessageRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Note","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Note","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Schedule",Zarafa.mail.MailRecordFields);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Note","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Note","createphantom",Zarafa.mail.MailRecordPhantomHandler);
Zarafa.core.data.RecordFactory.addDefaultValueToMessageClass("IPM.Note","message_flags",Zarafa.core.mapi.MessageFlags.MSGFLAG_UNSENT);Zarafa.core.data.RecordFactory.addDefaultValueToMessageClass("REPORT.IPM.Note","message_flags",Zarafa.core.mapi.MessageFlags.MSGFLAG_UNSENT);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("REPORT.IPM.Note",Zarafa.core.data.MessageRecord);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Note",Zarafa.core.data.MessageRecord);Ext.namespace("Zarafa.contact");
Zarafa.contact.DistListRecordFields=[{name:"fileas"},{name:"dl_name"},{name:"subject"},{name:"display_name"},{name:"sensitivity",type:"int",defaultValue:Zarafa.core.mapi.Sensitivity.NONE},{name:"address_type",type:"string",defaultValue:"SMTP"},{name:"private",type:"boolean",defaultValue:false}];
Zarafa.contact.DistlistRecord=Ext.extend(Zarafa.core.data.IPMRecord,{convertToRecipient:function(a){return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{object_type:Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,display_name:this.get("display_name"),email_address:this.get("fileas"),address_type:"SMTP",recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO})},convertToDistlistMember:function(){return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,
{entryid:this.get("entryid"),address_type:"ZARAFA",email_address:this.get("display_name"),distlist_type:Zarafa.core.mapi.DistlistType.DL_DIST,display_name:this.get("display_name")})},supportsMembers:function(){return this.supportsSubStore("members")},createMemberStore:function(){return this.createSubStore("members")},setMemberStore:function(a){return this.setSubStore("members",a)},getMemberStore:function(){return this.getSubStore("members")}});
Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.DistList",Zarafa.contact.DistListRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.DistList","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.DistList","members",Zarafa.contact.DistlistMemberStore);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.DistList",Zarafa.contact.DistlistRecord);Ext.namespace("Zarafa.calendar");
Zarafa.calendar.AppointmentRecordFields=[{name:"importance",type:"int",defaultValue:Zarafa.core.mapi.Importance.NORMAL},{name:"sensitivity",type:"int",defaultValue:Zarafa.core.mapi.Sensitivity.NONE},{name:"startdate",type:"date",dateFormat:"timestamp",allowBlank:false},{name:"duedate",type:"date",dateFormat:"timestamp",allowBlank:false},{name:"basedate",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"recurring",type:"boolean",defaultValue:false},{name:"recurring_reset",type:"boolean",
defaultValue:false},{name:"recurring_pattern",type:"string"},{name:"startdate_recurring",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"enddate_recurring",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"exception",type:"boolean",defaultValue:false},{name:"reply_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"busystatus",type:"int",defaultValue:Zarafa.core.mapi.BusyStatus.FREE},{name:"label",type:"int",defaultValue:Zarafa.core.mapi.AppointmentLabels.NONE},
{name:"request_sent",type:"boolean",defaultValue:false},{name:"alldayevent",type:"boolean",defaultValue:false},{name:"private",type:"boolean",defaultValue:false},{name:"meeting",type:"int",defaultValue:Zarafa.core.mapi.MeetingStatus.NONMEETING},{name:"location",type:"string"},{name:"duration",type:"int"},{name:"responsestatus",type:"int",defaultValue:Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE},{name:"reminder",type:"boolean"},{name:"reminder_minutes",type:"int"},{name:"reminder_time",type:"date",
dateFormat:"timestamp",defaultValue:null},{name:"flagdueby",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"commonstart",type:"date",dateFormat:"timestamp",allowBlank:false},{name:"commonend",type:"date",dateFormat:"timestamp",allowBlank:false},{name:"commonassign"},{name:"counter_proposal",type:"boolean",defaultValue:false},{name:"recurrence_type",mapping:"type",type:"int",forceProtocol:true},{name:"recurrence_subtype",mapping:"subtype",type:"int",forceProtocol:true},{name:"recurrence_everyn",
mapping:"everyn",type:"int",forceProtocol:true},{name:"recurrence_regen",mapping:"regen",type:"int",forceProtocol:true},{name:"recurrence_weekdays",mapping:"weekdays",type:"int",forceProtocol:true},{name:"recurrence_month",mapping:"month",type:"int",forceProtocol:true},{name:"recurrence_monthday",mapping:"monthday",type:"int",forceProtocol:true},{name:"recurrence_nday",mapping:"nday",type:"int",forceProtocol:true},{name:"recurrence_term",mapping:"term",type:"int",forceProtocol:true},{name:"recurrence_numoccur",
mapping:"numoccur",type:"int",forceProtocol:true},{name:"recurrence_numexcept",mapping:"numexcept",type:"int",forceProtocol:true},{name:"recurrence_numexceptmod",mapping:"numexceptmod",type:"int",forceProtocol:true},{name:"recurrence_start",mapping:"start",type:"date",dateFormat:"timestamp",forceProtocol:true,defaultValue:null},{name:"recurrence_end",mapping:"end",type:"date",dateFormat:"timestamp",forceProtocol:true,defaultValue:null},{name:"recurrence_startocc",mapping:"startocc",type:"int",forceProtocol:true},
{name:"recurrence_endocc",mapping:"endocc",type:"int",forceProtocol:true},{name:"timezone",type:"int",forceProtocol:true},{name:"timezone_unk",mapping:"unk",type:"int",forceProtocol:true},{name:"timezone_timezonedst",mapping:"timezonedst",type:"int",forceProtocol:true},{name:"timezone_dstendmonth",mapping:"dstendmonth",type:"int",forceProtocol:true},{name:"timezone_dstendweek",mapping:"dstendweek",type:"int",forceProtocol:true},{name:"timezone_dstendday",mapping:"dstendday",type:"int",forceProtocol:true},
{name:"timezone_dstendhour",mapping:"dstendhour",type:"int",forceProtocol:true},{name:"timezone_dststartmonth",mapping:"dststartmonth",type:"int",forceProtocol:true},{name:"timezone_dststartweek",mapping:"dststartweek",type:"int",forceProtocol:true},{name:"timezone_dststartday",mapping:"dststartday",type:"int",forceProtocol:true},{name:"timezone_dststarthour",mapping:"dststarthour",type:"int",forceProtocol:true}];
Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}",Zarafa.calendar.AppointmentRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}",Zarafa.core.data.MessageRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Appointment",Zarafa.calendar.AppointmentRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Appointment",Zarafa.core.data.MessageRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Appointment","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Appointment","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Appointment","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Appointment","createphantom",function(a){a.beginEdit();a.set("reminder",container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_reminder"));a.set("reminder_minutes",container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_reminder_time"));a.endEdit()});
Zarafa.calendar.AppointmentRecord=Ext.extend(Zarafa.core.data.MessageRecord,{baseIdProperties:["entryid","store_entryid","parent_entryid","basedate"],equals:function(a){if(Zarafa.calendar.AppointmentRecord.superclass.equals.apply(this,arguments)===true)return!this.get("recurring")||this.get("basedate")===a.get("basedate");return false},generateRecurringPattern:function(){var a=this.get("recurrence_type"),b=this.get("recurrence_everyn"),c=this.get("recurrence_start"),d=this.get("recurrence_end"),e=
this.get("recurrence_term"),f=this.get("recurrence_numoccur"),g=this.get("recurrence_startocc"),h=this.get("recurrence_endocc"),i=undefined,j=false,k=g!=0&&h!=0;switch(a){case Zarafa.common.recurrence.data.RecurrenceType.DAILY:if(b==1){a=_("workday");j=true}else if(b==1440){a=_("day");j=true}else{b/=1440;a=_("days");j=false}break;case Zarafa.common.recurrence.data.RecurrenceType.WEEKLY:if(b==1){a=_("week");j=true}else{a=_("weeks");j=false}break;case Zarafa.common.recurrence.data.RecurrenceType.MONTHLY:if(b==
1){a=_("month");j=true}else{a=_("months");j=false}break;case Zarafa.common.recurrence.data.RecurrenceType.YEARLY:if(b<=12){b=1;a=_("year");j=true}else{b/=12;a=_("years");j=false}break}var m=c.clone();m.setHours(g/60);m.setMinutes(g%60);g=m.format(_("G:i"));m.setHours(h/60);m.setMinutes(h%60);h=m.format(_("G:i"));c=c.format(_("d/m/Y"));d=d.format(_("d/m/Y"));if(e==Zarafa.common.recurrence.data.RecurrenceEnd.NEVER)i=k?j?String.format(_("Occurs every {0} effective {1} from {2} to {3}."),a,c,g,h):String.format(_("Occurs every {0} {1} effective {2} from {3} to {4}."),
b,a,c,g,h):j?String.format(_("Occurs every {0} effective {1}."),a,c):String.format(_("Occurs every {0} {1} effective {2}."),b,a,c);else if(e==Zarafa.common.recurrence.data.RecurrenceEnd.N_OCCURENCES)i=k?j?String.format(ngettext("Occurs every {0} effective {1} for {2} occurence from {3} to {4}.","Occurs every {0} effective {1} for {2} occurences from {3} to {4}.",f),a,c,f,g,h):String.format(ngettext("Occurs every {0} {1} effective {2} for {3} occurence from {4} to {5}.","Occurs every {0} {1} effective {2} for {3} occurences {4} to {5}.",
f),b,a,c,f,g,h):j?String.format(ngettext("Occurs every {0} effective {1} for {2} occurence.","Occurs every {0} effective {1} for {2} occurences.",f),a,c,f):String.format(ngettext("Occurs every {0} {1} effective {2} for {3} occurence.","Occurs every {0} {1} effective {2} for {3} occurences.",f),b,a,c,f);else if(e==Zarafa.common.recurrence.data.RecurrenceEnd.ON_DATE)i=k?j?String.format(_("Occurs every {0} effective {1} until {2} from {3} to {4}."),a,c,d,g,h):String.format(_("Occurs every {0} {1} effective {2} until {3} from {4} to {5}."),
b,a,c,d,g,h):j?String.format(_("Occurs every {0} effective {1} until {2}."),a,c,d):String.format(_("Occurs every {0} {1} effective {2} until {3}."),b,a,c,d);return i},generateMeetingTimeInfo:function(a){a=a||"";var b=this.get("startdate"),c=this.get("duedate"),d=this.get("location")||"",e=this.get("recurring_pattern")||"",f=_("When")+": ";if(e)f+=e+"\n";else{f+=b.format(_("l jS F Y G:i"))+" - ";f+=c.format(_("l jS F Y G:i"))+"\n"}f+=_("Where")+": "+d+"\n\n";f+="*~*~*~*~*~*~*~*~*~*\n\n"+a;return f},
sendMeetingRequestResponse:function(a,b,c){if(Ext.isDefined(a)){switch(a){case Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE:case Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED:this.addMessageAction("action_type","acceptMeetingRequest");break;case Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED:this.addMessageAction("action_type","declineMeetingRequest");break}this.addMessageAction("responseType",a);this.addMessageAction("meetingTimeInfo",b);this.addMessageAction("sendResponse",c);this.getStore().save(this)}},
respondToMeetingRequest:function(a,b,c){this.sendMeetingRequestResponse(a,this.generateMeetingTimeInfo(b),c)},proposeNewTimeToMeetingRequest:function(a,b,c,d){this.set("counter_proposal",true);this.addMessageAction("proposed_starttime",c);this.addMessageAction("proposed_endtime",d);this.sendMeetingRequestResponse(a,this.generateProposeNewTimeBody(b,c,d),true)},generateProposeNewTimeBody:function(a,b,c){a=a+"\n\n\n-----------\n"+_("New Meeting Time Proposed")+" :\n";a+=b.format(_("l jS F Y G:i"))+
" - ";a+=c.format(_("l jS F Y G:i"))+"\n";return a},cancelInvitation:function(a){this.addMessageAction("action_type","cancelInvitation");this.addMessageAction("meetingTimeInfo",this.generateMeetingTimeInfo(a));a=this.getStore();a.remove(this);a.save(this)},declineMeeting:function(a){var b=this.getStore();a&&this.addMessageAction("action_type","declineMeeting");b.remove(this);b.save(this)},isAppointmentInPast:function(){var a=this.get("duedate");if(this.isRecurring())if(!this.isRecurringOccurence()&&
!this.isRecurringException())a=this.get("enddate_recurring");if(Ext.isDate(a)&&a.getTime()<(new Date).getTime())return true;return false},isMeetingSent:function(){return this.isMeetingOrganized()&&this.get("request_sent")===true},isMeetingReceived:function(){return this.get("meeting")===Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED&&this.get("responsestatus")!==Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED},isMeetingOrganized:function(){return this.get("meeting")===Zarafa.core.mapi.MeetingStatus.MEETING&&
this.get("responsestatus")===Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED},isMeeting:function(){var a=this.get("meeting");return a&&a!==Zarafa.core.mapi.MeetingStatus.NONMEETING},isMeetingCanceled:function(){var a=this.get("meeting");return a===Zarafa.core.mapi.MeetingStatus.MEETING_CANCELED||a===Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED_AND_CANCELED},isMeetingReceivedAndCanceled:function(){return this.get("meeting")===Zarafa.core.mapi.MeetingStatus.MEETING_RECEIVED_AND_CANCELED&&this.get("responsestatus")!==
Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED},isMeetingResponseRequired:function(){return this.isMeetingReceived()&&this.get("responsestatus")!==Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE},isRecurring:function(){return this.get("recurring")===true},isRecurringOccurence:function(){return this.get("recurring")===true&&Ext.isDate(this.get("basedate"))},isRecurringException:function(){return this.get("recurring")===true&&this.get("exception")===true},hasRecurringExceptions:function(){if(this.isOpened()){if(!this.isRecurring()||
this.isRecurringOccurence()||this.isRecurringException())return false;var a=this.getSubStore("attachments");if(!a)return false;return a.findBy(function(b){return b.isRecurrenceException()})>=0}},afterOpen:function(){if(this.isRecurring()&&this.hasIdProp("basedate")===false){this.modified=this.modified||{};this.modified.startdate=this.get("startdate");this.modified.duedate=this.get("duedate");this.modified.basedate=this.get("basedate");if(this.trackUpdateModifications===true){this.updateModifications=
this.updateModifications||{};this.updateModifications.startdate=this.get("startdate");this.updateModifications.duedate=this.get("duedate");this.updateModifications.basedate=this.get("basedate")}}Zarafa.calendar.AppointmentRecord.superclass.afterOpen.call(this);this.opened=!this.isRecurring()||this.hasIdProp("basedate");this.openedSeries=!this.opened;this.updateMeetingRecipients()},isOpened:function(){return!this.isRecurring()||this.hasIdProp("basedate")?this.opened===true:this.openedSeries===true},
addMessageAction:function(a){Zarafa.calendar.AppointmentRecord.superclass.addMessageAction.apply(this,arguments);a==="send"&&this.addMessageAction("meetingTimeInfo",this.generateMeetingTimeInfo(this.getBody()))},afterEdit:function(){this.isMeeting()&&this.hasMessageAction("send")&&this.addMessageAction("meetingTimeInfo",this.generateMeetingTimeInfo(this.getBody()));Zarafa.calendar.AppointmentRecord.superclass.afterEdit.apply(this,arguments)},updateTimezoneInformation:function(){var a=Date.getTimezoneStruct();
this.beginEdit();this.set("timezone",a.timezone);this.set("timezone_timezonedst",a.timezonedst);this.set("timezone_dstendmonth",a.dstendmonth);this.set("timezone_dstendweek",a.dstendweek);this.set("timezone_dstendday",a.dstendday);this.set("timezone_dstendhour",a.dstendhour);this.set("timezone_dststartmonth",a.dststartmonth);this.set("timezone_dststartweek",a.dststartweek);this.set("timezone_dststartday",a.dststartday);this.set("timezone_dststarthour",a.dststarthour);this.endEdit()},updateMeetingRecipients:function(){var a=
this.getSubStore("recipients");if(Ext.isDefined(a))if(this.isMeeting()){if(a.findBy(function(c){if(c.isMeetingOrganizer())return true},this)<0){var b={recipient_type:Zarafa.core.mapi.RecipientType.MAPI_ORIG,recipient_flags:Zarafa.core.mapi.RecipientFlags.recipSendable|Zarafa.core.mapi.RecipientFlags.recipOrganizer,recipient_trackstatus:Zarafa.core.mapi.RecipientTrackStatus.RECIPIENT_TRACKSTATUS_NONE};this.get("sent_representing_entryid")?Ext.apply(b,{display_name:this.get("sent_representing_name"),
smtp_address:this.get("sent_representing_email_address"),address_type:this.get("sent_representing_address_type"),entryid:this.get("sent_representing_entryid")}):Ext.apply(b,{display_name:this.get("sender_name"),smtp_address:this.get("sender_email_address"),address_type:this.get("sender_address_type"),entryid:this.get("sender_entryid")});b=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,b,-1);a.insert(0,b)}}else a.getCount()>0&&
a.removeAll()},convertToOccurenceRecord:function(){if(this.hasIdProp("basedate")===false){var a=this.copy();a.addIdProp("basedate");if(!a.userIsStoreOwner()){var b=container.getHierarchyStore().getByEntryId(a.get("store_entryid"));b&&a.setDelegatorInfo(b,true)}return a}return this},convertToSeriesRecord:function(){if(this.hasIdProp("basedate")===true){var a=this.copy();a.set("basedate","");a.set("exception",false);a.removeIdProp("basedate");return a}return this}});
Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Appointment",Zarafa.calendar.AppointmentRecord);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}",Zarafa.calendar.AppointmentRecord);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookRecordFields=[{name:"entryid"},{name:"search_key"},{name:"fileas"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER},{name:"display_type",type:"int",defaultValue:Zarafa.core.mapi.DisplayType.DT_MAILUSER},{name:"display_type_ex",type:"int",defaultValue:Zarafa.core.mapi.DisplayType.DT_MAILUSER},{name:"address_type"},{name:"email_address"},{name:"smtp_address"},{name:"given_name"},{name:"initials"},{name:"surname"},{name:"display_name"},
{name:"account"},{name:"street_address"},{name:"locality"},{name:"state_or_province"},{name:"postal_code"},{name:"country"},{name:"title"},{name:"company_name"},{name:"department_name"},{name:"office_location"},{name:"assistant"},{name:"office_telephone_number"},{name:"business_telephone_number"},{name:"business2_telephone_number"},{name:"business2_telephone_number_mv"},{name:"primary_fax_number"},{name:"home_telephone_number"},{name:"home2_telephone_number"},{name:"home2_telephone_number_mv"},{name:"mobile_telephone_number"},
{name:"pager_telephone_number"},{name:"comment"}];Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,Zarafa.addressbook.AddressBookRecordFields);Zarafa.core.data.RecordFactory.addFieldToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,Zarafa.addressbook.AddressBookRecordFields);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"ems_ab_manager",Zarafa.addressbook.AddressBookSubStore);
Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"ems_ab_proxy_addresses",Zarafa.addressbook.AddressBookEmailAddressesSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"ems_ab_is_member_of_dl",Zarafa.addressbook.AddressBookSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"ems_ab_reports",Zarafa.addressbook.AddressBookSubStore);
Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"home2_telephone_numbers",Zarafa.addressbook.AddressBookTelephoneNumberSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"business2_telephone_numbers",Zarafa.addressbook.AddressBookTelephoneNumberSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,"ems_ab_owner",Zarafa.addressbook.AddressBookSubStore);
Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,"ems_ab_proxy_addresses",Zarafa.addressbook.AddressBookEmailAddressesSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,"ems_ab_is_member_of_dl",Zarafa.addressbook.AddressBookSubStore);Zarafa.core.data.RecordFactory.setSubStoreToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,"members",Zarafa.addressbook.AddressBookSubStore);
Zarafa.core.data.RecordFactory.addListenerToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,"createphantom",function(a){a.afterOpen()});Zarafa.core.data.RecordFactory.addListenerToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,"createphantom",function(a){a.afterOpen()});
Zarafa.addressbook.AddressBookRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{convertToRecipient:function(a){return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{entryid:this.get("entryid"),object_type:this.get("object_type"),display_name:this.get("display_name"),display_type:this.get("display_type"),display_type_ex:this.get("display_type_ex"),email_address:this.get("email_address"),smtp_address:this.get("smtp_address"),address_type:this.get("address_type"),
recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO})},convertToDistlistMember:function(){var a=Zarafa.core.mapi.DistlistType.DL_USER_AB;if(this.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_DISTLIST)a=Zarafa.core.mapi.DistlistType.DL_DIST_AB;a={entryid:this.get("entryid"),address_type:this.get("address_type"),distlist_type:a,display_name:this.get("display_name"),email_address:this.get("email_address")||this.get("smtp_address")};return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DISTLIST_MEMBER,
a)},convertToUserPermission:function(){return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_USER_PERMISSION,{entryid:this.get("entryid"),display_name:this.get("display_name"),object_type:this.get("object_type"),rights:Zarafa.core.mapi.Rights.RIGHTS_NO_RIGHTS})},convertToDelegate:function(){var a={entryid:this.get("entryid"),display_name:this.get("display_name")};return Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_DELEGATE,
a)},equals:function(a){return Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("entryid"))}});Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,Zarafa.addressbook.AddressBookRecord);Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,Zarafa.addressbook.AddressBookRecord);Ext.namespace("Zarafa.calendar");
Zarafa.calendar.MeetingRequestRecordFields=[{name:"conflictinfo"},{name:"appointment_not_found",type:"boolean",defaultValue:false},{name:"counter_proposal",type:"boolean",defaultValue:false},{name:"meetingtype",type:"number",defaultValue:Zarafa.core.mapi.MeetingType.MEETING_NONE},{name:"proposed_start_date",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"proposed_end_date",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"proposed_duration",type:"number"},{name:"appointment_entryid"},
{name:"appointment_store_entryid"},{name:"appointment_parent_entryid"},{name:"appointment_basedate",type:"date",dateFormat:"timestamp"},{name:"appointment_duedate",type:"date",dateFormat:"timestamp"},{name:"appointment_startdate",type:"date",dateFormat:"timestamp"},{name:"appointment_recurring",type:"boolean"},{name:"appointment_recurring_pattern",type:"string"},{name:"appointment_startdate_recurring",type:"date",dateFormat:"timestamp"},{name:"appointment_enddate_recurring",type:"date",dateFormat:"timestamp"},
{name:"appointment_exception",type:"boolean",defaultValue:false},{name:"appointment_location",type:"string"},{name:"updatecounter",type:"int",defaultValue:0},{name:"meeting_updated",type:"boolean",defaultValue:false},{name:"goid",type:"string"},{name:"goid2",type:"string"}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Schedule",Zarafa.calendar.MeetingRequestRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Schedule",Zarafa.core.data.MessageRecordFields);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Schedule","recipients",Zarafa.core.data.IPMRecipientStore);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.Schedule","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Schedule","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.calendar.MeetingRequestRecord=Ext.extend(Zarafa.calendar.AppointmentRecord,{isMeetingRequestResponse:function(){return this.isMessageClass("IPM.Schedule.Meeting.Resp",true)},isMeetingRequestCanceled:function(){return this.isMessageClass("IPM.Schedule.Meeting.Canceled",true)},isMeetingRequest:function(){return this.isMessageClass("IPM.Schedule.Meeting.Request",true)},isRecurring:function(){return this.get("appointment_recurring")===true},isRecurringOccurence:function(){return this.get("appointment_recurring")===
true&&Ext.isDate(this.get("appointment_basedate"))},isRecurringException:function(){return this.get("appointment_recurring")===true&&this.get("appointment_exception")===true},isMeetingOutOfDate:function(){return this.get("meetingtype")===Zarafa.core.mapi.MeetingType.MEETING_OUT_OF_DATE},generateMeetingTimeInfo:function(a){a=a||"";var b=this.get("appointment_startdate"),c=this.get("appointment_duedate"),d=this.get("appointment_location")||"",e=this.get("appointment_recurring_pattern")||"",f=_("When")+
": ";if(e)f+=e+"\n";else{f+=b.format(_("l jS F Y G:i"))+" - ";f+=c.format(_("l jS F Y G:i"))+"\n"}f+=_("Where")+": "+d+"\n\n";f+="*~*~*~*~*~*~*~*~*~*\n\n"+a;return f},convertToAppointmentRecord:function(a){var b=this.get("appointment_entryid"),c=this.get("appointment_parent_entryid"),d=this.get("appointment_store_entryid"),e=this.get("appointment_basedate");if(!(Ext.isEmpty(b)||Ext.isEmpty(d))){Ext.isBoolean(a)||(a=true);return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Appointment",
{entryid:b,object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,store_entryid:d,parent_entryid:c,basedate:e,counter_proposal:a,meeting:Zarafa.core.mapi.MeetingStatus.MEETING,responsestatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED,startdate:this.get("appointment_startdate"),duedate:this.get("appointment_duedate")},b)}},updateMeetingRecipients:Ext.emptyFn});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Schedule",Zarafa.calendar.MeetingRequestRecord);
