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.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(){var a=new Date(this.getTime()+this.getTimezoneOffset()*6E4);a.setMilliseconds(a.getMilliseconds()+Date.getDSTDiff(a,this));return a},fromUTC:function(){return 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)},getNextWorkWeekDay:function(a){a=a||new Date;a=a.getNextWeekDay();return container.getSettingsModel().get("zarafa/v1/main/working_days").indexOf(a.getDay())>-1?a:this.getNextWorkWeekDay(a)},clearSeconds:function(a){if(a)return this.clone().clearSeconds();this.setSeconds(0);this.setMilliseconds(0);return this},round:function(a,b){var c;switch(a){case Date.MILLI: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){var c;switch(a){case Date.MILLI: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){var c;switch(a){case Date.MILLI: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();d=d-e;switch(a){case Date.DAY:d-=Date.getDSTDiff(b,c);d/=24;case Date.HOUR:d/=60;case Date.MINUTE:d/=60;case Date.SECOND:d/=1E3;case Date.MILLI:default:break}return d},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}});
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.applyIf(String,{rightPad:function(a,b,c){a=String(a);for(c||(c=" ");a.length<b;)a+=c;return a}});Ext.namespace("Zarafa");
Ext.apply(Zarafa,{isReady:false,readyEvent:new Ext.util.Event,idleTime:0,onReady:function(a,b,c){this.readyEvent.addListener(a,b,c);this.isReady&&this.fireReady()},fireReady:function(){this.isReady=true;this.readyEvent.fire();this.readyEvent.clearListeners()},initializeGlobals:function(){Ext.USE_NATIVE_JSON=true;Zarafa.core.Util.enableLeaveRequester();window.onunload=function(){container.getRequest().paralyze(Zarafa.core.data.ParalyzeReason.BROWSER_RELOADING)};container=new Zarafa.core.Container;
container.getSettingsModel().initialize(settings);delete settings;container.setServerConfig(serverconfig);delete serverconfig;container.setUser(user);delete user;container.setVersion(version);delete version;container.setLanguages(languages);delete languages},initializeEnvironment:function(){Ext.state.Manager.setProvider(new Zarafa.core.data.SettingsStateProvider);Ext.getBody().on("contextmenu",this.onBodyContextMenu,this);Ext.EventManager.on(window,"dragover",this.onWindowDragDrop,this);Ext.EventManager.on(window,
"drop",this.onWindowDragDrop,this);container.getRequest().on("connectionparalyzed",this.onConnectionParalyze,this);container.getRequest().on("connectioninterrupted",this.onConnectionLoss,this);container.getRequest().on("connectionrestored",this.onConnectionRestore,this);container.getResponseRouter().on("receiveexception",this.onReceiveException,this);Ext.data.DataProxy.on("exception",this.onException,this);Ext.QuickTips.init()},onBodyContextMenu:function(a,b){Ext.get(b).hasClass("zarafa-contextmenu-enabled")||
a.preventDefault()},onWindowDragDrop:function(a){a.stopPropagation();a.preventDefault();return false},onException:function(a,b,c,d,e,f){if(b==="response")if(Ext.isDefined(f)&&f.error instanceof Error)a=f.error.toString();else{this.onReceiveException(d,e);return}else if(e&&e.error)switch(e.error.type){case Zarafa.core.ErrorType.MAPI:case Zarafa.core.ErrorType.ZARAFA:case Zarafa.core.ErrorType.GENERAL:a=e.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.");Ext.get("loading")?this.setErrorLoadingMask(_("Error"),a):container.getNotifier().notify("error.proxy",_("Error"),a)},onConnectionParalyze:function(a,b){var c="",d=Ext.emptyFn;switch(b){case Zarafa.core.data.ParalyzeReason.BROWSER_RELOADING:default:return;case Zarafa.core.data.ParalyzeReason.SESSION_EXPIRED:c=_("The session has expired, reauthentication is required.");d=container.logout.createDelegate(container,[true],false);
break;case Zarafa.core.data.ParalyzeReason.SESSION_INVALID:c=_("The session in the current browser window has been closed from another browser window or tab.");d=container.logout.createDelegate(container,[true,true],false);break}Ext.get("loading")?this.setErrorLoadingMask(_("Error"),c):Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:c+"<br>"+_("Do you wish to be redirected to the logon page?"),icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.YESNO,fn:this.onConnectionParalyzeConfirmation,scope:this,
logoutFn:d})},onConnectionParalyzeConfirmation:function(a,b,c){a==="yes"?c.logoutFn.call(this):container.getNotifier().notify("error.connection",_("Session expired"),_("Reauthentication required, click here to go to back to logon page."),{persistent:true,listeners:{click:c.logoutFn}})},onConnectionTimeupdate:function(a,b,c){var d=container.getRequest();if(!(!d.isInterrupted()||d.isParalyzed())){this.connEl=container.getNotifier().notify("error.connection",_("Connection problem"),String.format(_("Could not connect to server, retrying in {0} second(s)"),
c/1E3)+"<br />"+_("Click to retry now"),{persistent:true,update:!!this.connEl,reference:this.connEl,listeners:{click:a.retry,scope:a}});c>1E3&&this.connElTask.delay(1E3,this.onConnectionTimeupdate,this,[a,b,c-1E3])}},onConnectionRetry:function(a,b,c){this.connElTask.cancel();this.onConnectionTimeupdate(a,b,c)},onConnectionLoss:function(a,b){this.connElTask=new Ext.util.DelayedTask(this.onConnectionTimeupdate,this);b.on("retry",this.onConnectionRetry,this)},onConnectionRestore:function(){if(this.connElTask){this.connElTask.cancel();
delete this.connElTask}if(this.connEl){container.getNotifier().notify("error.connection",null,null,{destroy:true,reference:this.connEl});container.getNotifier().notify("info.connection.restore",_("Connection restored"),_("Connection with server has been restored"));delete this.connEl}},onReceiveException:function(a,b){var c=Ext.get("loading"),d,e;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?this.setErrorLoadingMask(d,
e):container.getNotifier().notify("error.json",d,e)},hideLoadingMask:function(){var a=Ext.get("loading-mask");a&&a.fadeOut({duration:1,remove:true})},setErrorLoadingMask:function(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})}},validateHierarchy:function(a){if(a.getDefaultStore()){for(var b=[{type:"inbox",name:pgettext("hierarchy.foldername","Inbox")},
{type:"outbox",name:pgettext("hierarchy.foldername","Outbox")},{type:"sent",name:pgettext("hierarchy.foldername","Sent Items")},{type:"wastebasket",name:pgettext("hierarchy.foldername","Deleted items")},{type:"calendar",name:pgettext("hierarchy.foldername","Calendar")},{type:"contact",name:pgettext("hierarchy.foldername","Contacts")},{type:"drafts",name:pgettext("hierarchy.foldername","Drafts")},{type:"journal",name:pgettext("hierarchy.foldername","Journal")},{type:"note",name:pgettext("hierarchy.foldername",
"Notes")},{type:"task",name:pgettext("hierarchy.foldername","Tasks")},{type:"junk",name:pgettext("hierarchy.foldername","Junk E-mail")}],c=[],d=0,e=b.length;d<e;d++){var f=b[d];a.getDefaultFolder(f.type)||c.push(f.name)}if(!Ext.isEmpty(c)){a="<ul><li>"+c.join("</li><li>")+"</li></ul>";container.getNotifier().notify("error.hierarchy.defaultfolder",_("Missing folders"),String.format(ngettext("The following required folder is missing in the hierarchy: {0}","The following required folders are missing in the hierarchy: {0}",
c.length),a)+_("Not all functionality of WebApp might be working properly because of this."),{persistent:true,listeners:{click:this.onHierarchyNotifierClick,scope:this}})}}else container.getNotifier().notify("error.hierarchy.defaultfolder",_("Missing store"),_("The default store is missing from the hierarchy.")+"<br>"+_("Not all functionality of WebApp might be working properly because of this."),{persistent:true,listeners:{click:this.onHierarchyNotifierClick,scope:this}})},onHierarchyNotifierClick:function(a){container.getNotifier().notify("error.hierarchy.defaultfolder",
null,null,{reference:a,destroy:true})},onHierarchyLoad:function(a,b){if(Ext.isEmpty(b))this.setErrorLoadingMask(_("Error"),_("Loading model from server failed"));else{container.getMainPanel();this.validateHierarchy(a);this.hideLoadingMask();window.removeEventListener("resize",onResize);this.registerMailto();Zarafa.core.URLActionMgr.execute(urlActionData);delete urlActionData;a.startKeepAlive();window.location!==window.parent.location&&window.parent.postMessage("logonSuccesful","*")}},registerMailto:function(){var a=
window.navigator;if(Ext.isFunction(a.registerProtocolHandler)){var b=container.getBaseURL()+"?action=mailto&to=%s",c=true;if(Ext.isFunction(a.isProtocolHandlerRegistered))c=!a.isProtocolHandlerRegistered("mailto",b);c&&a.registerProtocolHandler("mailto",b,"Zarafa WebApp")}},loadWebclient:function(){Zarafa.initializeGlobals();Zarafa.initializeEnvironment();Zarafa.fireReady();this.checkOof();this.initContext();container.getReminderStore().initializeReminderInterval();var a=container.getHierarchyStore();
a.on("load",this.onHierarchyLoad,this,{single:true});a.load();(a=container.getServerConfig().getClientTimeout())&&this.startIdleTimeChecker(a)},startIdleTimeChecker:function(a){if(document.addEventListener){var b=this;document.addEventListener("click",function(){b.idleTime=0},true);document.addEventListener("mousemove",function(){b.idleTime=0},true);document.addEventListener("keydown",function(){b.idleTime=0},true);var c=container.getHierarchyStore();Ext.TaskMgr.start.createDelegate(this,[{run:function(){this.idleTime+=
5;this.idleTime>a&&c.sendDestroySession()},scope:this,interval:5E3}]).defer(5E3);var d=(a-5)*1E3;if(d<5E3)d=5E3;Ext.TaskMgr.start.createDelegate(this,[{run:function(){c.sendKeepAlive()},scope:this,interval:d}]).defer(d)}},initContext:function(){var a=container.getSettingsModel().get("zarafa/v1/main/default_context");(a=container.getContextByName(a))||(a=container.getContextByName("today"));container.switchContext(a)},checkOof:function(){var a=false,b=container.getVersion(),c=b.getZCP();b=b.versionCompare(c,
"7.2.1")===-1;if(container.getSettingsModel().get("zarafa/v1/contexts/mail/outofoffice/set")===true)if(b)a=true;else{b=container.getSettingsModel().get("zarafa/v1/contexts/mail/outofoffice/from");c=container.getSettingsModel().get("zarafa/v1/contexts/mail/outofoffice/until");var d=(new Date).getTime()/1E3;if(b<=d)if(c===0||c>d)a=true;else container.getSettingsModel().set("zarafa/v1/contexts/mail/outofoffice/set",false)}a&&Ext.MessageBox.confirm(_("Zarafa WebApp"),_("Out of Office currently on. Would you like to turn it off?"),
this.onOofConfirm,this)},onOofConfirm:function(a){if(a==="yes"){container.getSettingsModel().set("zarafa/v1/contexts/mail/outofoffice/set",false);container.getNotifier().notify("info.saved",_("Out of office off"),_("Out of office has been turned off"))}},loadWelcome:function(){this.initializeGlobals();this.initializeEnvironment();this.fireReady();container.getWelcomePanel();this.hideLoadingMask();window.location!==window.parent.location&&window.parent.postMessage("firstLogon","*")},supportsFilesAPI:function(){if(!container.getSettingsModel().get("zarafa/v1/main/use_files_api"))return false;
return Ext.isDefined(window.File)&&Ext.isDefined(window.FileList)},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.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",reset:"reset",_delete:"delete",search:"search",updatesearch:"updatesearch",updatelist:"updatelist",stopsearch:"stopsearch",contacts:"contacts",keepalive:"keepalive",destroysession:"destroysession",newmail:"newmail",addFolder:"add",modifyFolder:"modify",deleteFolder:"delete",emptyFolder:"emptyfolder",
readAllMsgs:"readflags",folderProps:"folderprops",checknames:"checknames",expand:"expand",upload:"upload"};Ext.namespace("Zarafa.core");
Zarafa.core.ColorSchemes={fields:[{name:"base",weight:1}],colorSchemes:[],addField:function(a){var b;if(Ext.isArray(a))for(b=0;b<a.length;b++)this.addField(a[b]);else{this.fields.push(a);for(b=0;b<this.colorSchemes.length;b++)if(!Ext.isDefined(this.colorSchemes[b][a.name]))if(Ext.isDefined(a.color))this.colorSchemes[b][a.name]=a.color;else if(Ext.isDefined(a.weight))this.colorSchemes[b][a.name]=this.createColor(this.colorSchemes[b].base,a.weight)}},hexToRgb:function(a){return{red:parseInt(a.substring(1,
3),16),green:parseInt(a.substring(3,5),16),blue:parseInt(a.substring(5,7),16)}},rgbToHex:function(a){function b(c){c=parseInt(c,10);if(isNaN(c))return"00";c=Math.max(0,Math.min(c,255));return"0123456789ABCDEF".charAt((c-c%16)/16)+"0123456789ABCDEF".charAt(c%16)}return"#"+b(a.red)+b(a.green)+b(a.blue)},createDarkColor:function(a,b){var c=this.hexToRgb(a);return this.rgbToHex({red:c.red*b,green:c.green*b,blue:c.blue*b})},createLightColor:function(a,b){var c=this.hexToRgb(a);return this.rgbToHex({red:255-
(255-c.red)*(255-128*b)/127,green:255-(255-c.green)*(255-128*b)/127,blue:255-(255-c.blue)*(255-128*b)/127})},createColor:function(a,b){var c=this.hexToRgb(a);return Math.max(c.red,c.green,c.blue)>127?this.createLightColor(a,b):this.createDarkColor(a,b)},createColorScheme:function(a,b,c){if(Ext.isArray(a))for(b=0;b<a.length;b++)this.createColorScheme(a[b]);else{if(Ext.isObject(a)){b=a.displayName;c=a.baseColor||a.base;a=a.name}var d={name:a,displayName:b,base:c};for(b=0;b<this.fields.length;b++)if(this.fields[b].name!==
"base")d[this.fields[b].name]=Ext.isDefined(this.fields[b].color)?this.fields[b].color:this.createColor(c,this.fields[b].weight);Ext.isDefined(this.getColorScheme(a))||this.colorSchemes.push(d)}},addColorScheme:function(a){if(!(!Ext.isDefined(a.name)||!Ext.isDefined(a.displayName)||!Ext.isDefined(a.base))){for(var b=0;b<this.fields.length;b++)Ext.isDefined(a[this.fields[b].name])||(a[this.fields[b].name]=Ext.isDefined(this.fields[b].color)?this.fields[b].color:this.createColor(a.base,this.fields[b].weight));
this.colorSchemes.push(a)}},addColorSchemesFromConfig:function(){var a,b=container.getServerConfig().getColorSchemes();if(b&&Ext.isArray(b))for(a=0;a<b.length;a++)this.addColorScheme(b[a]);if((b=container.getServerConfig().getAdditionalColorSchemes())&&Ext.isArray(b))for(a=0;a<b.length;a++)this.addColorScheme(b[a])},getColorScheme:function(a){for(var b=0;b<this.colorSchemes.length;b++)if(this.colorSchemes[b].name===a)return this.colorSchemes[b]},getColorSchemes:function(){return this.colorSchemes},
rgbToHsl:function(a,b,c){if(arguments.length===1&&a.substr(0,1)==="#"){var d=this.hexToRgb(a);a=d.red;b=d.green;c=d.blue}a/=255;b/=255;c/=255;d=Math.max(a,b,c);var e=Math.min(a,b,c),f,g=(d+e)/2;if(d===e)f=e=0;else{var i=d-e;e=g>0.5?i/(2-d-e):i/(d+e);switch(d){case a:f=(b-c)/i+(b<c?6:0);break;case b:f=(c-a)/i+2;break;case c:f=(a-b)/i+4;break}f/=6}return[f,e,g]},hslToRgb:function(a,b,c){function d(g,i,h){if(h<0)h+=1;if(h>1)h-=1;if(h<1/6)return g+(i-g)*6*h;if(h<0.5)return i;if(h<2/3)return g+(i-g)*(2/
3-h)*6;return g}if(b===0)c=b=a=c;else{var e=c<0.5?c*(1+b):c+b-c*b,f=2*c-e;c=d(f,e,a+1/3);b=d(f,e,a);a=d(f,e,a-1/3)}return[Math.round(c*255),Math.round(b*255),Math.round(a*255)]},getLuma:function(a,b,c){if(arguments.length===1&&a.substr(0,1)==="#"){var d=this.hexToRgb(a);a=d.red;b=d.green;c=d.blue}return 0.2126*a+0.7152*b+0.0722*c}};Zarafa.onReady(function(){Zarafa.core.ColorSchemes.addColorSchemesFromConfig()});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());this.startDate=Ext.isEmpty(a)?null:new Date(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());this.dueDate=
Ext.isEmpty(a)?null:new Date(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(Date.DAY);return Ext.isDefined(a)?
Math.round(a):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(){if(Ext.isDate(this.startDate)&&Ext.isDate(this.dueDate)&&!this.isZeroMinuteRange())return this.startDate.clearTime(true).getTime()===
this.getStartTime()&&this.dueDate.clearTime(true).getTime()===this.getDueTime();return false},isZeroMinuteRange:function(){return this.dueDate.getTime()===this.startDate.getTime()},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.getTime()===b.clearTime(true).getTime()){b=b.clone();b.setHours(12);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.EntryId=function(){var a=Ext.extend(Object,{entryId:"",length:0,constructor:function(g){if(g){this.entryId=g.toUpperCase();this.length=g.length;this.decomposeEntryId(this.entryId)}},getPadding:function(g){for(var i="",h=0,k=4;k>0;k--)if(g.substring(g.length-(h+2),g.length-h)==="00"){i+="00";h+=2}else break;return i}}),b=Ext.extend(a,{abFlags:"",guid:"",version:"",type:"",uniqueId:"",server:"",padding:"",MIN_LENGTH:88,name:"EID",decomposeEntryId:function(g){var i=0;this.padding=this.getPadding(g);
g=g.substring(0,g.length-this.padding.length);this.abFlags=g.substr(i,8);i=+8;this.guid=g.substr(i,32);i+=32;this.version=g.substr(i,8);i+=8;this.type=g.substr(i,8);i+=8;this.uniqueId=g.substr(i,32);i+=32;this.server=g.substr(i)}}),c=Ext.extend(a,{abFlags:"",guid:"",version:"",type:"",id:"",server:"",padding:"",MIN_LENGTH:64,name:"EID_V0",decomposeEntryId:function(g){var i=0;this.padding=this.getPadding(g);g=g.substring(0,g.length-this.padding.length);this.abFlags=g.substr(i,8);i=+8;this.guid=g.substr(i,
32);i+=32;this.version=g.substr(i,8);i+=8;this.type=g.substr(i,8);i+=8;this.id=g.substr(i,8);i+=8;this.server=g.substr(i)}}),d=Ext.extend(a,{flags:"",providerUID:"",version:"",type:"",DLLFileName:"",terminationChar:"",unWrappedEntryId:"",name:"WrappedSEID",decomposeEntryId:function(g){var i=0;this.flags=g.substr(i,8);i+=8;this.providerUID=g.substr(i,32);i+=32;this.version=g.substr(i,2);i+=2;this.type=g.substr(i,2);i+=2;var h=g.slice(i).indexOf("00");this.DLLFileName=g.substr(i,h);i+=h;this.terminationChar=
g.substr(i,2);i+=2;this.unWrappedEntryId=g.substr(i);this.unWrappedEntryId=Zarafa.core.EntryId.createEntryIdObj(this.unWrappedEntryId)}}),e=Ext.extend(a,{abFlags:"",guid:"",version:"",type:"",id:"",extid:"",padding:"",MIN_LENGTH:64,name:"ABEID",decomposeEntryId:function(g){var i=0;this.padding=this.getPadding(g);g=g.substring(0,g.length-this.padding.length);this.abFlags=g.substr(i,8);i=+8;this.guid=g.substr(i,32);i+=32;this.version=g.substr(i,8);i+=8;this.type=g.substr(i,8);i+=8;this.id=g.substr(i,
8);i+=8;this.extid=g.substr(i)}}),f=Ext.extend(a,{ulVersion:"",muid:"",ulObjType:"",ulOffset:"",unWrappedEntryId:"",name:"WrappedABEID",decomposeEntryId:function(g){var i=0;this.ulVersion=g.substr(i,8);i+=8;this.muid=g.substr(i,32);i+=32;this.ulObjType=g.substr(i,8);i+=8;this.ulOffset=g.substr(i,8);i+=8;this.unWrappedEntryId=g.substr(i);this.unWrappedEntryId=Zarafa.core.EntryId.createEntryIdObj(this.unWrappedEntryId)}});f.wrapABEID=function(g,i){i=i.toString(16);i=String.leftPad(i,2,"0");i=String.rightPad(i,
8,"0");return"00000000727F0430E3924FDAB86AE52A7FE46571"+i+"00000000"+g};f.unwrapABEID=function(g){return g.substring(56)};return{createABEntryIdObj:function(g){return new e(g)},compareABEntryIds:function(g,i){if(!Ext.isString(g)||!Ext.isString(i))return false;if(g===i)return true;var h=Zarafa.core.EntryId.createABEntryIdObj(g),k=Zarafa.core.EntryId.createABEntryIdObj(i);if(h.length!==k.length)return false;if(h.abFlags!==k.abFlags)return false;if(h.version!==k.version)return false;if(h.type!==k.type)return false;
if(h.length<h.MIN_LENGTH)return false;if(h.extid!==k.extid)return false;return true},createEntryIdObj:function(g){return g.substr(40,8)==="00000000"?new c(g):new b(g)},compareEntryIds:function(g,i){if(!Ext.isString(g)||!Ext.isString(i))return false;if(g===i)return true;var h=Zarafa.core.EntryId.createEntryIdObj(g),k=Zarafa.core.EntryId.createEntryIdObj(i);if(h.length!==k.length)return false;if(h.abFlags!==k.abFlags)return false;if(h.version!==k.version)return false;if(h.type!==k.type)return false;
if(h.name==="EID_V0"){if(h.length<h.MIN_LENGTH)return false;if(h.id!==k.id)return false}else{if(h.length<h.MIN_LENGTH)return false;if(h.uniqueId!==k.uniqueId)return false}return true},createStoreEntryIdObj:function(g){return new d(g)},compareStoreEntryIds:function(g,i){if(!Ext.isString(g)||!Ext.isString(i))return false;if(g===i)return true;var h=Zarafa.core.EntryId.createStoreEntryIdObj(g),k=Zarafa.core.EntryId.createStoreEntryIdObj(i);h=h.unWrappedEntryId;k=k.unWrappedEntryId;if(h===k)return true;
if(h.length<h.MIN_LENGTH||k.length<k.MIN_LENGTH)return false;if(h.guid!==k.guid)return false;if(h.version!==k.version)return false;if(h.type!==k.type)return false;if(h.name==="EID_V0"){if(h.length<h.MIN_LENGTH)return false;if(h.id!==k.id)return false}else{if(h.length<h.MIN_LENGTH)return false;if(h.uniqueId!==k.uniqueId)return false}return true},unwrapContactProviderEntryId:function(g){return f.unwrapABEID(g)},wrapContactProviderEntryId:function(g,i){return f.wrapABEID(g,i)},createOneOffEntryId:function(g,
i,h){return"00000000812B1FA4BEA310199D6E00DD010F540200000080"+Zarafa.core.Util.encode_utf16(g)+"0000"+Zarafa.core.Util.encode_utf16(i)+"0000"+Zarafa.core.Util.encode_utf16(h)+"0000"},isFavoriteFolder:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).abFlags.substr(6,8)==="01"},isOneOffEntryId:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).guid==="812B1FA4BEA310199D6E00DD010F5402"},isFavoriteRootFolder:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).uniqueId==="00000000000000000000000000000002"},
isPublicRootFolder:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).uniqueId==="00000000000000000000000000000003"},isPublicSubtreeFolder:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).uniqueId==="00000000000000000000000000000001"},hasContactProviderGUID:function(g){return Zarafa.core.EntryId.createEntryIdObj(g).guid==="727F0430E3924FDAB86AE52A7FE46571"},hasAddressBookGUID:function(g){return Zarafa.core.EntryId.createABEntryIdObj(g).guid==="AC21A95040D3EE48B319FBA753304425"},
isGlobalAddressbookContainer:function(g){if(Zarafa.core.EntryId.hasAddressBookGUID(g)===false)return false;g=Zarafa.core.EntryId.createABEntryIdObj(g);return g.type==="04000000"&&g.id==="01000000"}}}();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.on("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.HTMLParser=function(){var a=/<style[^>]*>[\s\S]*?<\/style[^>]*>/gim,b=/<script[^>]*>[\s\S]*?<\/script[^>]*>/gim,c=/<br\s*?\/*?>/gim,d=/\r\n|\n|\r/gim,e=/(src\s*=\s*[\"\']?)cid:([^ \"\']*)([\"\']?)/igm,f=/(src\s*=\s*[\"\']?)\S*attachCid=([^ &\"\']*)[^ \"\']*([\"\']?)/igm;return{stripStyles:function(g){return!g?g:String(g).replace(a,"")},stripScripts:function(g){return!g?g:String(g).replace(b,"")},br2nl:function(g){return Ext.isEmpty(g)?"":g.replace(c,"\n")},nl2br:function(g){return Ext.isEmpty(g)?
"":g.replace(d,"<br>")},convertPlainToHTML:function(g){if(Ext.isEmpty(g))return g;g=Zarafa.core.HTMLParser.entityEncode(g,"ENT_NOQUOTES");g='<div><pre wrap style="white-space: pre-wrap; word-wrap: break-word;">'+g+"</pre></div>";g=g.replace(XRegExp("(?<prefix>^|[^\\p{L}])(?<word>\\*+[\\p{L}, ,\t,0-9]+\\*+)(?<postfix>[^\\p{L}]|$)","gi"),function(i){return i.prefix+"<strong>"+i.word+"</strong>"+i.postfix});g=g.replace(XRegExp("(?<prefix>^|[^\\p{L}])(?<word>_+[\\p{L}, ,\t,0-9]+_+)(?<postfix>[^\\p{L}]|$)",
"gi"),function(i){return i.prefix+'<span style="text-decoration: underline">'+i.word+"</span>"+i.postfix});return g=Zarafa.core.HTMLParser.nl2br(g)},convertHTMLToPlain:function(g){if(Ext.isEmpty(g))return g;g=g.replace(/<[\/]?(?:select)[^>]*>/gim,"\n");g=g.replace(/<[\/]?(?:option)[^>]*>/gim,"\t");g=g.replace(/<(?:hr)[^>]*>/gim,"\n-----------\n");g=g.replace(/<[\/]?(?:h[123456]|div|p|pre|title)[^>]*>/gim,"\n\n");g=g.replace(/<[\/]?(?:ul|ol|dl|dt|textarea|img)[^>]*>/gim,"\n");g=g.replace(/<[\/]?(?:dd|li)[^>]*>/gim,
"\t");g=g.replace(/<[\/]?(?:table)[^>]*>/gim,"\n\n");g=g.replace(/<[\/]?(?:caption|tr)[^>]*>/gim,"\n");g=g.replace(/<[^\/]?(?:th|td)[^>]*>/gim,"<br />");g=g.replace(/<a[^>]* href=[\'\"]?([^\s\'\">]*)[^>]*>([\s\S]*?)<\/a[^>]*>/gim,"$2 &lt;$1&gt;");g=Zarafa.core.HTMLParser.stripStyles(g);g=Zarafa.core.HTMLParser.stripScripts(g);g=g.replace(/<!--[\s\S]*?--\>/gim,"");g=Zarafa.core.HTMLParser.stripUnwantedTags(g,["br"]);g=Zarafa.core.HTMLParser.entityDecode(g);g=g.replace(/^\s*$/gm,"");g=g.replace(/(.*[^<>\n]$)/gm,
"$1<br />");g=g.replace(/\n/gm,"");g=Zarafa.core.HTMLParser.br2nl(g);g=g.replace(/[&][#0-9a-z]*[;]/gim,"");return g=g.replace(/\n(?!\n)$/gm,"")},stripUnwantedTags:function(g,i){var h=g.match(/(<\/?[^>]+>)/gi),k="",j="",l=-1,m=false;i||(i=[]);if(h&&h.length>0)for(var n=0,o=h.length;n<o;n++){k=h[n].toString();m=false;for(var p=0,q=i.length;p<q;p++){j=i[p].toLowerCase();l=-1;if(l!==0)l=k.toLowerCase().indexOf("<"+j+">");if(l!==0)l=k.toLowerCase().indexOf("<"+j+" ");if(l!==0)l=k.toLowerCase().indexOf("</"+
j);if(l===0){m=true;break}}if(m!==true)g=g.split(k).join("")}return g},hasExternalContent:function(g){if(Ext.isEmpty(g))return false;if(g.search(/(src|background)\s*=\s*([\'\"])*?\s*(https*:[^ \'\"]*)([\'\"])*/igm)!==-1)return true;if(g.search(/(style)\s*=(\S*)(url)\(([\'\"]*?)\s*(https*:.*[^\'\"])([\'\"]*?)\)/igm)!==-1)return true;return false},blockExternalContent:function(g){if(Ext.isEmpty(g))return g;if(!Zarafa.core.HTMLParser.hasExternalContent(g))return g;g=g.replace(/(src|background)\s*=\s*([\'\"])*?\s*(https*:[^ \'\"]*)\s*([\'\"])*/igm,
"$1=$2$4");return g=g.replace(/(style)\s*=(\S*)(url)\(([\'\"]*?)\s*(https*:.*[^\'\"])([\'\"]*?)\)/igm,"$1=$2$3($4$6)")},getHTMLTranslationTable:function(g,i){g||(g="HTML_SPECIALCHARS");i||(i="ENT_COMPAT");var h={};h["38"]="&amp;";if(g==="HTML_ENTITIES"){h["94"]="&circ;";h["126"]="&tilde;";h["130"]="&sbquo;";h["131"]="&fnof;";h["132"]="&bdquo;";h["133"]="&hellip;";h["134"]="&dagger;";h["135"]="&Dagger;";h["136"]="&circ;";h["137"]="&permil;";h["138"]="&Scaron;";h["139"]="&lsaquo;";h["140"]="&OElig;";
h["145"]="&lsquo;";h["146"]="&rsquo;";h["147"]="&ldquo;";h["148"]="&rdquo;";h["149"]="&bull;";h["150"]="&ndash;";h["151"]="&mdash;";h["152"]="&tilde;";h["153"]="&trade;";h["154"]="&scaron;";h["155"]="&rsaquo;";h["156"]="&oelig;";h["159"]="&Yuml;";h["160"]="&nbsp;";h["161"]="&iexcl;";h["162"]="&cent;";h["163"]="&pound;";h["164"]="&curren;";h["165"]="&yen;";h["166"]="&brvbar;";h["167"]="&sect;";h["168"]="&uml;";h["169"]="&copy;";h["170"]="&ordf;";h["171"]="&laquo;";h["172"]="&not;";h["173"]="&shy;";
h["174"]="&reg;";h["175"]="&macr;";h["176"]="&deg;";h["177"]="&plusmn;";h["178"]="&sup2;";h["179"]="&sup3;";h["180"]="&acute;";h["181"]="&micro;";h["182"]="&para;";h["183"]="&middot;";h["184"]="&cedil;";h["185"]="&sup1;";h["186"]="&ordm;";h["187"]="&raquo;";h["188"]="&frac14;";h["189"]="&frac12;";h["190"]="&frac34;";h["191"]="&iquest;";h["192"]="&Agrave;";h["193"]="&Aacute;";h["194"]="&Acirc;";h["195"]="&Atilde;";h["196"]="&Auml;";h["197"]="&Aring;";h["198"]="&AElig;";h["199"]="&Ccedil;";h["200"]=
"&Egrave;";h["201"]="&Eacute;";h["202"]="&Ecirc;";h["203"]="&Euml;";h["204"]="&Igrave;";h["205"]="&Iacute;";h["206"]="&Icirc;";h["207"]="&Iuml;";h["208"]="&ETH;";h["209"]="&Ntilde;";h["210"]="&Ograve;";h["211"]="&Oacute;";h["212"]="&Ocirc;";h["213"]="&Otilde;";h["214"]="&Ouml;";h["215"]="&times;";h["216"]="&Oslash;";h["217"]="&Ugrave;";h["218"]="&Uacute;";h["219"]="&Ucirc;";h["220"]="&Uuml;";h["221"]="&Yacute;";h["222"]="&THORN;";h["223"]="&szlig;";h["224"]="&agrave;";h["225"]="&aacute;";h["226"]=
"&acirc;";h["227"]="&atilde;";h["228"]="&auml;";h["229"]="&aring;";h["230"]="&aelig;";h["231"]="&ccedil;";h["232"]="&egrave;";h["233"]="&eacute;";h["234"]="&ecirc;";h["235"]="&euml;";h["236"]="&igrave;";h["237"]="&iacute;";h["238"]="&icirc;";h["239"]="&iuml;";h["240"]="&eth;";h["241"]="&ntilde;";h["242"]="&ograve;";h["243"]="&oacute;";h["244"]="&ocirc;";h["245"]="&otilde;";h["246"]="&ouml;";h["247"]="&divide;";h["248"]="&oslash;";h["249"]="&ugrave;";h["250"]="&uacute;";h["251"]="&ucirc;";h["252"]=
"&uuml;";h["253"]="&yacute;";h["254"]="&thorn;";h["255"]="&yuml;";h["264"]="&#264;";h["265"]="&#265;";h["338"]="&OElig;";h["339"]="&oelig;";h["352"]="&Scaron;";h["353"]="&scaron;";h["372"]="&#372;";h["373"]="&#373;";h["374"]="&#374;";h["375"]="&#375;";h["376"]="&Yuml;";h["402"]="&fnof;";h["710"]="&circ;";h["732"]="&tilde;";h["913"]="&Alpha;";h["914"]="&Beta;";h["915"]="&Gamma;";h["916"]="&Delta;";h["917"]="&Epsilon;";h["918"]="&Zeta;";h["919"]="&Eta;";h["920"]="&Theta;";h["921"]="&Iota;";h["922"]=
"&Kappa;";h["923"]="&Lambda;";h["924"]="&Mu;";h["925"]="&Nu;";h["926"]="&Xi;";h["927"]="&Omicron;";h["928"]="&Pi;";h["929"]="&Rho;";h["931"]="&Sigma;";h["932"]="&Tau;";h["933"]="&Upsilon;";h["934"]="&Phi;";h["935"]="&Chi;";h["936"]="&Psi;";h["937"]="&Omega;";h["945"]="&alpha;";h["946"]="&beta;";h["947"]="&gamma;";h["948"]="&delta;";h["949"]="&epsilon;";h["950"]="&zeta;";h["951"]="&eta;";h["952"]="&theta;";h["953"]="&iota;";h["954"]="&kappa;";h["955"]="&lambda;";h["956"]="&mu;";h["957"]="&nu;";h["958"]=
"&xi;";h["959"]="&omicron;";h["960"]="&pi;";h["961"]="&rho;";h["962"]="&sigmaf;";h["963"]="&sigma;";h["964"]="&tau;";h["965"]="&upsilon;";h["966"]="&phi;";h["967"]="&chi;";h["968"]="&psi;";h["969"]="&omega;";h["977"]="&thetasym;";h["978"]="&upsih;";h["982"]="&piv;";h["8194"]="&ensp;";h["8195"]="&emsp;";h["8201"]="&thinsp;";h["8204"]="&zwnj;";h["8205"]="&zwj;";h["8206"]="&lrm;";h["8207"]="&rlm;";h["8211"]="&ndash;";h["8212"]="&mdash;";h["8216"]="&lsquo;";h["8217"]="&rsquo;";h["8218"]="&sbquo;";h["8220"]=
"&ldquo;";h["8221"]="&rdquo;";h["8222"]="&bdquo;";h["8224"]="&dagger;";h["8225"]="&Dagger;";h["8226"]="&bull;";h["8230"]="&hellip;";h["8240"]="&permil;";h["8242"]="&prime;";h["8243"]="&Prime;";h["8249"]="&lsaquo;";h["8250"]="&rsaquo;";h["8254"]="&oline;";h["8260"]="&frasl;";h["8364"]="&euro;";h["8472"]="&weierp;";h["8465"]="&image;";h["8476"]="&real;";h["8482"]="&trade;";h["8501"]="&alefsym;";h["8592"]="&larr;";h["8593"]="&uarr;";h["8594"]="&rarr;";h["8595"]="&darr;";h["8596"]="&harr;";h["8629"]=
"&crarr;";h["8656"]="&lArr;";h["8657"]="&uArr;";h["8658"]="&rArr;";h["8659"]="&dArr;";h["8660"]="&hArr;";h["8704"]="&forall;";h["8706"]="&part;";h["8707"]="&exist;";h["8709"]="&empty;";h["8711"]="&nabla;";h["8712"]="&isin;";h["8713"]="&notin;";h["8715"]="&ni;";h["8719"]="&prod;";h["8721"]="&sum;";h["8722"]="&minus;";h["8727"]="&lowast;";h["8729"]="&#8729;";h["8730"]="&radic;";h["8733"]="&prop;";h["8734"]="&infin;";h["8736"]="&ang;";h["8743"]="&and;";h["8744"]="&or;";h["8745"]="&cap;";h["8746"]="&cup;";
h["8747"]="&int;";h["8756"]="&there4;";h["8764"]="&sim;";h["8773"]="&cong;";h["8776"]="&asymp;";h["8800"]="&ne;";h["8801"]="&equiv;";h["8804"]="&le;";h["8805"]="&ge;";h["8834"]="&sub;";h["8835"]="&sup;";h["8836"]="&nsub;";h["8838"]="&sube;";h["8839"]="&supe;";h["8853"]="&oplus;";h["8855"]="&otimes;";h["8869"]="&perp;";h["8901"]="&sdot;";h["8968"]="&lceil;";h["8969"]="&rceil;";h["8970"]="&lfloor;";h["8971"]="&rfloor;";h["9001"]="&lang;";h["9002"]="&rang;";h["9642"]="&#9642;";h["9643"]="&#9643;";h["9674"]=
"&loz;";h["9702"]="&#9702;";h["9824"]="&spades;";h["9827"]="&clubs;";h["9829"]="&hearts;";h["9830"]="&diams;"}if(i!=="ENT_NOQUOTES")h["34"]="&quot;";if(i==="ENT_QUOTES")h["39"]="&#39;";h["60"]="&lt;";h["62"]="&gt;";var k,j={};for(k in h)j[String.fromCharCode(k)]=h[k];return j},entityDecode:function(g,i){var h=Zarafa.core.HTMLParser.getHTMLTranslationTable("HTML_ENTITIES",i),k="",j="";for(k in h){j=h[k];g=g.split(j).join(k)}return g=g.split("&#039;").join("'")},entityEncode:function(g,i){var h=Zarafa.core.HTMLParser.getHTMLTranslationTable("HTML_ENTITIES",
i),k="",j="";for(k in h){j=h[k];g=g.split(k).join(j)}return g=g.split("'").join("&#039;")},inlineImgOutlookToZarafa:function(g,i,h,k){return g.replace(e,function(j,l,m,n){if(m){j=container.getBaseURL();j=Ext.urlAppend(j,"load=download_attachment");j=Ext.urlAppend(j,"attachCid="+m);j=Ext.urlAppend(j,"store="+i);j=Ext.urlAppend(j,"entryid="+h);j=Ext.urlAppend(j,"contentDispositionType=inline");if(!Ext.isEmpty(k))for(m=0;m<k.length;m++)j=Ext.urlAppend(j,"attachNum[]="+k[m]);return l+j+n}return j})},
inlineImgZarafaToOutlook:function(g){if(Ext.isDefined(g))return g.replace(f,function(i,h,k,j){if(k)return h+"cid:"+k+j;return i})}}}();Ext.namespace("Zarafa.core");
Zarafa.core.KeyMap=Ext.extend(Ext.KeyMap,{component:undefined,constructor:function(a,b,c,d){if(a)this.component=a;c||(c=a.getEl());c=Ext.get(c);Zarafa.core.KeyMap.superclass.constructor.call(this,c,b,d)},addBinding:function(a){if(Ext.isArray(a))Ext.each(a,function(j){this.addBinding(j)},this);else{var b=a.key,c=a.fn||a.handler,d=a.scope,e=a.stopEvent;if(!Ext.isDefined(e))e=this.stopEvent;if(typeof b=="string"){for(var f=[],g=b.toUpperCase(),i=0,h=g.length;i<h;i++)f.push(g.charCodeAt(i));b=f}var k=
Ext.isArray(b);this.bindings.push(function(j){if(this.checkModifiers(a,j)){var l=j.getKey();if(k)for(var m=0,n=b.length;m<n;m++){if(b[m]==l){e&&j.stopEvent();c.call(d||window,l,j,this.component);return}}else if(l==b){e&&j.stopEvent();c.call(d||window,l,j,this.component)}}})}}});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}if(b.length>a.length)return false;if(c===true)a=a.substring(0,b.length);return 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.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"},RULES:{list:"rulesmodule",item:"rulesmodule"},
RESTOREITEMS:{list:"restoreitemslistmodule",item:"restoreitemslistmodule"},"IPM.SEARCH":{list:"advancedsearchlistmodule",item:"createmailitemmodule"},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.PingService=Ext.extend(Ext.util.Observable,{url:"zarafa.php",cmd:"ping",headers:undefined,timeout:1E3,maxTimeout:3E5,pingTask:undefined,currentTimeout:undefined,pingPending:false,constructor:function(a){a=a||{};Ext.apply(a,{headers:{"Content-Type":"application/json; charset=utf-8;"}});Ext.apply(this,a);this.addEvents("start","stop","send","retry","restored");Zarafa.core.PingService.superclass.constructor.call(this,a);this.pingTask=new Ext.util.DelayedTask(this.sendPing,this)},start:function(){delete this.currentTimeout;
var a=this.getNextTimeout();this.fireEvent("start",this,a);this.pingTask.delay(a)},stop:function(){this.pingTask.cancel();this.fireEvent("stop",this)},retry:function(){this.pingTask.cancel();this.sendPing()},getNextTimeout:function(){this.currentTimeout=this.currentTimeout?2*this.currentTimeout:this.timeout;return this.currentTimeout=Math.min(this.maxTimeout,this.currentTimeout)},sendPing:function(){if(!this.pingPending){var a=new XMLHttpRequest,b=this.url;b=Ext.urlAppend(b,this.cmd);a.open("GET",
b,true);for(var c in this.headers)a.setRequestHeader(c,this.headers[c]);a.onreadystatechange=this.onStateChange.createDelegate(this,[a]);this.pingPending=true;a.send();this.fireEvent("send",this,a)}},onStateChange:function(a){if(a.readyState==4){this.pingPending=false;if(a.status!==200)this.failure();else if(a.responseText){a=Ext.decode(a.responseText);a.success?this.restored(a):this.failure(a)}else this.failure()}},restored:function(a){this.fireEvent("restored",this,a)},failure:function(a){var b=
this.getNextTimeout();this.fireEvent("retry",this,a,b);this.pingTask.delay(b)}});Ext.namespace("Zarafa.core");
Zarafa.core.Request=Ext.extend(Ext.util.Observable,function(){var a=false,b=false,c=0,d=undefined,e=false,f=false,g=[],i={},h=[],k=undefined;return{defaultUrl:"zarafa.php",defaultHeaders:undefined,subSystemPrefix:"webapp",requestHeaders:undefined,constructor:function(j){j=j||{};Ext.apply(j,{defaultHeaders:{"Content-Type":"application/json; charset=utf-8;"},requestHeaders:{}});Ext.apply(this,j);this.addEvents("connectionparalyzed","connectioninterrupted","connectionrestored","beforesend","aftersend");
Zarafa.core.Request.superclass.constructor.call(this,j);this.initialize()},initialize:function(){b=a=false;c=0;d=undefined;f=e=false;g=[];i={};h=[];k=this.subSystemPrefix+"_"+(new Date).getTime()},paralyze:function(j){if(!this.isParalyzed()){a=true;this.fireEvent("connectionparalyzed",this,j)}},isParalyzed:function(){return a},interrupt:function(){if(!(this.isInterrupted()||this.isParalyzed())){b=true;var j=new Zarafa.core.PingService({url:this.defaultUrl,headers:this.defaultHeaders});j.on("restored",
this.restore,this);this.on("connectionparalyzed",j.stop,j);this.on("connectionrestored",j.stop,j,{delay:1});this.fireEvent("connectioninterrupted",this,j);j.start()}},restore:function(j,l){if(this.isInterrupted())if(l&&l.active===false)this.paralyze(Zarafa.core.data.ParalyzeReason.SESSION_EXPIRED);else{b=false;this.fireEvent("connectionrestored",this);this.hasQueuedHttpRequests()&&this.dequeueHttpRequest()}},isInterrupted:function(){return b},setRequestHeader:function(j,l){this.requestHeaders[j]=
l},getRequestId:function(j){return(j||"z-gen")+ ++c},cancelActiveRequest:function(j){var l=container.getResponseRouter();if(g.indexOf(j)>=0)if(g.length===1){this.reset();l.removeRequestResponseHandler(j)}else l.addRequestResponseHandler(j,new Zarafa.core.data.DummyResponseHandler);else if(this.hasQueuedHttpRequests()){for(var m=0;m<h.length;m++){var n=h[m];if(n.queuedRequests.indexOf(j)>=0){if(n.queuedRequests.length===1){h.splice(m,1);l.removeRequestResponseHandler(j);return}break}}l.addRequestResponseHandler(j,
new Zarafa.core.data.DummyResponseHandler)}else{n=i[j];if(Ext.isDefined(n)){if(n.queuedRequests.length===1)n.preventRetry=true;l.addRequestResponseHandler(j,new Zarafa.core.data.DummyResponseHandler)}}},queueRequest:function(j){g.push(j)},dequeueRequests:function(){var j=g;g=[];return j},activateRequests:function(j,l){for(var m=0;m<j.length;m++)i[j[m]]=l},completeRequests:function(j){for(var l=0,m=j.length;l<m;l++)delete i[j[l]]},prepareHttpRequest:function(j,l,m,n){var o=new XMLHttpRequest;if(!m){m=
this.defaultUrl;m=Ext.urlAppend(m,"subsystem="+k)}o.open("POST",m,true);o.requestUrl=m;n=Ext.apply({},this.requestHeaders,n||this.defaultHeaders);for(var p in n)o.setRequestHeader(p,n[p]);o.requestHeaders=n;o.requestData=j;o.requestDataEncoded=l;o.queuedRequests=this.dequeueRequests();return o},cloneRequest:function(j){var l=new XMLHttpRequest;l.open("POST",j.requestUrl,true);l.requestUrl=j.requestUrl;var m=j.requestHeaders;for(var n in m)l.setRequestHeader(n,m[n]);l.requestHeaders=m;l.requestData=
j.requestData;l.requestDataEncoded=j.requestDataEncoded;l.queuedRequests=j.queuedRequests;return l},sendHttpRequest:function(j){var l=j.requestData,m=j.queuedRequests;if(!this.isParalyzed())if(this.fireEvent("beforesend",this,j)!==false){j.onreadystatechange=this.stateChange.createDelegate(this,[j]);this.activateRequests(m,j);j.send(l);this.fireEvent("aftersend",this,j)}},queueHttpRequest:function(j){h.push(j)},hasQueuedHttpRequests:function(){return!Ext.isEmpty(h)},dequeueHttpRequest:function(){var j=
h.shift();j&&this.sendHttpRequest(j)},stateChange:function(j){var l=j.queuedRequests,m=container.getResponseRouter();if(!this.isParalyzed())if(j.readyState==4){this.completeRequests(l);switch(j.status){case 401:j.getResponseHeader("X-Zarafa-Hresult")==="MAPI_E_INVALID_WORKSTATION_ACCOUNT"?this.paralyze(Zarafa.core.data.ParalyzeReason.SESSION_INVALID):this.paralyze(Zarafa.core.data.ParalyzeReason.SESSION_EXPIRED);return;case 500:this.hasQueuedHttpRequests()&&this.dequeueHttpRequest();this.receiveFailure(j);
return;case 200:this.hasQueuedHttpRequests()&&this.dequeueHttpRequest();break;default:this.interrupt();j.preventRetry!==true&&this.queueHttpRequest(this.cloneRequest(j));return}if(j.responseText){l=Ext.decode(j.responseText);Ext.isEmpty(l)||Ext.isEmpty(l.zarafa)?this.receiveFailure(j):m.receive(l)}else this.receiveFailure(j)}},receiveFailure:function(j){var l=container.getResponseRouter(),m=j.requestData;if(j.requestDataEncoded)m=Ext.decode(m);l.receiveFailure(m,j)},reset:function(){g=[];d={zarafa:{}};
f=e=false},addRequest:function(j,l,m,n){if(Ext.isEmpty(d))throw"Request object not initialised. Call reset() first";if(f)throw"Request object initialized with RAW data";var o=this.getRequestId(j);this.queueRequest(o);Ext.isDefined(n)&&container.getResponseRouter().addRequestResponseHandler(o,n);m=Ext.value(m,{});Ext.isDefined(d.zarafa[j])||(d.zarafa[j]={});Ext.isDefined(d.zarafa[j][o])||(d.zarafa[j][o]={});d.zarafa[j][o][l]=m;e=true;return o},addDataRequest:function(j,l,m,n){if(Ext.isEmpty(d))throw"Request object not initialised. Call reset() first";
if(e)throw"Request object intitialized with JSON data";if(f)throw"Request object already contains RAW data";j=this.getRequestId(j);this.queueRequest(j);Ext.isDefined(n)&&container.getResponseRouter().addRequestResponseHandler(j,n);d=m;f=true;return j},send:function(j,l){if(Ext.isEmpty(d))throw"Request object not initialised. Call reset() first";if(Ext.isEmpty(g))throw"No requests have been added. Use addRequest()";if(!this.isParalyzed()){var m=this.prepareHttpRequest(e?Ext.encode(d):d,e,j,l);this.isInterrupted()||
this.hasQueuedHttpRequests()?this.queueHttpRequest(m):this.sendHttpRequest(m)}d=undefined;f=e=false},singleRequest:function(j,l,m,n){this.reset();j=this.addRequest(j,l,m,n);this.send();return j}}}());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 i={moduleName:d,moduleId:f,moduleData:g};i.handler=this.getRequestResponseHandler(f);if(Ext.isEmpty(i.handler)){i.handler=this.getNotificationResponseHandler(d,g);Ext.isEmpty(i.handler)||c.push(i)}else b.push(i)},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,i){if(a.handle(g,i)===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,i=e.moduleData;e=e.handler;this.fireEvent("response",f,g,i,b)!==false&&this.handleResponse(e,f,g,i,b)}}else Ext.data.DataProxy.fireEvent("exception",Ext.data.DataProxy,"remote",null,null,a.zarafa,null)}});Ext.namespace("Zarafa.core");
Zarafa.core.Util={skipRequester:false,sortArray:function(a,b,c){var d=new Ext.util.MixedCollection;d.addAll(a);a=Ext.isFunction(c)?c:Ext.isString(c)?function(e,f){return Zarafa.core.Util.numericComparison(e[c],f[c])}:this.numericComparison;d.sort(b,a);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},objectKeysToLowerCase:function(a){for(var b,c=Object.keys(a),d={},e=0;e<c.length;e++){b=c[e];d[b.toLowerCase()]=a[b]}return d},splitStringByPattern:function(a,b){for(var c=[0],d;(d=b.exec(a))!==null;){d.index!==0&&c.push(d.index);b.lastIndex<a.length&&c.push(b.lastIndex)}d=[];if(c.length>1)for(var e=0;e<c.length;e++)Ext.isDefined(c[e+1])?d.push(a.slice(c[e],c[e+1])):d.push(a.slice(c[e]));else d=[a];return d},explodeObject:function(a,b){var c={};for(var d in a){for(var e=d.split(b),f=c,
g=0,i=e.length-1;g<i;g++){var h=e[g];Ext.isDefined(f[h])||(f[h]={});f=f[h]}f[e[e.length-1]]=a[d]}return c},inside:function(a,b,c){return b>=a.x&&b<a.x+a.width&&c>=a.y&&c<a.y+a.height},restrictBox:function(a,b){b=Ext.apply({},b);b.x=Math.max(a.x,b.x);b.y=Math.max(a.y,b.y);if(b.x>a.x)b.x-=Math.max(0,b.x+b.width-(a.x+a.width));if(b.y>a.y)b.y-=Math.max(0,b.y+b.height-(a.y+a.height));b.x=Math.max(a.x,b.x);b.y=Math.max(a.y,b.y);return b},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},encode_utf16:function(a){var b,c,d="";Ext.isString(a)||(a=String(a));for(var e=0,f=a.length;e<f;e++){c=(a.charCodeAt(e)>>8).toString(16);b=(a.charCodeAt(e)&255).toString(16);d+=String.leftPad(String(b),2,"0");d+=String.leftPad(String(c),
2,"0")}return d},stringToHex:function(a){a=a.toUpperCase();for(var b="",c=0;c<a.length;c++)b+=""+a.charCodeAt(c).toString(16);return b},hexToString:function(a){a=a.toString();for(var b="",c=0;c<a.length;c+=2)b+=String.fromCharCode(parseInt(a.substr(c,2),16));return b.toLowerCase()},reloadWebapp:function(){this.disableLeaveRequester();window.location.reload()},enableLeaveRequester:function(){window.onbeforeunload=this.onBeforeUnload.createDelegate(this)},disableLeaveRequester:function(){window.onbeforeunload=
null},onBeforeUnload:function(){if(this.skipRequester)this.skipRequester=false;else return _("Your changes will be lost if you leave this page now.")}};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.CallbackQueue=Ext.extend(Ext.util.Observable,{queue:undefined,running:false,currentTask:0,completionFn:undefined,completionScope:undefined,constructor:function(a){a=a||{};a.queue=[];this.addEvents("startqueue","completequeue","starttask","completetask");Ext.apply(this,a);Zarafa.core.data.CallbackQueue.superclass.constructor.call(this,a)},add:function(a,b){this.queue.push({fn:a,scope:b})},remove:function(a,b){for(var c=this.queue,d=0;d<c.length;d++){var e=c[d];if(e.fn===a&&e.scope===
b){this.queue.splice(d,1);return}}},run:function(a,b){this.running=true;this.currentTask=0;this.completionFn=a;this.completionScope=b;this.fireEvent("startqueue",this);this.doTask(this.currentTask)},isRunning:function(){return this.running},doTask:function(a){a=this.queue[a];this.fireEvent("starttask",this,a.fn,a.scope);a.fn.call(a.scope,this.onCompleteTask.createDelegate(this,[a],1))},onCompleteTask:function(a,b){a=a!==false;this.fireEvent("completetask",this,b.fn,b.scope,a);if(a&&this.currentTask<
this.queue.length-1){this.currentTask++;this.doTask(this.currentTask)}else{if(this.completionFn){this.completionFn.call(this.completionScope,a);this.completionScope=this.completionFn=undefined}this.fireEvent("completequeue",this,a);this.running=false}}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ContentPanelMgr=Ext.extend(Ext.util.Observable,{contentPanels:undefined,constructor:function(){this.contentPanels=new Ext.util.MixedCollection;this.addEvents(["createcontentpanel","destroycontentpanel"]);Zarafa.core.data.ContentPanelMgr.superclass.constructor.call(this)},register:function(a){a.on("show",this.onContentPanelShow,this);a.on("close",this.onContentPanelHide,this);a.on("hide",this.onContentPanelHide,this);this.contentPanels.add(a)},unregister:function(a){a.un("show",this.onContentPanelShow,
this);a.un("close",this.onContentPanelHide,this);a.un("hide",this.onContentPanelHide,this);this.contentPanels.remove(a)},onContentPanelShow:function(a){this.fireEvent("createcontentpanel",a)},onContentPanelHide:function(a){this.fireEvent("destroycontentpanel",a)},getContentPanelInstances:function(a){return this.contentPanels.filterBy(function(b){return b instanceof a})}});Zarafa.core.data.ContentPanelMgr=new Zarafa.core.data.ContentPanelMgr;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.IPMRecipientResolveRecordFields=[{name:"user_name"},{name:"display_name"},{name:"address_type"},{name:"smtp_address"},{name:"email_address"},{name:"entryid"},{name:"search_key"},{name:"object_type",type:"int"},{name:"display_type",type:"int"},{name:"display_type_ex",type:"int"}];Zarafa.core.data.IPMRecipientResolveRecord=Ext.data.Record.create(Zarafa.core.data.IPMRecipientResolveRecordFields);
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.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,i=this.getId(f),h=f.props||f;h={message_class:h.message_class,object_type:h.object_type};if(this.dynamicRecord===true)g=Zarafa.core.data.RecordFactory.createRecordObjectByRecordData(h,i);g||(g=new this.recordType({},i));this.moveIdProperties(f,g.baseIdProperties);h=g.fields;
i=h.items;h=h.length;this.update(g,this.extractValues(f,i,h));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);h=c.prototype.fields;i=h.items;h=h.length;h=this.extractValues(f,i,h);h[this.meta.idProperty]=this.getId(f.props||f);d.push(h)}return d},moveIdProperties:function(a,b){if(!a)return a;if(!a.props)a.props=
{};var c=this.meta.idProperty;if(c){var d=a[c];if(Ext.isDefined(d)){a.props[c]=d;delete a[c]}}if(Ext.isString(b)){d=a[b];if(Ext.isDefined(d)){a.props[b]=d;delete a[b]}}else if(b){c=0;for(var e=b.length;c<e;c++){var f=b[c];d=a[f];if(Ext.isDefined(d)){a.props[f]=d;delete a[f]}}}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);a.store&&a.store.reMap(a)}},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(true);else f=a.createSubStore(d);if(!Ext.isEmpty(e)){f.loadData(e);delete b[d]}}}},this)}a.commit()}}});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.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){this.doRequests(g.actionType||Zarafa.core.Actions.list,a,b,c,d,e,f,g)},doRequests:function(a,b,c,d,e,f,g,i){i.cancelPreviousRequest===
true&&this.cancelRequests(a);container.getRequest().reset();if(c&&i.listRequest!==true){var h=d.jsonData[e.meta.root];Ext.isArray(c)||(c=[c]);Ext.isArray(h)||(h=[h]);for(var k=0;k<c.length;k++){var j=c[k],l=h[k],m=this.getItemModuleName(j);j=this.getResponseHandlerForRequest(m,a,b,j,d,e,f,g,i);l=container.getRequest().addRequest(m,a,l,j);this.addRequestId(a,l)}}else{m=this.getListModuleName(c);j=this.getResponseHandlerForRequest(m,a,b,c,d,e,f,g,i);l=container.getRequest().addRequest(m,a,d,j);this.addRequestId(a,
l)}container.getRequest().send()}});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,isSaving:false,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("add",this.onAdd,this);this.on("remove",this.onRemove,this);this.on("write",
this.onWrite,this);this.on("beforesave",function(){this.isSaving=true},this);this.on("save",function(){this.isSaving=false},this)},getRecordKey:Ext.util.MixedCollection.prototype.getKey,isExecuting:function(a){return this.proxy.isExecuting(a)},cancelLoadRequests:function(){this.isExecuting("list")&&this.proxy.cancelRequests("list");this.isExecuting("open")&&this.proxy.cancelRequests("open")},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,i=a.length;g<i;g++){var h=a[g];if(this.removed.indexOf(h)>=0)b.push(h);else if(this.modified.indexOf(h)>=0)if(h.isValid())h.phantom?c.push(h):d.push(h)}b.length>0&&e.push(["destroy",b]);c.length>0&&
e.push(["create",c]);d.length>0&&e.push(["update",d]);if(i=e.length){b=++this.batchCounter;for(g=0;g<i;++g){a=e[g];f[a[0]]=a[1]}if(this.fireEvent("beforesave",this,f)!==false){for(g=0;g<i;++g){a=e[g];this.doTransaction(a[0],a[1],b)}return b}}return-1},onBeforeLoad:function(){this.isExecuting("open")&&this.proxy.cancelRequests("open")},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)}},getById:function(a){var b=
Zarafa.core.data.MAPIStore.superclass.getById.call(this,a);if(!b){var c=this.findBy(function(d){return this.idComparison(a,d.id)},this);if(c>=0)b=this.getAt(c)}return b},idComparison:function(a,b){return a===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)},clearData:function(){this.data.each(function(a){a.destroy()});Zarafa.core.data.MAPIStore.superclass.clearData.apply(this,arguments)},sortBy:function(a,b){this.data.sort(a,b);this.snapshot&&this.snapshot!=this.data&&this.snapshot.sort(a,b);this.fireEvent("datachanged",this)},clearGrouping:function(){this.groupField&&
Zarafa.core.data.MAPIStore.superclass.clearGrouping.apply(this,arguments)},destroy:function(){this.isDestroyed||this.cancelLoadRequests();Zarafa.core.data.MAPIStore.superclass.destroy.apply(this,arguments)}});Ext.reg("zarafa.mapistore",Zarafa.core.data.MAPIStore);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,b){a=[].concat(a);
if(!(a.length<1)){for(var c=0,d=a.length;c<d;c++)a[c].join(this);c=this.data.length;this.data.addAll(a);this.snapshot&&this.snapshot.addAll(a);b!==true&&this.fireEvent("add",this,a,c)}},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(){for(var a=this.modified.slice(0),b=0,c=a.length;b<c;b++){var d=a[b];d.phantom=false;d.commit()}this.modified=[];this.removed=[]},clearData:function(){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,query:Ext.data.Store.prototype.query,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");
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=="hierarchynotifier"||a=="newmailnotifier"?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=[];if(a.folders||a.newmail){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})}else if(a.stores){c=container.getHierarchyStore();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.Notifications={newMail:"newMail",objectCreated:"objectCreated",objectDeleted:"objectDeleted",objectModified:"objectModified"};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.RecordDefinition=Ext.extend(Ext.util.Observable,{parent:undefined,type:undefined,cfg:undefined,base:undefined,subStores:undefined,fields:undefined,defaults:undefined,createDefaults:undefined,constructor:function(a){this.addEvents(["createphantom","createrecord"]);this.parent=a.parent;delete a.parent;this.cfg=Ext.apply({},a);Zarafa.core.data.RecordDefinition.superclass.constructor.call(this,a)},createRecord:function(a,b){var c=this.getType(),d={};Ext.apply(d,this.getFieldDefaultValues());
Ext.isDefined(b)||Ext.apply(d,this.getDefaultValues());a&&Ext.apply(d,a);c=new c(d,b,this);c.phantom?this.fireEvent("createphantom",c,a):this.fireEvent("createrecord",c,a);c.commit();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.cfg.base=a},getBaseClass:function(){if(!Ext.isDefined(this.base))this.base=this.cfg.base?this.cfg.base:Ext.isDefined(this.parent)?
this.parent.getBaseClass():Ext.data.Record;return this.base},setSubStore:function(a,b){this.cfg.subStores=Ext.value(this.cfg.subStores,{});this.cfg.subStores[a]=b},getSubStores:function(){if(!this.subStores){this.subStores={};Ext.isDefined(this.parent)&&Ext.apply(this.subStores,this.parent.getSubStores());Ext.apply(this.subStores,this.cfg.subStores)}return Ext.apply({},this.subStores)},addField:function(a){this.cfg.fields=Ext.value(this.cfg.fields,[]);if(Ext.isArray(a))this.cfg.fields=this.cfg.fields.concat(a);
else this.cfg.fields.push(a)},getFields:function(){if(!this.fields){this.fields=[];if(Ext.isDefined(this.parent))this.fields=this.fields.concat(this.parent.getFields());if(this.cfg.fields)this.fields=this.fields.concat(this.cfg.fields)}return this.fields},addDefaultValue:function(a,b){this.cfg.defaults=Ext.value(this.cfg.defaults,{});this.cfg.defaults[Ext.isString(a)?a:a.name]=b},getDefaultValues:function(){if(!this.defaults){this.defaults={};Ext.isDefined(this.parent)&&Ext.apply(this.defaults,this.parent.getDefaultValues());
this.cfg.defaults&&Ext.apply(this.defaults,this.cfg.defaults)}return this.defaults},getFieldDefaultValues:function(){if(!this.fieldDefaults){var a=this.getFields();this.fieldDefaults={};for(var b=0,c=a.length;b<c;b++){var d=a[b],e=d.defaultValue;if(!Ext.isDefined(e))e=Ext.data.Field.prototype.defaultValue;this.fieldDefaults[d.name]=e}Ext.apply(this.fieldDefaults,this.cfg.createDefaults)}return this.fieldDefaults},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.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);Ext.isDefined(d)||(d=this.definitions.IPM);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.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.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.ZarafaCustomEventDispatcher=Ext.extend(Ext.util.Observable,{constructor:function(a){Zarafa.core.data.ZarafaCustomEventDispatcher.superclass.constructor.call(this,a)}});Zarafa.core.data.ZarafaCustomEventDispatcher=new Zarafa.core.data.ZarafaCustomEventDispatcher;Ext.ns("Zarafa.core.plugins");
Zarafa.core.plugins.ComboAutoWidth=Ext.extend(Ext.util.Observable,{init:function(a){this.container=a;a.mon(a.store,"load",this.resizeToFitContent,this);a.on("render",this.resizeToFitContent,this)},resizeToFitContent:function(){var a=this.container,b=a.getStore(),c=0,d=Ext.util.TextMetrics.createInstance(a.el);b.each(function(e){e=d.getWidth(e.get(a.displayField));if(e>c)c=e});if(c>0){c=Math.max(a.minListWidth,c);c+=a.getTriggerWidth();if(a.getWidth()<c)if(a.list)a.list.setWidth(c);else a.listWidth=
c}}});Ext.preg("zarafa.comboautowidth",Zarafa.core.plugins.ComboAutoWidth);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.TabCloseMenuPlugin=Ext.extend(Ext.ux.TabCloseMenu,{createMenu:function(){if(!this.menu){var a=[{itemId:"close",text:this.closeTabText,scope:this,handler:this.onClose}];this.showCloseAll&&a.push("-");a.push({itemId:"closeothers",text:this.closeOtherTabsText,scope:this,handler:this.onCloseOthers});this.showCloseAll&&a.push({itemId:"closeall",text:this.closeAllTabsText,scope:this,handler:this.onCloseAll});var b=container.populateInsertionPoint("main.content.tabpanel.tabclosemenu");
this.menu=new Ext.menu.Menu({items:a.concat(b)})}return this.menu},onClose:function(){this.active.close()},doClose:function(a){this.tabs.items.each(function(b){if(b.closable)if(!a||b!=this.active)b.close()},this)}});Ext.preg("zarafa.tabclosemenuplugin",Zarafa.core.plugins.TabCloseMenuPlugin);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.ui");
Zarafa.core.ui.ContentPanel=Ext.extend(Ext.Container,{title:undefined,closeAction:"closeWrap",standalone:false,width:800,height:550,iconCls:undefined,useInputAutoFocusPlugin:true,constructor:function(a){a=a||{};if(a.useInputAutoFocusPlugin!==false){a.plugins=Ext.value(a.plugins,[]);a.plugins.push({ptype:"zarafa.inputautofocusplugin"})}Ext.applyIf(a,{xtype:"zarafa.contentpanel",stateful:true});Zarafa.core.ui.ContentPanel.superclass.constructor.call(this,a);this.initializeChildComponent(this);Ext.isDefined(this.title)&&
this.setTitle(this.title);this.standalone||Zarafa.core.data.ContentPanelMgr.register(this)},afterRender:function(){Zarafa.core.ui.ContentPanel.superclass.afterRender.apply(this,arguments);var a=this.getXTypes();a=a.replace("component/box/container/zarafa.contentpanel","");a=a.replace(/\/zarafa\./g,".");a="contentpanel"+a.replace(/contentpanel/g,"");Zarafa.core.KeyMapMgr.activate(this,a)},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(){this.fireEvent("beforeclose",this)!==false&&this.doClose()},doClose:function(){this.fireEvent("close",this);Zarafa.core.data.ContentPanelMgr.unregister(this)},closeWrap:function(){this.close()},setTitle:function(a){this.title=a;this.fireEvent("titlechange",
this,a)},setIcon:function(a){var b=this.iconCls;this.iconCls=a;this.fireEvent("iconchange",this,a,b)},isModal:function(){return this.modal},getStateName:function(){return"dialogs/"+Zarafa.core.ui.ContentPanel.superclass.getStateName.call(this)},getState:function(){var a=Zarafa.core.ui.ContentPanel.superclass.getState.call(this)||{};return Ext.apply(a,this.getSize())}});Ext.reg("zarafa.contentpanel",Zarafa.core.ui.ContentPanel);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,layout:"fit",defaults:{border:false,autoScroll:false,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.MainContentTabPanel=Ext.extend(Ext.TabPanel,{onItemTitleChanged:function(a,b){var c=this.getTabEl(a);if(c){c=Ext.get(c).child(".x-tab-strip-text",true);c.qtip=b;c.innerHTML=Ext.util.Format.htmlEncodeElide(b,20,0)}},onItemIconChanged:function(a,b,c){a=this.getTabEl(a);if(!Ext.isEmpty(a)){if(c)c=c.split(" ");a=Ext.get(a).child(".x-tab-strip-text");if(b){a.addClass("x-tab-strip-icon");a.replaceClass(c,b)}else{a.removeClass("x-tab-strip-icon");a.removeClass(c)}}},onItemUserUpdateRecord:function(a,
b,c){if(a=this.getTabEl(a)){a=Ext.get(a).child(".x-tab-strip-text");b.phantom||c?a.addClass("zarafa-tab-edited"):a.removeClass("zarafa-tab-edited")}},initTab:function(a,b){var c=a.title;if(!Ext.isEmpty(c)){a.tabTip=c;a.title=Ext.util.Format.htmlEncodeElide(c,20,0)}Zarafa.core.ui.MainContentTabPanel.superclass.initTab.call(this,a,b);a.on({scope:this,render:this.applyTooltip,iconchange:this.onItemIconChanged,userupdaterecord:this.onItemUserUpdateRecord,close:this.onTabClose})},applyTooltip:function(a){if(a=
Ext.get(a.tabEl).child(".x-tab-strip-close",true))a.qtip=_("Close")+" (Ctrl + Alt + W)"},onTabClose:function(a){if(this.fireEvent("beforeclose",a)!==false){this.remove(a);this.fireEvent("close",a)}},onTabAddClick:function(){var a=container.getCurrentContext().getModel();if(a)if(a=a.createRecord())Zarafa.core.data.UIFactory.openCreateRecord(a);else{a=container.getMainPanel().mainToolbar.newButton;a.handler.call(a.scope)}},onRender:function(a,b){Zarafa.core.ui.MainContentTabPanel.superclass.onRender.call(this,
a,b);var c=this.edge.update("<span id=\"zarafa-mainpanel-addtabbutton\" class='x-tab-add'></span>");this.mon(c,"click",this.onTabAddClick,this);c.child(".x-tab-add",true).qtip=_("New item")+" (Ctrl + Alt + N)"},onStripMouseDown:function(a){if(a.button===0){a=this.findTargets(a);if(a.close)a.item.close();else a.item&&a.item!=this.activeTab&&this.setActiveTab(a.item)}},getScrollWidth:function(){return this.edge.getOffsetsTo(this.stripWrap)[0]+this.getScrollPos()+this.edge.getWidth()}});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.on("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)}}});Ext.reg("zarafa.maintab",Zarafa.core.ui.MainTab);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MainTabBar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.maintabbar",id:"zarafa-mainmenu",cls:"zarafa-maintabbar",defaultType:"zarafa.maintab"});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");this.addTooltip(a,b);var c={xtype:"tbtext",width:"auto",cls:"zarafa-maintabbar-logintext",text:container.getUser().getDisplayName(),id:"mainmenu-logintext"},d={text:_("Logout"),handler:this.onLogoutButton,id:"mainmenu-button-logout"};this.add(a,{xtype:"tbfill"},c,b,d)},addTooltip:function(a,b){var c=[];c=c.concat(a,b);Ext.each(c,function(d,e){d.tooltip=d.text+" (Ctrl + "+e+")"})},onLogoutButton:function(){container.logout()}});Ext.reg("zarafa.maintabbar",Zarafa.core.ui.MainTabBar);
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:242,minSize:150});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.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",id:"zarafa-mainview",layout:"border",cls:"zarafa-panel-body",border:false,items:[this.createTopbarContainer(),this.createNavigationPanel(),this.createTodayPanel(),this.createContentContainer()]}]});Zarafa.core.ui.MainViewport.superclass.constructor.call(this,a);Zarafa.core.KeyMapMgr.activate(null,
"global",Ext.getBody());Zarafa.core.KeyMapMgr.activate(null,"globaldisable",Ext.getBody())},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:_("Zarafa"),numColumns:1,stateful:true,statefulName:"todaybar",
statefulRelativeDimensions:false,settingsPath:"zarafa/v1/contexts/today/sidebar",collapsed:true})},getWidgetPanel:function(){return this.widgetPanel},createContentContainer:function(){var a=new Zarafa.core.ui.ContextContainer({name:"main.content",id:"zarafa-mainpanel-content"}),b=container.populateInsertionPoint("main.content.tabpanel",this);return this.contentPanel=new Zarafa.core.ui.MainContentTabPanel({id:"zarafa-mainpanel",activeTab:0,region:"center",enableTabScroll:true,layoutOnTabChange:true,
items:[a].concat(b),plugins:["zarafa.tabclosemenuplugin"],cls:"zarafa-body-tabbar"})},getContentPanel:function(){return this.contentPanel},createTopbarContainer:function(){return new Ext.Container({name:"main.topbar",region:"north",layout:"border",height:90,items:[new Zarafa.core.ui.MainTabBar({name:"main.maintabbar",region:"center",height:36,boxMinHeight:36,boxMaxHeight:36,ref:"../../mainTabBar"}),new Zarafa.core.ui.MainToolbar({name:"main.toolbar",region:"south",height:54,boxMinHeight:54,boxMaxHeight:54,
ref:"../../mainToolbar"})]})}});Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.PreviewPanel=Ext.extend(Ext.Panel,{model:undefined,recordComponentPlugin:undefined,recordComponentPluginConfig:undefined,record:undefined,isLoadMaskShown:false,loadMask:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",stateful:true,minWidth:200,minHeight:200,xtype:"zarafa.previewpanel"});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",{scope:this,model:a.model})];a.tbar.items=Ext.flatten(b);a.plugins=Ext.value(a.plugins,[]);a.plugins.push(Ext.applyIf(a.recordComponentPluginConfig||{},{ptype:"zarafa.recordcomponentplugin",useShadowStore:true,allowWrite:false}));a.plugins.push({ptype:"zarafa.recordcomponentupdaterplugin"},{ptype:"zarafa.enablefocusplugin"});container.getSettingsModel().get("zarafa/v1/contexts/mail/readflag_time_enable")===
true&&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.on({beforeloadrecord:this.onBeforeLoadRecord,loadrecord:this.onLoadRecord,exceptionrecord:this.onExceptionRecord,show:this.onPreviewPanelShow,expand:this.onPreviewPanelShow,scope:this})},afterRender:function(){Zarafa.core.ui.PreviewPanel.superclass.afterRender.apply(this,arguments);var a=
this.getXTypes();a=a.replace("component/box/container/panel/zarafa.previewpanel","");a=a.replace(/\/zarafa\./g,".");a="previewpanel"+a.replace(/previewpanel/g,"");Zarafa.core.KeyMapMgr.activate(this,a)},setRecord:function(a){for(var b=0;b<this.toolbars.length;b++)this.toolbars[b].setVisible(!!a);this.recordComponentPlugin&&this.recordComponentPlugin.setRecord(a)},update:function(a){this.record=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.isLoadMaskShown&&this.hideLoadMask();this.setRecord(a);return}this.removeAll();b&&this.add(new b);this.setRecord(a);this.doLayout();this.hideLoadMask()}},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.isLoadMaskShown!==true){if(!this.loadMask)this.loadMask=new Zarafa.common.ui.LoadMask(this.el);if(a)this.loadMask.showError();else{this.loadMask.show();this.isLoadMaskShown=true}}},hideLoadMask:function(){if(this.isLoadMaskShown!==false)if(this.loadMask){this.loadMask.hide();this.isLoadMaskShown=false}},onBeforeLoadRecord:function(){this.showLoadMask()},onLoadRecord: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.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.isFunction(d.setActiveItem))d.setActiveItem(a);else this.activeItem=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.isFunction(a.setActiveItem)?a.activeItem:this.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.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.on("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}}},onAddItem:function(a,b){if(b.isXType("menuitem")&&Ext.isDefined(b.recordComponentUpdaterPlugin)){var c=b.itemTpl.apply({id:b.id,cls:b.cls,href:"#",hrefTarget:"",iconCls:b.iconCls,text:b.overflowText}),d=new Ext.Element(document.createElement("div"));d.dom.outerHTML=
c;c=d.dom.innerHTML;b.getEl().dom.innerHtml=c}}});Ext.reg("zarafa.toolbar",Zarafa.core.ui.Toolbar);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=this.model||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.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.onDestroy();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,onDestroy:Ext.emptyFn});Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.WelcomeViewport=Ext.extend(Ext.Viewport,{savingEl:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:{type:"vbox",align:"stretch"},items:[{xtype:"container",flex:0.5},{layout:{type:"hbox"},xtype:"container",items:[{xtype:"container",flex:0.5},{xtype:"panel",cls:"zarafa-welcome-body",border:false,items:[{xtype:"displayfield",cls:"zarafa-welcome-title",value:_("Welcome to Zarafa WebApp")},{xtype:"displayfield",cls:"zarafa-welcome-message",value:_("This is the first time you are using WebApp. <br />Please check the following settings before continuing.")},
{xtype:"zarafa.settingswelcomecategory",ref:"../../settingsCategory"}],buttonAlign:"right",buttons:[{cls:"zarafa-action",text:_("Continue"),handler:this.onContinueButton,scope:this}]},{xtype:"container",flex:0.5}]},{xtype:"container",flex:0.5}]});Zarafa.core.ui.WelcomeViewport.superclass.constructor.call(this,a);this.settingsCategory.update(container.getSettingsModel());container.getSettingsModel().autoSave=false},onContinueButton:function(){var a=container.getSettingsModel();a.beginEdit();this.settingsCategory.updateSettings(a);
a.set("zarafa/v1/main/show_welcome",false);a.endEdit();this.mon(a,"save",this.onSettingsSave,this,{single:true});this.mon(a,"exception",this.onSettingsException,this,{single:true});this.savingEl=container.getNotifier().notify("info.saving","",_("Saving")+"...",{container:this.getEl(),persistent:true});a.save()},onSettingsSave:function(){container.getNotifier().notify("info.saving",null,null,{container:this.getEl(),destroy:true,reference:this.savingEl});Zarafa.core.Util.disableLeaveRequester();window.location.reload()},
onSettingsException:function(){container.getNotifier().notify("info.saving",null,null,{container:this.getEl(),destroy:true,reference:this.savingEl})}});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,itemTpl:new Ext.XTemplate('<a id="{id}" class="{cls} x-unselectable" hidefocus="true" unselectable="on" href="{href}"','<tpl if="hrefTarget">',' target="{hrefTarget}"',"</tpl>",">",'<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}" {iconStyle}/>','<span class="x-menu-item-text">{text}</span>',"</a>"),getTemplateArgs:function(){var a=
Zarafa.core.ui.menu.ConditionalItem.superclass.getTemplateArgs.call(this);a.iconStyle=this.iconBG?'style="background-color:'+this.iconBG+';"':"";return a},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}},applySelectionFilter:function(){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:function(a){a.applySelectionFilter()},
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.menu");
Zarafa.core.ui.menu.ConditionalMenu=Ext.extend(Ext.menu.Menu,{records:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.conditionalmenu",shadow:false});Zarafa.core.ui.menu.ConditionalMenu.superclass.constructor.call(this,a);this.on("beforeshow",this.onMenuBeforeShow,this);this.on("hide",this.onMenuHide,this)},onMenuBeforeShow:function(a){var b=this.records,c=false,d=-1;a.items.each(function(i,h){if(i.isXType("zarafa.conditionalitem")){if(Ext.isFunction(i.beforeShow))i.beforeShow.call(i.scope||
i,i,b);Ext.isDefined(i.menu)&&this.onMenuBeforeShow(i.menu)}if(i.isXType("menuseparator")){i.setVisible(c===true);c=false}else if(i.hidden===false){c=true;d=h}},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},onMenuHide:function(a){!Ext.isDefined(a.ownerCt)&&!Ext.isDefined(a.parentMenu)&&a.destroy()}});Ext.reg("zarafa.conditionalmenu",Zarafa.core.ui.menu.ConditionalMenu);Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.Widget=Ext.extend(Ext.ux.Portlet,{info:undefined,guid:undefined,hasConfig:false,about:undefined,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,{title:a.info.getDisplayName(),anchor:"100%",frame:true,collapsible:true,draggable:{ddGroup:"dd.widget"},tools:b});Zarafa.core.ui.widget.Widget.superclass.constructor.call(this,
a);this.initWidget()},initWidget:function(){Ext.isEmpty(this.about)||this.registerAboutText(this.title,this.about)},registerAboutText:function(a,b){this.tools.splice(this.tools.length-1,0,{id:"help",handler:this.showAbout,scope:this,title:a,text:b})},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,showAbout:function(a,b,c,d){(new Ext.Window({title:d.title,width:320,height:200,padding:5,autoScroll:true,items:[{xtype:"panel",layout:"form",border:false,items:[{xtype:"displayfield",value:d.text,hideLabel:true,htmlEncode:false}]}]})).show(this)}});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.common");
Zarafa.common.Actions={downloadFrame:undefined,openCopyMoveContent:function(a,b){b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.dialog.copymoverecords"],a,b)},openRecurrenceContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];b=Ext.applyIf(b||{},{autoSave:true,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.dialog.recurrence"],a,b)},openCategoriesContent:function(a,
b){Ext.isArray(a)||(a=[a]);b=Ext.applyIf(b||{},{autoSave:true,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.dialog.categories"],a,b)},openLegacyFileSelectionContent:function(a){a=Ext.applyIf(a||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.attachment.dialog.legacyfileselection"],undefined,a)},openAttachItemSelectionContent:function(a,b){b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem"],
a,b)},openWidgetsContent:function(a){Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.dialog.widgets"],undefined,a)},openViewRecipientContent:function(a,b){if(a.isResolved()){if(a.isPersonalContact()){a=a.convertToContactRecord();container.getShadowStore().add(a)}else if(a.isPersonalDistList()){a=a.convertToDistListRecord();container.getShadowStore().add(a)}else if(!a.isOneOff()){a=a.convertToABRecord();container.getShadowStore().add(a)}b=Ext.applyIf(b||{},
{manager:Ext.WindowMgr});Zarafa.core.data.UIFactory.openViewRecord(a,b)}},openDelegatePermissionContent:function(a,b){if(a){b=b||{};Ext.apply(b,{modal:true});Zarafa.core.data.UIFactory.openCreateRecord(a,b)}},openSendAsRecipientContent:function(a,b){if(a){var c=Zarafa.core.data.SharedComponentType["common.sendas.dialog.sendaseditcontentpanel"];b=b||{};Ext.apply(b,{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,a,b)}},openRulesEditContent:function(a,b){if(a){b=Ext.apply(b||{},{modal:true});
Zarafa.core.data.UIFactory.openCreateRecord(a,b)}},openSaveEmlDialog:function(a,b){a=[].concat(a);var c;if(b){c=new Zarafa.common.attachment.ui.AttachmentDownloader;c.downloadMessageAsZip(a)}else for(var d=0;d<a.length;d++){var e=a[d];c=new Zarafa.common.attachment.ui.AttachmentDownloader;c.downloadItem(e.getDownloadMessageUrl(false))}},openPrintDialog:function(a){if(!Ext.isEmpty(a)){if(Ext.isArray(a))if(a.length>1){Ext.MessageBox.alert(_("Print"),_("Printing of multiple items has not been implemented."));
return}else a=a[0];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 instanceof Zarafa.core.data.MAPIRecord&&
!a.isOpened()){a.getStore().on("open",b,a);a.open()}else b(undefined,a)}},openCheckNamesContent:function(a,b,c){var d=Zarafa.core.data.SharedComponentType["common.dialog.checknames"];c=Ext.applyIf(c||{},{checkNamesData:a,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(d,b,c)},openReminderContent:function(a,b){var c=Zarafa.core.data.SharedComponentType["common.dialog.reminder"],d=container.getSharedComponent(c,a);b=Ext.applyIf(b||{},{modal:false,manager:Ext.WindowMgr});d=Zarafa.core.data.ContentPanelMgr.getContentPanelInstances(d);
if(d.getCount()===0)a.length>0&&Zarafa.core.data.UIFactory.openLayerComponent(c,a,b);else if(d.getCount()===1){c=d.first();a.length>0?c.focus():c.close()}},openReminderRecord:function(a,b){b=b||{};if(Ext.isArray(a))Ext.each(a,this.openReminderRecord,this);else{a=a.convertToIPMRecord();Ext.applyIf(b,{manager:Ext.WindowMgr});a&&Zarafa.core.data.UIFactory.openViewRecord(a,b)}},openRecurringSelectionContent: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"}])},deleteRecurringSelectionContent: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"}])},deleteMeetingRequestConfirmationContent: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 i=Ext.isFunction(g.isRecurringOccurence)&&g.isRecurringOccurence()&&b!==false,h=g.get("message_class");if(Zarafa.core.MessageClass.isClass(h,"IPM.Schedule.Meeting",true)||Zarafa.core.MessageClass.isClass(h,"IPM.TaskRequest",true))i=false;if(i)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.deleteMeetingRequestConfirmationContent(g,this.declineInvitation,g);else{c.remove(g);d.push(g)}else{c.remove(g);
d.push(g)}}Ext.isEmpty(d)||c.save(d);c.totalLoadedRecord&&a.length===c.totalLoadedRecord&&c.showLoadMask()}},deleteRecurringItem:function(a){Zarafa.common.Actions.deleteRecurringSelectionContent(a,function(b,c){if(b=="ok"){a=c.id!="recurrence_series"?a.convertToOccurenceRecord():a.convertToSeriesRecord();container.getShadowStore().add(a);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)},openRestoreContent:function(a,b){var c=Zarafa.core.data.SharedComponentType["common.dialog.restoreitems"];b=Ext.applyIf(b||{},{folder:a});Zarafa.core.data.UIFactory.openLayerComponent(c,undefined,b)},openABUserSelectionContent:function(a){var b=Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"];a=Ext.applyIf(a||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(b,undefined,a)},openABUserMultiSelectionContent:function(a){a=a||
{};Ext.applyIf(a,{modal:true,convert:function(b){return b}});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.abmultiuserselection"],undefined,a)},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())if(b===true&&f.needsReadReceipt())switch(container.getSettingsModel().get("zarafa/v1/contexts/mail/readreceipt_handling")){case "never":f.setReadFlags(b);f.addMessageAction("send_read_receipt",
false);c.push(f);break;case "always":f.setReadFlags(b);f.addMessageAction("send_read_receipt",true);c.push(f);break;case "ask":default: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){this.setReadFlags(b);this.addMessageAction("send_read_receipt",g!=="no");this.save()},f);break}else{f.setReadFlags(b);c.push(f)}}Ext.isEmpty(c)||c[0].store.save(c)},downloadAttachment:function(a,
b){if(!this.downloadFrame)this.downloadFrame=new Zarafa.common.attachment.ui.AttachmentDownloader;this.downloadFrame.checkForEmbeddedAttachments(a,b)},openRulesWordsEditContent:function(a){Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.rules.dialog.ruleswordsedit"],undefined,a)},openAttachmentRecord:function(a,b){if(a.isEmbeddedMessage())a=a.convertToIPMRecord();a&&Zarafa.core.data.UIFactory.openViewRecord(a,b)},openMessageContent:function(a,b){Ext.each(a,
function(c){c.isUnsent()&&!c.isFaultyMessage()?Zarafa.core.data.UIFactory.openCreateRecord(c,b):Zarafa.core.data.UIFactory.openViewRecord(c,b)})}};Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachItemPanel=Ext.extend(Ext.Panel,{record:undefined,editor:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{layout:{type:"vbox",align:"stretch",pack:"start",padding:10},items:[{xtype:"displayfield",value:_("Look in:"),hideLabel:true,height:20},{xtype:"container",flex:1,layout:{type:"hbox",align:"stretch",pack:"start"},items:[{xtype:"zarafa.hierarchytree",flex:1,border:true,enableDD:false,treeSorter:true,ref:"../hierarchyTree",listeners:{load:this.onTreeNodeLoad,
scope:this}},{xtype:"container",width:150,defaults:{style:{margin:"0px 0px 10px 5px"}},style:{padding:"0px 0px 0px 10px"},items:[{xtype:"button",text:_("Ok"),disabled:true,cls:"zarafa-action",ref:"../../okButton",handler:this.onOK,scope:this},{xtype:"button",text:_("Cancel"),ref:"../../cancelButton",handler:this.onCancel,scope:this},{xtype:"fieldset",title:_("Insert as"),padding:"0px 5px 5px 5px",layout:{type:"fit"},items:[{xtype:"radiogroup",vertical:true,columns:1,ref:"../../../attachTypeRadioGroup",
defaults:{style:{margin:"5px 0px 0px 5px"}},items:[{xtype:"radio",boxLabel:_("Text only"),inputValue:"text_only",name:"attach_item"},{xtype:"radio",boxLabel:_("Attachment"),inputValue:"attachment",name:"attach_item"}],listeners:{afterrender:this.onRadioGroupAfterRender,change:this.onRadioSelectionChange,scope:this}}]}]}]},{xtype:"zarafa.attachitemgrid",flex:1,ref:"attachItemGrid"}]});Zarafa.common.attachment.dialogs.AttachItemPanel.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.common.attachment.dialogs.AttachItemPanel.superclass.initEvents.apply(this,
arguments);this.mon(this.hierarchyTree.getSelectionModel(),"selectionchange",this.onTreeSelectionChange,this);this.mon(this.attachItemGrid.getSelectionModel(),"selectionchange",this.onGridSelectionChange,this)},onOK:function(){this.attachItem()},onCancel:function(){this.dialog.close()},onTreeNodeLoad:function(){this.hierarchyTree.selectFolderInTree(this.dialog.getSelectedFolder())&&this.mun(this.hierarchyTree,"load",this.onTreeNodeLoad,this)},onRadioGroupAfterRender:function(a){var b=this.dialog.getSelectedRadioItem();
a.setValue(b)},onRadioSelectionChange:function(a,b){this.dialog.setRadioItemInState(b)},onTreeSelectionChange:function(a,b){var c=b.getFolder(),d=this.dialog.getStoreByFolder(c),e=this.dialog.getColumnModelByFolder(c);this.attachItemGrid.reconfigure(d,e);d.load();this.dialog.setFolderInState(c)},onGridSelectionChange:function(a){this.okButton.setDisabled(a.getCount()===0)},attachItem:function(){var a=this.attachItemGrid.getSelectionModel().getSelected(),b=this.attachTypeRadioGroup.getValue().inputValue;
if(Ext.isEmpty(a))Ext.MessageBox.alert(_("Attach Item"),_("No message selected"));else b==="text_only"?this.attachItemAsText(a):this.attachItemAsAttachment(a)},attachItemAsAttachment:function(a){this.record.getAttachmentStore().addEmbeddedAttachment(a);this.dialog.close()},attachItemAsText:function(a){if(a.isOpened()){this.dialog.editor.insertAtCursor(this.dialog.getRendererByMessage(a).generateText(a,this.record.get("isHTML")));this.dialog.close()}else this.openRecord(a,this.attachItemAsText)},openRecord:function(a,
b){this.dialog.showLoadMask();var c=a.getStore(),d=function(f,g){if(a===g){c.un("open",d,this);c.un("exception",e,this);this.dialog.hideLoadMask();b.call(this,a)}},e=function(f,g,i){if(i===Ext.data.Api.actions.open){c.un("open",d,this);c.un("exception",e,this);this.dialog.hideLoadMask()}};c.on("open",d,this);c.on("exception",e,this);a.open()}});Ext.reg("zarafa.attachitempanel",Zarafa.common.attachment.dialogs.AttachItemPanel);Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.MixAttachItemPanel=Ext.extend(Ext.Panel,{records:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.mixattachitempanel",border:false,items:[{xtype:"fieldset",layout:"form",anchor:"100% 30%",header:true,iconCls:"mixattach-message-box-icon",border:false,items:this.getMixAttachComponents()}]});Zarafa.common.categories.dialogs.CategoriesPanel.superclass.constructor.call(this,a)},getMixAttachComponents:function(){return[{xtype:"displayfield",value:_("These attachments have an unsupported file type and can not be added to the ZIP file:"),
hideLabel:true,htmlEncode:true},{xtype:"textarea",hideLabel:true,anchor:"100%",style:"padding-left: 5px;",readOnly:true,listeners:{afterrender:this.onAfterRenderTextArea,scope:this}},{xtype:"displayfield",value:_("Would you like to continue downloading without adding these files?"),hideLabel:true,htmlEncode:true},{xtype:"checkbox",ref:"../../dontShowCheckBox",boxLabel:_("Always continue download of ZIP files without adding unsupported file types."),hideLabel:true,scope:this}]},onAfterRenderTextArea:function(a){var b=
"";Ext.each(this.records,function(c){if(c.isEmbeddedMessage())b+=c.get("name")+"\n"});a.setValue(b)}});Ext.reg("zarafa.mixattachitempanel",Zarafa.common.attachment.dialogs.MixAttachItemPanel);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentButton=Ext.extend(Ext.SplitButton,{constructor:function(a){a=a||{};Ext.applyIf(a,{menu:{items:[{text:_("File upload"),handler:this.onFileUpload,scope:this,iconCls:"icon_attachment"},{text:_("Attach item"),handler:this.onFileAttach,scope:this,iconCls:"icon_embedded_attachment"},container.populateInsertionPoint("main.attachment.method",this)]},handler:this.onFileUpload,scope:this});Zarafa.common.attachment.ui.AttachmentButton.superclass.constructor.call(this,a)},
onFileUpload:function(){(new Zarafa.common.attachment.ui.UploadAttachmentComponent({callback:this.uploadAttachmentCallback,multiple:true,scope:this})).openAttachmentDialog()},uploadAttachmentCallback:function(a,b){this.record.getSubStore("attachments").uploadFiles(a,b)},onFileAttach:function(){var a=this.findParentByType("zarafa.recordcontentpanel").findByType("zarafa.editorfield");Ext.isEmpty(a)||(a=a[0]);Zarafa.common.Actions.openAttachItemSelectionContent(this.record,{editor:a})},bindRecord:function(a){this.record=
a},update:function(a,b){if(a&&a instanceof Zarafa.core.data.MAPIRecord)b&&this.bindRecord(a);else Zarafa.common.attachment.ui.AttachmentButton.superclass.update.apply(this,arguments)}});Ext.reg("zarafa.attachmentbutton",Zarafa.common.attachment.ui.AttachmentButton);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentDownloader=Ext.extend(Ext.Component,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.attachmentdownloader",renderTo:Ext.getBody(),hidden:true,autoEl:{tag:"iframe",src:Ext.SSL_SECURE_URL}});Zarafa.common.attachment.ui.AttachmentDownloader.superclass.constructor.call(this,a);Ext.EventManager.on(this.getEl(),"load",this.onIframeLoad,this)},downloadItem:function(a){Ext.getDom(this.getEl()).src=a},downloadMessageAsZip:function(a){var b=0;Ext.each(a,function(e){b+=
e.get("message_size")},this);if(b<31457280){var c=a[0].getDownloadMessageUrl(true),d=Ext.getDom(this.getEl()).contentDocument.body;c=Ext.DomHelper.append(d||Ext.getBody(),{tag:"form",action:c,method:"POST"},true);for(d=0;d<a.length;d++)Ext.DomHelper.append(c,{tag:"input",type:"hidden",name:"entryids[]",value:a[d].get("entryid")});if(Ext.isIE10||Ext.isIE9)Zarafa.core.Util.disableLeaveRequester();c.dom.submit();if(Ext.isIE10||Ext.isIE9)Zarafa.core.Util.enableLeaveRequester()}else container.getNotifier().notify("error.attachment",
_("Attachment error"),_("Cannot create ZIP, The allowed maximum size is 30 MB."))},onIframeLoad:function(){var a,b;a=this.getEl().dom.contentDocument;if(!Ext.isEmpty(a))b=a.body.textContent;Ext.isEmpty(b)||this.displaySaveEmailException(Ext.util.JSON.decode(b))},checkForEmbeddedAttachments:function(a,b){var c=false;if(b){var d=container.getSettingsModel().get("zarafa/v1/state/dialogs/mixattachitemcontentpanel/dontshowagain"),e=a.store;!d&&e.getCount()>1&&e.each(function(f){if(f.isEmbeddedMessage()){c=
true;return false}})}c?this.openMixAttachmentsDialog(e.getRange(),{allAsZip:b}):this.downloadItem(a.getAttachmentUrl(b))},openMixAttachmentsDialog:function(a,b){Ext.isArray(a)||(a=[a]);b=Ext.applyIf(b||{},{modal:true,downloadItem:this.downloadItem.createDelegate(this,[a[0].getAttachmentUrl(b.allAsZip)],1)});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.attachment.dialog.mixattachitem"],a,b)},displaySaveEmailException:function(a){Ext.MessageBox.show({title:_("Zarafa WebApp"),
msg:a.zarafa.error.info.display_message,icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})}});Ext.reg("zarafa.attachmentdownloader",Zarafa.common.attachment.ui.AttachmentDownloader);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.UploadAttachmentComponent=Ext.extend(Ext.Component,{callback:Ext.emptyFn,scope:undefined,multiple:false,accept:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.uploadattachmentcomponent"});Zarafa.common.attachment.ui.UploadAttachmentComponent.superclass.constructor.call(this,a)},openAttachmentDialog:function(){if(Zarafa.supportsFilesAPI()){var a=this.getAttachmentEl();a.on("change",this.onFileInputChange,this);a.dom.click()}else Zarafa.common.Actions.openLegacyFileSelectionContent({callback:this.onLegacyFileInputChange,
scope:this})},getAttachmentEl:function(){var a=Ext.DomHelper.append(Ext.getBody(),{cls:"x-hidden",tag:"input",type:"file"});if(Ext.isDefined(this.multiple)&&this.multiple)a.multiple=this.multiple;if(Ext.isDefined(this.accept))a.accept=this.accept;return a=Ext.get(a)},onLegacyFileInputChange:function(a){var b=Ext.pluck(a.items.items,"value");if(this.accept==="image/*")this.isSupportedImage("image/"+Ext.util.Format.basename(b[0]).split(".")[1])?this.callback.call(this.scope,b,a):this.showAttachmentError();
else this.callback.call(this.scope,b,a)},onFileInputChange:function(a){var b=a.browserEvent;a=Ext.get(b.target);b=(b=b.dataTransfer)?b.files:undefined;b=a.dom.files||b;if(this.scope.record.getAttachmentStore().canUploadFiles(b))if(this.accept==="image/*")this.isSupportedImage(b[0].type)?this.callback.call(this.scope,b):this.showAttachmentError();else this.callback.call(this.scope,b);a.remove()},showAttachmentError:function(){var a=_("Picture format is not supported. ");a+=_("Supported format for contact pictures are");
a+="<br/>";a+="JPEG, GIF, PNG, BMP";Ext.MessageBox.show({title:_("Attachment Error"),msg:a,icon:Ext.MessageBox.ERROR,buttons:Ext.MessageBox.OK})},isSupportedImage:function(a){return["image/bmp","image/jpg","image/jpeg","image/gif","image/png"].indexOf(a.toLowerCase())>=0}});Ext.reg("zarafa.uploadattachmentcomponent",Zarafa.common.attachment.ui.AttachmentButton);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.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,defaults:{border:false,bodyStyle:"padding-bottom: 5px; background-color: inherit;"},items:[this.createFormCategoriesField(),this.createFormSelectionArea()]});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(),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.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,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.delegates.dialogs");
Zarafa.common.delegates.dialogs.DelegatePermissionPanel=Ext.extend(Ext.form.FormPanel,{folderTypes:["calendar","tasks","inbox","contacts","notes","journal"],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",
style:{margin:"10px",padding:"10px"},title:_("This delegate has the following permissions"),autoHeight:true,autoWidth:true,cls:"zarafa-fieldset",labelAlign:"left",items:this.createFieldItems(this.folderTypes)},{xtype:"checkbox",boxLabel:_("Delegate can see my private items."),style:"margin-left : 10px;",ref:"delegatePrivateCheck",name:"can_see_private",hideLabel:true,checked:false,listeners:{check:this.onPrivateCheck,scope:this}}]},createDelegateMeetingRuleCheck:function(){return{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}}},createFieldItems:function(a){for(var b=[],c=0;c<a.length;c++){var d={xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.delegates.data.DelegatePermissionProfiles};d={xtype:"combo",name:"rights_"+a[c],boxMinWidth:200,anchor:"100%",fieldLabel:Ext.util.Format.capitalize(a[c]),
store:d,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,valueNotFoundText:_("Other"),forceSelection:true,editable:false,value:Zarafa.core.mapi.Rights.RIGHTS_NONE,listeners:{select:this.onProfileSelect,scope:this}};b.push(d);a[c]==="calendar"&&b.push(this.createDelegateMeetingRuleCheck())}return b},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.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,b){b=b||{};if(a=a||this.getSelectionModel().getSelected()){Ext.apply(b,{recordComponentPluginConfig:{enableOpenLoadTask:false}});Zarafa.common.Actions.openDelegatePermissionContent(a,b)}else Ext.Msg.alert(_("Alert"),_("Please select a delegate."))},removeDelegate:function(){var a=this.getSelectionModel(),b=a.getSelected();
if(b){if(a.hasNext())a.selectNext();else a.hasPrevious()&&a.selectPrevious();this.store.remove(b)}else Ext.Msg.alert(_("Alert"),_("Please select a delegate."))}});Ext.reg("zarafa.delegatesgrid",Zarafa.common.delegates.ui.DelegatesGrid);Ext.namespace("Zarafa.common.delegates.ui");
Zarafa.common.delegates.ui.DelegatesPanel=Ext.extend(Ext.Panel,{store:undefined,loadMask: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 send-on-behalf-of privileges, go to properties for each folder and change the options on the Permissions Tab."),
fieldClass:"x-form-display-field zarafa-settings-widget-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,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)},showLoadMask:function(){if(!this.loadMask)this.loadMask=
new Zarafa.common.ui.LoadMask(this.el);this.loadMask.show()},hideLoadMask:function(){this.loadMask&&this.loadMask.hide()},onDelegateAdd:function(){Zarafa.common.Actions.openABUserSelectionContent({callback:this.abCallBack,scope:this,hierarchyRestriction:{hide_contacts:true},listRestriction:{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.openDelegatePermissions(b,true)},openDelegatePermissions:function(a){a.isOpened()?this.delegatesGrid.openDelegatePermissions(a,{removeRecordOnCancel:true}):this.openDelegateRecord(a,this.openDelegatePermissions)},openDelegateRecord:function(a,b){this.showLoadMask();var c=a.getStore(),
d=function(f,g){if(a===g){c.un("open",d,this);c.un("exception",e,this);this.hideLoadMask();b.call(this,a)}},e=function(f,g,i){if(i===Ext.data.Api.actions.open){c.un("open",d,this);c.un("exception",e,this);this.hideLoadMask()}};c.on("open",d,this);c.on("exception",e,this);a.open()},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.dialogs");
Zarafa.common.dialogs.CopyMovePanel=Ext.extend(Ext.Panel,{record:undefined,objectType:undefined,store:undefined,constructor:function(a){a=a||{};if(a.record){if(Ext.isArray(a.record))this.store=a.record[0].getStore();else{a.record=[a.record];this.store=a.record.getStore()}if(!a.objectType)a.objectType=a.record[0].get("object_type")}Ext.applyIf(a,{xtype:"zarafa.copymovepanel",layout:{type:"vbox",align:"stretch"},border:false,header:true,items:[this.createTreePanel()],buttonAlign:"left",buttons:[{text:_("Move"),
handler:this.onMove,scope:this,ref:"../moveButton",cls:"zarafa-action",disabled:true},{text:_("Copy"),handler:this.onCopy,scope:this,ref:"../copyButton",disabled:true},{text:_("New folder"),handler:this.onCreateFolder,scope:this,ref:"../createFolderButton",disabled:true},"->",{text:_("Cancel"),handler:this.onCancel,cls:"zarafa-normal",scope:this}],listeners:{render:function(){var b=this.findParentByType("window");b&&b.focusEl&&b.focusEl.on("focus",this.onDialogFocussed,this);Zarafa.core.KeyMapMgr.activate(this,
"Zarafa.common.dialogs.CopyMovePanel")}}});Zarafa.common.dialogs.CopyMovePanel.superclass.constructor.call(this,a)},onDialogFocussed:function(){var a=this.hierarchyTree.ensureFolderVisible(this.dialog.getSelectedFolder());a&&a.select()},createTreePanel:function(){return{xtype:"panel",layout:"vbox",border:false,flex:1,layoutConfig:{align:"stretch"},cls:"copymove-tree-panel",bodyStyle:"background-color: inherit;",items:[{xtype:"container",ref:"displayfieldContainer",items:[{xtype:"displayfield",value:_("Destination folder")+
":",hideLabel:true,cls:"tree-header",ref:"../displayfield"}],autoheight:true},{xtype:"zarafa.hierarchytree",flex:1,border:true,treeSorter:true,enableDD:false,anchor:"100% 90%",ref:"../hierarchyTree"}],listeners:{afterlayout:function(){this.displayfieldContainer.setHeight(this.displayfield.getHeight())}}}},onRender:function(a,b){Zarafa.common.dialogs.CopyMovePanel.superclass.onRender.call(this,a,b);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())))},initEvents:function(){Zarafa.common.dialogs.CopyMovePanel.superclass.initEvents.apply(this,arguments);this.dialog.getSelectedFolder()&&this.mon(this.hierarchyTree,"load",this.onTreeNodeLoad,this);this.mon(this.hierarchyTree.getSelectionModel(),
"selectionchange",this.onSelectionChange,this)},onTreeNodeLoad:function(){this.hierarchyTree.selectFolderInTree(this.dialog.getSelectedFolder())&&this.mun(this.hierarchyTree,"load",this.onTreeNodeLoad,this)},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();this.createFolderButton.disable()}else{this.copyButton.enable();this.moveButton.enable();this.createFolderButton.enable()}},
onCreateFolder:function(){var a=this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder();Zarafa.hierarchy.Actions.openCreateFolderContent(a);this.mon(this.hierarchyTree,"append",this.onTreeAppend,this,{delay:10})},onTreeAppend:function(a,b,c){c.parentNode||(c=a.getNodeById(c.id));a.selectPath(c.getPath());this.mun(this.hierarchyTree,"append",this.onTreeAppend,this)},onCopy:function(){var a=this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder(),b=this.record;if(Ext.isDefined(a))if(!Ext.isEmpty(this.record)){Ext.each(b,
function(c,d){if(this.objectType===Zarafa.core.mapi.ObjectType.MAPI_MESSAGE&&!c.getStore())c=b[d]=this.store.getById(c.id);c.copyTo(a)},this);this.dialog.selectFolder(a);this.store.save(b);this.dialog.close()}},onMove:function(){var a=this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder(),b=this.record;if(Ext.isDefined(a))if(!Ext.isEmpty(this.record)){Ext.each(b,function(c,d){if(this.objectType===Zarafa.core.mapi.ObjectType.MAPI_MESSAGE&&!c.getStore())c=b[d]=this.store.getById(c.id);
c.moveTo(a)},this);this.dialog.selectFolder(a);this.store.save(b);this.dialog.close()}},onCancel:function(){this.dialog.close()}});Ext.reg("zarafa.copymovepanel",Zarafa.common.dialogs.CopyMovePanel);Ext.namespace("Zarafa.common.dialogs");
Zarafa.common.dialogs.MessageBox=Ext.apply({},Ext.MessageBox,{customButton:undefined,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(i){Ext.callback(c,d||window,[i,g.getValue()],1)},minWidth:Ext.MessageBox.minPromptWidth,scope:d,prompt:false,value:f});return this},addCustomButtons:function(a){var b=Ext.MessageBox.getDialog();this.customButton=b.getFooterToolbar().add(a.customButton);Ext.MessageBox.show(a);Ext.isEmpty(this.customButton)||
Ext.each(this.customButton,function(c){b.mon(c,"click",Ext.createDelegate(this.onButtonClick,a.scope,[a.fn],true),this)},this);b.on("hide",this.onDestroy,this,{single:true});b.on("destroy",this.onDestroy,this,{single:true})},onButtonClick:function(a,b,c){a=a.name||"cancel";Ext.MessageBox.hide();c.call(this,a)},onDestroy:function(a){if(!Ext.isEmpty(this.customButton)){for(var b=0;b<this.customButton.length;b++)a.getFooterToolbar().remove(this.customButton[b]);this.customButton=[]}}});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)}},setCursorLocation:function(){var a=this.getEl().dom,b=Ext.isIE?a.innerText.length:a.textLength,c=a.selectionEnd;a.selectionStart===b&&c===b&&a.setSelectionRange(0,0)}});Ext.reg("zarafa.textarea",Zarafa.common.form.TextArea);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=new Date;b.setHours(12);var c=container.getServerConfig(),d=c.getFreebusyLoadStartOffset();d=b.add(Date.DAY,-d).clearTime();c=c.getFreebusyLoadEndOffset();b=b.add(Date.DAY,c).clearTime();
var e;if(a.selectorRange){c=a.selectorRange.getStartDate();e=a.selectorRange.getDueDate()}else{c=(new Date).ceil(Date.MINUTE,30);e=c.add(Date.MINUTE,30)}Ext.applyIf(a,{userStore:a.userStore||new Zarafa.core.data.IPMRecipientStore,daterange:a.daterange||new Zarafa.core.DateRange({startDate:d,dueDate:b}),selectorRange:new Zarafa.core.DateRange({startDate:c,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.setHours(12);d=d.add(Date.DAY,1).clearTime()}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){d.isResolved()&&c.params.users.push({userid:d.id,entryid:d.get("entryid"),organizer:d.isMeetingOrganizer()})});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?this.blockStore.each(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,c){var d=this.getUserStore();if(!d)return false;d=d.getRange();for(var e=0,f=d.length;e<f;e++){var g=d[e];if((c!==true||g.phantom===true)&&!g.isMeetingOrganizer())if(this.checkAttendeeBusyStatus(g.id,a,b))return true}return false},checkAttendeeBusyStatus:function(a,
b,c){var d=this.getBlockStore();if(!d)return false;d.filter("userid",a,false,true,true);d.sort("start","ASC");b=b.getTime()/1E3;c=c.getTime()/1E3;a=false;for(var e=0,f=d.getCount();e<f;e++){var g=d.getAt(e);if(g.get("end")>b)if(!(g.get("status")===Zarafa.core.mapi.BusyStatus.FREE||g.get("status")===Zarafa.core.mapi.BusyStatus.UNKNOWN)){if(g.get("start")<c)a=true;break}}d.clearFilter();return a}});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:d=this.selectorRange.getDueDate();this.selectionStart=d.getTime()/1E3;break;case this.MOUSE_ON_EDGE_RIGHT:c=this.selectorRange.getStartDate();this.selectionStart=c.getTime()/1E3;break;default:c=new Date(d*1E3);c.round(Date.MINUTE,30);this.selectionStart=c.getTime()/1E3;d=c.add(Date.MINUTE,30);this.selectorRange.set(c,
d)}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.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,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,cls:"x-freebusy-userlist",footer:true,footerCfg:{tag:"div",cls:"x-panel-footer"},border:true,width:200,collapsible:true,split:true,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,cls:"zarafa-freebusy-suggestionlist",
footer:true,footerCfg:{tag:"div",cls:"x-panel-footer"},border:true,width:200,collapsible:true,split:true,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,hideNonWorkingHours:true,listeners:{bodyscroll:this.onTimelineScroll,scope:this}})},createLegendaView:function(){return Ext.applyIf(this.legendaConfig,{xtype:"container",region:"south",border:false,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:24,height:24},{xtype:"displayfield",value:_("Busy"),hideLabel:true,autoWidth:true},
{xtype:"container",cls:"x-freebusy-timeline-block-tentative",width:24,height:24},{xtype:"displayfield",value:_("Tentative"),hideLabel:true,autoWidth:true},{xtype:"container",cls:"x-freebusy-timeline-block-outofoffice",width:24,height:24},{xtype:"displayfield",value:_("Out of Office"),hideLabel:true,autoWidth:true},{xtype:"container",cls:"x-freebusy-timeline-block-blur",width:24,height:24},{xtype:"displayfield",value:_("No Information"),hideLabel:true,autoWidth:true}]})},initFreebusyEvents:function(){this.on("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(!(!Ext.isIE&&(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.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,items:[{xtype:"panel",border:true,autoHeight:true,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:"panel",flex:1,layout:"fit",cls:"suggestionlist",border:false,items:[{xtype:"zarafa.freebusysuggestionlistview",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.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 emptytext">'+_("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="" class="x-unselectable" 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(_("G:i"))}}),store:b,itemSelector:"div.zarafa-freebusy-suggestionrow"});Zarafa.common.freebusy.ui.SuggestionListView.superclass.constructor.call(this,a);this.mon(this.model,"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.TimelineView=Ext.extend(Ext.BoxComponent,{model:null,selector:null,headerHeight:64,defaultHourCellWidth:60,bufferTimesViewportWidth:5,daysMap:null,hoursEachDayMap:null,daySpacing:3,borderSpacing:0,blockRowHeight:30,sumBlockRowHeight:12,extraBodyHeight:0,workingHoursStart:0,workingHoursEnd:24,workDays:undefined,blockSelector:"div.x-freebusy-timeline-block",headerDayHeight:0,headerHoursHeight:24,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,blockstorechange:this.onBlockStoreChange,sumblockstorechange:this.onSumBlockStoreChange,showworkinghourschange:this.onShowWorkingHoursChange,scope: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="0" 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="0" 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="0" 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.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelinebody"],undefined,{position:a.getXY(),model:this.model})},onHeaderContextMenu:function(a){Zarafa.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu.freebusy.timelineheader"],undefined,{position:a.getXY(),model:this.model})},restyleBodyBackground:function(){for(var a="url(data:image/gif;base64,R0lGODlhAQABAIABAObm5v///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAAQABAAACAkQBADs=) repeat-x left top",
b=0;b<=this.userStore.getCount();b++)a+=", url(data:image/gif;base64,R0lGODlhAQABAIABAObm5v///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAAQABAAACAkQBADs=) repeat-x left "+this.blockRowHeight*(b+1)+"px";var c=this.bodyBackgroundElem.query(".x-freebusy-timeline-day");for(b=0;b<c.length;b++)Ext.get(c[b]).setStyle("background",a)},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);this.restyleBodyBackground()}},repaintTimeline:function(){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);this.restyleBodyBackground()},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){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);b.setHours(12);for(c=0;c<this.daterange.getNumDays();c++){d=b.add(Date.DAY,c).clearTime();e=a.getTime()==d.getTime();for(var f=false,g=0,i=this.workDays.length;g<i;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";if(this.model.showOnlyWorkingHours()){b=(new Date(a.start*1E3)).getDay();if(b===6)a.start=(new Date(a.start*1E3)).add(Date.DAY,2).getTime()/1E3;else if(b===0)a.start=(new Date(a.start*1E3)).add(Date.DAY,1).getTime()/1E3}b=this.daysMap[this.findDayIndexByTimestamp(a.start,true)].timestamp;a.start=b}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);if(a-this.daysMap[c].timestamp>=86400)return this.daysMap[c].leftPos+this.dayWidth;var 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){this.userStore&&this.mun(this.userStore,{datachanged:this.onUserRefresh,add:this.onUserAdd,remove:this.onUserRemove,clear:this.onUserRefresh,scope:this});if(this.userStore=Ext.StoreMgr.lookup(a)){this.mon(this.userStore,{datachanged:this.onUserRefresh,add:this.onUserAdd,remove:this.onUserRemove,clear:this.onUserRefresh,scope:this});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.ns("Zarafa.common.plugins");
Zarafa.common.plugins.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(){function a(b){for(var c=this.ownerCt;c;c=c.ownerCt)if(c[b])return c[b]}if(this.ownerCt)if(this.ownerCt.layout instanceof Ext.layout.FormLayout)return;this.resizeEl=(this.wrap||this.el).wrap({cls:"x-form-element",style:Ext.isIE9m&&
!Ext.isIE9||Ext.isOpera?"position:absolute;top:0;left:0;overflow:visible":""});this.positionEl=this.itemCt=this.resizeEl.wrap({cls:"x-form-item "});if(this.nextSibling())this.margins={top:0,right:0,bottom:this.positionEl.getMargins("b"),left:0};this.actionMode="itemCt";if(!Ext.isDefined(this.hideLabels))this.hideLabels=a.call(this,"hideLabels");if(this.hideLabels)this.resizeEl.setStyle("padding-left","0px");else{if(!Ext.isDefined(this.labelSeparator))this.labelSeparator=a.call(this,"labelSeparator");
if(!Ext.isDefined(this.labelPad))this.labelPad=a.call(this,"labelPad");if(!Ext.isDefined(this.labelAlign))this.labelAlign=a.call(this,"labelAlign")||"left";this.itemCt.addClass("x-form-label-"+this.labelAlign);if(this.labelAlign=="top"){if(!this.labelWidth)this.labelWidth="auto";this.resizeEl.setStyle("padding-left","0px")}else{if(!Ext.isDefined(this.labelWidth))this.labelWidth=a.call(this,"labelWidth")||100;this.resizeEl.setStyle("padding-left",this.labelWidth+(this.labelPad||5)+"px");this.labelWidth+=
"px"}this.label=this.itemCt.insertFirst({tag:"label",cls:"x-form-item-label",style:{width:this.labelWidth},html:this.fieldLabel+(this.labelSeparator||":")})}},onResize:function(a,b){var c=a,d=b;d=a;if(!(this.layout instanceof Ext.layout.FormLayout))if(!Ext.isEmpty(this.flex)||!Ext.isEmpty(this.columnWidth))c-=this.resizeEl.getPadding("l");else d+=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}},onDestroy:function(){if(this.ownerCt){Ext.destroy(this.ownerCt);this.ownerCt.remove()}}});Ext.preg("zarafa.fieldlabeler",Zarafa.common.plugins.FieldLabeler);Ext.ns("Zarafa.common.plugins");
Zarafa.common.plugins.SpinnerPlugin=Ext.extend(Ext.ux.Spinner,{doRender:function(a,b){Zarafa.common.plugins.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.plugins");
Zarafa.common.plugins.SplitFieldLabeler=Ext.extend(Ext.util.Observable,{labelCfg:{style:"text-align: left; padding: 3px 3px 3px 3px"},firstLabelCfg:{style:"text-align: left; padding: 3px 3px 3px 0px"},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.util.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(i){if(i.labelSplitter===
b[d]){e=i;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:"displayfield",value:f}))}c[0].xtype=="displayfield"&&Ext.apply(c[0],this.firstLabelCfg);c[c.length-1].xtype=="displayfield"&&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++){var e=b[d];if(e.xtype=="displayfield")if((!Ext.isDefined(e.width)||
e.width===0)&&!Ext.isEmpty(e.text))c+=e.text.length;else a-=e.width}for(d=0;d<b.length;d++){e=b[d];if(e.xtype=="displayfield")if((!Ext.isDefined(e.width)||e.width===0)&&!Ext.isEmpty(e.text))e.width=Math.round(a*(e.text.length/c))}}}});Ext.preg("zarafa.splitfieldlabeler",Zarafa.common.plugins.SplitFieldLabeler);Ext.namespace("Zarafa.common.recipientfield.data");
Zarafa.common.recipientfield.data.SuggestionListJsonWriter=Ext.extend(Ext.data.JsonWriter,{constructor:function(a){a=a||{};Ext.applyIf(a,{writeAllFields:true,encode:false});Zarafa.core.data.JsonWriter.superclass.constructor.call(this,a)},destroyRecord:function(a){return this.toHash(a)}});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:true,remoteSort:false,actionType:Zarafa.core.Actions.list,proxy:new Zarafa.common.recipientfield.data.SuggestionListProxy,writer:new Zarafa.common.recipientfield.data.SuggestionListJsonWriter,reader:new Ext.data.JsonReader({root:"result",id:"id"},Zarafa.common.recipientfield.data.SuggestionListRecord)});Zarafa.common.recipientfield.data.SuggestionListStore.superclass.constructor.call(this,
a);this.sort([{field:"display_name",direction:"ASC"},{field:"smtp_address",direction:"ASC"},{field:"email_address",direction:"ASC"}])},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.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.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.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:349920},{name:Date.monthNames[9],value:393120},{name:Date.monthNames[10],value:437760},{name:Date.monthNames[11],value:480960}];
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()]});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:100,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.7,spacerConfig:{width:5},listeners:{change:this.onDurationChange,scope:this}},{xtype:"spacer",
width:5},{xtype:"container",flex:0.3,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:150,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.5,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.5,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,combineErrors:false,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.fromUTC())},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(k){k.setValue(k.patternValue==c)});var d=a.get("recurrence_start");d=d?d.toUTC():(new Date).clearTime();var e=a.get("recurrence_end");e=e?e.toUTC():d.clone();var f=a.get("recurrence_startocc"),g=a.get("recurrence_endocc"),i=(new Date).clearTime();i.setDate(1);i.setMonth(0);i.setHours(f/60);i.setMinutes(f%60);f=(new Date).clearTime();f.setDate(1);f.setMonth(0);f.setHours(g/60);f.setMinutes(g%60);this.startDateField.setValue(d);
this.timeperiodField.getValue().set(i,f);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(k){k.setValue(k.endTerm==h)});switch(h){case Zarafa.common.recurrence.data.RecurrenceEnd.NEVER:b===true&&this.endOccurencesSpinner.setValue(10);if(b===true||a.isModifiedSinceLastUpdate("recurrence_start")&&d>this.endOnDateField.getValue())this.endOnDateField.setValue(d.clearTime(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(d.clearTime(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(e.clearTime(true));break}this.alldayCheckbox.setValue(a.get("alldayevent"))},
updateRecord:function(a){a.beginEdit();var b=this.recurrencePatternSelect.getValue();b?a.set("recurrence_type",b.patternValue):a.set("recurrence_type",Zarafa.common.recurrence.data.RecurrenceType.NONE);a.set("recurrence_start",this.startDateField.getValue().fromUTC());Ext.each(this.endPatternPanel.findByType("radio"),function(g){if(g.getValue()){a.set("recurrence_term",g.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")).fromUTC());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")).fromUTC());break;case Zarafa.common.recurrence.data.RecurrenceEnd.ON_DATE:a.set("recurrence_numoccur",undefined);a.set("recurrence_end",this.endOnDateField.getValue().fromUTC());break}a.set("alldayevent",this.alldayCheckbox.getValue());var c=this.timeperiodField.getValue();
b=c.getStartDate().getHours()*60+c.getStartDate().getMinutes();c=b+c.getDuration(Date.MINUTE);a.set("recurrence_startocc",b);a.set("recurrence_endocc",c);var d=this.startDateField.getValue(),e=d.clone();if(a.get("alldayevent")&&d.clearTime(true).getTime()===d.getTime()){var f=d.getHours()*60;b-=f;c-=f}d=d.add(Date.MINUTE,b);a.set("startdate",d);a.set("commonstart",d);e=e.add(Date.MINUTE,c);a.set("duedate",e);a.set("commonend",e);a.endEdit()}});Ext.reg("zarafa.recurrencepanel",Zarafa.common.recurrence.dialogs.RecurrencePanel);
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.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.getStore().getCount(),b=false;if(a>0)b=this.reminderGridView.getSelectionModel().hasSelection();this.dismissButton.setDisabled(!b);this.openButton.setDisabled(!b);this.snoozeTimeCombo.setDisabled(!b);this.snoozeButton.setDisabled(!b);
this.snoozeInfoText.setDisabled(!b);this.dismissAllButton.setDisabled(a<=0)},onDismissAll:function(){this.store.dismissReminders(this.store.getRange());this.dialog.close()},onOpenItem:function(){var a=this.reminderGridView.getSelectionModel().getSelected();a&&Zarafa.common.Actions.openReminderRecord(a)},onDismiss:function(){this.store.dismissReminders(this.reminderGridView.getSelectionModel().getSelections());this.store.getCount()===0&&this.dialog.close()},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.restoreitem.dialogs");
Zarafa.common.restoreitem.dialogs.RestoreItemPanel=Ext.extend(Ext.grid.GridPanel,{folder:undefined,itemType:"message",constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.restoreitempanel",border:false,store:new Zarafa.common.restoreitem.data.RestoreItemStore({autoLoad:{folder:a.folder}}),loadMask:true,viewConfig:{forceFit:true,emptyText:'<div class="emptytext">'+_("There are no items to show in this view")+"</div>",getRowClass:this.viewConfigGetRowClass},tbar:{xtype:"zarafa.contentpaneltoolbar",
insertionPointBase:"common.restoreitemcontentpanel",actionItems:this.createActionButtons()},bbar:[{xtype:"tbfill"},{xtype:"displayfield",height:15,ref:"../statusMessage"}],colModel:this.initMessageColumnModel(),sm:new Ext.grid.RowSelectionModel});Zarafa.common.restoreitem.dialogs.RestoreItemPanel.superclass.constructor.call(this,a);this.mon(this.store,"load",this.onStoreLoad,this);this.mon(this.store,"load",this.disableToolbarButton,this);this.mon(this.store,"load",this.setStatusMessage,this);this.mon(this.store,
"remove",this.setStatusMessage,this);this.mon(this.store,"remove",this.disableToolbarButton,this);this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},viewConfigGetRowClass:function(a){return!a.isRead()?"mail_unread":"mail_read"},createActionButtons:function(){var a=Ext.id(null,"restoreitem-");return[{xtype:"button",overflowText:_("Restore"),text:_("Restore"),iconCls:"icon_restore",handler:this.onRestore,disabled:true,ref:"../restoreButton",scope:this},{xtype:"button",
overflowText:_("Restore All"),text:_("Restore All"),iconCls:"icon_restore",handler:this.onRestoreAll,disabled:true,ref:"../restoreAllButton",scope:this},{xtype:"button",overflowText:_("Permanent Delete"),text:_("Permanent Delete"),iconCls:"icon_delete",handler:this.onPermanentDelete,disabled:true,ref:"../permanentDeleteButton",scope:this},{xtype:"button",overflowText:_("Delete All"),text:_("Delete All"),iconCls:"icon_delete",handler:this.onDeleteAll,disabled:true,ref:"../deleteAllButton",scope:this},
{xtype:"tbfill"},{xtype:"radio",width:90,boxLabel:_("Messages"),name:a,inputValue:"message",checked:true,listeners:{check:this.onRadioChecked,scope:this}},{xtype:"radio",width:70,boxLabel:_("Folders"),name:a,inputValue:"folder",listeners:{check:this.onRadioChecked,scope:this}}]},onRadioChecked:function(a,b){if(b===true){this.itemType=a.inputValue;this.store.load({params:{itemType:this.itemType}})}},onPermanentDelete:function(){this.doPermanentDelete(this.getSelectionModel().getSelections())},onDeleteAll:function(){var a=
this.store.getRange();Ext.MessageBox.confirm(_("Zarafa WebApp"),_("Are you sure you want to Permanently Delete all items?"),function(b){b=="yes"&&this.doPermanentDelete(a)},this)},doPermanentDelete:function(a){var b=[];if(!Ext.isEmpty(a)){for(var c=0,d=a.length;c<d;c++){var e=a[c];e.addMessageAction("action_type","delete"+this.itemType);this.store.remove(e);b.push(e)}this.store.save(b)}},onRestore:function(){this.doRestore(this.getSelectionModel().getSelections())},onRestoreAll:function(){var a=this.store.getRange();
Ext.MessageBox.confirm(_("Zarafa WebApp"),_("Are you sure you want to Restore all items?"),function(b){b=="yes"&&this.doRestore(a)},this)},doRestore:function(a){var b=[];if(!Ext.isEmpty(a)){for(var c=0,d=a.length;c<d;c++){var e=a[c];e.addMessageAction("action_type","restore"+this.itemType);this.store.remove(e);b.push(e)}this.store.save(b)}},onStoreLoad:function(a,b,c){Ext.isDefined(c.params.itemType)&&c.params.itemType=="folder"?this.reconfigure(a,this.initFolderColumnModel()):this.reconfigure(a,
this.initMessageColumnModel());this.getSelectionModel().selectFirstRow()},onSelectionChange:function(a){a=a.hasSelection()===false;this.restoreButton.setDisabled(a);this.permanentDeleteButton.setDisabled(a)},setStatusMessage:function(a){this.statusMessage.setValue(String.format(ngettext("Total {0} recoverable item","Total {0} recoverable items",a.getCount()),a.getCount()))},disableToolbarButton:function(a){a=a.getCount()===0;this.deleteAllButton.setDisabled(a);this.restoreAllButton.setDisabled(a)},
initFolderColumnModel:function(){return new Ext.grid.ColumnModel([{dataIndex:"icon_index",headerCls:"zarafa-icon-column",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:24,sortable:true,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"display_name",header:_("Name"),tooltip:_("Sort by: Name"),sortable:true,renderer:Ext.util.Format.htmlEncode},{dataIndex:"deleted_on",header:_("Deleted On"),tooltip:_("Sort by: Deleted On"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.datetime},
{dataIndex:"content_count",header:_("Item Count"),tooltip:_("Sort by: Item Count"),sortable:true,renderer:Ext.util.Format.htmlEncode}])},initMessageColumnModel:function(){return new Ext.grid.ColumnModel([{dataIndex:"icon_index",headerCls:"zarafa-icon-column",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:24,sortable:true,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"hasattach",headerCls:"zarafa-icon-column",header:"<p class='icon_attachment'>&nbsp;</p>",
tooltip:_("Sort by: Attachment"),width:24,sortable:true,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.attachment},{dataIndex:"sender_name",header:_("From"),tooltip:_("Sort by: From"),sortable:true,renderer:Ext.util.Format.htmlEncode},{dataIndex:"subject",header:_("Subject"),tooltip:_("Sort by: Subject"),sortable:true,renderer:Ext.util.Format.htmlEncode},{dataIndex:"deleted_on",header:_("Deleted On"),tooltip:_("Sort by: Deleted On"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.datetime},
{dataIndex:"message_delivery_time",header:_("Received"),tooltip:_("Sort by: Received"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.datetime},{dataIndex:"message_size",header:_("Size"),tooltip:_("Sort by: Size"),sortable:true,renderer:Zarafa.common.ui.grid.Renderers.size}])}});Ext.reg("zarafa.restoreitempanel",Zarafa.common.restoreitem.dialogs.RestoreItemPanel);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.FolderSelectionLink=Ext.extend(Ext.BoxComponent,{emptyText:_("Select one..."),folder:undefined,actionFlag:undefined,action:undefined,isModified:false,isValid:true,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.folderselectionlink",border:false,autoScroll:true,anchor:"100%",tpl:new Ext.XTemplate('<div class="zarafa-folder-link"><tpl if="!Ext.isEmpty(values.display_name)">&quot;{display_name:htmlEncode}&quot;</tpl><tpl if="Ext.isEmpty(values.display_name)">&quot;'+
_("Unnamed folder")+"&quot;</tpl></div>",{compiled:true})});Zarafa.common.rules.dialogs.FolderSelectionLink.superclass.constructor.call(this,a)},afterRender:function(){Zarafa.common.rules.dialogs.FolderSelectionLink.superclass.afterRender.apply(this,arguments);this.mon(this.getActionEl(),"click",this.onClick,this)},onClick:function(){Zarafa.hierarchy.Actions.openFolderSelectionContent({folder:this.folder,callback:function(a){this.folder=a;this.isModified=true;this.update(a)},scope:this,modal:true})},
setAction:function(a,b){this.folder=undefined;this.isValid=false;if(b){var c=container.getHierarchyStore().getById(b.storeentryid);if(c){this.folder=c.getSubStore("folders").getById(b.folderentryid);if(Ext.isDefined(this.folder))this.isValid=true}}this.actionFlag=a;this.action=b;this.isModified=!Ext.isDefined(b);this.update(this.folder)},getAction:function(){if(this.isModified!==true&&this.isValid===true)return this.action;var a={};if(!this.folder)return false;a.folderentryid=this.folder.get("entryid");
a.storeentryid=this.folder.get("store_entryid");switch(this.actionFlag){case Zarafa.common.rules.data.ActionFlags.MOVE:a.action=Zarafa.core.mapi.RuleActions.OP_MOVE;a.flags=0;a.flavor=0;break;case Zarafa.common.rules.data.ActionFlags.COPY:a.action=Zarafa.core.mapi.RuleActions.OP_COPY;a.flags=0;a.flavor=0;break;default:return false}return a},update:function(a){Zarafa.common.rules.dialogs.FolderSelectionLink.superclass.update.call(this,this.tpl.apply(a?a.data:{display_name:this.emptyText}))}});
Ext.reg("zarafa.folderselectionlink",Zarafa.common.rules.dialogs.FolderSelectionLink);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.ImportanceLink=Ext.extend(Ext.Container,{conditionFlag:undefined,condition:undefined,isModified:false,constructor:function(a){a=a||{};Ext.applyIf(a,{items:[{xtype:"combo",ref:"importanceCombo",width:100,store:{xtype:"jsonstore",fields:["name","value"],data:Zarafa.common.data.ImportanceFlags.flags},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,listeners:{select:function(){this.isModified=true},scope:this}}]});
Zarafa.common.rules.dialogs.ImportanceLink.superclass.constructor.call(this,a)},setCondition:function(a,b){var c=Zarafa.core.mapi.Importance.NORMAL;if(b)c=b[1][Zarafa.core.mapi.Restrictions.VALUE].PR_IMPORTANCE;this.conditionFlag=a;this.condition=b;this.isModified=!Ext.isDefined(b);this.importanceCombo.setValue(c)},getCondition:function(){if(this.isModified!==true)return this.condition;var a=Zarafa.core.data.RestrictionFactory,b=Zarafa.core.mapi.Restrictions,c=this.importanceCombo.getValue();return a.dataResProperty("PR_IMPORTANCE",
b.RELOP_EQ,c)}});Ext.reg("zarafa.importancelink",Zarafa.common.rules.dialogs.ImportanceLink);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesActionsContainer=Ext.extend(Ext.Container,{actionCount:0,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{layout:"form",autoHeight:true,items:[{xtype:"zarafa.compositefield",hideLabel:true,items:[{xtype:"button",ref:"../addActionBtn",text:_("Add action"),handler:this.addActionBox,scope:this},{xtype:"button",ref:"../removeActionBtn",text:_("Remove action"),handler:this.removeActionBox,
scope:this}]}]});Zarafa.common.rules.dialogs.RulesActionsContainer.superclass.constructor.call(this,a)},createActionBox:function(a){a="rule-action-"+String(a);return{xtype:"container",id:a,flex:1,height:25,layout:{type:"hbox",align:"stretch",defaultMargins:"0 5 0 0"},items:[{xtype:"combo",width:300,store:{xtype:"jsonstore",fields:[{name:"name"},{name:"value",type:"int"}],data:Zarafa.common.rules.data.ActionProfiles},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,
forceSelection:true,editable:false,value:_("Select one..."),listeners:{select:this.onActionComboSelect,scope:this}},{xtype:"container",flex:1,layout:"card",activeItem:0,items:this.createActionContentPanels(a)}]}},createActionContentPanels:function(a){return[{xtype:"container",id:a+"-empty"},{xtype:"zarafa.folderselectionlink",id:a+"-folder"},{xtype:"zarafa.deletelink",id:a+"-delete"},{xtype:"zarafa.userselectionlink",id:a+"-to"}]},addActionBox:function(){this.actionCount++;var a=this.createActionBox(this.actionCount);
a=this.insert(this.items.getCount()-1,a);this.removeActionBtn.setDisabled(this.actionCount<=1);this.doLayout();return a},removeActionBox:function(){if(this.actionCount>1){this.remove(this.get(this.items.getCount()-2));this.actionCount--;this.removeActionBtn.setDisabled(this.actionCount<=1);this.doLayout()}},setActionBoxCount:function(a){for(;a<this.actionCount;)this.removeActionBox();for(;a>this.actionCount;)this.addActionBox()},update:function(a,b){this.record=a;if(b||a.isModifiedSinceLastUpdate("rule_actions")){var c=
a.get("rule_actions");if(Ext.isEmpty(c))this.setActionBoxCount(1);else{c=[].concat(c);this.setActionBoxCount(Math.max(1,c.length));for(var d=0,e=c.length;d<e;d++)c[d]&&this.applyAction(this.get(d),c[d])}}},updateRecord:function(a){for(var b=[],c=true,d=0;d<this.actionCount;d++){var e=this.get(d),f=e.get(1).layout.activeItem,g=null;if(Ext.isFunction(f.getAction))g=f.getAction();if(!g){e.get(0).markInvalid();c=false}b.push(g)}a.set("rule_actions",b);a.setActionsValid(c)},applyAction:function(a,b){var c=
this.getActionFlagFromAction(b),d=a.get(0),e=a.get(1),f=d.store,g=f.findExact(d.valueField,c);if(g>=0){f=f.getAt(g);d.setValue(c);this.onActionComboSelect(d,f,g)}else{c=Zarafa.common.rules.data.ActionFlags.UNKNOWN;d.setValue(_("Unknown action"));d.markInvalid(_("This action for the current rule is unknown"))}d=e.getLayout();switch(c){case Zarafa.common.rules.data.ActionFlags.UNKNOWN:default:break;case Zarafa.common.rules.data.ActionFlags.MOVE:case Zarafa.common.rules.data.ActionFlags.COPY:case Zarafa.common.rules.data.ActionFlags.DELETE:case Zarafa.common.rules.data.ActionFlags.REDIRECT:case Zarafa.common.rules.data.ActionFlags.FORWARD:case Zarafa.common.rules.data.ActionFlags.FORWARD_ATTACH:d.activeItem.setAction(c,
b);break}},getActionFlagFromAction:function(a){switch(a.action){case Zarafa.core.mapi.RuleActions.OP_MOVE:var b=Zarafa.core.mapi.RuleStates;if(this.record.get("rule_state")&b.ST_EXIT_LEVEL===b.ST_EXIT_LEVEL)if((b=container.getHierarchyStore().getDefaultFolder("wastebasket"))&&Zarafa.core.EntryId.compareEntryIds(b.get("entryid"),a.folderentryid))return Zarafa.common.rules.data.ActionFlags.DELETE;return Zarafa.common.rules.data.ActionFlags.MOVE;case Zarafa.core.mapi.RuleActions.OP_COPY:return Zarafa.common.rules.data.ActionFlags.COPY;
case Zarafa.core.mapi.RuleActions.OP_FORWARD:b=Zarafa.core.mapi.FlavorFlags;switch(a.flavor){case 0:return Zarafa.common.rules.data.ActionFlags.FORWARD;case b.FWD_PRESERVE_SENDER|b.FWD_DO_NOT_MUNGE_MSG:return Zarafa.common.rules.data.ActionFlags.REDIRECT;case b.FWD_AS_ATTACHMENT:return Zarafa.common.rules.data.ActionFlags.FORWARD_ATTACH;default:return Zarafa.common.rules.data.ActionFlags.UNKNOWN}default:return Zarafa.common.rules.data.ActionFlags.UNKNOWN}},onActionComboSelect:function(a,b){var c=
a.ownerCt,d=c.get(1).getLayout(),e=b.get(a.valueField);switch(e){case Zarafa.common.rules.data.ActionFlags.UNKNOWN:default:d.setActiveItem(c.id+"-empty");break;case Zarafa.common.rules.data.ActionFlags.MOVE:case Zarafa.common.rules.data.ActionFlags.COPY:d.setActiveItem(c.id+"-folder");d.activeItem.setAction(e);break;case Zarafa.common.rules.data.ActionFlags.DELETE:d.setActiveItem(c.id+"-delete");d.activeItem.setAction(e);this.record.set("rule_state",this.record.get("rule_state")|Zarafa.core.mapi.RuleStates.ST_EXIT_LEVEL);
break;case Zarafa.common.rules.data.ActionFlags.REDIRECT:case Zarafa.common.rules.data.ActionFlags.FORWARD:case Zarafa.common.rules.data.ActionFlags.FORWARD_ATTACH:d.setActiveItem(c.id+"-to");d.activeItem.setAction(e);break}}});Ext.reg("zarafa.rulesactionscontainer",Zarafa.common.rules.dialogs.RulesActionsContainer);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesConditionContainer=Ext.extend(Ext.Container,{conditionCount:0,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{layout:"form",autoHeight:true,items:[{xtype:"zarafa.compositefield",hideLabel:true,items:[{xtype:"button",ref:"../addConditionBtn",text:_("Add condition"),handler:this.addConditionBox,scope:this},{xtype:"button",ref:"../removeConditionBtn",text:_("Remove condition"),handler:this.removeConditionBox,
scope:this}]}]});Zarafa.common.rules.dialogs.RulesConditionContainer.superclass.constructor.call(this,a)},createConditionBox:function(a){a="rule-condition-"+String(a);return{xtype:"container",id:a,flex:1,height:25,layout:{type:"hbox",align:"stretch",defaultMargins:"0 5 0 0"},items:[{xtype:"combo",width:300,store:{xtype:"jsonstore",fields:[{name:"name"},{name:"value",type:"int"}],data:Zarafa.common.rules.data.ConditionProfiles},mode:"local",triggerAction:"all",displayField:"name",valueField:"value",
lazyInit:false,forceSelection:true,editable:false,value:_("Select one..."),listeners:{select:this.onConditionComboSelect,scope:this}},{xtype:"container",flex:1,layout:"card",activeItem:0,items:this.createConditionContentPanels(a)}]}},createConditionContentPanels:function(a){return[{xtype:"container",id:a+"-empty"},{xtype:"zarafa.userselectionlink",id:a+"-from"},{xtype:"zarafa.wordselectionlink",id:a+"-senderwords"},{xtype:"zarafa.wordselectionlink",id:a+"-words"},{xtype:"zarafa.wordselectionlink",
id:a+"-bodywords"},{xtype:"zarafa.importancelink",id:a+"-importance"},{xtype:"zarafa.userselectionlink",id:a+"-to"},{xtype:"zarafa.senttomelink",id:a+"-to-me"}]},addConditionBox:function(){this.conditionCount++;var a=this.createConditionBox(this.conditionCount);a=this.insert(this.items.getCount()-1,a);this.removeConditionBtn.setDisabled(this.conditionCount<=1);this.doLayout();return a},removeConditionBox:function(){if(this.conditionCount>1){this.remove(this.get(this.items.getCount()-2));this.conditionCount--;
this.removeConditionBtn.setDisabled(this.conditionCount<=1);this.doLayout()}},setConditionBoxCount:function(a){for(;a<this.conditionCount;)this.removeConditionBox();for(;a>this.conditionCount;)this.addConditionBox()},update:function(a,b){this.record=a;if(b||a.isModifiedSinceLastUpdate("rule_condition")){var c=a.get("rule_condition");if(Ext.isEmpty(c))this.setConditionBoxCount(1);else{c=this.getConditionsArray(c);this.setConditionBoxCount(Math.max(1,c.length));for(var d=0,e=c.length;d<e;d++)c[d]&&
this.applyCondition(this.get(d),c[d])}}},updateRecord:function(a){for(var b=[],c=true,d=0;d<this.conditionCount;d++){var e=this.get(d),f=e.get(0);e=e.get(1).layout.activeItem;var g=null;if(Ext.isFunction(e.getCondition))g=e.getCondition();if(!g){f.markInvalid();c=false}b.push(g)}if(b)b=b.length>1?Zarafa.core.data.RestrictionFactory.createResAnd(b):b[0];a.set("rule_condition",b);a.setConditionsValid(c)},getConditionsArray:function(a){if(a[0]===Zarafa.core.mapi.Restrictions.RES_AND){for(var b=false,
c=0,d=a[1].length;c<d;c++){var e=a[1][c];if(e&&e[0]===Zarafa.core.mapi.Restrictions.RES_PROPERTY&&e[1][Zarafa.core.mapi.Restrictions.ULPROPTAG]==="PR_MESSAGE_TO_ME"){b=true;break}}a=b?[a]:a[1]}else a=[a];return a},applyCondition:function(a,b){var c=this.getConditionFlagFromCondition(b),d=a.get(0),e=a.get(1),f=d.store,g=f.findExact(d.valueField,c);if(g>=0){f=f.getAt(g);d.setValue(c);this.onConditionComboSelect(d,f,g)}else{c=Zarafa.common.rules.data.ConditionFlags.UNKNOWN;d.setValue(_("Unknown condition"));
d.markInvalid(_("This condition for the current rule is unknown"))}d=e.getLayout();switch(c){case Zarafa.common.rules.data.ConditionFlags.UNKNOWN:default:break;case Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS:case Zarafa.common.rules.data.ConditionFlags.BODY_WORDS:case Zarafa.common.rules.data.ConditionFlags.IMPORTANCE:case Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM:case Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS:case Zarafa.common.rules.data.ConditionFlags.SENT_TO:case Zarafa.common.rules.data.ConditionFlags.SENT_TO_ME_ONLY:d.activeItem.setCondition(c,
b);break}},getConditionFlagFromCondition:function(a){var b=Zarafa.core.mapi.Restrictions;switch(a[0]){case b.RES_COMMENT:switch(a[1][b.RESTRICTION][1][b.ULPROPTAG]){case "PR_SENDER_SEARCH_KEY":return Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM;default:return Zarafa.common.rules.data.ConditionFlags.UNKNOWN}case b.RES_CONTENT:case b.RES_PROPERTY:case b.RES_SUBRESTRICTION:switch(a[1][b.ULPROPTAG]){case "PR_BODY":return Zarafa.common.rules.data.ConditionFlags.BODY_WORDS;case "PR_SUBJECT":return Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS;
case "PR_IMPORTANCE":return Zarafa.common.rules.data.ConditionFlags.IMPORTANCE;case "PR_MESSAGE_RECIPIENTS":return Zarafa.common.rules.data.ConditionFlags.SENT_TO;case "PR_SENDER_SEARCH_KEY":return Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS;default:return Zarafa.common.rules.data.ConditionFlags.UNKNOWN}case b.RES_AND:for(var c=0,d=a[1].length;c<d;c++){var e=a[1][c];if(e[0]===b.RES_PROPERTY&&e[1][b.ULPROPTAG]==="PR_MESSAGE_TO_ME")return Zarafa.common.rules.data.ConditionFlags.SENT_TO_ME_ONLY}return Zarafa.common.rules.data.ConditionFlags.UNKNOWN;
case b.RES_OR:c=0;for(d=a[1].length;c<d;c++){e=a[1][c];b=this.getConditionFlagFromCondition(e);if(b!==Zarafa.common.rules.data.ConditionFlags.UNKNOWN)return b}return Zarafa.common.rules.data.ConditionFlags.UNKNOWN;default:return Zarafa.common.rules.data.ConditionFlags.UNKNOWN}},onConditionComboSelect:function(a,b){var c=a.ownerCt,d=c.get(1).getLayout(),e=b.get(a.valueField);switch(e){case Zarafa.common.rules.data.ConditionFlags.UNKNOWN:default:d.setActiveItem(c.id+"-empty");break;case Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM:d.setActiveItem(c.id+
"-from");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS:d.setActiveItem(c.id+"-senderwords");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS:d.setActiveItem(c.id+"-words");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.BODY_WORDS:d.setActiveItem(c.id+"-bodywords");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.IMPORTANCE:d.setActiveItem(c.id+
"-importance");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.SENT_TO:d.setActiveItem(c.id+"-to");d.activeItem.setCondition(e);break;case Zarafa.common.rules.data.ConditionFlags.SENT_TO_ME_ONLY:d.setActiveItem(c.id+"-to-me");d.activeItem.setCondition(e);break}}});Ext.reg("zarafa.rulesconditioncontainer",Zarafa.common.rules.dialogs.RulesConditionContainer);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesEditPanel=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.ruleseditpanel",layout:"anchor",autoScroll:true,items:this.createPanelItems()});Zarafa.common.rules.dialogs.RulesEditPanel.superclass.constructor.call(this,a)},createPanelItems:function(){return[{xtype:"displayfield",value:_("Rule name"),height:20},{xtype:"textfield",name:"rule_name",
width:250,listeners:{change:this.onChange,scope:this}},{xtype:"spacer",height:15},{xtype:"displayfield",value:_("When the message")+"...",height:20},{xtype:"zarafa.rulesconditioncontainer",anchor:"100%"},{xtype:"spacer",height:15},{xtype:"displayfield",value:_("Do the following")+"...",height:20},{xtype:"zarafa.rulesactionscontainer",anchor:"100%"},{xtype:"spacer",height:15},{xtype:"checkbox",ref:"stopProcessingCheckbox",boxLabel:_("Stop processing more rules"),handler:this.onToggleStopProcessing,
scope:this}]},onChange:function(a,b){this.record.set(a.name,b)},onToggleStopProcessing:function(a,b){var c=this.record.get("rule_state");if(b)c|=Zarafa.core.mapi.RuleStates.ST_EXIT_LEVEL;else c&=~Zarafa.core.mapi.RuleStates.ST_EXIT_LEVEL;this.record.set("rule_state",c)},update:function(a){this.record=a;this.getForm().loadRecord(a);var b=Zarafa.core.mapi.RuleStates;this.stopProcessingCheckbox.setValue((a.get("rule_state")&b.ST_EXIT_LEVEL)===b.ST_EXIT_LEVEL)},updateRecord:function(a){a.beginEdit();
this.getForm().updateRecord(a);var b=this.record.get("rule_state");if(this.stopProcessingCheckbox.getValue())b|=Zarafa.core.mapi.RuleStates.ST_EXIT_LEVEL;else b&=~Zarafa.core.mapi.RuleStates.ST_EXIT_LEVEL;this.record.set("rule_state",b);a.endEdit()}});Ext.reg("zarafa.ruleseditpanel",Zarafa.common.rules.dialogs.RulesEditPanel);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesWordsEditPanel=Ext.extend(Ext.form.FormPanel,{store:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.ruleswordseditpanel",layout:{type:"vbox",align:"stretch"},padding:5,items:[{xtype:"zarafa.compositefield",items:[{xtype:"button",ref:"../editWordBtn",text:_("Edit"),width:70,disabled:true,handler:this.onWordEdit,scope:this},{xtype:"spacer",width:5},{xtype:"button",ref:"../deleteWordBtn",text:_("Delete"),width:70,disabled:true,handler:this.onWordDelete,
scope:this}]},{xtype:"spacer",height:5},{xtype:"zarafa.compositefield",items:[{xtype:"textfield",ref:"../wordField",hideLabel:true,flex:1,listeners:{specialkey:this.onInputSpecialKey,scope:this}},{xtype:"button",autoWidth:true,iconCls:"zarafa-rules-add",handler:this.onWordAdd,scope:this}]},{xtype:"spacer",height:5},{xtype:"grid",ref:"gridPanel",flex:1,border:true,enableHdMenu:false,enableColumnMove:false,store:a.store,viewConfig:{headersDisabled:true,forceFit:true,autoExpandColumn:true,markDirty:false,
scrollOffset:0},colModel:new Ext.grid.ColumnModel({columns:[{dataIndex:"words",sortable:false,renderer:Ext.util.Format.htmlEncode}]}),sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:this.onSelectionChange,scope:this}})}]});Zarafa.common.rules.dialogs.RulesWordsEditPanel.superclass.constructor.call(this,a)},onInputSpecialKey:function(a,b){b.getKey()==b.ENTER&&this.onWordAdd()},onWordAdd:function(){var a=this.wordField.getValue().trim();if(!Ext.isEmpty(a)){this.store.add(new Ext.data.Record({words:a}));
this.wordField.reset()}this.wordField.focus()},onWordEdit:function(){var a=this.gridPanel.getSelectionModel().getSelected();if(a){this.store.remove(a);this.wordField.setValue(a.get("words"));this.wordField.focus()}},onWordDelete:function(){var a=this.gridPanel.getSelectionModel().getSelected();a&&this.store.remove(a)},onSelectionChange:function(a){a=a.hasSelection();this.editWordBtn.setDisabled(!a);this.deleteWordBtn.setDisabled(!a)}});Ext.reg("zarafa.ruleswordseditpanel",Zarafa.common.rules.dialogs.RulesWordsEditPanel);
Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.SentToMeLink=Ext.extend(Ext.Container,{conditionFlag:undefined,condition:undefined,isModified:false,setCondition:function(a,b){this.conditionFlag=a;this.condition=b;this.isModified=!Ext.isDefined(b)},getCondition:function(){if(this.isModified!==true)return this.condition;var a=Zarafa.core.data.RestrictionFactory,b=Zarafa.core.mapi.Restrictions;if(this.conditionFlag!==Zarafa.common.rules.data.ConditionFlags.SENT_TO_ME_ONLY)return false;return a.createResAnd([a.dataResProperty("PR_MESSAGE_TO_ME",
b.RELOP_EQ,true,"0x0057000B"),a.createResNot(a.dataResContent("PR_DISPLAY_TO",b.FL_SUBSTRING,";","0x0E04001E")),a.dataResProperty("PR_DISPLAY_CC",b.RELOP_EQ,"","0x00E03001E")])}});Ext.reg("zarafa.senttomelink",Zarafa.common.rules.dialogs.SentToMeLink);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.UserSelectionLink=Ext.extend(Ext.BoxComponent,{emptyText:_("Select one..."),userStringSeparator:_("and"),store:undefined,actionFlag:undefined,action:undefined,conditionFlag:undefined,condition:undefined,isModified:false,isValid:true,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.userselectionlink",border:false,autoScroll:true,anchor:"100%",multiSelect:false,store:new Zarafa.core.data.IPMRecipientStore,tpl:new Ext.XTemplate('<div class="zarafa-user-link"><tpl for="list"><tpl if="!Ext.isEmpty(values.display_name)">&quot;{display_name:htmlEncode}&quot;</tpl><tpl if="Ext.isEmpty(values.display_name) && !Ext.isEmpty(values.smtp_address)">&quot;{smtp_address:htmlEncode}&quot;</tpl><tpl if="xcount &gt; 0 && xindex != xcount"><span>&nbsp;{parent.seperator}&nbsp;</span></tpl></tpl></div>',
{compiled:true})});Zarafa.common.rules.dialogs.UserSelectionLink.superclass.constructor.call(this,a)},afterRender:function(){Zarafa.common.rules.dialogs.UserSelectionLink.superclass.initComponent.apply(this,arguments);this.mon(this.getActionEl(),"click",this.onClick,this);this.mon(this.store,"update",this.onRecipientUpdate,this);this.mon(this.store,"add",this.onRecipientAdd,this);this.mon(this.store,"resolved",this.onRecipientAdd,this)},onRecipientUpdate:function(a,b,c){c!==Ext.data.Record.COMMIT&&
this.update(this.store)},onRecipientAdd:function(a,b){var c=b[0];c.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("Distribution lists are not supported in rules, would you like to replace the distribution list with its members?"),buttons:Ext.MessageBox.YESNO,fn:this.onExpandDistList.createDelegate(this,[c],1),scope:this})},onExpandDistList:function(a,b){a==="yes"&&this.store.expand(b,true);this.store.remove(b)},onClick:function(){var a=
[];this.conditionFlag===Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM&&a.push("distribution_list");var b;b=this.conditionFlag===Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM?_("From"):_("To");Zarafa.common.Actions.openABUserMultiSelectionContent({listRestriction:{hide_groups:a},callback:function(){this.isModified=true;this.update(this.store)},convert:function(c){return c.convertToRecipient()},scope:this,store:this.store,modal:true,selectionCfg:[{xtype:"zarafa.recipientfield",fieldLabel:b+
":",height:50,boxStore:this.store,flex:1}]})},setCondition:function(a,b){this.store.removeAll();this.isValid=false;if(b){var c=Zarafa.core.mapi.Restrictions,d;switch(a){case Zarafa.common.rules.data.ConditionFlags.SENT_TO:d=b[0]===c.RES_OR?b[1]:[b];for(var e=0,f=d.length;e<f;e++){var g=d[e][1][c.RESTRICTION];if(g[1]&&g[1][c.PROPS]&&g[1][c.PROPS]["0x0001001E"]){var i=this.store.parseRecipient(g[1][c.PROPS]["0x0001001E"]);i.set("display_type",g[1][c.PROPS].PR_DISPLAY_TYPE);i.set("search_key",g[1][c.RESTRICTION][1][c.VALUE]["0x00010102"]);
this.store.add(i);this.isValid=true}}break;case Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM:d=b[0]===c.RES_OR?b[1]:[b];e=0;for(f=d.length;e<f;e++){g=d[e][1];if(g[c.PROPS]&&g[c.PROPS]["0x0001001E"]){i=this.store.parseRecipient(g[c.PROPS]["0x0001001E"]);i.set("display_type",g[c.PROPS].PR_DISPLAY_TYPE);i.set("search_key",g[c.RESTRICTION][1][c.VALUE]["0x00010102"]);this.store.add(i);this.isValid=true}}break;default:break}}this.conditionFlag=a;this.condition=b;this.userStringSeparator=_("or");
this.isModified=!Ext.isDefined(b);this.update(this.store)},getCondition:function(){if(this.isModified!==true&&this.isValid===true)return this.condition;var a=[];if(this.store.getCount()===0)return false;switch(this.conditionFlag){case Zarafa.common.rules.data.ConditionFlags.SENT_TO:this.store.each(function(b){b.isResolved()&&a.push(this.createToRestriction(b))},this);break;case Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM:this.store.each(function(b){b.isResolved()&&a.push(this.createFromRestriction(b))},
this);break;default:return false}return a.length===1?a[0]:a.length>1?Zarafa.core.data.RestrictionFactory.createResOr(a):false},createToRestriction:function(a){var b=Zarafa.core.data.RestrictionFactory;return b.createResSubRestriction("PR_MESSAGE_RECIPIENTS",b.dataResComment(b.dataResProperty("PR_SEARCH_KEY",Zarafa.core.mapi.Restrictions.RELOP_EQ,a.get("search_key"),"0x00010102"),{"0x60000003":Zarafa.core.mapi.RecipientType.MAPI_TO,"0x00010102":a.get("search_key"),"0x0001001E":a.get("display_name")+
" <"+a.get("smtp_address")+">",PR_DISPLAY_TYPE:a.get("display_type")}))},createFromRestriction:function(a){var b=Zarafa.core.data.RestrictionFactory;return b.dataResComment(b.dataResProperty("PR_SENDER_SEARCH_KEY",Zarafa.core.mapi.Restrictions.RELOP_EQ,a.get("search_key"),"0x00010102"),{"0x60000003":Zarafa.core.mapi.RecipientType.MAPI_TO,"0x00010102":a.get("search_key"),"0x0001001E":a.get("display_name")+" <"+a.get("smtp_address")+">",PR_DISPLAY_TYPE:a.get("display_type")})},setAction:function(a,
b){this.store.removeAll();this.isValid=false;if(b)for(var c=Zarafa.core.data.RecordFactory,d=Zarafa.core.data.RecordCustomObjectType,e=0,f=b.adrlist.length;e<f;e++){var g=b.adrlist[e];this.isValid=true;this.store.add(c.createRecordObjectByCustomType(d.ZARAFA_RECIPIENT,{entryid:g.PR_ENTRYID,object_type:g.PR_OBJECT_TYPE,display_name:g.PR_DISPLAY_NAME,display_type:g.PR_DISPLAY_TYPE,email_address:g.PR_EMAIL_ADDRESS,smtp_address:g.PR_SMTP_ADDRESS,address_type:g.PR_ADDRTYPE,recipient_type:g.PR_RECIPIENT_TYPE,
search_key:g.PR_SEARCH_KEY}))}this.actionFlag=a;this.action=b;this.userStringSeparator=_("and");this.isModified=!Ext.isDefined(b);this.update(this.store)},getAction:function(){if(this.isModified!==true&&this.isValid===true)return this.action;var a={};if(this.store.getCount()===0)return false;a.adrlist=[];this.store.each(function(e){a.adrlist.push({PR_ENTRYID:e.get("entryid"),PR_OBJECT_TYPE:e.get("object_type"),PR_DISPLAY_NAME:e.get("display_name"),PR_DISPLAY_TYPE:e.get("display_type"),PR_EMAIL_ADDRESS:e.get("email_address")||
e.get("smtp_address"),PR_SMTP_ADDRESS:e.get("smtp_address"),PR_ADDRTYPE:e.get("address_type"),PR_RECIPIENT_TYPE:e.get("recipient_type"),PR_SEARCH_KEY:e.get("search_key")})},this);var b=Zarafa.common.rules.data.ActionFlags,c=Zarafa.core.mapi.RuleActions,d=Zarafa.core.mapi.FlavorFlags;switch(this.actionFlag){case b.REDIRECT:a.action=c.OP_FORWARD;a.flags=0;a.flavor=d.FWD_PRESERVE_SENDER|d.FWD_DO_NOT_MUNGE_MSG;break;case b.FORWARD:a.action=c.OP_FORWARD;a.flags=0;a.flavor=0;break;case b.FORWARD_ATTACH:a.action=
c.OP_FORWARD;a.flags=0;a.flavor=d.FWD_AS_ATTACHMENT;break;default:return false}return a},update:function(a){a={seperator:this.userStringSeparator,list:Ext.pluck(a.getRange(),"data")};if(Ext.isEmpty(a.list))a.list=[{display_name:this.emptyText}];Zarafa.common.rules.dialogs.UserSelectionLink.superclass.update.call(this,this.tpl.apply(a))}});Ext.reg("zarafa.userselectionlink",Zarafa.common.rules.dialogs.UserSelectionLink);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.WordSelectionLink=Ext.extend(Ext.BoxComponent,{emptyText:_("Select one..."),wordStringSeparator:_("or"),store:undefined,conditionFlag:undefined,condition:undefined,isModified:false,isValid:true,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.wordselectionlink",border:false,autoScroll:true,anchor:"100%",multiSelect:false,store:new Ext.data.Store({fields:["words"]}),tpl:new Ext.XTemplate('<div class="zarafa-word-link"><tpl for="."><tpl if="!Ext.isEmpty(values.words)">&quot;{words:htmlEncode}&quot;</tpl><tpl if="xcount &gt; 0 && xindex != xcount"><span>&nbsp;'+
this.wordStringSeparator+"&nbsp;</span></tpl></tpl></div>",{compiled:true,wordStringSeparator:a.wordStringSeparator||this.wordStringSeparator})});Zarafa.common.rules.dialogs.WordSelectionLink.superclass.constructor.call(this,a)},afterRender:function(){Zarafa.common.rules.dialogs.WordSelectionLink.superclass.initComponent.apply(this,arguments);this.mon(this.getActionEl(),"click",this.onClick,this)},onClick:function(){var a=new Ext.data.Store({fields:["words"]});a.add(this.store.getRange());Zarafa.common.Actions.openRulesWordsEditContent({store:a,
callback:this.rulesWordsEditDialogCallback,scope:this,modal:true})},rulesWordsEditDialogCallback:function(a){this.store.removeAll();this.store.add(a.getRange());this.isModified=true;this.update(this.store)},setCondition:function(a,b){this.store.removeAll();this.isValid=false;if(b){var c=Zarafa.core.mapi.Restrictions;switch(a){case Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS:var d;d=b[0]==c.RES_OR?b[1]:[b];for(var e=0,f=d.length;e<f;e++){var g=d[e][1][c.VALUE];Ext.iterate(g,function(i,h){if(!Ext.isEmpty(h)){this.isValid=
true;if(a===Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS)h=Zarafa.core.Util.hexToString(h);this.store.add(new Ext.data.Record({words:h}))}},this)}break;case Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS:case Zarafa.common.rules.data.ConditionFlags.BODY_WORDS:default:d=b[0]==c.RES_OR?b[1]:[b];e=0;for(f=d.length;e<f;e++){g=d[e][1][c.VALUE];Ext.iterate(g,function(i,h){if(!Ext.isEmpty(h)){this.isValid=true;this.store.add(new Ext.data.Record({words:h}))}},this)}break}}this.conditionFlag=
a;this.condition=b;this.isModified=!Ext.isDefined(b);this.update(this.store)},getCondition:function(){if(this.isModified!==true&&this.isValid===true)return this.condition;if(this.store.getCount()===0)return false;var a=[],b=Zarafa.core.data.RestrictionFactory,c=Zarafa.core.mapi.Restrictions;switch(this.conditionFlag){case Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS:this.store.each(function(d){d=Zarafa.core.Util.stringToHex(d.get("words"));a.push(b.dataResContent("PR_SENDER_SEARCH_KEY",c.FL_SUBSTRING,
d))},this);break;case Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS:this.store.each(function(d){a.push(b.dataResContent("PR_SUBJECT",c.FL_SUBSTRING|c.FL_IGNORECASE,d.get("words")))},this);break;case Zarafa.common.rules.data.ConditionFlags.BODY_WORDS:this.store.each(function(d){a.push(b.dataResContent("PR_BODY",c.FL_SUBSTRING|c.FL_IGNORECASE,d.get("words")))},this);break;default:return false}return a.length===1?a[0]:Zarafa.core.data.RestrictionFactory.createResOr(a)},update:function(a){a=Ext.pluck(a.getRange(),
"data");if(Ext.isEmpty(a))a=[{words:this.emptyText}];Zarafa.common.rules.dialogs.WordSelectionLink.superclass.update.call(this,this.tpl.apply(a))}});Ext.reg("zarafa.wordselectionlink",Zarafa.common.rules.dialogs.WordSelectionLink);Ext.namespace("Zarafa.common.rules.ui");
Zarafa.common.rules.ui.RulesPanel=Ext.extend(Ext.Panel,{store:undefined,constructor:function(a){a=a||{};if(Ext.isEmpty(a.store))a.store=new Zarafa.common.rules.data.RulesStore;Ext.applyIf(a,{xtype:"zarafa.rulespanel",border:false,layout:"fit",items:this.createPanelItems(a)});Zarafa.common.rules.ui.RulesPanel.superclass.constructor.call(this,a)},createPanelItems:function(a){return[{xtype:"container",layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"zarafa.rulesgrid",ref:"../rulesGrid",
flex:1,store:a.store}]}]},discardChanges:function(){this.store.load()},saveChanges:function(){this.store.save()}});Ext.reg("zarafa.rulespanel",Zarafa.common.rules.ui.RulesPanel);Ext.namespace("Zarafa.common.sendas.ui");
Zarafa.common.sendas.ui.SendAsGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.sendasgrid",border:true,viewConfig:{forceFit:true,deferEmptyText:false,emptyText:"<div class='emptytext'>"+_("No send as address configured")+"</div>"},loadMask:{msg:_("Loading send as addresses")+"..."},columns:this.initColumnModel(),selModel:new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:true}),listeners:{viewready:this.onViewReady,rowdblclick:this.onRowDblClick,
scope:this}});Zarafa.common.sendas.ui.SendAsGrid.superclass.constructor.call(this,a)},initColumnModel:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",header:'<p class="icon_index">&nbsp;</p>',width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"display_name",header:_("Name"),renderer:Zarafa.common.ui.grid.Renderers.text},{dataIndex:"smtp_address",header:_("Email Address"),renderer:Zarafa.common.ui.grid.Renderers.text}]},onViewReady:function(){this.getSelectionModel().selectFirstRow()},
removeSendAs:function(){var a=this.getSelectionModel(),b=this.getSelectionModel().getSelected();if(b){if(a.hasNext())a.selectNext();else a.hasPrevious()&&a.selectPrevious();this.store.remove(b)}else Ext.Msg.alert(_("Alert"),_("Please select a send as record."))},onRowDblClick:function(a,b){var c=a.getStore().getAt(b);c.isOneOff()?this.editSendAsRecipient(c,false):this.viewSendAsRecipient(c)},editSendAsRecipient:function(a,b){Zarafa.common.Actions.openSendAsRecipientContent(a,{removeOnCancel:b})},
viewSendAsRecipient:function(a){Zarafa.common.Actions.openViewRecipientContent(a)}});Ext.reg("zarafa.sendasgrid",Zarafa.common.sendas.ui.SendAsGrid);Ext.namespace("Zarafa.common.sendas.ui");
Zarafa.common.sendas.ui.SendAsPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.sendaspanel",border:false,layout:{type:"vbox",align:"stretch",pack:"start"},items:this.createPanelItems(a.store)});Zarafa.common.sendas.ui.SendAsPanel.superclass.constructor.call(this,a)},createPanelItems:function(a){return[{xtype:"displayfield",value:_("Here you can setup your alias email addresses."),fieldClass:"x-form-display-field zarafa-settings-widget-extrainfo"},{xtype:"container",
flex:1,layout:{type:"hbox",align:"stretch",pack:"start"},items:[{xtype:"zarafa.sendasgrid",ref:"../sendasGrid",store:a,flex:1},{xtype:"container",width:160,layout:{type:"vbox",align:"center",pack:"start"},items:[{xtype:"button",text:_("Address Book")+"...",handler:this.onSendAsAddressBook,scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("Add")+"...",handler:this.onSendAsAdd,scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("Edit")+"...",disabled:true,ref:"../../editButton",
handler:this.onSendAsEdit,scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("View")+"...",disabled:true,ref:"../../viewButton",handler:this.onSendAsView,scope:this},{xtype:"spacer",height:20},{xtype:"button",text:_("Remove")+"...",disabled:true,ref:"../../removeButton",handler:this.onSendAsRemove,scope:this}]}]}]},initEvents:function(){Zarafa.common.sendas.ui.SendAsPanel.superclass.initEvents.call(this);this.mon(this.sendasGrid.getSelectionModel(),"selectionchange",this.onGridSelectionChange,
this)},onSendAsAdd:function(){var a=Ext.pluck(this.store.getRange(),"data");a=Ext.max(Ext.pluck(a,"rowid"))||0;a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{rowid:a+1,display_type:Zarafa.core.mapi.DisplayType.DT_REMOTE_MAILUSER});this.store.add(a);this.sendasGrid.editSendAsRecipient(a,true)},onGridSelectionChange:function(a){var b=a.getSelected();b=b&&b.isOneOff();a=a.hasSelection();this.editButton.setDisabled(!a||!b);this.viewButton.setDisabled(!a||
b);this.removeButton.setDisabled(!a)},onSendAsRemove:function(){this.sendasGrid.removeSendAs()},getSendAsRecord:function(){var a=this.sendasGrid.getSelectionModel().getSelected();if(a)return a;else Ext.Msg.alert(_("Alert"),_("Please select a sendas record."))},onSendAsEdit:function(){this.sendasGrid.editSendAsRecipient(this.getSendAsRecord(),false)},onSendAsView:function(){this.sendasGrid.viewSendAsRecipient(this.getSendAsRecord())},onSendAsAddressBook:function(){Zarafa.common.Actions.openABUserSelectionContent({callback:this.abCallBack,
scope:this,singleSelect:false,listRestriction:{hide_users:["system","everyone"],hide_companies:true}})},abCallBack:function(a){var b=Ext.pluck(this.store.getRange(),"data");b=Ext.max(Ext.pluck(b,"rowid"))||0;for(var c=0;c<a.length;c++){var d=a[c];d=d.convertToRecipient();d.set("rowid",++b);this.store.add(d)}}});Ext.reg("zarafa.sendaspanel",Zarafa.common.sendas.ui.SendAsPanel);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(){if(!this.isAnimDestroying&&!this.isDestroying){this.parent.focus();this.parent.doBoxRemove(this)}},onClick:function(a){a.stopEvent();!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxClick(this)},onContextMenu:function(a){a.stopEvent();
!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxContextMenu(this)},onDblClick:function(a){a.stopEvent();!this.isAnimDestroying&&!this.isDestroying&&this.parent.doBoxDblClick(this)},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)}this.parent.sizeContainer()},
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");if(Ext.isDefined(this.expandBtnEl))a-=this.expandBtnEl.getWidth()+this.expandBtnEl.getFrameWidth("lr")+this.expandBtnEl.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();this.parent.sizeContainer()},scope:this})}else{this.destroy();this.parent.sizeContainer()}}});Ext.reg("zarafa.box",Zarafa.common.ui.Box);Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.BoxField=Ext.extend(Ext.form.ComboBox,{boxType:"zarafa.box",boxStore:undefined,boxConfig:undefined,items:undefined,handleInputKey:";",enableComboBox:true,currentFocus:false,boxFocusEl:undefined,wrapBoxesEl:undefined,inputEl:undefined,boxKeyMap:undefined,inputKeyMap:undefined,specialInputKeyMap:undefined,listKeyMap: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,autoHeight:true,autoScroll:true,monitorTab:false});a.wrapCls=a.wrapCls?a.wrapCls+" "+this.wrapCls:this.wrapCls;this.addEvents("boxfocus","boxblur","boxclick","boxdblclick","boxcontextmenu","boxadd","boxremove");Zarafa.common.ui.BoxField.superclass.constructor.call(this,a);this.on("boxremove",this.onBoxRemove,this);this.on("boxadd",
this.onBoxAdd,this)},initComponent:function(){Zarafa.common.ui.BoxField.superclass.initComponent.call(this);this.items=new Ext.util.MixedCollection;if(Ext.isString(this.handleInputKey))this.handleInputKey=this.handleInputKey.charCodeAt(0);this.previousHeight=this.height},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.specialInputKeyMap=this.createSpecialInputKeyMap(this.el);this.inputKeyMap=this.createInputKeyMap(this.el);if(this.enableComboBox===true)this.listKeyMap=this.createListKeyMap(this.el);Zarafa.core.Events.addPasteEventHandler(this,this.el,this.onPaste,this)}this.listMode===true&&this.mon(this.ownerCt,"afterlayout",this.onParentLayout,this);this.on("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,add:this.onBoxStoreAdd,remove:this.onBoxStoreRemove,update:this.onBoxStoreUpdate,clear:this.onBoxStoreClear,scope:this});this.clearBoxes()}if(this.boxStore=Ext.StoreMgr.lookup(a)){this.loadBoxes(this.boxStore);this.mon(this.boxStore,{datachanged:this.onBoxStoreDataChanged,add:this.onBoxStoreAdd,remove:this.onBoxStoreRemove,update:this.onBoxStoreUpdate,clear:this.onBoxStoreClear,scope:this})}}},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(true);this.handleSelection(a);this.lastQuery=""},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");Ext.isDefined(this.boxStore)&&this.setBoxStore(this.boxStore,true)},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();if(Ext.isDefined(a)&&Ext.isDefined(a.dom)){var b=a.getHeight(),c=a.dom.scrollHeight,d=false;if(this.previousOuterHeight!==
b)d=true;if(b>this.boxMaxHeight){a.setHeight(this.boxMaxHeight);if(this.initialConfig.autoScroll!==false){this.setAutoScroll(true);a.scrollTo("top",b)}d=true}else if(b===this.boxMaxHeight&&c!==this.previousInnerHeight&&c<=b-2){a.setHeight("auto");this.initialConfig.autoScroll!==false&&this.setAutoScroll(false);d=true}this.previousOuterHeight=b;this.previousInnerHeight=c;d===true&&this.fireEvent("resizeheight")}},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{var c=this.getInputTextMetric();b=Ext.util.Format.htmlEncode(this.el.dom.value);b=c.getWidth(b);b+=this.minInputFieldWidth;b=Math.min(b,a.getWidth())}c=a.getHeight();this.el.setSize(b,
this.inputFieldHeight-this.el.getBorderWidth("tb"));b=a.getHeight();if(this.listMode===true||c!==b)this.sizeContainer();a.scrollTo("top",b)},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(true);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)if(b===this.el.dom)this.inputFocus();else{if(this.el.isVisible()){a.stopEvent();this.inputFocus(this.el.dom.value.length)}}else this.currentFocus||
this.boxFocus(this.items.last())},createBoxKeyMap:function(a){for(var b=[{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}],c=0,d=b.length;c<d;c++)Ext.apply(b[c],{shift:false,alt:false,ctrl:false});return new Ext.KeyMap(a,b)},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],shift:false,alt:false,ctrl:false,handler:this.onInputKey,scope:this}],"keypress")},createListKeyMap:function(a){return new Ext.KeyMap(a,{key:[Ext.EventObject.DELETE],handler:this.onListKeyDelete,scope:this,shift:false,alt:false,ctrl:false})},createSpecialInputKeyMap:function(a){for(var b=[{key:[Ext.EventObject.ENTER],handler:this.onInputKeyEnter,scope:this},{key:[Ext.EventObject.TAB],
handler:this.onInputKeyTab,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}],c=0,d=b.length;c<d;c++)Ext.apply(b[c],{shift:false,alt:false,ctrl:false});return new Ext.KeyMap(a,b)},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()&&this.store.getCount()>0)){b.stopEvent();this.convertInputToBox()}},onInputKeyTab:function(a,b){if(Ext.isEmpty(this.getValue()))this.triggerBlur();else{b.stopEvent();this.isExpanded()&&this.store.getCount()>0||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())}},onListKeyDelete:function(a,b){var c=
this.getStore();if(c.getCount()!==0){b.stopEvent();c.removeAt(this.selectedIndex);c.getCount()==this.selectedIndex?this.selectPrev():this.select(this.selectedIndex);this.restrictHeight()}},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){if(this.filterRecord(b)){var c=this.getBoxForRecord(b);c?c.update(b):this.addBox(b)}else this.removeBox(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);if(this.boxStore.getCount()<this.boxLimit&&this.initialConfig.readOnly!==true){this.setReadOnly(false);this.inputFocus()}},onBoxAdd:function(){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.sizeContainer();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);this.items.getCount()<this.boxLimit&&this.initialConfig.readOnly!==true&&this.setReadOnly(false);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.BoxFieldDragZone=Ext.extend(Ext.dd.DragZone,{field:undefined,getDragData:function(a){if(a=a.getTarget(".x-zarafa-boxfield-item")){for(var b=Ext.DomHelper.createDom({tag:"div",html:a.innerHTML,id:Ext.id(),cls:a.className,style:"display : inline-block"}),c=0;c<b.childNodes.length;c++)if(b.childNodes[c].id)b.childNodes[c].id=Ext.id();return{ddel:b,sourceEl:a,repairXY:Ext.fly(a).getXY(),draggedRecord:this.field.items.get(a.id).record}}},getRepairXY:function(){return this.dragData.repairXY}});
Ext.reg("zarafa.boxfielddragzone",Zarafa.common.ui.BoxFieldDragZone);Ext.namespace("Zarafa.common.ui");Zarafa.common.ui.BoxFieldDropZone=Ext.extend(Ext.dd.DropZone,{field:undefined,getTargetFromEvent:function(a){return a.getTarget(".x-zarafa-boxfield")},onNodeEnter:function(a){Ext.get(a).addClass(this.wrapFocusClass)},onNodeOut:function(a){Ext.get(a).removeClass(this.wrapFocusClass)},onNodeOver:function(){return Ext.dd.DropZone.prototype.dropAllowed}});Ext.reg("zarafa.boxfielddropzone",Zarafa.common.ui.BoxFieldDropZone);
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");
Zarafa.common.CommonViewButtons=Ext.extend(Ext.menu.Menu,{constructor:function(a){a=a||{};Ext.applyIf(a,{items:this.createMainToolbarViewButton(a.context)});Zarafa.common.CommonViewButtons.superclass.constructor.call(this,a)},createMainToolbarViewButton:function(a){var b=a.getName(),c=container.populateInsertionPoint("main.maintoolbar.view."+b,this)||[];return[{id:"zarafa-maintoolbar-view-"+b+"-nopreview",overflowText:_("No preview"),iconCls:"icon_previewpanel_off",text:_("No preview"),valueView:Zarafa.common.data.Views.LIST,
valueViewMode:Zarafa.common.data.ViewModes.NO_PREVIEW,valueDataMode:Zarafa.common.data.DataModes.ALL,handler:a.onContextSelectView,scope:a},{id:"zarafa-maintoolbar-view-"+b+"-previewright",overflowText:_("Right preview"),iconCls:"icon_previewpanel_right",text:_("Right preview"),valueView:Zarafa.common.data.Views.LIST,valueViewMode:Zarafa.common.data.ViewModes.RIGHT_PREVIEW,valueDataMode:Zarafa.common.data.DataModes.ALL,handler:a.onContextSelectView,scope:a},{id:"zarafa-maintoolbar-view-"+b+"-previewbottom",
overflowText:_("Bottom preview"),iconCls:"icon_previewpanel_bottom",text:_("Bottom preview"),valueView:Zarafa.common.data.Views.LIST,valueViewMode:Zarafa.common.data.ViewModes.BOTTOM_PREVIEW,valueDataMode:Zarafa.common.data.DataModes.ALL,handler:a.onContextSelectView,scope:a}].concat(c)}});Ext.reg("zarafa.commonviewbuttons",Zarafa.common.CommonViewButtons);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",defaultMargins:"0 6 0 0"});a.cls=a.cls?a.cls+" zarafa-compositefield":"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},validateValue:function(a,b){var c=true;this.eachItem(function(d){if(d.isXType("field")&&!d.isValid(b))c=false});return c},find:Ext.Container.prototype.find,findBy:Ext.Container.prototype.findBy,findByType:Ext.Container.prototype.findByType});
Ext.reg("zarafa.compositefield",Zarafa.common.ui.CompositeField);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.calendar.ui");
Zarafa.common.ui.ContextMainPanelToolbar=Ext.extend(Ext.Toolbar,{context:undefined,model:undefined,paging:undefined,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=b.concat({xtype:"zarafa.searchfield",boxMinWidth:100,ref:"searchTextfield",listeners:{render:function(){this.onModelFolderChange(this.model)},scope:this}});Ext.isEmpty(a.paging)||(b=b.concat(a.paging));b.push({xtype:"zarafa.paging",
style:"border-style : none",ref:"pagesToolbar",pageSize:container.getSettingsModel().get("zarafa/v1/main/page_size"),store:a.model?a.model.getStore():undefined});b=b.concat(["->",{xtype:"zarafa.toolbarbutton",overflowText:_("Copy/Move"),tooltip:_("Copy/Move")+" (Ctrl + M)",iconCls:"icon_copy",ref:"copyButton",nonEmptySelectOnly:true,handler:this.onCopyMove,model:a.model,scope:this},{xtype:"zarafa.toolbarbutton",overflowText:_("Delete"),tooltip:_("Delete")+" (DELETE)",ref:"deleteButton",iconCls:"icon_delete",
nonEmptySelectOnly:true,handler:this.onDelete,model:a.model,scope:this}]);Ext.isEmpty(a.items)||(b=b.concat(a.items));delete a.items;Ext.applyIf(a,{xtype:"zarafa.contextmainpaneltoolbar",ref:"contextMainPanelToolbar",items:b,enableOverflow:true});Zarafa.common.ui.ContextMainPanelToolbar.superclass.constructor.call(this,a);this.initEvent()},initEvent:function(){this.on("afterlayout",this.onAfterLayout,this,{delay:2});this.mon(this.model,{folderchange:this.onModelFolderChange,scope:this})},onModelFolderChange:function(a){this.searchTextfield.setEmptyText(this.searchTextfield.getEmptySearchText(a.getDefaultFolder()))},
onAfterLayout:function(a,b){var c=this.getWidth(),d=0;Ext.each(a.items.items,function(e){if(!e.isXType("zarafa.searchfield")&&e.rendered)if(e.isVisible())d+=e.getWidth();else if(Ext.isDefined(e.xtbHidden)&&e.xtbHidden)d+=e.xtbWidth},this);c>d&&Ext.each(a.items.items,function(e){!e.isVisible()&&Ext.isDefined(e.xtbHidden)&&e.xtbHidden&&b.unhideItem(e)},this);a.searchTextfield.setWidth(c-d)},onCopyMove:function(){Zarafa.common.Actions.openCopyMoveContent(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.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.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.ns("Zarafa.common.ui");
Zarafa.common.ui.DateRangeField=Ext.extend(Ext.Container,{startFieldConfig:{},endFieldConfig:{},spacerConfig:undefined,defaultValue:undefined,defaultPeriod:undefined,defaultPeriodType:Date.MINUTE,allowEqualValue:false,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){var e=b.getTime(),f=c.getStartTime();if(e<f||this.allowEqualValue===false&&e===f){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.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.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,templateEl:undefined,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push({ptype:"zarafa.enablefocusplugin"});Zarafa.common.ui.DraggableDataView.superclass.constructor.call(this,a)},onRender:function(){Zarafa.common.ui.DraggableDataView.superclass.onRender.apply(this,
arguments);this.templateEl=this.getEl().createChild({tag:this.autoEl});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"})},afterRender:function(){Zarafa.common.ui.DraggableDataView.superclass.afterRender.apply(this,arguments);Zarafa.core.KeyMapMgr.activate(this,
"view.mapimessage")},getTemplateTarget:function(){return this.templateEl?this.templateEl:Zarafa.common.ui.DraggableDataView.superclass.getTemplateTarget.apply(this)},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.DurationField=Ext.extend(Ext.form.NumberField,{stripCharsRe:/[^0-9]+/,allowDecimals:false,allowNegative:false,processValue:function(a){if(Ext.isString(a)&&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.EditorField=Ext.extend(Ext.Container,{useHtml:true,htmlXtype:"zarafa.htmleditor",plaintextXtype:"zarafa.textarea",htmlName:"",plaintextName:"",componentConfig:undefined,relayedEvents:["change","valuecorrection","keypress","initialized"],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);this.addEvents("setAutoFocusCursor");
Zarafa.common.ui.EditorField.superclass.constructor.call(this,a);this.on("beforerender",this.onBeforeRender,this);this.on("setAutoFocusCursor",this.onSetAutoFocusCursor,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,enableKeyEvents:a.enableKeyEvents||false},b),Ext.apply({},{xtype:a.plaintextXtype||this.plaintextXtype,name:a.plaintextName||this.plaintextName,enableKeyEvents:a.enableKeyEvents||false},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()})},getEditor:function(){return this.getLayout().activeItem},getName:function(){return this.getLayout().activeItem.getName()},isInitialized:function(){if(this.isHtmlEditor())return this.getLayout().activeItem.initialized;
return true},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},onSetAutoFocusCursor:function(){this.getLayout().activeItem.setCursorLocation()},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.IconClass={getIconClass:function(a){var b=a.get("icon_index"),c=a.get("object_type"),d="";if(!Ext.isEmpty(b))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;case Zarafa.core.mapi.ObjectType.MAPI_ATTACH:d=this.getIconClassFromAttachMethod(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)Ext.isDefined(b)||(b=a.getDisplayType());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_PRIVATE_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"}},getIconClassFromAttachMethod:function(a){return a.isEmbeddedMessage()?"icon_embed_attachment":"icon_attachment"}};
Zarafa.common.ui.LoadMask=Ext.extend(Ext.LoadMask,{msg:_("Loading..."),isLoading:false,failureMsg:_("Failed"),failureMsgCls:"x-mask-error",onLoad:function(a,b,c){c&&(c.actionType===Zarafa.core.Actions.updatesearch||c.actionType===Zarafa.core.Actions.updatelist)||Zarafa.common.ui.LoadMask.superclass.onLoad.apply(this,arguments)},onBeforeLoad:function(a,b){b&&(b.actionType===Zarafa.core.Actions.updatesearch||b.actionType===Zarafa.core.Actions.updatelist)||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.PagingToolbar=Ext.extend(Ext.PagingToolbar,{displayRefresh:false,displayInfo:false,initComponent:function(){this.cls="zarafa-paging-toolbar";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,cls:"x-btn-page-next",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);if(this.store){this.mon(this.store,"search",function(){this.pageSize=container.getSettingsModel().get("zarafa/v1/main/page_size")},this);this.mon(this.store,
"beforeupdatesearch",this.updateInfo,this)}else 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);
Ext.ns("Zarafa.common.ui");
Zarafa.common.ui.SearchField=Ext.extend(Ext.form.TriggerField,{searchIndicatorClass:"zarafa-tbar-loading",renderedSearchPanel:false,errorMsgEmpty:_("Please enter text to start search."),constructor:function(a){Ext.apply(a,{validationEvent:false,validateOnBlur:false,cls:"zarafa-searchfield",triggerClass:"icon_search"});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.stopSearch():this.onTriggerClick()}},stopSearch:function(){if(this.fireEvent("beforestop",this)!==false){this.doStop();this.fireEvent("stop",this)}},onTriggerClick:function(){if(this.fireEvent("beforestart",this)!==false){if(Ext.isEmpty(this.getValue())){container.getNotifier().notify("error.search",_("Error"),this.errorMsgEmpty);return false}this.isRenderedSearchPanel()||
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["common.search"],[],{searchText:this.getValue(),parentSearchField:this});this.doStart();this.fireEvent("start",this)}},setEmptyText:function(a){Ext.isEmpty(this.getRawValue())&&this.setRawValue(a);this.emptyText=a},getEmptySearchText:function(a){if(a){var b=a.get("display_name");a=a.getMAPIStore().get("mailbox_owner_name");return String.format(_('Search in "{0} - {1}"'),b,a)}},doStart:function(){this.el.addClass([this.searchIndicatorClass])},
doStop:function(){this.el.removeClass([this.searchIndicatorClass])},isRenderedSearchPanel:function(){return this.renderedSearchPanel}});Ext.reg("zarafa.searchfield",Zarafa.common.ui.SearchField);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.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.namespace("Zarafa.common.ui.appointmentpanel");
Zarafa.common.ui.appointmentpanel.AppointmentBody=Ext.extend(Ext.form.FormPanel,{headerTemplate:'<div class="preview-header-titlebox"><tpl if="!Ext.isEmpty(values.subject)"><span class="preview-title">{subject:htmlEncode}</span></tpl></div>',constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.appointmentbody",border:false,header:true,autoScroll:true,unstyled:true,autoWidth:true,headerCfg:{cls:"preview-header-title"},
items:[{xtype:"fieldset",title:_("Appointment"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Subject"),name:"subject"},{fieldLabel:_("Location"),name:"location"},{fieldLabel:_("Label"),ref:"../labelPreview"},{fieldLabel:_("Start Date"),ref:"../startDate"},{fieldLabel:_("End Date"),ref:"../endDate"},{fieldLabel:_("All Day Event"),name:"alldayevent"}]}]});Zarafa.common.ui.taskpanel.TaskBody.superclass.constructor.call(this,a);if(Ext.isString(this.headerTemplate))this.headerTemplate=new Ext.XTemplate(this.headerTemplate,
{compiled:true})},update:function(a){this.record=a;this.getForm().loadRecord(a);if(Ext.isDefined(a))this.headerTemplate.overwrite(this.header.dom,a.data);else this.header.dom.innerHTML="";this.labelPreview.setValue(Zarafa.core.mapi.AppointmentLabels.getDisplayName(a.get("label")));var b=a.get("startdate");if(Ext.isDate(b)){b=b.toUTC();this.startDate.setValue(b)}a=a.get("duedate");if(Ext.isDate(a)){a=a.toUTC();this.endDate.setValue(a)}}});Ext.reg("zarafa.appointmentbody",Zarafa.common.ui.appointmentpanel.AppointmentBody);
Ext.namespace("Zarafa.common.ui.contactpanel");
Zarafa.common.ui.contactpanel.ContactBody=Ext.extend(Ext.form.FormPanel,{headerTemplate:'<div class="preview-header-titlebox"><tpl if="!Ext.isEmpty(values.subject)"><span class="preview-title">{subject:htmlEncode}</span></tpl></div>',constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.contactbody",border:false,header:true,autoScroll:true,unstyled:true,autoWidth:true,headerCfg:{cls:"preview-header-title"},
items:[{xtype:"fieldset",title:_("Name"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Full name"),name:"display_name"},{fieldLabel:_("Company"),name:"company_name"},{fieldLabel:_("Job Title"),name:"title"},{fieldLabel:_("File as"),name:"fileas"}]},{xtype:"fieldset",title:_("Phone Numbers"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Business"),name:"business_telephone_number"},{fieldLabel:_("Home"),name:"home_telephone_number"},{fieldLabel:_("Business Fax"),name:"business_fax_number"},
{fieldLabel:_("Mobile"),name:"cellular_telephone_number"}]},{xtype:"fieldset",title:_("Email"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Email"),name:"email_address_1"},{fieldLabel:_("Display name"),name:"email_address_display_name_1"},{fieldLabel:_("Webpage"),name:"webpage"},{fieldLabel:_("IM Address"),name:"im"}]},{xtype:"fieldset",title:_("Address"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Business"),name:"business_address"}]}]});Zarafa.common.ui.contactpanel.ContactBody.superclass.constructor.call(this,
a);if(Ext.isString(this.headerTemplate))this.headerTemplate=new Ext.XTemplate(this.headerTemplate,{compiled:true})},update:function(a){this.record=a;this.getForm().loadRecord(a);if(Ext.isDefined(a))this.headerTemplate.overwrite(this.header.dom,a.data);else this.header.dom.innerHTML=""}});Ext.reg("zarafa.contactbody",Zarafa.common.ui.contactpanel.ContactBody);Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.ColumnModel=Ext.extend(Ext.grid.ColumnModel,{name:"default",constructor:function(a){a=a||{};this.addEvents("beforeconfigchange");Ext.apply(this,a);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(a){if(this.getColumnAt(a).fixed!==
true){Zarafa.common.ui.grid.ColumnModel.superclass.setState.apply(this,arguments);this.totalWidth=null}}});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.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.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)},afterRender:function(){Zarafa.common.ui.grid.GridPanel.superclass.afterRender.apply(this,arguments);var a=this.getXTypes();a=a.replace("component/box/container/panel/grid/zarafa.gridpanel",
"");a=a.replace(/\/zarafa\./g,".");a="grid"+a.replace(/grid/g,"");Zarafa.core.KeyMapMgr.activate(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.store.on("write",this.onWriteRecord,this);this.on("viewready",
this.onViewReady,this)},onWriteRecord:function(a,b){if(b==="destroy")if(!a.syncStore){var c=this.getView().scroller;if(Ext.isDefined(c)&&!c.isScrollable())if(a.totalLoadedRecord<a.totalLength){c={add:true,actionType:Zarafa.core.Actions.list};Ext.applyIf(c,a.lastOptions);var d=container.getSettingsModel().get("zarafa/v1/main/page_size");c.params.restriction.limit=d-a.getCount();c.params.restriction.start=a.getCount();a.syncStore=true;if(a.loadMask){a.loadMask.hide();a.loadMask=undefined}a.load(c)}}},
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){if(b&&b.actionType===Zarafa.core.Actions.updatelist){if(!this.isLoading){this.getView().showGridRowLoadMask(this.loadMask.msg);this.isLoading=true}}else if(!(!Ext.isEmpty(a)&&a.hasSearchResults===true)){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:function(a,
b,c){if(c&&c.actionType===Zarafa.core.Actions.updatelist)if(this.isLoading){this.getView().removeGridRowLoadMask();this.isLoading=false}},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.GridView=Ext.extend(Ext.grid.GroupingView,{disableScrollToTop:undefined,isBuffering:false,constructor:function(a){Ext.applyIf(a,{enableGrouping:true,enableGroupingMenu:false,groupTextTpl:'{text:htmlEncode} ({values.rs.length} {[ngettext("Item","Items", values.rs.length)]})',disableScrollToTop:false,deferEmptyText:true,emptyText:'<div class="emptytext">'+_("There are no items to show in this view")+"</div>",forceFit:true});this.addEvents("beforelivescrollstart","livescrollstart",
"beforesort");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(a,b,c){!Ext.isDefined(c.reload)&&this.disableScrollToTop!==true&&Ext.isDefined(this.scroller.dom)&&c.actionType=="list"&&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"})}},onScroll:function(a,b){if(this.fireEvent("beforelivescrollstart",this,b)!==false)if((Ext.isDefined(b.scrollTopMax)?b.scrollTopMax:b.scrollHeight-b.offsetHeight)*0.9<b.scrollTop&&!this.isBuffering){var c=this.ds.getCount();c!==this.ds.totalLength&&this.fireEvent("livescrollstart",
c)}},resetScroll:function(){if(this.getScrollState().top>0){this.scrollToTop();this.focusRow(1)}},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();this.scroller.on("scroll",this.onScroll,this)},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)}},onHeaderClick:function(){this.fireEvent("beforesort",this)!==false&&Zarafa.common.ui.grid.GridView.superclass.onHeaderClick.apply(this,arguments)},handleHdMenuClick:function(){this.fireEvent("beforesort",this)!==false&&Zarafa.common.ui.grid.GridView.superclass.handleHdMenuClick.apply(this,arguments)},showGridRowLoadMask:function(a){this.isBuffering=true;var b=this.getRow(1).offsetHeight;b={styles:"width :"+this.getTotalWidth()+"px; height :"+
b+"px"};b=(new Ext.Template('<div  id="dummy-row" style = "{styles}"> </div>')).apply(b);b=Ext.DomHelper.insertHtml("beforeEnd",this.mainBody.dom,b);Ext.get(b).mask(a,"x-mask-loading x-mask-loading-row");Ext.get(b).child(".ext-el-mask",true).className+="x-mask-row"},removeGridRowLoadMask:function(){var a=Ext.query("div#dummy-row",this.mainBody.dom)[0];Ext.isDefined(a)&&Ext.get(a).remove();this.isBuffering=false}});Ext.reg("zarafa.gridview",Zarafa.common.ui.grid.GridView);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){a=Zarafa.core.mapi.FlagStatus.get(c.get("flag_status"));if(!c.isMessageClass(["IPM.Note","IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true))return"";switch(a){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)},sender:function(a,b,c){a=c.get("sent_representing_name");var d=c.get("sent_representing_presence_status");if(Ext.isEmpty(a)){a=c.get("sender_name");d=c.get("sender_presence_status")}return'<span class="zarafa-presence-status '+Zarafa.core.data.PresenceStatus.getCssClass(d)+'"><span class="zarafa-presence-status-icon"></span>'+
Zarafa.common.ui.grid.Renderers.name(a,b,c)+"</span>"},organizer:function(a,b,c){if(Ext.isDefined(c.isMeeting)&&c.isMeeting())return Zarafa.common.ui.grid.Renderers.sender(a,b,c);else{b.css+=" zarafa-grid-empty-cell";return""}},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 Ext.util.Format.percentage(a)},date:function(a,b){b.css="mail_date";return Ext.isDate(a)?a.format(_("l d/m/Y")):_("None")},utcdate:function(a,b){b.css="mail_date";return Ext.isDate(a)?a.toUTC().format(_("l d/m/Y")):_("None")},datetime:function(a,b,c,d,e,f,g){b.css=
"mail_date";if(g&&g.css)b.css+=" "+g.css;return Ext.isDate(a)?a.format(_("l d/m/Y G:i")):_("None")},duration:function(a,b){b.css="mail_duration";return a?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)},
colorTextValue:function(a){return Zarafa.core.mapi.NoteColor.getColorText(a)},dataColumn:function(a,b,c){b.css="search-data";if(Ext.isEmpty(a))b.css+=" zarafa-grid-empty-cell";var d=c.get("message_class"),e="",f="",g="";switch(d){case "IPM.Contact":case "IPM.DistList":e=Ext.util.Format.htmlEncode(c.get("display_name"));f=Ext.util.Format.htmlEncode(c.get("fileas"));g=Ext.util.Format.htmlEncode(c.get("email_address_1"));break;case "IPM.Task":e=Ext.util.Format.htmlEncode(c.get("subject"));g=Ext.util.Format.htmlEncode(c.get("body"));
break;case "IPM.StickyNote":e=Ext.util.Format.htmlEncode(c.get("subject"));f=Ext.util.Format.htmlEncode(c.get("body"));break;default:e=Zarafa.common.ui.grid.Renderers.sender(a,b,c);f=Ext.util.Format.htmlEncode(c.get("subject"));g=Ext.util.Format.htmlEncode(c.get("body"));break}return'<table cellpadding=0 cellspacing=0 style="width:100%" class="messageclass-data mc-'+d.toLowerCase().replace(".","")+'"><tr><td class="x-grid3-col x-grid3-cell x-grid3-td-0 icon '+Zarafa.common.ui.IconClass.getIconClass(c)+
'"></td><td class="name"><div class="padding">'+e+'</div></td><td class="subject-body"><div class="padding">'+(f?'<span class="subject">'+f+"</span>":"")+(g?'<span class="body">'+g+"</span>":"")+"</div></td></tr></table>"},dateColumn:function(a,b,c){b.css="search-date";return'<table cellpadding=0 cellspacing=0 style="width:100%"><tr><td class="date"><div>'+(Ext.isDate(a)?a.format(_("d/m/Y")):"")+"</div></td>"+(c.get("hasattach")?'<td class="icon_attachment" style="width:22px"></td>':"")+"</tr></table>"}};
Ext.namespace("Zarafa.common.ui.grid");
Zarafa.common.ui.grid.RowSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,{constructor:function(a){Zarafa.common.ui.grid.RowSelectionModel.superclass.constructor.call(this,a);this.selections=new Ext.util.MixedCollection(false,function(b){var c=b.store;if(c&&Ext.isFunction(c.getRecordKey))return c.getRecordKey(b);return b.id})},clearSelections:function(a){if(!this.isLocked()){if(a!==true){var b=this.grid.getStore();a=this.selections;a.each(function(c){c=Ext.isFunction(b.getRecordKey)&&b.getRecordKey(c)||
c.id;this.deselectRow(b.indexOfId(c))},this);a.clear()}else this.selections.clear();this.last=false}},isSelected:function(a){var b=this.grid.getStore();a=Ext.isNumber(a)?b.getAt(a):a;b=Ext.isFunction(b.getRecordKey)&&b.getRecordKey(a)||a.id;return a&&this.selections.key(b)?true:false}});Ext.namespace("Zarafa.common.ui.htmleditor");
Zarafa.common.ui.htmleditor.Fonts=function(){return{getFonts:function(){return{1:8,2:10,3:12,4:14,5:18,6:24,7:36}},getFontFamilies:function(){return"Arial=arial,helvetica,sans-serif;Courier New=courier new,courier;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva"},getDefaultFontSize:function(){var a=this.getFonts(),b=container.getSettingsModel().get("zarafa/v1/main/default_font_size");return a[b]+"pt"}}}();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.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,i=g.length;for(d=0;d<i;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 h=this.switchMap[f];this[h]=this[f].split?new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchSplitRegion(this,e.initialConfig,h):new Zarafa.common.ui.layout.SwitchBorderLayout.SwitchRegion(this,e.initialConfig,h);this[h].render(b,e,true);if(f==="north"||f==="south"){this.horizontalRegion=
h;this.verticalRegion=f}else{this.horizontalRegion=f;this.verticalRegion=h}}}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.messagepanel");
Zarafa.common.ui.messagepanel.AttachmentLinks=Ext.extend(Ext.DataView,{ellipsisStringStartLength:20,ellipsisStringEndLength:20,maxHeight:50,fieldLabel:pgettext("mail.previewpanel","Attachments"),constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.attachmentlinks",plugins:["zarafa.recordcomponentupdaterplugin"],border:false,autoScroll:true,anchor:"100%",cls:"preview-header-attachments",multiSelect:false,overClass:"zarafa-attachment-link-over",itemSelector:"span.zarafa-attachment-link",tpl:new Ext.XTemplate('<div class="preview-header-attachmentbox"><div class="preview-attachment-title">{this.fieldLabel}:</div><div class="preview-attachment-data" style="max-height: {this.maxHeight}px"><tpl for="."><span class="zarafa-attachment-link x-zarafa-boxfield-item" viewIndex="{viewIndex}">{values.name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)} <tpl if="!Ext.isEmpty(values.size) && values.size &gt; 0">({values.size:fileSize})</tpl></span> </tpl></div></div>',
{compiled:true,fieldLabel:a.fieldLabel||this.fieldLabel,maxHeight:a.maxHeight||this.maxHeight,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.on({contextmenu:this.onNodeContextMenu,click:this.onAttachmentClicked,scope: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.hasVisibleAttachments()){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)))},update:function(a,b){if(a&&a instanceof Zarafa.core.data.MAPIRecord)b&&a.isOpened()&&this.setRecord(a);else Zarafa.common.ui.messagepanel.AttachmentLinks.superclass.update.apply(this,
arguments)},onAttachmentClicked:function(a,b,c){if(this.store){a=a.getRecord(c);Zarafa.common.Actions.openAttachmentRecord(a)}},onNodeContextMenu:function(a,b,c,d){Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getRecord(c),{position:d.getXY(),model:this.model})}});Ext.reg("zarafa.attachmentlinks",Zarafa.common.ui.messagepanel.AttachmentLinks);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."),faultyMessageInfoString:pgettext("mail.previewpanel",
"This message is corrupt and will not be displayed correctly, Click here to fix it."),acceptInfoString:pgettext("mail.previewpanel","{0} has accepted."),acceptDelegateInfoString:pgettext("mail.previewpanel","{0} has accepted on behalf of {1}."),tentativeInfoString:pgettext("mail.previewpanel","{0} has tentatively accepted."),tentativeDelegateInfoString:pgettext("mail.previewpanel","{0} has tentatively accepted on behalf of {1}."),declineInfoString:pgettext("mail.previewpanel","{0} has declined."),
declineDelegateInfoString:pgettext("mail.previewpanel","{0} has declined on behalf of {1}."),counterProposalTentativeAcceptedString:pgettext("mail.previewpanel","{0} tentatively accepted and proposed a new time for this meeting."),counterProposalTentativeAcceptedDelegateString:pgettext("mail.previewpanel","{0} tentatively accepted on behalf of {1} and proposed a new time for this meeting."),counterProposalDeclinedString:pgettext("mail.previewpanel","{0} declined and proposed a new time for this meeting."),
counterProposalDeclinedDelegateString:pgettext("mail.previewpanel","{0} declined on behalf of {1} 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}."),repliedString:pgettext("mail.previewpanel","You replied to this message on {0}."),forwardString:pgettext("mail.previewpanel","You forwarded this message on {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"),f=a.get("last_verb_executed");if(f===104){c=String.format(this.forwardString,a.get("last_verb_execution_time").format("j-m-Y H:i"));b.createChild({tag:"div",html:c,cls:this.itemCls});c=true}else if(f===102||f==103){c=String.format(this.repliedString,a.get("last_verb_execution_time").format("j-m-Y H:i"));b.createChild({tag:"div",
html:c,cls:this.itemCls});c=true}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(a.isFaultyMessage()){d=b.createChild({tag:"div",html:this.faultyMessageInfoString,
cls:this.itemCls});this.mon(d,"click",this.onExtraInfoFaultyClick,this);d.addClassOnOver("preview-header-extrainfobox-item-over");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);c&&this.doLayout()}else this.setVisible(false)},onExtraInfoBlockClick:function(a){Zarafa.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu.previewpanel.extrainfo"],this.record,{position:a.getXY()})},onExtraInfoFaultyClick:function(){Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("We are going to try to fix a corrupted mail message, do you wish to continue?"),icon:Ext.MessageBox.WARNING,fn:this.onFixFaultyMessage,scope:this,
buttons:Ext.MessageBox.YESNO})},onFixFaultyMessage:function(a){if(a=="yes"){if(this.dialog)this.dialog.closeOnSave=true;this.record.fixFaultyMessage()}},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=this.record.get("appointment_not_found"),f=
false;if(this.record.senderIsUser())return f;if(c){a.createChild({tag:"div",html:this.meetingOutDatedInfoString,cls:this.itemCls});f=true}else{if(d){a.createChild({tag:"div",html:this.organizerAsAttendeeInfoString,cls:this.itemCls});f=true}else{if(this.record.isAppointmentInPast()){a.createChild({tag:"div",html:this.elapsedTimeInfoString,cls:this.itemCls});f=true}else if(e!==true){a.createChild({tag:"div",html:this.responseRequiredString,cls:this.itemCls});f=true}if(!Ext.isEmpty(b)){a.createChild({tag:"div",
html:b,cls:this.itemCls});f=true}}if(this.record.get("updatecounter")>0){a.createChild({tag:"div",html:this.meetingUpdatedString,cls:this.itemCls});f=true}}return f},setMeetingResponseInfo:function(a){var b=false,c=this.record.get("counter_proposal"),d=this.record.get("sender_entryid"),e=this.record.get("sent_representing_entryid"),f=this.record.get("sent_representing_name")||this.record.get("sent_representing_email_address"),g="";if(e&&!Zarafa.core.EntryId.compareABEntryIds(d,e))g=this.record.get("sender_name")||
this.record.get("sender_email_address");if(!Ext.isEmpty(f)){if(this.record.get("meeting_updated")){a.createChild({tag:"div",html:this.meetingUpdatedInfoString,cls:this.itemCls});b=true}if(c){c="";if(Ext.isEmpty(g))if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent"))c=String.format(this.counterProposalTentativeAcceptedString,f);else{if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg"))c=String.format(this.counterProposalDeclinedString,f)}else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent"))c=
String.format(this.counterProposalTentativeAcceptedDelegateString,g,f);else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg"))c=String.format(this.counterProposalDeclinedDelegateString,g,f)}else{c="";if(Ext.isEmpty(g))if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Pos"))c=String.format(this.acceptInfoString,f);else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent"))c=String.format(this.tentativeInfoString,f);else{if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg"))c=
String.format(this.declineInfoString,f)}else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Pos"))c=String.format(this.acceptDelegateInfoString,g,f);else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Tent"))c=String.format(this.tentativeDelegateInfoString,g,f);else if(this.record.isMessageClass("IPM.Schedule.Meeting.Resp.Neg"))c=String.format(this.declineDelegateInfoString,g,f)}if(!Ext.isEmpty(c)){a.createChild({tag:"div",html:c,cls:this.itemCls});b=true}}return b},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.MessageBody=Ext.extend(Ext.Container,{plaintextTemplate:"<html><body><pre>{body}</pre></body></html>",emailPattern:/((mailto:)[\w@,;.?=&%:///+ ]+)|([\w-\._\+%]+@(?:[\w-]+\.)+[\w]*)/gi,linkPattern:/((?:http|ftp)s?:\/\/|www.)([\w\.\-]+)\.(\w{2,6})([\w\/\-\_\+\.\,\?\=\&\!\:\;\%\#\|]+)*/gi,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:Ext.SSL_SECURE_URL},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})},setRelayEventListeners:function(){this.getEl().dom.contentWindow.document.addEventListener("mousedown",this.onMouseDown.createDelegate(this),true)},onMouseDown:function(){Ext.getDoc().fireEvent("mousedown")},
setIdleTimeEventListeners:function(){var a=this.getEl().dom.contentWindow.document;if(a.addEventListener){a.addEventListener("click",function(){Zarafa.idleTime=0},true);a.addEventListener("mousemove",function(){Zarafa.idleTime=0},true);a.addEventListener("keydown",function(){Zarafa.idleTime=0},true)}},update:function(a){var b=this.getEl().dom.contentWindow,c=b.document,d=new Ext.Element(c),e="",f;Ext.isEmpty(c.body)||Zarafa.core.KeyMapMgr.deactivate(d);if(Ext.isDefined(a)){f=a.get("isHTML");if(e=
a.getBody(f)){if(f===false)e=this.plaintextTemplate.applyTemplate({body:Ext.util.Format.htmlEncode(e)})}else e=""}c.open();c.write("<!DOCTYPE html><html><body>");c.write(e);c.write("</body></html>");c.close();Ext.EventManager.on(b,"dragover",Zarafa.onWindowDragDrop);Ext.EventManager.on(b,"drop",Zarafa.onWindowDragDrop);this.addCSSText(c);this.scanDOMForLinks(c);this.handleMailToLinks(d);if(a=this.recordComponentUpdaterPlugin.rootContainer){Zarafa.core.KeyMapMgr.activate(a,"global",d);Zarafa.core.KeyMapMgr.activate(a,
"contentpanel.record.message.showmail",d)}},scanDOMForLinks:function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)c.nodeName!="A"&&this.scanDOMForLinks(c);else if(c.nodeType==3)if(c.nodeValue.trim().length>0)if(c.nodeValue.search(this.emailPattern)!=-1||c.nodeValue.search(this.linkPattern)!=-1)this.linkifyDOMNode(c,a)}},linkifyDOMNode:function(a,b){for(var c=Zarafa.core.Util.splitStringByPattern(a.nodeValue,this.linkPattern),d=[],e=0;e<c.length;e++)if(c[e].search(this.linkPattern)==
-1){var f=Zarafa.core.Util.splitStringByPattern(c[e],this.emailPattern);d.push.apply(d,f)}else d.push(c[e]);c=Ext.DomHelper.createDom({tag:"span"});for(e=0;e<d.length;e++)if(d[e].search(this.linkPattern)!=-1){f=Ext.DomHelper.append(c,{tag:"a",html:d[e]});var g=d[e];if(g.search(/(http|ftp)(s)?:\/\//gi)!==0)g="http://"+g;f.setAttribute("href",g);f.setAttribute("target","_blank")}else if(d[e].search(this.emailPattern)!=-1){f=Ext.DomHelper.append(c,{tag:"a",html:d[e]});g=d[e];if(g.indexOf("mailto:")!==
0)g="mailto:"+g;f.setAttribute("href",g)}else Ext.DomHelper.append(c,Ext.util.Format.htmlEncode(d[e]));e=0;for(d=c.childNodes.length;e<d;e++)b.insertBefore(c.childNodes.item(0),a);b.removeChild(a)},handleMailToLinks:function(a){a=a.query('a[href^="mailto:"]');if(!Ext.isEmpty(a))for(var b=0;b<a.length;b++)Ext.EventManager.on(a[b],"click",this.onMailtoClick)},onMailtoClick:function(a,b){a.preventDefault();Zarafa.core.URLActionMgr.execute({mailto:this.href||b.href})},addCSSText:function(a){var b=a.getElementsByTagName("head")[0];
a=a.createElement("style");a.setAttribute("type","text/css");a.appendChild(document.createTextNode("body { margin: 0; padding: 9px; } blockquote { margin-right: 0px; }pre { white-space: pre-wrap; }"));b.appendChild(a)},onRender:function(a,b){Zarafa.common.ui.messagepanel.MessageBody.superclass.onRender.call(this,a,b);container.getServerConfig().getClientTimeout()&&this.getEl().on("load",this.setIdleTimeEventListeners,this);this.getEl().on("load",this.setRelayEventListeners,this);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.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",plugins:["zarafa.recordcomponentupdaterplugin"],fieldLabel:pgettext("mail.previewpanel","To"),recipientType:Zarafa.core.mapi.RecipientType.MAPI_TO},{xtype:"zarafa.recipientlinks",plugins:["zarafa.recordcomponentupdaterplugin"],
fieldLabel:pgettext("mail.previewpanel","Cc"),recipientType:Zarafa.core.mapi.RecipientType.MAPI_CC},{xtype:"zarafa.recipientlinks",plugins:["zarafa.recordcomponentupdaterplugin"],fieldLabel:pgettext("mail.previewpanel","Bcc"),recipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC},{xtype:"zarafa.attachmentlinks",plugins:["zarafa.recordcomponentupdaterplugin"],fieldLabel:pgettext("mail.previewpanel","Attachments")},container.populateInsertionPoint("previewpanel.toolbar.detaillinks",this)]});Zarafa.common.ui.messagepanel.MessageHeader.superclass.constructor.call(this,
a);this.on("collapse",this.onAfterSlide,this);this.on("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=""}},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.RecipientLinks=Ext.extend(Ext.DataView,{ellipsisStringStartLength:30,ellipsisStringEndLength:30,maxHeight:50,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:"span.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" style="max-height: {this.maxHeight}px"><tpl for="."><span viewIndex="{viewIndex}" class="zarafa-emailaddress-link zarafa-recipient-link"><span class="zarafa-presence-status {[Zarafa.core.data.PresenceStatus.getCssClass(values.presence_status)]}"><span class="zarafa-presence-status-icon"></span><tpl if="!Ext.isEmpty(values.display_name)">{display_name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)} </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></span></span><tpl if="xindex &gt; 0 && xindex != xcount"><span>; </span></tpl></tpl></div></div></tpl>',
{compiled:true,fieldLabel:a.fieldLabel||this.fieldLabel,maxHeight:a.maxHeight||this.maxHeight,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);
container.populateInsertionPoint("previewpanel.toolbar.recipientlinks",this);this.on("contextmenu",this.onRecipientContextMenu,this);this.on("dblclick",this.onRecipientDoubleClick,this)},setRecord:function(a){if(a)a.isOpened()&&this.bindStore(a.getRecipientStore());else this.bindStore(null)},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,10)))},update:function(a,b){if(a&&a instanceof
Zarafa.core.data.MAPIRecord)b&&a.isOpened()&&this.setRecord(a);else Zarafa.common.ui.messagepanel.RecipientLinks.superclass.update.apply(this,arguments)},onUpdate:function(a,b){if(b.get("recipient_type")===this.recipientType){var c=this.store.indexOf(b),d=-1;Ext.each(this.store.getRange(),function(g){g.get("recipient_type")===this.recipientType&&d++},this);if(c>-1){var e=this.isSelected(d),f=this.all.elements[d];c=this.bufferRender([b],c)[0];this.all.replaceElement(d,c,true);if(e){this.selected.replaceElement(f,
c);this.all.item(d).addClass(this.selectedClass)}this.updateIndexes(d,d)}}},refresh:function(){this.clearSelections(false,true);var a=this.getTemplateTarget(),b=this.store.getRange();a.update("");if(b.length<1){if(!this.deferEmptyText||this.hasSkippedEmptyText)a.update(this.emptyText);this.all.clear();this.setVisible(false)}else{b=this.collectData(b,0);this.tpl.overwrite(a,b);this.all.fill(Ext.query(this.itemSelector,a.dom));this.updateIndexes(0);b.length<1?this.setVisible(false):this.setVisible(true)}this.hasSkippedEmptyText=
true},onRecipientContextMenu:function(a,b,c,d){Zarafa.core.data.UIFactory.openDefaultContextMenu(this.createRecipientFromNode(c),{position:d.getXY()})},onRecipientDoubleClick:function(a,b,c){a=a.getRecord(c);Zarafa.common.Actions.openViewRecipientContent(a)},createRecipientFromNode:function(a){a=this.getRecord(a);a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,a.data);a.set("rowid","");a.set("recipient_trackstatus","");a.set("recipient_trackstatus_time",
"");return a}});Ext.reg("zarafa.recipientlinks",Zarafa.common.ui.messagepanel.RecipientLinks);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.sender_entryid) && !Ext.isEmpty(values.sent_representing_entryid) && !Zarafa.core.EntryId.compareABEntryIds(values.sent_representing_entryid, values.sender_entryid)"><span class="preview-from"><span class="zarafa-emailaddress-link zarafa-sentinfo-link"> <span class="zarafa-presence-status {[Zarafa.core.data.PresenceStatus.getCssClass(values.sender_presence_status)]}"><span class="zarafa-presence-status-icon"></span>{sender_name:htmlEncode} &lt;{sender_email_address:htmlEncode}&gt; </span></span><span>&nbsp;'+pgettext("mail.previewpanel",
"on behalf of")+'&nbsp;</span><span class="zarafa-emailaddress-link zarafa-sentinfo-on-behalf"><span class="zarafa-presence-status {[Zarafa.core.data.PresenceStatus.getCssClass(values.sent_representing_presence_status)]}"><span class="zarafa-presence-status-icon"></span>{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></span></span></span></tpl><tpl if="Ext.isEmpty(values.sender_entryid) || Ext.isEmpty(values.sent_representing_entryid) || Zarafa.core.EntryId.compareABEntryIds(values.sent_representing_entryid, values.sender_entryid)"><span class="preview-from zarafa-presence-status {[Zarafa.core.data.PresenceStatus.getCssClass(values.sender_presence_status)]}"><span class="zarafa-presence-status-icon"></span><span class="zarafa-emailaddress-link zarafa-sentinfo-link">{sender_name:htmlEncodeElide(this.ellipsisStringStartLength, this.ellipsisStringEndLength)}&nbsp;<tpl if="!Ext.isEmpty(values.sender_email_address)">&lt;{sender_email_address:htmlEncode}&gt;</tpl></span></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){var b=Ext.get(this.senderElem);if(Ext.isDefined(a)){this.senderTemplate.overwrite(b,a.data);this.mon(b.select(".zarafa-sentinfo-link"),"contextmenu",this.onSenderContextMenu,this);this.mon(b.select(".zarafa-sentinfo-on-behalf"),"contextmenu",this.onSenderContextMenu,this);this.mon(b.select(".zarafa-sentinfo-link"),"dblclick",this.onDoubleClick,this);this.mon(b.select(".zarafa-sentinfo-on-behalf"),
"dblclick",this.onDoubleClick,this)}else{this.mun(b.select(".zarafa-sentinfo-link"),"contextmenu",this.onSenderContextMenu,this);this.mun(b.select(".zarafa-sentinfo-on-behalf"),"contextmenu",this.onSenderContextMenu,this);this.mun(b.select(".zarafa-sentinfo-link"),"dblclick",this.onDoubleClick,this);this.mun(b.select(".zarafa-sentinfo-on-behalf"),"dblclick",this.onDoubleClick,this);this.senderElem.innerHTML=""}}this.record=a},onSenderContextMenu:function(a,b){var c=this.convertSenderToRecord(b);Zarafa.core.data.UIFactory.openDefaultContextMenu(c,
{position:a.getXY()})},onDoubleClick:function(a,b){var c=this.convertSenderToRecord(b);Zarafa.common.Actions.openViewRecipientContent(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.taskpanel");
Zarafa.common.ui.taskpanel.TaskBody=Ext.extend(Ext.form.FormPanel,{headerTemplate:'<div class="preview-header-titlebox"><tpl if="!Ext.isEmpty(values.subject)"><span class="preview-title">{subject:htmlEncode}</span></tpl></div>',constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");a=Ext.applyIf(a,{xtype:"zarafa.taskbody",border:false,header:true,autoScroll:true,unstyled:true,autoWidth:true,headerCfg:{cls:"preview-header-title"},items:[{xtype:"fieldset",
title:_("Task"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Subject"),name:"subject"},{fieldLabel:_("Start Date"),ref:"../startDate"},{fieldLabel:_("End Date"),ref:"../endDate"},{fieldLabel:_("Status"),ref:"../taskStatusPreview",name:"status"},{fieldLabel:_("Priority"),ref:"../taskImportancePreview",name:"importance"},{fieldLabel:_("% Complete"),name:"percent_complete"},{fieldLabel:_("Owner"),name:"owner"}]},{xtype:"fieldset",title:_("Details"),defaults:{xtype:"displayfield"},items:[{fieldLabel:_("Date Complete"),
name:"date_completed"},{fieldLabel:_("Total Work"),name:"totalwork"},{fieldLabel:_("Actual Work"),name:"actualwork"},{fieldLabel:_("Mileage"),name:"mileage"},{fieldLabel:_("Billing Information"),name:"billing_information"},{fieldLabel:_("Companies"),name:"companies"}]}]});Zarafa.common.ui.taskpanel.TaskBody.superclass.constructor.call(this,a);if(Ext.isString(this.headerTemplate))this.headerTemplate=new Ext.XTemplate(this.headerTemplate,{compiled:true})},update:function(a){this.record=a;this.getForm().loadRecord(a);
if(Ext.isDefined(a))this.headerTemplate.overwrite(this.header.dom,a.data);else this.header.dom.innerHTML="";this.taskStatusPreview.setValue(Zarafa.core.mapi.TaskStatus.getDisplayName(a.get("status")));this.taskImportancePreview.setValue(Zarafa.core.mapi.Importance.getDisplayName(a.get("importance")));var b=a.get("startdate");if(Ext.isDate(b)){b=b.toUTC();this.startDate.setValue(b)}a=a.get("duedate");if(Ext.isDate(a)){a=a.toUTC();this.endDate.setValue(a)}}});Ext.reg("zarafa.taskbody",Zarafa.common.ui.taskpanel.TaskBody);
Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.Actions={openAddressBook:function(a){a=Ext.applyIf(a||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"],undefined,a)},openDetailsContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];if(a.isPersonalContact()){a=a.convertToContactRecord();container.getShadowStore().add(a)}else if(a.isPersonalDistList()){a=a.convertToDistListRecord();container.getShadowStore().add(a)}b=Ext.applyIf(b||{},
{modal:true});Zarafa.core.data.UIFactory.openViewRecord(a,b)}};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.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"},container.populateInsertionPoint("context.addressbook.abgroupdetailcontentpanel.tabs",this)]});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.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.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>',headerCls:"zarafa-icon-column icon",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.on("rowdblclick",this.onRowDblClick,this)},onRowDblClick:function(a,b){var c=this.getStore().getAt(b);c&&Zarafa.core.data.UIFactory.openViewRecord(c)}});Ext.reg("zarafa.abitemgrid",Zarafa.addressbook.dialogs.ABItemGrid);
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.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"},container.populateInsertionPoint("context.addressbook.abuserdetailcontentpanel.tabs",this)]});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.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:[{ptype:"zarafa.fieldlabeler"}]},{xtype:"spacer",width:6,height:3},{xtype:"textfield",columnWidth:0.3,labelWidth:50,fieldLabel:_("Initial"),
name:"initials",plugins:[{ptype:"zarafa.fieldlabeler"}]}]},{xtype:"container",layout:"column",anchor:"100%",border:false,items:[{xtype:"textfield",columnWidth:0.7,readOnly:true,style:"margin-top: 3px;",fieldLabel:_("Display"),plugins:[{ptype:"zarafa.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.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.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.ui");
Zarafa.addressbook.ui.ABMultiUserSelectionPanel=Ext.extend(Ext.form.FormPanel,{callback:Ext.emptyFn,convert:Ext.emptyFn,scope:undefined,store:undefined,selectionCfg:undefined,constructor:function(a){a=a||{};var b=[{xtype:"zarafa.addressbookmainpanel",ref:"abPanel",flex:1,hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction}];Ext.each(a.selectionCfg,function(c){b.push({xtype:"zarafa.resizablecompositefield",cls:"zarafa-addressbook-dialog-compositefield",hideLabel:true,anchor:"100%",
autoHeight:false,items:[{xtype:"button",text:c.fieldLabel,autoHeight:true,handler:this.onSelectionBtnClick,scope:this},c]})},this);Ext.applyIf(a,{xtype:"zarafa.abmultiuserselectionpanel",layout:{type:"vbox",align:"stretch"},bodyStyle:"padding: 5px;",items:b,buttons:[{text:_("Ok"),handler:this.onSubmit,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]});Zarafa.addressbook.ui.ABMultiUserSelectionPanel.superclass.constructor.call(this,a)},doCallBack:function(){var a=this.abPanel.getGridPanel().getSelectionModel().getSelections();
Ext.isEmpty(a)||Ext.each(a,function(b){this.store.add(this.convert(b))},this)},initEvents:function(){Zarafa.addressbook.ui.ABMultiUserSelectionPanel.superclass.initEvents.apply(this,arguments);this.mon(this.abPanel.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,this);this.mon(this.abPanel.getGridPanel(),"rowcontextmenu",this.onAddressBookRowContextMenu,this)},onAddressBookRowDblClick:function(){this.onSelectionBtnClick()},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.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),dialog:this.dialog})},onSelectionBtnClick:function(a){var b=a?a.ownerCt.get(1):undefined;a=this.abPanel.getGridPanel().getSelectionModel().getSelections();Ext.isFunction(this.convert)&&!Ext.isEmpty(a)&&Ext.each(a,function(c){(c=this.convert.call(this.scope||this,c,b))&&this.store.add(c)},this)},onSubmit:function(){if(Ext.isFunction(this.callback))this.callback.call(this.scope||
this)!==false?this.dialog.close():Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("You must select one or more users."),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})},onCancel:function(){this.dialog.close()}});Ext.reg("zarafa.abmultiuserselectionpanel",Zarafa.addressbook.ui.ABMultiUserSelectionPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookMainPanel=Ext.extend(Ext.Panel,{hierarchyStore:undefined,addressBookStore:undefined,hierarchyRestriction:undefined,listRestriction:undefined,singleSelect:false,loadMask:undefined,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:Ext.isDefined(a.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.mon(this.hierarchyStore,"load",this.onHierarchyStoreLoad,this);this.on("afterlayout",this.onAfterLayout,this,{single:true});this.mon(this.hierarchyStore,"beforeload",
this.showLoadMask,this);this.on("destroy",this.hierarchyStore.destroy,this.hierarchyStore);this.on("destroy",this.addressBookStore.destroy,this.addressBookStore)},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.addressbookgrid",hideLabel:true,name:"viewpanel",store:a,border:false,ref:"viewPanel",flex:1})},getGridPanel:function(){return this.viewPanel},onAddressBookChange:function(a,b){this.addressBookStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.globaladdressbook,entryid:b.get("entryid"),store_entryid:b.get("store_entryid"),
restriction:Ext.applyIf({},this.listRestriction),folderType:b.get("type")}})},onAfterLayout:function(){this.hierarchyStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.hierarchy,gab:"all",restriction:Ext.applyIf({},this.hierarchyRestriction)}})},onHierarchyStoreLoad:function(){var a;if(Ext.isDefined(this.addressBookSelectionCB))if(this.hierarchyStore.getCount()!==0){var b=container.getSettingsModel().get("zarafa/v1/main/default_addressbook");Ext.isEmpty(b)||
(a=this.hierarchyStore.getById(b));if(Ext.isEmpty(a))a=this.hierarchyStore.getAt(0);this.hideLoadMask();this.addressBookStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.globaladdressbook,entryid:a.get("entryid"),store_entryid:a.get("store_entryid"),restriction:Ext.applyIf({},this.listRestriction),folderType:a.get("type")}});a=a.get("entryid");Ext.isDefined(a)&&this.addressBookSelectionCB.setValue(a)}},onSearchButtonClick:function(){var a=this.searchText.getValue().trim();
this.addressBookStore.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.globaladdressbook,restriction:Ext.applyIf({searchstring:a},this.listRestriction),folderType:this.addressBookStore.lastOptions.params.folderType}})},onSearchTextFiledKeyUp:function(a,b){b.getKey()===b.ENTER&&this.onSearchButtonClick()},showLoadMask:function(){if(!this.loadMask)this.loadMask=new Zarafa.common.ui.LoadMask(this.el);this.loadMask.show()},hideLoadMask:function(){this.loadMask&&this.loadMask.hide()}});
Ext.reg("zarafa.addressbookmainpanel",Zarafa.addressbook.ui.AddressBookMainPanel);Ext.namespace("Zarafa.advancesearch.data");Zarafa.advancesearch.data.DateRangeFields=[{name:_("Any date"),value:"all_dates"},{name:_("Past week"),value:"past_week"},{name:_("Past 2 weeks"),value:"past_two_weeks"},{name:_("Past month"),value:"past_month"},{name:_("Past 6 month"),value:"past_six_month"},{name:_("Past year"),value:"past_year"},{name:_("Custom date"),value:"custom_date"}];Ext.namespace("Zarafa.advancesearch.dialogs");
Zarafa.advancesearch.dialogs.SearchCenterPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.searchContext))a.model=a.searchContext.getModel();Ext.applyIf(a,{xtype:"zarafa.searchcenterpanel",region:"center",layout:"fit",ref:"centerRegion",unstyled:true,items:[{xtype:"panel",layout:"zarafa.switchborder",ref:"switchBorder",border:false,unstyled:true,items:[{layout:"fit",cls:"zarafa-context-mainpanel",collapsible:false,region:"center",items:[{xtype:"zarafa.switchviewcontentcontainer",
ref:"../viewPanel",layout:"card",activeItem:0,items:[{xtype:"zarafa.searchgrid",flex:1,id:"search-grid"+ ++Ext.Component.AUTO_ID,searchTabId:a.searchTabId,anchor:"100%",searchContext:a.searchContext,ref:"../../searchGrid"}]}]},{region:"south",xtype:"zarafa.searchresultpreviewpanel",ref:"../searchResultPreviewPanel",split:true,width:400,height:400,searchContext:a.searchContext}]}]});Zarafa.advancesearch.dialogs.SearchCenterPanel.superclass.constructor.call(this,a)},initEvents:function(){if(Ext.isDefined(this.searchContext)){this.switchBorder.mon(this.searchContext,
{viewchange:this.onViewChange,viewmodechange:this.onViewModeChange,scope:this});this.switchBorder.on("afterlayout",this.onAfterLayout,this,{single:true})}},getSearchResultPreviewPanel:function(){return this.searchResultPreviewPanel},onAfterLayout:function(){this.onViewModeChange(this.searchContext,this.searchContext.getCurrentViewMode())},onViewChange:function(a,b){b===Zarafa.common.data.Views.LIST&&this.switchBorder.viewPanel.switchView(this.switchBorder.searchGrid.getId())},onViewModeChange:function(a,
b){var c;switch(b){case Zarafa.common.data.ViewModes.NO_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.OFF;break;case Zarafa.common.data.ViewModes.RIGHT_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.HORIZONTAL;this.getSearchResultPreviewPanel().getTopToolbar().onHide();break;case Zarafa.common.data.ViewModes.BOTTOM_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.VERTICAL;var d=this.model.getPreviewRecord();Ext.isDefined(d)&&this.getSearchResultPreviewPanel().getTopToolbar().onShow();
break;case Zarafa.common.data.ViewModes.SEARCH:case Zarafa.common.data.ViewModes.LIVESCROLL:return}d=this.switchBorder.getLayout();if(Ext.isFunction(d.setOrientation))d.setOrientation(c);else if(Ext.isString(d))this.layoutConfig=Ext.apply(this.layoutConfig||{},{orientation:c});else this.layout.orientation=c}});Ext.reg("zarafa.searchcenterpanel",Zarafa.advancesearch.dialogs.SearchCenterPanel);Ext.namespace("Zarafa.advancesearch.dialogs");
Zarafa.advancesearch.dialogs.SearchPanel=Ext.extend(Ext.Panel,{searchContentPanel:undefined,constructor:function(a){a=a||{};var b=container.getContextByName("advancesearch");if(!Ext.isDefined(a.model)&&Ext.isDefined(b)){a.model=b.getModel();var c=container.getCurrentContext().getModel();b.enable(c.getDefaultFolder(),true)}Ext.applyIf(a,{xtype:"zarafa.searchpanel",layout:"border",border:false,items:[{xtype:"zarafa.searchtoolboxpanel",searchContext:b,region:"west",scope:this},{xtype:"zarafa.searchcenterpanel",
searchContext:b,searchTabId:a.searchTabId,region:"center",scope:this},{xtype:"zarafa.searchtoolbarpanel",searchContext:b,searchText:a.searchText,region:"north",scope:this}]});Zarafa.advancesearch.dialogs.SearchPanel.superclass.constructor.call(this,a)},initEvents:function(){this.mon(this.centerRegion.getSearchResultPreviewPanel(),{afterupdatesearchpreviewpanel:this.onAfterUpdateSearchPreviewPanel,scope:this});this.mon(this.searchContentPanel,{beforeclose:this.onBeforeCloseContentPanel,scope:this});
this.mon(this.centerRegion.switchBorder.searchGrid,{resize:this.onSearchGridResize,scope:this});this.mon(this.searchToolBox,{afterupdaterestriction:this.onAfterUpdateRestriction,scope:this});this.mon(this.searchToolBox,"afterlayout",this.onAfterRenderSearchToolBox,this,{single:true});this.mon(this.model,{searchfinished:this.onModelSearchFinished,searchexception:this.onModelSearchException,scope:this});this.searchToolbar.mon(this.searchToolbar.getAdvanceSearchField(),{render:this.onRenderAdvanceSearchTextField,
start:this.onSearchStart,stop:this.onSearchStop,scope:this});this.mon(container,{aftercontextswitch:this.onAfterContextSwitch,scope:this})},onAfterContextSwitch:function(){var a=container.getTabPanel().getActiveTab().getActiveItem().getTopToolbar(),b;Ext.isDefined(a)&&Ext.isDefined(b=a.searchTextfield)?this.searchContentPanel.setParentSearchField(b):this.searchContentPanel.setParentSearchField(undefined)},onBeforeCloseContentPanel:function(a){var b=this.resetParentSearchField();if(b)b.renderedSearchPanel=
false;b=false;var c=this.model;if(c.getActiveStore().getSearchStoreUniqueId()!==a.name){b=this.model.store;c.setActiveStore(c.stores[a.name])}this.onSearchStop();Ext.isDefined(c.getSelectedRecords())&&c.setSelectedRecords(undefined);c.discardStore(a.name);b!==false&&c.setActiveStore(b)},onModelSearchFinished:function(){this.resetParentSearchField();this.searchToolbar.getAdvanceSearchField().doStop(true)},resetParentSearchField:function(){var a=this.searchContentPanel.getParentSearchField();if(Ext.isDefined(a)){a.reset();
a.doStop(false);return a}return false},onModelSearchException:function(){var a=this.searchToolbar.getAdvanceSearchField();a.doStop(false);a.focus()},onSearchStart:function(a){a=a.getValue();var b=this.searchToolbar.getAdvanceSearchField();this.searchContentPanel.setTitle(a);b.getValue()!==a&&b.setValue(a);a=this.searchToolBox.createRestriction(a);b=this.searchToolBox.getFolder();this.model.startSearch(a,b.isIPMSubTree(),{folder:b});container.getTabPanel().setActiveTab(this.searchContentPanel)},onSearchStop:function(){this.model.stopSearch();
Ext.isDefined(this.searchToolbar)&&this.searchToolbar.getAdvanceSearchField().focus()},onAfterRenderSearchToolBox:function(){var a=this.searchToolbar.getAdvanceSearchField();a.renderedSearchPanel=this.rendered;a.onTriggerClick()},onAfterUpdateRestriction:function(){this.searchToolbar.getAdvanceSearchField().onTriggerClick()},onRenderAdvanceSearchTextField:function(a){a.setValue(this.searchText)},onSearchGridResize:function(a,b){var c=this.searchToolbar.contextMainPanelToolbar,d=this.searchToolbar.getRightSearchToolbar(),
e=this.getLayout().west,f=e.getMargins();f=f.left+f.right;c.setWidth(e.getSize().width+f+b);d.setWidth(this.centerRegion.switchBorder.getLayout().south.getSize().width);d.setPosition(c.getWidth())},onAfterUpdateSearchPreviewPanel:function(a,b){var c=this.searchToolbar.getRightSearchToolbar();c.setVisible(!!b);if(b){var d=b.isFaultyMessage(),e=Zarafa.core.MessageClass.isClass(b.get("message_class"),["IPM.NOTE","REPORT.IPM","IPM.SCHEDULE","IPM.APPOINTMENT"]);if(e&&Zarafa.core.MessageClass.isClass(b.get("message_class"),
["IPM.APPOINTMENT"]))b.isMeeting()||(e=false);c.replyBtn.setVisible(!d&&e);c.replyAllBtn.setVisible(!d&&e);c.forwardBtn.setVisible(!d&&e);var f=a.model.getDefaultFolder();c.editAsNewBtn.setVisible(f.getDefaultFolderKey()==="sent"&&!d&&e);this.searchToolbar.recordComponentPlugin.setRecord(b)}}});Ext.reg("zarafa.searchpanel",Zarafa.advancesearch.dialogs.SearchPanel);Ext.namespace("Zarafa.advancesearch.dialogs");
Zarafa.advancesearch.dialogs.SearchToolBoxPanel=Ext.extend(Ext.Panel,{model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.searchContext))a.model=a.searchContext.getModel();a.messageClasses={};a.folder=undefined;a.searchFields={};a.searchCriteria={};a.searchCriteria.date_range={};a.searchCriteria.date_range.start=0;a.searchCriteria.date_range.end=0;var b={xtype:"jsonstore",autoDestroy:true,fields:["name","value"],autoLoad:true,data:Zarafa.advancesearch.data.DateRangeFields};
Ext.applyIf(a,{xtype:"zarafa.searchtoolboxpanel",title:_("Search tools"),width:175,boxMaxWidth:175,boxMinWidth:175,iconCls:"advance_search",cls:"zarafa-search-toolbox",split:true,plugins:[{ptype:"zarafa.recordcomponentplugin"},{ptype:"zarafa.recordcomponentupdaterplugin"}],collapsible:true,layout:"fit",unstyled:true,ref:"searchToolBox",items:[{xtype:"container",layout:"vbox",items:[this.createFoldersFieldset(a.model.getDefaultFolder()),this.createMessageTypeFieldset(),this.createFilterFieldset(),
this.createDateRangeFieldset(b),this.createSearchInFieldset()]}]});this.addEvents("afterupdaterestriction");Zarafa.advancesearch.dialogs.SearchToolBoxPanel.superclass.constructor.call(this,a)},createFoldersFieldset:function(a){var b=a.getMAPIStore();b=!(b.isPublicStore()||b.isSharedStore());var c="folders"+ ++Ext.Component.AUTO_ID;return{layout:"form",xtype:"fieldset",border:false,width:156,title:_("Folders"),items:[{xtype:"radiogroup",columns:1,ref:"../../folderRadioGroup",hideLabel:true,items:[{name:c,
checked:b,disabled:!b,inputValue:"all_folders",ref:"../allFoldersRadio",boxLabel:_("All My folders"),listeners:{check:this.onRadioCheck,scope:this}},{name:c,checked:!b,ref:"../currentFolderRadio",inputValue:"current_folder",boxLabel:_("Current folder")+" ("+a.getDisplayName()+")",listeners:{check:this.onRadioCheck,scope:this}}]}]}},createMessageTypeFieldset:function(){return{layout:"form",xtype:"fieldset",width:156,border:false,title:_("Show.."),items:[{xtype:"checkboxgroup",ref:"../../messageTypeCheckboxGroup",
columns:1,hideLabel:true,listeners:{change:this.onMessageTypeCheckboxChange,scope:this},items:[{name:"mail",boxLabel:_("Mails")},{name:"calendar",boxLabel:_("Calendar items")},{name:"contact",boxLabel:_("Contact items")},{name:"task",boxLabel:_("Task items")},{name:"note",boxLabel:_("Note items")}]}]}},createFilterFieldset:function(){return{layout:"form",xtype:"fieldset",width:156,border:false,title:_("Filter.."),items:[{xtype:"checkboxgroup",columns:1,hideLabel:true,listeners:{change:this.onFilterCheckBoxGroup,
scope:this},items:[{name:"message_flags",boxLabel:_("Unread items")},{name:"hasattach",boxLabel:_("With attachments")}]}]}},createDateRangeFieldset:function(a){return{layout:"form",xtype:"fieldset",border:false,title:_("Date"),items:[{xtype:"combo",displayField:"name",editable:false,hideLabel:true,ref:"../../dateRangeCombo",store:a,valueField:"value",value:a.data[0].value,mode:"local",triggerAction:"all",width:146,listeners:{select:this.onSelectCombo,scope:this}},{xtype:"zarafa.dateperiodfield",ref:"../../dateField",
hidden:true,allowBlank:false,defaultValue:new Zarafa.core.DateRange({allowBlank:false,startDate:(new Date).add(Date.MONTH,-1),dueDate:new Date}),startFieldConfig:{labelSeparator:"",fieldLabel:_("From"),labelStyle:"width : 35px",itemCls:"zarafa-dateperiodfield-itemsCls",labelWidth:50,width:110},endFieldConfig:{labelSeparator:"",fieldLabel:_("To"),labelStyle:"width : 35px",itemCls:"zarafa-dateperiodfield-itemsCls",labelWidth:50,width:110}}]}},createSearchInFieldset:function(){return{layout:"form",xtype:"fieldset",
width:160,border:false,title:_("Search.."),items:[{xtype:"checkboxgroup",columns:1,hideLabel:true,listeners:{change:this.onSearchInCheckboxChange,scope:this},items:[{name:"sender_name",boxLabel:_("Sender")},{name:["display_to","display_cc","display_bcc"],boxLabel:_("Recipients")},{name:"subject",boxLabel:_("Subject")},{name:"body",boxLabel:_("Body & Attachments")}]}]}},initEvents:function(){this.mon(this.folderRadioGroup,{render:this.onAfterRenderFolderRadioGroup,scope:this});this.mon(this.messageTypeCheckboxGroup,
{render:this.onAfterRenderCheckboxGroup,scope:this});this.mon(this.dateRangeCombo,{enable:this.onEnableCombo,scope:this});this.mon(this.dateField,{change:this.onChangeDateField,scope:this});this.dateField.mon(this.dateField.startField,"specialkey",this.onSpecialKey,this);this.dateField.mon(this.dateField.endField,"specialkey",this.onSpecialKey,this);this.mon(this.model,"folderchange",this.onFolderChange,this)},onSpecialKey:function(a,b){b.getKey()===b.ENTER&&a.triggerBlur()},onSelectCombo:function(a,
b){var c=b.get("value"),d=new Date;this.searchCriteria.date_range.end=d.add(Date.DAY,1).getTime()/1E3;if(c!=="custom_date"){this.dateField.hide();this.doLayout()}switch(c){case "past_week":this.searchCriteria.date_range.start=d.add(Date.DAY,-7).getTime()/1E3;break;case "past_two_weeks":this.searchCriteria.date_range.start=d.add(Date.DAY,-14).getTime()/1E3;break;case "past_month":this.searchCriteria.date_range.start=d.add(Date.MONTH,-1).getTime()/1E3;break;case "past_six_month":this.searchCriteria.date_range.start=
d.add(Date.MONTH,-6).getTime()/1E3;break;case "past_year":this.searchCriteria.date_range.start=d.add(Date.YEAR,-1).getTime()/1E3;break;case "custom_date":this.dateField.show();this.doLayout();this.searchCriteria.date_range.start=this.dateField.startField.getValue().getTime()/1E3;this.searchCriteria.date_range.end=this.dateField.endField.getValue().add(Date.DAY,1).getTime()/1E3;break;default:this.searchCriteria.date_range.start=0;this.searchCriteria.date_range.end=0}this.afterUpdateRestriction()},
onFilterCheckBoxGroup:function(a,b){this.setFilterRestriction(a,b);this.afterUpdateRestriction()},onMessageTypeCheckboxChange:function(a,b){this.setMessageClassRestriction(a,b);this.afterUpdateRestriction()},onSearchInCheckboxChange:function(a,b){if(Ext.isEmpty(b))this.setMessageClassRestriction(this.messageTypeCheckboxGroup,this.messageTypeCheckboxGroup.getValue());else{var c=[];b.forEach(function(d){c=c.concat(d.name)});this.searchCriteria.search_fields=c}this.afterUpdateRestriction()},afterUpdateRestriction:function(){this.fireEvent("afterupdaterestriction",
this)},onAfterRenderCheckboxGroup:function(a){this.setMessageClassRestriction(a,[])},setFilterRestriction:function(a,b){this.searchCriteria.extra_fields=b.map(function(c){return c.name})},setMessageClassRestriction:function(a,b){function c(f,g,i){return i.indexOf(f)===g}var d=[],e=[];if(Ext.isEmpty(b))b=a.items.items;b.forEach(function(f){d=d.concat(this.getMessageClass(f.name));e=e.concat(Zarafa[f.name].data.SearchFields[0].value.split(" "))},this);this.searchCriteria.message_class=d.filter(c);this.searchCriteria.search_fields=
e.filter(c)},getMessageClass:function(a){switch(a){case "mail":return["IPM.Note"];case "calendar":return["IPM.Appointment","IPM.Schedule"];case "contact":return["IPM.Contact","IPM.DistList"];case "task":return["IPM.Task"];case "note":return["IPM.StickyNote"]}},onChangeDateField:function(a,b,c){a=b.startDate.getTime()/1E3;var d=b.dueDate.add(Date.DAY,1).getTime()/1E3;this.searchCriteria.date_range.start=a;this.searchCriteria.date_range.end=d;b.compare(c)!==0&&this.afterUpdateRestriction()},onEnableCombo:function(a){var b=
a.getStore().find("value",a.getValue());b=a.getStore().getAt(b);this.onSelectCombo(a,b)},onFolderChange:function(a,b){var c=b[0].getMAPIStore(),d=this.folderRadioGroup.panel.currentFolderRadio,e=this.folderRadioGroup.panel.allFoldersRadio;d.boxLabel=_("Current folder")+" ("+a.getDefaultFolder().getDisplayName()+")";d.rendered&&d.wrap.child(".x-form-cb-label").update(d.boxLabel);if(Ext.isDefined(c)&&(c.isSharedStore()||c.isPublicStore())){e.disable();d.suspendEvents();d.setValue(true);d.resumeEvents()}else e.enable();
c=this.folderRadioGroup.getValue();c.inputValue==="current_folder"&&this.setFolder(c)},onAfterRenderFolderRadioGroup:function(a){this.setFolder(a.getValue())},setFolder:function(a){var b=this.model.getDefaultFolder();if(a.inputValue==="all_folders")this.folder=b.getMAPIStore().getSubtreeFolder();else if(a.inputValue==="current_folder")this.folder=b},getFolder:function(){return this.folder},onRadioCheck:function(a,b){if(b){this.setFolder(a);this.afterUpdateRestriction()}},createRestriction:function(a){if(Ext.isEmpty(a))return[];
var b=[],c=[],d=[],e=[],f=[],g=[];Ext.iterate(this.searchCriteria,function(h,k){h==="search_fields"&&Ext.each(k,function(j){e.push(Zarafa.core.data.RestrictionFactory.dataResContent(j,Zarafa.core.mapi.Restrictions.FL_SUBSTRING|Zarafa.core.mapi.Restrictions.FL_IGNORECASE,a))},this);h==="extra_fields"&&Ext.each(k,function(j){j==="hasattach"&&g.push(Zarafa.core.data.RestrictionFactory.dataResProperty(j,Zarafa.core.mapi.Restrictions.RELOP_EQ,true));j==="message_flags"&&g.push(Zarafa.core.data.RestrictionFactory.dataResBitmask(j,
Zarafa.core.mapi.Restrictions.BMR_EQZ,Zarafa.core.mapi.MessageFlags.MSGFLAG_READ))});if(h==="date_range")if(k.start!==0&&k.end!==0){d.push(Zarafa.core.data.RestrictionFactory.dataResProperty("last_modification_time",Zarafa.core.mapi.Restrictions.RELOP_GE,k.start));d.push(Zarafa.core.data.RestrictionFactory.dataResProperty("last_modification_time",Zarafa.core.mapi.Restrictions.RELOP_LT,k.end))}h==="message_class"&&!Ext.isEmpty(k)&&Ext.each(k,function(j){f.push(Zarafa.core.data.RestrictionFactory.dataResContent(h,
Zarafa.core.mapi.Restrictions.FL_PREFIX|Zarafa.core.mapi.Restrictions.FL_IGNORECASE,j))},this)},this);if(Ext.isEmpty(d))c.push(Zarafa.core.data.RestrictionFactory.createResOr(e));else{var i=[];i.push(Zarafa.core.data.RestrictionFactory.createResAnd(d));i.push(Zarafa.core.data.RestrictionFactory.createResOr(e));c.push(Zarafa.core.data.RestrictionFactory.createResAnd(i))}c.push(Zarafa.core.data.RestrictionFactory.createResOr(f));Ext.isEmpty(g)||c.push(Zarafa.core.data.RestrictionFactory.createResAnd(g));
Ext.isEmpty(c)||(b=Zarafa.core.data.RestrictionFactory.createResAnd(c));return b}});Ext.reg("zarafa.searchtoolboxpanel",Zarafa.advancesearch.dialogs.SearchToolBoxPanel);Ext.namespace("Zarafa.advancesearch.dialogs");
Zarafa.advancesearch.dialogs.SearchToolbarPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.searchContext))a.model=a.searchContext.getModel();Ext.applyIf(a,{xtype:"zarafa.searchtoolbarpanel",layout:"hbox",ref:"searchToolbar",border:false,plugins:[{ptype:"zarafa.recordcomponentplugin",enableOpenLoadTask:true,autoOpenLoadTaskDefer:250},{ptype:"zarafa.recordcomponentupdaterplugin"}],height:38,items:[{xtype:"zarafa.searchpaneltoolbar",style:"border-style : none",
searchText:a.searchText,context:a.searchContext},{xtype:"zarafa.toolbar",style:"border-style : none; padding : 0px",cls:"zarafa-previewpanel-toolbar zarafa-context-mainpanel",ref:"rightSearchToolbar",hidden:true,items:[{xtype:"tbfill"},{xtype:"button",tooltip:_("Reply")+" (Ctrl + R)",overflowText:_("Reply"),iconCls:"icon_replyEmail",ref:"replyBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLY,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Reply All")+" (Ctrl + Alt + R)",overflowText:_("Reply All"),
iconCls:"icon_replyAllEmail",ref:"replyAllBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLYALL,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Forward")+" (Ctrl + F)",overflowText:_("Forward"),iconCls:"icon_forwardEmail",ref:"forwardBtn",responseMode:Zarafa.mail.data.ActionTypes.FORWARD,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Edit as New Message")+" (Ctrl + E)",overflowText:_("Edit as New Message"),iconCls:"icon_editAsNewEmail",ref:"editAsNewBtn",responseMode:Zarafa.mail.data.ActionTypes.EDIT_AS_NEW,
handler:this.onResponse,scope:this},container.populateInsertionPoint("previewpanel.toolbar.right",{scope:this,model:a.model})]}]});Zarafa.advancesearch.dialogs.SearchToolbarPanel.superclass.constructor.call(this,a)},getAdvanceSearchField:function(){return this.contextMainPanelToolbar.searchTextfield},update:function(a){this.record=a},getRightSearchToolbar:function(){return this.rightSearchToolbar},onResponse:function(a){var b=container.getContextByName("mail").getModel();Zarafa.mail.Actions.openCreateMailResponseContent(this.record,
b,a.responseMode)}});Ext.reg("zarafa.searchtoolbarpanel",Zarafa.advancesearch.dialogs.SearchToolbarPanel);Ext.namespace("Zarafa.advancesearch.ui");Zarafa.advancesearch.ui.AdvanceSearchRowSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,{handleMouseDown:function(a,b,c){var d=false;if(c.target.className.indexOf("icon")!==-1)d=true;d!==true&&Zarafa.advancesearch.ui.AdvanceSearchRowSelectionModel.superclass.handleMouseDown.call(this,a,b,c)}});Ext.reg("zarafa.advancesearchrowselectionmodel",Zarafa.advancesearch.ui.AdvanceSearchRowSelectionModel);
Ext.namespace("Zarafa.calendar");
Zarafa.calendar.Actions={openAppointmentContent:function(a,b){Ext.each(a,function(c){Ext.isDefined(c.isRecurringOccurence)&&c.isRecurringOccurence()?Zarafa.common.Actions.openRecurringSelectionContent(c,function(d,e){if(d=="ok"){c=e.id!=="recurrence_series"?c.convertToOccurenceRecord():c.convertToSeriesRecord();Zarafa.core.data.UIFactory.openViewRecord(c,b)}}):Zarafa.core.data.UIFactory.openViewRecord(c,b)},this)},openCreateAppointmentContent:function(a,b){var c=a.createRecord();Zarafa.core.data.UIFactory.openCreateRecord(c,
b)},openMeetingRequestContent:function(a,b){Zarafa.calendar.Actions.openAppointmentContent(a,b)},openCreateMeetingRequestContent:function(a,b){var c=a.createRecord();c.convertToMeeting();Zarafa.core.data.UIFactory.openCreateRecord(c,b)},openAppointmentContentToAcceptProposal:function(a,b){if(Ext.isArray(a))a=a[0];var c=a.convertToAppointmentRecord(false);if(Ext.isDefined(c)){b=Ext.applyIf(b||{},{useShadowStore:true,activeTab:0,newAppointmentProps:{startdate:a.get("proposed_start_date"),duedate:a.get("proposed_end_date"),
commonstart:a.get("proposed_start_date"),commonend:a.get("proposed_end_date"),duration:a.get("proposed_duration"),counter_proposal:false}});Zarafa.core.data.UIFactory.openCreateRecord(c,b)}else container.getNotifier().notify("error.proposal",_("Error"),_("Could not accept proposal as this meeting is not available in calendar; It may have been moved or deleted."))},openAppointmentContentToViewAllProposals:function(a,b){if(Ext.isArray(a))a=a[0];var c=a.convertToAppointmentRecord();if(Ext.isDefined(c)){b=
Ext.applyIf(b||{},{useShadowStore:true,activeTab:1});Zarafa.core.data.UIFactory.openCreateRecord(c,b)}else container.getNotifier().notify("error.proposal",_("Error"),_("Could not view proposal as this meeting is not available in calendar; It may have been moved or deleted."))},openProposeNewTimeContent:function(a,b){b=Ext.applyIf(b||{},{autoSave:false,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.proposenewtimecontentpanel"],a,b)},
openRecipientSelectionContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];var c=a.copy(),d=c.getSubStore("recipients");Zarafa.common.Actions.openABUserMultiSelectionContent({callback:function(){a.applyData(c)},convert:function(e,f){return e.convertToRecipient(f?f.defaultRecipientType:b.defaultRecipientType)},store:d,selectionCfg:[{xtype:"zarafa.recipientfield",fieldLabel:_("Required")+":",height:50,boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,
flex:1},{xtype:"zarafa.recipientfield",fieldLabel:_("Optional")+":",height:50,boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,flex:1},{xtype:"zarafa.recipientfield",fieldLabel:_("Resource")+":",height:50,boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,flex:1}]})},openSendConfirmationContent:function(a,b){b=Ext.applyIf(b||{},{record:a,
modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestconfirmation"],a,b)},openSendCancellationContent:function(a,b){b=Ext.applyIf(b||{},{record:a,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestcancellation"],a,b)},showMeetingInCalendar:function(a){var b,c,d=a.get("appointment_store_entryid");if(d)b=container.getHierarchyStore().getById(d);
if(!b){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)){container.getNotifier().notify("error",_("Error"),_("Could not open store."));return}}if(d=a.get("appointment_parent_entryid"))c=b.getFolder(d);if(!c){c=b.getDefaultFolder("calendar");if(!Ext.isDefined(c)){container.getNotifier().notify("error",_("Error"),_("Could not open default calendar folder."));
return}}d=container.getContextByFolder(c);b=d.getModel();container.switchContext(d,c,true);d.switchView(Zarafa.calendar.data.Views.BLOCKS,Zarafa.calendar.data.ViewModes.DAYS);a=a.get("appointment_startdate")||a.get("appointment_basedate");b.setDataMode(Zarafa.calendar.data.DataModes.DAY);b.setDate(a);b.resumeLoading()}};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.data");
Zarafa.calendar.data.SearchFields=[{name:_("All text fields"),value:"subject sender_name sender_email_address sent_representing_name sent_representing_email_address body display_to display_cc location"},{name:_("Subject"),value:"subject"},{name:_("Sender"),value:"sender_name sender_email_address sent_representing_name sent_representing_email_address"},{name:_("Body"),value:"body"},{name:_("Subject or Sender"),value:"subject sender_name sender_email_address sent_representing_name sent_representing_email_address"},
{name:_("To or cc"),value:"display_to display_cc"},{name:_("Location"),value:"location"}];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,layoutOnTabChange:true,
plugins:["zarafa.recordcomponentupdaterplugin"],update:this.onTabPanelUpdate.createDelegate(this),listeners:{render:this.onTabPanelRender,tabchange:this.onTabPanelChange,scope:this},items:[{xtype:"zarafa.appointmenttab",title:_("Appointment"),ref:"../appointmentTab"},{xtype:"zarafa.freebusytab",title:_("Scheduling"),ref:"../schedulingTab"},{xtype:"zarafa.trackingtab",title:_("Tracking"),ref:"../trackingTab"},container.populateInsertionPoint("context.calendar.appointmentcontentpanel.tabs",this)]}]},
onTabPanelUpdate:function(a,b){if(!b&&a.isModifiedSinceLastUpdate("meeting")&&a.get("meeting")==Zarafa.core.mapi.MeetingStatus.NONMEETING)if(this.tabPanel.activeTab==this.schedulingTab||this.tabPanel.activeTab==this.trackingTab)this.tabPanel.setActiveTab(this.appointmentTab);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."),{container:this.getEl(),persistent:true});
this.enableNotifier=false}}}}},onRecipientsChange:function(){this.enableNotifier=true}});Ext.reg("zarafa.appointmentpanel",Zarafa.calendar.dialogs.AppointmentPanel);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}"),proposeNewTimeDelegateInfoString:pgettext("calendar.dialog","{0} proposed a new time for this meeting on {1}"),
acceptedInfoString:pgettext("calendar.dialog","Accepted on {0}"),acceptedDelegateInfoString:pgettext("calendar.dialog","Accepted by {0} on {1}"),tentativeInfoString:pgettext("calendar.dialog","Tentatively Accepted on {0}"),tentativeDelegateInfoString:pgettext("calendar.dialog","Tentatively Accepted by {0} on {1}"),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."),meetingOverwrittenString:pgettext("calendar.dialog","Please note that any changes you make will be overwritten when this meeting request is updated by the organizer"),hasUserSetLocation:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");
Ext.applyIf(a,{xtype:"zarafa.appointmenttab",cls:"zarafa-appointmentcreatetab",layout:{type:"vbox",align:"stretch"},border:false,labelPad:0,items:[this.createExtraInfoPanel(),this.createMeetingOrganizerPanel(),this.createRecipientPanel(),this.createSubjectPanel(),this.createLocationPanel(),this.createDateTimePanel(),this.createAttachmentsPanel(),this.createBodyPanel()]});Zarafa.calendar.dialogs.AppointmentTab.superclass.constructor.call(this,a)},createExtraInfoPanel:function(){return{xtype:"container",
cls:"zarafa-calendar-appointment-extrainfo",ref:"extraInfoPanel",autoHeight:true,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:"zarafa.resizablecompositefield",cls:"field-to",ref:"recipientPanel",anchor:"100%",autoHeight:false,items:[{xtype:"button",
autoHeight:true,text:_("To")+":",handler:this.showRecipientContent,scope:this},{xtype:"zarafa.recipientfield",plugins:["zarafa.recordcomponentupdaterplugin"],flex:1}]}},createSubjectPanel:function(){return{xtype:"panel",cls:"subject-panel",layout:"form",labelWidth:84,labelAlign:"left",autoHeight:true,border:false,items:[{xtype:"textfield",name:"subject",fieldLabel:_("Subject"),anchor:"100%",listeners:{change:this.onFieldChange,scope:this}}]}},createLocationPanel:function(){return{xtype:"panel",cls:"location-panel",
layout:"form",labelWidth:84,labelAlign:"left",autoHeight:true,border:false,items:[{xtype:"textfield",name:"location",fieldLabel:_("Location"),anchor:"100%",enableKeyEvents:true,listeners:{change:this.onFieldChange,keypress:this.onLocationKeyPress,scope:this}}]}},createDateTimePanel:function(){return{xtype:"panel",cls:"datetime-panel",border:false,autoHeight:true,layout:{type:"table",columns:2},items:[{xtype:"panel",border:false,items:[this.createDatePanel(),this.createRecurrencePanel()]},this.createBusyStatusPanel(),
this.createReminderPanel(),this.createLabelPanel()]}},createDatePanel:function(){return{xtype:"panel",cls:"date-panel",layout:{type:"table",columns:3},ref:"../../datePanel",autoHeight:true,autoWidth:true,border:false,items:[{xtype:"zarafa.datetimeperiodfield",ref:"../../../datetimePeriod",defaultPeriod:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period"),defaultPeriodType:Date.MINUTE,timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),
width:585,allowEqualValue:true,layout:"hbox",listeners:{change:this.onDateRangeFieldChange,scope:this},startFieldConfig:{fieldLabel:_("Time"),labelWidth:83,cls:"from-field"},endFieldConfig:{fieldLabel:_("until"),labelWidth:84,cls:"to-field"}},{xtype:"spacer",width:10},{xtype:"panel",border:false,items:[{xtype:"checkbox",name:"alldayevent",boxLabel:_("All Day Event"),handler:this.onToggleAllDay,scope:this}]}]}},createRecurrencePanel:function(){return{xtype:"panel",cls:"recurrence-panel",ref:"../../recurrencePanel",
layout:"form",autoHeight:true,border:false,items:[{xtype:"displayfield",ref:"../../../recurrencePatternField",fieldLabel:_("Recurrence"),htmlEncode:true}]}},createReminderPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.ReminderPeriods};return{xtype:"panel",cls:"reminder-panel",autoHeight:true,border:false,items:[{xtype:"zarafa.compositefield",autoHeight:true,items:[{xtype:"checkbox",name:"reminder",boxLabel:_("Reminder")+":",width:78,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,swidth:150,listeners:{select:this.onFieldSelect,scope:this}}]}]}},createBusyStatusPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.BusyStatus};return{xtype:"panel",cls:"busystatus-panel",layout:"form",autoHeight:true,border:false,labelAlign:"left",
items:[{xtype:"combo",ref:"../../comboBusyStatus",name:"busystatus",fieldLabel:_("Busy Status"),store:a,mode:"local",triggerAction:"all",displayField:"name",valueField:"value",lazyInit:false,forceSelection:true,editable:false,listeners:{select:this.onFieldSelect,scope:this}}]}},createLabelPanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.calendar.data.AppointmentLabels};return{xtype:"panel",cls:"label-panel",layout:"form",autoHeight:true,border:false,labelAlign:"left",
items:[{xtype:"combo",name:"label",fieldLabel:_("Label"),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}}]}},createAttachmentsPanel:function(){return{xtype:"zarafa.resizablecompositefield",hideLabel:true,anchor:"100%",cls:"zarafa-appointmentcreatepanel-field-attachments",autoHeight:true,items:[{xtype:"button",ref:"../occurenceAttachmentsButton",text:_("Attachments")+":",width:100,handler:function(){Ext.MessageBox.show({title:_("Warning"),msg:_("Attachments cannot be modified for a single occurence"),buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING})}},{xtype:"zarafa.attachmentbutton",ref:"../normalAttachmentsButton",
plugins:["zarafa.recordcomponentupdaterplugin"],text:_("Attachments")+":",autoHeight:true,width:100},{xtype:"spacer",width:5},{xtype:"zarafa.attachmentfield",plugins:["zarafa.recordcomponentupdaterplugin"],ref:"../attachField",flex:1,hideLabel:true}]}},createBodyPanel:function(){return{xtype:"panel",cls:"body-panel",layout:"fit",border:false,flex:1,autoHeight:false,items:[{xtype:"zarafa.editorfield",ref:"../editorField",hideLabel:true,flex:1,useHtml:false,listeners:{afterlayout:function(){this.editorField.getEditor().getEl().set({placeholder:_("Type your message here...")})},
change:this.onBodyChange,scope:this}}]}},onLocationKeyPress:function(){this.hasUserSetLocation=true},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"))if(a.get("alldayevent")){this.datetimePeriod.setEnabledTimeSelection(false);
this.datetimePeriod.defaultPeriod=1;this.datetimePeriod.defaultPeriodType=Date.DAY}else{this.datetimePeriod.setEnabledTimeSelection(true);this.datetimePeriod.defaultPeriod=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period");this.datetimePeriod.defaultPeriodType=Date.MINUTE}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){if(a.isRecurringOccurence()){this.occurenceAttachmentsButton.setVisible(true);this.normalAttachmentsButton.setVisible(false);this.attachField.setEditable(false)}else{this.occurenceAttachmentsButton.setVisible(false);this.normalAttachmentsButton.setVisible(true);
this.attachField.setEditable(true)}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")){c.clearTime();e.setHours(12);e=e.add(Date.DAY,-1).clearTime()}if(d||f)this.datetimePeriod.getValue().set(c,e);b&&a.isOpened()&&this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()));
this.updateExtraInfoPanel();if(b===true||a.isModifiedSinceLastUpdate("recurring_pattern"))this.recurrencePatternField.setValue(a.get("recurring_pattern"));if(a.get("reminder")===true)if(!a.get("flagdueby")||a.isModifiedSinceLastUpdate("reminder_minutes")||a.isModifiedSinceLastUpdate("startdate")){var g;if(a.isRecurring()||a.isRecurringOccurence())g=a.get("startdate_recurring");g||(g=a.get("startdate"));if(Ext.isDate(g)){a.set("reminder_time",g.clone());a.set("flagdueby",g.add(Date.MINUTE,-a.get("reminder_minutes")))}}if(a.isOpened()&&
a.isSubStoreModifiedSincelastUpdate("recipients"))if((c=a.updateSubStoreModifications.recipients)&&c.changes){c=c.changes;d=false;for(e=0;e<c.length;e++)if(c[e].get("display_type_ex")===Zarafa.core.mapi.DisplayTypeEx.DT_ROOM){d=true;break}d&&this.updateLocation()}},updateLocation:function(){var a=[];this.record.getSubStore("recipients").each(function(d){if(d.get("display_type_ex")===Zarafa.core.mapi.DisplayTypeEx.DT_ROOM){d=d.get("display_name");Ext.isEmpty(d)||a.push(d)}});var b=a.join("; "),c=this.record.get("location");
if(c!=b)this.hasUserSetLocation===false||Ext.isEmpty(c)||c.toUpperCase()==b.toUpperCase()?this.doSetLocation(b):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(c),Ext.util.Format.htmlEncode(b)),buttons:Ext.Msg.YESNO,icon:Ext.MessageBox.WARNING,fn:this.setLocation,locationSuggestion:b,scope:this})},setLocation:function(a,b,c){a=="yes"&&this.doSetLocation(c.locationSuggestion)},doSetLocation:function(a){this.record.set("location",
a);this.hasUserSetLocation=false},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);this.updateStartDueDate(a,this.datetimePeriod.getValue());if(a.get("reminder")===true)if(!a.get("flagdueby")||a.isModifiedSinceLastUpdate("reminder_minutes")||a.isModifiedSinceLastUpdate("startdate")){var b;if(a.isRecurring()||a.isRecurringOccurence())b=a.get("startdate_recurring");b||(b=a.get("startdate"));if(Ext.isDate(b)){a.set("reminder_time",b.clone());a.set("flagdueby",b.add(Date.MINUTE,-a.get("reminder_minutes")))}}this.onBodyChange(this.editorField.getEditor(),
this.editorField.getValue());a.endEdit()},onFieldChange:function(a,b){this.record.set(a.getName(),b)},onBodyChange:function(a,b){var c=this.record,d=a instanceof Ext.form.HtmlEditor;c.beginEdit();c.setBody(b,d);c.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.setHours(12);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()}},showRecipientContent:function(){Zarafa.calendar.Actions.openRecipientSelectionContent(this.record,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO})},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");if(c!==Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE){this.setOrganizerInfo();b=this.setMeetingOverwrittenInfo(a)===true?true:
b}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("reply_name"),f=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=Ext.isEmpty(e)?String.format(this.proposeNewTimeInfoString,d):String.format(this.proposeNewTimeDelegateInfoString,e,d);else switch(a){case Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED:c=Ext.isEmpty(e)?String.format(this.acceptedInfoString,d):String.format(this.acceptedDelegateInfoString,
e,d);break;case Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE:c=Ext.isEmpty(e)?String.format(this.tentativeInfoString,d):String.format(this.tentativeDelegateInfoString,e,d);break}}else if(Ext.isDate(f)&&f.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(){this.meetingOrganizerField.setValue(this.record.getSenderString())},setMeetingCanceledInfo:function(a){a.createChild({tag:"div",html:this.meetingCanceledString});return true},setMeetingUnsentInfo:function(a){a.createChild({tag:"div",html:this.meetingUnsentString});return true},setMeetingOverwrittenInfo:function(a){a.createChild({tag:"div",html:this.meetingOverwrittenString});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.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.on("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 i=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:i};d.proposals.push(g)}else if(g.get("proposednewtime")===true){i=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:i};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();var c=b[0].get("startdate");b=b[0].get("duedate");this.record.set("startdate",c);this.record.set("duedate",b);this.record.set("commonstart",c);this.record.set("commonend",b);this.record.set("duration",(b-c)/6E4);this.record.set("counter_proposal",a.isSelected(0));this.record.endEdit()}}});Ext.reg("zarafa.counterproposalgrid",Zarafa.calendar.dialogs.CounterProposalGrid);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.on("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",cls:"zarafa-freebusy-panel",ref:"freebusyPanel",flex:1,modelConfig:{listeners:{selectorrangeupdate:this.onSelectorRangeUpdate,scope:this}},items:[this.createOptionsPanel()]}},createOptionsPanel:function(){return{xtype:"panel",region:"north",layout:"column",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"),defaultPeriodType:Date.MINUTE,timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),allowEqualValue:true,layout:"hbox",listeners:{change:this.onDateRangeFieldChange,afterrender:this.onDateRangeFieldAfterRender,scope:this},startFieldConfig:{fieldLabel:_("Time"),labelConfig:{cls:"label-startfield"}},endFieldConfig:{fieldLabel:_("until")},
spacerConfig:{width:10}},{xtype:"checkbox",ref:"../../workingHoursCheckbox",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(){this.record&&
!this.record.isMeeting()&&this.record.get("responsestatus")===Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE&&this.record.convertToMeeting();this.freebusyPanel.scrollTimelineToSelection()},updateUI:function(a,b){if(b===true||a.isModifiedSinceLastUpdate("alldayevent"))if(a.get("alldayevent")){this.datetimePeriod.setEnabledTimeSelection(false);this.datetimePeriod.defaultPeriod=1;this.datetimePeriod.defaultPeriodType=Date.DAY}else{this.datetimePeriod.setEnabledTimeSelection(true);this.datetimePeriod.defaultPeriod=
container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period");this.datetimePeriod.defaultPeriodType=Date.MINUTE}},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")){c.clearTime();e.setHours(12);e=e.add(Date.DAY,
-1).clearTime()}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.updateRecurringInfo(this.record,a);this.updateStartDueDate(this.record,a);this.record.endEdit()},updateRecurringInfo:function(a,b){var c=b.getStartDate().clone();if(a.get("alldayevent")===true)c=c.clearTime();if(a.isRecurring()&&a.isMeeting()){a.updateTimezoneInformation();var d=c.getHours()*60+c.getMinutes(),e=d+b.getDuration(Date.MINUTE);a.beginEdit();a.set("recurring_reset",true);a.set("recurrence_startocc",
d);a.set("recurrence_endocc",e);a.set("recurrence_start",c.clearTime(true).fromUTC());a.set("recurring_pattern",a.generateRecurringPattern());a.endEdit()}},onDateRangeFieldChange:function(a,b){this.updateRecurringInfo(this.record,b);this.updateStartDueDate(this.record,b)},onDateRangeFieldAfterRender:function(a){a.setWidth(550)},updateStartDueDate:function(a,b){var c=b.getStartDate().clone(),d=b.getDueDate().clone();if(a.get("alldayevent")===true){c=c.clearTime();d.setHours(12);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.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,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.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,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.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.ui");
Zarafa.calendar.ui.AppointmentPreviewPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.appointmentpreviewpanel",border:false,bodyCfg:{cls:"preview-body"},layout:"fit",items:[{xtype:"zarafa.appointmentbody"}]});Zarafa.calendar.ui.AppointmentPreviewPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.appointmentpreviewpanel",Zarafa.calendar.ui.AppointmentPreviewPanel);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.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}}]});Zarafa.calendar.ui.CalendarBlockPanel.superclass.constructor.call(this,a);this.mon(this.selectionModel,"selectionchange",this.onSelectionChange,this);(a=a.model.getStore())&&this.mon(a,
"remove",this.onStoreRemove,this)},onStoreRemove:function(a,b){this.selectionModel.deselectRecord(b)},getCalendarPanel:function(){return this.calendarPanel},onContextMenu:function(a,b){Zarafa.core.data.UIFactory.openDefaultContextMenu(b,{position:a.getXY()})},onDblClick:function(a,b){Zarafa.calendar.Actions.openAppointmentContent(b)},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.CalendarPanel=Ext.extend(Ext.Panel,{context:undefined,model:undefined,store:undefined,loadMaskText:_("Loading")+"...",selectionModel:undefined,rangeSelectionModel:undefined,viewConfig:undefined,view:undefined,showTooltip:true,tooltipTitleTpl:new Ext.XTemplate('<tpl if="!Ext.isEmpty(values.subject)">',"{values.subject:htmlEncode}","</tpl>",{compiled:true}),tooltipTextTpl:new Ext.XTemplate('<tpl if="values.meeting !== Zarafa.core.mapi.MeetingStatus.NONMEETING && !Ext.isEmpty(this.formatOrganizer(values))">',
_("Organizer")+": {[this.formatOrganizer(values)]}\n","</tpl>",'<tpl if="values.alldayevent != true">',_("Time")+": {[this.formatTime(values.startdate, values.duedate)]}\n","</tpl>",'<tpl if="values.alldayevent == true">',_("Date")+": {[this.formatDate(values.startdate, values.duedate)]}\n","</tpl>",'<tpl if="!Ext.isEmpty(values.location)">',_("Location")+": {values.location:htmlEncode}\n","</tpl>",'<tpl if="!Ext.isEmpty(values.recurring_pattern)">',_("Recurrence")+": {values.recurring_pattern:htmlEncode}\n",
"</tpl>",{compiled:true,formatOrganizer:function(a){var b=a.sent_representing_name;if(Ext.isEmpty(b))b=a.sender_name;return Ext.util.Format.htmlEncode(b)},formatTime:function(a,b){return a.clearTime(true).getTime()==b.clearTime(true).getTime()?a.format(_("G:i"))+" - "+b.format(_("G:i")):a.format(_("jS F G:i"))+" - "+b.format(_("jS F G:i"))},formatDate:function(a,b){b=b.add(Date.HOUR,-1);return Date.diff(Date.DAY,b,a)<=1?a.format(_("jS F Y")):a.format(_("jS F Y"))+" - "+b.format(_("jS F Y"))}}),constructor:function(a){a=
a||{};Ext.apply(this,a,{xtype:"zarafa.calendarpanel",border:false});this.addEvents("beforeappointmentcalendardrop","appointmentcalendardrop","appointmentmouseover","appointmentmouseout","beforeappointmentmove","beforeappointmentresize","beforeappointmentcreate","appointmentmove","appointmentresize","appointmentcreate","contextmenu","dblclick","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.store&&this.mon(this.store,"remove",this.onStoreRemove,this);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,appointmentmouseover:this.onAppointmentMouseOver,appointmentmouseout:this.onAppointmentMouseOut,appointmentmove:this.onAppointmentMove,appointmentresize:this.onAppointmentResize,appointmentcreate:this.onAppointmentCreate,
appointmentinitdrag:this.onAppointmentInitDrag,appointmentenddrag:this.onAppointmentEndDrag,contextmenu:this.onViewContextMenu,dblclick:this.onDoubleClick,dayclick:this.onDayClick,calendarclose:this.onCalendarClose,scope:this});this.store&&this.bindStore(this.store)},onStoreRemove:function(a,b){this.selectionModel.deselectRecord(b)},onViewContextMenu:function(a,b){this.fireEvent("contextmenu",a,b);a.stopEvent()},onDoubleClick:function(a,b){this.fireEvent("dblclick",a,b)},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){a=b.copy();this.doAppointmentChange(a,e);var g={};for(var i in a.modified)g[i]=a.get(i);b.addMessageAction("dropmodifications",g);f.ctrlKey?b.copyTo(d):b.moveTo(d);b.save();this.fireEvent("appointmentcalendardrop",this,b,c,d,e)}},onAppointmentMouseOver:function(a,b,c){if(this.showTooltip===true)if(a=this.view.getTooltipInstance()){var d=
b.store.data.getKey(b),e=this.tooltipTitleTpl.apply(b.data),f=this.tooltipTextTpl.apply(b.data);a.show(d,{title:e,text:f},c)}this.fireEvent("appointmentmouseover",this,b,c)},onAppointmentMouseOut:function(a,b,c){if(this.showTooltip===true)(a=this.view.getTooltipInstance())&&a.hide(c);this.fireEvent("appointmentmouseout",this,b,c)},onAppointmentMove:function(a,b,c){b.isMeetingSent()&&!b.isAppointmentInPast()&&b.getMessageAction("send")!==true?this.doAppointmentChangeConfirmation(b,c,this.doAppointmentMove):
this.doAppointmentMove(b,c)},doAppointmentMove:function(a,b){if(this.fireEvent("beforeappointmentmove",this,a,b)!==false){this.doAppointmentChange(a,b);a.isMeetingSent()&&!a.isAppointmentInPast()&&a.addMessageAction("send",true);a.save();this.fireEvent("appointmentmove",this,a,b)}},onAppointmentResize:function(a,b,c){b.isMeetingSent()&&!b.isAppointmentInPast()&&b.getMessageAction("send")!==true?this.doAppointmentChangeConfirmation(b,c,this.doAppointmentResize):this.doAppointmentResize(b,c)},doAppointmentResize:function(a,
b){if(this.fireEvent("beforeappointmentresize",this,a,b)!==false){this.doAppointmentChange(a,b);a.isMeetingSent()&&!a.isAppointmentInPast()&&a.addMessageAction("send",true);a.save();this.fireEvent("appointmentresize",this,a,b)}},doAppointmentChangeConfirmation:function(a,b,c){Zarafa.common.dialogs.MessageBox.select(_("Zarafa WebApp"),_("The time of the meeting has changed. Choose one of the following:"),function(d,e){if(d=="ok")if(e.id=="review_changes"){var f=[];f.push({fn:function(g,i,h,k){var j=
b.clone();if(i.isOpened()){this.doAppointmentChange(i,j);k()}else{var l=function(m,n){if(n===i){m.un("open",l,h);this.doAppointmentChange(i,j);k()}};i.getStore().on("open",l,this,{delay:1})}},scope:this});Zarafa.calendar.Actions.openMeetingRequestContent(a,{recordComponentPluginConfig:{loadTasks:f}})}else c.call(this,a,b)},this,[{boxLabel:_("Save changes and send an update to all recipients"),id:"send_update",name:"select",checked:true},{boxLabel:_("Open meeting request with changes"),id:"review_changes",
name:"select"}])},doAppointmentChange:function(a,b){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().getById(a.get("store_entryid")))&&a.setDelegatorInfo(c,
true);a.endEdit()},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)}},onAppointmentInitDrag:function(a){if(this.showTooltip===true)(a=a.getTooltipInstance())&&a.hide()},onAppointmentEndDrag:Ext.emptyFn,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();Zarafa.core.KeyMapMgr.activate(this,"view.mapimessage")},getView:function(){return this.view},getSelectionModel:function(){return this.selectionModel},getRangeSelectionModel:function(){return this.rangeSelectionModel},
bindStore:function(a){this.store=a;Ext.isDefined(a)&&this.mon(a,{beforeload:this.onBeforeLoad,load:this.onLoad,exception:this.onLoadException,notify:this.onStoreNotify,scope:this});this.view.bindStore(a)},releaseStore:function(a){Ext.isDefined(a)||this.mun(a,{beforeload:this.onBeforeLoad,load:this.onLoad,exception:this.onLoadException,notify:this.onStoreNotify,scope: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.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.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}},onBeforeDrag:function(a){var b=a.target;if(b&&b.getRecord().get("access")===0)return false;return Zarafa.calendar.ui.CalendarViewDragZone.superclass.onBeforeDrag.apply(this,arguments)},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;b&&this.calendar.onInitDrag(a.origEvent,b);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)},beforeDragOut:function(){return this.dragData.state!==Zarafa.calendar.data.DragStates.SELECTING},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){var c=a.target;this.calendar.onEndDrag(b,
c);this.calendar.onMouseUp(b,c)},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.DatePicker=Ext.extend(Ext.DatePicker,{store: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);this.on("destroy",this.store.destroy,this.store)},afterRender:function(){Zarafa.calendar.ui.DatePicker.superclass.afterRender.call(this);this.mon(this.store,"load",this.onLoad,this)},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,i=0,h=b.length;i<h;i++){var k=b[i],j=k.get("startdate").clearTime(true).getTime();if(f==j&&k.get("busystatus")!=Zarafa.core.mapi.BusyStatus.FREE){g=true;break}}g?e.addClass("x-date-busy"):e.removeClass("x-date-busy")}},onShow:function(){this.reloadStore(this.cells.first().dom.firstChild.dateValue,this.cells.last().dom.firstChild.dateValue);
Zarafa.calendar.ui.DatePicker.superclass.onShow.apply(this,arguments)},onHide:function(){this.store.cancelLoadRequests();Zarafa.calendar.ui.DatePicker.superclass.onHide.apply(this,arguments)},reloadStore:function(a,b){var c=container.getHierarchyStore().getDefaultFolder("calendar");if(c){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:c.get("entryid"),store_entryid:c.get("store_entryid"),
restriction:{startdate:a/1E3,duedate:b/1E3}}})}},update:function(a,b){Zarafa.calendar.ui.DatePicker.superclass.update.call(this,a,b);!this.hidden&&this.dateIsChanged(a)&&this.reloadStore(this.cells.first().dom.firstChild.dateValue,this.cells.last().dom.firstChild.dateValue)},dateIsChanged:function(a){a=a.getTime();return!this.monthStart||!this.monthEnd||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.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.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.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,i=false,h=false,k=false,j=a.isSubMessage(),l=a.senderIsReceiver(),m=a.get("appointment_not_found"),n=a.senderIsStoreOwner(),o=a.isMeetingReceived();if(a instanceof Zarafa.calendar.MeetingRequestRecord){c=b=a.isMeetingRequest();e=(d=a.isMeetingRequestResponse())&&
a.get("counter_proposal");f=a.get("appointment_recurring");i=a.get("meeting_updated");h=a.isMeetingRequestCanceled();k=a.isMeetingOutOfDate()}else{b=a.isMeeting();h=a.isMeetingCanceled();f=a.get("recurring");k=(g=a.hasIdProp("basedate"))&&a.get("duedate")<new Date}this.removeFromCalendarButton.setVisible(h&&!j&&!m);this.nonCurrentButton.setVisible(c&&!j&&k);this.noResponseButton.setVisible(c&&!j&&l&&!k);this.acceptButton.setVisible(b&&!j&&!l&&!k&&!h&&!n&&o);this.tentativeButton.setVisible(b&&!j&&
!l&&!k&&!h&&!n&&o);this.declineButton.setVisible(b&&!j&&!l&&!k&&!h&&!n&&o);this.proposeNewTimeButton.setVisible(b&&!j&&(!f||g)&&!l&&!k&&!h&&!n&&o);this.viewProposalsButton.setVisible(e&&!j&&!i&&!n);this.acceptProposalButton.setVisible(e&&!j&&!i&&!n);this.calendarButton.setVisible((c||d)&&!j&&!m);var p=false;this.items.each(function(q){if(q.hidden!==true){p=true;return false}});this.setVisible(p)}else this.setVisible(false)},getRemoveFromCalendarButton:function(){return{xtype:"button",ref:"removeFromCalendarButton",
text:_("Remove From Calendar"),tooltip:{title:_("Remove From Calendar"),text:_("Remove From Calendar")},cls:"tb-calendar-btn-remove",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")},cls:"tb-calendar-btn-not-current",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")},cls:"tb-calendar-btn-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_calendar_appt_accept",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED,
handler:this.openSendConfirmationContent,scope:this}},getTentativeButton:function(){return{xtype:"button",ref:"tentativeButton",text:_("Tentative"),tooltip:{title:_("Tentative"),text:_("Tentatively Accept Meeting Request")},iconCls:"icon_appt_meeting_tentative",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE,handler:this.openSendConfirmationContent,scope:this}},getDeclineButton:function(){return{xtype:"button",ref:"declineButton",text:_("Decline"),tooltip:{title:_("Decline"),text:_("Decline Meeting Request")},
iconCls:"icon_calendar_appt_cancelled",responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED,handler:this.openSendConfirmationContent,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_calendar_appt_newtime",handler:this.openProposeNewTimeContent,scope:this}},getViewAllProposalsButton:function(){return{xtype:"button",
ref:"viewProposalsButton",text:_("View All Proposals"),tooltip:{title:_("View All Proposals"),text:_("View All Proposals")},iconCls:"icon_calendar_appt_proposals",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_calendar_appt_accept",handler:this.acceptProposal,scope:this}},getCalendarButton:function(){return{xtype:"button",
ref:"calendarButton",text:_("Calendar"),tooltip:{title:_("Calendar"),text:_("Calendar")},cls:"tb-calendar-btn-calendar",iconCls:"icon_calendar",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)},openProposeNewTimeContent:function(){this.record.get("appointment_not_found")?
Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This appointment has been moved or deleted, do you want to continue?"),icon:Ext.MessageBox.WARNING,record:this.record,fn:this.onProposeNewTimeAppointmentNotFoundConfirmation,scope:this,buttons:Ext.MessageBox.YESNO}):Zarafa.calendar.Actions.openProposeNewTimeContent(this.record)},onProposeNewTimeAppointmentNotFoundConfirmation:function(a){a==="yes"&&Zarafa.calendar.Actions.openProposeNewTimeContent(this.record)},openSendConfirmationContent:function(a){this.record.get("appointment_not_found")?
Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This appointment has been moved or deleted, do you want to continue?"),icon:Ext.MessageBox.WARNING,record:this.record,fn:this.onRespondAppointmentNotFoundConfirmation.createDelegate(this,[a.responseStatus],1),scope:this,buttons:Ext.MessageBox.YESNO}):Zarafa.calendar.Actions.openSendConfirmationContent(this.record,{responseType:a.responseStatus})},onRespondAppointmentNotFoundConfirmation:function(a,b){a==="yes"&&Zarafa.calendar.Actions.openSendConfirmationContent(this.record,
{responseType:b})},acceptProposal:function(){Zarafa.calendar.Actions.openAppointmentContentToAcceptProposal(this.record)},showMeetingInCalendar:function(){Zarafa.calendar.Actions.showMeetingInCalendar(this.record)},viewAllProposals:function(){Zarafa.calendar.Actions.openAppointmentContentToViewAllProposals(this.record)}});Ext.reg("zarafa.meetingrequestbuttons",Zarafa.calendar.ui.MeetingRequestButtons);Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.ToolTip=Ext.extend(Ext.util.Observable,{el:undefined,stylingEl:undefined,cancelFx:false,targetId:undefined,container:undefined,tipCls:"zarafa-canvas zarafa-canvas-quicktip",lineHeight:12,lineWidth:1,radius:3,borderWidth:1,width:250,height:100,margins:10,titleMargins:5,backgroundColor:"#dfdfdf",backgroundOpacity:0.7,borderColor:"#b0b0b0",fontColor:"#111111",fontType:"8pt Arial",titleFontType:"bold 10pt Arial",enableShadow:true,shadowColor:"#ffffff",shadowSize:5,shadowOffset:1,
fadeOutOnHide:true,fadeOutTime:0.5,fadeOutTimeOnOver:3.5,hoverXOffset:10,hoverYOffset:10,constructor:function(a){a=a||{};this.addEvents("tooltipmousemove");Ext.apply(this,a);Zarafa.calendar.ui.canvas.ToolTip.superclass.constructor.call(this,a)},getTooltip:function(){if(this.el){this.cancelFx=true;this.el.stopFx();this.cancelFx=false}else{this.el=Ext.get(this.container).createChild({tag:"canvas",cls:this.tipCls});this.stylingEl=this.el.createChild({tag:"div",cls:"zarafa-styling-element"});this.stylingElTitle=
this.stylingEl.createChild({tag:"h2"});this.stylingElText=this.stylingEl.createChild({tag:"p"});this.stylingEl.styling={paddingLeft:this.stylingEl.getPadding("l"),paddingRight:this.stylingEl.getPadding("r"),paddingTop:this.stylingEl.getPadding("t"),paddingBottom:this.stylingEl.getPadding("b")};this.stylingElTitle.styling={font:this.stylingElTitle.getStyle("font-style")+" normal "+this.stylingElTitle.getStyle("font-weight")+" "+this.stylingElTitle.getStyle("font-size")+"/"+this.stylingElTitle.getStyle("line-height")+
" "+this.stylingElTitle.getStyle("font-family"),color:this.stylingElTitle.getStyle("color"),fontSize:parseInt(this.stylingElTitle.getStyle("font-size"),10),lineHeight:parseInt(this.stylingElTitle.getStyle("line-height"),10),marginBottom:this.stylingElTitle.getMargins("b")};this.stylingElText.styling={font:this.stylingElText.getStyle("font-style")+" normal "+this.stylingElText.getStyle("font-weight")+" "+this.stylingElText.getStyle("font-size")+"/"+this.stylingElText.getStyle("line-height")+" "+this.stylingElText.getStyle("font-family"),
color:this.stylingElText.getStyle("color"),fontSize:parseInt(this.stylingElText.getStyle("font-size"),10),lineHeight:parseInt(this.stylingElText.getStyle("line-height"),10),marginBottom:this.stylingElText.getMargins("b")}}this.el.hide();return this.el},show:function(a,b,c){var d=this.getTooltip();if(this.targetId!==a){this.targetId=a;d.on("mousemove",this.onTooltipMouseMove,this);d.on("click",this.onTooltipClick,this);a=d.dom.getContext("2d");var e=Ext.util.Format.htmlDecode(b.title);b=Ext.util.Format.htmlDecode(b.text);
this.height=this.stylingEl.styling.paddingTop+this.stylingEl.styling.paddingBottom;if(!Ext.isEmpty(e)){a.setFont(this.stylingElTitle.styling.font);this.height+=a.textHeight(e,this.width-this.stylingEl.styling.paddingLeft-this.stylingEl.styling.paddingRight,this.stylingElTitle.styling.lineHeight);this.height+=this.stylingElTitle.styling.marginBottom}if(!Ext.isEmpty(b)){a.setFont(this.stylingElText.styling.font);this.height+=a.textHeight(b,this.width-this.stylingEl.styling.paddingLeft-this.stylingEl.styling.paddingRight,
this.stylingElText.styling.lineHeight)}var f=Ext.apply({},this.container.getSize());f.x=this.container.getX();f.y=this.container.getY();c={x:c.getPageX()+this.hoverXOffset,y:c.getPageY()+this.hoverYOffset,height:this.height,width:this.width};c=Zarafa.core.Util.restrictBox(f,c);d.setStyle({position:"absolute",left:c.x-f.x+"px",top:c.y-f.y+"px"});Zarafa.resizeCanvas(d,this.width,this.height);a.clearRect(0,0,this.width,this.height);d.setWidth(this.width+parseInt(d.getStyle("border-left-width"),10)+parseInt(d.getStyle("border-right-width"),
10));d.setHeight(this.height+parseInt(d.getStyle("border-top-width"),10)+parseInt(d.getStyle("border-bottom-width"),10));a.save();a.lineWidth=this.lineWidth;f=a.createLinearGradient(0,0,this.width,0);c=Math.min(1,Math.max(0.1,(this.width-this.stylingEl.styling.paddingRight)/this.width));f.addColorStop(0,this.stylingElTitle.styling.color);f.addColorStop(c,this.stylingElTitle.styling.color);f.addColorStop(1,a.convertHexRgbToDecRgba(this.stylingElTitle.styling.color,0));a.fillStyle=f;f=this.stylingEl.styling.paddingTop;
if(Ext.isEmpty(e))f+=this.stylingElText.styling.lineHeight-parseInt((this.stylingElText.styling.lineHeight-this.stylingElText.styling.fontSize)/2,10);else{a.setFont(this.stylingElTitle.styling.font);f+=this.stylingElTitle.styling.lineHeight-parseInt((this.stylingElTitle.styling.lineHeight-this.stylingElTitle.styling.fontSize)/2,10);f+=a.drawWrappedText(e,this.stylingEl.styling.paddingLeft,f,this.width-this.stylingEl.styling.paddingLeft-this.stylingEl.styling.paddingRight,this.stylingElTitle.styling.lineHeight,
this.height-this.stylingEl.styling.paddingTop-this.stylingEl.styling.paddingBottom);f+=this.stylingElTitle.styling.marginBottom}e=a.createLinearGradient(0,0,this.width,0);c=Math.min(1,Math.max(0.1,(this.width-this.stylingEl.styling.paddingRight)/this.width));e.addColorStop(0,this.stylingElText.styling.color);e.addColorStop(c,this.stylingElText.styling.color);e.addColorStop(1,a.convertHexRgbToDecRgba(this.stylingElText.styling.color,0));a.fillStyle=this.stylingElText.styling.color;a.fillStyle=e;if(!Ext.isEmpty(b)){a.setFont(this.stylingElText.styling.font);
a.drawWrappedText(b,this.stylingEl.styling.paddingLeft,f,this.width-this.stylingEl.styling.paddingLeft-this.stylingEl.styling.paddingRight,this.stylingElText.styling.lineHeight,this.height-f+this.stylingElText.styling.lineHeight-this.stylingEl.styling.paddingBottom)}a.restore()}d.show()},hide:function(a){var b=this.el;this.fadeOutOnHide===true&&a?b.fadeOut({endOpacity:0,easing:"easeOut",duration:a.getTarget().id===b.id?this.fadeOutTimeOnOver:this.fadeOutTime,remove:false,callback:this.onHideComplete,
scope:this}):this.onHideComplete()},onHideComplete:function(){var a=this.el;if(this.cancelFx!==true){a.un("mousemove",this.onTooltipMouseMove,this);a.un("click",this.onTooltipClick,this);a.hide()}this.targetId=false},onTooltipMouseMove:function(a){this.fireEvent("tooltipmousemove",this,a)},onTooltipClick:function(){this.el.stopFx();this.hide()}});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.openContactContent(a,b);else a.isMessageClass("IPM.DistList",true)&&this.openDistlistContent(a,b)},openContactContent:function(a,b){if(Ext.isArray(a))for(var c=0,d=a.length;c<d;c++)Zarafa.contact.Actions.openContactContent(a[c],b);else Ext.isEmpty(a)||Zarafa.core.data.UIFactory.openCreateRecord(a,b)},openCreateContactContent:function(a,
b){var c=a.createRecord(undefined,false);Zarafa.contact.Actions.openContactContent(c,b)},openDistlistContent:function(a,b){if(Ext.isArray(a))for(var c=0,d=a.length;c<d;c++)Zarafa.contact.Actions.openDistlistContent(a[c],b);else Ext.isEmpty(a)||Zarafa.core.data.UIFactory.openCreateRecord(a,b)},openRecipientContactContent:function(a){var b=this.getModel().createRecord();a=a.getRecords();Zarafa.core.data.UIFactory.openCreateRecord(b);b.beginEdit();b.set("display_name",a.get("display_name"));b.set("email_address_1",
a.get("smtp_address"));b.set("email_address_type_1",a.get("address_type"));b.updateAddressbookProps();a=(new Zarafa.contact.data.ContactDetailsParser).parseNameInfo(a.get("display_name"));b.set("given_name",a.given_name);b.set("surname",a.surname);b.endEdit()},openCreateDistlistContent:function(a,b){var c=a.createRecord(undefined,true);Zarafa.contact.Actions.openDistlistContent(c,b)},openDetailedNameContent:function(a,b){if(!Ext.isEmpty(a)){var c=Zarafa.core.data.SharedComponentType["contact.dialog.contact.namedetails"];
b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,a,b)}},openDetailedAddressContent:function(a,b){if(!Ext.isEmpty(a)){var c=Zarafa.core.data.SharedComponentType["contact.dialog.contact.addressdetails"];b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,a,b)}},openDetailedPhoneContent:function(a,b){if(!Ext.isEmpty(a)){var c=Zarafa.core.data.SharedComponentType["contact.dialog.contact.phonedetails"];b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,
a,b)}},openMembersSelectionContent:function(a,b){if(Ext.isArray(a))for(var c=0,d=a.length;c<d;c++)Zarafa.contact.Actions.openMembersSelectionContent(a[c],b);else{var e=a.copy();c=e.getSubStore("members");Zarafa.common.Actions.openABUserMultiSelectionContent({callback:function(){a.applyData(e)},convert:function(f){return f.convertToDistlistMember()},store:c,selectionCfg:[{xtype:"zarafa.memberboxfield",fieldLabel:_("Members")+":",height:50,boxStore:c,flex:1}]})}},openDistlistExternalMemberContent:function(a,
b){var c=Zarafa.core.data.SharedComponentType["contact.dialog.distlist.externalmember"];b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,a,b)},openDistlistMember:function(a,b){if(a){var c;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:c=a.convertToContactRecord();break;case Zarafa.core.mapi.DistlistType.DL_USER_AB:case Zarafa.core.mapi.DistlistType.DL_DIST_AB:c=
a.convertToAddressBookRecord();break;case Zarafa.core.mapi.DistlistType.DL_EXTERNAL_MEMBER:default:Zarafa.contact.Actions.openDistlistExternalMemberContent(a,{parentRecord:b});break}if(c){container.getShadowStore().add(c);Zarafa.core.data.UIFactory.openViewRecord(c)}}}};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.data");
Zarafa.contact.data.SearchFields=[{name:_("All text fields"),value:"display_name display_name_prefix categories generation fileas company_name email_address_1 email_address_2 email_address_3 home_address other_address business_address home_telephone_number cellular_telephone_number business_telephone_number business_fax_number assistant_telephone_number business2_telephone_number callback_telephone_number car_telephone_number company_telephone_number home2_telephone_number home_fax_number other_telephone_number pager_telephone_number primary_fax_number primary_telephone_number radio_telephone_number telex_telephone_number ttytdd_telephone_number"},{name:_("Name"),
value:"display_name display_name_prefix generation"},{name:_("File as"),value:"fileas"},{name:_("Company"),value:"company_name"},{name:_("Email address"),value:"email_address_1 email_address_2 email_address_3"},{name:_("Phone number"),value:"home_telephone_number cellular_telephone_number business_telephone_number business_fax_number assistant_telephone_number business2_telephone_number callback_telephone_number car_telephone_number company_telephone_number home2_telephone_number home_fax_number other_telephone_number pager_telephone_number primary_fax_number primary_telephone_number radio_telephone_number telex_telephone_number ttytdd_telephone_number"},
{name:_("Address"),value:"home_address other_address business_address"}];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)){var b=true;if(Ext.isEmpty(this.parsedData)){var c=this.getForm().getValues();for(var d in c)if(!Ext.isEmpty(a.get(d))){this.parsedData=Ext.apply(this.parsedData||{},a.data);b=false;break}if(b&&!Ext.isEmpty(a.get(this.property))){a=this.parser.parseInfo("address",a.get(this.property));this.parsedData=Ext.apply(this.parsedData||{},a)}}b&&Ext.iterate(this.parsedData,function(e,f){this.parsedData[this.property+"_"+e]=f;delete this.parsedData[e]},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.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",cls:"zarafa-contactdetailtab",title:_("Details"),autoScroll:true,labelWidth:120,labelAlign:"left",defaults:{columnWidth:0.5,height:120,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.onNameChange}},{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.onNameChange}}]}},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"),ref:"../birthdayField",name:"birthday",format:"d/m/Y",listeners:{scope:this,change:this.onDateChange}},{xtype:"datefield",fieldLabel:_("Anniversary"),ref:"../anniversaryField",name:"wedding_anniversary",format:"d/m/Y",listeners:{scope:this,change:this.onDateChange}}]}},update:function(a){if(!Ext.isEmpty(a)){this.record=a;this.getForm().loadRecord(a)}},updateRecord:function(a){a.beginEdit();
var b=this.birthdayField.getValue(),c=a.get(this.birthdayField.getName());if(Ext.isDate(b)!==Ext.isDate(c)||Ext.isDate(b)&&b!==c)this.onDateChange(this.birthdayField,b,c);b=this.anniversaryField.getValue();c=a.get(this.anniversaryField.getName());if(Ext.isDate(b)!==Ext.isDate(c)||Ext.isDate(b)&&b!==c)this.onDateChange(this.anniversaryField,b,c);this.getForm().updateRecord(a);if(a.isModifiedSinceLastUpdate("display_name_prefix")||a.isModifiedSinceLastUpdate("given_name")||a.isModifiedSinceLastUpdate("middle_name")||
a.isModifiedSinceLastUpdate("surname")||a.isModifiedSinceLastUpdate("generation"))this.generateDisplayName();a.endEdit()},onFieldChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();this.record.set(a.getName(),b);this.record.endEdit()}},onNameChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();this.record.set(a.getName(),b);this.generateDisplayName();this.record.endEdit()}},onDateChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();
Ext.isEmpty(b)?this.record.set(a.getName(),null):this.record.set(a.getName(),b);a.getName()=="birthday"?this.record.set("birthday_eventid",this.record.get("birthday_eventid"),true):this.record.set("anniversary_eventid",this.record.get("anniversary_eventid"),true);this.record.set("subject",this.record.get("subject"),true);this.record.updateTimezoneInformation();this.record.endEdit()}},generateDisplayName:function(){var a=this.record,b={display_name_prefix:a.get("display_name_prefix"),given_name:a.get("given_name"),
middle_name:a.get("middle_name"),surname:a.get("surname"),generation:a.get("generation")};a.set("display_name",this.getContactParser().combineInfo("name",b))},getContactParser:function(){return this.dialog.contactParser}});Ext.reg("zarafa.contactdetailtab",Zarafa.contact.dialogs.ContactDetailTab);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)){var b=this.getForm().getValues();for(var c in b)if(!Ext.isEmpty(a.get(c))){this.parsedData=Ext.apply(this.parsedData||{},a.data);break}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.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.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"),layout:"fit",items:[{xtype:"zarafa.editorfield",useHtml:false,ref:"editorField",plaintextName:"body",listeners:{afterlayout:function(){this.editorField.getEditor().getEl().set({placeholder:_("Type your note here...")})},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.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.distlistcontentpanel.tabs",
this)]}]}});Ext.reg("zarafa.distlistpanel",Zarafa.contact.dialogs.DistlistPanel);Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.ui.ContactPhotoContextMenu=Ext.extend(Ext.menu.Menu,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactphotocontextmenu",items:[{text:_("Change Picture")+"...",iconCls:"icon_change_picture",handler:this.onChangePicture,scope:this},{text:_("Remove Picture"),iconCls:"icon_delete",handler:this.onRemovePicture,scope:this}]});Zarafa.contact.ui.ContactPhotoContextMenu.superclass.constructor.call(this,a)},onChangePicture:function(){this.parent.uploadContactPhoto()},onRemovePicture:function(){this.parent.clearContactPhoto(this.records.store,
this.records)}});Ext.reg("zarafa.contactphotocontextmenu",Zarafa.contact.ui.ContactPhotoContextMenu);Ext.namespace("Zarafa.contact.ui");Zarafa.contact.ui.ContactPreviewPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactpreviewpanel",border:false,bodyCfg:{cls:"preview-body"},layout:"fit",items:[{xtype:"zarafa.contactbody"}]});Zarafa.contact.ui.ContactPreviewPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.contactpreviewpanel",Zarafa.contact.ui.ContactPreviewPanel);
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)}},openCreateFolderContent:function(a,b){if(!Ext.isDefined(a)){a=container.getHierarchyStore().getDefaultFolder(container.getCurrentContext().getName());Ext.isDefined(a)||(a=container.getHierarchyStore().getDefaultFolder("inbox"))}var c=
Zarafa.core.data.RecordFactory.createRecordObjectByObjectType(Zarafa.core.mapi.ObjectType.MAPI_FOLDER,{parent_entryid:a.get("entryid"),store_entryid:a.get("store_entryid")});b=Ext.applyIf(b||{},{parentFolder:a,manager:Ext.WindowMgr});Zarafa.core.data.UIFactory.openCreateRecord(c,b)},openFolderPropertiesContent:function(a,b){var c=Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderproperties"];b=Ext.applyIf(b||{},{manager:Ext.WindowMgr});Zarafa.core.data.UIFactory.openLayerComponent(c,a,
b)},openFolderSizeContent:function(a,b){var c=Zarafa.core.data.SharedComponentType["hierarchy.dialog.foldersize"];b=Ext.applyIf(b||{},{manager:Ext.WindowMgr});Zarafa.core.data.UIFactory.openLayerComponent(c,a,b)},openSharedFolderContent:function(a,b){var c=Zarafa.core.data.SharedComponentType["hierarchy.dialog.opensharedfolder"];b=Ext.applyIf(b||{},{defaultSelectedFolderType:a,modal:true});Zarafa.core.data.UIFactory.openLayerComponent(c,undefined,b)},openFolderSelectionContent:function(a){var b=Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderselection"];
a=Ext.applyIf(a||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(b,undefined,a)}};Ext.namespace("Zarafa.hierarchy.data");
Zarafa.hierarchy.data.HierarchyTreeLoader=Ext.extend(Ext.tree.TreeLoader,{tree:undefined,store:undefined,nodeConfig:undefined,deferredLoading:false,deferredLoadingActiveParent:undefined,isDeferred:false,constructor:function(a){a=a||{};if(!a.directFn)a.directFn=this.directFn.createDelegate(this);Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.constructor.call(this,a);this.tree.rendered?this.onTreeAfterRender():this.tree.on("afterrender",this.onTreeAfterRender,this,{single:true})},onTreeAfterRender:function(){this.bindStore(this.store,
true);if(this.deferredLoading===true)if(this.isParentCardLayout(this.tree))this.deferredLoadingActiveParent=this.tree;else{this.deferredLoadingActiveParent=this.tree.findParentBy(this.isParentCardLayout,this);if(!this.deferredLoadingActiveParent)this.deferredLoading=false}},isParentCardLayout:function(a){return a.ownerCt&&a.ownerCt.layout&&a.ownerCt.layout.type==="card"},bindStore:function(a,b){if(!(b!==true&&this.store===a)){if(this.store){this.store.un("load",this.onHierarchyLoad,this);this.store.un("remove",
this.onHierarchyStoreRemove,this);this.store.un("addFolder",this.onHierarchyAddFolder,this);this.store.un("updateFolder",this.onHierarchyUpdateFolder,this);this.store.un("removeFolder",this.onHierarchyRemoveFolder,this)}(this.store=a)&&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){c.add!==true&&this.tree.getRootNode().removeAll(true);
a=this.deferredLoadingActiveParent;if(this.deferredLoading!==true||a===a.ownerCt.layout.activeItem)this.doHierarchyLoad();else{this.isDeferred=true;this.deferredLoadingActiveParent.on("activate",this.doHierarchyLoad,this,{single:true})}},doHierarchyLoad:function(){var a=this.tree.getRootNode();this.fireEvent("beforeload",this,a,this.directFn)!==false&&this.directFn(a.id,this.doHierarchyLoadCallback.createDelegate(this));this.isDeferred=false},doHierarchyLoadCallback:function(a,b){for(var c=this.tree.getRootNode(),
d=0,e=a.length;d<e;d++){var f=a[d],g=c.findChildByEntryId(f.folder.get("entryid"));if(g){if(g.attributes.folder!==f.folder){g.attributes.folder=f.folder;g.reload()}}else{f=this.createNode(f);c.appendChild(f)}}this.fireEvent("load",this,c,b)},onHierarchyStoreRemove:function(a,b){if(this.isDeferred!==true){var c=this.tree.getRootNode().findChildStoreByEntryId(b.get("store_entryid"));c&&c.remove(true)}},onHierarchyAddFolder:function(a,b,c){if(this.isDeferred!==true)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){if(this.isDeferred!==true){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){if(this.isDeferred!==true)(a=this.tree.getNodeById(c.get("entryid")))&&a.remove(true)},directFn:function(a,b){var c=this.tree.getNodeById(a),d=[];if(c.isRoot){for(var e=this.store.getRange(),f=0,g=e.length;f<g;f++){var i=e[f],h=i.getSubtreeFolder();if(h)if((!this.tree.hasFilter()||!i.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"))}b(d,{status:true})}else(function(k,j){d=this.getFilteredChildNodes(c.getFolder(),"folder");j(d,{status:true})}).defer(1,this,[a,b])},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 if(g.get("has_subfolder"))d=
d.concat(this.getFilteredChildNodes(g,b))}return d},getFilteredParentNode:function(a,b){var c=a.getParentFolder(),d=false;if(c)d=c===b?b:this.tree.nodeFilter(c)?this.tree.getNodeById(c.get("entryid")):this.getFilteredParentNode(c);return d},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)},destroy:function(){this.bindStore(null);Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.destroy.apply(this,arguments)}});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,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)},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"),cls:"form-field-name",ref:"../newNameField",listeners:{scope:this,specialkey:function(a,b){b.getKey()==b.ENTER&&this.onSubmit()}}},{xtype:"combo",fieldLabel:_("Folder contains"),cls:"form-field-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"),cls:"form-field-hierarchy",border:true,forceLayout:true,anchor:"100% 65%",
ref:"../hierarchyTree",treeSorter:true}]}},initEvents:function(){Zarafa.hierarchy.dialogs.CreateFolderPanel.superclass.initEvents.apply(this,arguments);this.parentFolder&&this.mon(this.hierarchyTree,"load",this.onTreeNodeLoad,this);this.mon(this.hierarchyTree.getSelectionModel(),"selectionchange",this.onHierarchyNodeSelect,this)},onTreeNodeLoad:function(){if(this.hierarchyTree.selectFolderInTree(this.parentFolder)){this.mun(this.hierarchyTree,"load",this.onTreeNodeLoad,this);this.newNameField.focus()}},
update:function(a){this.record=a},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.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",cls:"tab-general",border:false,bodyStyle:"background-color: inherit;",labelAlign:"left",defaults:{border:false,xtype:"panel",layout:"form"},items:[this.createNameInfoPanel(),this.createDescriptionInfoPanel(),this.createContentInfoPanel()]});
Zarafa.hierarchy.dialogs.FolderPropertiesGeneralTab.superclass.constructor.call(this,a)},createNameInfoPanel:function(){return{style:{borderBottomWidth:"1px",borderBottomStyle:"solid"},items:[{xtype:"displayfield",cls:"display-name",name:"display_name",htmlEncode:true,ref:"displayField",hideLabel:true}],ref:"nameInfoPanel"}},createDescriptionInfoPanel:function(){return{cls:"description-panel",style:{borderBottomWidth:"1px",borderBottomStyle:"solid"},defaults:{anchor:"100%"},items:[{xtype:"displayfield",
fieldLabel:_("Type"),htmlEncode:true,ref:"folderTypeField"},{xtype:"displayfield",fieldLabel:_("Location"),ref:"locationField",htmlEncode:true},{xtype:"textarea",fieldLabel:_("Description"),height:72,name:"comment",listeners:{change:this.onFieldChange,scope:this}}],ref:"descriptionPanel"}},createContentInfoPanel:function(){return{cls:"content-info-panel",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}]}},updateUI:function(a,b){var c=false;if(b===true){c=a.get("container_class").substr(4).replace(/\./,"").toLowerCase();var d=Zarafa.common.ui.IconClass.getIconClass(a);if(c==="appointment"){c=container.getContextByName("calendar").getModel().getColorScheme(a.get("entryid"));
this.nameInfoPanel.displayField.getEl().setStyle("background-image",'url(\'data:image/svg+xml;utf8,<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="15" height="13" viewBox="0 0 15 13" style="color:'+c.base+';"><g><g class="icbg" style="fill:currentColor;stroke:none"><rect width="15" height="12" x="0" y="1" /><rect width="1" height="1" x="2" y="0" /><rect width="1" height="1" x="7" y="0" /><rect width="1" height="1" x="12" y="0" /></g><path class="icgr" d="M 2.5,6.5 h 10 v 4 h -10 v -4.5 M 4.5,6.5 v 4 M 6.5,6.5 v 4 M 8.5,6.5 v 4 M 10.5,6.5 v 4 M 2.5,8.5 h 9.5" style="fill:currentColor;stroke:#ffffff;stroke-width:1;stroke-linejoin=miter" /></g></svg>\')')}else this.nameInfoPanel.displayField.addClass(String.format("folder-dialog-icon "+
d));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.openFolderSizeContent(this.record)}});
Ext.reg("zarafa.folderpropertiesgeneraltab",Zarafa.hierarchy.dialogs.FolderPropertiesGeneralTab);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.folderpropertiespanel",cls:"zarafa-folderproperties tabpanel-container",border:false,layout:"fit",deferredRender:false,items:[{xtype:"tabpanel",border:false,activeTab:0,deferredRender:false,layoutOnTabChange:true,items:[{xtype:"zarafa.folderpropertiesgeneraltab",title:_("General")},{xtype:"zarafa.folderpropertiespermissiontab",title:_("Permissions")},container.populateInsertionPoint("folderpropertiescontentpanel.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.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",cls:"tab-permissions",layout:{type:"vbox",align:"stretch"},border:false,bodyStyle:"background-color: inherit;",items:[this.createUserListPanel(),this.createProfilePanel(),this.createPermissionPanel()]});Zarafa.hierarchy.dialogs.FolderPropertiesPermissionTab.superclass.constructor.call(this,
a)},createUserListPanel:function(){return{xtype:"panel",cls:"userlist-panel",layout:"fit",flex:1,border:false,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,autoWidth:false},{text:_("Remove"),ref:"../../removeUserBtn",handler:this.onUserRemove,scope:this,autoWidth:false}]}},createProfilePanel:function(){var a={xtype:"jsonstore",fields:["name","value"],data:Zarafa.hierarchy.data.PermissionProfiles};return{xtype:"panel",layout:"fit",cls:"profile-panel",
autoHeight:true,border:false,items:{xtype:"container",autoHeight:true,items:[{xtype:"form",layout:{type:"table",columns:2},border:false,ref:"../profileForm",items:[{xtype:"label",autoWidth:true,autoHeight:true,forId:"profile-combo",hideLabel:false,text:_("Profile")+":",ref:"../../profileLabel"},{xtype:"combo",ref:"../../../profileCombo",width:122,flex:1,id:"profile-combo",fieldLabel:_("Profile"),labelWidth:undefined,labelStyle:"width: auto",hideLabel:true,autoHeight:true,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}}]}]}}},createPermissionPanel:function(){return{xtype:"form",layout:"fit",cls:"permissions-panel",autoHeight:true,border:false,ref:"permissionsForm",items:[{xtype:"fieldset",autoHeight:true,autoWidth:true,cls:"zarafa-fieldset",items:[{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.openABUserSelectionContent({callback:this.onUserSelected,
scope:this,hierarchyRestriction:{hide_contacts:true},listRestriction:{hide_users:["non_security"],hide_groups:["non_security"],hide_companies:["non_security"]}})},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,{container: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()},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){var b;if(this.selectedUser){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.FolderSelectionPanel=Ext.extend(Ext.Panel,{folder:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",border:false,items:[{xtype:"zarafa.hierarchytree",ref:"hierarchyTree",border:true,forceLayout:true,treeSorter:true}]});Zarafa.hierarchy.dialogs.FolderSelectionPanel.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.hierarchy.dialogs.FolderSelectionPanel.superclass.initEvents.apply(this,arguments);this.folder&&this.mon(this.hierarchyTree,
"load",this.onTreeNodeLoad,this)},onTreeNodeLoad:function(){this.hierarchyTree.selectFolderInTree(this.folder)&&this.mun(this.hierarchyTree,"load",this.onTreeNodeLoad,this)},getFolder:function(){return this.hierarchyTree.getSelectionModel().getSelectedNode().getFolder()}});Ext.reg("zarafa.folderselectionpanel",Zarafa.hierarchy.dialogs.FolderSelectionPanel);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.ui");
Zarafa.hierarchy.ui.FolderNode=Ext.extend(Ext.tree.AsyncTreeNode,{folder:undefined,isNodeSelected:false,tpl:new Ext.XTemplate("{text:htmlEncode}",{compiled:true}),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));if(!this.ui.getIconEl()||this.ui.getIconEl().tagName!=="svg"){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;if(this.ownerTree&&this.ownerTree.model)b=this.ownerTree.model.getFolder(this.getFolder().get("entryid"));Ext.isDefined(b)?this.setChecked(true):this.setChecked(false);if(a){b=0;for(var c=this.childNodes.length;b<c;b++)this.childNodes[b].update(a)}}});Ext.tree.TreePanel.nodeTypes.folder=Zarafa.hierarchy.ui.FolderNode;Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.FolderNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{currentCounterType:undefined,renderElements:function(a,b,c,d){this.indentMarkup=a.parentNode?a.parentNode.ui.getChildIndent():"";var e;if(a.getOwnerTree().colored)e=a.getOwnerTree().model.getColorScheme(b.folder.get("entryid"));var f=Ext.isBoolean(b.checked);e=f?'<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="15" height="13" viewBox="0 0 15 13" style="color:'+e.base+'; position:relative; top:2px;"><g><g class="icbg" style="fill:currentColor;stroke:none"><rect width="15" height="12" x="0" y="1" /><rect width="1" height="1" x="2" y="0" /><rect width="1" height="1" x="7" y="0" /><rect width="1" height="1" x="12" y="0" /></g><path class="icgr" d="M 2.5,6.5 h 10 v 4 h -10 v -4.5 M 4.5,6.5 v 4 M 6.5,6.5 v 4 M 8.5,6.5 v 4 M 10.5,6.5 v 4 M 2.5,8.5 h 9.5" style="fill:currentColor;stroke:#ffffff;stroke-width:1;stroke-linejoin=miter" /></g></svg>':
"";var g='<img src="'+(b.icon||this.emptyIcon)+'" class="x-tree-node-icon" unselectable="on" />',i;e='<li class="x-tree-node"><div ext:tree-node-id="'+a.id+'" class="x-tree-node-el x-tree-node-leaf x-unselectable zarafa-hierarchy-node" unselectable="on"><span class="x-tree-node-indent">'+this.indentMarkup+'</span><img src="'+this.emptyIcon+'" class="x-tree-ec-icon x-tree-elbow" />'+(f?'<input class="x-tree-node-cb zarafa-hierarchy-node-cb" type="checkbox" '+(b.checked?'checked="checked" />':"/>"):
"")+(f?e:g)+'<a hidefocus="on" class="x-tree-node-anchor zarafa-hierarchy-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&&(i=a.nextSibling.ui.getEl())?Ext.DomHelper.insertHtml("beforeBegin",
i,e):Ext.DomHelper.insertHtml("beforeEnd",c,e);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(f){this.checkbox=c[2];this.iconNode=c[3];i=this.iconNode.childNodes[0];this.calendarSVGIconChilds=[i.childNodes[0].childNodes[0],i.childNodes[1]];this.checkbox.defaultChecked=this.checkbox.checked;d++}this.anchor=c[d];this.textNode=c[d].firstChild;this.counterNode=c[d].firstChild.nextSibling;
c=Ext.get(this.elNode);d=Ext.get(this.iconNode);i=Ext.get(this.wrap);e=Ext.get(this.textNode);f&&e.addClass("zarafa-hierarchy-node-color");Ext.isEmpty(b.cls)||c.addClass(b.cls);b.icon&&d.addClass("x-tree-node-inline-icon");b.iconCls&&d.addClass(b.iconCls);Ext.isEmpty(b.containerCls)||i.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)){var d=this.currentCounterType,e=a.getCounterType();
switch(e){case Zarafa.hierarchy.data.CounterTypes.TOTAL:if(Ext.isDefined(d)){if(d!==e){b.replaceClass("zarafa-hierarchy-node-unread-count","zarafa-hierarchy-node-total-count");b.addClass("zarafa-hierarchy-node-withcounter")}}else b.addClass(["zarafa-hierarchy-node-total-count","zarafa-hierarchy-node-withcounter"]);c.update("("+a.getCounterValue()+")");c.repaint();break;case Zarafa.hierarchy.data.CounterTypes.UNREAD:if(Ext.isDefined(d)){if(d!==e){b.replaceClass("zarafa-hierarchy-node-total-count",
"zarafa-hierarchy-node-unread-count");b.addClass("zarafa-hierarchy-node-withcounter")}}else b.addClass(["zarafa-hierarchy-node-unread-count","zarafa-hierarchy-node-withcounter"]);c.update("("+a.getCounterValue()+")");c.repaint();break;case Zarafa.hierarchy.data.CounterTypes.NONE:default:if(Ext.isDefined(d)&&d!==e){b.removeClass(["zarafa-hierarchy-node-total-count","zarafa-hierarchy-node-unread-count"]);b.removeClass("zarafa-hierarchy-node-withcounter")}c.update("");c.repaint();break}this.currentCounterType=
e}},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(){var a=[this.iconNode,this.textNode,this.counterNode,this.elNode];if(Ext.isDefined(this.calendarSVGIconChilds))a=a.concat(this.calendarSVGIconChilds);
return a}});Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.HierarchyRootNode=Ext.extend(Ext.tree.AsyncTreeNode,{constructor:function(a){a=a||{};Ext.applyIf(a,{text:"root",leaf:false,expanded:true,uiProvider:Ext.tree.RootTreeNodeUI});Zarafa.hierarchy.ui.HierarchyRootNode.superclass.constructor.call(this,a)},findChildByEntryId:function(a){return this.findChildBy(function(b){return Zarafa.core.EntryId.compareEntryIds(b.attributes.folder.get("entryid"),a)})},findChildStoreByEntryId:function(a){return this.findChildBy(function(b){return Zarafa.core.EntryId.compareStoreEntryIds(b.attributes.folder.get("store_entryid"),a)})}});
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:"table",defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.ALL,items:[{cls:"zarafa-hierarchy-treepanel-footer-opensharedfolder",xtype:"button",tooltip:b+" (Alt + S)",text:b+" + ",
handler:this.openSharedFolder.createDelegate(this)}]});Zarafa.hierarchy.ui.HierarchyTreeBottomBar.superclass.constructor.call(this,a)},openSharedFolder:function(){Zarafa.hierarchy.Actions.openSharedFolderContent(this.defaultSelectedSharedFolderType)}});Ext.reg("zarafa.hierarchytreebottombar",Zarafa.hierarchy.ui.HierarchyTreeBottomBar);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});Ext.EventManager.on(Ext.getDoc(),"keydown",this.onDragKeyDown,this);Ext.EventManager.on(Ext.getDoc(),"keyup",this.onDragKeyUp,this);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(){Ext.EventManager.un(Ext.getDoc(),"keydown",this.onDragKeyDown,this);Ext.EventManager.un(Ext.getDoc(),"keyup",this.onDragKeyUp,this);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.Tree=Ext.extend(Ext.tree.TreePanel,{model:undefined,store:undefined,IPMFilter:undefined,hideDeletedFolders:false,nodeConfig:undefined,deferredLoading:false,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,root:new Zarafa.hierarchy.ui.HierarchyRootNode});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(){if(!this.loader)this.loader=new Zarafa.hierarchy.data.HierarchyTreeLoader({tree:this,store:this.store,nodeConfig:this.nodeConfig,deferredLoading:this.deferredLoading});Zarafa.hierarchy.ui.Tree.superclass.initComponent.apply(this,arguments);if(this.enableDD===true)if(this.ddAutoScrollContainer===true)this.on("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.on("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){var b=false;if(Ext.isDefined(this.IPMFilter))b=!a.isContainerClass(this.IPMFilter,false);if(!b&&this.hideDeletedFolders)b=a.isInDeletedItems();return!b},getAllNodes:function(){return this.getRootNode().childNodes},selectFolderInTree:function(a){if(a=
this.ensureFolderVisible(a)){this.getSelectionModel().select(a);return true}else return false},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}Zarafa.hierarchy.ui.Tree.superclass.beforeDestroy.call(this)}});Ext.reg("zarafa.hierarchytree",Zarafa.hierarchy.ui.Tree);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.on({beforenodeclick:this.onBeforeNodeClick,beforestartedit:this.onBeforeStartEdit,canceledit:this.onEditCancel,complete:this.onEditComplete,scope: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.TreeSorter=Ext.extend(Ext.tree.TreeSorter,{folderProperty:"display_name",storeProperty:"mailbox_owner_name",folderOrder:["inbox","drafts","outbox","sent","IPF.Note","wastebasket","junk","calendar","IPF.Appointment","contact","IPF.Contact","task","IPF.Task","note","IPF.StickyNote","journal","IPF.Journal","IPF.Note.OutlookHomepage"],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",i=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,i);if(e!==0)return e}return this.compareRecordProp(c,
d,this.folderProperty,g,i)},compareRecordProp:function(a,b,c,d,e){var f=a.getDefaultFolderKey(),g=b.getDefaultFolderKey();f||(f=a.get("container_class"));g||(g=b.get("container_class"));f=this.folderOrder.indexOf(f);g=this.folderOrder.indexOf(g);if(f>-1)if(g===-1||f<g)return d?+1:-1;else{if(f>g)return d?-1:+1}else if(g>-1)return d?-1:+1;a=a.get(c);b=b.get(c);if(!e){a=!Ext.isEmpty(a)?a.toLowerCase():a;b=!Ext.isEmpty(b)?b.toLowerCase():b}return a<b?d?+1:-1:a>b?d?-1:+1:0}});Ext.namespace("Zarafa.mail");
Zarafa.mail.Actions={openMailContent:function(a,b){Ext.each(a,function(c){c.isUnsent()&&!c.isFaultyMessage()?Zarafa.core.data.UIFactory.openCreateRecord(c,b):Zarafa.core.data.UIFactory.openViewRecord(c,b)})},openCreateMailContent:function(a,b){var c=a.createRecord();Zarafa.core.data.UIFactory.openCreateRecord(c,b)},openCreateMailContentForContacts:function(a,b,c){a=a.createRecord();var d=a.getRecipientStore(),e=[];b=Ext.isArray(b)?b:[b];for(var f=0,g=b.length;f<g;f++){var i=b[f];if(i.isOpened()){var h=
i.convertToRecipient(Zarafa.core.mapi.RecipientType.MAPI_TO,true);d.add(h)}else e.push({fn:function(){var k=i;return function(j,l,m,n){var o=function(p,q){if(q===k){p.un("open",o,m);var r=k.convertToRecipient(Zarafa.core.mapi.RecipientType.MAPI_TO,true);d.add(r);n()}};k.getStore().on("open",o,m);k.open()}}()})}c=Ext.applyIf(c||{},{recordComponentPluginConfig:{loadTasks:e}});Zarafa.core.data.UIFactory.openCreateRecord(a,c)},openCreateMailResponseContent:function(a,b,c,d){Ext.isArray(a)||(a=[a]);for(var e=
undefined,f=0;f<a.length;f++){var g=a[f];if(!g.isFaultyMessage())if(c===Zarafa.mail.data.ActionTypes.FORWARD_ATTACH)e=b.createResponseRecord(g,c,e);else{var i=function(h,k){if(this===k)if(c===Zarafa.mail.data.ActionTypes.FORWARD_ATTACH)e=b.createResponseRecord(k,c,e);else{e=b.createResponseRecord(k,c);Zarafa.core.data.UIFactory.openCreateRecord(e,d);h.un("open",i,k)}};if(g.isOpened()){e=b.createResponseRecord(g,c);Zarafa.core.data.UIFactory.openCreateRecord(e,d)}else{g.getStore().on("open",i,g);g.open()}}}c===
Zarafa.mail.data.ActionTypes.FORWARD_ATTACH&&Zarafa.core.data.UIFactory.openCreateRecord(e,d)},openMailOptionsContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];b=Ext.applyIf(b||{},{modal:true});Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mail.dialog.options"],a,b)},openMailFlagsContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];b=Ext.applyIf(b||{},{modal:true});b.autoSave||Ext.apply(b,{disableFlagColor:true,disableCompleted:true});
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mail.dialog.flags"],a,b)},openRecipientSelectionContent:function(a,b){if(Ext.isArray(a)&&!Ext.isEmpty(a))a=a[0];var c=a.copy(),d=c.getSubStore("recipients");Zarafa.common.Actions.openABUserMultiSelectionContent({callback:function(){a.applyData(c)},convert:function(e,f){return e.convertToRecipient(f?f.defaultRecipientType:b.defaultRecipientType)},store:d,selectionCfg:[{xtype:"zarafa.recipientfield",fieldLabel:_("To")+
":",boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,flex:1},{xtype:"zarafa.recipientfield",fieldLabel:_("CC")+":",boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,flex:1},{xtype:"zarafa.recipientfield",fieldLabel:_("BCC")+":",boxStore:d,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,
flex:1}]})}};Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.ActionTypes={REPLY:"reply",REPLYALL:"replyall",FORWARD:"forward",FORWARD_ATTACH:"forward_attach",EDIT_AS_NEW:"edit_as_new",isSendOrForward:function(a){return a===this.REPLY||a===this.REPLYALL||a===this.FORWARD||a===this.FORWARD_ATTACH}};Ext.namespace("Zarafa.mail.data");
Zarafa.mail.data.SearchFields=[{name:_("All text fields"),value:"subject sender_name sender_email_address sent_representing_name sent_representing_email_address body display_to display_cc"},{name:_("Subject"),value:"subject"},{name:_("Sender"),value:"sender_name sender_email_address sent_representing_name sent_representing_email_address"},{name:_("Body"),value:"body"},{name:_("Subject or Sender"),value:"subject sender_name sender_email_address sent_representing_name sent_representing_email_address"},
{name:_("To or cc"),value:"display_to display_cc"}];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:"{signatureData}<blockquote style='border-left: 2px solid #325FBA; padding-left: 5px; margin: 0px 5px;'><span style=\"font-family:tahoma,arial,helvetica,sans-serif; font-size: 10pt;\">-----"+_("Original message")+'-----<br /><tpl if="!Ext.isEmpty(values.sent_representing_name)"><span><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></span><br /></tpl><tpl if="Ext.isDate(values.message_delivery_time)"><span><strong>'+
_("Sent")+':</strong> {message_delivery_time:date("'+_("l jS F Y G:i")+'")}</span><br /></tpl><tpl if="!Ext.isEmpty(values.display_to)"><span><strong>'+_("To")+':</strong> {display_to:htmlEncode}</span><br /></tpl><tpl if="!Ext.isEmpty(values.display_cc)"><span><strong>'+_("Cc")+":</strong> {display_cc:htmlEncode}</span><br /></tpl><span><strong>"+_("Subject")+":</strong> {subject:htmlEncode}</span><br /><br /></span>{body}</blockquote>"};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,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.dialogs");
Zarafa.mail.dialogs.MailCreatePanel=Ext.extend(Ext.form.FormPanel,{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,cls:"zarafa-mailcreatepanel",bodyStyle:"background-color: inherit;",defaults:{border:false},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)}},initSendAsList:function(){var a=container.getSettingsModel().get("zarafa/v1/contexts/mail/sendas",true),b=[];if(Ext.isEmpty(a)){b.push({text:_("No send as address configured!")});return b}Ext.each(a,function(c){c=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,
c);c={text:c.formatRecipient(true),handler:this.onSelectSendAsRecipient,scope:this,record:c};b.push(c)},this);return b},initMessageFormPanel:function(){return[{xtype:"zarafa.compositefield",hideLabel:true,ref:"fromField",cls:"zarafa-mailcreatepanel-field-from",anchor:"100%",autoHeight:true,items:[{xtype:"splitbutton",autoHeight:true,text:_("From")+":",handler:this.onSelectUser,menu:new Ext.menu.Menu({showSeparator:false,items:this.initSendAsList()}),scope:this},{xtype:"zarafa.addressbookboxfield",
enableKeyEvents:true,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.resizablecompositefield",hideLabel:true,cls:"zarafa-mailcreatepanel-field-to",anchor:"100%",autoHeight:false,items:[{xtype:"button",text:_("To")+":",autoHeight:true,handler:function(){Zarafa.mail.Actions.openRecipientSelectionContent(this.record,
{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO})},scope:this},{xtype:"zarafa.recipientfield",ref:"../toRecipientField",enableKeyEvents:true,plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO}]},{xtype:"zarafa.resizablecompositefield",hideLabel:true,cls:"zarafa-mailcreatepanel-field-cc",anchor:"100%",autoHeight:false,items:[{xtype:"button",autoHeight:true,text:_("Cc")+
":",handler:function(){Zarafa.mail.Actions.openRecipientSelectionContent(this.record,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC})},scope:this},{xtype:"zarafa.recipientfield",enableKeyEvents:true,plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_CC}]},{xtype:"zarafa.resizablecompositefield",ref:"bccField",hideLabel:true,cls:"zarafa-mailcreatepanel-field-bcc",anchor:"100%",
autoHeight:false,items:[{xtype:"button",autoHeight:true,text:_("Bcc")+":",handler:function(){Zarafa.mail.Actions.openRecipientSelectionContent(this.record,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC})},scope:this},{xtype:"zarafa.recipientfield",enableKeyEvents:true,plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,filterRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_BCC}]},{xtype:"textfield",cls:"zarafa-mailcreatepanel-field-subject",
name:"subject",enableKeyEvents:true,value:undefined,height:36,emptyText:_("Subject")+":",listeners:{change:this.onChange,scope:this}},{xtype:"zarafa.resizablecompositefield",hideLabel:true,cls:"zarafa-mailcreatepanel-field-attachments",anchor:"100%",autoHeight:true,items:[{xtype:"zarafa.attachmentbutton",autoHeight:true,plugins:["zarafa.recordcomponentupdaterplugin"],text:_("Attachments")+":"},{xtype:"zarafa.attachmentfield",enableKeyEvents:true,plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,
tabIndex:-1,hideLabel:true,value:undefined}]},{xtype:"zarafa.editorfield",cls:"zarafa-mailcreatepanel-field-editor",enableKeyEvents:true,ref:"editorField",hideLabel:true,flex:1,listeners:{change:this.onBodyChange,initialized:this.onEditorInitialized,valuecorrection:this.onBodyValueCorrection,scope:this}}]},update:function(a,b){this.record=a;this.getForm().loadRecord(a);if(a.isOpened())if(b){this.editorField.setHtmlEditor(this.use_html_editor,false);this.editorField.bindRecord(a);this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()))}else{var c=
a.getBody(this.editorField.isHtmlEditor()),d=this.editorField.getValue();if(c!==d&&!this.editorField.getEditor().hasFocus||d===this.editorField.getEditor().originalValue)this.editorField.setValue(d)}},onBodyValueCorrection:function(a,b){var c=this.record;if(this.editorField.isHtmlEditor())c.data.html_body=c.inlineImgZarafaToOutlook(b);else c.data.body=b},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);a.setBody(this.editorField.getValue(),this.editorField.isHtmlEditor());a.endEdit()},
onChange:function(a,b){this.record.set(a.name,b)},onBodyChange:function(){var a=this.record;a.beginEdit();a.setBody(this.editorField.getValue(),this.editorField.isHtmlEditor());a.endEdit()},onEditorInitialized:function(a,b){var c=new Ext.Element(b.getDoc());Zarafa.core.KeyMapMgr.activate(this.dialog,"global",c);Zarafa.core.KeyMapMgr.activate(this.dialog,"contentpanel.record.message",c)},onDialogBccToggle:function(a,b){this.bccField.setVisible(b);this.doLayout()},onDialogFromToggle:function(a,b){this.fromField.setVisible(b);
this.doLayout()},setSignatureInEditor:function(a){a=this.dialog.getContextModel().getSignatureData(this.editorField.isHtmlEditor(),a);Ext.isEmpty(a)||this.editorField.insertAtCursor(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.openABUserSelectionContent({callback:this.abCallBack,scope:this,hierarchyRestriction:{hide_contacts:true},listRestriction:{hide_users:["system","everyone"],hide_companies:true}})},
onSelectSendAsRecipient:function(a){if(a.record){var b=this.fromRecipientField.getBoxStore();b.removeAll();b.add(a.record)}},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.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,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",null);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",null);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",null)}}});Ext.reg("zarafa.mailflagspanel",Zarafa.mail.dialogs.MailFlagsPanel);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.openCategoriesContent(this.record,
{autoSave:false})},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.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.MailViewOptionsPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailviewoptionspanel",layout:{type:"vbox",align:"stretch"},border:false,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.ui");Zarafa.mail.ui.MailRowSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,{handleMouseDown:function(a,b,c){var d=a.getColumnModel(),e=a.getView().findCellIndex(c.getTarget()),f=false;if(e!==false&&e>=0)f=d.config[e].preventRowSelection;f!==true&&Zarafa.mail.ui.MailRowSelectionModel.superclass.handleMouseDown.call(this,a,b,c)}});Ext.reg("zarafa.mailrowselectionmodel",Zarafa.mail.ui.MailRowSelectionModel);
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.note");
Zarafa.note.Actions={openNoteContent:function(a,b){Ext.each(a,function(c){Zarafa.core.data.UIFactory.openViewRecord(c,b)})},openCreateNoteContent:function(a,b){var c=a.createRecord();Zarafa.core.data.UIFactory.openCreateRecord(c,b)}};Ext.namespace("Zarafa.note.data");Zarafa.note.data.SearchFields=[{name:_("All text fields"),value:"body categories"},{name:_("Categories"),value:"categories"}];Ext.namespace("Zarafa.note.dialogs");
Zarafa.note.dialogs.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:"zarafa.editorfield",useHtml:false,ref:"noteText",plaintextName:"body",listeners:{change:this.onTextareaChange,scope:this}}]});Zarafa.note.dialogs.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){var c=this.noteText.getEditor();if(a){this.record=a;if(b||a.isModifiedSinceLastUpdate("body"))this.noteText.setValue(a.get("body")||"");if(b||a.isModifiedSinceLastUpdate("icon_index")){c.removeClass(this.currentColorCss);var d=this.getTextAreaColor(a.get("icon_index"));this.currentColorCss=d;c.addClass(d)}}else{this.noteText.setValue("");c.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.dialogs.NoteEditPanel);Ext.namespace("Zarafa.settings");
Zarafa.settings.SettingsModel=Ext.extend(Ext.util.Observable,{pathSeparator:"/",autoSave:true,defaults:undefined,settings:undefined,editing:false,editingCount:0,modified:undefined,restored:undefined,deleted:undefined,resetSettings:undefined,requiresReload:false,constructor:function(a){a=a||{};this.addEvents("set","remove","exception","beforesave","save");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=[];this.resetSettings=[];Ext.data.DataProxy.relayEvents(this,["exception"])},initialize:function(a){this.settings=Zarafa.core.Util.applyRecursive({},a,this.defaults)},beginEdit:function(){this.editingCount++;if(this.editingCount<1)this.editingCount=1;if(this.editingCount===1){this.editing=true;this.modified=this.modified||[];this.restored=this.restored||[];this.deleted=this.deleted||[]}},endEdit:function(){this.editingCount--;if(this.editingCount<
0)this.editingCount=0;if(this.editingCount===0){this.editing=false;if(!Ext.isEmpty(this.modified)||!Ext.isEmpty(this.deleted))this.afterEdit()}},afterEdit:function(){var a=false;Ext.isEmpty(this.restored)||this.fireEvent("set",this,this.restored);this.restored=[];if(!Ext.isEmpty(this.modified)){this.fireEvent("set",this,this.modified);a=true}if(!Ext.isEmpty(this.deleted)){this.fireEvent("remove",this,this.deleted);a=true}a===true&&this.autoSave!==false&&this.save()},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(){Ext.isEmpty(this.deleted)||this.execute(Zarafa.core.Actions["delete"],
this.deleted);Ext.isEmpty(this.modified)||this.execute(Zarafa.core.Actions.set,this.modified);Ext.isEmpty(this.resetSettings)||this.execute(Zarafa.core.Actions.reset,this.resetSettings)},execute:function(a,b){this.fireEvent("beforesave",this,{action:b})!==false&&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:{action:a,parameters:b,requiresReload:this.requiresReload},
callback:this.onExecuteComplete,scope:this}))},onExecuteComplete:function(a,b,c){if(c){this.fireEvent("save",this,b);this.commit()}},commit:function(){this.deleted=[];this.modified=[];this.resetSettings=[];this.requiresReload=false},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 i=this.removeSettingsObject(a+this.pathSeparator+g,b);e=e.concat(i)}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="",i=0,h=f.length;i<h;i++){var k=f[i];g+=(!Ext.isEmpty(g)?this.pathSeparator:"")+k;if(Ext.isEmpty(c[k]))c[k]={};c=c[k]}}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()},reset:function(a){Ext.isArray(a)||(a=[a]);this.resetSettings=this.resetSettings.concat(a)},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,c){a=this.getPath(a);a=c?this.getSettingsObject(a,this.defaults):this.getSettingsObject(a,this.settings);if(Ext.isObject(a)){if(b===true)return Zarafa.core.Util.applyRecursive({},a)}else return Ext.isArray(a)||Ext.isDate(a)?a.clone():a}});Ext.namespace("Zarafa.settings.data");
Zarafa.settings.data.SettingsDefaultValue=function(){return{getDefaultValues:function(){return{zarafa:{v1:{main:{default_context:"mail",language:"en_GB",use_canvas_rendering:true,use_files_api:true,confirm_close_dialog:true,week_start:1,working_days:[1,2,3,4,5],start_working_hour:540,end_working_hour:1020,default_font:"tahoma,arial,helvetica,sans-serif",default_font_size:2,keycontrols:Zarafa.settings.data.KeyboardSettings.NO_KEYBOARD_SHORTCUTS,page_size:50,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")],search:{updatesearch_timeout:500},notifier:{"default":"messagebox",error:{value:"messagebox",connection:{value:"dropdown"},hierarchy:{defaultfolder:{value:"dropdown"}}},warning:{value:"messagebox"},info:{value:"popup",
reminder:{value:"none"},newmail:{value:"popup"},sent:{value:"dropdown"},saved:{value:"dropdown"},mailsaved:{value:"toolbarnotifierplugin"},sending:{value:"dropdown"},saving:{value:"dropdown"},mailsaving:{value:"toolbarnotifierplugin"},unresolved_recipients:{value:"dropdown"},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,datepicker_show_busy:true,free_busy_range:2},contact:{show_name_dialog:true,show_address_dialog:true},mail:{enable_live_scroll:true,readreceipt_handling:"ask",always_request_readreceipt:false,autosave_enable:true,autosave_time:60,readflag_time_enable:true,readflag_time:0,from_address_list:[],block_external_content:true,safe_senders_list:[],blocked_senders_list:[],close_on_respond:true,outofoffice:{message:"",set:false,subject:"",from:"",until:""},
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.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]),
i=(!Ext.isEmpty(c)?c+"/":"")+f,h=false;if(this.autoExpandFilter)if(this.autoExpandFilter.test(i))h=i.split("/").length<this.autoExpandLevel;e.push({nodeType:"setting",text:f,id:i,leaf:g,expanded:!g&&h,value:g?d[f]:undefined,uiProvider:Zarafa.settings.ui.SettingsTreeNodeUI})}b(e,{status:true})}});Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.QuotaBar=Ext.extend(Ext.BoxComponent,{userStore:undefined,quotaTemplate:'<div class="zarafa-quotabar"><div class="zarafa-quotabar-normal"></div><div class="zarafa-quotabar-warn"></div><div class="zarafa-quotabar-soft"></div><div class="zarafa-quotabar-hard"></div></div>',constructor:function(a){a=a||{};Zarafa.settings.ui.QuotaBar.superclass.constructor.call(this,a);this.quotaTemplate=new Ext.XTemplate(this.quotaTemplate,{compiled:true});this.on("afterrender",this.onQuotaBarRender,
this);this.userStore&&this.mon(this.userStore.getStore(),"update",this.onUpdateHierarchyStore,this)},onQuotaBarRender:function(){this.quotaTemplate.overwrite(Ext.get(this.el));this.updateQuotaBar()},updateQuotaBar:function(){if(this.userStore)if(this.el&&this.el.child("div.zarafa-quotabar")){var a=this.userStore.get("store_size"),b=this.userStore.get("quota_soft"),c=this.userStore.get("quota_hard"),d=this.userStore.get("quota_warning");if(!(!b&&!c&&!d)){var e=[];if(d&&(!b||d<b)&&(!c||d<c))e.push({size:d,
element:"div.zarafa-quotabar-warn"});if(b&&(!c||b<c))e.push({size:b,element:"div.zarafa-quotabar-soft"});c&&e.push({size:c,element:"div.zarafa-quotabar-hard"});c=c||b||d;if(a>c){c=a;e.push({size:a})}b=this.el.child("div.zarafa-quotabar").getWidth(true);c=b/c;var f;d=0;for(var g="div.zarafa-quotabar-normal",i=0;i<e.length;i++){f=e[i].size;if(a<=f){f=a;a=0}f-=d;d+=f;if(g){f=Math.round(f*c);f=Math.max(f,0);if(b<f)f=b;this.el.child(g).setWidth(f);b-=f}(g=e[i].element)&&this.el.child(g).setWidth(0)}}}},
onUpdateHierarchyStore:function(a,b){b.isDefaultStore()&&this.updateQuotaBar()}});Ext.reg("zarafa.quotabar",Zarafa.settings.ui.QuotaBar);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsCategory=Ext.extend(Ext.Container,{items:undefined,settingsContext:undefined,title:"",categoryIndex:100,savingEl:undefined,savingElCounter:0,constructor:function(a){a=a||{};Ext.applyIf(a,{autoScroll:true});Zarafa.settings.ui.SettingsCategory.superclass.constructor.call(this,a)},onShow:function(){Zarafa.settings.ui.SettingsCategory.superclass.onShow.apply(this,arguments);this.mon(container.getCurrentContext().getModel(),"beforesavesettings",this.onBeforeSaveSettingsModel,
this)},onHide:function(){Zarafa.settings.ui.SettingsCategory.superclass.onHide.apply(this,arguments);this.mun(container.getCurrentContext().getModel(),"beforesavesettings",this.onBeforeSaveSettingsModel,this);this.mun(container.getSettingsModel(),"beforesave",this.onBeforeSettingsSave,this)},onBeforeSaveSettingsModel:function(){this.mon(container.getSettingsModel(),"beforesave",this.onBeforeSettingsSave,this,{single:true});this.savingElCounter=0},onBeforeSettingsSave:function(a){this.displaySavingMask();
this.mun(a,"beforesave",this.onBeforeSettingsSave,this);this.mon(a,"save",this.onSettingsSave,this);this.mon(a,"exception",this.onSettingsException,this)},onSettingsSave:function(a){this.mun(a,"save",this.onSettingsSave,this);this.mun(a,"exception",this.onSettingsException,this);this.hideSavingMask(true)},onSettingsException:function(a){this.mun(a,"save",this.onSettingsSave,this);this.mun(a,"exception",this.onSettingsException,this);this.hideSavingMask(false)},displaySavingMask:function(){this.savingElCounter++;
if(!this.savingEl)this.savingEl=container.getNotifier().notify("info.saving","",_("Saving")+"...",{container:container.getContentPanel().getEl(),persistent:true})},hideSavingMask:function(a){var b=container.getContentPanel().getEl();this.savingElCounter--;if(this.savingElCounter===0||!a)if(this.savingEl){container.getNotifier().notify("info.saving",null,null,{container:b,destroy:true,reference:this.savingEl});delete this.savingEl;a&&container.getNotifier().notify("info.saved",_("Saved"),_("Saved successfully"),
{container:b})}},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.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.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.SettingsCategoryWidgetPanel=Ext.extend(Ext.Container,{context:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"card",cls:"zarafa-settings-category-widget-panel"});Zarafa.settings.ui.SettingsCategoryWidgetPanel.superclass.constructor.call(this,a);if(this.context){a=this.context.getModel();this.mon(this.context,{viewchange:this.onViewChange,viewmodechange:this.onViewModeChange,scope:this});this.mon(a,{beforesavesettings:this.onBeforeSaveSettings,savesettings:this.onSaveSettings,
discardsettings:this.onDiscardSettings,scope:this})}this.on("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.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.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.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.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.SettingsWidget=Ext.extend(Ext.Panel,{settingsContext:undefined,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.task");
Zarafa.task.Actions={openTaskContent:function(a,b){Ext.each(a,function(c){Zarafa.core.data.UIFactory.openViewRecord(c,b)})},openCreateTaskContent:function(a,b){var c=a.createRecord();Zarafa.core.data.UIFactory.openCreateRecord(c,b)},createTaskFromMail:function(a,b){var c;if(Ext.isArray(a)&&!Ext.isEmpty(a))c=a[0];if(c.isOpened()){c=c.convertToTask(b.getDefaultFolder());Zarafa.core.data.UIFactory.openCreateRecord(c)}else{c.getStore().on("open",this.openHandler.createDelegate(this,[b],2),this,{single:true});
c.open()}},openHandler:function(a,b,c){a=b.convertToTask(c.getDefaultFolder());Zarafa.core.data.UIFactory.openCreateRecord(a)}};Ext.namespace("Zarafa.task.data");
Zarafa.task.data.SearchFields=[{name:_("All text fields"),value:"subject body categories owner companies"},{name:_("Subject"),value:"subject"},{name:_("Categories"),value:"categories"},{name:_("Body"),value:"body"},{name:_("Owner"),value:"owner"},{name:_("Companies"),value:"companies"},{name:_("Due Date"),value:"duedate"},{name:_("Start Date"),value:"startdate"}];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"),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(a.processValue(b))&&this.record.set(a.name,b)}});Ext.reg("zarafa.taskdetailtab",Zarafa.task.dialogs.TaskDetailTab);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",plugins:["zarafa.recordcomponentupdaterplugin"],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 date"),labelWidth:100},endFieldConfig:{fieldLabel:_("End date"),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:217,timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/task/reminder_time_stepping"),listeners:{change:this.onPropertyChange,scope:this},dateFieldConfig:{flex:0}},{xtype:"spacer",width:23},{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:"zarafa.resizablecompositefield",
hideLabel:true,anchor:"100%",cls:"zarafa-taskcreatepanel-field-attachments",autoHeight:true,items:[{xtype:"zarafa.attachmentbutton",plugins:["zarafa.recordcomponentupdaterplugin"],width:100,text:_("Attachments")+":",autoHeight:true},{xtype:"zarafa.attachmentfield",plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,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.toUTC();d=b||a.isModifiedSinceLastUpdate("startdate")}var e=a.get("duedate"),f=false;if(Ext.isDate(e)){e=e.toUTC();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.getHierarchyStore().getById(a.get("store_entryid")))&&this.ownerField.setReadOnly(!c.isPublicStore())},update:function(a,
b){this.record=a;this.updateUI(a,b);b&&a.isOpened()&&this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()));if(b||a.isModifiedSinceLastUpdate("reminder_time"))a.set("flagdueby",a.get("reminder_time"));this.getForm().loadRecord(a)},updateRecord:function(a){a.beginEdit();this.getForm().updateRecord(a);this.updateStartDueDate(a,this.dateField.getValue());this.onBodyChange(this.editorField.getEditor(),this.editorField.getValue());a.endEdit()},onPropertyChange:function(a,b){!Ext.isEmpty(a.name)&&
a.validateValue(a.processValue(b))&&this.record.set(a.name,b)},onImportanceSelect:function(a,b){var c=b.get(a.valueField);!Ext.isEmpty(a.name)&&a.validateValue(a.processValue(c))&&this.record.set(a.name,c)},onBodyChange:function(){var a=this.record;a.beginEdit();a.setBody(this.editorField.getValue(),this.editorField.isHtmlEditor());a.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.fromUTC());a.set("commonstart",c.clone())}else{a.set("startdate",null);a.set("commonstart",null)}if(Ext.isDate(d)){a.set("duedate",d.fromUTC());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.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,defaults:{bodyStyle:"background-color: inherit; padding: 5px;"},items:[{xtype:"zarafa.taskgeneraltab"},{xtype:"zarafa.taskdetailtab"},container.populateInsertionPoint("context.task.taskcontentpanel.tabs",
this)]}]}});Ext.reg("zarafa.taskpanel",Zarafa.task.dialogs.TaskPanel);Ext.namespace("Zarafa.task.ui");Zarafa.task.ui.TaskPreviewPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.taskpreviewpanel",border:false,bodyCfg:{cls:"preview-body"},layout:"fit",items:[{xtype:"zarafa.taskbody"}]});Zarafa.task.ui.TaskPreviewPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.taskpreviewpanel",Zarafa.task.ui.TaskPreviewPanel);
Ext.apply(Ext.EventObjectImpl.prototype,{getKeyCharCode:function(){var a=this.getCharCode();if(a>=this.NUM_ZERO&&a<=this.NUM_NINE)a-=48;return String.fromCharCode(a)}});
Zarafa.core.ColorSchemes.addField([{name:"header",weight:1},{name:"border",weight:1.8},{name:"borderInner",weight:1.42},{name:"startcolorappointment",weight:1},{name:"endcolorappointment",weight:1},{name:"startcolorappointmentbox",weight:1.29},{name:"endcolorappointmentbox",weight:1.29},{name:"stripnormal",weight:1.86},{name:"stripworking",color:"#ffffff"},{name:"linenormal",weight:1.73},{name:"hourline",weight:1.33}]);Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.LabelColorSchemes=[{startcolorappointment:"#A7BFE5",endcolorappointment:"#8CA9D9",startcolorappointmentbox:"#C4D5EF",endcolorappointmentbox:"#7294CB",border:"#7294CB"},{startcolorappointment:"#F4B7B5",endcolorappointment:"#E98784",startcolorappointmentbox:"#FDEAEA",endcolorappointmentbox:"#DA5A56",border:"#DA5A56"},{startcolorappointment:"#B6CAE9",endcolorappointment:"#8CA9D9",startcolorappointmentbox:"#E4EBF8",endcolorappointmentbox:"#6389C6",border:"#6389C6"},{startcolorappointment:"#D9E9B6",
endcolorappointment:"#C0D98C",startcolorappointmentbox:"#F1F8E4",endcolorappointmentbox:"#A6C663",border:"#A6C663"},{startcolorappointment:"#EBDA6C",endcolorappointment:"#DFCB47",startcolorappointmentbox:"#F4E894",endcolorappointmentbox:"#CAB52B",border:"#CAB52B"},{startcolorappointment:"#E9DAB6",endcolorappointment:"#D9C18C",startcolorappointmentbox:"#F8F1E4",endcolorappointmentbox:"#C6A763",border:"#C6A763"},{startcolorappointment:"#B6DDE9",endcolorappointment:"#8CC6D9",startcolorappointmentbox:"#E4F3F8",
endcolorappointmentbox:"#63ADC6",border:"#63ADC6"},{startcolorappointment:"#B6B6E9",endcolorappointment:"#8C8CD9",startcolorappointmentbox:"#E4E4F8",endcolorappointmentbox:"#6363C6",border:"#6363C6"},{startcolorappointment:"#DCB6E9",endcolorappointment:"#C48CD9",startcolorappointmentbox:"#F2E4F8",endcolorappointmentbox:"#AB63C6",border:"#AB63C6"},{startcolorappointment:"#E9BBB6",endcolorappointment:"#D9928C",startcolorappointmentbox:"#F8E5E4",endcolorappointmentbox:"#C66B63",border:"#C66B63"},{startcolorappointment:"#C1E9B6",
endcolorappointment:"#9BD98C",startcolorappointmentbox:"#E8F8E4",endcolorappointmentbox:"#77C663",border:"#77C663"}];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"}]);
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,i){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+i,b+d);this.arc(a+i,b+d-i,i,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.stroke()};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.getFontSize=function(){return parseInt(/([0-9]*)p[tx]/.exec(this.font)[1],10)};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,i){for(;a[a.length-1]==="\n";)a=a.substr(0,a.length-1);var h=a.split("\n");if(h.length>1){var k=0;for(a=0;a<h.length;a++){var j=this.drawWrappedText(h[a],b,c,d,e,f,g,i);c+=j;k+=j;f-=j}return k}h=a.split(" ");k=this.textWidth(" ");g=g||0;i=i||0;j=b+g;var l=
c;a=0;for(var m=h.length;a<m;a++){var n=h[a],o=this.textWidth(n);if(j-b+o>=d&&j!==b){var p=true;if(o>=d)if(j-b+o/2<d)p=false;if(p){l+=e;if(l>i)g=0;j=b+g;if(l-c>f)break}}this.drawText(n,j,l);j+=o+k}return l-c+e};CanvasRenderingContext2D.prototype.textHeight=function(a,b,c){for(;a[a.length-1]==="\n";)a=a.substr(0,a.length-1);var d=a.split("\n");if(d.length>1){var e=0;for(a=0;a<d.length;a++){var f=this.textHeight(d[a],b,c);e+=f}return e}d=a.split(" ");e=this.textWidth(" ");var g=f=0;a=0;for(var i=d.length;a<
i;a++){var h=this.textWidth(d[a]);if(f+h>=b&&f!==0){var k=true;if(h>=b)if(f+h/2<b)k=false;if(k){f=0;g+=c}}f+=h+e}g+=c;return g};CanvasRenderingContext2D.prototype.textWidth=function(a){if(this.measureText)return this.measureText(a).width;if(this.mozMeasureText)return this.mozMeasureText(a);return 0};CanvasRenderingContext2D.prototype.convertHexRgbToDecRgba=function(a,b){if(Ext.isString(a)&&a.search(/#?[A-F0-9]{6}/i)===0){Ext.isNumber(b)||(b=1);var c=[];a=a.replace("#","");c[0]=parseInt(a.substr(0,
2),16);c[1]=parseInt(a.substr(2,2),16);c[2]=parseInt(a.substr(4,2),16);return"rgba("+c[0]+","+c[1]+","+c[2]+","+b+")"}return"rgba(0,0,0,0)"}}
Zarafa.core.Container=Ext.extend(Ext.util.Observable,{contexts:undefined,contextsMetaData:undefined,plugins:undefined,pluginsMetaData:undefined,widgetsMetaData:undefined,constructor:function(){this.addEvents(["beforecontextswitch","contextswitch","aftercontextswitch","folderselect","beforelogout","logout"]);Zarafa.core.Container.superclass.constructor.call(this);this.plugins=[];this.pluginsMetaData=[];this.contexts=[];this.contextsMetaData=[];this.widgetsMetaData=[]},logout:function(a,b){if(this.fireEvent("beforelogout")!==
false){this.fireEvent("logout");this.doLogout(a,b)}},doLogout:function(a,b){var c=a===true?"&user="+this.getUser().getUserName():"";Zarafa.core.Util.disableLeaveRequester();window.location=b!==true?"index.php?logout"+c:"index.php?load=logon"+c},getServerConfig:function(){return this.serverConfigRecord},setServerConfig:function(a){this.serverConfigRecord=new Zarafa.core.data.ServerConfig(a)},getUser:function(){return this.userRecord},setUser:function(a){this.userRecord=new Zarafa.core.data.User(a)},
getVersion:function(){return this.versionRecord},setVersion:function(a){this.versionRecord=new Zarafa.core.data.Version(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)},getMainToolbar:function(){return this.getMainPanel().mainToolbar},getWelcomePanel:function(){return this.welcomePanel=this.welcomePanel=new Zarafa.core.ui.WelcomeViewport},getTabPanel:function(){return this.getMainPanel().getContentPanel()},getContentPanel:function(){return this.getTabPanel().get(0).getActiveItem()},getNavigationBar:function(){return this.getMainPanel().getNavigationPanel()},
getWidgetSideBar:function(){return this.getMainPanel().getWidgetPanel()},getPlugins:function(){return this.plugins},getPluginsMetaData:function(){return this.pluginsMetaData},getContexts:function(){return this.contexts},getContextsMetaData:function(){return this.contextsMetaData},getWidgetsMetaData:function(){return this.widgetsMetaData},getContextByName:function(a){for(var b=this.getContexts(),c=0,d=b.length;c<d;c++)if(b[c].getName()===a)return b[c]},getContextMetaDataByName:function(a){for(var b=
this.getContextsMetaData(),c=0,d=b.length;c<d;c++)if(b[c].getName()===a)return b[c]},getPluginByName:function(a){for(var b=this.getPlugins(),c=0,d=b.length;c<d;c++)if(b[c].getName()===a)return b[c]},getPluginMetaDataByName:function(a){for(var b=this.getPluginsMetaData(),c=0,d=b.length;c<d;c++)if(b[c].getName()===a)return b[c]},getWidgetMetaDataByName:function(a){for(var b=this.getWidgetsMetaData(),c=0,d=b.length;c<d;c++)if(b[c].getName()===a)return b[c]},populateInsertionPoint:function(){for(var a=
this.getPlugins(),b=[],c=Ext.toArray(arguments),d=0,e=a.length;d<e;d++){var f=a[d],g=f.getComponents.apply(f,c);Ext.each(g,function(i){i.plugin=f;b.push(i)})}return Ext.flatten(b)},registerContext:function(a){this.getContextsMetaData().push(a);a.isEnabled()&&this.getContexts().push(a.getInstance());this.registerPlugin(a)},registerPlugin:function(a){this.getPluginsMetaData().push(a);a.isEnabled()&&this.getPlugins().push(a.getInstance())},registerWidget:function(a){this.getWidgetsMetaData().push(a)},
switchContext:function(a,b,c){var d=this.getCurrentContext();if(d!==a&&this.fireEvent("beforecontextswitch",b,d,a)!==false){if(d){d.disable();var e=d.getModel();e&&e.un("folderchange",this.onContextFolderChange,this)}a.enable(b,c);(c=a.getModel())&&c.on("folderchange",this.onContextFolderChange,this);this.currentContext=a;this.fireEvent("folderselect",b);this.fireEvent("contextswitch",b,d,a);this.fireEvent("aftercontextswitch",b,d,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],i=g.bid(a);if(c===undefined||i>c){c=i;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){for(var g=0,i=e.length;g<i;g++){var h=e[g],k=h.bidSharedComponent(a,b);if(d===undefined||k>d){d=k;c=h}}if(c&&d>=0)f=c.getSharedComponent(a,b)}return f},getReminderStore:function(){return this.reminderStore||(this.reminderStore=new Zarafa.common.reminder.data.ReminderStore)},getBaseURL:function(){var a=window.location;a=a.protocol+"//"+a.host+a.pathname;if(a.indexOf("index.php")===-1)a+="index.php";return a},getBasePath:function(){var a=container.getBaseURL();
return a.substring(0,a.lastIndexOf("index.php"))}});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""}};
Ext.namespace("Zarafa.core");
Zarafa.core.ContextModel=Ext.extend(Zarafa.core.data.StatefulObservable,{current_data_mode:undefined,store:undefined,folders:undefined,last_used_folders:undefined,selectedRecords:undefined,defaultFolder:undefined,statefulRecordSelection:false,lastPreviewedRecord:{},lastSelectedRecord:{},isBusyScrolling:false,enabled:false,suspended:false,suspendLoad:false,suspendData:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{stateful:true});this.addEvents("previewrecordchange","recordselectionchange",
"folderchange","datamodechange","beforelivescrollstart","livescrollstart","beforelivescrollstop","livescrollstop","beforesearchstart","searchstart","searchupdate","beforesearchstop","searchstop","searchfinish","searchexception");Zarafa.core.ContextModel.superclass.constructor.call(this,a);if(this.statefulRecordSelection===true){this.store.on("beforeload",this.onBeforeLoad,this);this.store.on("load",this.onLoad,this)}this.stateful&&this.initState();a=container.getHierarchyStore();a.on("load",this.onHierarchyLoad,
this);this.onHierarchyLoad(a);Zarafa.core.data.IPFStoreMgr.on("afterrecordupdate",this.afterRecordUpdate,this)},enable:function(a,b){this.enabled=true;this.suspendLoading(true);a&&this.setFolders(a);this.setDataMode(this.getCurrentDataMode(),true);b!==true&&this.resumeLoading()},disable:function(){this.enabled=false;this.stopLiveScroll();this.store.cancelLoadRequests();this.store.removeAll(true)},onBeforeLoad:function(a,b){b&&(b.actionType===Zarafa.core.Actions.updatesearch||b.actionType===Zarafa.core.Actions.updatelist)||
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.getById(b);if(c=this.lastSelectedRecord[c.params.entryid]){b=0;for(var f=c.length;b<f;b++){var g=a.getById(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);if(Ext.isEmpty(this.folders)){b=[];if(!Ext.isEmpty(this.last_used_folders))for(var c in this.last_used_folders){var d=a.getById(c);if(d){d=d.getSubStore("folders");for(var e=this.last_used_folders[c],f=0;f<e.length;f++){var g=d.getById(e[f]);g&&b.push(g)}}}Ext.isEmpty(b)&&this.defaultFolder&&
b.push(this.defaultFolder);this.setFolders(b)}}},afterRecordUpdate:function(a,b,c){if(this.enabled){a=b.getMessageAction("action_type");if(c=="commit"&&Ext.isString(a))switch(a.toLowerCase()){case "emptyfolder":case "readflags":Ext.each(this.getFolders(),function(d){if(b.equals(d)){this.reload();return false}},this);break}}},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){var b=true;if(this.folders==a||this.folders===undefined)b=false;this.folders=Ext.isArray(a)?a.clone():Ext.isDefined(a)?[a]:[];
this.onFolderChange(this,this.folders);this.fireEvent("folderchange",this,this.folders,b);this.load()},onFolderChange:function(a,b){this.stopLiveScroll();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(){if(this.enabled){var a=this.getFolders();if(!Ext.isEmpty(a))return a[0]}return this.defaultFolder},
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},suspendLoading:function(){this.suspended=true},resumeLoading:function(a){if(this.suspended===true){this.suspended=false;a!==false&&this.suspendLoad===true&&this.load(this.suspendData);delete this.suspendData}},load:function(a){if(this.enabled)if(this.suspended){this.suspendLoad=true;this.suspendData=a}else 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(){var a=this.store.lastOptions;!this.isSearching()&&this.isBusyScrolling&&this.stopLiveScroll();if(this.suspended){this.suspendLoad=true;this.suspendData=a}else 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(){if(Ext.isDefined(this.getStore())&&Ext.isDefined(this.getStore().isBusySearching)&&this.getStore().isBusySearching)return true;return false},supportsSearchFolder:function(a){a=a||this.getDefaultFolder();if(Ext.isEmpty(a))return false;a=a.getMAPIStore();if(!a)return false;return a.hasSearchSupport()},isLiveScrolling:function(){return this.isBusyScrolling},startLiveScroll:function(a){if(container.getSettingsModel().get("zarafa/v1/contexts/mail/enable_live_scroll"))if(this.fireEvent("beforelivescrollstart",
this,a)!==false){this.isBusyScrolling=true;this.store.on("exception",this.onLiveScrollException,this);if(this.fireEvent("livescrollstart",this,a)!==false){var b={restriction:{}};b.restriction.start=a;b.restriction.limit=container.getSettingsModel().get("zarafa/v1/main/page_size");this.store.liveScroll({folder:[this.getDefaultFolder()],params:b,add:true})}}},stopLiveScroll:function(){if(this.isBusyScrolling&&this.fireEvent("beforelivescrollstop",this)!==false){this.store.stopLiveScroll();this.store.un("exception",
this.onLiveScrollException,this);this.isBusyScrolling=false;this.fireEvent("livescrollstop",this)}},onLiveScrollException:function(){this.store.un("exception",this.onLiveScrollException,this);this.stopLiveScroll()},startSearch:function(a,b,c){var d=this.supportsSearchFolder();d||(b=false);if(this.fireEvent("beforesearchstart",this,a,b)!==false){this.store.isBusySearching=true;this.fireEvent("searchstart",this,a,b);this.store.on("exception",this.onSearchException,this);d?this.store.on("beforeupdatesearch",
this.onSearchUpdate,this):this.store.on("load",function(){this.fireEvent("searchfinished",this)},this,{single:true});this.store.search({folder:c.folder,useSearchFolder:d,subfolders:b,searchRestriction:a})}},stopSearch:function(){if(this.isSearching()&&this.fireEvent("beforesearchstop",this)!==false){this.store.stopSearch({});this.store.un("exception",this.onSearchException,this);this.store.un("beforeupdatesearch",this.onSearchUpdate,this);this.isBusyScrolling=this.store.isBusySearching=false;this.fireEvent("searchstop",
this)}},onSearchUpdate:function(a,b){this.fireEvent("searchupdate",this,a,b);if(!Zarafa.core.mapi.Search.isSearchRunning(b.searchState)){a.un("exception",this.onSearchException,this);a.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.stopSearch();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.saveDataModeState,this,{delay:100});this.on("folderchange",this.saveFolderChangeState,this,{delay:100})},saveFolderChangeState:function(a,b,c){c!=false&&this.saveState()},saveDataModeState:function(a,b,c){b!=c&&this.saveState()},
getState:function(){var a=Zarafa.core.ContextModel.superclass.getState.call(this)||{},b=this.isSearching();if(this.folders){this.last_used_folders={};for(var c=0,d=this.folders.length;c<d;c++){var e=this.folders[c],f=e.get("store_entryid");e=e.get("entryid");Ext.isDefined(this.last_used_folders[f])||(this.last_used_folders[f]=[]);this.last_used_folders[f].push(e)}}return Ext.apply(a,b?{}:{current_data_mode:this.current_data_mode,last_used_folders:this.last_used_folders})}});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.KeyMapMgr=Ext.extend(Object,{keyMaps:undefined,keys:undefined,constructor:function(){this.keyMaps=new Ext.util.MixedCollection;this.keys={}},register:function(a,b){this.keys[a]||(this.keys[a]=[]);Ext.isArray(b)||(b=[b]);this.keys[a]=this.keys[a].concat(b);this.preventBrowserDefaults(a,b)},preventBrowserDefaults:function(a,b){if(a!=="global"&&a!=="globaldisable")for(var c=0,d=b.length;c<d;c++){var e=b[c];if(e.enableGlobally!==true){var f={handler:Ext.emptyFn,stopEvent:true};Ext.applyIf(f,
e);this.register("globaldisable",f)}else if(e.ctrl===true){f=e.key;if(Ext.isString(f))f=f.toUpperCase().charCodeAt(0);if(f===Ext.EventObject.A){f={handler:this.disableTextSelection,stopEvent:false};Ext.applyIf(f,e);this.register("globaldisable",f)}}}},disableTextSelection:function(a,b){var c=b.getTarget().nodeName.toLowerCase();c!=="textarea"&&c!=="input"&&b.stopEvent()},activate:function(a,b,c){c||(c=a.getEl());c=Ext.get(c);var d=c.id;if(!Ext.isEmpty(d)){b=this.getKeyBindings(b);var e=container.getSettingsModel().get("zarafa/v1/main/keycontrols");
if(e===Zarafa.settings.data.KeyboardSettings.BASIC_KEYBOARD_SHORTCUTS)b=b.filter(function(f){return Ext.isDefined(f.basic)});else if(e===Zarafa.settings.data.KeyboardSettings.NO_KEYBOARD_SHORTCUTS)b=[];if(!Ext.isEmpty(b))if(e=this.getActive(c))e.addBinding(b);else{a instanceof Ext.Component&&a.on("beforedestroy",this.onComponentDestroy,this);this.keyMaps.add(d,new Zarafa.core.KeyMap(a,b,c))}}},getKeyBindings:function(a){for(var b=[];!Ext.isEmpty(a);){if(this.keys[a])b=b.concat(this.keys[a]);a=a.substr(0,
a.lastIndexOf("."))}return b},onComponentDestroy:function(a){this.deactivate(a.getEl())},deactivate:function(a){a=Ext.get(a);if(a=this.keyMaps.get(a.id)){a.disable();this.keyMaps.remove(a)}},getActive:function(a){a=Ext.get(a);return this.keyMaps.get(a.id)},enableKeyMap:function(a){a=Ext.get(a);if(a=this.keyMaps.get(a.id))if(this.isGloballyEnabled())a.enable();else a.originallyEnabled=true},disableKeyMap:function(a){a=Ext.get(a);if(a=this.keyMaps.get(a.id)){a.disable();if(!this.isGloballyEnabled())a.originallyEnabled=
false}},enableAllKeymaps:function(){this.keyMaps.each(function(a){a.originallyEnabled===true&&a.enable();delete a.originallyEnabled},this)},disableAllKeymaps:function(){this.keyMaps.each(function(a){a.originallyEnabled=a.isEnabled();a.disable()},this)},isEnabled:function(a){return(a=this.getActive(a))&&a.isEnabled()},isGloballyEnabled:function(){return container.getSettingsModel().get("zarafa/v1/main/keycontrols")!==Zarafa.settings.data.KeyboardSettings.NO_KEYBOARD_SHORTCUTS}});
Zarafa.core.KeyMapMgr=new Zarafa.core.KeyMapMgr;Ext.namespace("Zarafa.core");
Zarafa.core.Plugin=Ext.extend(Zarafa.core.data.StatefulObservable,{info:undefined,constructor:function(a){Zarafa.core.Plugin.superclass.constructor.call(this,a);this.initPlugin()},initPlugin:function(){var a=this.info.getAbout();Ext.isEmpty(a)||this.registerAboutText(this.getDisplayName(),a)},getName:function(){return this.info.getName()},getDisplayName:function(){return this.info.getDisplayName()},getIconCls:function(){return this.info.getIconCls()},getSettingsBase:function(){return this.info.getSettingsBase()},
registerAboutText:function(a,b){this.registerInsertionPoint("context.settings.category.copyright",function(){return{xtype:"zarafa.settingscopyrightwidget",title:a,about:b}})},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.PluginMetaData=Ext.extend(Object,{name:"",displayName:"",settingsName:"",iconCls:"",about:undefined,allowUserDisable:true,allowUserVisible:true,pluginConstructor:undefined,instance:undefined,constructor:function(a){a=a||{};Ext.apply(this,a);Zarafa.core.PluginMetaData.superclass.constructor.call(this,a);if(Ext.isEmpty(this.displayName))this.displayName=this.name;if(Ext.isEmpty(this.settingsName))this.settingsName=this.name},isEnabled:function(){return!this.allowUserDisable||container.getSettingsModel().get(this.getSettingsBase()+
"/enable")===true},isPrivate:function(){return this.allowUserVisible===false},getName:function(){return this.name},getDisplayName:function(){return this.displayName},getIconCls:function(){return this.iconCls},getAbout:function(){return this.about},getSettingsBase:function(){return"zarafa/v1/plugins/"+this.settingsName},getInstance:function(){if(!this.instance)this.instance=new this.pluginConstructor({info:this});return this.instance}});Ext.namespace("Zarafa.core");
Zarafa.core.PresenceManager=Ext.extend(Ext.util.Observable,{presencePlugins:undefined,getPresencePlugins:function(){if(!Ext.isDefined(this.presencePlugins)){this.presencePlugins=[];var a=container.getPlugins();Ext.each(a,function(b){b instanceof Zarafa.core.PresencePlugin&&this.presencePlugins.push(b)},this)}return this.presencePlugins},getPresenceStatusForUsers:function(a){Ext.isArray(a)||(a=[a]);if(a.length===0)return[];var b=[],c=this.getPresencePlugins();if(c.length===0){for(var d=0;d<a.length;d++)b.push(Zarafa.core.data.PresenceStatus.UNKNOWN);
return b}var e=[];Ext.each(a,function(f){var g=false;Ext.each(e,function(i){if(i.type===f.type&&i.username===f.username&&i.email_address===f.email_address)return g=true});g||e.push(f)});for(d=0;d<a.length;d++)b.push({});Ext.each(c,function(f){var g=f.getName(),i=f.getPresenceStatuses(e);Ext.each(a,function(h,k){Ext.each(e,function(j,l){if(h.username===j.username&&h.email_address===j.email_address)b[k][g]=i[l]})})});Ext.each(b,function(f,g){var i=Zarafa.core.data.PresenceStatus.UNKNOWN;for(var h in f)if(f[h]>
i)i=f[h];b[g]=i});return b},registerStore:function(a,b){a.on("load",this.onStoreLoad.createDelegate(this,[b],true),this)},onStoreLoad:function(a,b,c,d){var e=[];Ext.isArray(d)||(d=[d]);Ext.each(b,function(g){Ext.each(d,function(i,h){if(!Ext.isDefined(i)){i="";d[h]=""}e.push(this.getUserInfo(i,g))},this)},this);var f=Zarafa.core.PresenceManager.getPresenceStatusForUsers(e);Ext.each(b,function(g,i){var h=g.dirty;g.beginEdit();Ext.each(d,function(k,j){g.set(k+(Ext.isEmpty(k)?"presence_status":"_presence_status"),
f[i*d.length+j])});g.dirty=h;g.endEdit();g.commit()})},getUserInfo:function(a,b){var c={};if(Ext.isObject(a)){c.display_name=b.get(a.display_name);c.type=b.get(a.type);if(c.type==="ZARAFA"){c.entryid=b.get(a.entryid);c.username=b.get(a.username)}else c.email_address=b.get(a.email_address)}else if(Ext.isString(a)){c.display_name=b.get(a+(Ext.isEmpty(a)?"display_name":"_name"));c.type=b.get(a+(Ext.isEmpty(a)?"address_type":"_address_type"));if(c.type==="ZARAFA"){c.entryid=b.get(a+(Ext.isEmpty(a)?"entryid":
"_entryid"));c.username=b.get(a+(Ext.isEmpty(a)?"username":"_username"))||b.get(a+(Ext.isEmpty(a)?"email_address":"_email_address"))}else c.email_address=b.get(a+(Ext.isEmpty(a)?"email_address":"_email_address"))||b.get(a+(Ext.isEmpty(a)?"smtp_address":"_smtp_address"))}return c}});Zarafa.core.PresenceManager=new Zarafa.core.PresenceManager;Ext.namespace("Zarafa.core");
Zarafa.core.URLActionMgr=Ext.extend(Ext.util.Observable,{mappings:undefined,constructor:function(){this.mappings={}},register:function(a,b){this.mappings[a]||(this.mappings[a]=[]);this.mappings[a]=this.mappings[a].concat(b)},execute:function(a){Ext.iterate(a,function(b,c){var d=this.mappings[b];d&&Ext.each(d,function(e){e.handler.call(e.scope||this,b,c,e)})},this)}});Zarafa.core.URLActionMgr=new Zarafa.core.URLActionMgr;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.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.getById(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(){if(!this.standalone){Zarafa.core.data.IPFStoreMgr.unregister(this,this.serveronly);Zarafa.core.data.IPFStoreMgr.un("beforerecordsave",this.onExternalSave,this);Zarafa.core.data.IPFStoreMgr.un("afterrecordwrite",this.onExternalWrite,this)}Zarafa.core.data.IPFStore.superclass.destroy.call(this)}});
Ext.reg("zarafa.ipfstore",Zarafa.core.data.IPFStore);Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMAttachmentProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{getResponseHandlerForRequest:function(a,b,c,d,e,f,g,i,h){return new Zarafa.core.data.IPMAttachmentResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:h,callback:g,scope:i})},createUpdateAction:function(a,b,c,d,e,f,g){this.doRequests(g.actionType||Zarafa.core.Actions.upload,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)},doRequests:function(a,
b,c,d,e,f,g,i){var h=container.getRequest(),k=c;if(Ext.isArray(c))k=c[0];k=this.getItemModuleName(k);b=this.getResponseHandlerForRequest(k,a,b,c,d,e,f,g,i);if(Zarafa.supportsFilesAPI()){c=new FormData;for(var j in d){e=d[j];if(Ext.isArray(e)||e instanceof FileList){f=0;for(g=e.length;f<g;f++)c.append(j+"[]",e[f])}else c.append(j,e)}h.reset();a=h.addDataRequest(k,a,c,b);j=i.requestUrl;j=Ext.urlAppend(j,"module="+k);j=Ext.urlAppend(j,"moduleid="+a);h.send(j,{})}else{a=container.getRequest().getRequestId(k);
container.getResponseRouter().addRequestResponseHandler(a,b);h={zarafa:{}};h.zarafa[k]={};h.zarafa[k][a]=d;if(!i.requestForm){i.autoDestroyRequestForm=true;i.requestForm=(new Ext.form.FormPanel({renderTo:Ext.getBody(),fileUpload:true,cls:"x-hidden"})).getForm()}j=i.requestUrl;j=Ext.urlAppend(j,"module="+k);j=Ext.urlAppend(j,"moduleid="+a);i.requestForm.submit({url:j,request:h,destroyForm:i.autoDestroyRequestForm===true,params:d,failure:this.onLegacyFailure,success:this.onLegacySuccess,scope:this})}},
onLegacySuccess:function(a,b){if(!Ext.isEmpty(b.result)&&!Ext.isEmpty(b.result.zarafa)){container.getResponseRouter().receive(b.result);this.onLegacyPostProcessAction(a,b)}else this.onLegacyFailure(a,b)},onLegacyFailure:function(a,b){b.response.status=200;container.getResponseRouter().receiveFailure(b.options.request,b.response);this.onLegacyPostProcessAction(a,b)},onLegacyPostProcessAction:function(a,b){if(b.options.destroyForm){var c=a.el.parent(".x-panel");if(c)(c=Ext.ComponentMgr.get(c.id))&&
c.destroy()}}});Ext.namespace("Zarafa.core.data");Zarafa.core.data.IPMExpandDistlistProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{listModuleName:"expanddistlistmodule",getResponseHandlerForRequest:function(a,b,c,d,e,f,g,i,h){return new Zarafa.core.data.IPMExpandDistlistResponseHandler({proxy:this,action:Ext.data.Api.actions.read,reader:f,sendRecords:d,options:h,callback:g,scope:i})},request:function(a,b,c,d,e,f,g){switch(a){case Zarafa.core.Actions.expand: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,i,h){return new Zarafa.core.data.IPMResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:h,callback:g,scope:i})},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.IPMRecipientResolveProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{listModuleName:"resolvenamesmodule",getResponseHandlerForRequest:function(a,b,c,d,e,f,g,i,h){return new Zarafa.core.data.IPMRecipientResolveResponseHandler({proxy:this,action:Ext.data.Api.actions.read,reader:f,sendRecords:d,options:h,callback:g,scope:i})},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");
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.findBy(function(i){if(f.equals(i))return true});
if(!(g<0)){g=this.getAt(g);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++)for(var e=0,f=a.length;e<f;e++)if(Zarafa.core.EntryId.compareEntryIds(b[c].get("entryid"),a[e]))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);!Ext.isEmpty(b)&&b[0]instanceof Ext.data.Record&&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){a=false;Ext.isArray(b)||(b=[b]);for(var d=0,e=b.length;d<e;d++){var f=b[d],g=Ext.isArray(c)?c[d]:c;f.setEventPropagation(false);var i=f.get("message_class");if(g instanceof Ext.data.Record){if(i!==
g.get("message_class"))if(i.indexOf(g.get("message_class"))!==0)a=true;f.applyData(g);f.commit()}else if(Object.keys(g).length!==0){var h=g.message_class||g.props.message_class;if(i!==h)if(i.indexOf(h)!==0)a=true;this.reader.update(f,g)}f.setEventPropagation(true)}a&&this.reload()},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.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");
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.data)}},this);Ext.each(b,function(d){if(d.isInline()){if(!Ext.isDefined(c.attachments.remove))c.attachments.remove=
[];c.attachments.remove.push(d.data)}},this);return c}});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],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}});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,actions:undefined,constructor:function(a,b,c){Zarafa.core.data.MAPIRecord.superclass.constructor.call(this,a,b);this.idProperties=this.baseIdProperties.clone();this.actions={};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,true)},applyData:function(a,b){this.beginEdit();this.trackUpdateModifications=a.trackUpdateModifications;for(var c in a.data)if(c!=="message_class")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)){this.createSubStores();this.mergeSubStores(a.subStores,b);a.isOpened()&&!this.isOpened()&&this.afterOpen()}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();delete this.updateModifications;delete this.updateSubStoreModifications},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(d(this.data[a])!==
d(b)){if(!this.updateModifications)this.updateModifications={};if(this.updateModifications[a]===undefined)this.updateModifications[a]=this.data[a]}else if(c!==true)return}Zarafa.core.data.MAPIRecord.superclass.set.call(this,a,b);this.modified=this.modified||{};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},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)},commit:function(a){delete this.updateModifications;delete this.updateSubStoreModifications;for(var b in this.subStores)this.subStores[b].commitChanges();Zarafa.core.data.MAPIRecord.superclass.commit.call(this,a)},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.trackUpdateModifications===true){if(this.updateSubStoreModifications&&this.updateSubStoreModifications[a])return this.updateSubStoreModifications[a].changes}else{a=
this.getSubStore(a);return[].concat(a.modified,a.removed)}},getMessageActions:function(){return this.actions},getMessageAction:function(a){return this.actions[a]?this.actions[a]:false},addMessageAction:function(a,b){this.actions[a]=b;Ext.isDefined(this.store)&&this.store.modified.indexOf(this)==-1&&this.store.modified.push(this)},deleteMessageAction:function(a){delete this.actions[a]},hasMessageAction:function(a){return Ext.isDefined(this.actions[a])},clearMessageActions:function(){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.onSubStoreUpdate,this);b.on("add",this.onSubStoreChange,this);b.on("remove",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){d.each(function(e){var f=b.getById(b.data.getKey(e));f?e.applyData(f):d.remove(e)});b.each(function(e){d.getById(d.data.getKey(e))||d.add(e.copy())},this)}else{d.removeAll(true);d.add(b.getRange(),true);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}},onSubStoreUpdate:function(a,b,c){c!==Ext.data.Record.COMMIT&&
this.onSubStoreChange(a,b)},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},destroy:function(){for(var a in this.subStores)this.subStores[a].destroy();this.subStores=null}});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},getById:function(a){var b=Zarafa.core.data.MAPISubStore.superclass.getById.call(this,a);if(!b){var c=-1;if(this.reader.meta.idProperty==="entryid")c=this.findBy(function(d){return Zarafa.core.EntryId.compareEntryIds(a,d.id)});else if(this.reader.meta.idProperty===
"store_entryid")c=this.findBy(function(d){return Zarafa.core.EntryId.compareStoreEntryIds(a,d.id)});if(c>=0)b=this.getAt(c)}return b},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)}},sortBy:function(a,b){this.data.sort(a,b);this.snapshot&&this.snapshot!=this.data&&
this.snapshot.sort(a,b);this.fireEvent("datachanged",this)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ServerConfig=Ext.extend(Object,{meta:undefined,constructor:function(a){this.meta=a},isPluginsEnabled:function(){return this.meta.enable_plugins},isAdvancedSettingsEnabled:function(){return this.meta.enable_advanced_settings},getMaxAttachments:function(){return this.meta.max_attachments},getMaxFileUploads:function(){return this.meta.max_file_uploads},getMaxPostRequestSize:function(){return this.meta.post_max_size},getMaxAttachmentSize:function(){return this.meta.max_attachment_size},
getMaxAttachmentTotalSize:function(){return this.meta.max_attachment_total_size},getFreebusyLoadStartOffset:function(){return this.meta.freebusy_load_start_offset},getFreebusyLoadEndOffset:function(){return this.meta.freebusy_load_end_offset},getMaxEmlFilesInZIP:function(){return this.meta.maximum_eml_files_in_zip},getClientTimeout:function(){return this.meta.client_timeout},getActiveTheme:function(){return this.meta.active_theme},getPluginsVersion:function(){return this.meta.version_info},getColorSchemes:function(){return this.meta.color_schemes},
getAdditionalColorSchemes:function(){return this.meta.additional_color_schemes},getContactPrefix:function(){return this.meta.contact_prefix},getContactSuffix:function(){return this.meta.contact_suffix},getPowerpasteConfig:function(){return this.meta.powerpaste}});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,i,h){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:h,callback:g,scope:i})},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.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.UIFactory={layers:[],registerLayer:function(a){var b=a.index||0;if(this.layers.length>0)for(var c=0,d=this.layers.length;c<d;c++)if(this.layers[c].index>b){this.layers.splice(c,0,a);return}this.layers.push(a)},getPreferredLayer:function(a){var b=this.layers,c=0,d=container.getSettingsModel().get("zarafa/v1/main/base_content_layer");if(!Ext.isEmpty(d))for(var e=0,f=b.length;e<f;e++)if(b[e].type===d){c=e;break}if(a){if(a.manager){e=0;for(f=b.length;e<f;e++)if(a.manager===b[e].manager){c=
e;break}}if(a.modal===true){e=c;for(f=b.length;e<f;e++)if(b[e].allowModal===true)c=e}}return b[c]},openLayerComponent:function(a,b,c){if(a=container.getSharedComponent(a,b))if(a.prototype instanceof Ext.Component){var d=this.getPreferredLayer(c);c=Ext.applyIf(c||{},{record:b,closable:true,plugins:[]});c.plugins=c.plugins.concat(d.plugins);d.create(a,c)}else a.doOpen(b)},openViewRecord:function(a,b){this.openLayerComponent(Zarafa.core.data.SharedComponentType["common.view"],a,b)},openCreateRecord:function(a,
b){this.openLayerComponent(Zarafa.core.data.SharedComponentType["common.create"],a,b)},openDefaultContextMenu:function(a,b){this.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu"],a,b)},openContextMenu:function(a,b,c){if(a=container.getSharedComponent(a,b))(new a(Ext.applyIf(c||{},{records:b}))).showAt(c.position)}};Ext.namespace("Zarafa.core.data");
Zarafa.core.data.UIFactoryLayer=Ext.extend(Object,{type:"",index:undefined,plugins:undefined,allowModal:false,manager:undefined,constructor:function(a){Ext.apply(this,a)},create:Ext.emptyFn});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},getSessionId:function(){return""},
getFirstName:function(){return this.meta.given_name},getInitials:function(){return this.meta.initials},getLastName:function(){return this.meta.surname},getAddress:function(){return this.meta.street_address},getCity:function(){return this.meta.locality},getState:function(){return this.meta.state_or_province},getZipCode:function(){return this.meta.postal_code},getCountry:function(){return this.meta.country},getTitle:function(){return this.meta.title},getCompany:function(){return this.meta.company_name},
getDepartment:function(){return this.meta.department_name},getOffice:function(){return this.meta.office_location},getAssistant:function(){return this.meta.assistant},getPhone:function(){return this.getPhoneBusiness()},getPhoneBusiness:function(){return this.meta.business_telephone_number||this.meta.office_telephone_number},getPhoneBusiness2:function(){return this.meta.business2_telephone_number},getFax:function(){return this.meta.primary_fax_number},getPhoneAssistant:function(){return this.meta.assistant_telephone_number},
getPhoneHome:function(){return this.meta.home_telephone_number},getPhoneHome2:function(){return this.meta.home2_telephone_number},getPhoneMobile:function(){return this.meta.mobile_telephone_number},getPhonePager:function(){return this.meta.pager_telephone_number}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.Version=Ext.extend(Object,{meta:undefined,constructor:function(a){this.meta=a},getWebApp:function(){return this.meta.webapp},getZCP:function(){return this.meta.zcp},getServer:function(){return this.meta.server},getGit:function(){return this.meta.git},versionCompare:function(a,b){if(a.indexOf("-")>-1)a=a.split("-")[0];if(b.indexOf("-")>-1)b=b.split("-")[0];a=a.split(".");b=b.split(".");for(var c=0;c<a.length;c++){if(!Ext.isDefined(b[c]))return 1;var d=parseInt(a[c],10),e=parseInt(b[c],
10);if(d<e)return-1;else if(d>e)return 1}if(b[a.length])return-1;return 0}});Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.AutoSaveMessagePlugin=Ext.extend(Object,{field:undefined,record:undefined,messageAutoSaveTimer:undefined,constructor:function(a){Ext.apply(this,a)},init:function(a){this.field=a;a.messageAutoSavePlugin=this;this.field.on("render",this.onRender,this)},onRender:function(){this.field.on({setrecord:this.onSetRecord,userupdaterecord:this.onUserUpdateRecord,saverecord:this.onSaveRecord,close:this.onDestroy,destroy:this.onDestroy,scope:this});var a=this.field.find("enableKeyEvents",true);
Ext.each(a,function(b){this.field.mon(b,{keypress:this.onFieldKeyPress,scope:this})},this)},onSetRecord:function(a,b){this.record=b instanceof Zarafa.core.data.IPMRecord?b:undefined},onUserUpdateRecord:function(a,b,c){c&&this.startMessageAutoSaveTimer()},onFieldKeyPress:function(){this.startMessageAutoSaveTimer()},startMessageAutoSaveTimer:function(){if(!this.messageAutoSaveTimer&&this.record&&this.record.isUnsent())this.messageAutoSaveTimer=this.messageAutoSave.defer(container.getSettingsModel().get("zarafa/v1/contexts/mail/autosave_time")*
1E3,this)},resetMessageAutoSaveTimer:function(){if(this.messageAutoSaveTimer){window.clearTimeout(this.messageAutoSaveTimer);this.messageAutoSaveTimer=null}},messageAutoSave:function(){if(this.record){var a=false;this.record.getSubStore("recipients").each(function(b){if(b.resolveAttemptAmbiguous)a=true});if(a){this.resetMessageAutoSaveTimer();this.startMessageAutoSaveTimer()}else this.field.saveRecord()}},onSaveRecord:function(){this.resetMessageAutoSaveTimer()},onDestroy:function(){this.resetMessageAutoSaveTimer();
this.record=undefined}});Ext.preg("zarafa.autosavemessageplugin",Zarafa.core.plugins.AutoSaveMessagePlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.ContentLayerPlugin=Ext.extend(Object,{field:undefined,constructor:function(a){Ext.apply(this,a)},init:function(a){this.field=a;this.field.on("added",this.onAdded,this,{single:true})},initPlugin:function(){this.focus();this.field.on("titlechange",this.onTitleChange,this);this.field.on("iconchange",this.onIconChange,this);this.field.on("hide",this.onHide,this);this.field.on("close",this.onClose,this)},onAdded:function(a,b){b.on("add",this.onContainerAdd,this)},onContainerAdd:function(a,
b){if(this.field===b){a.un("add",this.onContainerAdd,this);this.initPlugin()}},onTitleChange:function(a,b){this.setTitle(b)},onIconChange:function(a,b){this.setIconClass(b)},onHide:function(){this.hide()},onClose:function(){this.close()},setTitle:Ext.emptyFn,setIconClass:Ext.emptyFn,hide:Ext.emptyFn,close:Ext.emptyFn,focus:Ext.emptyFn});Ext.preg("zarafa.contentlayerplugin",Zarafa.core.plugins.ContentLayerPlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.EnableFocusPlugin=Ext.extend(Object,{focusEl:undefined,constructor:function(a){Ext.apply(this,a)},init:function(a){this.field=a;a.enableFocusPlugin=this;this.field.focus=this.field.focus.createInterceptor(this.focus,this);this.field.on("render",this.onRender,this)},focus:function(){if(this.field.rendered&&!this.field.isDestroyed)if(this.focusEl){this.focusEl.focus();return false}return true},onRender:function(){if(this.field){var a=this.field.getEl();this.focusEl=a.createChild({tag:"a",
href:"#",tabindex:-1,style:"position: absolute; left:-10000px; top:-10000px;"});this.focusEl.swallowEvent("click",true);this.field.mon(a,{click:this.onFieldClick,scope:this})}},onFieldClick:function(a,b){var c=Ext.get(document.activeElement),d=Ext.get(b);if(c!=d)this.field.getEl().contains(c)||this.focus()}});Ext.preg("zarafa.enablefocusplugin",Zarafa.core.plugins.EnableFocusPlugin);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)},init:function(a){this.field=a;a.inputAutoFocusPlugin=this;this.field.on("afterrender",this.onAfterRender,this);this.field.on("afterlayout",this.onAfterFirstLayout,this,{single:true});this.field.on("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; left:-10000px; top:-10000px;"},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; left:-10000px; top:-10000px;"},true);this.endFocusEl.dom.innerHTML="&nbsp;";this.endFocusEl.on("focus",
this.onLimitFocussed,this);var a=this.field.findParentByType("window");a&&a.focusEl&&a.focusEl.on("focus",this.onDialogFocussed,this)},onAfterFirstLayout:function(){if(Ext.isDefined(this.field.tabEl))this.field.on("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(){Ext.destroy(this.beginFocusEl);Ext.destroy(this.endFocusEl)},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));if(a){a.focus.defer(1,a);a.events.setAutoFocusCursor&&a.fireEvent("setAutoFocusCursor",a.getEditor())}},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;if(!c)return false;var 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.plugins");
Zarafa.core.plugins.MarkAsReadPlugin=Ext.extend(Object,{field:undefined,record:undefined,readFlagTimer:undefined,ignoreReadFlagTimer:undefined,constructor:function(a){Ext.apply(this,a)},init:function(a){this.field=a;a.markAsReadPlugin=this;this.field.on("render",this.onRender,this);a.addInternalAction&&a.addInternalAction("send_read_receipt")},onRender:function(){this.field.on({setrecord:this.onSetRecord,beforesetrecord:this.onBeforeSetRecord,loadrecord:this.onLoadRecord,close:this.onDestroy,destroy:this.onDestroy,
scope:this})},onSetRecord:function(a,b){this.resetReadFlagTimer();b&&b.isOpened()&&this.onLoadRecord(this.field,this.record)},onBeforeSetRecord:function(a,b){this.resetReadFlagTimer();if(b instanceof Zarafa.core.data.IPMRecord){this.record=b;var c=this.record.getStore();if(Ext.isDefined(c)){this.field.mon(c,"load",this.onStoreLoad,this);this.field.mon(c,"remove",this.onStoreRemove,this)}}else this.record=undefined},onStoreLoad:function(){this.resetReadFlagTimer()},onStoreRemove:function(a,b){this.record===
b&&this.resetReadFlagTimer()},onLoadRecord:function(a,b){if(b&&!b.phantom&&!b.isRead())this.ignoreReadFlagTimer?this.markAsRead():this.startReadFlagTimer()},startReadFlagTimer:function(){if(!this.readFlagTimer)this.readFlagTimer=this.markAsRead.defer(container.getSettingsModel().get("zarafa/v1/contexts/mail/readflag_time")*1E3,this)},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.MenuItemTooltipPlugin=Ext.extend(Object,{constructor:function(a){a=a||{};Ext.apply(this,a)},init:function(a){this.field=a;a.menuItemTooltipPlugin=this;this.field.on("activate",this.applyTooltip,this)},applyTooltip:function(a){if(Ext.isDefined(a.tooltip)){Ext.QuickTips.unregister(a.getEl());if(Ext.isObject(a.tooltip))Ext.QuickTips.register(Ext.apply({target:a.getEl().id},a.tooltip));else a.getEl().dom.qtip=a.tooltip}}});Ext.preg("zarafa.menuitemtooltipplugin",Zarafa.core.plugins.MenuItemTooltipPlugin);
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,isChangedByUser:false,loadTasks:undefined,enableOpenLoadTask:true,autoOpenLoadTaskDefer:0,scheduledTasks:undefined,pendingTasks:undefined,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)},init:function(a){this.field=a;a.recordComponentPlugin=this;this.field.addEvents("beforesetrecord","setrecord","beforeloadrecord","loadrecord","updaterecord","userupdaterecord","exceptionrecord","writerecord");this.field.on("afterlayout",this.onAfterFirstLayout,this,{single:true});this.field.on("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.scheduledTasks){Ext.each(this.scheduledTasks,function(d){d.cancel()});this.scheduledTasks=[]}if(this.pendingTasks)this.pendingTasks=[];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);c=this.loadTasks?this.loadTasks.clone():[];!a.isOpened()&&this.enableOpenLoadTask&&c.push({fn:this.openTaskHandler,scope:this,defer:this.autoOpenLoadTaskDefer});this.doLoadRecord(a,c)}else{this.record=a;this.field.fireEvent("setrecord",this,a,c)}}}},openTaskHandler:function(a,b,c,d){var e=function(f,g){if(this.isRecordInContainer(g)){this.field.mun(f,"open",e,this);this.record!==g&&this.record.applyData(g);d()}};this.field.mon(b.getStore(),
"open",e,this);b.open()},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)}},doLoadRecord:function(a,b){this.pendingTasks=[];this.scheduledTasks=[];if(Ext.isEmpty(b))this.afterLoadRecord(a);else this.field.fireEvent("beforeloadrecord",this.field,a)!==false&&Ext.each(b,function(c){this.pendingTasks.push(c);if(c.defer&&c.defer>0){var d=
new Ext.util.DelayedTask(this.doTask,this,[a,c]);this.scheduledTasks.push(d);d.delay(c.defer)}else this.doTask(a,c)},this)},doTask:function(a,b){if(this.isRecordInContainer(a))b.fn.call(b.scope||b,this.field,a,b,this.doLoadRecordCallback.createDelegate(this,[b]))},doLoadRecordCallback:function(a){var b=this.record;this.pendingTasks.remove(a);if(this.pendingTasks.length===0){this.scheduledTasks=[];this.field.fireEvent("loadrecord",this.field,b);this.afterLoadRecord(b)}},resetUserChangeTracker:function(){this.isChangedByUser=
false;this.field.fireEvent("userupdaterecord",this.field,this.record,this.isChangedByUser)},registerUserChange:function(){if(this.isChangedByUser!==true){this.isChangedByUser=true;this.field.fireEvent("userupdaterecord",this.field,this.record,this.isChangedByUser)}},checkForUserChanges:function(a){var b=a.updateModifications;a=a.updateSubStoreModifications;if(b&&Object.keys(b).length>0||a&&Object.keys(a).length>0)this.registerUserChange()},afterLoadRecord:function(){if(this.ignoreUpdates!==true){this.resetUserChangeTracker();
this.field.mon(this.record.getStore(),{update:this.onUpdateRecord,write:this.onWrite,scope:this})}},onUpdateRecord:function(a,b,c){if(this.isRecordInContainer(b)){if(this.record!==b){if(c!==Ext.data.Record.COMMIT)return;this.record.applyData(b)}if(this.ignoreUpdates!==true)c===Ext.data.Record.COMMIT?this.resetUserChangeTracker():this.checkForUserChanges(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]){b==Ext.data.Api.actions.destroy&&this.resetUserChangeTracker();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.RecordComponentUpdaterPlugin=Ext.extend(Object,{rootContainer:undefined,field:undefined,isReady:false,record:undefined,constructor:function(a){Ext.apply(this,a)},init:function(a){this.field=a;a.recordComponentUpdaterPlugin=this;if(this.rootContainer)this.hookToRootContainer(this.rootContainer);else a.rootContainer?this.hookToRootContainer(a.rootContainer):this.field.on("beforerender",this.onFirstBeforeRender,this,{single:true});if(Ext.isDefined(this.field.layout))this.field.on("afterlayout",this.onReadyComponent,
this,{single:true});else this.field.rendered!==true?this.field.on("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,{activate:this.onActivateRoot,setrecord:this.onSetRecord,loadrecord:this.onLoadRecord,updaterecord:this.onUpdateRecord,exceptionrecord:this.onExceptionRecord,beforesaverecord:this.onBeforeSaveRecord,beforesendrecord:this.onBeforeSendRecord,
beforeclose:this.onBeforeClose,deactivate:this.onDeactivate,scope: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},onActivateRoot:function(){this.record&&this.isReady===true&&this.field.isDestroyed!==true&&this.field.update(this.record,true)},
onSetRecord:function(a,b){this.record=b;this.isReady===true&&this.field.update(b,true)},onLoadRecord: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},onBeforeSendRecord:function(a,b){if(this.isReady===true&&this.field.isDestroyed!==true)if(Ext.isFunction(this.field.updateRecord))return this.field.updateRecord(b);return true},onBeforeClose:function(){if(this.isReady===true&&this.field.isDestroyed!==true)if(this.record&&Ext.isFunction(this.field.updateRecord))return this.field.updateRecord(this.record);
return true},onDeactivate:function(){if(this.isReady===true&&this.field.isDestroyed!==true)if(this.record&&Ext.isFunction(this.field.updateRecord))return this.field.updateRecord(this.record);return true}});Ext.preg("zarafa.recordcomponentupdaterplugin",Zarafa.core.plugins.RecordComponentUpdaterPlugin);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.ContentPanelToolbar=Ext.extend(Zarafa.core.ui.Toolbar,{insertionPointBase:undefined,actionItems:[],optionItems:[],constructor:function(a){Ext.apply(this,a,{xtype:"zarafa.contentpaneltoolbar",cls:"zarafa-dialogtoolbar"});this.addEvents("window_before_pop");Zarafa.core.ui.ContentPanelToolbar.superclass.constructor.call(this,a);this.initButtonGroups()},initButtonGroups:function(){var a=this.insertionPointBase+".toolbar";this.addItems(this.actionItems,a+".actions");this.addItems(this.optionItems,
a+".options")}});Ext.reg("zarafa.contentpaneltoolbar",Zarafa.core.ui.ContentPanelToolbar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.ContextContainer=Ext.extend(Zarafa.core.ui.SwitchViewContentContainer,{name:undefined,title: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});
this.addEvents("titlechange","iconchange");Zarafa.core.ui.ContextContainer.superclass.constructor.call(this,a);this.init()},init:function(){this.mon(container,"contextswitch",this.onContextSwitch,this);this.mon(container,"folderselect",this.onFolderSelect,this);var a=container.getCurrentContext().getModel(),b,c;if(a){if(a=a.getDefaultFolder()){b=a.getFullyQualifiedDisplayName();c=Zarafa.common.ui.IconClass.getIconClass(a)}}else b=container.getCurrentContext().getDisplayName();this.setTitle(b);this.setIcon(c)},
setTitle:function(a){var b=this.title;this.title=a;this.fireEvent("titlechange",this,a,b)},setIcon:function(a){var b=this.iconCls;this.iconCls=a;this.fireEvent("iconchange",this,a,b)},onContextSwitch:function(a,b,c){b=this.getActiveItem();a=this.findBy(function(f){return f.context===c});var d=true;if(Ext.isEmpty(a))d=false;else{a=a[0];this.layout.setActiveItem(a.id)}this.isVisible()!=d&&this.setVisible(d);if(this.autoClean===true&&b&&b!=a){this.remove(b);delete b}b=c.getModel();var e;if(b)e=b.getDefaultFolder();
if(e){b=e.getFullyQualifiedDisplayName();e=Zarafa.common.ui.IconClass.getIconClass(e)}else{b=a.title;e=a.iconCls}this.setTitle(b);this.setIcon(e)},onFolderSelect:function(a){var b;if(a){b=Ext.isArray(a)?a[0]:a;a=b.getFullyQualifiedDisplayName();b=Zarafa.common.ui.IconClass.getIconClass(b)}else a=container.getCurrentContext().getDisplayName();this.setTitle(a);this.setIcon(b);this.ownerCt.setActiveTab(0)}});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",id:"zarafa-maintoolbar",cls:"zarafa-maintoolbar"});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)||[];b=Zarafa.core.Util.sortArray(b,"ASC","newMenuIndex");b=Zarafa.core.Util.uniqueArray(b,"text");if(b.length!==0){b[0].hidden=true;b[0].ref="defaultButton";a.push({xtype:"menuitem",id:"zarafa-maintoolbar-newitem-defaultbutton",tooltip:b[0].tooltip,plugins:"zarafa.menuitemtooltipplugin",iconCls:b[0].iconCls,text:b[0].text,handler:b[0].handler,scope:b[0].scope},"-")}if(b.length!==0)a=a.concat(b);this.addItems({xtype:"splitbutton",id:"zarafa-maintoolbar-newitem",cls:"zarafa-action",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 i=a.items.itemAt(e);if(f===false&&i.context==c.getName()){f=i;i.setVisible(false)}else i.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.tooltip=f.tooltip;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",id:"zarafa-maintoolbar-view-"+f.getName(),scale:"large",iconCls:"view_icon",tooltip:_("Switch view")+" (Ctrl + Alt + 1..9)",hidden:true,contextName:f.getName(),menu:Zarafa.core.Util.uniqueArray(a,"text"),listeners:{render:this.onRenderViewButton}});else for(var g=0,i=a.length;g<i;g++){var h=Ext.apply({},a[g],{xtype:"button",scale:"large",hidden:true,contextName:f.getName()});h.tooltip=h.text+" (Ctrl + Alt + "+
(g+1)+")";delete h.text;h.listeners=Zarafa.core.Util.mergeListeners(h.listeners,{render:this.onRenderViewButton});b.push(h)}}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",id:"zarafa-maintoolbar-print-"+f.getName(),scale:"large",iconCls:"icon_print",tooltip:_("Print")+" (Ctrl + P)",handler:a[0].handler,scope:a[0].scope,hidden:true,contextName:f.getName(),menu:{xtype:"zarafa.conditionalmenu",defaults:{context:f,getRecords:function(){return this.context.getModel().getSelectedRecords()}},items:Zarafa.core.Util.uniqueArray(a,"text"),onMenuHide:Ext.emptyFn},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",id:"zarafa-maintoolbar-addressbook",scale:"large",overflowText:_("Address Book"),tooltip:_("Address Book"),iconCls:"icon_addressbook",handler:this.onAddressBook,scope:this});a.push({xtype:"button",id:"zarafa-maintoolbar-refresh",scale:"large",title:_("Refresh"),overflowText:_("Refresh"),tooltip:_("Refresh")+
" (F5)",iconCls:"x-tbar-loading",handler:this.onRefresh,ref:"refreshButton",scope:this,listeners:{render:this.onRenderRefreshButton,scope:this}});a.push({hidden:true,xtype:"button",scale:this.enableSearchButton?"small":"large",text:_("Advanced find"),overflowText:_("Advanced find"),iconCls:"icon_advanced_find"});this.addItems(a,"main.toolbar.actions")},onAddressBook:function(){Zarafa.addressbook.Actions.openAddressBook()},onRefresh:function(){var a=container.getCurrentContext().getModel();a&&a.reload()},
onPrint:function(){var a=container.getCurrentContext();a&&Zarafa.common.Actions.openPrintDialog(a)},onRenderRefreshButton:function(a){var b=container.getCurrentContext();a.mon(container,"contextswitch",function(c,d,e){c=e.getModel().getStore();this.setVisible(Ext.isDefined(c))},a);b=b.getModel();a.setVisible(Ext.isDefined(b)&&Ext.isDefined(b.getStore()))}});Ext.reg("zarafa.maintoolbar",Zarafa.core.ui.MainToolbar);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.NavigationPanel=Ext.extend(Zarafa.core.ui.MainViewSidebar,{centerPanel: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:{type:"card",deferredRender:true},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"},id:"zarafa-navigationpanel",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.showFolderList=container.getSettingsModel().get("zarafa/v1/state/sidebars/hierarchytree/showallcheckbox")||false},getAllFoldersPanel:function(){return{xtype:"zarafa.contextnavigation",ownerTitle:_("Folders List"),cls:"zarafa-navigationpanel-centerpanel-allfolders",items:[{layout:"fit",cls:"zarafa-context-navigation-block",items:this.getFolderListPanel()}]}},
getFolderListPanel:function(){return{xtype:"zarafa.hierarchytreepanel",enableDD:true,enableItemDrop:true,showAllFoldersDefaultValue:true,deferredLoading:true}},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)}var d=this.centerPanel,e=d.getLayout(),f=false;if(!this.showFolderList){a=0;for(b=d.items.length;a<b;a++){c=d.items.itemAt(a);if(c.getContext()==this.activeContext){if(Ext.isFunction(e.setActiveItem))e.setActiveItem(a);else d.activeItem=a;f=true;break}}}if(!f)if(Ext.isFunction(e.setActiveItem))e.setActiveItem(0);else d.activeItem=0},setShowFolderList:function(a){if(this.showFolderList!==a){this.showFolderList=a;this.toggleVisibilityNavigationComponents();
this.doLayout();this.fireEvent("toggleshowallfolders",this.showFolderList)}},initEvents:function(){this.activeContext=container.getCurrentContext();this.mon(container,"contextswitch",this.onContextSwitch,this);this.onContextSwitch(null,this.activeContext,this.activeContext);this.on("resize",this.onResizePanel,this);Zarafa.core.ui.NavigationPanel.superclass.initEvents.apply(this,arguments)},onResizePanel:function(){this.doLayout()},saveState:function(){container.getCurrentContext().getName()!=="settings"&&
Zarafa.core.ui.NavigationPanel.superclass.saveState.apply(this)}});Ext.reg("zarafa.navigationpanel",Zarafa.core.ui.NavigationPanel);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.RecordContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{autoSave:true,recordComponentPluginConfig:undefined,record:undefined,modalRecord:undefined,recordComponentPlugin:undefined,showLoadMask:true,loadMask:undefined,showInfoMask:true,savingText:{msg:_("Saving")+"..."},savingDoneText:{title:_("Saved"),msg:_("Saved successfully")},internalActions:undefined,isSaving:false,savingEl:undefined,closeOnSave:false,confirmClose:false,removeRecordOnCancel:false,showLoadMaskOnStart:false,showModalWithoutParent:false,
constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Zarafa Content Panel")});if(a.recordComponentPluginConfig&&a.recordComponentPluginConfig.allowWrite&&a.modal)a.recordComponentPluginConfig.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(Ext.applyIf(a.recordComponentPluginConfig||{},{ptype:"zarafa.recordcomponentplugin"}));a.plugins.push({ptype:"zarafa.recordcomponentupdaterplugin"});
this.addEvents("beforesaverecord","saverecord","aftersaverecord");this.internalActions=[];Zarafa.core.ui.RecordContentPanel.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)},initEvents:function(){this.mon(this,{setrecord:this.onSetRecord,beforeloadrecord:this.onBeforeLoadRecord,loadrecord:this.onLoadRecord,
updaterecord:this.onUpdateRecord,writerecord:this.onWriteRecord,exceptionrecord:this.onExceptionRecord,afterlayout:this.onAfterLayout,scope: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(){if(this.showInfoMask!==false)this.savingEl=container.getNotifier().notify("info.saving",
this.savingText.title,this.savingText.msg,{container:this.getEl(),persistent:true})},hideInfoMask:function(a){if(this.showInfoMask!==false)if(this.savingEl){container.getNotifier().notify("info.saving",null,null,{container:this.getEl(),destroy:true,reference:this.savingEl});delete this.savingEl;a!==false&&container.getNotifier().notify("info.saved",this.savingDoneText.title,this.savingDoneText.msg)}},setRecord:function(a){var b;if(this.recordComponentPlugin){if(this.recordComponentPlugin.allowWrite===
true){if(a.phantom===true&&Ext.isDefined(a.store)&&a.store.isSaving){if(this.el)this.displayLoadMask();else this.showLoadMaskOnStart=true;a.store.on("save",Ext.createDelegate(this.onStoreSave,this,[a]),this,{single:true});return}if(this.isModal()&&!this.showModalWithoutParent){this.modalRecord=a;a=a.copy("modal-"+a.id);b=true}}this.recordComponentPlugin.setRecord(a,b)}},onStoreSave:function(a){this.showLoadMaskOnStart=false;this.el&&this.hideLoadMask();this.setRecord(a)},saveRecord:function(a){if(this.recordComponentPlugin.allowWrite===
false||this.isSaving===true)return false;if(this.fireEvent("beforesaverecord",this,this.record)===false)return false;if(!this.record.isValid())return false;this.fireEvent("saverecord",this,this.record);Ext.isDefined(this.modalRecord)&&this.modalRecord.applyData(this.record);if(a!==false){a=this.modalRecord||this.record;if(a.getStore().modified.indexOf(a)<0)this.closeOnSave===true&&this.close();else a.save()}},deleteRecord:function(){if(this.recordComponentPlugin.allowWrite!==false)this.recordComponentPlugin.isChangedByUser===
true?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("This item has been changed. Are you sure you want to delete it?"),this.onConfirmDelete,this):Zarafa.common.Actions.deleteRecords(this.modalRecord||this.record)},onConfirmDelete:function(a){if(a==="yes")Zarafa.common.Actions.deleteRecords(this.modalRecord||this.record)},onAfterLayout:function(){this.showLoadMaskOnStart===true&&this.displayLoadMask()},onSetRecord:function(a,b){if(b){this.record=b;this.mon(this.record.getStore(),"beforesave",this.onBeforeSaveRecord,
this)}},onBeforeLoadRecord:function(){this.displayLoadMask()},onLoadRecord:function(){this.hideLoadMask()},onBeforeSaveRecord:function(a,b){if(b&&(b.update&&b.update.indexOf(this.record)>=0||b.create&&b.create.indexOf(this.record)>=0)){this.isSaving=true;this.hasInternalAction()||this.displayInfoMask()}},onUpdateRecord:function(a,b){if(this.isSaving===true&&b==Ext.data.Record.COMMIT){this.hasInternalAction()||this.hideInfoMask(true);this.isSaving=false;this.fireEvent("aftersaverecord",this,this.record);
if(this.closeOnSave){this.close();return false}}},onExceptionRecord:function(a,b){if(!this.hasInternalAction())if(b==="open")this.displayLoadMask(true);else{this.hideInfoMask(false);this.isSaving=false}},onOk:function(){this.saveRecord(this.autoSave)!==false&&this.closeOnSave!==true&&this.close()},onCancel:function(){this.removePhantomRecord();this.close()},closeWrap:function(){this.removePhantomRecord();Zarafa.core.ui.RecordContentPanel.superclass.closeWrap.apply(this,arguments)},removePhantomRecord:function(){if(!this.removeRecordOnCancel)return false;
var a=this.modalRecord;if(a){var b=a.getStore();b&&b.remove(a)}},onWriteRecord:function(a,b){if(b==Ext.data.Api.actions.destroy){this.close();return false}},doClose:function(){this.confirmClose&&this.recordComponentPlugin.isChangedByUser===true?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("You are going to lose all unsaved changes. Are you sure you want to close this window?"),this.onConfirmClose,this):Zarafa.core.ui.RecordContentPanel.superclass.doClose.call(this)},onConfirmClose:function(a){if(a===
"yes"){this.record.reject();Zarafa.core.ui.RecordContentPanel.superclass.doClose.call(this)}},update:Ext.emptyFn,addInternalAction:function(a){this.internalActions.push(a)},deleteInternalAction:function(a){this.internalActions.splice(this.internalActions.indexOf(a),1)},getInternalActions:function(){return this.internalActions},hasInternalAction:function(){var a=false,b=this.record.getMessageActions(),c=this.getInternalActions();Ext.iterate(b,function(d){if(c.indexOf(d)>-1){a=true;return false}},this);
return a}});Ext.reg("zarafa.recordcontentpanel",Zarafa.core.ui.RecordContentPanel);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(/\./g,"/")+(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){a=a.toLowerCase();var e=this.getPlugin(a);if(e)return e.notify(a,b,c,d)}});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.SliderContainer=Ext.extend(Object,{parentContainer:undefined,containerCls:"zarafa-notifier-container",itemCls:"zarafa-notifier-container-item",containerPosition:"t",slideinDirection:"t",slideoutDirection:"t",animatedContainerResize:false,container:undefined,pendingMessages:undefined,stackedMessages:undefined,animating:false,constructor:function(a){Ext.apply(this,a);this.container=this.getContainer();this.pendingMessages=[];this.stackedMessages=[];if(!Ext.isDefined(a.animatedContainerResize))this.animatedContainerResize=
this.slideinDirection!=="t"},createMessage:function(a,b){var c=Ext.DomHelper.append(this.container,{html:a,cls:this.itemCls,style:"visibility: hidden;"},true);this.pendingMessages.push(c);c.timeout=b;c.slider=this;this.showNextMessage();return c},updateMessage:function(a,b){a.dom.innerHTML=b;return a},removeMessage:function(a){this.animating=true;this.stackedMessages.indexOf(a)>=0&&a.ghost(this.slideoutDirection,{remove:true,callback:this.onRemoveComplete.createDelegate(this,[a]),scope:this})},showNextMessage:function(){var a=
this.pendingMessages[0],b=a.getHeight(),c=this.container.getHeight(),d=this.parentContainer.getHeight();if(d===0&&this.parentContainer.dom.tagName==="BODY")d=document.height;if(!(this.animating||c+b>d)){this.animating=true;this.updateContainer(c+b,this.animatedContainerResize);a.height=b;this.pendingMessages.remove(a);this.stackedMessages.push(a);this.animMessage(a)}},animMessage:function(a){a=a.slideIn(this.slideinDirection,{callback:this.onShowComplete,scope:this});Ext.isNumber(a.timeout)&&a.pause(a.timeout,
{callback:this.onPauseComplete,scope:this}).ghost(this.slideoutDirection,{remove:true,callback:this.onRemoveComplete.createDelegate(this,[a]),scope:this})},onShowComplete:function(){this.animating=false;!Ext.isEmpty(this.pendingMessages)&&this.parentContainer.dom&&this.showNextMessage()},onPauseComplete:function(){this.animating=true},onRemoveComplete:function(a){var b=this.container.getHeight()-a.height;a=this.stackedMessages.indexOf(a);if(!(a<0)){this.stackedMessages.splice(a,1);this.animating=
false;if(b<0)b=0;if(this.parentContainer.dom){this.updateContainer(b,false);Ext.isEmpty(this.pendingMessages)||this.showNextMessage()}}},getContainer:function(){var a=this.containerCls+" "+this.containerCls+"-"+this.containerPosition,b=this.parentContainer.id+"-"+this.containerCls+"-"+this.containerPosition,c=Ext.DomQuery.select("#"+b).shift();if(c)c=Ext.get(c);else{c=Ext.DomHelper.insertFirst(this.parentContainer,{id:b,cls:a},true);c.setHeight(0);c.alignTo(this.parentContainer,this.containerPosition)}return c},
updateContainer:function(a,b){var c=this.containerPosition+"-"+this.containerPosition;this.container.setHeight(a);this.container.alignTo(this.parentContainer,c,undefined,b)}});Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.WidgetContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{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=[],d=container.getWidgetsMetaData();Ext.each(d,function(e){c.push({name:e.getName(),display_name:e.getDisplayName(),icon:e.getIconPath()})},this);
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.WidgetContentPanel.superclass.constructor.call(this,a)},onWidgetDblClick:function(a,b,c){this.widgetPanel&&this.widgetPanel.createWidget(a.getRecord(c).get("name"))}});Ext.reg("zarafa.widgetcontentpanel",Zarafa.core.ui.widget.WidgetContentPanel);Ext.namespace("Zarafa.core.ui.widget");
Zarafa.core.ui.widget.WidgetMetaData=Ext.extend(Object,{name:"",displayName:"",iconCls:"",iconPath:"",about:undefined,widgetConstructor:undefined,constructor:function(a){a=a||{};Ext.apply(this,a);Zarafa.core.ui.widget.WidgetMetaData.superclass.constructor.call(this,a);if(Ext.isEmpty(this.displayName))this.displayName=this.name},getName:function(){return this.name},getDisplayName:function(){return this.displayName},getIconCls:function(){return this.iconCls},getIconPath:function(){return this.iconPath},
getAbout:function(){return this.about},getInstance:function(a){return new this.widgetConstructor(Ext.apply({info:this},a))}});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.common.Actions.openWidgetsContent({widgetPanel:this,manager:Ext.WindowMgr})}}];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.getWidgetMetaDataByName(e)){e=e.getInstance({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],b%3)},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,b){var c=container.getWidgetMetaDataByName(a);Ext.isDefined(b)||(b=0);if(c){var d=Zarafa.generateId(32);this.addGuid(d);c=c.getInstance({widgetPanel:this,guid:d});c.set("__name",a);this.portal.get(b).add(c);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.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachItemBaseRenderer=Ext.extend(Object,{labels:undefined,htmlTemplate:undefined,plainTemplate:undefined,constructor:function(){this.labels=Ext.apply({},{subject:_("Subject"),display_to:_("To"),display_cc:_("Cc"),display_bcc:_("Bcc"),from:_("From"),categories:_("Categories"),sensitivity:_("Sensitivity"),importance:_("Importance"),attachment_names:_("Attachments")})},generateText:function(a,b){var c;if(b){if(!this.htmlTemplate)this.htmlTemplate=new Ext.XTemplate(this.cleanTemplate(this.generateHTMLTemplate()));
c=this.htmlTemplate}else{if(!this.plainTemplate)this.plainTemplate=new Ext.XTemplate(this.generatePlainTemplate());c=this.plainTemplate}c=c.apply(this.prepareData(a,b));if(!Ext.isEmpty(c.trim())&&b){c=c.replace(/(<hr width=\'100%\'>)*$/gi,"");var d="<blockquote style='border-left: 2px solid #325FBA; padding-left: 5px; margin-left: 10px; margin-top: 10px;'>";d+=c;d+="</blockquote><br>";c=d}return c},addPlainRowGroup:function(a){var b="";Ext.iterate(a,function(c,d){if(Ext.isObject(d)){b+='<tpl if="!Ext.isEmpty(values.'+
c+')">';b+=this.addPlainRowGroup(d);b+="</tpl>"}else b+=this.addPlainRow(c,d)},this);b+=this.addPlainSeperator(a);return b},addPlainRow:function(a,b){var c="";c+='<tpl if="!Ext.isEmpty(values.'+a+')">';c+=this.getLabel(a)+" : \t"+b+"\n";c+="</tpl>";return c},addPlainSeperator:function(a){if(a){var b="",c=false;Ext.iterate(a,function(d,e){if(Ext.isObject(e)){c=true;return false}else b+=(Ext.isEmpty(b)?"":" || ")+"!Ext.isEmpty(values."+d+")"});a="";if(c!==true){a+='<tpl if="'+b+'">';a+="\n";a+="</tpl>"}return a}return"\n"},
addHTMLRowGroup:function(a){var b="";Ext.iterate(a,function(c,d){if(Ext.isObject(d)){b+='<tpl if="!Ext.isEmpty(values.'+c+')">';b+=this.addHTMLRowGroup(d);b+="</tpl>"}else b+=this.addHTMLRow(c,d)},this);b+=this.addHTMLSeperator(a);return b},addHTMLRow:function(a,b){var c="";c+='<tpl if="!Ext.isEmpty(values.'+a+')">';c+="<div width='100%'><div style=\"display: inline-block; width: 20%;\"><strong>"+this.getLabel(a)+' :</strong></div><div style="display: inline-block; width: 80%">'+b+"</div></div>";
c+="</tpl>";return c},addHTMLSeperator:function(a){if(a){var b="",c=false;Ext.iterate(a,function(d,e){if(Ext.isObject(e)){c=true;return false}else b+=(Ext.isEmpty(b)?"":" || ")+"!Ext.isEmpty(values."+d+")"});a="";if(c!==true){a+='<tpl if="'+b+'">';a+="<hr width='100%'>";a+="</tpl>"}return a}return"<hr width='100%'>"},cleanTemplate:function(a){return a.replace(/\r/g,"").replace(/\\/g,"\\\\")},generateHTMLTemplate:Ext.emptyFn,generatePlainTemplate:Ext.emptyFn,getLabel:function(a){return this.labels[a]},
prepareData:function(a,b){var c=Ext.apply({},a.data);c.sensitivity===Zarafa.core.mapi.Sensitivity.NONE&&delete c.sensitivity;c.importance===Zarafa.core.mapi.Importance.NORMAL&&delete c.importance;c.from=a.getSenderString();c.attachment_names=a.getAttachmentNames();c.body=a.getBody(b);return c}});Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachItemContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{last_selected_folder:undefined,last_selected_radio:undefined,record:undefined,editor:undefined,loadMask:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Insert item"),layout:"fit",items:[{xtype:"zarafa.attachitempanel",record:a.record,editor:a.editor}]});Zarafa.common.attachment.dialogs.AttachItemContentPanel.superclass.constructor.call(this,a)},getSelectedFolder:function(){if(!this.last_selected_folder)this.last_selected_folder=
container.getHierarchyStore().getDefaultFolder("inbox");return this.last_selected_folder},getSelectedRadioItem:function(){if(!this.last_selected_radio)this.last_selected_radio="attachment";return this.last_selected_radio},setFolderInState:function(a){this.last_selected_folder=a;this.stateful!==false&&this.saveState()},setRadioItemInState:function(a){this.last_selected_radio=a.inputValue;this.stateful!==false&&this.saveState()},getState:function(){var a=Zarafa.common.attachment.dialogs.AttachItemContentPanel.superclass.getState.call(this);
if(this.last_selected_folder)a.last_selected_folder=this.last_selected_folder.get("entryid");if(this.last_selected_radio)a.last_selected_radio=this.last_selected_radio;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}delete a.last_selected_radio;Zarafa.common.attachment.dialogs.AttachItemContentPanel.superclass.applyState.call(this,a)},showLoadMask:function(){if(!this.loadMask)this.loadMask=
new Zarafa.common.ui.LoadMask(this.el);this.loadMask.show()},hideLoadMask:function(){this.loadMask&&this.loadMask.hide()},getStoreByFolder:function(a){var b=container.getContextByFolder(a).getModel().getStore();b||(b=new Zarafa.mail.MailStore);return b=new b.constructor({standalone:true,folder:a,autoDestroy:true})},getColumnModelByFolder:function(a){return new (container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"],a))},getRendererByMessage:function(a){return new (container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"],
a))}});Ext.reg("zarafa.attachitemcontentpanel",Zarafa.common.attachment.dialogs.AttachItemContentPanel);Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.AttachItemGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.attachitemgrid",border:true,colModel:this.initColumnModel(),selModel:this.initSelectionModel(),store:new Zarafa.core.data.ListModuleStore,loadMask:true,tbar:[{xtype:"displayfield",value:_("Items:"),hideLabel:true},"->",{xtype:"zarafa.paging",pageSize:50,store:new Zarafa.core.data.ListModuleStore}],listeners:{reconfigure:this.onGridReconfigure,rowdblclick:this.onRowDblClick,
scope:this}});Zarafa.common.attachment.dialogs.AttachItemGrid.superclass.constructor.call(this,a)},initColumnModel:function(){return new Zarafa.common.ui.grid.ColumnModel},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:true})},onStoreLoad:function(){this.getSelectionModel().selectFirstRow()},onGridReconfigure:function(a,b){this.getTopToolbar().findByType("zarafa.paging")[0].bindStore(b);this.mon(b,"load",this.onStoreLoad,this)},onRowDblClick:function(){this.ownerCt.attachItem()}});
Ext.reg("zarafa.attachitemgrid",Zarafa.common.attachment.dialogs.AttachItemGrid);Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.LegacyFileSelectionContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{callback:Ext.emptyFn,scope:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Select file"),layout:"fit",width:500,height:75,items:[{xtype:"form",layout:"fit",fileUpload:true,padding:5,items:[{xtype:"fileuploadfield",buttonText:_("Browse")+"...",name:"attachments[]",listeners:{fileselected:this.onFileSelected,scope:this}}],buttons:[{text:_("Cancel"),handler:this.close,scope:this}]}]});
Zarafa.common.attachment.dialogs.LegacyFileSelectionContentPanel.superclass.constructor.call(this,a)},onFileSelected:function(a){a=a.ownerCt.getForm();this.hide();this.callback.call(this.scope,a);a.on("actioncomplete",this.close,this,{delay:5});a.on("actionfailed",this.close,this,{delay:5})}});Ext.reg("zarafa.legacyfileselectioncontentpanel",Zarafa.common.attachment.dialogs.LegacyFileSelectionContentPanel);Ext.namespace("Zarafa.common.attachment.dialogs");
Zarafa.common.attachment.dialogs.MixAttachItemContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.mixattachitemcontentpanel",layout:"fit",title:_("Download as ZIP"),width:400,height:250,items:[{xtype:"zarafa.mixattachitempanel",records:a.record,ref:"mixAttachItemPanel",buttons:[{text:_("Continue"),handler:this.onContinue.createDelegate(this,[a.downloadItem],1),scope:this},{text:_("Cancel"),ref:"../../dialogCancelButton",handler:this.onCancel,
scope:this}]}]});Zarafa.common.attachment.dialogs.MixAttachItemContentPanel.superclass.constructor.call(this,a);this.mon(this.dontShowCheckBox,"check",this.onDontShowCheck,this)},onContinue:function(a,b){if(!Ext.isEmpty(this.record)){this.saveState();b.call()}this.close()},onCancel:function(){this.close()},onDontShowCheck:function(a,b){this.dialogCancelButton.setDisabled(b)},getState:function(){var a=Zarafa.common.attachment.dialogs.MixAttachItemContentPanel.superclass.getState.call(this)||{},b=this.dontShowCheckBox.getValue();
return Ext.apply(a,{dontshowagain:b})}});Ext.reg("zarafa.mixattachitemcontentpanel",Zarafa.common.attachment.dialogs.MixAttachItemContentPanel);Ext.namespace("Zarafa.common.attachment.ui");
Zarafa.common.attachment.ui.AttachmentBox=Ext.extend(Zarafa.common.ui.Box,{validCls:"x-zarafa-boxfield-attachment-item-uploaded",invalidCls:"x-zarafa-boxfield-attachment-item-invalid",uploadingCls:"x-zarafa-boxfield-attachment-item-uploading",constructor:function(a){a=a||{};Ext.applyIf(a,{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) && values.size &gt; 0">&nbsp;({values.size:fileSize})</tpl>'});
Zarafa.common.attachment.ui.AttachmentBox.superclass.constructor.call(this,a)},isValidRecord:function(a){return a.isUploaded()},update:function(a){Zarafa.common.attachment.ui.AttachmentBox.superclass.update.apply(this,arguments);if(this.isValidRecord(a)){this.el.removeClass(this.uploadingCls);this.el.removeClass(this.invalidCls);this.el.addClass(this.validCls)}else{if(a.attemptedToUpload()){this.el.removeClass(this.uploadingCls);this.el.addClass(this.invalidCls)}else{this.el.addClass(this.uploadingCls);
this.el.removeClass(this.invalidCls)}this.el.removeClass(this.validCls)}}});Ext.reg("zarafa.attachmentbox",Zarafa.common.attachment.ui.AttachmentBox);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(){return[{text:_("Preview"),iconCls:"icon_attachment_preview",scope:this,handler:this.onPreviewItem,beforeShow:this.onPreviewBeforeShow},{text:_("Download"),iconCls:"icon_saveaseml",scope:this,handler:this.onDownloadItem,beforeShow:this.onDownloadBeforeShow},{text:_("Download all as ZIP"),iconCls:"icon_saveemlaszip",scope:this,handler:this.onDownloadAllAsZip,beforeShow:this.onDownloadZipBeforeShow}]},
onPreviewBeforeShow:function(a,b){var c=container.getSharedComponent(Zarafa.core.data.SharedComponentType["common.view"],b);c=(c=!c||c instanceof Zarafa.common.CommonContext)||b.isEmbeddedMessage();a.setDisabled(c)},onDownloadBeforeShow:function(a,b){a.setDisabled(b.isEmbeddedMessage())},onDownloadZipBeforeShow:function(a,b){var c=0;b.store.getCount()>1&&b.store.each(function(d){d.get("hidden")||c++});a.setDisabled(b.isEmbeddedMessage()||c<=1)},onPreviewItem:function(){Zarafa.core.data.UIFactory.openViewRecord(this.records)},
onDownloadItem:function(){Zarafa.common.Actions.downloadAttachment(this.records)},onDownloadAllAsZip:function(){Zarafa.common.Actions.downloadAttachment(this.records,true)}});Ext.reg("zarafa.attachmentcontextmenu",Zarafa.common.attachment.ui.AttachmentContextMenu);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,height:25,boxMinHeight:25,boxMaxHeight:75});a.wrapCls=a.wrapCls?a.wrapCls+" zarafa-attachmentfield":"zarafa-attachmentfield";Zarafa.common.attachment.ui.AttachmentField.superclass.constructor.call(this,a);this.on("boxdblclick",this.onBoxDblClick,this);this.on("boxcontextmenu",this.onBoxContextMenu,this)},onRender:function(){Zarafa.common.attachment.ui.AttachmentField.superclass.onRender.apply(this,
arguments);this.el.addClass("x-hidden");this.wrap.on("dragover",this.onBrowserDragOver,this);this.wrap.on("dragleave",this.onBrowserDragLeave,this);this.wrap.on("drop",this.onBrowserDrop,this)},onBrowserDragOver:function(a){if(this.editable){a.stopPropagation();a.preventDefault();this.wrap.addClass(this.wrapFocusClass)}},onBrowserDragLeave:function(a){if(this.editable){a.stopPropagation();a.preventDefault();this.wrap.removeClass(this.wrapFocusClass)}},onBrowserDrop:function(a){if(this.editable){a.stopPropagation();
a.preventDefault();this.wrap.removeClass(this.wrapFocusClass);a=a.browserEvent.target.files||a.browserEvent.dataTransfer.files;this.boxStore.canUploadFiles(a,{container:this.recordComponentUpdaterPlugin.rootContainer.getEl()})&&this.boxStore.uploadFiles(a)}},setAttachmentStore:function(){return this.setBoxStore.apply(this,arguments)},getAttachmentStore:function(){return this.getBoxStore()},update:function(a,b){if(a&&a instanceof Zarafa.core.data.MAPIRecord)b&&a.isOpened()&&this.setAttachmentStore(a.getAttachmentStore());
else Zarafa.common.attachment.ui.AttachmentField.superclass.update.apply(this,arguments)},filterRecord:function(a){return a.get("hidden")!==true},onBoxDblClick:function(a,b,c){Zarafa.common.Actions.openAttachmentRecord(c)},onBoxContextMenu:function(a,b,c){Zarafa.core.data.UIFactory.openDefaultContextMenu(c,{position:b.getEl().getXY()})}});Ext.reg("zarafa.attachmentfield",Zarafa.common.attachment.ui.AttachmentField);Ext.namespace("Zarafa.common.categories.dialogs");
Zarafa.common.categories.dialogs.CategoriesContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{record:undefined,autoSave:true,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.categoriescontentpanel",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.CategoriesContentPanel.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()}});Ext.reg("zarafa.categoriescontentpanel",Zarafa.common.categories.dialogs.CategoriesContentPanel);Ext.namespace("Zarafa.common.checknames.dialogs");
Zarafa.common.checknames.dialogs.CheckNamesContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{checkNamesData:undefined,record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.checknamescontentpanel",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.CheckNamesContentPanel.superclass.constructor.call(this,
a)},onRender:function(){Zarafa.common.checknames.dialogs.CheckNamesContentPanel.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()}});Ext.reg("zarafa.checknamescontentpanel",Zarafa.common.checknames.dialogs.CheckNamesContentPanel);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,batch:false,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.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.dialogs");
Zarafa.common.dialogs.CopyMoveContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{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.copymovecontentpanel",useInputAutoFocusPlugin:false,
layout:"fit",title:b,width:400,height:350,cls:"copymove-panel",items:[{xtype:"zarafa.copymovepanel",record:a.record,objectType:c}]});Zarafa.common.dialogs.CopyMoveContentPanel.superclass.constructor.call(this,a)},getSelectedFolder:function(){if(!this.last_selected_folder&&!Ext.isEmpty(this.record)){var a=container.getHierarchyStore(),b=this.record[0];if(b.get("container_class"))this.last_selected_folder=a.getDefaultFolderFromContainerClass(b.get("container_class"));else if(b.get("message_class"))this.last_selected_folder=
a.getDefaultFolderFromMessageClass(b.get("message_class"))}return this.last_selected_folder},selectFolder:function(a){this.last_selected_folder=a;this.stateful!==false&&this.saveState()},getState:function(){var a=Zarafa.common.dialogs.CopyMoveContentPanel.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.CopyMoveContentPanel.superclass.applyState.call(this,a)}});Ext.reg("zarafa.copymovecontentpanel",Zarafa.common.dialogs.CopyMoveContentPanel);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.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,i,h){return new Zarafa.common.freebusy.data.FreebusyResponseHandler({proxy:this,action:c,reader:f,options:h,callback:g,scope:i})}});
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.openDetailsContent,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.core.data.UIFactory.openCreateRecord(this.records)},openDetailsContent:function(){Zarafa.common.Actions.openViewRecipientContent(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.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.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.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.on("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.on("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.un("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.ns("Zarafa.common.plugins");
Zarafa.common.plugins.NumberSpinner=Ext.extend(Zarafa.common.plugins.SpinnerPlugin,{allowDecimals:true,decimalSeparator:".",decimalPrecision:2,allowNegative:true,constructor:function(a){Ext.applyIf(this,a);Zarafa.common.plugins.NumberSpinner.superclass.constructor.call(this,a)},init:function(a){Zarafa.common.plugins.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(a.allowDecimals)b+=a.decimalSeparator;if(a.allowNegative)b+="-";a.maskRe=RegExp("["+Ext.escapeRe(b)+"]");a.value=this.floatToString(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,stringToFloat:function(a){return parseFloat(a)},floatToString:function(a){if(Ext.isDefined(a))return a.toString()},
setValue:function(a){this.setStringValue(this.floatToString(this.fixBoundries(a)))},getValue:function(){var a=this.getStringValue();if(!Ext.isEmpty(a))return this.stringToFloat(a)},spin:function(a,b){this.field.rendered&&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.plugins.NumberSpinner);
Ext.ns("Zarafa.common.plugins");
Zarafa.common.plugins.TimeSpinner=Ext.extend(Zarafa.common.plugins.SpinnerPlugin,{format:_("G:i"),alternateIncrementField:Date.HOUR,incrementField:Date.MINUTE,constructor:function(a){Ext.applyIf(this,a);Zarafa.common.plugins.TimeSpinner.superclass.constructor.call(this,a)},init:function(a){Zarafa.common.plugins.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=null;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.isEmpty(this.dateValue))return null;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.rendered&&this.field.onFocus();var d=this.field.getValue(),e=b===true?this.field.alternateIncrementValue:this.field.incrementValue,f=b===true?this.alternateIncrementField:this.incrementField;if(c=d)d=d.add(f,a?-1*e:e);if(!a&&d&&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.plugins.TimeSpinner);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){for(var b=a.document.getElementsByTagName("img"),c=0,d=b.length;c<
d;c++){var e=b[c];if(e.complete!==true||e.width+e.height===0){this.doPrintOnStylesheetLoad.defer(10,this,[a]);return}}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(this.cleanTemplate('<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />\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>"),{disableFormats:true})).apply(this.prepareData(a))},cleanTemplate:function(a){return a.replace(/\r/g,"").replace(/\\/g,"\\\\")},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();for(var b in a)if(Ext.isString(a[b]))a[b]=Ext.util.Format.htmlEncode(a[b]);return a},postRender:Ext.emptyFn,getTitle:function(a){return typeof a.getTitle==
"function"?a.getTitle():a.title||"Printing"}});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,i,h){return new Zarafa.common.recipientfield.data.SuggestionListResponseHandler({proxy:this,action:c,reader:f,
options:h,callback:g,scope:i})}});Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.EditRecipientContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{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"),allowBlank:false,vtype:"email",name:"smtp_address",anchor:"100%"}],
buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.recipientfield.ui.EditRecipientContentPanel.superclass.constructor.call(this,a);this.on("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()}});
Ext.reg("zarafa.editrecipientcontentpanel",Zarafa.common.recipientfield.ui.EditRecipientContentPanel);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",expandBtnEl:undefined,expandBtnCls:"x-zarafa-boxfield-item-expand",expandBtnHoverCls:"x-zarafa-boxfield-item-expand-hover",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)},renderButtons:function(){Zarafa.common.recipientfield.ui.RecipientBox.superclass.renderButtons.apply(this,arguments);this.record.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&this.renderExpandButton()},afterRender:function(a){Zarafa.common.recipientfield.ui.RecipientBox.superclass.afterRender.call(this,
a);Ext.isDefined(this.expandBtnEl)&&this.expandBtnEl.setVisible(this.editable)},setEditable:function(a){Zarafa.common.recipientfield.ui.RecipientBox.superclass.setEditable.call(this,a);Ext.isDefined(this.expandBtnEl)&&this.expandBtnEl.setVisible(this.editable)},renderExpandButton:function(){this.expandBtnEl=this.el.insertFirst({tag:"span",cls:this.expandBtnCls});this.expandBtnEl.addClassOnOver(this.expandBtnHoverCls);this.mon(this.expandBtnEl,"click",this.onClickExpand,this)},onClickExpand:function(){Ext.MessageBox.show({title:_("Zarafa WebApp"),
msg:_("Distribution list will be replaced with its members. You will not be able to collapse it again."),icon:Ext.MessageBox.WARNING,record:this.record,fn:this.doExpand,scope:this,buttons:Ext.MessageBox.OKCANCEL})},doExpand:function(a){if(a=="ok"){this.parent.getBoxStore().expand(this.record);Zarafa.common.recipientfield.ui.RecipientBox.superclass.onClickRemove.apply(this,arguments)}},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)},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()&&a.dirty){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)}this.record.get("object_type")==
Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&this.enableButtons===true&&!Ext.isDefined(this.expandBtnEl)&&this.renderExpandButton()}});Ext.reg("zarafa.recipientbox",Zarafa.common.recipientfield.ui.RecipientBox);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"),iconCls:"icon_edit_recipient",hidden:!b||c,handler:this.editRecipient,scope:this},{xtype:"zarafa.conditionalitem",text:_("Show Details"),
iconCls:"icon_contact",hidden:!c,handler:this.openDetailsContent,scope:this},{xtype:"zarafa.conditionalitem",text:_("Send e-mail"),iconCls:"icon_send_email_to_recipient",handler:this.emailRecipient,scope:this},container.populateInsertionPoint("context.common.recipientfield.contextmenu.actions",this),{xtype:"menuseparator"}]});Zarafa.common.recipientfield.ui.RecipientContextMenu.superclass.constructor.call(this,a)},editRecipient:function(){Zarafa.core.data.UIFactory.openCreateRecord(this.records,{manager:Ext.WindowMgr})},
openDetailsContent:function(){Zarafa.common.Actions.openViewRecipientContent(this.records)},emailRecipient:function(){var a=container.getHierarchyStore().getDefaultFolder("drafts");a=container.getContextByFolder(a).getModel().createRecord(a);var b=a.getRecipientStore(),c=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,this.records.data);c.set("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_TO);b.add(c);Zarafa.core.data.UIFactory.openCreateRecord(a)}});
Ext.reg("zarafa.recipientcontextmenu",Zarafa.common.recipientfield.ui.RecipientContextMenu);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.RecipientDropZone=Ext.extend(Zarafa.common.ui.BoxFieldDropZone,{onNodeDrop:function(a,b,c,d){if(!this.isValidDropPoint(a,b,c,d))return false;if(b.field.boxStore!==this.field.boxStore){b.field.boxStore.remove(d.draggedRecord);this.field.defaultRecipientType&&d.draggedRecord.set("recipient_type",this.field.defaultRecipientType);this.field.boxStore.add(d.draggedRecord)}else{if(d.draggedRecord.get("recipient_type")===this.field.defaultRecipientType)return false;d.draggedRecord.set("recipient_type",
this.field.defaultRecipientType)}return true},onNodeOver:function(a,b,c,d){return this.isValidDropPoint(a,b,c,d)?Ext.dd.DropZone.prototype.dropAllowed:Ext.dd.DropZone.prototype.dropNotAllowed},isValidDropPoint:function(){return!this.field.boxLimit||this.field.items.getCount()<this.field.boxLimit}});Ext.reg("zarafa.recipientdropzone",Zarafa.common.recipientfield.ui.RecipientDropZone);Ext.namespace("Zarafa.common.recipientfield.ui");
Zarafa.common.recipientfield.ui.ViewRecipientContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{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.ViewRecipientContentPanel.superclass.constructor.call(this,a);this.on("afterlayout",this.onAfterFirstLayout,this,{single:true})},onAfterFirstLayout:function(){this.formPanel.getForm().loadRecord(this.record)},onOk:function(){this.close()},onCancel:function(){this.close()}});
Ext.reg("zarafa.viewrecipientcontentpanel",Zarafa.common.recipientfield.ui.ViewRecipientContentPanel);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.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.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.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(){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.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,i,h){return new Zarafa.core.data.IPMResponseHandler({proxy:this,action:c,reader:f,options:h,callback:g,scope:i})}});Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{store:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=container.getReminderStore();a=Ext.applyIf(a,{xtype:"zarafa.remindercontentpanel",layout:"fit",title:_("Reminders"),border:false,width:350,minWidth:350,maxWidth:350,height:300,items:[{xtype:"zarafa.reminderpanel",store:a.store}]});Zarafa.common.reminder.dialogs.ReminderContentPanel.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.remindercontentpanel",Zarafa.common.reminder.dialogs.ReminderContentPanel);Ext.namespace("Zarafa.common.reminder.dialogs");
Zarafa.common.reminder.dialogs.ReminderGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{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.on("rowdblclick",this.onRowDblClick,this);this.on("rowcontextmenu",this.onRowContextMenu,this)},initColumnModel:function(){return[{header:'<p class="icon_index">&nbsp;</p>',
headerCls:"zarafa-icon-column",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.core.data.UIFactory.openContextMenu(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.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.contentpanel.contextmenu.actions",this),{xtype:"menuseparator"},container.populateInsertionPoint("context.common.reminder.contentpanel.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.restoreitem.data");
Zarafa.common.restoreitem.data.RestoreItemStore=Ext.extend(Zarafa.core.data.MAPIStore,{entryId:undefined,storeEntryId:undefined,constructor:function(a){a=a||{};var b=Zarafa.core.data.RecordFactory.getRecordClassByObjectType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RESTOREITEM);Ext.applyIf(a,{remoteSort:true,sortInfo:{field:"deleted_on",direction:"DESC"},actionType:Zarafa.core.Actions.list,writer:new Zarafa.core.data.JsonWriter,reader:new Zarafa.core.data.JsonReader({dynamicRecord:false},b),
proxy:new Zarafa.core.data.IPMProxy({listModuleName:Zarafa.core.ModuleNames.getListName("RESTOREITEMS"),itemModuleName:Zarafa.core.ModuleNames.getItemName("RESTOREITEMS")})});Zarafa.common.restoreitem.data.RestoreItemStore.superclass.constructor.call(this,a)},load:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isEmpty(a.folder)){this.entryId=a.folder.get("entryid");this.storeEntryId=a.folder.get("store_entryid")}Ext.apply(a.params,{entryid:this.entryId,store_entryid:this.storeEntryId});
return Zarafa.common.restoreitem.data.RestoreItemStore.superclass.load.call(this,a)}});Ext.reg("zarafa.restoreitemstore",Zarafa.common.restoreitem.data.RestoreItemStore);Ext.namespace("Zarafa.common.rules.data");
Zarafa.common.rules.data.JsonRulesReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=a||{};Ext.applyIf(a,{id:"rule_id",idProperty:"rule_id",dynamicRecord:false});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RULE));Zarafa.common.rules.data.JsonRulesReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.common.rules.data");
Zarafa.common.rules.data.RulesStore=Ext.extend(Zarafa.core.data.MAPIStore,{actionType:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{autoLoad:true,batch:true,actionType:Zarafa.core.Actions.list,writer:new Zarafa.core.data.JsonWriter({writeAllFields:true}),reader:new Zarafa.common.rules.data.JsonRulesReader,proxy:new Zarafa.common.rules.data.RulesProxy({listModuleName:Zarafa.core.ModuleNames.getListName("RULES"),itemModuleName:Zarafa.core.ModuleNames.getItemName("RULES")})});Zarafa.common.rules.data.RulesStore.superclass.constructor.call(this,
a)},createRecords:function(a,b){for(var c=0,d=b.length;c<d;c++){var e=b[c];if(e.phantom){var f=10;a.each(function(g){g=g.get("rule_sequence");Ext.isEmpty(g)||(f=Math.max(f,g))},this);e.data.rule_sequence=f+1}}Zarafa.common.rules.data.RulesStore.superclass.createRecords.apply(this,arguments)},save:function(){if(!this.writer)throw new Ext.data.Store.Error("writer-undefined");var a=[],b,c,d,e={},f;b=this.getModifiedRecords();if(!(b.length===0&&this.removed.length===0)){b=[].concat(this.getRange());if(b.length)for(f=
b.length-1;f>=0;f--)b[f].isValid()||b.splice(f,1);a.push(["create",b]);if(b=a.length){d=++this.batchCounter;for(f=0;f<b;++f){c=a[f];e[c[0]]=c[1]}if(this.fireEvent("beforesave",this,e)!==false){for(f=0;f<b;++f){c=a[f];this.doTransaction(c[0],c[1],d)}return d}}return-1}},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.rules.data.RulesStore.superclass.load.call(this,
a)}});Ext.namespace("Zarafa.common.rules.dialogs");Zarafa.common.rules.dialogs.DeleteLink=Ext.extend(Zarafa.common.rules.dialogs.FolderSelectionLink,{onClick:function(){},setAction:function(a,b){this.actionFlag=Zarafa.common.rules.data.ActionFlags.MOVE;this.action=b;this.isModified=!Ext.isDefined(b);this.folder=container.getHierarchyStore().getDefaultFolder("wastebasket")},update:function(){}});Ext.reg("zarafa.deletelink",Zarafa.common.rules.dialogs.DeleteLink);Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesWordsEditContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{store:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.ruleswordseditcontentpanel",layout:"fit",width:500,height:300,title:_("Specify Words or Phrases"),items:[{xtype:"zarafa.ruleswordseditpanel",ref:"rulesWordsEditPanel",store:a.store,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.rules.dialogs.RulesWordsEditContentPanel.superclass.constructor.call(this,
a)},onOk:function(){if(this.rulesWordsEditPanel.onWordAdd()!==false){if(Ext.isFunction(this.callback))this.callback.call(this.scope||this,this.store);this.close()}},onCancel:function(){this.close()}});Ext.reg("zarafa.ruleswordseditcontentpanel",Zarafa.common.rules.dialogs.RulesWordsEditContentPanel);Ext.namespace("Zarafa.common.rules.ui");
Zarafa.common.rules.ui.RulesGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.rulesgrid",border:true,enableHdMenu:false,viewConfig:{forceFit:true,emptyText:"<div class='emptytext'>"+_("No rule exists")+"</div>"},loadMask:this.initLoadMask(),sm:new Ext.grid.RowSelectionModel({singleSelect:true}),columns:this.initColumnModel(),listeners:{rowdblclick:this.onRowDblClick,scope:this},tbar:this.initToolbar()});Zarafa.common.rules.ui.RulesGrid.superclass.constructor.call(this,
a)},initEvents:function(){Zarafa.common.rules.ui.RulesGrid.superclass.initEvents.call(this);this.mon(this.getSelectionModel(),"selectionchange",this.onGridSelectionChange,this)},initToolbar:function(){return[{xtype:"button",text:_("New"),handler:this.onRuleAdd,ref:"../addButton",scope:this,width:70},{xtype:"spacer",width:10},{xtype:"button",text:_("Delete"),disabled:true,ref:"../removeButton",handler:this.onRuleRemove,scope:this,width:75},{xtype:"spacer",width:10},{xtype:"button",text:_("Edit"),disabled:true,
ref:"../editButton",handler:this.onRuleEdit,scope:this,width:70},{xtype:"spacer",width:10},{xtype:"button",iconCls:"zarafa-rules-sequence-up",disabled:true,ref:"../upButton",handler:this.onRuleSequenceUp,scope:this,width:20},{xtype:"spacer",width:10},{xtype:"button",iconCls:"zarafa-rules-sequence-down",disabled:true,ref:"../downButton",handler:this.onRuleSequenceDown,scope:this,width:20}]},initColumnModel:function(){return[{xtype:"checkcolumn",dataIndex:"rule_state",header:_("Active"),fixed:true,
width:60,sortable:false,renderer:this.ruleStateRenderer.createDelegate(this),processEvent:this.onRuleStateColumnProcessEvent.createDelegate(this)},{dataIndex:"rule_name",header:_("Rule"),sortable:false,renderer:Zarafa.common.ui.grid.Renderers.text}]},ruleStateRenderer:function(a){a=(a&Zarafa.core.mapi.RuleStates.ST_ENABLED)===Zarafa.core.mapi.RuleStates.ST_ENABLED;return Ext.ux.grid.CheckColumn.prototype.renderer.apply(this,arguments)},onRuleStateColumnProcessEvent:function(a,b,c,d){if(a==="mousedown"){a=
c.getStore().getAt(d);b=a.get("rule_state");(b&Zarafa.core.mapi.RuleStates.ST_ENABLED)===Zarafa.core.mapi.RuleStates.ST_ENABLED?a.set("rule_state",b&~Zarafa.core.mapi.RuleStates.ST_ENABLED):a.set("rule_state",b|Zarafa.core.mapi.RuleStates.ST_ENABLED)}},initLoadMask:function(){return{msg:_("Loading rules")+"..."}},onViewReady:function(){Zarafa.common.rules.ui.RulesGrid.superclass.onViewReady.apply(this,arguments);this.getSelectionModel().selectFirstRow()},onStoreLoad:function(){Zarafa.common.rules.ui.RulesGrid.superclass.onStoreLoad.apply(this,
arguments);this.getSelectionModel().hasSelection()||this.getSelectionModel().selectFirstRow()},onRowDblClick:function(a,b){Zarafa.common.Actions.openRulesEditContent(a.getStore().getAt(b))},onGridSelectionChange:function(a){var b=a.hasSelection()===false;this.removeButton.setDisabled(b);this.editButton.setDisabled(b);this.upButton.setDisabled(!a.hasPrevious());this.downButton.setDisabled(!a.hasNext())},onRuleAdd:function(){var a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RULE);
this.getStore().add(a);Zarafa.common.Actions.openRulesEditContent(a,{removeRecordOnCancel:true})},onRuleRemove:function(){var a=this.getStore(),b=this.getSelectionModel().getSelected();b?a.remove(b):container.getNotifier().notify("error.rules",_("Error"),_("Please select a rule."))},onRuleEdit:function(){var a=this.getSelectionModel().getSelected();a?Zarafa.common.Actions.openRulesEditContent(a):container.getNotifier().notify("error.rules",_("Error"),_("Please select a rule."))},onRuleSequenceUp:function(){var a=
this.getStore(),b=this.getSelectionModel(),c=b.getSelected();if(c)if(b.hasPrevious()){var d=undefined;a.each(function(e){if(c.get("rule_sequence")>e.get("rule_sequence"))if(!d||e.get("rule_sequence")>d.get("rule_sequence"))d=e},this);this.swapRules(c,d)}else container.getNotifier().notify("error.rules",_("Error"),_("Rule already has highest priority."));else container.getNotifier().notify("error.rules",_("Error"),_("Please select a rule."))},onRuleSequenceDown:function(){var a=this.getStore(),b=this.getSelectionModel(),
c=b.getSelected();if(c)if(b.hasNext()){var d=undefined;a.each(function(e){if(c.get("rule_sequence")<e.get("rule_sequence"))if(!d||e.get("rule_sequence")<d.get("rule_sequence"))d=e},this);this.swapRules(c,d)}else container.getNotifier().notify("error.rules",_("Error"),_("Rule already has lowest priority."));else container.getNotifier().notify("error.rules",_("Error"),_("Please select a rule."))},swapRules:function(a,b){var c=a.get("rule_sequence"),d=b.get("rule_sequence");a.set("rule_sequence",d);
b.set("rule_sequence",c);this.getStore().sort("rule_sequence","ASC");c=this.getSelectionModel();this.upButton.setDisabled(!c.hasPrevious());this.downButton.setDisabled(!c.hasNext())}});Ext.reg("zarafa.rulesgrid",Zarafa.common.rules.ui.RulesGrid);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsDelegateCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Delegates"),categoryIndex:5,xtype:"zarafa.settingsdelegatecategory",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)},onHide:function(){Zarafa.common.settings.SettingsDelegateCategory.superclass.onHide.apply(this,arguments);this.mun(this.get(0).getDelegateStore(),"beforesave",this.onBeforeSaveDelegate,this)},onBeforeSaveSettingsModel:function(){Zarafa.common.settings.SettingsDelegateCategory.superclass.onBeforeSaveSettingsModel.apply(this,arguments);this.mon(this.get(0).getDelegateStore(),"beforesave",this.onBeforeSaveDelegate,this,{single:true})},onBeforeSaveDelegate:function(){this.displaySavingMask();var a=
this.get(0).getDelegateStore();this.mon(a,"save",this.onDelegateSave,this);this.mon(a,"exception",this.onDelegateException,this)},onDelegateSave:function(){this.hideSavingMask(true);var a=this.get(0).getDelegateStore();this.mun(a,"save",this.onDelegateSave,this);this.mun(a,"exception",this.onDelegateException,this)},onDelegateException:function(){this.hideSavingMask(false);var a=this.get(0).getDelegateStore();this.mun(a,"save",this.onDelegateSave,this);this.mun(a,"exception",this.onDelegateException,
this)}});Ext.reg("zarafa.settingsdelegatecategory",Zarafa.common.settings.SettingsDelegateCategory);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsDelegateWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{height:400,title:_("Delegate settings"),xtype:"zarafa.settingsdelegatewidget",layout:{type:"fit"},items:[{xtype:"zarafa.delegatespanel",ref:"delegatesPanel"}]});Zarafa.common.settings.SettingsDelegateWidget.superclass.constructor.call(this,a)},getDelegateStore:function(){return this.delegatesPanel.store},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.getDelegateStore(),{remove:this.doStoreRemove,update:this.doStoreUpdate,scope:this})},doStoreRemove:function(a,b){b.phantom||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.SettingsRuleCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Mail filters"),categoryIndex:3,xtype:"zarafa.settingsrulecategory",iconCls:"zarafa-settings-category-rules",items:[{xtype:"zarafa.settingsrulewidget",settingsContext:a.settingsContext},container.populateInsertionPoint("context.settings.category.rules",this)]});Zarafa.common.settings.SettingsRuleCategory.superclass.constructor.call(this,a)},onHide:function(){Zarafa.common.settings.SettingsRuleCategory.superclass.onHide.apply(this,
arguments);this.mun(this.get(0).getRulesStore(),"beforesave",this.onBeforeSaveRules,this)},onBeforeSaveSettingsModel:function(){Zarafa.common.settings.SettingsRuleCategory.superclass.onBeforeSaveSettingsModel.apply(this,arguments);this.mon(this.get(0).getRulesStore(),"beforesave",this.onBeforeSaveRules,this,{single:true})},onBeforeSaveRules:function(){this.displaySavingMask();var a=this.get(0).getRulesStore();this.mon(a,"save",this.onRulesSave,this);this.mon(a,"exception",this.onRulesException,this)},
onRulesSave:function(){this.hideSavingMask(true);var a=this.get(0).getRulesStore();this.mun(a,"save",this.onRulesSave,this);this.mun(a,"exception",this.onRulesException,this)},onRulesException:function(){this.hideSavingMask(false);var a=this.get(0).getRulesStore();this.mun(a,"save",this.onRulesSave,this);this.mun(a,"exception",this.onRulesException,this)}});Ext.reg("zarafa.settingsrulecategory",Zarafa.common.settings.SettingsRuleCategory);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsRuleWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{height:400,title:_("Mail filters"),xtype:"zarafa.settingsrulewidget",layout:{type:"fit"},items:[{xtype:"zarafa.rulespanel",ref:"rulesPanel"}]});Zarafa.common.settings.SettingsRuleWidget.superclass.constructor.call(this,a)},getRulesStore:function(){return this.rulesPanel.store},initEvents:function(){Zarafa.common.settings.SettingsRuleWidget.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.getRulesStore(),{remove:this.doStoreRemove,update:this.doStoreUpdate,scope:this})},doStoreRemove:function(a,b){b.phantom!==true&&this.settingsContext.getModel().setDirty()},doStoreUpdate:function(a,b,c){c!==Ext.data.Record.COMMIT&&this.settingsContext.getModel().setDirty()},onSaveSettings:function(){this.rulesPanel.saveChanges()},onDiscardSettings:function(){this.rulesPanel.discardChanges()}});
Ext.reg("zarafa.settingsrulewidget",Zarafa.common.settings.SettingsRuleWidget);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsSendAsCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Send As"),categoryIndex:6,xtype:"zarafa.settingssendascategory",iconCls:"zarafa-settings-category-sendas",items:[{xtype:"zarafa.settingssendaswidget",settingsContext:a.settingsContext},container.populateInsertionPoint("context.settings.category.sendas",this)]});Zarafa.common.settings.SettingsSendAsCategory.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.settingssendascategory",Zarafa.common.settings.SettingsSendAsCategory);Ext.namespace("Zarafa.common.settings");
Zarafa.common.settings.SettingsSendAsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b=new Zarafa.core.data.IPMRecipientStore({autoResolve:false,autoDestroy:true});Ext.applyIf(a,{height:400,title:_("Send As settings"),xtype:"zarafa.settingssendaswidget",layout:{type:"fit"},items:[{xtype:"zarafa.sendaspanel",store:b,ref:"sendasPanel"}]});Zarafa.common.settings.SettingsSendAsWidget.superclass.constructor.call(this,a)},getStore:function(){return this.sendasPanel.store},
initEvents:function(){Zarafa.common.settings.SettingsSendAsWidget.superclass.initEvents.call(this);this.mon(this.getStore(),{remove:this.doStoreRemove,update:this.doStoreUpdate,add:this.doStoreAdd,scope:this})},update:function(a){this.model=a;a=a.get("zarafa/v1/contexts/mail/sendas",true);var b={item:[]};Ext.each(a,function(c){b.item.push({props:c})});this.getStore().loadData(b)},updateSettings:function(a){var b=this.getStore().getRange();b=Ext.pluck(b,"data");for(var c=0;c<b.length;c++){var d=b[c];
delete d.proposednewtime;delete d.proposednewtime_end;delete d.proposednewtime_start;delete d.recipient_flags;delete d.recipient_trackstatus;delete d.recipient_trackstatus_time}a.set("zarafa/v1/contexts/mail/sendas",b)},doStoreRemove:function(a,b){b.phantom||this.settingsContext.getModel().setDirty()},doStoreAdd:function(a,b){Ext.isEmpty(b[0].get("entryid"))||this.settingsContext.getModel().setDirty()},doStoreUpdate:function(a,b,c){c!==Ext.data.Record.COMMIT&&this.settingsContext.getModel().setDirty()}});
Ext.reg("zarafa.settingssendaswidget",Zarafa.common.settings.SettingsSendAsWidget);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.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,dateFieldConfig:{},timeFieldConfig:{},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.hideLabels=true;var b=[];if(!a.hideLabel&&a.fieldLabel){var c=a.labelConfig||{};c=Ext.applyIf(c,{xtype:"label",text:a.fieldLabel+(a.labelSeparator||":")||""});if(a.labelWidth)c.width=a.labelWidth;else c.autoWidth=true;b.push(c)}b=b.concat([Ext.apply({xtype:"datefield",ref:"dateField",flex:1,format:this.dateFormat,
value:this.defaultValue,minValue:this.minValue,maxValue:this.maxValue,listeners:{change:this.onDateChange,select:this.onDateSelect,scope:this},hideLabel:true,hideLabels:true},this.dateFieldConfig),Ext.apply({xtype:"zarafa.spinnerfield",ref:"timeField",width:85,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}},this.timeFieldConfig)]);a=Ext.applyIf(a,{isSingleValued:true,hideLabels:true,items:b});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.DateTimePeriodField=Ext.extend(Zarafa.common.ui.DateRangeField,{enableTimeSelection:true,dateFormat:_("d/m/Y"),timeFormat:_("G:i"),timeIncrement:30,constructor:function(a){a=a||{};a.hideLabels=true;Ext.apply(this,a);a.startFieldConfig=Ext.applyIf(a.startFieldConfig||{},{xtype:"zarafa.datetimefield",fieldLabel:_("Start date"),enableTimeSelection:this.enableTimeSelection,dateFormat:this.dateFormat,timeFormat:this.timeFormat,timeIncrement:this.timeIncrement});a.endFieldConfig=Ext.applyIf(a.endFieldConfig||
{},{xtype:"zarafa.datetimefield",fieldLabel:_("End date"),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.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();this.mon(a.field.el,"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.namespace("Zarafa.common.ui");
Zarafa.common.ui.HtmlEditor=Ext.extend(Ext.ux.form.TinyMCETextArea,{defaultFontFamily:undefined,defaultFontSize:undefined,applyFormattingForcefully:false,constructor:function(a){a=a||{};var b=Zarafa.common.ui.htmleditor.Fonts.getFonts(),c=Zarafa.common.ui.htmleditor.Fonts.getFontFamilies(),d="";for(var e in b)d+=b[e]+"pt,";b=container.getServerConfig().getPowerpasteConfig();a=Ext.applyIf(a,{xtype:"zarafa.tinymcetextarea",hideLabel:true,hideMode:"offsets",readOnly:false,tinyMCEConfig:{delta_height:1,
plugins:["advlist emoticons directionality lists link image charmap searchreplace textcolor"],external_plugins:{powerpaste:"../tinymce-plugins/powerpaste/plugin.min.js"},powerpaste_word_import:b.powerpaste_word_import,powerpaste_html_import:b.powerpaste_html_import,powerpaste_allow_local_images:b.powerpaste_allow_local_images,toolbar1:"fontselect fontsizeselect | bold italic underline strikethrough | subscript superscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | outdent indent | ltr rtl | bullist numlist | searchreplace | link unlink | undo redo | charmap emoticons image hr removeformat",
extended_valid_elements:"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],table[style|class|border=2|width|cellspacing|cellpadding|bgcolor],colgroup,col[style|width],tbody,tr[style|class],td[style|class|colspan|rowspan|width|height],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style|br],p[class|style|span|br]",paste_data_images:true,automatic_uploads:false,remove_trailing_brs:false,valid_children:"+body[style]",
font_formats:c,theme_advanced_font_sizes:d,font_size_style_values:d,browser_spellcheck:true,menubar:false,statusbar:false,skin:"white",visual_anchor_class:"zarafa_tinymce_anchor",forced_root_block:"P",forced_root_block_attrs:{style:"padding: 0; margin: 0;"},content_style:"body{ word-wrap: break-word;}"},defaultFontFamily:container.getSettingsModel().get("zarafa/v1/main/default_font"),defaultFontSize:Zarafa.common.ui.htmleditor.Fonts.getDefaultFontSize()});container.populateInsertionPoint("common.htmleditor.tinymceconfig",
{scope:this,config:a.tinyMCEConfig});this.addEvents("valuecorrection");Zarafa.common.ui.HtmlEditor.superclass.constructor.call(this,a);this.on("initialized",this.onEditorInitialized,this);this.on("beforedestroy",this.onBeforeDestroy,this)},onEditorInitialized:function(a,b){container.getServerConfig().getClientTimeout()&&this.setIdleTimeEventListeners();b.on("keydown",this.onKeyDown.createDelegate(this),this);b.on("paste",this.onPaste.createDelegate(this),this);b.on("mousedown",this.onMouseDown.createDelegate(this),
this);var c={blur:this.onBlur,focus:this.onFocus,scope:this};Ext.EventManager.on(this.getEditor().getWin(),c);b._hasCaretEvents=true;b.on("focus",this.onFocus.createDelegate(this),this);b.on("blur",this.onBlur.createDelegate(this),this);c=b.theme.panel.find(".toolbar-grp")[0].items()[0].items();var d=c[1];c[0].on("select",this.onFontFamilyChange.createDelegate(this),this);d.on("select",this.onFontSizeChange.createDelegate(this),this);(new Ext.util.DelayedTask(this.applyDefaultFormatting,this,[b])).delay(5)},
setIdleTimeEventListeners:function(){var a=this.getEditorDocument();if(a.addEventListener){a.addEventListener("click",function(){Zarafa.idleTime=0},true);a.addEventListener("mousemove",function(){Zarafa.idleTime=0},true);a.addEventListener("keydown",function(){Zarafa.idleTime=0},true)}},onBeforeDestroy:function(){var a=this.getEditor();a&&a.remove()},onPaste:function(a){var b=this.getEditor();if(b.editorManager.Env.webkit&&a.clipboardData&&a.clipboardData.types){var c=a.clipboardData.getData("text/html");
if(Ext.isEmpty(c)){var d=a.clipboardData.getData("text");d&&d.length>0&&b.once("BeforePastePreProcess",function(g){var i=d.replace(/\n/g,"<br/>").replace(/\s/g,"&nbsp;");g.content=i;return g})}}if(Ext.isIE){var e=this.defaultFontFamily,f=this.defaultFontSize;b.once("BeforePastePreProcess",function(g){var i=g.content,h='<p style="margin: 0px; padding: 0px; data-mce-style="margin: 0px; padding: 0px;">';h+='<span style="font-family:'+e+"; font-size:"+f+'; data-mce-style="font-family:'+e+"; font-size:"+
f+";>";i=i.replace(/<p>|<P>/g,h).replace(/<\/p>|<\/P>/g,'<br data-mce-bogus="1"></span></p>');g.content=i;b.once("NodeChange",function(){var k=b.selection.getNode();(k=b.dom.getParent(k,"p"))&&k.nextSibling&&b.selection.setCursorLocation(k.nextSibling.firstChild,0)});return g})}},onFontFamilyChange:function(a){this.defaultFontFamily=a.control.settings.value},onFontSizeChange:function(a){this.defaultFontSize=a.control.settings.value},applyDefaultFormatting:function(a){if(!this.isDisabled()&&this.record&&
this.record.phantom||this.applyFormattingForcefully)if(Ext.isDefined(this.defaultFontSize)&&Ext.isDefined(this.defaultFontFamily)){a.fire("focusin",{});if(a.selection){var b=a.getBody().firstChild,c,d=Ext.isDefined(this.record.getMessageAction)?this.record.getMessageAction("action_type"):false;if(b.nodeName==="P"&&d!==Zarafa.mail.data.ActionTypes.EDIT_AS_NEW){if(a.getContent()!==""){c=b.cloneNode();b=a.getBody().insertBefore(c,b)}}else if(Zarafa.mail.data.ActionTypes.isSendOrForward(d)){c=a.dom.create("p",
a.settings.forced_root_block_attrs,'<br data-mce-bogus="1" />');b=a.getBody().insertBefore(c,b)}if(!Ext.isDefined(d)||d!==false||d!==Zarafa.mail.data.ActionTypes.EDIT_AS_NEW){a.selection.setCursorLocation(a.getBody().firstChild,0);this.composeDefaultFormatting(a)}else a.selection.setCursorLocation();if(Zarafa.mail.data.ActionTypes.isSendOrForward(d)){a.getBody().insertBefore(b.cloneNode(),b);a.selection.setCursorLocation(a.getBody().firstChild,0);this.composeDefaultFormatting(a)}this.checkValueCorrection(this,
"");a.undoManager.clear();this.applyFormattingForcefully=false}}},composeDefaultFormatting:function(a){a.execCommand("fontsize",false,this.defaultFontSize,{skip_focus:true});a.execCommand("FontName",false,this.defaultFontFamily,{skip_focus:true});this.repositionBrTag(a)},repositionBrTag:function(a){var b=a.selection.getNode();a.dom.add(b,"br");var c=a.dom.getParent(b,"p");c&&c.lastChild.nodeName==="BR"&&c.removeChild(c.lastChild);Ext.isIE11&&a.selection.setCursorLocation(b,0)},setValue:function(a){var b=
this.getEditor();if(b)if(b.getContent()===a)return;Zarafa.common.ui.HtmlEditor.superclass.setValue.call(this,a);this.rendered&&this.withEd(function(){this.checkValueCorrection(this,a)})},enable:function(){if(this.disabled){Zarafa.common.ui.HtmlEditor.superclass.enable.apply(this,arguments);var a=this.getEditor();a.selection.lastFocusBookmark=null;Ext.isEmpty(a.getContent())&&this.applyDefaultFormatting(a)}},checkValueCorrection:function(a,b){var c=a.getValue();b!==c&&a.fireEvent("valuecorrection",
a,c,b)},onMouseDown:function(){Ext.getDoc().fireEvent("mousedown")},onKeyDown:function(a){var b=this.getEditor();if(a.keyCode===Ext.EventObject.BACKSPACE||a.keyCode===Ext.EventObject.DELETE)(function(){var c=b.getContent();if(Ext.isEmpty(c)){(c=b.dom.get("_mce_caret"))&&b.dom.remove(c);this.applyFormattingForcefully=true;this.applyDefaultFormatting(b)}else{c=b.selection.getNode();c.hasChildNodes()&&this.validateStyleStructure(c)}}).createDelegate(this).defer(1);if(a.keyCode===Ext.EventObject.ENTER){if(a.ctrlKey){a.preventDefault();
return false}if(this.inBlockquote(b)){a.preventDefault();this.handleEnterInBlockquote();return false}(function(){var c=b.selection.getNode();if(c.nodeName==="P"){if(!c.hasChildNodes()||c.firstChild.nodeName==="BR")this.composeDefaultFormatting(b)}else c.nodeName==="SPAN"&&c.hasChildNodes()&&c.firstChild.nodeName==="BR"&&c.firstChild.removeAttribute("data-mce-bogus")}).createDelegate(this).defer(1)}if(a.keyCode===Ext.EventObject.TAB){if(!b.dom.getParent(b.selection.getStart(),"LI,DT,DD")){b.dom.events.cancel(a);
for(a=0;a<=3;a++)b.execCommand("mceInsertContent",false,"&nbsp;")}}else this.fireEvent("keypress",this,Ext.EventObject)},inBlockquote:function(a){var b=null;b=a.selection.getNode();b=b.nodeName==="BLOCKQUOTE"?b:a.dom.getParent(b,"BLOCKQUOTE",a.getBody());return b!==null?b:false},splitBlockquote:function(a,b){a.selection.setContent('<span id="zarafa-splitter"></span>');var c=a.dom.get("zarafa-splitter");a.dom.split(b,c);var d=a.dom.getPrev(c,"blockquote"),e=a.dom.getNext(c,"blockquote");a.dom.setStyle(d,
"margin-bottom","1em");if(e){a.dom.setStyle(e,"margin-top","1em");if(d=e.firstChild){if(d.nodeName==="DIV"&&a.dom.hasClass(d,"bodyclass"))d=d.firstChild;if(d&&d.firstChild&&d.firstChild.nodeName==="BR"){a.dom.remove(d.firstChild);d.nodeName==="SPAN"&&a.dom.isEmpty(d)&&a.dom.remove(d)}}}d=a.dom.create("p",a.settings.forced_root_block_attrs,'<br data-mce-bogus="1" />');a.dom.replace(d,c);a.selection.select(d)},handleEnterInBlockquote:function(){var a=this.getEditor(),b=this.inBlockquote(a);a.undoManager.add();
a.undoManager.transact(function(){for(;b;){this.splitBlockquote(a,b);b=this.inBlockquote(a)}var c=a.selection.getNode();a.selection.setCursorLocation(c);this.composeDefaultFormatting(a)}.createDelegate(this))},insertNode:function(a){switch(a.nodeName){case "SPAN":this.addTextNodeInSpan(a);break;case "BODY":this.addPTagInBody(a);break;case "P":this.addTextNodeInP(a);break}},validateStyleStructure:function(a){var b=a.firstChild;if(b.nodeName==="BR"||a.nodeName==="BODY")this.insertNode(a);else b.nodeName===
"#text"&&a.getAttribute("style")===null&&a.setAttribute("style",a.getAttribute("data-mce-style"))},addTextNodeInSpan:function(a){var b=this.getEditorDocument().createTextNode("");a.insertBefore(b,a.firstChild)},addPTagInBody:function(){var a=this.getEditor(),b=a.dom.select("br");Ext.each(b,function(c){var d=c.parentNode;if(d.nodeName==="BODY"){c.remove();this.composeDefaultFormatting(a)}else d.nodeName==="P"&&d.firstChild.nodeName==="BR"&&this.composeDefaultFormatting(a)},this)},addTextNodeInP:function(a){var b=
this.getEditor();if(a.id===""){this.composeDefaultFormatting(b);a.id="dirtyP"}else if(a.previousSibling!==null){this.getEditorDocument().execCommand("Delete",false,null);a=b.selection.getNode();if(a.firstChild.nodeName==="BR"){this.composeDefaultFormatting(b);a.id="dirtyP"}}else a.remove()},onBlur:function(){if(!(this.isDestroyed===true||this.getEditor().removed)){if(this.hasFocus===true){var a=this.getRawValue();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.getRawValue();this.hasFocus=true;this.fireEvent("focus",this)}},setCursorLocation:function(){var a=this.getEditor();a?this.withEd(function(){a.fire("focusin",{})}):this.on("initialized",function(){var b=this.ownerCt;b.focus.defer(1,b);b.fireEvent("setAutoFocusCursor",b.getEditor())},this)},getEditorDocument:function(){return this.getEditor().getDoc()},getEditorBody:function(){return this.getEditor().getBody()},
bindRecord:function(a){this.record=a}});Ext.reg("zarafa.htmleditor",Zarafa.common.ui.HtmlEditor);Zarafa.onReady(function(){var a=Ext.getBody();if(a.hasClass("zarafa-webclient")){a=a.createChild({id:"tiny-prefetch",style:{width:"10px",height:"10px","z-index":-10,top:"-10000px",left:"-10000px",visibility:"hidden",position:"absolute"}});new Ext.Panel({xtype:"panel",applyTo:a,layout:"fit",border:false,flex:1,autoHeight:false,items:[{xtype:"zarafa.editorfield",ref:"../editorField",flex:1,useHtml:true}]})}});
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.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.PreviewPanelToolbarButtons=Ext.extend(Object,{model:undefined,constructor:function(a){Ext.apply(this,a)},getToolbarButtons:function(a,b){var c=false;if(Ext.isDefined(b.model)&&b.model instanceof Zarafa.core.ContextModel)c=b.model;return[{xtype:"zarafa.toolbarbutton",tooltip:_("Copy/Move")+" (Ctrl + M)",overflowText:_("Copy/Move"),iconCls:"icon_copy",nonEmptySelectOnly:true,handler:this.onCopyMove,model:c||this.model},{xtype:"zarafa.toolbarbutton",tooltip:_("Delete")+" (DELETE)",overflowText:_("Delete"),
iconCls:"icon_delete",nonEmptySelectOnly:true,handler:this.onDelete,model:c||this.model}]},onCopyMove:function(){Zarafa.common.Actions.openCopyMoveContent(this.model.getSelectedRecords())},onDelete:function(){Zarafa.common.Actions.deleteRecords(this.model.getSelectedRecords())},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.model.getSelectedRecords())}});Ext.namespace("Zarafa.common.ui");
Zarafa.common.ui.ResizableCompositeField=Ext.extend(Zarafa.common.ui.CompositeField,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.resizablecompositefield"});a.cls=a.cls?a.cls+" zarafa-resizable-compositefield":"zarafa-resizable-compositefield";Ext.apply(this,a);Zarafa.common.ui.ResizableCompositeField.superclass.constructor.call(this,a)},initComponent:function(){for(var a=[],b=this.items,c,d=0,e=b.length;d<e;d++){c=b[d];if(!Ext.isEmpty(c.ref))c.ref="../"+c.ref;a.push(c.fieldLabel);
Ext.applyIf(c,this.defaults);d==e-1&&this.skipLastItemMargin||Ext.applyIf(c,{margins:this.defaultMargins})}this.fieldLabel=this.fieldLabel||this.buildLabel(a);this.fieldErrors=new Ext.util.MixedCollection(true,function(f){return f.field});this.fieldErrors.on({scope:this,add:this.updateInvalidMark,remove:this.updateInvalidMark,replace:this.updateInvalidMark});Ext.form.Field.prototype.initComponent.apply(this);this.innerCt=new Ext.Container({layout:"hbox",layoutConfig:{pack:"start",align:"stretch"},
items:this.items,cls:"x-form-composite",defaultMargins:"0 3 0 0",ownerCt:this});delete this.innerCt.ownerCt;a=this.innerCt.findBy(function(f){return f.isFormField},this);this.items=new Ext.util.MixedCollection;this.items.addAll(a);a=this.innerCt.findBy(function(f){return f.isXType("box")},this);this.items.addAll(a);this.innerCt.ownerCt=this;Ext.each(this.items.items,function(f){f.isXType("zarafa.boxfield")&&f.mon(f,"resizeheight",function(){this.onResize();this.ownerCt.doLayout(false)},this,{delay:0})},
this)},onResize:function(a,b,c,d){if(!Ext.isDefined(this.padding))this.padding=this.getEl().getPadding("tb");var e=this.innerCt,f=0,g=e.items;if(g.items)g=g.items;Ext.each(g,function(i){var h=0,k=0;if(i.getResizeEl&&i.getResizeEl()){h=i.getResizeEl().getHeight();k=i.getResizeEl().getPadding("tb")}if(h+k>f)f=h+k},this);f+=this.padding;if(f!==b)b=f;this.rendered&&e.rendered&&e.setSize(a,b);Zarafa.common.ui.ResizableCompositeField.superclass.onResize.apply(this,[a,b,c,d])}});
Ext.reg("zarafa.resizablecompositefield",Zarafa.common.ui.ResizableCompositeField);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"),width:190,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"),width:190,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.namespace("Zarafa.common.ui.grid");Zarafa.common.ui.grid.MapiMessageGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{});
Ext.reg("zarafa.mapimessagegrid",Zarafa.common.ui.grid.MapiMessageGrid);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.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}]});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");var now=new Date;Zarafa.ABOUT="<p>Copyright (C) 2005 - "+now.format("Y")+'  Zarafa B.V. &lt;info@zarafa.com&gt; and its licensors</p><p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.</p><p>You should have received a copy of the GNU Affero General Public License along with this program.  If not, see <a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>.</p><hr /><p>WebApp contains the following third-party components:</p><h1>Ext JS</h1><p>Copyright (C) Sencha, Inc.  Ext JS is distributed under the terms of the GNU General Public License: <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></p><h1>xregexp</h1><p>Copyright (c) 2007-2012 Steven Levithan <a href="http://xregexp.com/" target="_blank">http://xregexp.com/</a></p><p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p><h1>Object.js</h1><p>Code copied from <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys" target="_blank">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys</a>, which is copyright (C) 2012, Mozilla Contributors</p><p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p><h1>Printer rendering</h1><p>Copyright (C) 2010 Ed Spencer</p><p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p><h1>TinyMCE</h1><p>Copyright, Moxiecode Systems AB. Released under LGPL License: <a href="http://www.tinymce.com/license" target="_blank">http://www.tinymce.com/license</a></p><h1>TinyMCE PowerPaste</h1><p>Copyright (C) 2015 Ephox Corporation</p><p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.</p>You should have received a copy of the GNU Affero General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>.</p>';
Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABMultiUserSelectionContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{callback:undefined,convert:undefined,scope:undefined,store:undefined,hierarchyRestriction:undefined,listRestriction:undefined,selectionCfg:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.abmultiuserselectioncontentpanel",layout:"fit",title:_("Address Book"),items:[{xtype:"zarafa.abmultiuserselectionpanel",hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction,
selectionCfg:a.selectionCfg,callback:a.callback,convert:a.convert,scope:a.scope,store:a.store}]});Zarafa.addressbook.dialogs.ABMultiUserSelectionContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.abmultiuserselectioncontentpanel",Zarafa.addressbook.dialogs.ABMultiUserSelectionContentPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.ABUserSelectionPanel=Ext.extend(Zarafa.addressbook.ui.AddressBookMainPanel,{callback:Ext.emptyFn,singleSelect:true,scope:undefined,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()){a=
a.getSelectionModel().getSelections();this.singleSelect?this.callback.call(this.scope||this,a[0]):this.callback.call(this.scope||this,a);return true}},onAfterLayout:function(){Zarafa.addressbook.ui.ABUserSelectionPanel.superclass.onAfterLayout.apply(this,arguments);this.mon(this.getGridPanel(),"rowdblclick",this.onAddressBookRowDblClick,this);this.mon(this.getGridPanel(),"rowcontextmenu",this.onAddressBookRowContextMenu,this)},onAddressBookRowDblClick:function(){this.doCallBack()===true&&this.dialog.close()},
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.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),dialog:this.dialog})},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.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"),iconCls:"icon_contact",singleSelectOnly:true,handler:this.onOpenDetails,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.openDetailsContent(this.records)}});Ext.reg("zarafa.addressbookcontextmenu",Zarafa.addressbook.ui.AddressBookContextMenu);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.AddressBookGrid=Ext.extend(Zarafa.common.ui.grid.GridPanel,{singleSelect:false,constructor:function(a){a=a||{};Ext.applyIf(a,{autoExpandColumn:"displayname",autoExpandMin:100,loadMask:true,stateful:true,statefulRelativeDimensions:false,sm:this.createSelectionModel(a),cm:new Zarafa.addressbook.ui.GABColumnModel,view:new Ext.ux.grid.BufferView({emptyText:"<div class='emptytext'>"+_("There are no items to show in this view")+"</div>",scrollDelay:false,rowHeight:31})});Zarafa.addressbook.ui.AddressBookGrid.superclass.constructor.call(this,
a);this.mon(this.getStore(),"load",this.onStoreLoad,this)},onStoreLoad:function(a,b,c){b=c&&c.params&&c.params.folderType==="gab"?new Zarafa.addressbook.ui.GABColumnModel:new Zarafa.addressbook.ui.GABPersonalColumnModel;this.colModel.name!==b.name&&this.reconfigure(a,b)},createSelectionModel:function(a){return new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:a.singleSelect})},getSelectedItems:function(){return this.getSelectionModel().getSelections()},getStateName:function(){var a=this.store.lastOptions,
b="globaladdressbook";if(a&&a.params&&a.params.entryid)if(Zarafa.core.EntryId.hasContactProviderGUID(a.params.entryid))b="contacts";return"gab/"+b+"/list"},getState:function(){var a=Zarafa.addressbook.ui.AddressBookGrid.superclass.getState.call(this),b={sort:a.sort};delete a.sort;Ext.apply(b,a[this.getColumnModel().name]);return b},applyState:function(a){if(a){var b={sort:a.sort};delete a.sort;b[this.getColumnModel().name]=a;Zarafa.addressbook.ui.AddressBookGrid.superclass.applyState.call(this,b)}}});
Ext.reg("zarafa.addressbookgrid",Zarafa.addressbook.ui.AddressBookGrid);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.openDetailsContent(c)},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.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),dialog:this.dialog})}});Ext.reg("zarafa.addressbookpanel",Zarafa.addressbook.ui.AddressBookPanel);Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.GABColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"globaladdressbook",columns:this.getColumns()});Zarafa.addressbook.ui.GABColumnModel.superclass.constructor.call(this,a)},getColumns:function(){var a=container.populateInsertionPoint("context.addressbook.gridpanel",this),b=[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",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:_("Username"),sortable:true,hidden:false,tooltip:_("Sort by: Username"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"smtp_address",
header:_("Email Address"),sortable:true,hidden:false,tooltip:_("Sort by: Email Address"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"surname",header:_("Last Name"),sortable:true,hidden:true,tooltip:_("Sort by: Last Name"),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:"mobile_telephone_number",header:_("Mobile"),sortable:true,hidden:true,tooltip:_("Sort by: Mobile"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"home_telephone_number",header:_("Home Phone"),sortable:true,hidden:true,tooltip:_("Sort by: Home Phone"),renderer:Ext.util.Format.htmlEncode,width:150},{dataIndex:"pager_telephone_number",header:_("Pager"),sortable:true,hidden:true,tooltip:_("Sort by: Pager"),
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}];if(Ext.isArray(a)){var c=1;a.forEach(function(d){if(Ext.isObject(a[0])){b.splice(c,0,d);c+=1}})}return b}});Ext.namespace("Zarafa.addressbook.ui");
Zarafa.addressbook.ui.GABPersonalColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{name:"personal_contacts",columns:[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",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.advancesearch.dialogs");
Zarafa.advancesearch.dialogs.SearchContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{};var b="advancesearchtab-"+ ++Ext.Component.AUTO_ID;Ext.applyIf(a,{xtype:"zarafa.searchcontentpanel",layout:"fit",name:b,title:a.searchText,iconCls:"advance_search",border:false,parentSearchField:a.parentSearchField,items:[{xtype:"zarafa.searchpanel",ref:"searchPanel",searchTabId:b,searchText:a.searchText,searchContentPanel:this}]});Zarafa.advancesearch.dialogs.SearchContentPanel.superclass.constructor.call(this,
a);this.initEvents()},initEvents:function(){this.mon(container.getTabPanel(),"tabchange",this.onTabChange,this)},onTabChange:function(a,b){var c=container.getMainToolbar(),d=b.isXType("zarafa.searchcontentpanel");c.searchView.setVisible(d);var e=container.getCurrentContext().getName();switch(e){case "calendar":Ext.each(["Day","Workweek","Week","Month","List"],function(i){c["calendar"+i].setVisible(!d)},this);break;default:e=c.get("zarafa-maintoolbar-view-"+e);Ext.isDefined(e)&&e.setVisible(!d)}var f=
b.searchPanel;if(Ext.isDefined(f)){e=f.model;var g=e.stores[b.name];if(Ext.isDefined(g)){f=f.centerRegion.switchBorder.searchGrid.getSelectionModel().getSelections();e.setSelectedRecords(f,false);e.setActiveStore(g)}}},setParentSearchField:function(a){this.parentSearchField=a},getParentSearchField:function(){return this.parentSearchField}});Ext.reg("zarafa.searchcontentpanel",Zarafa.advancesearch.dialogs.SearchContentPanel);Ext.namespace("Zarafa.advancesearch.ui");
Zarafa.advancesearch.ui.SearchGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(a)});Zarafa.advancesearch.ui.SearchGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(a){var b=a.grid;a=a.folder.getMAPIStore().get("mailbox_owner_name");a=String.format(_('Search results - "{0}"'),a);return[{id:b.getId()+"-col0",header:a,sortable:false,hideable:false,renderer:Zarafa.common.ui.grid.Renderers.dataColumn},
{id:b.getId()+"-col1",dataIndex:"searchdate",header:_("Date"),width:110,fixed:true,resizable:false,sortable:true,tooltip:_("Sort by: Date"),hideable:false,renderer:Zarafa.common.ui.grid.Renderers.dateColumn,css:"padding: 0; margin:0;"}]}});Ext.namespace("Zarafa.advancesearch.ui");
Zarafa.advancesearch.ui.SearchResultPreviewPanel=Ext.extend(Zarafa.core.ui.PreviewPanel,{constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.searchContext))a.model=a.searchContext.getModel();Ext.applyIf(a,{xtype:"zarafa.searchresultpreviewpanel",cls:"zarafa-previewpanel zarafa-context-mainpanel",recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{enableOpenLoadTask:true,autoOpenLoadTaskDefer:250}),width:600,height:400,tbar:{height:33,items:[{xtype:"button",
tooltip:_("Reply")+" (Ctrl + R)",overflowText:_("Reply"),iconCls:"icon_replyEmail",ref:"replyBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLY,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Reply All")+" (Ctrl + Alt + R)",overflowText:_("Reply All"),iconCls:"icon_replyAllEmail",ref:"replyAllBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLYALL,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Forward")+" (Ctrl + F)",overflowText:_("Forward"),iconCls:"icon_forwardEmail",
ref:"forwardBtn",responseMode:Zarafa.mail.data.ActionTypes.FORWARD,handler:this.onResponse,scope:this},{xtype:"button",tooltip:_("Edit as New Message")+" (Ctrl + E)",overflowText:_("Edit as New Message"),iconCls:"icon_editAsNewEmail",ref:"editAsNewBtn",responseMode:Zarafa.mail.data.ActionTypes.EDIT_AS_NEW,handler:this.onResponse,scope:this}]}});this.addEvents(["afterupdatesearchpreviewpanel"]);Zarafa.advancesearch.ui.SearchResultPreviewPanel.superclass.constructor.call(this,a)},update:function(a,
b){Zarafa.advancesearch.ui.SearchResultPreviewPanel.superclass.update.apply(this,arguments);this.fireEvent("afterupdatesearchpreviewpanel",this,a,b);if(a){var c=a.isFaultyMessage(),d=Zarafa.core.MessageClass.isClass(a.get("message_class"),["IPM.NOTE","REPORT.IPM","IPM.SCHEDULE","IPM.APPOINTMENT"]);if(d&&Zarafa.core.MessageClass.isClass(a.get("message_class"),["IPM.APPOINTMENT"]))a.isMeeting()||(d=false);var e=this.getTopToolbar();e.replyBtn.setVisible(!c&&d);e.replyAllBtn.setVisible(!c&&d);e.forwardBtn.setVisible(!c&&
d);var f=this.model.getDefaultFolder();e.editAsNewBtn.setVisible(f.getDefaultFolderKey()==="sent"&&!c&&d)}},setRecord:function(a){for(var b=0;b<this.toolbars.length;b++)this.searchContext.getCurrentViewMode()===Zarafa.common.data.ViewModes.RIGHT_PREVIEW?this.toolbars[b].setVisible(false):this.toolbars[b].setVisible(!!a);this.recordComponentPlugin&&this.recordComponentPlugin.setRecord(a)},showRecordInPanel:function(a){this.model.store.getSearchStoreUniqueId()===this.dialog.name&&Zarafa.advancesearch.ui.SearchResultPreviewPanel.superclass.showRecordInPanel.call(this,
a)},onResponse:function(a){var b=container.getContextByName("mail").getModel();Zarafa.mail.Actions.openCreateMailResponseContent(this.record,b,a.responseMode)}});Ext.reg("zarafa.searchresultpreviewpanel",Zarafa.advancesearch.ui.SearchResultPreviewPanel);Ext.namespace("Zarafa.calendar.attachitem");
Zarafa.calendar.attachitem.AttachCalendarColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.getColumns(),defaults:{sortable:true}});Zarafa.calendar.attachitem.AttachCalendarColumnModel.superclass.constructor.call(this,a)},getColumns:function(){return[{header:"<p class='icon_index'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"icon_index",tooltip:_("Sort by: Icon"),width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},
{header:"<p class='icon_attachment'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"hasattach",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.attachment,tooltip:_("Sort by: Attachment")},{header:"<p class='icon_recurring'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"recurring",tooltip:_("Sort by: Recurring"),width:24,renderer:Zarafa.common.ui.grid.Renderers.recurrence,fixed:true},{header:_("Subject"),dataIndex:"subject",tooltip:_("Sort by: Subject"),renderer:Zarafa.common.ui.grid.Renderers.subject},
{header:_("Startdate"),dataIndex:"startdate",tooltip:_("Sort by: Startdate"),width:180,renderer:Zarafa.common.ui.grid.Renderers.datetime},{header:_("Enddate"),dataIndex:"duedate",tooltip:_("Sort by: Enddate"),width:180,renderer:Zarafa.common.ui.grid.Renderers.datetime}]}});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.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.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.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,i,h){return new Zarafa.calendar.data.busytime.BusyTimeResponseHandler({proxy:this,action:c,reader:f,options:h,callback:g,scope:i})}});Ext.namespace("Zarafa.calendar.data.busytime");
Zarafa.calendar.data.busytime.BusyTimeStore=Ext.extend(Zarafa.core.data.MAPIStore,{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)},clearData:function(){Zarafa.core.data.MAPIStore.superclass.clearData.apply(this,arguments)}});
Ext.reg("zarafa.busytimestore",Zarafa.calendar.data.busytime.BusyTimeStore);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.ProposeNewTimeContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.proposenewtimecontentpanel",layout:"fit",title:_("Propose New Time"),width:375,height:200,recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),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.ProposeNewTimeContentPanel.superclass.constructor.call(this,a)},onOk:function(){this.proposeNewTimePanel.updateRecord(this.record);this.close()},onCancel:function(){this.close()}});Ext.reg("zarafa.proposenewtimecontentpanel",Zarafa.calendar.dialogs.ProposeNewTimeContentPanel);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestCancellationContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{record:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestcancellationcontentpanel",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.SendMeetingRequestCancellationContentPanel.superclass.constructor.call(this,a)},onOk:function(){this.sendMRCancellationPanel.updateRecord(this.record);this.close()},onCancel:function(){this.close()}});Ext.reg("zarafa.sendmeetingrequestcancellationcontentpanel",Zarafa.calendar.dialogs.SendMeetingRequestCancellationContentPanel);Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.SendMeetingRequestConfirmationContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{record:undefined,responseType:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.sendmeetingrequestconfirmcontentpanel",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.SendMeetingRequestConfirmationContentPanel.superclass.constructor.call(this,a)},onOk:function(){if(this.record.isRecurringOccurence()&&Ext.isDefined(this.buttonName)&&this.buttonName==="recurring"){this.record.removeIdProp("basedate");this.record.set("basedate","")}this.sendMRConfirmationPanel.updateRecord(this.record);this.close()},onCancel:function(){this.close()}});
Ext.reg("zarafa.sendmeetingrequestconfirmcontentpanel",Zarafa.calendar.dialogs.SendMeetingRequestConfirmationContentPanel);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:4,iconCls:"zarafa-settings-category-calendar",items:[{xtype:"zarafa.settingscalendarwidget"},{xtype:"zarafa.settingsfreebusywidget"},{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.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:"checkboxgroup",ref:"workingDays",fieldLabel:_("Working days"),name:"zarafa/v1/main/working_days",width:225,columns:4,
items:[{boxLabel:_("Mon"),name:"day-col-1",inputValue:1},{boxLabel:_("Tue"),name:"day-col-2",inputValue:2},{boxLabel:_("Wed"),name:"day-col-3",inputValue:3},{boxLabel:_("Thu"),name:"day-col-4",inputValue:4},{boxLabel:_("Fri"),name:"day-col-5",inputValue:5},{boxLabel:_("Sat"),name:"day-col-6",inputValue:6},{boxLabel:_("Sun"),name:"day-col-0",inputValue:0}]},{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));a=this.model.get(this.workingDays.name);b={};for(c=0;c<=6;c++)b["day-col-"+c]=a.indexOf(c)>-1?true:false;this.workingDays.setValue(b);this.mon(this.workingDays,"change",this.onWorkingDaysChange,this,{single:true})},updateSettings:function(a){a.beginEdit();this.onWorkTimeChange(this.workingHourPeriod,this.workingHourPeriod.getValue());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.set(this.workingDays.name,Ext.pluck(this.workingDays.getValue(),"inputValue"));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();if(d<c)d=c+this.workingHourPeriod.defaultPeriod*60;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)},onWorkingDaysChange:function(){this.model&&this.model.set(this.workingDays.name,Ext.pluck(this.workingDays.getValue(),"inputValue"))}});Ext.reg("zarafa.settingscalendarwidget",Zarafa.calendar.settings.SettingsCalendarWidget);Ext.namespace("Zarafa.calendar.settings");
Zarafa.calendar.settings.SettingsFreeBusyWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b=_("Free/busy information is used by people sending meeting requests, ");b+=_("to determine when you are available for meetings.");Ext.applyIf(a,{title:_("Free/Busy permission"),items:[{xtype:"displayfield",hideLabel:true,value:b},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Publish {A} month(s) of Calendar free/busy information on the server."),
items:[{xtype:"numberfield",width:25,name:"zarafa/v1/contexts/calendar/free_busy_range",labelSplitter:"{A}",ref:"../freeBusyMonth",minValue:1,maxValue:36,allowBlank:false,allowDecimals:false,allowNegative:false,listeners:{change:this.onFieldChange,scope:this}}]},{xtype:"displayfield",hideLabel:true,value:_("You can only publish a free/busy period from 1 to 36 months.")}]});Zarafa.calendar.settings.SettingsFreeBusyWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;this.freeBusyMonth.setValue(a.get(this.freeBusyMonth.name))},
updateSettings:function(a){var b=this.freeBusyMonth.isValid()?this.freeBusyMonth.getValue():a.get(this.freeBusyMonth.name,false,true);a.beginEdit();a.set(this.freeBusyMonth.name,b);a.endEdit()},onFieldChange:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)}});Ext.reg("zarafa.settingsfreebusywidget",Zarafa.calendar.settings.SettingsFreeBusyWidget);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.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.ui");
Zarafa.calendar.ui.AbstractCalendarView=Ext.extend(Zarafa.core.ui.View,{rangeSelectionModel:undefined,selectionModel:undefined,contextModel:undefined,folders:undefined,selectedFolder:undefined,tabs:undefined,selectionView:undefined,textEditView:undefined,appointments:undefined,leftOffset:0,width:0,appointmentBodyLeftMargin:0,appointmentBodyRightMargin:0,appointmentHeaderLeftMargin:6,appointmentHeaderRightMargin:6,body:undefined,header:undefined,headerBorderLeft:undefined,headerBorderRight:undefined,
borderLeft:undefined,borderRight:undefined,borderBottom:undefined,tabArea:undefined,enableDD:false,enableBodyDD:false,enableHeaderDD:false,enableBodyDrag:false,enableHeaderDrag:false,enableBodyDrop:false,enableHeaderDrop:false,ddGroup:"AppointmentDD",bodyDragZone:undefined,bodyDragConfig:undefined,bodyDropZone:undefined,bodyDropConfig:undefined,headerDragZone:undefined,headerDragConfig:undefined,headerDropZone:undefined,headerDropConfig:undefined,groupId:undefined,active:false,constructor:function(a){a=
a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar"});this.addEvents("appointmentcalendardrop","appointmentmouseover","appointmentmouseout","appointmentmove","appointmentresize","appointmentcreate","appointmentinitdrag","appointmentenddrag","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=this.createAppointmentProxy();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.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(){this.folders.indexOf(this.selectedFolder)<0&&this.setSelectedFolder(this.folders[0]);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,createAppointmentProxy: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,screenLocationToDateRange: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=[];b?Ext.each(a,function(g){var i=this.getDateRange().getStartTime();
c.push({appointment:g,start:Math.floor((g.getDateRange().getStartTime()-i)/Date.dayInMillis),due:Math.ceil((g.getDateRange().getDueTime()-i)/Date.dayInMillis)})},this):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","zarafa-calendar-header");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.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.enableBodyDD||this.enableBodyDrag)if(!this.bodyDragZone&&this.body)this.bodyDragZone=new Zarafa.calendar.ui.CalendarViewDragZone(this,this.bodyDragConfig||{ddGroup:this.ddGroup||"AppointmentDD",headerMode:false});if(this.enableDD||this.enableHeaderDD||this.enableHeaderDrag)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.enableBodyDD||this.enableBodyDrop)if(!this.bodyDropZone&&this.body){this.bodyDropZone=new Zarafa.calendar.ui.CalendarViewDropZone(this,this.bodyDropConfig||{ddGroup:this.ddGroup||"AppointmentDD",headerMode:false,selectingSnapMode:Zarafa.calendar.data.SnapModes.ZOOMLEVEL,draggingSnapMode:Zarafa.calendar.data.SnapModes.ZOOMLEVEL});this.bodyDropZone.proxy=this.selectionView}if(this.enableDD||this.enableHeaderDD||
this.enableHeaderDrop)if(!this.headerDropZone&&this.header){this.headerDropZone=new Zarafa.calendar.ui.CalendarViewDropZone(this,this.headerDropConfig||{ddGroup:this.ddGroup||"AppointmentDD",headerMode:true,selectingSnapMode:Zarafa.calendar.data.SnapModes.DAY,draggingSnapMode: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(){var a=this.contextModel.getColorScheme(this.getSelectedFolder().get("entryid"));if(this.parentView.showBorder){var b=this.getBorderWidth(),c=this.parentView.getHeaderAreaHeight();
this.headerBorderLeft.dom.className=this.getClassName("border","left");this.headerBorderLeft.setLeftTop(this.leftOffset,0);this.headerBorderLeft.setSize(b,c);this.headerBorderLeft.applyStyles({"background-color":a.header,"border-color":a.header});this.headerBorderLeft.show();this.headerBorderRight.dom.className=this.getClassName("border","right");this.headerBorderRight.setLeftTop(this.leftOffset+this.width-b,0);this.headerBorderRight.setSize(b,c);this.headerBorderRight.applyStyles({"background-color":a.header,
"border-color":a.header});this.headerBorderRight.show();c=this.parentView.getHourHeight()*this.parentView.numHours;this.borderLeft.dom.className=this.getClassName("border","left");this.borderLeft.setLeftTop(this.leftOffset,0);this.borderLeft.setSize(b,c);this.borderLeft.applyStyles({"background-color":a.header,"border-color":a.header});this.borderLeft.show();this.borderRight.dom.className=this.getClassName("border","right");this.borderRight.setLeftTop(this.leftOffset+this.width-b,0);this.borderRight.setSize(b,
c);this.borderRight.applyStyles({"background-color":a.header,"border-color":a.header});this.borderRight.show();this.borderBottom.dom.className=this.getClassName("border","bottom");this.borderBottom.setLeftTop(this.leftOffset,0);this.borderBottom.setSize(this.width,b);this.borderBottom.applyStyles({"background-color":a.header,"border-color":a.header});this.borderBottom.show()}else{this.headerBorderLeft.hide();this.headerBorderRight.hide();this.borderLeft.hide();this.borderRight.hide();this.borderBottom.hide()}},
layoutTabs:function(){for(var a=[],b=[],c=[],d=0,e=0,f;f=this.folders[e];e++){var g=this.tabs[f.get("entryid")];g.setSelected(this.selectedFolder==f,this.active);g.setShowMergeIcon(this.canMerge);g.setShowSeparateIcon(this.folders.length>1);g.setShowCloseIcon(this.canClose);a.push(g);g.desiredWidth=g.getDesiredWidth();g.lrmargins=g.tabContents.getMargins("lr");d+=g.desiredWidth+g.lrmargins}if(d>this.width){for(e=0;e<a.length;e++)a[e].getDesiredWidth()+a[e].tabContents.getMargins("lr")<this.width/
a.length?c.push(a[e]):b.push(a[e]);g=this.width;for(e=f=0;e<c.length;e++)g-=c[e].desiredWidth+c[e].lrmargins;for(e=0;e<b.length;e++)f+=b[e].desiredWidth+b[e].lrmargins;if(b.length===1)b[0].desiredWidth=g-b[0].lrmargins;else for(;f>g;){c=b[0].desiredWidth>b[1].desiredWidth?b[0]:b[1];var i=b[0].desiredWidth>b[1].desiredWidth?b[1]:b[0];for(e=2;e<b.length;e++)if(a[e].desiredWidth>c.desiredWidth)c=a[e];else if(a[e].desiredWidth>i.desiredWidth)i=a[e];if(c.desiredWidth-i.desiredWidth>f-g){c.desiredWidth-=
f-g+c.lrmargins;f=g}else{f-=c.desiredWidth-i.desiredWidth+1;c.desiredWidth=i.desiredWidth-1}}}for(e=0;f=this.folders[e];e++){g=this.tabs[f.get("entryid")];a=g.desiredWidth;g.tabContents.dom.style.removeProperty("min-width");b=parseInt(g.tabContents.getStyle("min-width"))+g.tabContents.getPadding("lr");if(b>a){g.tabContents.setStyle("min-width",0);if(d<=this.width)a=b}g.setWidth(a)}},onLayout:function(){if(this.getSelectedFolder()){var a=this.contextModel.getColorScheme(this.getSelectedFolder().get("entryid"));
if(a)this.calendarColorScheme=a}else return Zarafa.calendar.ui.AbstractCalendarView.superclass.onLayout.call(this);this.layoutBorder();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=b.getRecord().get("parent_entryid");b.calendarColorScheme=this.contextModel.getColorScheme(c);c=this.getFolderById(c);
b.setActive(c==this.selectedFolder)}Zarafa.calendar.ui.AbstractCalendarView.superclass.onLayout.call(this);this.layoutTabs()},onAfterLayout:function(){this.layoutChildren()},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)}else this.selectionView.isVisible()&&
this.selectionView.setVisible(false)}},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.onTabClick(this.getSelectedFolder());
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()},onMouseMove:Ext.emptyFn,onMouseDown:function(a,b){this.groupId!=this.contextModel.active_group&&this.onTabClick(this.getSelectedFolder());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.screenLocationToDateRange(c[0],c[1]))&&this.rangeSelectionModel.set(c,this)}},onMouseUp:function(a,b){if(b&&(b.isAllDay()?b.eventOverHeader(a):b.eventOverBody(a)))this.selectionModel.deselectRecord(b.getRecord())},onInitDrag:function(a,
b){this.fireEvent("appointmentinitdrag",this,a,b)},onEndDrag:function(a,b){this.fireEvent("appointmentenddrag",this,a,b)},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)},setActive:function(a){this.active=a}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.AbstractDateRangeView=Ext.extend(Zarafa.core.ui.View,{slot:undefined,slotCount:undefined,visible:true,dateRange:undefined,setDateRange:function(a){this.dateRange=a},getDateRange:function(){return this.dateRange},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:Ext.emptyFn,layoutInBody:Ext.emptyFn,onLayout:function(){if(this.visible)this.isHeaderRange()?this.layoutInHeader():this.layoutInBody();Zarafa.calendar.ui.AbstractDateRangeView.superclass.onLayout.call(this)},isHeaderRange:function(){return this.parentView.isHeaderRange(this.getDateRange())}});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},{xtype:"menuseparator"},{xtype:"zarafa.conditionalitem",ref:"acceptButton",text:_("Accept"),hidden:true,iconCls:"icon_calendar_appt_accept",beforeShow:this.beforeShowOnMeeting,responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_ACCEPTED,scope:this},{xtype:"zarafa.conditionalitem",
ref:"tentativeButton",text:_("Tentative"),hidden:true,iconCls:"icon_appt_meeting_tentative",beforeShow:this.beforeShowOnMeeting,responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_TENTATIVE,scope:this},{xtype:"zarafa.conditionalitem",ref:"declineButton",text:_("Decline"),iconCls:"icon_calendar_appt_cancelled",hidden:true,beforeShow:this.beforeShowOnMeeting,responseStatus:Zarafa.core.mapi.ResponseStatus.RESPONSE_DECLINED,scope:this},{xtype:"zarafa.conditionalitem",ref:"proposeNewTimeButton",text:_("Propose New Time"),
proposeNewTime:true,hidden:true,iconCls:"icon_calendar_appt_newtime",beforeShow:this.beforeShowOnMeeting,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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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:"zarafa-calendar-appointment-label-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)},beforeShowOnMeeting:function(a,b){if(!(b.length>1)){var c=b[0],d=Ext.isDefined(a.proposeNewTime)&&a.proposeNewTime;c.isMeetingReceived()&&a.setVisible(true);if(c.isMeetingReceived()&&!(c.isRecurringOccurence()||c.get("recurring")))d?a.setHandler(this.openProposeNewTimeContent,this):a.setHandler(this.openSendConfirmationContent,this);if(c.isMeetingReceived()&&(c.isRecurringOccurence()||
c.get("recurring")))a.menu=new Ext.menu.Menu({items:[{xtype:"zarafa.conditionalitem",text:a.text+" "+_("Occurrence"),responseStatus:a.responseStatus,beforeShow:function(e){d?e.setHandler(this.openProposeNewTimeContent,this):e.setHandler(this.openSendConfirmationContent,this)},scope:this},{xtype:"zarafa.conditionalitem",text:a.text+" "+_("Series"),name:"recurring",beforeShow:function(e){d?e.setVisible(false):e.setHandler(this.openSendConfirmationContent,this)},responseStatus:a.responseStatus,isProposeButton:d,
scope:this}],scope:this})}},openProposeNewTimeContent:function(){var a;if(Ext.isArray(this.records))a=this.records[0];a.get("appointment_not_found")?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This appointment has been moved or deleted, do you want to continue?"),icon:Ext.MessageBox.WARNING,record:a,fn:this.onProposeNewTimeAppointmentNotFoundConfirmation.createDelegate(this,[a],1),scope:this,buttons:Ext.MessageBox.YESNO}):Zarafa.calendar.Actions.openProposeNewTimeContent(a)},onProposeNewTimeAppointmentNotFoundConfirmation:function(a,
b){a==="yes"&&Zarafa.calendar.Actions.openProposeNewTimeContent(b)},openSendConfirmationContent:function(a){var b;if(Ext.isArray(this.records))b=this.records[0];b.get("appointment_not_found")?Ext.MessageBox.show({title:_("Zarafa WebApp"),msg:_("This appointment has been moved or deleted, do you want to continue?"),icon:Ext.MessageBox.WARNING,record:b,fn:this.onRespondAppointmentNotFoundConfirmation.createDelegate(this,[a.responseStatus,b],1),scope:this,buttons:Ext.MessageBox.YESNO}):Zarafa.calendar.Actions.openSendConfirmationContent(b,
{responseType:a.responseStatus,buttonName:a.name})},onRespondAppointmentNotFoundConfirmation:function(a,b,c){a==="yes"&&Zarafa.calendar.Actions.openSendConfirmationContent(c,{responseType:b})},onCategories:function(){Zarafa.common.Actions.openCategoriesContent(this.records)},onSetBusyStatus:function(a){var b,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,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.openAppointmentContent(this.records)},onDelete:function(){Zarafa.common.Actions.deleteRecords(this.records)},onCreate:function(a){if(a.meetingRequest){a=0;for(var b=this.records.length;a<b;a++){var c=this.records[a];c.get("meeting")===Zarafa.core.mapi.MeetingStatus.NONMEETING&&c.convertToMeeting()}Zarafa.calendar.Actions.openMeetingRequestContent(this.records)}else Zarafa.calendar.Actions.openAppointmentContent(this.records)}});
Ext.reg("zarafa.calendarcontextmenu",Zarafa.calendar.ui.CalendarContextMenu);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}});Zarafa.calendar.ui.CalendarGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{xtype:"checkcolumn",headerCls:"zarafa-icon-column",header:'<p class="icon_allday">&nbsp;<span class="title">'+_("All Day")+"</span></p>",dataIndex:"alldayevent",tooltip:_("Sort by: All Day"),width:24,
fixed:true,processEvent:Ext.emptyFn},{header:'<p class="icon_index">&nbsp;<span class="title">'+_("Icon")+"</span></p>",headerCls:"zarafa-icon-column",dataIndex:"icon_index",tooltip:_("Sort by: Icon"),width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,fixed:true},{header:'<p class="icon_recurring">&nbsp;<span class="title">'+_("Recurring")+"</span></p>",headerCls:"zarafa-icon-column",dataIndex:"recurring",tooltip:_("Sort by: Recurring"),width:24,renderer:Zarafa.common.ui.grid.Renderers.recurrence,
fixed:true},{header:_("Subject"),dataIndex:"subject",tooltip:_("Sort by: Subject"),width:200,renderer:Zarafa.common.ui.grid.Renderers.subject},{header:_("Startdate"),dataIndex:"startdate",tooltip:_("Sort by: Startdate"),width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime},{header:_("Enddate"),dataIndex:"duedate",tooltip:_("Sort by: Enddate"),width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime},{header:_("Location"),dataIndex:"location",tooltip:_("Sort by: Location"),width:200,renderer:Zarafa.common.ui.grid.Renderers.subject},
{header:_("Duration"),dataIndex:"duration",tooltip:_("Sort by: Duration"),width:160,renderer:Zarafa.common.ui.grid.Renderers.duration},{header:_("Meeting Status"),dataIndex:"meeting",tooltip:_("Sort by: Meeting Status"),width:160,renderer:Zarafa.common.ui.grid.Renderers.meetingstatus},{header:_("Busy Status"),dataIndex:"busystatus",tooltip:_("Sort by: Busy Status"),width:160,renderer:Zarafa.common.ui.grid.Renderers.busystatus,hidden:true},{header:_("Categories"),dataIndex:"categories",tooltip:_("Sort by: Categories"),
width:160,renderer:Zarafa.common.ui.grid.Renderers.text,hidden:true},{header:_("Created On"),dataIndex:"creation_time",tooltip:_("Sort by: Created On"),width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,hidden:true},{header:_("Due By"),dataIndex:"duedate",tooltip:_("Sort by: Due By"),width:160,renderer:Zarafa.common.ui.grid.Renderers.dueBy,hidden:true},{header:_("Label"),dataIndex:"label",tooltip:_("Sort by: Label"),width:160,renderer:Zarafa.common.ui.grid.Renderers.label,hidden:true},{header:_("Organizer"),
dataIndex:"sent_representing_name",tooltip:_("Sort by: Organizer"),hidden:true,renderer:Zarafa.common.ui.grid.Renderers.organizer},{header:_("Required Attendee"),dataIndex:"display_to",tooltip:_("Sort by: Required Attendee"),hidden:true,renderer:Ext.util.Format.htmlEncode},{header:_("Optional Attendee"),dataIndex:"display_cc",tooltip:_("Sort by: Optional Attendee"),hidden:true,renderer:Ext.util.Format.htmlEncode},{header:_("Resources"),dataIndex:"display_bcc",tooltip:_("Sort by: Resources"),hidden:true,
renderer:Ext.util.Format.htmlEncode},{header:_("Recurring Startdate"),dataIndex:"startdate_recurring",tooltip:_("Sort by: Recurring Startdate"),width:160,renderer:Zarafa.common.ui.grid.Renderers.date,hidden:true},{header:_("Recurring Enddate"),dataIndex:"enddate_recurring",tooltip:_("Sort by: Recurring Enddate"),width:160,renderer:Zarafa.common.ui.grid.Renderers.date,hidden:true},{header:_("Recurring Pattern"),dataIndex:"recurring_pattern",tooltip:_("Sort by: Recurring Pattern"),width:400,renderer:Zarafa.common.ui.grid.Renderers.subject,
hidden:true},{header:'<p class="icon_reminder">&nbsp;<span class="title">'+_("Reminder")+"</span></p>",headerCls:"zarafa-icon-column",dataIndex:"reminder",tooltip:_("Sort by: Reminder"),width:24,renderer:Zarafa.common.ui.grid.Renderers.reminder,fixed:true,hidden:true},{header:_("Sensitivity"),dataIndex:"sensitivity",tooltip:_("Sort by: Sensitivity"),width:160,renderer:Zarafa.common.ui.grid.Renderers.sensitivity,hidden:true}]}});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:"fit",items:[{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);return b=b.concat(a)},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.CalendarMultiView=Ext.extend(Zarafa.core.ui.View,{context:undefined,tabAreaHeight:30,headerTextHeight:24,headerItemHeight:24,headerLineHeight:1,calendarGap:6,numHours:24,timeStripWidth:60,timeStripGap:0,zoomLevel:30,model:undefined,timeStripShift:1,firstWorkingHour:540,lastWorkingHour:1020,workingDays:undefined,tooltip: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:24,minHeaderDayTextWidth:150,showBorder:false,borderWidth:1,showTimeStrips:true});
this.addEvents("appointmentcalendardrop","appointmentmouseover","appointmentmouseout","appointmentmove","appointmentresize","appointmentcreate","appointmentinitdrag","appointmentenddrag","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()},getTooltipInstance:function(){if(!this.tooltip){this.tooltip=new Zarafa.calendar.ui.canvas.ToolTip({container:this.container});this.tooltip.on("tooltipmousemove",
this.onTooltipMouseMove,this)}return this.tooltip},onTooltipMouseMove:function(a,b){for(var c=0;c<this.calendars.length;c++){var d=this.calendars[c],e=d.getCalendarHeader();e={x:e.getX(),y:e.getY(),width:e.getWidth(),height:this.scrollable.getHeight()};if(Zarafa.core.Util.inside(e,b.getPageX(),b.getPageY())){d.onMouseMove(b);break}}},onViewModeChanged:function(a,b){var c=Zarafa.calendar.ui.canvas;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(){Ext.isDefined(this.folders)&&this.manageCalendarViews()},onAppointmentCalendarDrop:function(a,
b,c,d,e){this.fireEvent("appointmentcalendardrop",this,c,b.getSelectedFolder(),a.getSelectedFolder(),d,e)},onAppointmentMouseOver:function(a,b,c){this.fireEvent("appointmentmouseover",this,b,c)},onAppointmentMouseOut:function(a,b,c){this.fireEvent("appointmentmouseout",this,b,c)},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)},onAppointmentInitDrag:function(a,b,c){this.fireEvent("appointmentinitdrag",this,b,c)},onAppointmentEndDrag:function(a,b,c){this.fireEvent("appointmentenddrag",this,b,c)},onContextMenu:function(a,b,c,d){if(c){if(c.get("access")===0)return;if(c.phantom!==true){this.rangeSelectionModel.clearSelections();this.selectionModel.selectRecord(c,false)}}else{if(d){c=this.model.createRecord(a.getSelectedFolder(),d);this.rangeSelectionModel.set(d,a)}this.selectionModel.clearSelections()}this.fireEvent("contextmenu",
b,c)},onDoubleClick:function(a,b,c){if(c){if(c.get("access")===0)return;if(c.phantom!==true){this.selectionModel.selectRecord(c,false);this.rangeSelectionModel.clearSelections()}}else this.selectionModel.clearSelections();this.fireEvent("dblclick",b,c)},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",undefined,"scrollable"));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"));this.scrollable.ddScrollConfig={vthresh:50,hthresh:-1,frequency:100,increment:100};this.header.ddScrollConfig={vthresh:50,hthresh:-1,frequency:100,increment:100};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,{beforeload:this.onBeforeLoad,load:this.onLoad,
add:this.onAdd,remove:this.onRemove,update:this.onUpdate,scope:this});(this.store=a)&&a.lastOptions&&!a.isExecuting("list")&&this.onLoad(a,a.getRange(),a.lastOptions)}},releaseStore:function(a){Ext.isDefined(a)&&this.mun(a,{beforeload:this.onBeforeLoad,load:this.onLoad,add:this.onAdd,remove:this.onRemove,update:this.onUpdate,scope:this});a&&a.autoDestroy&&a.destroy();this.store=undefined},resizeAreas:function(){var a=this.getTabHeight(),b=this.getHeaderAreaHeight();if(this.showTimeStrips)b=Math.min(b,
this.container.getHeight()/2);var c=a+b,d=this.container.getHeight()-c-this.getBorderWidth();if(this.showTimeStrips)d=Math.min(d,this.getHourHeight()*this.numHours);var e=d+c;this.tab.setLeftTop(0,0);this.tab.setSize(this.container.getWidth(),a);this.header.setLeftTop(0,a);this.header.setSize(this.container.getWidth(),b);this.scrollable.setLeftTop(0,c);this.scrollable.setSize(this.container.getWidth(),d);this.showTimeStrips&&this.scrollable.scrollTo("top",this.firstWorkingHour/60*this.getHourHeight());
this.bottom.setLeftTop(0,e);this.bottom.setSize(this.container.getWidth(),this.getBorderWidth());for(a=0;b=this.timeStrips[a];a++){b.setLeftMargin((this.timeStripWidth+this.timeStripGap)*a-this.timeStripShift);b.setWidth(this.timeStripWidth)}a=this.showTimeStrips?this.timeStrips.length*this.timeStripWidth+(this.timeStrips.length-1)*this.timeStripGap-this.timeStripShift:0;this.headerLine.setLeftTop(0,c-this.headerLineHeight);this.headerLine.setSize(a,this.headerLineHeight)},onLayout:function(){this.resizeAreas();
this.scrollable.dom.style.overflowY=this.showTimeStrips?"scroll":"hidden";this.header.dom.style.overflowY=this.showTimeStrips&&this.getHeaderAreaHeight()>this.container.getHeight()/2?"scroll":"hidden";if(!this.showTimeStrips){this.scrollable.scrollTo("top",0);this.header.scrollTo("top",0)}Ext.dd.ScrollManager.unregister(this.scrollable);Ext.dd.ScrollManager.unregister(this.header);if(this.context.getCurrentViewMode()===Zarafa.calendar.data.ViewModes.DAYS){Ext.dd.ScrollManager.register(this.scrollable);
Ext.dd.ScrollManager.register(this.header)}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.setActive(this.model.getActiveGroup()==
d.groupId);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,contextModel:this.model});
this.mon(c,{appointmentcalendardrop:this.onAppointmentCalendarDrop,appointmentmouseover:this.onAppointmentMouseOver,appointmentmouseout:this.onAppointmentMouseOut,appointmentmove:this.onAppointmentMove,appointmentresize:this.onAppointmentResize,appointmentcreate:this.onAppointmentCreate,appointmentinitdrag:this.onAppointmentInitDrag,appointmentenddrag:this.onAppointmentEndDrag,contextmenu:this.onContextMenu,dblclick:this.onDoubleClick,dayclick:this.onDayClick,activate:this.onCalendarActivate,merge:this.onCalendarMerge,
separate:this.onCalendarSeparate,close:this.onCalendarClose,scope:this});b&&Ext.each(b,c.addFolder,c);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,appointmentmouseover:this.onAppointmentMouseOver,appointmentmouseout:this.onAppointmentMouseOut,appointmentmove:this.onAppointmentMove,appointmentresize:this.onAppointmentResize,appointmentcreate:this.onAppointmentCreate,
appointmentinitdrag:this.onAppointmentInitDrag,appointmentenddrag:this.onAppointmentEndDrag,contextmenu:this.onContextMenu,dblclick:this.onDoubleClick,dayclick:this.onDayClick,activate:this.onCalendarActivate,merge:this.onCalendarMerge,separate:this.onCalendarSeparate,close:this.onCalendarClose,scope: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();if(Ext.isEmpty(b)){this.model.resetGroupings();this.model.applyGrouping();b=this.model.getGroupings()}Ext.iterate(b,function(c,d){var e=[];if(Ext.isEmpty(d.folders))return true;for(var 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 i=this.createCalendarView(c);this.moveFolder(g,i,f);g=i}else{if(g.groupId!==c)g.groupId=c}else g=this.createCalendarView(c,f);for(f=1;f<e.length;f++){i=e[f];var h=this.getCalendarViewByFolder(i);if(h&&h!==g)this.moveFolder(h,g,i);else h||g.addFolder(i)}g.setSelectedFolder(g.getFolderById(d.active))}},this)},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);Date.diff(Date.DAY,b.get("duedate"),b.get("startdate"))>=1&&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);Date.diff(Date.DAY,b.get("duedate"),b.get("startdate"))>=1&&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),i=f.containsFolderId(b.get("parent_entryid"));if(g&&!i)f.onAppointmentRemove(a,b,c);else!g&&i?f.onAppointmentAdd(a,b,c):this.calendars[d].onAppointmentUpdate(a,b,c)}if(b.isModifiedSinceLastUpdate("startdate")||b.isModifiedSinceLastUpdate("duedate"))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);b.setActive(true);a.removeFolder(c);this.removeCalendarViewIfEmpty(a);if(!a.isDestroyed){this.updateActiveFolder(a);a.setActive(false)}},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);this.model.setActiveFolder(b);for(var c=0,d=this.calendars.length;c<d;c++){this.calendars[c].setActive(this.model.getActiveGroup()==this.calendars[c].groupId);
this.calendars[c].layoutTabs()}},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)},onDestroy:function(){Zarafa.calendar.ui.CalendarMultiView.superclass.onDestroy.apply(this,
arguments);this.scrollable&&Ext.dd.ScrollManager.unregister(this.scrollable);this.header&&Ext.dd.ScrollManager.unregister(this.header)}});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:"button",iconCls:"x-tbar-page-next",handler:this.onNext,scope:this},{xtype:"tbseparator"},{xtype:"tbtext",ref:"../text"}]});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.on("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);switch(b){case Zarafa.calendar.data.DataModes.WEEK:case Zarafa.calendar.data.DataModes.WORKWEEK:this.text.setWidth(250);break;case Zarafa.calendar.data.DataModes.DAY:this.text.setWidth(140);break;default:this.text.setWidth(120);break}}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.CalendarTabView=Ext.extend(Zarafa.core.ui.View,{title:undefined,folder:undefined,tab:undefined,tabContents:undefined,tabText:undefined,mergeIcon:undefined,separateIcon:undefined,closeIcon:undefined,width:0,selected:true,active:false,showMergeIcon:false,showSeparateIcon:false,showCloseIcon:false,constructor:function(a){a=a||{};var b=undefined;if(a.folder)b=a.folder.getFullyQualifiedDisplayName();Ext.applyIf(a,{baseCls:"zarafa-calendar",title:b?Ext.util.Format.htmlEncode(b):undefined});
this.addEvents("merge","separate","close","click");Zarafa.calendar.ui.CalendarTabView.superclass.constructor.call(this,a)},getDesiredWidth:function(){if(!this.rendered)return 0;var a=!this.tabContents.hasClass("zarafa-calendar-tab-selected");a&&this.tabContents.addClass("zarafa-calendar-tab-selected");var b=Ext.util.TextMetrics.createInstance(this.tabText);a&&this.tabContents.removeClass("zarafa-calendar-tab-selected");a=this.getMinimumWidth()+b.getWidth(this.title);this.tabContents.dom.style.removeProperty("min-width");
b=parseInt(this.tabContents.getStyle("min-width"))+this.tabContents.getPadding("lr");return Math.max(a,b)},getMinimumWidth:function(){if(!this.rendered)return 0;var a=this.tabContents.getPadding("lr");if(this.showCloseIcon)a+=this.closeIcon.getWidth();if(this.showMergeIcon)a+=this.mergeIcon.getWidth();if(this.showSeparateIcon)a+=this.separateIcon.getWidth();return a},setWidth:function(a){this.width=a},setSelected:function(a,b,c){if(c===true||this.selected!==a||this.active!==b){c=this.getBaseClassName()+
"-tab-selected";if(a===true)b===true?this.tabContents.addClass(c):this.tabContents.removeClass(c);else this.tabContents.removeClass(c)}this.active=b;this.selected=a},setShowMergeIcon:function(a){this.showMergeIcon=a},setShowSeparateIcon:function(a){this.showSeparateIcon=a},setShowCloseIcon:function(a){this.showCloseIcon=a},applyCSSClassNames:function(){var a=container.getCurrentContext().getModel();if(a instanceof Zarafa.calendar.CalendarContextModel){a=a.getColorScheme(this.folder.get("entryid"));
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.tabContents.applyStyles({"background-color":a.header});this.selected&&this.setSelected(this.selected,this.active,true)}},onLayout:function(){this.applyCSSClassNames();
var a=container.getCurrentContext().getModel();if(a instanceof Zarafa.calendar.CalendarContextModel){a=a.getColorScheme(this.folder.get("entryid"));Zarafa.core.ColorSchemes.getLuma(a.base)<155||this.tabContents.addClass("light-background")}this.showMergeIcon?this.tabContents.addClass("zarafa-with-merge-icon"):this.tabContents.removeClass("zarafa-with-merge-icon");this.showSeparateIcon?this.tabContents.addClass("zarafa-with-separate-icon"):this.tabContents.removeClass("zarafa-with-separate-icon");
this.showCloseIcon?this.tabContents.addClass("zarafa-with-close-icon"):this.tabContents.removeClass("zarafa-with-close-icon");this.tabContents.setWidth(this.width);this.tabText.setWidth(this.width-this.getMinimumWidth());this.mergeIcon.setVisible(this.showMergeIcon);if(this.tabText.dom.innerHTML!=this.title)this.tabText.dom.innerHTML=this.title;this.closeIcon.setVisible(this.showCloseIcon);this.separateIcon.setVisible(this.showSeparateIcon);Zarafa.calendar.ui.CalendarTabView.superclass.onLayout.call(this)},
render:function(a){this.createDiv(this.parentView.tabArea,"tabContents");this.createDiv(this.tabContents,"mergeIcon");this.createDiv(this.tabContents,"tabText");this.createDiv(this.tabContents,"closeIcon");this.createDiv(this.tabContents,"separateIcon");this.mergeIcon.setVisibilityMode(Ext.Element.DISPLAY);this.closeIcon.setVisibilityMode(Ext.Element.DISPLAY);this.separateIcon.setVisibilityMode(Ext.Element.DISPLAY);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.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/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADaSURBVCiRfZE9SkNRFIS/GbMBW0uthKQVBCEbMNroBrIE95BtBMGfgJDKFYQUWgQEwR1Y2VgYbQxMCl/kRd/NwMA9l++eM5xLEpoMnEt6kvQhaQb0klCCjyWl5kdJn8CJKmBNtp+BzqpOsi1pCixa/+gf7dQLSe/Vce7Cg7fC/UtT/v6f/CsvgO7aBEm7tveBe+ALGAMPkm6TtJNM6p1PJcX2je1roNu4wQq+kPRq+8r2CDja8D+cSZravrR9BxyW4CRQxRhKGgMHm+AkbAHfwF6SQZJZYZ2/WgIY6MDMF1W9zwAAAABJRU5ErkJggg==";return function(){return a}}(),
getPrivateIconActive:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADDSURBVCiRhZExakJREEWPNtbiDtIJsRJSCX8DUQnoBlyCZZaRBaRRYyUWtjaioIUgCNlBKrEzSfXhpPnKN7ynFwZmhjszd2ZQiVhX3akndas2VWLkZ6+xUX/UVkElgD1Qy8VlYAmksYIjUAnkv4shNnCI5D9D+nuGkarJ/wkPQBWYAb/ABFgDH8AjsMh3bmedRupQTUIXPDt99UsdqGO1EftPEegAL8AcKAFvwCqyNGQy3tWJ+nTj8xdJr+pUrd8jq/wBj4Qn+tCooUUAAAAASUVORK5CYII=";
return function(){return a}}(),getRecurringIcon:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAMCAYAAABbayygAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAC8SURBVBiVjdAxSoNhEITh5wsBK0EkeIUUVqaytAsWKTyBjW1IpaAewsbCI1h4gBQeQ8EiB7ASjIkQElmbTfj4IeLCwMK+DDsjItTCHlq5X+MgItTACG8ILPCCJR7yruAJn7jEEU4SDKxwCOf4QrdyP05orTG84qr5a1MF+5hGxMofU9aPbgVK6WDxH/ARO3CLKWaYY1iFOsMPerCL90z3gQFOcZ/V3GwKx0WCE3yn8zP6G/cEW7ir9naznl/h/Yxfc66Y/AAAAABJRU5ErkJggg==";
return function(){return a}}(),getRecurringIconActive:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAMCAYAAABbayygAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAC+SURBVBiVjdA9SoNRFITh+ULAShARt2BhpZWlnVhYZAU2tmKloC7CJoVLsHABFi7DQIosIJVg/IFg5LHwfnATJGRg4MB5Gc6ZIAveQKfM19hGauACQ3+a4gXfuG/BBo94wyX2cFhAmGE3OMU7dqr0A/N6Cga4+ufWOTfYTDJJMssSNVi2T5KtJNNVwIcka8EtJvjAJ86r23r4wX6wjnH57hUnOEa/VHNTF35WwBG+SvIzjtr0Fuzgrpq7i/X8AnV2PLeO7j8sAAAAAElFTkSuQmCC";
return function(){return a}}(),getExceptionIcon:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADlSURBVCiRfdG9LsRBFMbhZ3wUQmk7dFuQyMqWmyAhEbRb2HtwAUTpClBpJFpXoBGVXkMh8dFJkG0QiUJG4SxT/NdJTjFzzm/yvu/APmZyzqoa25gszjp4RAObOMcb7nCKT5z8AkFtxOAKa6hhGpfI0Ys5ZwN+qh7L4+jmnF8wgTl/dZBSGoQR3GAK63hCq6+nkDRUmFrBc09CJVCRzFJAy70HMdwXiKWFgFaxhcNS0hle8Y4PtOO+hW7M6mVKOxjDKB5wnVJqYh4pYp2FUsIRvnCBe9ziOP6jGel1SqCG3X88NbD3DfGjzICsYsYEAAAAAElFTkSuQmCC";
return function(){return a}}(),getExceptionIconActive:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADsSURBVCiRfdHNKsRRHMbxJy+zMSuZjYWNUuyU15IkUmY1WbsA5QJkaa/kDiyVS+AOrGdjITWi7OQlpI/FHPzNwlNP53ee0/fX+Z0THGMKqXgEA6Xew9j3WdBCB7M4xLWu3tEu61kVCLbxgXvsYg5NXPnVWhU4LZ3vMFOydX/VxmAwjjfMYxW3WOiZ6cffxWglXC7Q0n9ArxcLtFL2dTT+A1JerVOGPcJlFTjHI57wgq2ST+MBn9hA+tLVfpJ6kqEkd0kekzST7CQZTvKcpJbkz5VOSqfr8lmvuMAmJnGDVhVo4KDU/aj1zDSB4y/Ev7tGkhQziQAAAABJRU5ErkJggg==";
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.TextEditView=Ext.extend(Zarafa.core.ui.View,{dateRange:undefined,minimumHeight:20,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"));this.header.setSize(2,2);this.mon(this.body,"keypress",this.onKeyPress,this);this.mon(this.body,"keydown",this.onKeyPress,this);this.mon(this.body,"blur",this.onBlur,this);this.mon(this.header,"keypress",this.onKeyPress,this);this.mon(this.header,"keydown",this.onKeyPress,this);this.mon(this.header,"blur",this.onBlur,this);Zarafa.calendar.ui.TextEditView.superclass.render.call(this,
a);this.hide()},makeElementsVisible:function(a,b){Ext.each(a,function(c){c.setVisible(b)})},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.TimeStripView=Ext.extend(Zarafa.core.ui.View,{timeDifference:0,name:"",textTemplate:"<div>{0}:00</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.contact.attachitem");
Zarafa.contact.attachitem.AttachContactColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.getColumns(),defaults:{sortable:true}});Zarafa.contact.attachitem.AttachContactColumnModel.superclass.constructor.call(this,a)},getColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",header:"<p class='icon_index'>&nbsp;</p>",tooltip:_("Sort by: Icon"),width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon},
{header:"<p class='icon_attachment'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"hasattach",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.attachment,tooltip:_("Sort by: Attachment")},{dataIndex:"fileas",header:_("File As"),tooltip:_("Sort by: File As"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"company_name",header:_("Company Name"),tooltip:_("Sort by: Company Name"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"title",header:_("Job Title"),tooltip:_("Sort by: Job Title"),
renderer:Ext.util.Format.htmlEncode}]}});Ext.namespace("Zarafa.contact.data");
Zarafa.contact.data.ContactDetailsParser=Ext.extend(Object,{prefixOptions:undefined,suffixOptions:undefined,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||{};this.prefixOptions=Zarafa.contact.data.config.Prefix;this.suffixOptions=Zarafa.contact.data.config.Suffix;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;case 0:c.incomplete_info=false;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.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.ui");
Zarafa.contact.dialogs.ContactGeneralTab=Ext.extend(Ext.form.FormPanel,{hasContactPhoto:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{labelWidth:110,labelAlign:"left"});Ext.applyIf(a,{xtype:"zarafa.contactgeneraltab",cls:"zarafa-contactgeneraltab",title:_("General"),autoScroll:true,border:false,layoutConfig:{columns:2},defaults:{columnWidth:0.5,border:false,xtype:"fieldset"},items:[this.createNameFieldset(a),
this.createPhotoFieldset(a),this.createClear(),this.createPhoneFieldset(a),this.createEmailFieldset(a),this.createClear(),this.createAddressFieldset(a),this.createAdditionalFieldset(a),this.createClear(),this.createAttachmentFieldset(a)]});Zarafa.contact.dialogs.ContactGeneralTab.superclass.constructor.call(this,a)},createClear:function(){return{xtype:"panel",cls:"zarafa-clear",columnWidth:1}},createNameFieldset:function(a){return{title:_("Name"),defaultType:"zarafa.compositefield",defaults:{anchor:"100%"},
items:[{hideLabel:true,items:[{xtype:"button",width:a.labelWidth-1,text:_("Full Name")+":",listeners:{scope:this,click:function(){this.showDetailedNameContent()}}},{xtype:"textfield",flex:1,name:"display_name",listeners:{scope:this,change:this.onDisplayNameChange}}]},{xtype:"textfield",flex:1,name:"company_name",fieldLabel:_("Company"),listeners:{scope:this,change:this.onFieldChange}},{xtype:"textfield",flex:1,name:"title",fieldLabel:_("Job Title"),listeners:{scope:this,change:this.onFieldChange}},
{xtype:"combo",flex:1,name:"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.onFileasChange}}]}},createPhotoFieldset:function(){return{title:_("Photo"),layout:{type:"hbox"},items:{xtype:"box",cls:"contact_photo_box default_contact_photo",ctCls:"contact_photo_box_ct",autoEl:{tag:"img",src:Ext.BLANK_IMAGE_URL},
ref:"../contactPhotoBox",listeners:{afterrender:this.onAfterRender,scope:this}}}},createPhoneFieldset:function(a){return{title:_("Phone Numbers"),defaultType:"zarafa.compositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{items:[{xtype:"splitbutton",width:a.labelWidth-1,text:_("Business")+":",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_1","business_telephone_number")},{xtype:"textfield",flex:1,name:"business_telephone_number",listeners:{scope:this,
change:this.onFieldChange}}]},{items:[{xtype:"splitbutton",width:a.labelWidth-1,text:_("Home")+":",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_2","home_telephone_number")},{xtype:"textfield",flex:1,name:"home_telephone_number",listeners:{scope:this,change:this.onFieldChange}}]},{items:[{xtype:"splitbutton",width:a.labelWidth-1,text:_("Business Fax")+":",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_3",
"business_fax_number")},{xtype:"textfield",flex:1,name:"business_fax_number",listeners:{scope:this,change:this.onFieldChange}}]},{items:[{xtype:"splitbutton",width:a.labelWidth-1,text:_("Mobile")+":",handler:this.handlePhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("message_phonenumber_4","cellular_telephone_number")},{xtype:"textfield",flex:1,name:"cellular_telephone_number",listeners:{scope:this,change:this.onFieldChange}}]}]}},createEmailFieldset:function(a){return{title:_("Email"),
items:[{xtype:"zarafa.compositefield",anchor:"100%",hideLabel:true,items:[{xtype:"splitbutton",width:a.labelWidth-1,text:_("Email")+":",handler:this.openAddressBook,scope:this,menu:this.initEmailButtonMenu("message_email_address","email_address_1")},{xtype:"textfield",flex:1,ref:"../../mailAddressField",name:"email_address_1",listeners:{scope:this,change:this.onEmailAddressChange}}]},{xtype:"textfield",flex:1,anchor:"100%",name:"email_address_display_name_1",fieldLabel:_("Display name"),ref:"../mailDisplayNameField",
listeners:{scope:this,change:this.onFieldChange}},{xtype:"textfield",ref:"../webpageField",flex:1,anchor:"100%",fieldLabel:_("Webpage"),name:"webpage",listeners:{scope:this,change:this.onWebpageChange}},{xtype:"textfield",flex:1,anchor:"100%",fieldLabel:_("IM Address"),name:"im",listeners:{scope:this,change:this.onFieldChange}}]}},createAddressFieldset:function(a){return{title:_("Addresses"),defaultType:"zarafa.compositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{items:[{xtype:"splitbutton",
width:a.labelWidth-1,text:_("Business")+":",handler:this.handleAddressButtonClick,scope:this,menu:this.initAddressButtonMenu("business_address","business_address")},{xtype:"textarea",flex:1,name:"business_address",height:120,listeners:{scope:this,change:this.onAddressChange}}]}]}},createAdditionalFieldset:function(){return{title:_("Additional information"),items:[{xtype:"zarafa.editorfield",useHtml:false,ref:"../editorField",anchor:"100% 100%",height:120,listeners:{change:this.onBodyChange,scope:this}}]}},
createAttachmentFieldset:function(a){return{title:_("Attachments"),columnWidth:1,border:false,defaultType:"zarafa.resizablecompositefield",defaults:{hideLabel:true,anchor:"100%"},items:[{cls:"zarafa-contactcreatepanel-field-attachments",items:[{xtype:"zarafa.attachmentbutton",plugins:["zarafa.recordcomponentupdaterplugin"],width:a.labelWidth-1,autoHeight:true,text:_("Attachments")+":"},{xtype:"zarafa.attachmentfield",plugins:["zarafa.recordcomponentupdaterplugin"],flex:1,hideLabel:true}]}]}},initPhoneButtonMenu:function(a,
b){return{xtype:"menu",listeners:{click:this.onMenuItemSelection,scope:this},items:[{xtype:"menucheckitem",group:a,text:_("Assistant"),name:"assistant_telephone_number",checked:b==="assistant_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Business"),name:"business_telephone_number",checked:b==="business_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Business 2"),name:"business2_telephone_number",checked:b==="business2_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Business Fax"),
name:"business_fax_number",checked:b==="business_fax_number"},{xtype:"menucheckitem",group:a,text:_("Callback"),name:"callback_telephone_number",checked:b==="callback_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Car"),name:"car_telephone_number",checked:b==="car_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Company"),name:"company_telephone_number",checked:b==="company_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Home"),name:"home_telephone_number",checked:b===
"home_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Home 2"),name:"home2_telephone_number",checked:b==="home2_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Home Fax"),name:"home_fax_number",checked:b==="home_fax_number"},{xtype:"menucheckitem",group:a,text:_("ISDN"),name:"isdn_number",checked:b==="isdn_number"},{xtype:"menucheckitem",group:a,text:_("Mobile"),name:"cellular_telephone_number",checked:b==="cellular_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Other"),
name:"other_telephone_number",checked:b==="other_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Other Fax"),name:"primary_fax_number",checked:b==="primary_fax_number"},{xtype:"menucheckitem",group:a,text:_("Pager"),name:"pager_telephone_number",checked:b==="pager_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Primary"),name:"primary_telephone_number",checked:b==="primary_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Radio"),name:"radio_telephone_number",checked:b===
"radio_telephone_number"},{xtype:"menucheckitem",group:a,text:_("Telex"),name:"telex_telephone_number",checked:b==="telex_telephone_number"},{xtype:"menucheckitem",group:a,text:_("TTY/TDD"),name:"ttytdd_telephone_number",checked:b==="ttytdd_telephone_number"}]}},initAddressButtonMenu:function(a,b){return{xtype:"menu",listeners:{click:this.onMenuItemSelection,scope:this},items:[{xtype:"menucheckitem",group:a,text:_("Home"),name:"home_address",checked:b==="home_address"},{xtype:"menucheckitem",group:a,
text:_("Business"),name:"business_address",checked:b==="business_address"},{xtype:"menucheckitem",group:a,text:_("Other"),name:"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"),name:"email_address_1",checked:b==="email_address_1"},{text:_("Email 2"),name:"email_address_2",checked:b==="email_address_2"},{text:_("Email 3"),
name:"email_address_3",checked:b==="email_address_3"}]}},handlePhoneButtonClick:function(a){this.showDetailedPhoneContent(a.ownerCt.findByType("textfield")[0].getName())},handleAddressButtonClick:function(a){this.showDetailedAddressContent(a.ownerCt.findByType("textarea")[0].getName())},openAddressBook:function(){Zarafa.common.Actions.openABUserSelectionContent({callback:this.abCallBack,scope:this})},abCallBack:function(a){var b;b=(a.get("address_type")||"SMTP")==="ZARAFA"?a.get("smtp_address"):a.get("email_address");
this.mailAddressField.setValue(b);this.record.beginEdit();switch(this.mailAddressField.getName()){case "email_address_1":this.record.set("email_address_1",b);this.record.set("email_address_type_1","SMTP",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","SMTP",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","SMTP",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;this.getForm().loadRecord(a);a.isOpened()&&b&&this.updateContactPhoto();if(b){this.generateFileAsItems();this.fileAsField.selectByValue(a.get("fileas"),true)}a.isModifiedSinceLastUpdate("fileas")&&this.fileAsField.selectByValue(a.get("fileas"),true);b&&a.isOpened()&&this.editorField.setValue(a.getBody(this.editorField.isHtmlEditor()));
if(a.isModifiedSinceLastUpdate("display_name")||a.isModifiedSinceLastUpdate("company_name")){this.generateFileAsItems();this.updateFileas()}}},updateContactPhoto:function(){var a=this.record.getAttachmentStore(),b=this.contactPhotoBox.getEl();imgEl=new Ext.Element(Ext.getDoc().dom.createElement("img"));imgEl.on("load",this.onLoadContactPhoto,this,{single:true});b&&a.getCount()>0&&a.each(function(c){if(c.isContactPhoto()){imgEl.set({src:c.getInlineImageUrl()});b.setStyle({"background-image":"url("+
encodeURI(c.getInlineImageUrl())+")"});this.hasContactPhoto=true;this.record.set("has_picture",true);this.contactPhotoBox.removeClass("default_contact_photo");return false}},this)},onLoadContactPhoto:function(a,b){var c=this.contactPhotoBox.getEl(),d=Ext.get(b),e=c.up(".contact_photo_box_ct"),f=e.getPadding("lr");e=e.getWidth()-f-2;f=d.dom.naturalWidth;var g=d.dom.naturalHeight;if(f<e&&g<e){d=f;f=g}else if(f>g){d=e;f=e*g/f}else{d=e*f/g;f=e}c.setWidth(d);c.setHeight(f);c.setStyle({"background-size":d+
"px "+f+"px",left:(e-d)/2+"px",top:(e-f)/2+"px"})},onAfterRender:function(a){this.mon(a.getEl().up("div"),{click:this.onSingleClick,dblclick:this.onDoubleClick,contextmenu:this.onContextMenuClick,scope:this})},onContextMenuClick:function(a){if(this.hasContactPhoto){var b=this.getAttachedContactPhoto();Zarafa.core.data.UIFactory.openDefaultContextMenu(b,{position:a.getXY(),parent:this})}},getAttachedContactPhoto:function(){var a;this.record.getAttachmentStore().each(function(b){if(b.isContactPhoto())a=
b},this);return a},onSingleClick:function(){this.hasContactPhoto||this.uploadContactPhoto()},onDoubleClick:function(){this.hasContactPhoto&&this.uploadContactPhoto()},clearContactPhoto:function(a,b){a.remove(b);var c=this.contactPhotoBox.getEl();this.hasContactPhoto=false;this.record.set("has_picture",false);var d=this.contactPhotoBox.el.up(".contact_photo_box_ct");d=d.getWidth()-d.getPadding("lr")-2;c.set({src:Ext.BLANK_IMAGE_URL});c.setStyle({width:d+"px",height:d+"px",left:0,top:0,"background-image":"",
"background-size":"auto"});this.contactPhotoBox.addClass("default_contact_photo")},uploadContactPhoto:function(){this.mon(this.record.getAttachmentStore(),"update",this.updateContactPhoto,this);(new Zarafa.common.attachment.ui.UploadAttachmentComponent({callback:this.uploadContactPhotoCallback,accept:"image/*",scope:this})).openAttachmentDialog()},uploadContactPhotoCallback:function(a,b){var c=this.record.getAttachmentStore();this.beforeUploadContactPhoto(c);c.uploadFiles(a,b,true,{sourcetype:"contactphoto"})},
beforeUploadContactPhoto:function(a){var b=this.getAttachedContactPhoto();Ext.isDefined(b)&&a.remove(b)},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.name=b.name;c.el.dom.name=b.name;c.setValue(this.record.get(b.name))}}},onEmailMenuItemSelection:function(a,b,c){this.onMenuItemSelection(a,b,c);if(!Ext.isEmpty(this.mailDisplayNameField)){a=
b.name.replace("email_address","email_address_display_name");this.mailDisplayNameField.name=a;this.mailDisplayNameField.el.dom.name=a;this.mailDisplayNameField.setValue(this.record.get(a))}},generateFileAsItems:function(){var a=this.record,b=[],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))Ext.isEmpty(a)||b.push([a]);else{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];b.push([d])}else{d=c[c.length-1]+","+Zarafa.contact.data.config.NBSP;e=c.slice(0,c.length-1);d=d+e.join(Zarafa.contact.data.config.NBSP);b.push([d]);b.push([c.join(Zarafa.contact.data.config.NBSP)])}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))},updateRecord:function(a){a.beginEdit();var b=this.webpageField.getValue(),c=a.get(this.webpageField.getName());b!==c&&this.onWebpageChange(this.webpageField,b,c);b=this.fileAsField.getValue();c=a.get(this.fileAsField.getName());
b!==c&&this.onFileasChange(this.fileAsField,b,c);b=this.mailAddressField.getValue();c=a.get(this.mailAddressField.getName());b!==c&&this.onEmailAddressChange(this.mailAddressField,b,c);this.getForm().updateRecord(a);if(a.isModified("display_name")||a.isModified("display_name_prefix")||a.isModified("generation")||a.isModified("fileas"))a.updateSubject();this.onBodyChange(this.editorField.getEditor(),this.editorField.getValue());a.updateAddressbookProps();a.endEdit()},onFieldChange:function(a,b){a.validateValue(a.processValue(b))&&
this.record.set(a.getName(),b)},onBodyChange:function(a,b){var c=this.record,d=a instanceof Ext.form.HtmlEditor;c.beginEdit();c.setBody(b,d);c.endEdit()},onEmailAddressChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();this.record.set(a.getName(),b);switch(a.getName()){case "email_address_1":this.record.set("email_address_type_1","SMTP",true);break;case "email_address_2":this.record.set("email_address_type_2","SMTP",true);break;case "email_address_3":this.record.set("email_address_type_3",
"SMTP",true);break}this.record.updateAddressbookProps();this.record.endEdit()}},onFileasChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();this.record.set(a.getName(),b);this.record.set("fileas_selection",-1);this.record.endEdit()}},onWebpageChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.beginEdit();this.record.set(a.getName(),b);this.record.set("business_home_page",b);this.record.endEdit()}},onDisplayNameChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.set(a.getName(),
b);(function(){var c=this.getContactParser().parseInfo("name",b);this.record.beginEdit();this.record.set("display_name_prefix",c.display_name_prefix);this.record.set("given_name",c.given_name);this.record.set("middle_name",c.middle_name);this.record.set("surname",c.surname);this.record.set("generation",c.generation);this.record.endEdit();container.getSettingsModel().get("zarafa/v1/contexts/contact/show_name_dialog")===true&&!Ext.isEmpty(b)&&c.incomplete_info===true&&this.showDetailedNameContent(c)}).defer(1,
this)}},onAddressChange:function(a,b){if(a.validateValue(a.processValue(b))){this.record.set(a.getName(),b);(function(){var c=this.getContactParser().parseInfo("address",b),d=a.getName();this.record.beginEdit();this.record.set(d+"_street",c.street);this.record.set(d+"_city",c.city);this.record.set(d+"_state",c.state);this.record.set(d+"_postal_code",c.postal_code);this.record.set(d+"_country",c.country);this.record.endEdit();container.getSettingsModel().get("zarafa/v1/contexts/contact/show_address_dialog")===
true&&!Ext.isEmpty(b)&&c.incomplete_info===true&&this.showDetailedAddressContent(d,c)}).defer(1,this)}},showDetailedNameContent:function(a){Zarafa.contact.Actions.openDetailedNameContent(this.record,{parser:this.getContactParser(),parsedData:a})},showDetailedAddressContent:function(a,b){Zarafa.contact.Actions.openDetailedAddressContent(this.record,{parser:this.getContactParser(),parsedData:b,property:a})},showDetailedPhoneContent:function(a){Zarafa.contact.Actions.openDetailedPhoneContent(this.record,
{parser:this.getContactParser(),property:a})},getContactParser:function(){return this.dialog.contactParser}});Ext.reg("zarafa.contactgeneraltab",Zarafa.contact.dialogs.ContactGeneralTab);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistExternalMemberContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{parentRecord:undefined,record:undefined,formPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.distlistexternalmembercontentpanel",title:_("New e-mail address"),layout:"fit",items:this.createFormItems()});Zarafa.contact.dialogs.DistlistExternalMemberContentPanel.superclass.constructor.call(this,a);this.on("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()}});
Ext.reg("zarafa.distlistexternalmembercontentpanel",Zarafa.contact.dialogs.DistlistExternalMemberContentPanel);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",headerCls:"zarafa-icon-column",header:'<p class="icon_index">&nbsp;</p>',tooltip:_("Sort by: Icon"),width:24,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.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,contextmenu:this.onNodeContextMenu,
selectionchange:this.onSelectionChange,scope:this})},onNodeContextMenu:function(a,b,c,d){a.isSelected(c)||a.select(c);Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelectedRecords(),{position: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.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:_("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)},onContextItemCategories:function(){Zarafa.common.Actions.openCategoriesContent(this.records)},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.ContactGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true,width:150}});Zarafa.contact.ui.ContactGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column icon",header:'<p class="icon_index">&nbsp;<span class="title">'+_("Icon")+"</span></p>",tooltip:_("Sort by: Icon"),width:25,fixed:true,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.ContactMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactmainpanel",layout:"fit",items:[{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.contactgrid",id:"contact-gridview",context:a},{xtype:"zarafa.contactcardpanel",id:"contact-cardview",context:a}];a=container.populateInsertionPoint("context.contact.views",this,a);return b=b.concat(a)},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.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,i,h){return new Zarafa.hierarchy.data.HierarchyResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:h,callback:g,scope:i})}});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.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.dialogs");
Zarafa.hierarchy.dialogs.CreateFolderContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{parentFolder:undefined,preferredContainerClass:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.createfoldercontentpanel",layout:"fit",title:_("Create New Folder"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true,ignoreUpdates:false,useShadowStore:true}),width:330,height:380,items:[{xtype:"zarafa.createfolderpanel",parentFolder:a.parentFolder,
preferredContainerClass:a.preferredContainerClass}]});Zarafa.hierarchy.dialogs.CreateFolderContentPanel.superclass.constructor.call(this,a)},onUpdateRecord:function(a,b){Zarafa.hierarchy.dialogs.CreateFolderContentPanel.superclass.onUpdateRecord.apply(this,arguments);if(b==Ext.data.Record.COMMIT){this.close();return false}}});Ext.reg("zarafa.createfoldercontentpanel",Zarafa.hierarchy.dialogs.CreateFolderContentPanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderSelectionContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{folder:undefined,callback:Ext.emptyFn,scope:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",title:_("Select Folder"),width:330,height:380,items:[{xtype:"zarafa.folderselectionpanel",folder:a.folder,buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.hierarchy.dialogs.FolderSelectionContentPanel.superclass.constructor.call(this,
a)},onOk:function(){if(Ext.isFunction(this.callback))this.callback.call(this.scope||this,this.get(0).getFolder());this.close()},onCancel:function(){this.close()}});Ext.reg("zarafa.folderselectioncontentpanel",Zarafa.hierarchy.dialogs.FolderSelectionContentPanel);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(a)],defaults:{xtype:"zarafa.conditionalitem",scope:this}});Zarafa.hierarchy.ui.ContextMenu.superclass.constructor.call(this,a)},createContextMenuItems:function(a){return[{text:_("Open"),iconCls:"icon_open",handler:this.onContextItemOpen,
beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||c.isIPMSubTree()&&!c.getMAPIStore().isDefaultStore()?b.setDisabled(true):b.setDisabled(false)}},{xtype:"menuseparator"},{text:_("Copy/Move Folder"),iconCls:"icon_copy",handler:this.onContextCopyMoveFolder,beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||c.isIPMSubTree()||c.isRSSFolder()||c.isDefaultFolder()?b.setDisabled(true):b.setDisabled(false)}},{text:_("Rename Folder"),iconCls:"icon_folder_rename",
handler:this.onContextItemRenameFolder,beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_MODIFY)||c.isIPMSubTree()||c.isRSSFolder()||c.isDefaultFolder()||!this.contextTree||!this.contextNode?b.setDisabled(true):b.setDisabled(false)}},{text:_("New Folder"),iconCls:"icon_createFolderColor",handler:this.onContextItemNewFolder,beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_CREATE_HIERARCHY)||c.getMAPIStore().isArchiveStore()?b.setDisabled(true):b.setDisabled(false)}},
{xtype:"menuseparator"},{text:_("Mark All Messages Read"),iconCls:"icon_mark_all_read",handler:this.onContextItemReadFlags,beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_READ)||c.isIPMSubTree()?b.setDisabled(true):b.setDisabled(false)}},{xtype:"menuseparator"},{text:_("Delete Folder"),iconCls:"icon_folder_delete",handler:this.onContextItemDeleteFolder,beforeShow:function(b,c){!(c.get("access")&Zarafa.core.mapi.Access.ACCESS_DELETE)||c.isIPMSubTree()||c.isDefaultFolder()||
c.isRSSFolder()||c.getMAPIStore().isArchiveStore()?b.setDisabled(true):b.setDisabled(false)}},{text:_("Empty folder"),iconCls:"icon_empty_trash",handler:this.onContextItemEmptyFolder,beforeShow:function(b,c){c.get("access")&Zarafa.core.mapi.Access.ACCESS_READ&&c.isSpecialFolder("wastebasket")||c.isSpecialFolder("junk")?b.setDisabled(false):b.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Add to favorites folder"),iconCls:"icon_folder_add_favorite",beforeShow:function(b,c){c.get("access");b.setDisabled(true)}},
{xtype:"menuseparator"},{text:_("Close store"),iconCls:"icon_store_close",handler:this.onContextItemCloseStore,scope:this,beforeShow:function(b,c){c.isIPMSubTree()&&c.getMAPIStore().isSharedStore()?b.setDisabled(false):b.setDisabled(true)}},{text:_("Close folder"),iconCls:"icon_folder_close",handler:this.onContextItemCloseFolder,scope:this,beforeShow:function(b,c){!c.isIPMSubTree()&&c.isSharedFolder()?b.setDisabled(false):b.setDisabled(true)}},{xtype:"menuseparator"},{text:_("Reload"),iconCls:"icon_refresh",
handler:this.onContextItemReload,scope:this,beforeShow:function(b,c){c.isOwnRoot()?b.setDisabled(false):b.setDisabled(true)}},{text:_("Restore items"),handler:this.onContextItemRestore,iconCls:"icon_restore",beforeShow:function(b,c){c.get("access")?b.setDisabled(false):b.setDisabled(true)}},{text:_("Select color"),iconCls:"icon-select-color",beforeShow:function(b){var c=this.contextNode.id,d=this.contextTree.model;if(!this.contextTree.colored||!Ext.isDefined(d))b.setDisabled(true);else{b.setDisabled(false);
c=d.getColorScheme(c);b.iconBG=c.base}},menu:this.createSelectColorSubmenu(a)},{text:_("Properties"),handler:this.onContextItemProperties,iconCls:"icon_openMessageOptions",beforeShow:function(b,c){c.get("access")?b.setDisabled(false):b.setDisabled(true)}}]},createSelectColorSubmenu:function(a){var b=[],c=a.contextTree.model;if(!c)return b;c=c.colorScheme;var d=a.contextNode.getFolder().colorTheme;Ext.each(c,function(e){b.push({xtype:"zarafa.conditionalitem",text:e.displayName,ctCls:d===e.name?"x-menu-item-selected":
"",iconCls:"icon-select-color color-"+e.name,colorSchemeName:e.name,handler:this.onContextItemSelectColor.createDelegate(this),iconBG:e.header})},this);return b},onContextItemOpen:function(){this.contextTree&&this.contextTree.selectFolderInTree(this.records);Zarafa.hierarchy.Actions.openFolder(this.records)},onContextCopyMoveFolder:function(){Zarafa.common.Actions.openCopyMoveContent(this.records)},onContextItemRenameFolder:function(){this.contextTree.startEditingNode(this.contextNode)},onContextItemNewFolder:function(){Zarafa.hierarchy.Actions.openCreateFolderContent(this.records)},
onContextItemDeleteFolder:function(){var a=this.records.isInDeletedItems()||this.records.getMAPIStore().isPublicStore(),b;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()},onContextItemSelectColor:function(a){var b=this.contextTree.model,c=a.getRecords(),d=b.getStore();a=Zarafa.core.ColorSchemes.getColorScheme(a.colorSchemeName);b.setColorScheme(c.get("entryid"),a);(b=this.contextNode.getUI().getEl().querySelector("svg"))&&Ext.get(b).setStyle("color",a.base);d&&d.lastOptions&&!d.isExecuting("list")&&d.fireEvent("load",d,d.getRange(),d.lastOptions)},onContextItemProperties:function(){Zarafa.hierarchy.Actions.openFolderPropertiesContent(this.records,
{modal:true,showModalWithoutParent:true})},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()},onContextItemRestore:function(){Zarafa.common.Actions.openRestoreContent(this.records)}});Ext.reg("zarafa.hierarchycontextmenu",Zarafa.hierarchy.ui.ContextMenu);
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 i=false;this.allowParentInsert||(i=c.hasChildNodes()&&c.isExpanded());c=(d-e)/(g?2:3);return f>=e&&f<e+c?"above":!i&&(g||f>=d-c&&f<=d)?"below":"append"}});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.HierarchyTreePanel=Ext.extend(Zarafa.hierarchy.ui.Tree,{enableItemDrop:false,itemDropZone:undefined,itemDropConfig:undefined,bbarConfig: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,statefulName:"hierarchytree",tbar:{items:[{xtype:"checkbox",
cls:"zarafa-hierarchy-treepanel-showallfolders",ref:"../showAllFoldersCheckbox",boxLabel:_("Show all folders"),checked:b,listeners:{beforerender:this.reviseCheckboxDisablity,check:this.onCheckShowAllFoldersCheckbox,scope:this}}]},loadMask:true,treeSorter:true,trackMouseOver:true,containerScroll:true,dragConfig:{ddGroup:"dd.mapifolder"},dropConfig:{ddGroup:"dd.mapifolder",expandDelay:250,allowParentInsert:true},enableItemDrop:true,itemDropConfig:{ddGroup:"dd.mapiitem"}});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.on("afterrender",function(){this.on("expandnode",this.checkTreeHeight,this);this.on("collapsenode",this.checkTreeHeight,this);this.on("afterlayout",this.checkTreeHeight,this);this.on("append",this.checkTreeHeight,this);this.on("remove",this.checkTreeHeight,this);this.on("resize",
this.checkTreeHeight,this)},this,{single:true});this.on("contextmenu",this.onTreeNodeContextMenu,this);this.on("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);this.mon(container,"contextswitch",this.reviseCheckboxDisablity,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.on("expandnode",this.saveFolderState,this,{buffer:5});this.on("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.on("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.on("itemdrop",this.onItemDrop,this)}Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.initEvents.call(this)},initStateEvents:function(){Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.initStateEvents.call(this);this.mon(this.showAllFoldersCheckbox,"check",this.saveState,this,{delay:100})},checkTreeHeight:function(){if(this.ownerCt){var a=this.body.down("ul").getHeight(),b=this.ownerCt.getHeight(),
c=this.getTopToolbar().getHeight(),d=this.getBottomToolbar().getHeight();b<a+d+c?this.ownerCt.getEl().addClass("fixed-bottombar"):this.ownerCt.getEl().removeClass("fixed-bottombar")}},reviseCheckboxDisablity:function(a,b,c){c=c||container.getCurrentContext();this.showAllFoldersCheckbox.setDisabled(c==container.getContextByName("settings")||c==container.getContextByName("today"))},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(b.isSpecialFolder("wastebasket"))Zarafa.common.Actions.deleteRecords(c);else 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)}b.isSpecialFolder("wastebasket")||
d.save(c)}},onStoreRemove:function(a,b){var c=b.getSubStore("folders");this.model&&c.each(function(d){this.model.removeFolder(d)},this)},onFolderRemove:function(a,b,c){this.model&&this.model.removeFolder(c)},onFolderSelect:function(a){if(Ext.isArray(a))a=a.length>1&&this.model?this.model.getDefaultFolder():a[0];a&&this.selectFolderInTree(a)},onHierarchyLoaderLoad:function(){if(this.model){for(var a=this.model.getFolders(),b=0,c=a.length;b<c;b++)this.selectFolderInTree(a[b]);a.length>1&&this.model&&
this.selectFolderInTree(this.model.getDefaultFolder())}},onTreeNodeContextMenu:function(a,b){var c=b.getXY();if(c[0]===0&&c[1]===0){c=a.ui.anchor.getBoundingClientRect();c=[c.left,c.top]}Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getFolder(),{position:c,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().getState(b,"tree").is_open!==a.expanded&&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)},getState:function(){var a=Zarafa.hierarchy.ui.HierarchyTreePanel.superclass.getState.call(this)||{},b=this.showAllFoldersCheckbox.getValue();return Ext.apply(a,{showallcheckbox:b})},
getStateName:function(){return"sidebars/"+Zarafa.core.ui.MainViewSidebar.superclass.getStateName.call(this)}});Ext.reg("zarafa.hierarchytreepanel",Zarafa.hierarchy.ui.HierarchyTreePanel);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()||a.get("is_unavailable")===true},getTextFromFolder:function(a){return this.attributes.extendedDisplayName?a.getFullyQualifiedDisplayName():Zarafa.hierarchy.ui.RootFolderNode.superclass.getTextFromFolder.call(this,a)}});Ext.tree.TreePanel.nodeTypes.rootfolder=Zarafa.hierarchy.ui.RootFolderNode;Ext.namespace("Zarafa.mail.attachitem");
Zarafa.mail.attachitem.AttachMailColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.getColumns(),defaults:{sortable:true}});Zarafa.mail.attachitem.AttachMailColumnModel.superclass.constructor.call(this,a)},getColumns:function(){return[{header:"<p class='icon_importance'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"importance",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.importance,tooltip:_("Sort by: Importance")},
{header:"<p class='icon_index'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"icon_index",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.icon,tooltip:_("Sort by: Icon")},{header:"<p class='icon_attachment'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"hasattach",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.attachment,tooltip:_("Sort by: Attachment")},{header:_("From"),dataIndex:"sent_representing_name",width:100,renderer:Zarafa.common.ui.grid.Renderers.sender,
tooltip:_("Sort by: From")},{header:_("To"),dataIndex:"display_to",width:100,renderer:Zarafa.common.ui.grid.Renderers.to,tooltip:_("Sort by: To")},{header:_("Subject"),dataIndex:"subject",renderer:Zarafa.common.ui.grid.Renderers.subject,tooltip:_("Sort by: Subject")},{header:_("Received"),dataIndex:"message_delivery_time",width:180,renderer:Zarafa.common.ui.grid.Renderers.datetime,tooltip:_("Sort by: Received")},{header:_("Categories"),dataIndex:"categories",width:160,renderer:Zarafa.common.ui.grid.Renderers.text,
tooltip:_("Sort by: Categories")}]}});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,beforeShow:Zarafa.mail.dialogs.MailFlagsMenu.onMenuItemBeforeShow,menu:{xtype:"zarafa.conditionalmenu",items:a}}};
Zarafa.mail.dialogs.MailFlagsMenu.onMenuItemBeforeShow=function(a,b){Ext.each(b,function(c){if(c.isFaultyMessage()){a.setVisible(false);return false}},this)};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,beforeShow:Zarafa.mail.dialogs.MailFlagsMenu.onMenuItemBeforeShow})},this);return b};Ext.reg("zarafa.mailflagsmenu",Zarafa.mail.dialogs.MailFlagsMenu);
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"}]},c={xtype:"jsonstore",autoDestroy:true,fields:["name","value"],data:Zarafa.common.ui.htmleditor.Fonts.getFontFamilies().split(";").map(function(g){return{name:g.split("=")[0],value:g.split("=")[1].toLowerCase()}})},d=Zarafa.common.ui.htmleditor.Fonts.getFonts(),
e=[];for(var f in d)e.push({name:d[f]+"pt",value:f});d={xtype:"jsonstore",autoDestroy:true,fields:["name","value"],data:e};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:"combo",name:"zarafa/v1/main/default_font",cls:"x-font-select",fieldLabel:_("Default font"),width:200,ref:"fontCombo",store:c,triggerAction:"all",mode:"local",displayField:"name",valueField:"value",editable:false,autoSelect:true,forceSelection:true,lazyInit:false,listeners:{select:this.onFontSelect,scope:this}},{xtype:"combo",name:"zarafa/v1/main/default_font_size",cls:"x-font-select",fieldLabel:_("Default font size"),width:200,ref:"fontSizeCombo",store:d,triggerAction:"all",mode:"local",
displayField:"name",valueField:"value",editable:false,autoSelect:true,forceSelection:true,lazyInit:false,listeners:{select:this.onFontSelect,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}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("{A}AutoSave unsent mail every {B} minute(s)"),labelWidth:250,combineErrors:false,
items:[{xtype:"checkbox",labelSplitter:"{A}",name:"zarafa/v1/contexts/mail/autosave_enable",ref:"../autoSaveBox",boxLabel:"",hideLabel:true,checked:true,listeners:{check:this.onAutoSaveCheckBoxChange,change:this.onFieldChange,scope:this}},{xtype:"zarafa.spinnerfield",labelSplitter:"{B}",vtype:"naturalInteger",name:"zarafa/v1/contexts/mail/autosave_time",ref:"../autoSaveTimeSpinner",incrementValue:1,defaultValue:1,minValue:1,allowBlank:false,allowDecimals:false,allowNegative:false,listeners:{change:this.onFieldChange,
scope:this},plugins:["zarafa.numberspinner"]}]}]});Zarafa.mail.settings.SettingsComposeWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;var b=a.get(this.composerCombo.name);this.composerCombo.setValue(b?"html":"plain");this.fontCombo.setValue(a.get(this.fontCombo.name));this.fontSizeCombo.setValue(a.get(this.fontSizeCombo.name));this.fontCombo.setDisabled(b!==true);this.fontSizeCombo.setDisabled(b!==true);this.readBox.setValue(a.get(this.readBox.name));this.autoSaveBox.setValue(a.get(this.autoSaveBox.name));
this.autoSaveTimeSpinner.setValue(a.get(this.autoSaveTimeSpinner.name)/60)},updateSettings:function(a){var b=this.autoSaveTimeSpinner.getValue();b=b===0||!Ext.isDefined(b)?a.get("zarafa/v1/contexts/mail/autosave_time",false,true):b*60;a.beginEdit();a.set(this.composerCombo.name,this.composerCombo.getValue()==="html");a.set(this.readBox.name,this.readBox.getValue());a.set(this.autoSaveTimeSpinner.name,b);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");this.fontCombo.setDisabled(c!=="html");this.fontSizeCombo.setDisabled(c!=="html")}},onFieldChange:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)},onAutoSaveCheckBoxChange:function(a,b){this.onFieldChange(a,b);this.autoSaveTimeSpinner.setDisabled(!b)},onFontSelect: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.settingscomposewidget",Zarafa.mail.settings.SettingsComposeWidget);
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}},{xtype:"zarafa.compositefield",plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("{A}Automatically mark mail as read after {B} second(s)"),labelWidth:250,items:[{xtype:"checkbox",labelSplitter:"{A}",name:"zarafa/v1/contexts/mail/readflag_time_enable",ref:"../readFlagTimeCheckbox",
boxLabel:"",hideLabel:true,listeners:{check:this.onCheckboxChange,scope:this}},{xtype:"zarafa.spinnerfield",labelSplitter:"{B}",name:"zarafa/v1/contexts/mail/readflag_time",ref:"../readFlagTimeSpinner",incrementValue:1,defaultValue:0,minValue:0,listeners:{change:this.onFieldChange,scope:this},plugins:["zarafa.numberspinner"]}]}]});Zarafa.mail.settings.SettingsIncomingMailWidget.superclass.constructor.call(this,a)},update:function(a){this.model=a;var b=a.get(this.readFlagTimeCheckbox.name);this.readFlagTimeCheckbox.setValue(b);
this.readFlagTimeSpinner.setValue(a.get(this.readFlagTimeSpinner.name));this.readReceiptGroup.setValue(a.get(this.readReceiptGroup.name));this.readFlagTimeSpinner.setDisabled(!b)},updateSettings:function(a){a.beginEdit();a.set(this.readReceiptGroup.name,this.readReceiptGroup.getValue().inputValue);a.set(this.readFlagTimeCheckbox.name,this.readFlagTimeCheckbox.getValue());a.set(this.readFlagTimeSpinner.name,this.readFlagTimeSpinner.getValue());a.endEdit()},onRadioChange:function(a,b){this.model&&this.model.get(a.name)!==
b.inputValue&&this.model.set(a.name,b.inputValue)},onFieldChange:function(a,b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)},onCheckboxChange:function(a,b){this.onFieldChange(a,b);this.readFlagTimeSpinner.setDisabled(!b)}});Ext.reg("zarafa.settingsincomingmailwidget",Zarafa.mail.settings.SettingsIncomingMailWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsMailCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};var b=[{xtype:"zarafa.settingsmailwidget"},{xtype:"zarafa.settingscomposewidget"},container.populateInsertionPoint("context.settings.category.mail.aftercomposesettings",this),{xtype:"zarafa.settingsincomingmailwidget"},{xtype:"zarafa.settingssignatureswidget"},container.populateInsertionPoint("context.settings.category.mail",this)];Ext.applyIf(a,{title:_("Mail"),categoryIndex:1,
iconCls:"zarafa-settings-category-mail",items:b});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.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 of preview pane"),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}},{xtype:"checkbox",name:"zarafa/v1/contexts/mail/close_on_respond",ref:"closeCheck",boxLabel:_("Close original message on reply or forward"),hideLabel:true,lazyInit:false,listeners:{check:this.onCheck,scope:this}}]});Zarafa.mail.settings.SettingsMailWidget.superclass.constructor.call(this,
a)},update:function(a){this.model=a;var b=a.get(this.previewCombo.name);if(!Ext.isDefined(b))b=Zarafa.mail.data.ViewModes.RIGHT_PREVIEW;this.previewCombo.setValue(b);this.closeCheck.setValue(a.get(this.closeCheck.name))},updateSettings:function(a){a.set(this.previewCombo.name,this.previewCombo.getValue());a.set(this.closeCheck.name,this.closeCheck.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)}},onCheck:function(a,
b){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)}});Ext.reg("zarafa.settingsmailwidget",Zarafa.mail.settings.SettingsMailWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsOofWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{useOldVersion:false,constructor:function(a){a=a||{};var b=container.getVersion(),c=b.getZCP();this.useOldVersion=b.versionCompare(c,"7.2.1")===-1;Ext.applyIf(a,{title:_("Out of Office"),favorite:true,iconCls:"zarafa-settings-favorite-oof"});Ext.applyIf(a,this.useOldVersion?this.getOldConfig():this.getNewConfig());Zarafa.mail.settings.SettingsOofWidget.superclass.constructor.call(this,a);if(!this.useOldVersion){this.outOfOfficeDateTimeField.dateField.on("selectnow",
this.onOutOfOfficeSelectNow,this);this.backDateTimeField.dateField.on("selectnow",this.onBackSelectNow,this)}},getOldConfig:function(){return{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}}]}},getNewConfig:function(){return{items:[{xtype:"radio",name:"zarafa/v1/contexts/mail/outofoffice/set",inputValue:"false",boxLabel:_("I am currently in the office"),hideLabel:true,ref:"inOfficeField",listeners:{check:this.onRadioChecked,scope:this}},{xtype:"container",layout:{type:"table",columns:3},border:false,style:{paddingBottom:"25px"},items:[{xtype:"radio",name:"zarafa/v1/contexts/mail/outofoffice/set",hideLabel:true,boxLabel:_("I am out of the office from")+":",ref:"../outOfOfficeRadio",
cellCls:"zarafa-settings-oof-table-cellpadding",inputValue:"true",listeners:{check:this.onRadioChecked,scope:this}},{xtype:"zarafa.datetimefield",ref:"../outOfOfficeDateTimeField",name:"zarafa/v1/contexts/mail/outofoffice/from",dateFieldConfig:{showNow:true,invalidClass:"zarafa-settings-oof-invalid"},fieldLabel:"",width:200,hideLabel:true,dateFormat:_("d/m/Y"),timeFormat:_("G:i"),minValue:new Date,defaultValue:new Date,timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),
listeners:{change:this.onOutOfOfficeChange,scope:this}},{xtype:"displayfield"},{xtype:"checkbox",disabled:true,name:"zarafa/v1/contexts/mail/autosave_enable",ref:"../willBeBackCheckBox",cellCls:"zarafa-settings-oof-table-cellpadding",boxLabel:_("I will be back on")+":",hideLabel:true,listeners:{render:this.onWillBeBackCheckRender,check:this.onWillBeBackCheck,scope:this}},{xtype:"zarafa.datetimefield",fieldLabel:"",ref:"../backDateTimeField",cellCls:"zarafa-settings-oof-table-cellpadding",name:"zarafa/v1/contexts/mail/outofoffice/until",
dateFieldConfig:{showNow:true,invalidClass:"zarafa-settings-oof-invalid"},timeFieldConfig:{invalidClass:"zarafa-settings-oof-invalid"},width:200,disabled:true,hideLabel:true,dateFormat:_("d/m/Y"),timeFormat:_("G:i"),minValue:new Date,defaultValue:(new Date).getNextWorkWeekDay().clearTime().add(Date.MINUTE,container.getSettingsModel().get("zarafa/v1/main/start_working_hour")),timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),listeners:{change:this.backDateTimeChange,
scope:this}},{xtype:"displayfield",width:"100%",cellCls:"zarafa-settings-oof-table-cellpadding",ref:"../oofWarning"}]},{xtype:"container",cls:"zarafa-settings-oof-subject",anchor:"100%",layout:"hbox",items:[{xtype:"displayfield",cls:"label-subject",value:_("Subject")+":",autoWidth:true},{xtype:"textfield",name:"zarafa/v1/contexts/mail/outofoffice/subject",ref:"../subjectField",emptyText:_("Out of Office"),flex:1,listeners:{change:this.onFieldChange,scope:this}}]},{xtype:"displayfield",anchor:"100%",
cls:"zarafa-settings-oof-autoreplay",hideLabel:true,value:_("AutoReply only once to each sender with the following text")+":"},{xtype:"textarea",anchor:"100%",name:"zarafa/v1/contexts/mail/outofoffice/message",ref:"bodyField",hideLabel:true,emptyText:_("User is currently out of office."),listeners:{change:this.onFieldChange,scope:this}}]}},onWillBeBackCheckRender:function(a){a.wrap.addClass("zarafa-settings-oof-table-cellalign")},update:function(a){this.model=a;if(this.useOldVersion)this.oofField.setValue(a.get(this.oofField.name).toString());
else{var b=a.get(this.inOfficeField.name);this.inOfficeField.setValue(!b);this.outOfOfficeRadio.setValue(b);if(b){b=a.get(this.outOfOfficeDateTimeField.name);var c=a.get(this.backDateTimeField.name);b!==0&&this.outOfOfficeDateTimeField.setValue(new Date(b*1E3));if(c!==0){this.backDateTimeField.setValue(new Date(c*1E3));this.willBeBackCheckBox.setValue(true)}}}this.subjectField.setValue(a.get(this.subjectField.name));this.bodyField.setValue(a.get(this.bodyField.name))},updateSettings:function(a){var b=
this.subjectField.getValue()||this.subjectField.emptyText,c=this.bodyField.getValue()||this.bodyField.emptyText;a.beginEdit();a.set(this.subjectField.name,b);a.set(this.bodyField.name,c);if(this.useOldVersion){b=this.oofField.getValue().inputValue==="true";a.set(this.oofField.name,b)}else{a.set(this.outOfOfficeRadio.name,this.outOfOfficeRadio.getValue());if(this.outOfOfficeRadio.getValue()){a.set(this.outOfOfficeDateTimeField.name,this.outOfOfficeDateTimeField.getValue().getTime()/1E3);this.willBeBackCheckBox.getValue()===
true?a.set(this.backDateTimeField.name,this.backDateTimeField.getValue().getTime()/1E3):a.set(this.backDateTimeField.name,0)}}a.endEdit()},onOutOfOfficeSelectNow:function(){this.outOfOfficeDateTimeField.timeField.setValue(new Date)},onBackSelectNow:function(){this.backDateTimeField.timeField.setValue(new Date)},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)},onRadioChecked:function(a,
b){if(b===true){var c=a.inputValue==="true";this.model&&this.model.get(a.name)!==c&&this.model.set(a.name,c);this.subjectField.setDisabled(!c);this.bodyField.setDisabled(!c);this.outOfOfficeDateTimeField.setDisabled(!c);this.willBeBackCheckBox.setDisabled(!c);this.willBeBackCheckBox.getValue()===true&&this.willBeBackCheckBox.setValue(false);this.reviseWarningStatus()}},onWillBeBackCheck:function(a,b){this.backDateTimeField.setDisabled(!b);this.reviseWarningStatus()},onFieldChange:function(a,b){if(this.model)this.model.set(a.name,
b||a.emptyText)},onOutOfOfficeChange:function(a,b){this.backDateTimeField.dateField.setMinValue(b);this.reviseWarningStatus();if(this.model)this.model.set(a.name,b||a.defaultValue)},backDateTimeChange:function(a,b){this.reviseWarningStatus();if(this.model)this.model.set(a.name,b||a.defaultValue)},reviseWarningStatus:function(){if(this.outOfOfficeDateTimeField.getValue()>=this.backDateTimeField.getValue()&&this.willBeBackCheckBox.getValue()===true){this.oofWarning.setValue(_("The time you entered is before the out of office date. Please reschedule."));
this.backDateTimeField.dateField.markInvalid();this.backDateTimeField.timeField.markInvalid()}else{this.oofWarning.reset();this.backDateTimeField.dateField.clearInvalid();this.backDateTimeField.timeField.clearInvalid()}}});Ext.reg("zarafa.settingsoofwidget",Zarafa.mail.settings.SettingsOofWidget);Ext.namespace("Zarafa.mail.settings");
Zarafa.mail.settings.SettingsOutOfOfficeCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Out of Office"),categoryIndex:2,iconCls:"zarafa-settings-category-oof",items:[{xtype:"zarafa.settingsoofwidget"},container.populateInsertionPoint("context.settings.category.outofoffice",this)]});Zarafa.mail.settings.SettingsOutOfOfficeCategory.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingsoutofofficecategory",Zarafa.mail.settings.SettingsOutOfOfficeCategory);
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",cls:"zarafa-settings-signatures",columnWidth:0.5,height:200,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",htmlName:"content",plaintextName:"content",ref:"contentField",anchor:"100%",height:300,disableEditor:true,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,i=b.length;g<i;g++){var h;h=Ext.apply({},b[g].data);e.push(new a.recordType(h,b[g].id));h=Ext.apply({},b[g].data);f.push(new d.recordType(h,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")}}b.length!==0?a.set(this.signaturesGrid.name,c):a.remove(this.signaturesGrid.name);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.bindRecord();this.contentField.setValue("");this.contentField.disable();this.saveSignatureBtn.disable();this.signaturesGrid.getSelectionModel().clearSelections()}else{this.selectedSignature=a;this.dirtySelectedSignature=false;this.delSignatureBtn.enable();this.nameField.setValue(a.get("name"));
this.nameField.enable();this.contentField.bindRecord(a);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.contentField.isHtmlEditor(),b=this.signaturesGrid.getStore();a=new b.recordType({id:(new Date).getTime(),name:_("New signature"),isHTML:a});b.add(a);this.model&&this.model.set(this.signaturesGrid.name+"/"+a.get("id"),{name:a.get("name"),content:a.get("content"),isHTML:a.get("isHTML")});
this.signaturesGrid.getSelectionModel().selectRecords([a]);this.doSelectSignature(a);a.set("content",this.contentField.getRawValue())},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.getRawValue());a.set("isHTML",this.contentField.isHtmlEditor(),true);a.commit();this.dirtySelectedSignature=false}},onRejectSignature:function(){var a=this.selectedSignature;if(a){this.nameField.setValue(a.get(this.nameField.name));this.contentField.setValue("");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.getRawValue())}return this.dirtySelectedSignature}else return false}});Ext.reg("zarafa.settingssignatureswidget",Zarafa.mail.settings.SettingsSignaturesWidget);
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();this.defaultColumns=this.defaultColumns.concat(container.populateInsertionPoint("context.mail.griddefaultcolumn",this)||[]);Ext.applyIf(a,{columns:this.defaultColumns,defaults:{sortable:true}});if(a.useCompactView===true)a.columns=this.compactColumns;Zarafa.mail.ui.MailGridColumnModel.superclass.constructor.call(this,
a)},createDefaultColumns:function(){return[{header:'<p class="icon_importance">&nbsp;<span class="title">'+_("Importance")+"</span></p>",headerCls:"zarafa-icon-column importance",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;<span class="title">'+_("Icon")+"</span></p>",headerCls:"zarafa-icon-column icon",dataIndex:"icon_index",width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,
fixed:true,tooltip:_("Sort by: Icon"),preventRowSelection:true},{header:'<p class="icon_attachment">&nbsp;<span class="title">'+_("Attachment")+"</span></p>",headerCls:"zarafa-icon-column attachment",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.sender,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.createDelegate(null,[{css:"mail-received"}],
true),tooltip:_("Sort by: Received")},{header:_("Sent"),dataIndex:"client_submit_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime.createDelegate(null,[{css:"mail-sent"}],true),tooltip:_("Sort by: Sent")},{header:_("Modified"),dataIndex:"last_modification_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime.createDelegate(null,[{css:"mail-modified"}],true),hidden:true,tooltip:_("Sort by: Modified")},{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;<span class="title">'+_("Flag Status")+"</span></p>",headerCls:"zarafa-icon-column icon",dataIndex:"flag_status",width:24,renderer:Zarafa.common.ui.grid.Renderers.flag,fixed:true,tooltip:_("Sort by: Flag Status"),preventRowSelection:true}]},createCompactColumns:function(){return[{header:'<p class="icon_index">&nbsp;<span class="title">'+_("Icon")+"</span></p>",dataIndex:"icon_index",headerCls:"zarafa-icon-column icon",
width:24,renderer:Zarafa.common.ui.grid.Renderers.icon,fixed:true,tooltip:_("Sort by: Icon"),preventRowSelection:true},{header:_("From"),dataIndex:"sent_representing_name",width:160,renderer:Zarafa.common.ui.grid.Renderers.sender,tooltip:_("Sort by: From")},{header:_("To"),dataIndex:"display_to",width:160,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.createDelegate(null,
[{css:"mail-received"}],true),tooltip:_("Sort by: Received")},{header:_("Sent"),dataIndex:"client_submit_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime.createDelegate(null,[{css:"mail-sent"}],true),tooltip:_("Sort by: Sent")},{header:_("Modified"),dataIndex:"last_modification_time",width:160,sortable:true,renderer:Zarafa.common.ui.grid.Renderers.datetime.createDelegate(null,[{css:"mail-modified"}],true),tooltip:_("Sort by: Modified")},{header:_("Size"),dataIndex:"message_size",
width:80,hidden:true,renderer:Zarafa.common.ui.grid.Renderers.size,tooltip:_("Sort by: Size")},{header:'<p class="icon_mail_flag">&nbsp;<span class="title">'+_("Flag Status")+"</span></p>",headerCls:"zarafa-icon-column icon",dataIndex:"flag_status",width:24,renderer:Zarafa.common.ui.grid.Renderers.flag,fixed:true,tooltip:_("Sort by: Flag Status"),preventRowSelection:true}]},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.MailGridContextMenu=Ext.extend(Zarafa.core.ui.menu.ConditionalMenu,{context:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model))a.model=Ext.isDefined(a.context)?a.context.getModel():container.getContextByName("mail").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);this.mon(this.model.getStore(),"load",this.onLoad,this)},createContextActionItems:function(){return[{xtype:"zarafa.conditionalitem",text:_("Open"),iconCls:"icon_open",singleSelectOnly:true,handler:this.onContextItemOpen,scope:this},{xtype:"zarafa.conditionalitem",text:_("Download as files"),iconCls:"icon_saveaseml",handler:this.onContextItemEml,scope:this},
{xtype:"zarafa.conditionalitem",text:_("Download as ZIP"),iconCls:"icon_saveemlaszip",hideOnDisabled:false,beforeShow:this.onZipMenuItemBeforeShow,handler:this.onContextItemEmlZip,scope:this},{xtype:"zarafa.conditionalitem",text:_("Copy/Move"),iconCls:"icon_copy",hideOnDisabled:false,handler:this.onCopyMove,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",beforeShow:this.onMenuItemBeforeShow,singleSelectOnly:true,responseMode:Zarafa.mail.data.ActionTypes.REPLY,handler:this.onContextItemResponse,scope:this},{xtype:"zarafa.conditionalitem",text:_("Reply All"),iconCls:"icon_replyAllEmail",singleSelectOnly:true,beforeShow:this.onMenuItemBeforeShow,responseMode:Zarafa.mail.data.ActionTypes.REPLYALL,handler:this.onContextItemResponse,scope:this},{xtype:"zarafa.conditionalitem",text:_("Forward"),iconCls:"icon_forwardEmail",
singleSelectOnly:true,beforeShow:this.onMenuItemBeforeShow,responseMode:Zarafa.mail.data.ActionTypes.FORWARD,handler:this.onContextItemResponse,scope:this},{xtype:"zarafa.conditionalitem",text:_("Forward as Attachment"),iconCls:"icon_embedded_attachment",singleSelectOnly:true,beforeShow:this.onMenuItemBeforeShow,responseMode:Zarafa.mail.data.ActionTypes.FORWARD_ATTACH,handler:this.onContextItemResponse,scope:this},{xtype:"zarafa.conditionalitem",text:_("Edit as New Message"),iconCls:"icon_editAsNewEmail",
singleSelectOnly:true,hidden:true,beforeShow:this.onEditAsNewItemBeforeShow,responseMode:Zarafa.mail.data.ActionTypes.EDIT_AS_NEW,handler:this.onContextItemResponse,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.openCategoriesContent(this.records)},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",beforeShow:this.onMoveToJunkBeforeShow,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",beforeShow:this.onMenuItemBeforeShow,singleSelectOnly:true,handler:this.onContextItemOptions,scope:this}]},onContextItemOpen:function(){Zarafa.mail.Actions.openMailContent(this.records)},
onContextItemEml:function(){Zarafa.common.Actions.openSaveEmlDialog(this.records)},onContextItemEmlZip:function(){Zarafa.common.Actions.openSaveEmlDialog(this.records,true)},onZipMenuItemBeforeShow:function(a,b){var c=container.getServerConfig().getMaxEmlFilesInZIP();if(b.length>c){a.setText(a.text+" ( "+_("max. ")+c+" )");a.disable()}},onContextItemPrint:function(){Zarafa.common.Actions.openPrintDialog(this.records)},onContextItemResponse:function(a){Zarafa.mail.Actions.openCreateMailResponseContent(this.records,
this.model,a.responseMode)},onMenuItemBeforeShow:function(a,b){Ext.each(b,function(c){if(c.isFaultyMessage()){a.setVisible(false);return false}},this)},onEditAsNewItemBeforeShow:function(a,b){this.model&&this.model.getDefaultFolder().getDefaultFolderKey()==="sent"&&a.setVisible(true);return this.onMenuItemBeforeShow(a,b)},onMoveToJunkBeforeShow:function(a){if(this.model){var b=this.model.getDefaultFolder();a.setVisible(!b.isSpecialFolder("junk"))}},onCopyMove:function(){Zarafa.common.Actions.openCopyMoveContent(this.model.getSelectedRecords())},
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;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.openMailOptionsContent(this.records,
{autoSave:true})},onLoad:function(a){var b=[];Ext.each(this.records,function(c){(c=a.getById(c.id))?b.push(c):this.destroy()},this);this.records=b}});Ext.reg("zarafa.mailgridcontextmenu",Zarafa.mail.ui.MailGridContextMenu);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.switchviewcontentcontainer",
ref:"../viewPanel",layout:"card",lazyItems:this.initViews(a.context)}],tbar:{xtype:"zarafa.mailpaneltoolbar",id:"zarafa-main-content-mail-toolbar",defaultTitle:_("Mail"),paging:container.populateInsertionPoint("context.mail.toolbar.paging",this),items:container.populateInsertionPoint("context.mail.toolbar.item",this),context:a.context},listeners:{render:function(b){this.topToolbar=b.getTopToolbar()},scope:this}}},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);return b=b.concat(a)},getGridPanel:function(){return this.mailGrid},initPreviewPanel:function(a){return{xtype:"zarafa.mailpreviewpanel",id:"zarafa-main-content-mail-preview",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,d=this.getEl();switch(b){case Zarafa.mail.data.ViewModes.NO_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.OFF;d.removeClass("zarafa-preview-bottom").removeClass("zarafa-preview-right").addClass("zarafa-preview-off");break;case Zarafa.mail.data.ViewModes.RIGHT_PREVIEW:c=
Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.HORIZONTAL;d.removeClass("zarafa-preview-bottom").removeClass("zarafa-preview-off").addClass("zarafa-preview-right");break;case Zarafa.mail.data.ViewModes.BOTTOM_PREVIEW:c=Zarafa.common.ui.layout.SwitchBorderLayout.Orientation.VERTICAL;d.removeClass("zarafa-preview-off").removeClass("zarafa-preview-right").addClass("zarafa-preview-bottom");break;case Zarafa.mail.data.ViewModes.SEARCH:case Zarafa.mail.data.ViewModes.LIVESCROLL:return}d=this.getLayout();
if(Ext.isFunction(d.setOrientation))d.setOrientation(c);else if(Ext.isString(d))this.layoutConfig=Ext.apply(this.layoutConfig||{},{orientation:c});else this.layout.orientation=c}});Ext.reg("zarafa.mailpanel",Zarafa.mail.ui.MailPanel);Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailPanelToolbar=Ext.extend(Zarafa.common.ui.ContextMainPanelToolbar,{pageInfoText:_("Loaded {0} of {1}"),constructor:function(a){a=a||{};a.paging=a.paging||[];a.paging.push({xtype:"tbtext",ref:"loadedMailInfo",cls:"zarafa-loaded-mail-info"});Zarafa.mail.ui.MailPanelToolbar.superclass.constructor.call(this,a)},onResize:function(a){Zarafa.mail.ui.MailPanelToolbar.superclass.onResize.apply(this,arguments);Ext.isDefined(a)&&this.resizeSearchField()},initComponent:function(){Zarafa.mail.ui.MailPanelToolbar.superclass.initComponent.call(this);
if(container.getSettingsModel().get("zarafa/v1/contexts/mail/enable_live_scroll")){this.pagesToolbar.setVisible(false);this.model&&this.mon(this.model.getStore(),"load",this.onLoad,this)}else{this.pagesToolbar.setVisible(true);this.pagesToolbar.inputItem.setWidth(30);this.pagesToolbar.next.setIconClass("x-tbar-page-next btn-width");this.pagesToolbar.next.addClass("btn-margin-right");this.pagesToolbar.prev.setIconClass("x-tbar-page-prev btn-width");this.pagesToolbar.prev.addClass("btn-margin-right");
this.pagesToolbar.first.setIconClass("x-tbar-page-first btn-width");this.pagesToolbar.first.addClass("btn-margin-right");this.pagesToolbar.last.setIconClass("x-tbar-page-last btn-width");this.pagesToolbar.last.addClass("btn-margin-right");this.loadedMailInfo.setVisible(false)}},onAfterLayout:Ext.emptyFn,onLoad:function(a){var b=a.getTotalCount();a=a.getRange().length;this.loadedMailInfo.setText(String.format(this.pageInfoText,a,b));this.resizeSearchField()},resizeSearchField:function(){var a=this.el.getStyleSize().width,
b=0,c=0,d=0;if(this.loadedMailInfo.isVisible())b=this.loadedMailInfo.getWidth();else if(this.pagesToolbar.isVisible())b=this.pagesToolbar.getWidth();else if(this.loadedMailInfo.xtbHidden){b=this.loadedMailInfo.xtbWidth;if(a>this.searchTextfield.getWidth()+b){this.layout.unhideItem(this.loadedMailInfo);this.doLayout()}}else if(this.pagesToolbar.xtbHidden){b=this.pagesToolbar.xtbWidth;if(a>this.searchTextfield.getWidth()+b){this.layout.unhideItem(this.pagesToolbar);this.doLayout()}}if(this.copyButton.xtbHidden){c=
this.copyButton.xtbWidth;if(a>this.searchTextfield.getWidth()+b+c){this.layout.unhideItem(this.copyButton);this.doLayout()}}else c=this.copyButton.getWidth();if(this.deleteButton.xtbHidden){d=this.deleteButton.xtbWidth;if(a>this.searchTextfield.getWidth()+b+c+d){this.layout.unhideItem(this.deleteButton);this.doLayout()}}else d=this.deleteButton.getWidth();this.searchTextfield.setWidth(a-b-c-d-0)}});Ext.reg("zarafa.mailpaneltoolbar",Zarafa.mail.ui.MailPanelToolbar);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",recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{enableOpenLoadTask:true,autoOpenLoadTaskDefer:250}),width:600,height:400,tbar:{items:[this.createReplyButton(),this.createReplyAllButton(),this.createForwardButton(),
this.createEditAsNewButton()]}});Zarafa.mail.ui.MailPreviewPanel.superclass.constructor.call(this,a)},update:function(a){Zarafa.mail.ui.MailPreviewPanel.superclass.update.apply(this,arguments);if(a){var b=a.isFaultyMessage(),c=this.getTopToolbar();c.replyBtn.setVisible(!b);c.replyAllBtn.setVisible(!b);c.forwardBtn.setVisible(!b);var d=this.model.getDefaultFolder();c.editAsNewBtn.setVisible(d.getDefaultFolderKey()==="sent"&&!b)}},createReplyButton:function(){return{xtype:"button",tooltip:_("Reply")+
" (Ctrl + R)",overflowText:_("Reply"),iconCls:"icon_replyEmail",ref:"replyBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLY,handler:this.onResponse,scope:this}},createReplyAllButton:function(){return{xtype:"button",tooltip:_("Reply All")+" (Ctrl + Alt + R)",overflowText:_("Reply All"),iconCls:"icon_replyAllEmail",ref:"replyAllBtn",responseMode:Zarafa.mail.data.ActionTypes.REPLYALL,handler:this.onResponse,scope:this}},createForwardButton:function(){return{xtype:"button",tooltip:_("Forward")+" (Ctrl + F)",
overflowText:_("Forward"),iconCls:"icon_forwardEmail",ref:"forwardBtn",responseMode:Zarafa.mail.data.ActionTypes.FORWARD,handler:this.onResponse,scope:this}},createEditAsNewButton:function(){return{xtype:"button",tooltip:_("Edit as New Message")+" (Ctrl + E)",overflowText:_("Edit as New Message"),iconCls:"icon_editAsNewEmail",ref:"editAsNewBtn",responseMode:Zarafa.mail.data.ActionTypes.EDIT_AS_NEW,handler:this.onResponse,scope:this}},onResponse:function(a){Zarafa.mail.Actions.openCreateMailResponseContent(this.record,
this.model,a.responseMode)}});Ext.reg("zarafa.mailpreviewpanel",Zarafa.mail.ui.MailPreviewPanel);Ext.namespace("Zarafa.note.attachitem");
Zarafa.note.attachitem.AttachNoteColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.getColumns(),defaults:{sortable:true}});Zarafa.note.attachitem.AttachNoteColumnModel.superclass.constructor.call(this,a)},getColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",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"),tooltip:_("Sort by: Subject"),renderer:Zarafa.common.ui.grid.Renderers.subject}]}});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},{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.openNoteContent(this.records)},onContextItemEmail:function(){Zarafa.note.Actions.openNoteEmailContent(this.records)},onContextItemCategories:function(){Zarafa.common.Actions.openCategoriesContent(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.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}});Zarafa.note.ui.NoteGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",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:"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:Zarafa.common.ui.grid.Renderers.colorTextValue,hidden:true}]}});
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">','<div class="zarafa-note-iconview-icon {icon_index:this.getTheme}"></div>','<div class="zarafa-note-iconview-subject">{subject:this.encodeSubject}</div>',"</div>","</tpl>","</div>",{getTheme:function(a){switch(a){case 768:return"icon_note_blue_large";case 769:return"icon_note_green_large";case 770:return"icon_note_pink_large";case 771:return"icon_note_yellow_large";case 772:return"icon_note_white_large";default:return"icon_note_yellow_large"}},
encodeSubject:function(a){return Ext.util.Format.ellipsis(Ext.util.Format.htmlEncode(a),20)}})},getMainPanel:function(){return this.ownerCt},initEvents:function(){this.on({contextmenu:this.onNoteIconContextMenu,dblclick:this.onIconDblClick,selectionchange:this.onSelectionChange,scope:this})},onNoteIconContextMenu:function(a,b,c,d){a.isSelected(c)||a.select(c);Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelectedRecords(),{position:d.getXY()})},onIconDblClick:function(a,b){Zarafa.note.Actions.openNoteContent(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.NoteMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{viewPanel:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.notemainpanel",layout:"fit",items:[{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.notegrid",id:"note-gridview",context:a}];a=container.populateInsertionPoint("context.note.views",this,a);return b=b.concat(a)},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.settings.ui");
Zarafa.settings.ui.SettingsAccountWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{origLanguage:"",defaultThemeName:_("Basic"),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");var e={xtype:"jsonstore",autoDestroy:true,fields:["context","text"],data:d};d=[[0,this.defaultThemeName,
"basic"]];for(var f=container.getPlugins(),g=0;g<f.length;g++){var i=f[g];i instanceof Zarafa.core.ThemePlugin&&d.push([d.length,i.getDisplayName(),i.getName()])}d=new Ext.data.ArrayStore({fields:["id","displayName","name"],idIndex:0,data:d,sortInfo:{field:"displayName",direction:"ASC"}});Ext.applyIf(a,{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",cls:"zarafa-settings-reload-warning",ref:"../languageWarning"}]},{xtype:"combo",
fieldLabel:_("Startup folder"),name:"zarafa/v1/main/default_context",ref:"startupCombo",width:200,store:e,mode:"local",triggerAction:"all",displayField:"text",valueField:"context",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onStartupSelect,scope:this}}]});d.data.length>1&&a.items.push({xtype:"combo",width:200,editable:false,forceSelection:true,triggerAction:"all",store:d,fieldLabel:_("Theme"),mode:"local",valueField:"name",displayField:"displayName",ref:"themeCombo",
name:"zarafa/v1/main/active_theme",listeners:{select:this.onThemeSelect,scope:this}});Zarafa.settings.ui.SettingsAccountWidget.superclass.constructor.call(this,a)},onLanguageSelect:function(a,b){var c=b.get(a.valueField);if(this.origLanguage!==c){this.model.requiresReload=true;this.languageWarning.setValue(_("This change requires a reload of the WebApp"))}else 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)},onThemeSelect:function(a,b){var c=b.get(a.valueField);if(this.activeTheme!==c)this.model.requiresReload=true;this.model&&this.model.set(a.name,c)},update:function(a){Zarafa.settings.ui.SettingsAccountWidget.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));if(Ext.isDefined(this.themeCombo)){this.activeTheme=a.get(this.themeCombo.name);
if(!this.activeTheme||this.themeCombo.store.find("name",this.activeTheme)===-1)this.activeTheme=container.getServerConfig().getActiveTheme()||this.defaultThemeName;this.themeCombo.setValue(this.activeTheme)}},updateSettings:function(a){Zarafa.settings.ui.SettingsAccountWidget.superclass.updateSettings.apply(this,arguments);a.beginEdit();a.set(this.languageCombo.name,this.languageCombo.getValue());a.set(this.startupCombo.name,this.startupCombo.getValue());Ext.isDefined(this.themeCombo)&&a.set(this.themeCombo.name,
this.themeCombo.getValue());a.endEdit()}});Ext.reg("zarafa.settingsaccountwidget",Zarafa.settings.ui.SettingsAccountWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsAddressBookWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{store:undefined,constructor:function(a){a=a||{};var b=new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">',"{depth:indent}{display_name:htmlEncode}","</div>","</tpl>",{compiled:true});if(Ext.isEmpty(a.store))a.store=new Zarafa.addressbook.AddressBookHierarchyStore;Ext.applyIf(a,{xtype:"zarafa.settingsaddressbookwidget",title:_("Address Book"),layout:"form",items:[{xtype:"combo",fieldLabel:_("Select Default Folder"),
name:"zarafa/v1/main/default_addressbook",ref:"defaultABCombo",width:200,store:a.store,mode:"local",triggerAction:"all",displayField:"display_name",valueField:"entryid",tpl:b,lazyInit:false,forceSelection:true,editable:false,listeners:{select:this.onDefaultABSelect,render:this.onABComboRender,scope:this}}]});Zarafa.settings.ui.SettingsAddressBookWidget.superclass.constructor.call(this,a)},onHierarchyStoreLoad:function(a){if(a.getCount()!==0){var b=this.defaultABCombo,c=this.model.get(b.name),d;Ext.isEmpty(c)||
(d=a.getById(c));if(Ext.isEmpty(d))d=a.getAt(0);b.setValue(d.get(b.valueField))}},onABComboRender:function(a){new Zarafa.common.ui.LoadMask(a.wrap,{store:this.store,msgCls:"x-mask-loading x-mask-loading-combo",removeMask:true});this.store.load({actionType:Zarafa.core.Actions.list,params:{subActionType:Zarafa.core.Actions.hierarchy}})},onDefaultABSelect:function(a,b){var c=b.get(a.valueField);this.model&&this.model.set(a.name,c)},update:function(a){Zarafa.settings.ui.SettingsAddressBookWidget.superclass.update.apply(this,
arguments);this.model=a;var b=this.store;b.getCount()===0?this.mon(b,"load",this.onHierarchyStoreLoad,this,{single:true}):this.onHierarchyStoreLoad(b)},updateSettings:function(a){Zarafa.settings.ui.SettingsAddressBookWidget.superclass.updateSettings.apply(this,arguments);a.set(this.defaultABCombo.name,this.defaultABCombo.getValue())}});Ext.reg("zarafa.settingsaddressbookwidget",Zarafa.settings.ui.SettingsAddressBookWidget);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.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.SettingsCopyrightCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("About"),categoryIndex:1E4,iconCls:"zarafa-settings-category-copyright",items:[{xtype:"zarafa.settingscopyrightwidget",about:Zarafa.ABOUT},container.populateInsertionPoint("context.settings.category.copyright",this)]});Zarafa.settings.ui.SettingsCopyrightCategory.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingscopyrightcategory",Zarafa.settings.ui.SettingsCopyrightCategory);
Ext.namespace("Zarafa.settings.ui");Zarafa.settings.ui.SettingsCopyrightWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{about:Zarafa.ABOUT,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Zarafa WebApp"),layout:"form",items:[{xtype:"displayfield",cls:"zarafa-settings-about-text",value:a.about||this.about,hideLabel:true,htmlEncode:false}]});Zarafa.settings.ui.SettingsCopyrightWidget.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingscopyrightwidget",Zarafa.settings.ui.SettingsCopyrightWidget);
Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsGeneralCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("General"),categoryIndex:0,iconCls:"zarafa-settings-category-general",items:[{xtype:"zarafa.settingsaccountwidget"},{xtype:"zarafa.settingsinboxnavigationwidget"},{xtype:"zarafa.settingsaddressbookwidget"},{xtype:"zarafa.settingsquotainfowidget"},{xtype:"zarafa.settingsresetsettingswidget",settingsContext:a.settingsContext},{xtype:"zarafa.settingsversionwidget"},
container.populateInsertionPoint("context.settings.category.general",this)]});Zarafa.settings.ui.SettingsGeneralCategory.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingsgeneralcategory",Zarafa.settings.ui.SettingsGeneralCategory);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsInboxNavigationWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.settingsinboxnavigationwidget",title:_("Inbox navigation"),layout:"form",items:[{xtype:"displayfield",hideLabel:true,value:_("I want to navigate through my items by using.")},{xtype:"radiogroup",name:"zarafa/v1/contexts/mail/enable_live_scroll",ref:"liveScroll",hideLabel:true,columns:1,style:{marginBottom:"10px"},items:[{xtype:"radio",name:"enablescroll",
inputValue:"true",boxLabel:_("Infinite Scroll")+'<span class="zarafa-settings-category-general-liveScroll">('+_("WebApp automatically loads additional items when you scroll down")+")</span>"},{xtype:"radio",name:"enablescroll",inputValue:"false",boxLabel:_("Pagination")+'<span class="zarafa-settings-category-general-liveScroll">('+_("WebApp displays items on pages and you can use navigation controls to navigate")+")</span>"}],listeners:{change:this.onRadioChange,scope:this}},{xtype:"zarafa.compositefield",
plugins:["zarafa.splitfieldlabeler"],fieldLabel:_("Load {A} items per page."),items:[{labelSplitter:"{A}",xtype:"combo",name:"zarafa/v1/main/page_size",ref:"../pageSize",width:55,hideLabel:true,store:{xtype:"jsonstore",autoDestroy:true,fields:["size"],data:[{size:50},{size:100},{size:150},{size:200}]},mode:"local",triggerAction:"all",displayField:"size",valueField:"size",lazyInit:false,forceSelection:true,editable:false,autoSelect:true,listeners:{select:this.onPageSizeSelect,scope:this}}]}]});Zarafa.settings.ui.SettingsInboxNavigationWidget.superclass.constructor.call(this,
a)},update:function(a){this.model=a;this.liveScroll.setValue(a.get(this.liveScroll.name));this.pageSize.setValue(a.get(this.pageSize.name))},updateSettings:function(a){var b=this.liveScroll.getValue().inputValue==="true";a.beginEdit();a.set(this.liveScroll.name,b);a.set(this.pageSize.name,this.pageSize.getValue());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)},onPageSizeSelect:function(a){this.model&&this.model.get(a.name)!==
a.getValue()&&this.model.set(a.name,a.getValue())}});Ext.reg("zarafa.settingsinboxnavigationwidget",Zarafa.settings.ui.SettingsInboxNavigationWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsKeyShortcutCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Keyboard Shortcuts"),categoryIndex:9998,iconCls:"zarafa-settings-category-keyshortcut",items:this.generateWidgets(a)});Zarafa.settings.ui.SettingsKeyShortcutCategory.superclass.constructor.call(this,a)},getShortcutDescription:function(){var a={};Ext.iterate(Zarafa.core.KeyMapMgr.keys,function(b,c){for(var d=0,e=c.length;d<e;d++){var f=this.getKeyCombination(c[d]),
g=c[d].settingsCfg;if(!(Ext.isEmpty(f)||!Ext.isDefined(g))){var i=g.category;Ext.isObject(a[i])||(a[i]={});a[i][f]={shortcutDesc:g.description,fieldLabel:f,basicShortcut:Ext.isDefined(c[d].basic)}}}},this);return a},generateWidgets:function(a){var b=this.getShortcutDescription(),c=[{xtype:"zarafa.settingskeyshortcutwidget",settingsContext:a.settingsContext}];Ext.iterate(b,function(d){c.push({xtype:"zarafa.settingswidget",title:d,layout:"form",itemCls:"zarafa-settings-keyboard-shortcut-row",items:this.generateRows(b[d]),
labelSeparator:""})},this);return c},generateRows:function(a){var b=[];Ext.iterate(a,function(c,d){b.push({xtype:"displayfield",fieldLabel:d.fieldLabel,html:this.generateDisplayValue(d)})},this);return b},generateDisplayValue:function(a){if(a.basicShortcut){a='<span class="keyboard-desc" style="width: 300px"> '+a.shortcutDesc+"</span>";a+='<span class="keyboard-type" title="'+_("Part of basic keyboard shortcuts")+'">'+_("Basic")+"</span>"}else a='<span class="keyboard-desc"> '+a.shortcutDesc+"</span>";
return a},getKeyCombination:function(a){var b=[];if(a.ctrl)b.push(Ext.isMac?"CMD":"CTRL");a.alt&&b.push("ALT");a.shift&&b.push("SHIFT");var c=a.key;if(!Ext.isEmpty(c)){if(Ext.isArray(c))c[0]===Ext.EventObject.LEFT&&c[1]===Ext.EventObject.RIGHT?b.push("ARROW KEYS"):b.push(a.ctrl&&a.alt?"1...9":"0...9");else if(c===Ext.EventObject.F5)b.push("F5");else if(c===Ext.EventObject.ENTER)b.push("ENTER");else if(c===Ext.EventObject.HOME)b.push("HOME");else if(c===Ext.EventObject.END)b.push("END");else if(c===
Ext.EventObject.DELETE){Ext.isMac&&b.push("FN");b.push("DELETE")}else Ext.isNumber(c)?b.push(String.fromCharCode(c)):b.push(c);return b.join(" + ")}return""}});Ext.reg("zarafa.settingskeyshortcutcategory",Zarafa.settings.ui.SettingsKeyShortcutCategory);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsKeyShortcutWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Keyboard Shortcuts"),layout:"form",items:[{xtype:"zarafa.compositefield",hideLabel:true,height:60,items:[{xtype:"radiogroup",ref:"../keyShortcutGroup",columns:1,hideLabel:true,name:"zarafa/v1/main/keycontrols",items:[{xtype:"radio",boxLabel:_("Keyboard shortcuts off"),name:"keyboardshortcut",inputValue:Zarafa.settings.data.KeyboardSettings.NO_KEYBOARD_SHORTCUTS},
{xtype:"radio",boxLabel:_("Basic keyboard shortcuts on"),name:"keyboardshortcut",inputValue:Zarafa.settings.data.KeyboardSettings.BASIC_KEYBOARD_SHORTCUTS},{xtype:"radio",boxLabel:_("All keyboard shortcuts on"),name:"keyboardshortcut",inputValue:Zarafa.settings.data.KeyboardSettings.ALL_KEYBOARD_SHORTCUTS}],listeners:{change:this.enableKeyboardShortcuts,scope:this},flex:1},{xtype:"displayfield",hideLabel:true,height:20,ref:"../keyShortcutWarning",flex:2}]}]});Zarafa.settings.ui.SettingsKeyShortcutWidget.superclass.constructor.call(this,
a)},initEvents:function(){Zarafa.settings.ui.SettingsKeyShortcutWidget.superclass.initEvents.call(this);this.mon(this.settingsContext.getModel(),"savesettings",this.onSaveSettings,this)},onSaveSettings:function(a,b){var c=false,d=b.modified;if(!Ext.isEmpty(d))for(var e=0;e<d.length;e++)if(d[e].path===this.keyShortcutGroup.name){c=true;break}if(c===true)b.get(this.keyShortcutGroup.name)!==Zarafa.settings.data.KeyboardSettings.NO_KEYBOARD_SHORTCUTS?Zarafa.core.KeyMapMgr.enableAllKeymaps():Zarafa.core.KeyMapMgr.disableAllKeymaps()},
update:function(a){this.model=a;this.keyShortcutGroup.setValue(a.get(this.keyShortcutGroup.name));this.keyShortcutWarning.reset()},updateSettings:function(a){a.set(this.keyShortcutGroup.name,this.keyShortcutGroup.getValue().inputValue)},enableKeyboardShortcuts:function(a,b){this.model.get(a.name)!==b.inputValue&&this.model.set(a.name,b.inputValue);if(Ext.isEmpty(this.model.modified))this.keyShortcutWarning.reset();else{this.keyShortcutWarning.setValue(_("This change requires a reload of the WebApp"));
this.model.requiresReload=true}}});Ext.reg("zarafa.settingskeyshortcutwidget",Zarafa.settings.ui.SettingsKeyShortcutWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsMainPanel=Ext.extend(Zarafa.common.ui.ContextMainPanel,{constructor:function(a){a=a||{};Ext.apply(a,{iconCls:"zarafa-settings-category-general"});for(var b=container.populateInsertionPoint("context.settings.categories",this,a.context),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 i=0,
h=g.items.length;i<h;i++){var k=g.items.get(i);k.favorite===true&&d.push({xtype:"zarafa.settingsfavoritetab",title:k.title,favoriteIndex:g.categoryIndex*(i+1),iconCls:k.iconCls,context:a.context,category:g,widget:k})}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,{cls:"zarafa-setting-mainpanel",header:false,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,hidden:true,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",
enableOverflow:false,toolbarCls:"x-panel-footer",cls:"x-panel-fbar",flex:0.8,buttonAlign:"right",defaults:{minWidth:Ext.Panel.prototype.minButtonWidth},items:[{xtype:"button",cls:"zarafa-action",text:_("Apply"),handler:this.onApply,scope:this},{xtype:"button",text:_("Discard"),handler:this.onDiscard,scope:this}]}]},{xtype:"container",hidden:true,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.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:[{xtype:"zarafa.settingspluginswidget",settingsContext:a.settingsContext},container.populateInsertionPoint("context.settings.category.plugins",this)]});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.SettingsPluginsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};for(var b=new Ext.data.ArrayStore({fields:[{name:"name"},{name:"display_name"},{name:"version"},{name:"enabled",type:"boolean"},{name:"allow_disable",type:"boolean"},{name:"settings_base"}]}),c=container.getPluginsMetaData(),d=container.getServerConfig().getPluginsVersion(),e,f=0,g=c.length;f<g;f++){var i=c[f];if(!i.isPrivate()){e=Ext.isEmpty(d[i.getName()])?_("Unknown"):d[i.getName()];
b.add(new Ext.data.Record({name:i.getName(),display_name:i.getDisplayName(),version:e,enabled:i.isEnabled(),allow_disable:i.allowUserDisable,settings_base:i.getSettingsBase()}))}}b.sort("display_name","ASC");c=new Ext.grid.CheckboxSelectionModel({checkOnly:true,header:"&#160;",renderer:this.onEnabledRenderer,onKeyPress:Ext.emptyFn,listeners:{rowselect:this.onRowSelect,rowdeselect:this.onRowDeselect,scope:this}});Ext.applyIf(a,{title:_("Available plugins"),layout:"fit",height:510,items:[{xtype:"panel",
border:false,cls:"zarafa-settings-pluginavailable",layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"displayfield",value:_("The following plugins are available in the WebApp. It is possible to select and/or deselect different plugins to indicate which plugins should be enabled. When any plugin is enabled or disabled, the WebApp must be reloaded in order for the changes to take effect."),fieldClass:"x-form-display-field zarafa-settings-widget-extrainfo"},{xtype:"grid",border:true,flex:1,
enableHdMenu:false,deferRowRender:false,autoExpandColumn:"display_name",ref:"../pluginsGrid",viewConfig:{forceFit:true,emptyText:"<div class='emptytext'>"+_("No plugins available")+"</div>"},store:b,columns:[c,{id:"display_name",header:_("Display Name"),dataIndex:"display_name",sortable:false,renderer:this.onDisplayNameRenderer},{id:"display_name",header:_("Version"),dataIndex:"version",sortable:false}],selModel:c}]}]});Zarafa.settings.ui.SettingsCopyrightWidget.superclass.constructor.call(this,a);
this.pluginsGrid.on("rowclick",this.onRowClick,this)},onRowClick:function(a,b){a.getView().focusRow(b);var c=a.getSelectionModel(),d=a.getStore().getAt(b);if(d.get("allow_disable"))d.get("enabled")?c.deselectRow(b):c.selectRow(b,true)},update:function(a){this.model=a;var b=this.pluginsGrid.getSelectionModel(),c=[];this.pluginsGrid.getStore().each(function(d){d.get("allow_disable")&&d.set("enabled",a.get(d.get("settings_base")+"/enable"));d.get("enabled")&&c.push(d)});b.suspendEvents(false);b.selectRecords(c);
b.resumeEvents()},updateSettings:function(a){var b=this.pluginsGrid.getStore();a.beginEdit();b.each(function(c){c.get("allow_disable")&&a.set(c.get("settings_base")+"/enable",c.get("enabled"))});a.endEdit()},onDisplayNameRenderer:function(a,b,c){a=Ext.util.Format.htmlEncode(a);if(!c.get("allow_disable")){b.css+=" zarafa-settings-pluginavailable-fixed";a+=" <span>"+_("This plugin cannot be disabled")+"</span>"}return a},onEnabledRenderer:function(a,b,c){if(c.get("allow_disable"))return Ext.grid.CheckboxSelectionModel.prototype.renderer.apply(this,
arguments);else{b.css+=" zarafa-settings-pluginavailable-fixed";return""}},onRowSelect:function(a,b,c){c.set("enabled",true);this.model.set(c.get("settings_base")+"/enable",true);this.model.requiresReload=true},onRowDeselect:function(a,b,c){c.set("enabled",false);this.model.set(c.get("settings_base")+"/enable",false);this.model.requiresReload=true}});Ext.reg("zarafa.settingspluginswidget",Zarafa.settings.ui.SettingsPluginsWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsQuotaInfoWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.settingswidget",title:_("Mailbox Usage"),layout:"form",items:[{xtype:"zarafa.quotabar",width:400,hidden:true,ref:"quotaBar",userStore:container.getHierarchyStore().getDefaultStore()},{xtype:"displayfield",width:400,hideLabel:true,ref:"unavailableQuotaInfo",hidden:true,value:_("Quota information is not set on the user's store.")},{xtype:"displayfield",
hideLabel:true,width:400,ref:"quotaInfo"}]});Zarafa.settings.ui.SettingsQuotaInfoWidget.superclass.constructor.call(this,a);this.on("afterrender",this.updateQuotaInfo,this);this.mon(container.getHierarchyStore(),"update",this.onUpdateHierarchyStore,this)},updateQuotaInfo:function(){var a=container.getHierarchyStore().getDefaultStore(),b=a.get("store_size"),c=a.get("quota_soft"),d=a.get("quota_hard");a=a.get("quota_warning");var e=String.format(_("{0} of mailbox space is used."),Ext.util.Format.fileSize(b*
1024)),f='<span class="zarafa-quota-string">'+e+"</span>";if(c||d||a){this.quotaBar.setVisible(true);this.unavailableQuotaInfo.setVisible(false);e=this.getQuotaSuggestionString(c,d,b);Ext.isEmpty(e)||(f+=" "+e)}else{this.quotaBar.setVisible(false);this.unavailableQuotaInfo.setVisible(true)}this.quotaInfo.setValue(f)},getQuotaSuggestionString:function(a,b,c){if(Ext.isDefined(c)){if(b&&a>=b)a=null;if(b&&c>b)return _("You have exceeded hard quota, you can not send or recieve mails.");else if(a&&c<a)return String.format(_("At {0} you won't be able to send mails."),
Ext.util.Format.fileSize(a*1024));else if(a&&b&&a<c&&c<b)return String.format(_("You can not send mails as you have exceeded soft quota, at {0} you won't be able to recieve mails."),Ext.util.Format.fileSize(b*1024));else if(!a&&b&&c<b)return String.format(_("At {0} you won't be able to send or recieve mails."),Ext.util.Format.fileSize(b*1024));else if(a&&!b&&a<c)return _("You can not send mails as you have exceeded soft quota.")}},onUpdateHierarchyStore:function(a,b){b.isDefaultStore()&&this.updateQuotaInfo()}});
Ext.reg("zarafa.settingsquotainfowidget",Zarafa.settings.ui.SettingsQuotaInfoWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsResetSettingsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{loadMask:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Reset WebApp settings"),layout:"column",items:[{xtype:"displayfield",columnWidth:1,hideLabel:true,value:_("Resets WebApp's settings to their original defaults")},{xtype:"button",text:_("Reset WebApp settings"),columnWidth:1,autoWidth:true,handler:this.onResetSettings,scope:this}]});Zarafa.settings.ui.SettingsResetSettingsWidget.superclass.constructor.call(this,
a)},onResetSettings:function(){var a=_("Your WebApp settings will be restored to their default condition. Are you sure you want to reset all WebApp settings?");a+="<br/><br/>";a+=_("WebApp will automatically restart in order for these changes to take effect");a+="<br/>";Zarafa.common.dialogs.MessageBox.addCustomButtons({title:_("Reset WebApp settings"),msg:a,icon:Ext.MessageBox.QUESTION,fn:this.resetDefaultSettings,customButton:[{text:_("Reset"),name:"reset"},{text:_("Cancel"),name:"cancel"}],scope:this})},
resetDefaultSettings:function(a){if(a==="reset"){a=this.settingsContext.getModel().getRealSettingsModel();a.reset("zarafa/v1");a.save();this.loadMask=new Zarafa.common.ui.LoadMask(Ext.getBody(),{msg:"<b>"+_("Webapp is reloading, Please wait.")+"</b>"});this.loadMask.show();this.mon(a,"save",this.onSettingsSave,this);this.mon(a,"exception",this.onSettingsException,this)}},onSettingsSave:function(a,b){if(b.action===Zarafa.core.Actions.reset){this.mun(a,"save",this.onSettingsSave,this);this.mun(a,"exception",
this.onSettingsException,this);Zarafa.core.Util.reloadWebapp()}},onSettingsException:function(a,b,c,d){if(d.action===Zarafa.core.Actions.reset){this.loadMask.hide();this.mun(a,"save",this.onSettingsSave,this);this.mun(a,"exception",this.onSettingsException,this)}}});Ext.reg("zarafa.settingsresetsettingswidget",Zarafa.settings.ui.SettingsResetSettingsWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsVersionWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b=container.getVersion();Ext.applyIf(a,{title:_("Version information"),layout:"form",items:[{xtype:"displayfield",fieldLabel:_("WebApp"),value:b.getWebApp()+(!Ext.isEmpty(b.getGit())?"-"+b.getGit():""),htmlEncode:true},{xtype:"displayfield",fieldLabel:_("ZCP"),value:b.getZCP(),htmlEncode:true},{xtype:"displayfield",fieldLabel:_("Server"),value:b.getServer(),hidden:Ext.isEmpty(b.getServer()),
htmlEncode:true}]});Zarafa.settings.ui.SettingsVersionWidget.superclass.constructor.call(this,a)}});Ext.reg("zarafa.settingsversionwidget",Zarafa.settings.ui.SettingsVersionWidget);Ext.namespace("Zarafa.settings.ui");
Zarafa.settings.ui.SettingsWelcomeCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{categoryIndex:0,iconCls:"zarafa-settings-category-welcome",defaults:{cls:"zarafa-settings-widget-welcome"},items:[{xtype:"zarafa.settingsaccountwidget"},{xtype:"zarafa.settingscalendarwidget"},container.populateInsertionPoint("context.settings.category.welcome",this)]});Zarafa.settings.ui.SettingsWelcomeCategory.superclass.constructor.call(this,a)},onRender:function(){Zarafa.settings.ui.SettingsWelcomeCategory.superclass.onRender.apply(this,
arguments);var a=this.find("name","zarafa/v1/contexts/calendar/datepicker_show_busy");Ext.isEmpty(a)||a[0].hide()}});Ext.reg("zarafa.settingswelcomecategory",Zarafa.settings.ui.SettingsWelcomeCategory);Ext.namespace("Zarafa.task.attachitem");
Zarafa.task.attachitem.AttachTaskColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.getColumns(),defaults:{sortable:true}});Zarafa.task.attachitem.AttachTaskColumnModel.superclass.constructor.call(this,a)},getColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column",header:"<p class='icon_index'>&nbsp;</p>",width:24,fixed:true,tooltip:_("Sort by: Icon"),renderer:Zarafa.common.ui.grid.Renderers.icon},{dataIndex:"importance",
headerCls:"zarafa-icon-column",header:"<p class='icon_importance'>&nbsp;</p>",width:24,fixed:true,tooltip:_("Sort by: Priority"),renderer:Zarafa.common.ui.grid.Renderers.importance},{header:"<p class='icon_attachment'>&nbsp;</p>",headerCls:"zarafa-icon-column",dataIndex:"hasattach",width:24,fixed:true,renderer:Zarafa.common.ui.grid.Renderers.attachment,tooltip:_("Sort by: Attachment")},{dataIndex:"subject",header:_("Subject"),tooltip:_("Sort by: Subject"),renderer:Zarafa.common.ui.grid.Renderers.subject},
{header:_("Status"),dataIndex:"status",width:160,renderer:Zarafa.common.ui.grid.Renderers.taskstatus,tooltip:_("Sort by: Status")},{dataIndex:"duedate",header:_("Due Date"),tooltip:_("Sort by: Due Date"),renderer:Zarafa.common.ui.grid.Renderers.utcdate},{dataIndex:"percent_complete",header:_("% Completed"),width:75,tooltip:_("Sort by: Percent Completed"),renderer:Zarafa.common.ui.grid.Renderers.percentage},{dataIndex:"categories",header:_("Categories"),tooltip:_("Sort by: Categories"),renderer:Zarafa.common.ui.grid.Renderers.text}]}});
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.openTaskContent(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:_("Categories"),iconCls:"icon_categories",handler:function(){Zarafa.common.Actions.openCategoriesContent(this.records)},
scope:this},{xtype:"zarafa.conditionalitem",text:_("Delete"),iconCls:"icon_delete",nonEmptySelectOnly:true,handler:this.onContextItemDelete,scope:this}]},onContextItemDelete:function(){var a;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)}});Ext.reg("zarafa.taskcontextmenu",Zarafa.task.ui.TaskContextMenu);Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{columns:this.createColumns(),defaults:{sortable:true}});Zarafa.task.ui.TaskGridColumnModel.superclass.constructor.call(this,a)},createColumns:function(){return[{dataIndex:"icon_index",headerCls:"zarafa-icon-column icon",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(a){this.addClass(Zarafa.core.mapi.IconIndex.getClassName(a))}}},{dataIndex:"importance",headerCls:"zarafa-icon-column importance",header:'<p class="icon_importance">&nbsp;</p>',width:24,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"}},{headerCls:"zarafa-icon-column",header:'<p class="icon_attachment">&nbsp;</p>',dataIndex:"hasattach",width:24,renderer:Zarafa.common.ui.grid.Renderers.attachment,fixed:true,tooltip:_("Sort by: Attachment")},{headerCls:"zarafa-icon-column",header:'<p class="icon_recurring">&nbsp;</p>',dataIndex:"recurring",width:24,renderer:Zarafa.common.ui.grid.Renderers.recurrence,fixed:true},{headerCls:"zarafa-icon-column",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},{xtype:"checkcolumn",dataIndex:"complete",headerCls:"zarafa-icon-column",header:'<p class="icon_complete">&nbsp;</p>',width:25,fixed:true,renderer:this.completeColumnRenderer.createDelegate(this),tooltip:_("Sort by: Complete"),editor:{xtype:"checkbox",
style:"margin-left: 10px;"},processEvent:Ext.ux.grid.CheckColumn.prototype.processEvent.createSequence(this.onCompleteColumnProcessEvent)},{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.utcdate,editor:{xtype:"datefield",emptyText:_("None")}},{dataIndex:"duedate",header:_("Due Date"),
tooltip:_("Sort by: Due Date"),renderer:Zarafa.common.ui.grid.Renderers.utcdate,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:_("Modified"),dataIndex:"last_modification_time",width:160,renderer:Zarafa.common.ui.grid.Renderers.datetime,hidden:true,tooltip:_("Sort by: Modified")},{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")}]},completeColumnRenderer:function(a,b){b.css+=" zarafa-grid-empty-cell";return Ext.ux.grid.CheckColumn.prototype.renderer.apply(this,arguments)},onCompleteColumnProcessEvent:function(a,b,c,d){if(a==="mousedown"){a=c.store.getAt(d);a.beginEdit();if(a.get("complete")){a.set("percent_complete",1);a.set("status",Zarafa.core.mapi.TaskStatus.COMPLETE);a.set("date_completed",new Date)}else{a.set("status",Zarafa.core.mapi.TaskStatus.NOT_STARTED);
a.set("percent_complete",0);a.set("date_completed",null)}a.endEdit();a.save()}}});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:"fit",items:[{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);return b=b.concat(a)},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.core");
Zarafa.core.Context=Ext.extend(Zarafa.core.Plugin,{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,b){this.stateful&&this.initState();var c=this.getModel();c&&c.enable(a,b);this.switchView(this.getCurrentView(),this.getCurrentViewMode(),true)},disable:function(){var a=this.getModel();a&&a.disable()},bid:function(){return-1},getStateName:function(){var a=
this.statefulName;a||(a=this.getName());return"contexts/"+a},initStateEvents:function(){Zarafa.core.Context.superclass.initStateEvents.call(this);this.on("viewchange",this.saveViewModeState,this,{delay:100});this.on("viewmodechange",this.saveViewModeState,this,{delay:100})},saveViewModeState:function(a,b,c){b!=c&&this.saveState()},getState:function(){var a=Zarafa.core.Context.superclass.getState.call(this)||{},b=this.getModel(),c=b&&b.isSearching(),d=b&&b.isLiveScrolling();b=d&&!c&&!Zarafa.mail.data.ViewModes.isMainViewMode(this.current_view_mode);
c=d&&c&&Zarafa.mail.data.ViewModes.isMainViewMode(this.oldViewMode);return Ext.apply(a,b||c?{current_view:this.oldView,current_view_mode:this.oldViewMode}:{current_view:this.current_view,current_view_mode:this.current_view_mode})}});Ext.namespace("Zarafa.core");Zarafa.core.ContextMetaData=Ext.extend(Zarafa.core.PluginMetaData,{constructor:function(a){a=a||{};Ext.applyIf(a,{allowUserDisable:false});Zarafa.core.ContextMetaData.superclass.constructor.call(this,a)}});Ext.namespace("Zarafa.core");
Zarafa.core.ErrorType=Zarafa.core.Enum.create({MAPI:1,ZARAFA:2,GENERAL:3});Ext.namespace("Zarafa.core");
Zarafa.core.MultiFolderContextModel=Ext.extend(Zarafa.core.ContextModel,{colorScheme:undefined,assigningColors:false,default_merge_state:false,groupings:undefined,colorMap:undefined,active_group:undefined,constructor:function(a){a=a||{};this.addEvents("foldermergestatechanged","foldergroupingchanged","colormapchanged");this.groupings={};this.colorMap={};Zarafa.core.MultiFolderContextModel.superclass.constructor.call(this,a);container.getHierarchyStore().on("addFolder",this.onHierarchyAddFolder,this)},
enable:function(){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()},onHierarchyLoad:function(a){if(a.getCount()!==0){Zarafa.core.MultiFolderContextModel.superclass.onHierarchyLoad.apply(this,arguments);this.sortFolders();this.assignColors()}},onHierarchyAddFolder:function(){this.assignColors()},getDefaultFolder:function(){if(this.enabled){var a=this.getActiveGroup();if(a&&this.groupings[a]){a=this.getFolder(this.groupings[a].active);if(!Ext.isEmpty(a))return a}}return Zarafa.core.MultiFolderContextModel.superclass.getDefaultFolder.apply(this,
arguments)},activateFolderInGroup:function(a,b){this.active_group=b;this.groupings[b].active=a.get("entryid");this.fireEvent("foldergroupingchanged",this,this.groupings,this.active_group)},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);this.groupings[b].active=
a;this.active_group=b;this.fireEvent("foldergroupingchanged",this,this.groupings,this.active_group);return b},separateFolderFromGroup:function(a,b){var c=Ext.id(null,"group-"),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};this.active_group=c;this.fireEvent("foldergroupingchanged",
this,this.groupings,this.active_group);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]}this.fireEvent("foldergroupingchanged",this,this.groupings,this.active_group)},addItemToGroup:function(a){if(this.default_merge_state){var b=Object.keys(this.groupings);if(Ext.isEmpty(b)){this.active_group=
Ext.id(null,"group-");this.groupings[this.active_group]={folders:[a],active:a}}else{this.active_group=b[0];this.groupings[b[0]].folders.push(a)}}else{this.active_group=Ext.id(null,"group-");this.groupings[this.active_group]={folders:[a],active:a}}},removeItemFromGroup:function(a){Ext.iterate(this.groupings,function(b,c){if(Ext.isEmpty(c.folders))return true;var d=c.folders.indexOf(a);if(d>-1){c.folders.splice(d,1);if(Ext.isEmpty(c.folders)){delete this.groupings[b];if(this.active_group==b)this.active_group=
Object.keys(this.groupings).pop()}return false}},this)},applyGrouping:function(){for(var a=[],b=0,c=this.folders.length;b<c;b++)a.push(this.folders[b].get("entryid"));var d=[];Ext.iterate(this.groupings,function(f,g){d=d.concat(g.folders)},this);b=0;for(c=d.length;b<c;b++){var 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]);this.fireEvent("foldergroupingchanged",this,this.groupings,this.active_group)},getGroupings:function(){return this.groupings},
sortFolders:function(){if(this.folders.length>1)this.folders=container.getHierarchyStore().getSortedFolders(this.hasFolder,this)},assignColors:function(){this.assigningColors=true;for(var a=0,b=this.folders.length;a<b;a++)this.getColorScheme(this.folders[a].get("entryid"));this.assigningColors=false},getColorScheme:function(a){if(this.colorMap){var b=Zarafa.core.ColorSchemes.getColorScheme(this.colorMap[a]);if(!Ext.isDefined(b)){b=this.colorScheme[Math.floor(Math.random()*this.colorScheme.length)];
this.setColorScheme(a,b)}return b}},setColorScheme:function(a,b){this.colorMap[a]=b.name;this.assigningColors||this.fireEvent("colormapchanged",this,this.colorMap)},getActiveGroup:function(){return this.active_group},saveFolderGroupinChanged:function(a,b,c){if(this.groupings!=b||c!=this.active_group)this.saveState()},initStateEvents:function(){Zarafa.core.MultiFolderContextModel.superclass.initStateEvents.call(this);this.on("foldergroupingchanged",this.saveFolderGroupinChanged,this,{delay:100});this.on("colormapchanged",
this.saveState,this,{delay:100})},getState:function(){var a=Zarafa.core.MultiFolderContextModel.superclass.getState.call(this)||{};return Ext.apply(a,{groupings:this.groupings,active_group:this.active_group,colorMap:this.colorMap})},applyState:function(a){if(Ext.isDefined(a.groupings))for(var b in a.groupings)if(a.groupings.hasOwnProperty(b))if(a.groupings[b].folders.indexOf(a.groupings[b].active)<0)a.groupings[b].active=a.groupings[b].folders[0];Zarafa.core.MultiFolderContextModel.superclass.applyState.call(this,
a)},resetGroupings:function(){this.groupings={}}});Ext.namespace("Zarafa.core");Zarafa.core.PresencePlugin=Ext.extend(Zarafa.core.Plugin,{getPresenceStatuses:function(a){for(var b=[],c=0;c<a.length;c++)b.push(Zarafa.core.data.PresenceStatus.UNKNOWN);return b}});Ext.namespace("Zarafa.core");Zarafa.core.ThemePlugin=Ext.extend(Zarafa.core.Plugin,{constructor:function(a){Zarafa.core.Plugin.superclass.constructor.call(this,a);container.getServerConfig().getActiveTheme()===this.getName()&&this.initPlugin()}});
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.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.IPFRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{equals:function(a){if(this===a)return true;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)}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.ListModuleStore=Ext.extend(Zarafa.core.data.IPMStore,{hasSearchResults:false,useSearchFolder:false,actionType:undefined,subfolders:false,entryId:undefined,storeEntryId:undefined,folder:undefined,syncStore:false,totalLoadedRecord:undefined,loadMask:undefined,preferredMessageClass:"IPM.Note",defaultSortInfo:undefined,searchUpdateTimer:undefined,constructor:function(a){a=a||{};a.restriction={};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");this.totalLoadedRecord=container.getSettingsModel().get("zarafa/v1/main/page_size");Zarafa.core.data.ListModuleStore.superclass.constructor.call(this,a);Ext.isEmpty(this.folder)||this.setFolder(this.folder)},idComparison:function(a,b){return Zarafa.core.EntryId.compareEntryIds(a,b)},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},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.hasSearchResults)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.entryId,search_folder_entryid:this.searchFolderEntryId,store_entryid:this.storeEntryId});Ext.applyIf(a,{actionType:this.actionType});Ext.applyIf(a.params,{restriction:this.restriction});if(this.restriction.search)if(this.isAdvanceSearchStore())a.params.restriction=
Ext.apply(a.params.restriction||{},{search:this.restriction.search});else delete a.params.restriction.search;a.actionType==Zarafa.core.Actions.search&&Ext.applyIf(a.params,{use_searchfolder:this.useSearchFolder,subfolders:this.subfolders});a.actionType==Zarafa.core.Actions.list&&Ext.isArray(a.params.restriction.search)&&Ext.isDefined(a.params.search_folder_entryid)&&delete a.params.restriction.search;if(a.actionType==Zarafa.core.Actions.updatesearch||a.actionType==Zarafa.core.Actions.stopsearch)delete a.params.restriction;
a.actionType==Zarafa.core.Actions.list&&Ext.isArray(a.params.restriction.search)&&Ext.isDefined(this.searchFolderEntryId)&&this.useSearchFolder&&delete a.params.restriction.search;return Zarafa.core.data.ListModuleStore.superclass.load.call(this,a)},reload:function(a){this.hasSearchResults?this.updateSearch(Ext.applyIf(a||{},this.lastOptions)):Zarafa.core.data.ListModuleStore.superclass.reload.apply(this,arguments)},isAdvanceSearchStore:function(){return this.preferredMessageClass==="IPM.Search"},
liveScroll:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};this.isExecuting("list")&&this.proxy.cancelRequests("list");Ext.apply(a,{actionType:Zarafa.core.Actions.updatelist});Ext.isDefined(this.searchFolderEntryId)&&this.useSearchFolder&&delete this.restriction.search;this.load(a)},stopLiveScroll:function(){var a=this.lastOptions.params.restriction;this.isExecuting("updatelist")&&this.proxy.cancelRequests("updatelist");Ext.apply(this.lastOptions,{actionType:Zarafa.core.Actions.list});
Ext.apply(a,{start:0});Ext.isDefined(a)&&delete a.limit;delete this.lastOptions.add},search:function(a){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(!Ext.isEmpty(a.searchRestriction)){this.setSearchRestriction(a.searchRestriction);this.isExecuting("list")&&this.proxy.cancelRequests("list");this.setUseSearchFolder(a.useSearchFolder);this.setSubfolders(a.subfolders);this.useSearchFolder&&Ext.apply(a,{actionType:Zarafa.core.Actions.search});this.load(a);if(this.useSearchFolder)this.hasSearchResults=
true;this.fireEvent("search",this,a)}},updateSearch:function(a){if(this.hasSearchResults){Ext.isObject(a)||(a={});Ext.apply(a,{actionType:Zarafa.core.Actions.updatesearch});this.load(a);this.fireEvent("updatesearch",this,a);Ext.apply(this.lastOptions,{actionType:Zarafa.core.Actions.search})}},stopSearch:function(a){this.setSearchRestriction({});if(this.hasSearchResults){Ext.isObject(a)||(a={});if(!Ext.isObject(a.params))a.params={};if(this.isExecuting(Zarafa.core.Actions.updatesearch)||this.isExecuting(Zarafa.core.Actions.search)){this.proxy.cancelRequests(Zarafa.core.Actions.updatesearch);
this.proxy.cancelRequests(Zarafa.core.Actions.search)}if(this.searchUpdateTimer){clearTimeout(this.searchUpdateTimer);delete this.searchUpdateTimer}Ext.apply(a,{actionType:Zarafa.core.Actions.stopsearch});Ext.apply(a.params,{store_entryid:this.storeEntryId,search_folder_entryid:this.searchFolderEntryId});this.proxy.request(Ext.data.Api.actions.destroy,null,a.params,this.reader,Ext.emptyFn,this,a);this.setSearchEntryId(undefined);this.hasSearchResults=false;this.fireEvent("stopsearch",this,a);Ext.apply(this.lastOptions,
{actionType:Zarafa.core.Actions.list})}},loadRecords:function(a,b,c,d){if(c!==false){var e=undefined;if(Ext.isDefined(b.params)&&Ext.isDefined(b.params.restriction))e=b.params.restriction;var f=container.getSettingsModel().get("zarafa/v1/main/page_size");if(e){this.totalLoadedRecord=e.start?e.start+e.limit:f;if(this.syncStore){e.start=this.totalLoadedRecord-f;delete e.limit;delete this.lastOptions.add;this.syncStore=false}}if(d){d.search_meta&&this.updateSearchInfo(d.search_meta,d.page);if(d.page)this.totalLength=
d.page.totalrowcount;if(d.folder&&b.folder&&b.folder.length===1){e=b.folder[0];Ext.isDefined(d.folder.content_unread)&&e.set("content_unread",d.folder.content_unread);Ext.isDefined(d.folder.content_count)&&e.set("content_count",d.folder.content_count)}}}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},showLoadMask:function(){if(!this.loadMask){var a=container.getContentPanel();if(Ext.isFunction(a.getGridPanel)){this.loadMask=
a.getGridPanel().loadMask;this.loadMask.show()}}}});Ext.reg("zarafa.listmodulestore",Zarafa.core.data.ListModuleStore);Ext.namespace("Zarafa.core.data");Zarafa.core.data.ParalyzeReason=Zarafa.core.Enum.create({BROWSER_RELOADING:0,SESSION_EXPIRED:1,SESSION_INVALID:2});Ext.namespace("Zarafa.core.data");Zarafa.core.data.PresenceStatus=Zarafa.core.Enum.create({UNKNOWN:0,OFFLINE:1,ONLINE:2,getCssClass:function(a){a=(a=this.getName(a))?a.toLowerCase():"unknown";return"zarafa-presence-status-"+a}});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){var c;try{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){var b={sendRecords:this.sendRecords};a={error:a};this.proxy.fireEvent("exception",this.proxy,"remote",this.action,this.options,a,b);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=this.sendRecords.clone(),c=[];if(!Ext.isEmpty(a.data)&&!Ext.isEmpty(b))for(var d=0,e=a.data.length;d<e;d++)for(var f=0,g=b.length;f<g;f++)if(this.compareResponseDataToRecord(a.data[d],b[f])){c.push(a.data[d]);b.splice(f,1);break}return c},compareResponseDataToRecord:function(a,b){return b.phantom||Zarafa.core.EntryId.compareEntryIds(a.entryid,b.get("entryid"))},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.RecordCustomObjectType=Zarafa.core.Enum.create({BASE_TYPE:1E3});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,"common.search":5});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.UIFactoryTabLayer=Ext.extend(Zarafa.core.data.UIFactoryLayer,{constructor:function(a){a=a||{};Ext.applyIf(a,{type:"tabs",index:1,allowModal:false,plugins:["zarafa.contenttablayerplugin"]});Zarafa.core.data.UIFactoryTabLayer.superclass.constructor.call(this,a)},create:function(a,b){b=b||{};b.plugins=Ext.value(b.plugins,[]);b.plugins.push("zarafa.enablefocusplugin");var c=new a(b);container.getTabPanel().add(c)}});Zarafa.core.data.UIFactory.registerLayer(new Zarafa.core.data.UIFactoryTabLayer);
Ext.namespace("Zarafa.core.data");
Zarafa.core.data.UIFactoryWindowLayer=Ext.extend(Zarafa.core.data.UIFactoryLayer,{constructor:function(a){a=a||{};Ext.applyIf(a,{type:"dialogs",index:10,allowModal:true,manager:Ext.WindowMgr,plugins:["zarafa.contentwindowlayerplugin"]});Zarafa.core.data.UIFactoryWindowLayer.superclass.constructor.call(this,a)},create:function(a,b){var c=new a(b),d={modal:c.modal,manager:c.manager,constrainHeader:true,minimizable:c.minimizable||false,headerCfg:{tag:"div",cls:"zarafa-window-header x-window-header x-unselectable x-window-draggable"},layout:"fit",
items:[c],title:c.title,listeners:{afterrender:function(e){Ext.isDefined(e.header)&&Ext.isElement(e.header.dom)&&Ext.DomHelper.append(e.header.dom,"<span class='fade'>&nbsp;</span>")}}};Ext.applyIf(d.listeners,b.listeners);if(c.closeAction){d.closeAction=c.closeAction;d[c.closeAction]=c[c.closeAction].createDelegate(c)}c=document.activeElement;d=new Ext.Window(d);d.on("close",this.onWindowClose.createDelegate(this,[c]));d.show()},onWindowClose:function(a){a&&a.focus()}});Zarafa.core.data.UIFactory.registerLayer(new Zarafa.core.data.UIFactoryWindowLayer);
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.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.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.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.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.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.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.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.FlavorFlags=Zarafa.core.Enum.create({FWD_PRESERVE_SENDER:1,FWD_DO_NOT_MUNGE_MSG:2,FWD_AS_ATTACHMENT:4});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.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.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.MDBProvider=Zarafa.core.Enum.create({ZARAFA_SERVICE_GUID:"ca3d253c27d23c4494fe425fab958c19",ZARAFA_STORE_PUBLIC_GUID:"094a7fd4bdd33c49b2fc3c90bbcb48d4",ZARAFA_STORE_DELEGATE_GUID:"85107c7c6dbc534e9dab8a53f8def808",ZARAFA_STORE_ARCHIVER_GUID:"ad5389bc3f2e72419404896ff459870f"});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.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.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.NoteColor=Zarafa.core.Enum.create({note_blue:0,note_green:1,note_pink:2,note_yellow:3,note_white:4,getColorText:function(a){var b="";switch(parseInt(a,10)){case this.note_blue:b=_("Blue");break;case this.note_green:b=_("Green");break;case this.note_pink:b=_("Pink");break;case this.note_white:b=_("White");break;case this.note_yellow:default:b=_("Yellow");break}return b},getColorValue:function(a){return this[Zarafa.core.mapi.IconIndex.getName(a)]}});
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.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.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.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.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.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.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.RuleActions=Zarafa.core.Enum.create({OP_MOVE:1,OP_COPY:2,OP_REPLY:3,OP_OOF_REPLY:4,OP_DEFER_ACTION:5,OP_BOUNCE:6,OP_FORWARD:7,OP_DELEGATE:8,OP_TAG:9,OP_DELETE:10,OP_MARK_AS_READ:11});Ext.namespace("Zarafa.core.mapi");
Zarafa.core.mapi.RuleStates=Zarafa.core.Enum.create({ST_DISABLED:0,ST_ENABLED:1,ST_ERROR:2,ST_ONLY_WHEN_OOF:4,ST_KEEP_OOF_HIST:8,ST_EXIT_LEVEL:16,ST_SKIP_IF_SCL_IS_SAFE:32,ST_RULE_PARSE_ERROR:64,ST_CLEAR_OOF_HIST:2147483648});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.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.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.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.TaskState=Zarafa.core.Enum.create({NORMAL:0,OWNER_NEW:1,OWNER:2,ACCEPT:3,DECLINE:4});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.plugins");Zarafa.core.plugins.ContentTabLayerPlugin=Ext.extend(Zarafa.core.plugins.ContentLayerPlugin,{focus:function(){container.getTabPanel().setActiveTab(this.field)}});Ext.preg("zarafa.contenttablayerplugin",Zarafa.core.plugins.ContentTabLayerPlugin);Ext.namespace("Zarafa.core.plugins");
Zarafa.core.plugins.ContentWindowLayerPlugin=Ext.extend(Zarafa.core.plugins.ContentLayerPlugin,{win:undefined,windowRelays:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{windowRelays:["beforeshow","show","beforehide","hide"]});Zarafa.core.plugins.ContentWindowLayerPlugin.superclass.constructor.call(this,a)},initPlugin:function(){this.win=this.field.findParentByType("window");this.win.saveState=function(){this.field.saveState()}.createDelegate(this);this.field.relayEvents(this.win,this.windowRelays);
Zarafa.core.plugins.ContentWindowLayerPlugin.superclass.initPlugin.apply(this,arguments);this.win.on("render",this.applyTooltip)},applyTooltip:function(){var a=Ext.get(this.el).child(".x-tool-close",true);if(a)a.qtip=_("Close")+" (Ctrl + Alt + W)"},setTitle:function(a){this.win.setTitle(Ext.util.Format.htmlEncode(a))},hide:function(){this.win.hide()},close:function(){this.win.close()},focus:function(){(this.win.manager||Ext.WindowMgr).bringToFront(this.win)}});
Ext.preg("zarafa.contentwindowlayerplugin",Zarafa.core.plugins.ContentWindowLayerPlugin);Ext.namespace("Zarafa.core.ui");
Zarafa.core.ui.MessageContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{sendValidationQueue:undefined,sendingText:{msg:_("Sending")+"..."},sendingDoneText:{title:_("Sent"),msg:_("Sent successfully")},isSending:false,sendingEl:undefined,closeOnSend:false,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);container.getSettingsModel().get("zarafa/v1/contexts/mail/readflag_time_enable")===true&&a.plugins.push({ptype:"zarafa.markasreadplugin",ignoreReadFlagTimer:true});this.addEvents("beforesendrecord",
"sendrecord","aftersendrecord");Zarafa.core.ui.MessageContentPanel.superclass.constructor.call(this,a);this.createSendValidationQueue();if(Ext.isString(this.sendingText))this.sendingText={title:"",msg:this.sendingText};if(Ext.isString(this.sendingDoneText))this.sendingDoneText={title:"",msg:this.sendingDoneText}},createSendValidationQueue:function(){this.sendValidationQueue=new Zarafa.core.data.CallbackQueue;this.sendValidationQueue.add(this.validateEmptyRecipients,this);this.sendValidationQueue.add(this.validateEmptySubject,
this);this.sendValidationQueue.add(this.validateResolvedRecipients,this);this.sendValidationQueue.add(this.validateAttachmentUpload,this)},displayInfoMask:function(){if(this.showInfoMask!==false)if(this.record.hasMessageAction("send")||this.record.getMessageAction("sendResponse"))this.sendingEl=container.getNotifier().notify("info.sending",this.sendingText.title,this.sendingText.msg,{container:this.getEl(),persistent:true});else Zarafa.core.ui.MessageContentPanel.superclass.displayInfoMask.apply(this,
arguments)},hideInfoMask:function(a){if(this.showInfoMask!==false)if(this.record.hasMessageAction("send")||this.record.getMessageAction("sendResponse")){this.sendingEl&&container.getNotifier().notify("info.sending",null,null,{container:this.getEl(),destroy:true,reference:this.sendingEl});a!==false&&container.getNotifier().notify("info.sent",this.sendingDoneText.title,this.sendingDoneText.msg)}else Zarafa.core.ui.MessageContentPanel.superclass.hideInfoMask.apply(this,arguments)},onBeforeSaveRecord:function(a,
b){if(b&&(b.update&&b.update.indexOf(this.record)>=0||b.create&&b.create.indexOf(this.record)>=0))this.isSending=this.record.hasMessageAction("send")||this.record.hasMessageAction("sendResponse");Zarafa.core.ui.MessageContentPanel.superclass.onBeforeSaveRecord.apply(this,arguments)},onUpdateRecord:function(a,b,c){Zarafa.core.ui.MessageContentPanel.superclass.onUpdateRecord.apply(this,arguments);var d=this.isSending;if(b==Ext.data.Record.COMMIT){var e=c.hasMessageAction("send")||this.record.hasMessageAction("sendResponse");
if(e){this.fireEvent("aftersendrecord",this,this.record);this.isSending=false}if(d&&this.closeOnSend&&e){this.close();return false}}},onExceptionRecord:function(a,b){if(b!=="open")this.isSending=false;Zarafa.core.ui.MessageContentPanel.superclass.onExceptionRecord.apply(this,arguments)},sendRecord:function(){if(this.isSaving===true)this.on("aftersaverecord",this.onAfterSaveRecord,this,{single:true});else if(!(this.recordComponentPlugin.allowWrite===false||this.isSending===true))if(this.fireEvent("beforesendrecord",
this,this.record)!==false){this.isSending=true;this.sendValidationQueue.run(this.onCompleteValidateSendRecord,this)}},onAfterSaveRecord:function(a,b){this.mon(b.getStore(),"write",this.sendRecord,this,{single:true})},validateEmptyRecipients:function(a){var b=this.record.getRecipientStore();if(!Ext.isDefined(b)||b.getCount()===0){container.getNotifier().notify("warning.sending",_("Zarafa WebApp"),_("Please specify a recipient"));a(false)}else{var c=true;b.each(function(d){if(d.get("recipient_type")!==
Zarafa.core.mapi.RecipientType.MAPI_ORIG)return c=false},this);if(c){container.getNotifier().notify("warning.sending",_("Zarafa WebApp"),_("Please specify a recipient"));a(false)}else a(true)}},validateAttachmentUpload:function(a){var b=true;this.record.getAttachmentStore().each(function(d){if(!d.isUploaded())return b=false},this);if(b)a(true);else{var c=_("The attached files are not uploaded yet.");c+="<br/>";c+=_("Do you want to send this message without attachments?");Zarafa.common.dialogs.MessageBox.addCustomButtons({title:_("Zarafa WebApp"),
icon:Ext.MessageBox.WARNING,msg:c,fn:function(d){a(d==="sendanyway")},customButton:[{text:_("Don't Send"),name:"dontsend"},{text:_("Send Anyway"),name:"sendanyway"}]})}},validateEmptySubject:function(a){Ext.isEmpty(this.record.get("subject"))?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("Send this message without a subject?"),function(b){a(b=="yes")},this):a(true)},validateResolvedRecipients:function(a){var b=this.record.getRecipientStore(),c=b.getUnresolvedRecipients(),d=b.getInvalidRecipients();
if(Ext.isEmpty(d))if(Ext.isEmpty(c))a(true);else{this.mon(b,"resolved",this.validateResolvedRecipients.createDelegate(this,[a],false),this,{single:true});b.resolve(c,{cancelPreviousRequest:true})}else{container.getNotifier().notify("warning.sending","",_("Not all recipients could be resolved"));a(false)}},onCompleteValidateSendRecord:function(a){if(a){this.record.addMessageAction("send",true);this.saveRecord()!==false&&this.fireEvent("sendrecord",this,this.record)}else this.isSending=false}});
Ext.reg("zarafa.messagecontentpanel",Zarafa.core.ui.MessageContentPanel);Ext.namespace("Zarafa.core.ui.notifier");Zarafa.core.ui.notifier.ConsolePlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notify:function(a,b,c){if(console){b=b+": "+c;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.notifier");Zarafa.core.ui.notifier.MessageBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notify:function(a,b,c){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;return 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.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.SliderNotifierPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{msgTemplate:new Ext.XTemplate('<div class="{categorycls} {basecls}"><div class="left"><div class="icon" ></div></div><div class="right"><h2 class="{basecls}-title">{title}</h2><div class={basecls}-message">{message}</div></div></div>'),itemCls:"zarafa-slide-notifier",categoryCls:"zarafa-slide-notifier",msgLifetime:5,sliderContainerPosition:"t",constructor:function(a){Zarafa.core.ui.notifier.SliderNotifierPlugin.superclass.constructor.call(this,
a);if(Ext.isString(this.msgTemplate))this.msgTemplate=new Ext.XTemplate(this.msgTemplate,{compiled:true})},getSliderContainer:function(a,b){a=a||Ext.getBody();var c=a.id+"-"+b,d=Zarafa.core.ui.notifier.SliderNotifierPlugin.sliderContainers;if(!d[c]||!Ext.get(d[c].container.id))d[c]=new Zarafa.core.ui.notifier.SliderContainer({parentContainer:a,containerPosition:b,slideinDirection:b[0],slideoutDirection:b[0]});else d[c].parentContainer=a;return d[c]},notify:function(a,b,c,d){d=d||{};var e=this.itemCls;
a=this.categoryCls+"-"+a.split(".")[0]+" "+this.categoryCls+"-"+a.replace(/\./g,"-");b=this.msgTemplate.apply({title:b,message:c,basecls:e,categorycls:a});c=this.getSliderContainer(d.container,this.sliderContainerPosition);if(d.reference)if(d.destroy)c.removeMessage(d.reference);else{if(d.update)return c.updateMessage(d.reference,b)}else{b=c.createMessage(b,d.persistent?false:this.msgLifetime);d.listeners&&this.addMessageListeners(b,d.listeners);return b}},addMessageListeners:function(a,b){for(var c in b){var d=
b[c];if(c!=="scope"&&Ext.isFunction(d))a.on(c,function(e,f,g){g.call(this,f,e)}.createDelegate(b.scope||a,[a,d],1))}}});Zarafa.core.ui.notifier.SliderNotifierPlugin.sliderContainers={};Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.ToolbarNotifierPlugin=Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin,{notify:function(a,b,c){if(a=="info.mailsaving"||a=="info.mailsaved")if(c.toolbar){if(!c.toolbar.saveMessageText){c.toolbar.add([{xtype:"tbfill"},{xtype:"tbtext",autoWidth:true,ref:"saveMessageText"}]);c.toolbar.doLayout()}c.toolbar.saveMessageText.setText(b)}Zarafa.core.ui.notifier.ToolbarNotifierPlugin.superclass.notify.apply(this,arguments)}});
Zarafa.onReady(function(){container.getNotifier().registerPlugin("toolbarnotifierplugin",new Zarafa.core.ui.notifier.ToolbarNotifierPlugin)});Ext.namespace("Zarafa.common");
Zarafa.common.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[Ext.EventObject.ZERO,Ext.EventObject.ONE,Ext.EventObject.TWO,Ext.EventObject.THREE,Ext.EventObject.FOUR,Ext.EventObject.FIVE,Ext.EventObject.SIX,Ext.EventObject.SEVEN,Ext.EventObject.EIGHT,Ext.EventObject.NINE,Ext.EventObject.NUM_ZERO,Ext.EventObject.NUM_ONE,Ext.EventObject.NUM_TWO,Ext.EventObject.NUM_THREE,Ext.EventObject.NUM_FOUR,Ext.EventObject.NUM_FIVE,Ext.EventObject.NUM_SIX,Ext.EventObject.NUM_SEVEN,Ext.EventObject.NUM_EIGHT,
Ext.EventObject.NUM_NINE],b=[{key:a,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onSwitchContexts,scope:this,settingsCfg:{description:_("Switch between different contexts e.g. inbox, calendar, etc."),category:_("Basic navigation")}}];a=[{key:a,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onSwitchViews,scope:this,settingsCfg:{description:_("Switch between different views"),category:_("Basic navigation")}},{key:Ext.EventObject.N,ctrl:true,alt:true,shift:false,stopEvent:true,
handler:this.onNewItem,scope:this,settingsCfg:{description:_("New item"),category:_("Creating an item")}},{key:Ext.EventObject.F5,ctrl:false,alt:false,shift:false,stopEvent:true,handler:this.onRefresh,scope:this,settingsCfg:{description:_("Refresh"),category:_("All views")},basic:true}];var c=[{key:Ext.EventObject.W,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onCloseCurrentMainContentTab,scope:this,settingsCfg:{description:_("Close tab"),category:_("Basic navigation")}}],d=[{key:Ext.EventObject.P,
ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onPrintItem,scope:this,settingsCfg:{description:_("Print item"),category:_("Items")},basic:true}],e=[{key:Ext.EventObject.S,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onSaveTabItem,scope:this,settingsCfg:{description:_("Save an item e.g. mail, contact, etc."),category:_("Items")},basic:true}],f=[{key:Ext.EventObject.ENTER,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onSendTabItem,scope:this,settingsCfg:{description:_("Send an item e.g. mail, meeting request, etc."),
category:_("Items")},basic:true}],g=[{key:Ext.EventObject.A,ctrl:true,alt:false,shift:false,stopEvent:true,enableGlobally:true,handler:this.onSelectAll,scope:this,settingsCfg:{description:_("Select all items"),category:_("All views")},basic:true},{key:Ext.EventObject.HOME,ctrl:false,alt:false,shift:true,handler:this.onSelectUpDown,scope:this,settingsCfg:{description:_("Extend the selection to the first item in the list"),category:_("All views")}},{key:Ext.EventObject.END,ctrl:false,alt:false,shift:true,
handler:this.onSelectUpDown,scope:this,settingsCfg:{description:_("Extend the selection to the last item in the list"),category:_("All views")}}],i=[{key:Ext.EventObject.ENTER,ctrl:false,alt:false,shift:false,stopEvent:true,enableGlobally:true,handler:this.onOpenItem,scope:this,settingsCfg:{description:_("Open selected item"),category:_("All views")},basic:true},{key:Ext.EventObject.G,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onCategorize,scope:this,settingsCfg:{description:_("Open dialog to categorize selected item"),
category:_("All views")}},{key:Ext.EventObject.P,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onPrintList,scope:this,settingsCfg:{description:_("Print list"),category:_("All views")}},{key:Ext.EventObject.P,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onPrintListItem,scope:this,settingsCfg:{description:_("Print selected item"),category:_("All views")},basic:true},{key:Ext.EventObject.M,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onMoveItem,scope:this,settingsCfg:{description:_("Open copy/move dialog"),
category:_("All views")}},{key:Ext.EventObject.DELETE,ctrl:false,alt:false,shift:false,stopEvent:true,enableGlobally:true,handler:this.onDeleteItem,scope:this,settingsCfg:{description:_("Delete selected item"),category:_("All views")},basic:true}],h=[{key:Ext.EventObject.ENTER,ctrl:false,alt:false,shift:false,stopEvent:true,enableGlobally:true,handler:this.onOpenReminder,scope:this}];Zarafa.core.KeyMapMgr.register("global",b);Zarafa.core.KeyMapMgr.register("global",a);Zarafa.core.KeyMapMgr.register("grid",
g);Zarafa.core.KeyMapMgr.register("view.mapimessage",g);Zarafa.core.KeyMapMgr.register("grid.mapimessage",i);Zarafa.core.KeyMapMgr.register("view.mapimessage",i);Zarafa.core.KeyMapMgr.register("grid.reminder",h);Zarafa.core.KeyMapMgr.register("contentpanel",c);Zarafa.core.KeyMapMgr.register("contentpanel.record",d);Zarafa.core.KeyMapMgr.register("contentpanel.record",e);Zarafa.core.KeyMapMgr.register("contentpanel.record.message",f);Zarafa.core.KeyMapMgr.register("previewpanel.mail",d)},onNewItem:function(){var a=
container.getMainPanel().mainToolbar.newButton;a.handler.call(a.scope)},onRefresh:function(){var a=container.getMainPanel().mainToolbar.refreshButton;a.isVisible()&&a.handler.call(a.scope)},onSwitchContexts:function(a,b){var c=parseInt(b.getKeyCharCode(),10),d=container.getMainPanel().mainTabBar;if((c=d.find("type","button")[c])&&c.handler&&c.handler!==d.onLogoutButton)c.handler.call(c.scope||c)},onSwitchViews:function(a,b){var c=parseInt(b.getKeyCharCode(),10)-1;if((c=container.getCurrentContext().getMainToolbarViewButtons()[c])&&
c.handler)c.handler.call(c.scope||c,c)},onCloseCurrentMainContentTab:function(a,b,c){c.closable&&c[c.closeAction]()},onSendTabItem:function(a,b,c){Ext.isFunction(c.sendRecord)&&c.sendRecord()},onSaveTabItem:function(a,b,c){Ext.isFunction(c.saveRecord)&&c.saveRecord()},onPrintItem:function(a,b,c){c.record&&Zarafa.common.Actions.openPrintDialog(c.record)},onPrintList:function(a,b,c){c.context&&Zarafa.common.Actions.openPrintDialog(c.context)},getSelectedRecords:function(a){if(Ext.isFunction(a.getSelectedRecords))return a.getSelectedRecords();
else if(Ext.isFunction(a.getSelectionModel))return a.getSelectionModel().getSelections();return[]},onPrintListItem:function(a,b,c){a=this.getSelectedRecords(c);Ext.isEmpty(a)||Zarafa.common.Actions.openPrintDialog(a)},onMoveItem:function(a,b,c){a=this.getSelectedRecords(c);Ext.isEmpty(a)||Zarafa.common.Actions.openCopyMoveContent(a)},onDeleteItem:function(a,b,c){a=this.getSelectedRecords(c);Ext.isEmpty(a)||Zarafa.common.Actions.deleteRecords(a)},onCategorize:function(a,b,c){a=this.getSelectedRecords(c);
Ext.isEmpty(a)||Zarafa.common.Actions.openCategoriesContent(a)},onOpenItem:function(a,b,c){a=this.getSelectedRecords(c);if(!Ext.isEmpty(a)){b=0;for(c=a.length;b<c;b++)a[b].isUnsent()&&!a[b].isFaultyMessage()?Zarafa.core.data.UIFactory.openCreateRecord(a[b]):Zarafa.core.data.UIFactory.openViewRecord(a[b])}},onOpenReminder:function(a,b,c){a=this.getSelectedRecords(c);if(!Ext.isEmpty(a)){b=0;for(c=a.length;b<c;b++)Zarafa.common.Actions.openReminderRecord(a[b])}},onSelectUpDown:function(a,b,c){var d=
c.getStore();b=null;if(a===Ext.EventObject.HOME)b=0;else if(a===Ext.EventObject.END)b=d.getCount();if(Ext.isFunction(c.selectRange)){a=c.getSelectedRecords();Ext.isEmpty(a)||c.selectRange(d.indexOf(a[0]),b)}else if(Ext.isFunction(c.getSelectionModel)){c=c.getSelectionModel();if(a=c.getSelected())if(!c.singleSelect){d=d.indexOf(a);c.selectRange(d,b)}}},onSelectAll:function(a,b,c){if(Ext.isFunction(c.selectRange))c.selectRange();else if(Ext.isFunction(c.getSelectionModel)){a=c.getSelectionModel();a.singleSelect||
a.selectAll()}}});Zarafa.common.KeyMapping=new Zarafa.common.KeyMapping;Ext.namespace("Zarafa.common.data");Zarafa.common.data.DataModes=Zarafa.core.Enum.create({ALL:0,SEARCH:1});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.data");Zarafa.common.data.ViewModes=Zarafa.core.Enum.create({NO_PREVIEW:0,RIGHT_PREVIEW:1,BOTTOM_PREVIEW:2,SEARCH:3,LIVESCROLL:4,isMainViewMode:function(a){return a===this.NO_PREVIEW||a===this.RIGHT_PREVIEW||a===this.BOTTOM_PREVIEW}});Ext.namespace("Zarafa.common.data");Zarafa.common.data.Views=Zarafa.core.Enum.create({LIST:0,SEARCH:1,LIVESCROLL:2});Ext.namespace("Zarafa.common.delegates.dialogs");
Zarafa.common.delegates.dialogs.DelegatePermissionContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.delegatepermissioncontentpanel",layout:"fit",modal:true,recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true,useShadowStore:true}),autoSave:false,width:500,height:325,title:_("Delegate Permissions"),items:[{xtype:"zarafa.delegatepermissionpanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},
{text:_("Cancel"),handler:this.onCancel,scope:this}]}]});Zarafa.common.delegates.dialogs.DelegatePermissionContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.delegatepermissioncontentpanel",Zarafa.common.delegates.dialogs.DelegatePermissionContentPanel);Ext.namespace("Zarafa.common.dialogs");
Zarafa.common.dialogs.CopyMovePanelKeyMapping=Ext.extend(Object,{constructor:function(){Zarafa.core.KeyMapMgr.register("Zarafa.common.dialogs.CopyMovePanel",[{key:Ext.EventObject.ENTER,ctrl:false,alt:false,shift:false,stopEvent:true,handler:this.onMoveItems,enableGlobally:true,scope:this,basic:true}])},onMoveItems:function(a,b,c){c.onMove()}});Zarafa.common.dialogs.CopyMovePanelKeyMapping=new Zarafa.common.dialogs.CopyMovePanelKeyMapping;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,{autoHeight:true,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);this.iconEl.removeClass(["x-freebusy-userlist-recipienttype-required","x-freebusy-userlist-recipienttype-optional",
"x-freebusy-userlist-recipienttype-resource"]);Zarafa.common.freebusy.ui.UserlistBox.superclass.update.apply(this,arguments);this.record.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&this.enableButtons===true&&Ext.isDefined(this.expandBtnEl)&&this.onResize(this.width,this.height,this.width,this.height)}});Ext.reg("zarafa.userlistbox",Zarafa.common.freebusy.ui.UserlistBox);Ext.ns("Zarafa.common.plugins");
Zarafa.common.plugins.PercentSpinner=Ext.extend(Zarafa.common.plugins.NumberSpinner,{constructor:function(a){a=a||{};Ext.applyIf(a,{allowDecimals:true,decimalPrecision:4});Zarafa.common.plugins.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.plugins.PercentSpinner.superclass.init.call(this,a)},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;Zarafa.common.plugins.PercentSpinner.superclass.setValue.call(this,a)}});Ext.preg("zarafa.percentspinner",Zarafa.common.plugins.PercentSpinner);
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},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=Ext.util.Format.htmlEncode(a.getAttachmentNames());return b},customStylesheetPath:"client/resources/css/external/print.record.css"});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.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.RecurrenceType=Zarafa.core.Enum.create({NONE:0,DAILY:10,WEEKLY:11,MONTHLY:12,YEARLY:13});Ext.namespace("Zarafa.common.recurrence.dialogs");
Zarafa.common.recurrence.dialogs.RecurrenceContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{editRecurrence:false,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.recurrencecontentpanel",layout:"fit",title:_("Appointment Recurrence"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),border:false,defaults:{bodyStyle:"padding-top: 5px; padding-left: 6px; padding-right: 5px; background-color: inherit;",border:false},autoSave:false,width:600,
height:500,items:[{xtype:"zarafa.recurrencepanel",ref:"recurrencePanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this,ref:"../../okBtn"},{text:_("Cancel"),scope:this,handler:this.onCancel},{text:_("Remove Recurrence"),handler:this.onRemoveRecurrence,scope:this,ref:"../../removeReccurrenceBtn"}]}]});Zarafa.common.recurrence.dialogs.RecurrenceContentPanel.superclass.constructor.call(this,a);this.on("beforesetrecord",this.onBeforeSetRecord,this);this.on("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;Ext.isDate(d)||(d=b.get("alldayevent")?c.add(Date.DAY,1):c.add(Date.MINUTE,30));if(b.get("alldayevent")){var f=0;e=c.getHours()*60+c.getMinutes();if(c.clearTime(true).getTime()===c.getTime()){f=e;e=0}d=e+f+Date.diff(Date.MINUTE,d,c)}else{e=c.getHours()*60+c.getMinutes();d=e+Date.diff(Date.MINUTE,d,c)}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.clearTime(true).fromUTC());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.RecurrenceContentPanel.superclass.onOk.apply(this,arguments)},this):Zarafa.common.recurrence.dialogs.RecurrenceContentPanel.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","")},update:function(a){this.updateTitleFromRecord(a);var b=false;if(a&&a.isSubMessage())b=true;this.removeReccurrenceBtn.setDisabled(b);this.okBtn.setDisabled(b)},updateTitleFromRecord:function(a){if(Ext.isDefined(a))a.isMessageClass("IPM.TaskRequest",true)?this.setTitle(_("Task Recurrence")):this.setTitle(_("Appointment Recurrence"));else this.setTitle(this.initialConfig.title)},
onSetRecord:function(a,b,c){Zarafa.common.recurrence.dialogs.RecurrenceContentPanel.superclass.onSetRecord.call(this,a,b,c);this.updateTitleFromRecord(b)},onRemoveRecurrence:function(){this.record.beginEdit();this.record.set("recurring",false);this.record.set("recurring_pattern","");this.record.set("recurrence_type",Zarafa.common.recurrence.data.RecurrenceType.NONE);this.record.endEdit();Ext.isDefined(this.modalRecord)&&this.modalRecord.applyData(this.record);if(this.autoSave!==false){var a=this.modalRecord||
this.record;this.displayInfoMask();this.isSaving=true;a.save()}else this.close()}});Ext.reg("zarafa.recurrencecontentpanel",Zarafa.common.recurrence.dialogs.RecurrenceContentPanel);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,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),batch:false});Zarafa.common.reminder.data.ReminderStore.superclass.constructor.call(this,
a)},initEvents:function(){this.on("exception",this.onError,this);Zarafa.common.reminder.data.ReminderStore.superclass.initEvents.call(this)},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){c===Ext.data.Api.actions.read&&this.clearReminderInterval();this.lastChecksum=
undefined},initializeReminderInterval:function(){var a=container.getSettingsModel().get("zarafa/v1/main/reminder/polling_interval");if(Ext.isNumber(a)&&a>0){this.on("load",this.sendReminderRequest,this,{buffer:a*1E3});this.sendReminderRequest.defer(a*1E3,this)}},sendReminderRequest:function(){this.load()},resetReminderInterval:function(){this.clearReminderInterval();this.initializeReminderInterval()},clearReminderInterval:function(){this.un("load",this.sendReminderRequest,this)},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.openReminderContent(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.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.restoreitem.dialogs");
Zarafa.common.restoreitem.dialogs.RestoreItemContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{folder:undefined,store:undefined,constructor:function(a){a=a||{};var b=a.folder,c="",d=_("Restore Softdeleted Items");if(b){c=b.getFullyQualifiedDisplayName();Ext.isEmpty(c)||(d=String.format(_("Restore From {0}"),c))}Ext.applyIf(a,{xtype:"zarafa.restoreitemcontentpanel",layout:"fit",title:d,items:[{xtype:"zarafa.restoreitempanel",folder:b,store:a.store}]});Zarafa.common.restoreitem.dialogs.RestoreItemContentPanel.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.restoreitemcontentpanel",Zarafa.common.restoreitem.dialogs.RestoreItemContentPanel);Ext.namespace("Zarafa.common.rules.data");Zarafa.common.rules.data.ActionFlags=Zarafa.core.Enum.create({UNKNOWN:-1,MOVE:1,COPY:2,DELETE:3,REDIRECT:4,FORWARD:5,FORWARD_ATTACH:6});Ext.namespace("Zarafa.common.rules.data");Zarafa.common.rules.data.ConditionFlags=Zarafa.core.Enum.create({UNKNOWN:-1,RECEIVED_FROM:1,SENT_TO:2,SUBJECT_WORDS:3,BODY_WORDS:4,SENDER_WORDS:5,NAME_TO_CC:6,IMPORTANCE:7,SENT_TO_ME_ONLY:8});
Ext.namespace("Zarafa.core.data");
Zarafa.common.rules.data.RulesProxy=Ext.extend(Zarafa.core.data.IPMProxy,{getResponseHandlerForRequest:function(a,b,c,d,e,f,g,i,h){return new Zarafa.common.rules.data.RulesResponseHandler({proxy:this,action:c,reader:f,sendRecords:d,options:h,callback:g,scope:i})},createUpdateAction:function(a,b,c,d,e,f,g){Ext.applyIf(g,{listRequest:true});c=c.jsonData[d.meta.root];Zarafa.common.rules.data.RulesProxy.superclass.createUpdateAction.apply(this,arguments)},destroyAction:function(a,b,c,d,e,f,g){Ext.applyIf(g,
{listRequest:true});c=c.jsonData[d.meta.root];Zarafa.common.rules.data.RulesProxy.superclass.destroyAction.apply(this,arguments)},openAction:function(a,b,c,d,e,f,g){Ext.applyIf(g,{listRequest:true});c=c.jsonData[d.meta.root];Zarafa.common.rules.data.RulesProxy.superclass.openAction.apply(this,arguments)}});Ext.namespace("Zarafa.common.rules.dialogs");
Zarafa.common.rules.dialogs.RulesEditContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.ruleseditcontentpanel",layout:"fit",modal:true,recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true,useShadowStore:true}),autoSave:false,width:600,height:400,title:_("Inbox Rule"),items:[{xtype:"zarafa.ruleseditpanel",buttons:[{text:_("Save"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,
scope:this}]}]});Zarafa.common.rules.dialogs.RulesEditContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.ruleseditcontentpanel",Zarafa.common.rules.dialogs.RulesEditContentPanel);Ext.namespace("Zarafa.common.sendas.dialogs");
Zarafa.common.sendas.dialogs.SendAsEditContentPanel=Ext.extend(Zarafa.common.recipientfield.ui.EditRecipientContentPanel,{removeOnCancel:true,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.sendaseditcontentpanel",title:_("Add/Edit recipient")});Zarafa.common.sendas.dialogs.SendAsEditContentPanel.superclass.constructor.call(this,a)},onOk:function(){var a=this.formPanel.getForm();if(a.isValid()){a.updateRecord(this.record);this.record.generateOneOffEntryId();this.close()}},closeWrap:function(){this.removePhantomRecord();
Zarafa.common.sendas.dialogs.SendAsEditContentPanel.superclass.closeWrap.apply(this,arguments)},onCancel:function(){this.removePhantomRecord();Zarafa.common.sendas.dialogs.SendAsEditContentPanel.superclass.onCancel.call(this)},removePhantomRecord:function(){this.removeOnCancel===true&&this.record.phantom&&this.record.store.remove(this.record)}});Ext.reg("zarafa.sendaseditcontentpanel",Zarafa.common.sendas.dialogs.SendAsEditContentPanel);Ext.namespace("Zarafa.common.ui.layout");
Zarafa.common.ui.layout.SwitchBorderLayout.Orientation=Zarafa.core.Enum.create({OFF:"off",VERTICAL:"vertical",HORIZONTAL:"horizontal"});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.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.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,i,h){return new Zarafa.addressbook.AddressBookResponseHandler({proxy:this,action:c,reader:f,options:h,callback:g,scope:i})}});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.dialogs");
Zarafa.addressbook.dialogs.ABGroupDetailContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abgroupdetailcontentpanel",layout:"fit",border:false,title:_("Group details"),items:[{xtype:"zarafa.abgroupdetailpanel"}]});Zarafa.addressbook.dialogs.ABGroupDetailContentPanel.superclass.constructor.call(this,a)},update:function(){this.updateTitleFromRecord(this.record)},updateTitleFromRecord:function(a){a=a.get("display_name");Ext.isEmpty(a)?
this.setTitle(this.initialConfig.title):this.setTitle(a)}});Ext.reg("zarafa.abgroupdetailcontentpanel",Zarafa.addressbook.dialogs.ABGroupDetailContentPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserDetailContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.abuserdetailcontentpanel",layout:"fit",border:false,title:_("User details"),items:[{xtype:"zarafa.abuserdetailpanel"}]});Zarafa.addressbook.dialogs.ABUserDetailContentPanel.superclass.constructor.call(this,a)},update:function(a,b){this.updateTitleFromRecord(this.record);b&&this.updateIconFromRecord(this.record)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},
updateTitleFromRecord:function(a){a=a.get("display_name");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)}});Ext.reg("zarafa.abuserdetailcontentpanel",Zarafa.addressbook.dialogs.ABUserDetailContentPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.ABUserSelectionContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{callback:Ext.emptyFn,singleSelect:true,scope:undefined,hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.abuserselectioncontentpanel",layout:"fit",title:_("Address Book"),items:[{xtype:"zarafa.abuserselectionpanel",hierarchyRestriction:a.hierarchyRestriction,listRestriction:a.listRestriction,callback:a.callback,singleSelect:Ext.isDefined(a.singleSelect)?
a.singleSelect:this.singleSelect,scope:a.scope}]});Zarafa.addressbook.dialogs.ABUserSelectionContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.abuserselectioncontentpanel",Zarafa.addressbook.dialogs.ABUserSelectionContentPanel);Ext.namespace("Zarafa.addressbook.dialogs");
Zarafa.addressbook.dialogs.AddressBookContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{hierarchyRestriction:undefined,listRestriction:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.addressbookcontentpanel",layout:"fit",title:_("Address Book"),items:[{xtype:"zarafa.addressbookpanel",listRestriction:a.listRestriction,hierarchyRestriction:a.hierarchyRestriction}]});Zarafa.addressbook.dialogs.AddressBookContentPanel.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.addressbookcontentpanel",Zarafa.addressbook.dialogs.AddressBookContentPanel);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.advancesearch");
Zarafa.advancesearch.AdvanceSearchContextModel=Ext.extend(Zarafa.core.ContextModel,{stores:{},constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.advancesearch.AdvanceSearchStore;Ext.applyIf(a,{statefulRecordSelection:true,current_data_mode:Zarafa.common.data.DataModes.ALL,stateful:false});Zarafa.advancesearch.AdvanceSearchContextModel.superclass.constructor.call(this,a);container.on("folderselect",this.onFolderSelect,this)},setActiveStore:function(a){this.store=a},getActiveStore:function(){return this.store},
pushStore:function(a,b){this.stores[a]=b},discardStore:function(a){delete this.stores[a]},createNewSearchStore:function(a){var b=new Zarafa.advancesearch.AdvanceSearchStore({searchStoreUniqueId:a.searchTabId});this.setActiveStore(b);this.pushStore(a.searchTabId,b);return b},createResponseRecord:function(a,b,c){return container.getContextByName("mail").getModel().createResponseRecord(a,b,c)},onFolderSelect:function(a){var b;b=Ext.isArray(a)?a[0]:a;if(b instanceof Zarafa.core.data.IPFRecord&&Ext.isDefined(b.getMAPIStore()))if(Ext.isDefined(b)&&
!b.isIPMSubTree()){var c=this.getDefaultFolder();b.equals(c)||this.setFolders(a)}}});Ext.namespace("Zarafa.advancesearch.ui");
Zarafa.advancesearch.ui.SearchGrid=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{searchContext:undefined,model:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.model)&&Ext.isDefined(a.searchContext))a.model=a.searchContext.getModel();if(!Ext.isDefined(a.store)&&Ext.isDefined(a.model))if(Ext.isDefined(a.model.store.getSearchStoreUniqueId()))a.store=a.model.createNewSearchStore({searchTabId:a.searchTabId});else{var b=a.model;b.store.searchStoreUniqueId=a.searchTabId;a.store=b.store;
b.pushStore(a.searchTabId,b.store)}a.store=Ext.StoreMgr.lookup(a.store);Ext.applyIf(a,{xtype:"zarafa.searchgrid",cls:"zarafa-searchgrid",border:false,stateful:false,statefulRelativeDimensions:false,loadMask:this.initLoadMask(),sm:this.initSelectionModel(),cm:new Zarafa.advancesearch.ui.SearchGridColumnModel({grid:this,folder:a.model.getDefaultFolder()}),enableDragDrop:true,ddGroup:"dd.mapiitem",viewConfig:this.initViewConfig(),enableColumnHide:false,enableColumnMove:false,enableColumnResize:false,
enableHdMenu:false,autoExpandMin:200,sortableRecordsMax:500});Zarafa.advancesearch.ui.SearchGrid.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.advancesearch.ui.SearchGrid.superclass.initEvents.call(this);this.on({cellclick:this.onCellClick,rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this});this.mon(this.getView(),"livescrollstart",this.onLiveScrollStart,this);this.mon(this.getView(),"beforesort",this.onBeforeSort,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.model,"searchstop",this.onSearchStop,this);this.mon(this.searchContext,"viewchange",this.onContextViewChange,this)},initLoadMask:function(){return{msg:_("Loading Search results")+"..."}},initSelectionModel:function(){return new Zarafa.advancesearch.ui.AdvanceSearchRowSelectionModel({singleSelect:false})},
initViewConfig:function(){return{getRowClass:this.viewConfigGetRowClass,rowSelectorDepth:15}},viewConfigGetRowClass:function(a){return"x-grid3-row-collapsed "+(Ext.isFunction(a.isRead)&&!a.isRead()?"mail_unread":"mail_read")},onContextViewChange:function(a,b,c){c===Zarafa.common.data.Views.LIVESCROLL&&this.getView().resetScroll()},onCellClick:function(a,b,c,d){a=this.store.getAt(b);if(!(!Ext.isDefined(a)||a.get("message_class")!="IPM.Note")){b=d.xy[0];c=d.target;if(!c.classList.contains("icon")){c=
c.querySelector("td.icon");if(c===null)return}d=c.getBoundingClientRect().left;c=c.getBoundingClientRect().width;b>=d&&b<=d+c&&Zarafa.common.Actions.markAsRead(a,!a.isRead())}},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.core.data.UIFactory.openDefaultContextMenu(b,{position:c.getXY(),context:this.searchContext})},onRowDblClick:function(){Zarafa.common.Actions.openMessageContent(this.getSelectionModel().getSelected())},
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)}},onLiveScrollStart:function(a){this.model.startLiveScroll(a)},
onBeforeSort:function(a){if(a.activeHdIndex===1){var b=this.getStore();a=b.getTotalCount();if(a>=this.sortableRecordsMax){Zarafa.common.dialogs.MessageBox.alert(_("Sorting not possible"),String.format(_("The search results could not be sorted because the number of items is higher than {0}. Narrow down your results by specifying your input."),this.sortableRecordsMax));return false}this.model.stopLiveScroll();b.remoteSort=false;this.dialog.findByType("zarafa.paging")[0].pageSize=this.sortableRecordsMax;
if(b.getCount()<a){b.isExecuting("list")&&b.proxy.cancelRequests("list");a={actionType:Zarafa.core.Actions.list,folder:this.model.getFolders()[0],params:{restriction:{start:0,limit:a}},callback:function(){b.sort(b.sortInfo.field,b.sortInfo.direction)}};b.load(a)}}},onSearchStop:function(){this.loadMask.hide()}});Ext.reg("zarafa.searchgrid",Zarafa.advancesearch.ui.SearchGrid);Ext.namespace("Zarafa.advancesearch.ui");
Zarafa.advancesearch.ui.SearchPanelToolbar=Ext.extend(Zarafa.mail.ui.MailPanelToolbar,{constructor:function(a){a=a||{};Zarafa.advancesearch.ui.SearchPanelToolbar.superclass.constructor.call(this,a);this.on("afterlayout",this.onAfterLayout,this)},onAfterLayout:function(){this.resizeSearchField()},initComponent:function(){Zarafa.advancesearch.ui.SearchPanelToolbar.superclass.initComponent.call(this);this.pagesToolbar.bindStore(this.model.getStore());container.getSettingsModel().get("zarafa/v1/contexts/mail/enable_live_scroll")&&
this.model&&this.mon(this.model.getStore(),"load",this.onLoad,this)}});Ext.reg("zarafa.searchpaneltoolbar",Zarafa.advancesearch.ui.SearchPanelToolbar);Ext.namespace("Zarafa.calendar");
Zarafa.calendar.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.A,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewAppointment,scope:this,settingsCfg:{description:_("New appointment"),category:_("Creating an item")}},{key:Ext.EventObject.V,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewMeetingRequest,scope:this,settingsCfg:{description:_("New meeting request"),category:_("Creating an item")}},{key:[Ext.EventObject.LEFT,Ext.EventObject.RIGHT],
ctrl:false,alt:true,shift:false,stopEvent:true,handler:this.onSwitchRange,scope:this,settingsCfg:{description:_("Switch calendar range back and forth"),category:_("Calendar")}}];Zarafa.core.KeyMapMgr.register("global",a)},onNewAppointment:function(){Zarafa.calendar.Actions.openCreateAppointmentContent(container.getContextByName("calendar").getModel())},onNewMeetingRequest:function(){Zarafa.calendar.Actions.openCreateMeetingRequestContent(container.getContextByName("calendar").getModel())},onSwitchRange:function(a){a===
Ext.EventObject.LEFT?container.getContextByName("calendar").getModel().previousDate():container.getContextByName("calendar").getModel().nextDate()}});Zarafa.calendar.KeyMapping=new Zarafa.calendar.KeyMapping;Ext.namespace("Zarafa.calendar.attachitem");
Zarafa.calendar.attachitem.AttachCalendarRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{constructor:function(a){Zarafa.calendar.attachitem.AttachCalendarRenderer.superclass.constructor.call(this,a);Ext.apply(this.labels,{from:_("Organizer"),location:_("Where"),display_to:_("Required Attendee"),display_cc:_("Optional Attendee"),display_bcc:_("Resource"),busystatus:_("Show Time As"),startdate:_("Start Date"),duedate:_("End Date"),recurring_pattern:_("Recurrence pattern"),
alldayevent:_("All Day Event")})},generateHTMLTemplate:function(){var a="";a+=this.addHTMLRowGroup({subject:"{subject:htmlEncode}",location:"{location:htmlEncode}"});a+=this.addHTMLRowGroup({startdate:'{startdate:date("'+_("l jS F Y G:i")+'")}',duedate:'{duedate:date("'+_("l jS F Y G:i")+'")}',busystatus:"{busystatus:busyStatusString}",alldayevent:"{alldayevent}"});a+=this.addHTMLRowGroup({from:"{from:htmlEncode}"});a+=this.addHTMLRowGroup({meeting:{display_to:"{display_to:htmlEncode}",display_cc:"{display_cc:htmlEncode}",
display_bcc:"{display_bcc:htmlEncode}"}});a+=this.addHTMLRowGroup({recurring:{recurring_pattern:"{recurring_pattern:htmlEncode}"}});a+=this.addHTMLRowGroup({categories:"{categories:htmlEncode}",sensitivity:"{sensitivity:sensitivityString}",importance:"{importance:importanceString}"});a+=this.addHTMLRow("attachment_names","{attachment_names:htmlEncode}");a+="{body}";return a},generatePlainTemplate:function(){var a="";a+=this.addPlainRowGroup({subject:"{subject}",location:"{location}"});a+=this.addPlainRowGroup({startdate:'{startdate:date("'+
_("l jS F Y G:i")+'")}',duedate:'{duedate:date("'+_("l jS F Y G:i")+'")}',busystatus:"{busystatus:busyStatusString}",alldayevent:"{alldayevent}"});a+=this.addPlainRowGroup({from:"{from}"});a+=this.addPlainRowGroup({meeting:{display_to:"{display_to}",display_cc:"{display_cc}",display_bcc:"{display_bcc}"}});a+=this.addPlainRowGroup({recurring:{recurring_pattern:"{recurring_pattern}"}});a+=this.addPlainRowGroup({categories:"{categories}",sensitivity:"{sensitivity:sensitivityString}",importance:"{importance:importanceString}"});
a+=this.addPlainRow("attachment_names","{attachment_names}");a+="{body}";return a},prepareData:function(a){var b=Zarafa.calendar.attachitem.AttachCalendarRenderer.superclass.prepareData.apply(this,arguments);a.isMeeting()||delete b.meeting;a.get("recurring")||delete b.recurring;a.get("alldayevent")||delete b.alldayevent;a.get("busystatus")===Zarafa.core.mapi.BusyStatus.BUSY&&delete b.busystatus;if(a.isMessageClass("IPM.Schedule.Meeting",true)){var c=a.get("appointment_startdate");if(Ext.isDate(c))b.startdate=
c;c=a.get("appointment_duedate");if(Ext.isDate(c))b.duedate=c;c=a.get("appointment_recurring");if(!c){b.recurring=c;b.recurring_pattern=a.get("appointment_recurring_pattern")}}return b}});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.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.SnapModes=Zarafa.core.Enum.create({NONE:1,DAY:2,ZOOMLEVEL:3});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.Views=Zarafa.core.Enum.create({BLOCKS:0,LIST:1,SEARCH:2});Ext.namespace("Zarafa.calendar.dialogs");
Zarafa.calendar.dialogs.AppointmentToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.calendar.appointmentcontentpanel",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.calendar.dialogs.AppointmentToolbar.superclass.constructor.call(this,a);this.mon(this.saveMeeting,"beforeshow",this.onSaveButtonBeforeShow,
this)},createActionButtons:function(){return[{xtype:"zarafa.meetingrequestbuttons"},{xtype:"button",overflowText:_("Send invitation"),text:_("Send"),tooltip:{title:_("Send invitation"),text:_("Send invitation to recipients")+" (Ctrl + ENTER)"},iconCls:"buttons-icon_send_white",cls:"button_sendMail zarafa-action",ref:"sendInvitation",handler:this.onSendButton,scope:this},{xtype:"button",text:_("Save"),overflowText:_("Save & Close"),tooltip:{title:_("Save & Close"),text:_("Save appointment and close dialog")+
" (Ctrl + S)"},cls:"zarafa-action",iconCls:"buttons-icon_save_white",ref:"saveAppointment",handler:this.onSaveButton,scope:this},{xtype:"button",overflowText:_("Save"),tooltip:{title:_("Save"),text:_("Save without sending an invitation to recipients")+" (Ctrl + S)"},cls:"tb-calendar-btn-save",iconCls:"icon_saveEmail",ref:"saveMeeting",handler:this.onSaveButton,scope:this},{xtype:"button",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this appointment")},cls:"tb-calendar-btn-delete",
iconCls:"icon_delete",ref:"deleteAppointment",handler:this.onDeleteButton,scope:this},{xtype:"zarafa.attachmentbutton",plugins:["zarafa.recordcomponentupdaterplugin"],ref:"normalAttachmentsButton",overflowText:_("Add attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this appointment")},cls:"tb-calendar-btn-add-attachment",iconCls:"icon_attachment",listeners:{added:this.onAttachmentButtonAdded,scope:this}},{xtype:"button",ref:"occurenceAttachmentsButton",overflowText:_("Cannot add attachment"),
tooltip:{title:_("Cannot add attachment"),text:_("Attachments cannot be modified for a single occurence")},cls:"tb-calendar-btn-occurence-attachment",iconCls:"icon_attachment",handler:function(){Ext.MessageBox.show({title:_("Warning"),msg:_("Attachments cannot be modified for a single occurence"),buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING})}},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this appointment")},cls:"tb-calendar-btn-print",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")},cls:"tb-calendar-btn-checknames",iconCls:"icon_checkNames",ref:"checkNames",handler:this.onCheckNamesButton,scope:this}]},onAttachmentButtonAdded:function(a){if(a.isXType("menuitem"))a.update=Zarafa.common.attachment.ui.AttachmentButton.prototype.update.createDelegate(this.normalAttachmentsButton)},createOptionButtons:function(){return[{xtype:"button",text:_("Recurrence"),
overflowText:_("Recurrence"),tooltip:{title:_("Recurrence"),text:_("Open the recurrence dialog")},cls:"tb-calendar-btn-recurrence",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")},cls:"tb-calendar-btn-ivite-attendees",iconCls:"icon_invite_attendees",ref:"inviteAttendees",handler:this.onSetMeetingRequest,
scope:this},{xtype:"button",text:_("Cancel invitation"),tooltip:{title:_("Cancel invitation"),text:_("Convert this meeting request to an appointment by removing attendees")},overflowText:_("Cancel invitation"),cls:"tb-calendar-btn-cancel",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")},cls:"tb-calendar-btn-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")},cls:"tb-calendar-btn-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")},cls:"tb-calendar-btn-categories",iconCls:"icon_categories",handler:this.onCategories,scope:this},{xtype:"button",overflowText:_("Private"),tooltip:{title:_("Private"),text:_("Mark this appointment as private")},cls:"tb-calendar-btn-private",iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSetRecurrence:function(){Zarafa.common.Actions.openRecurrenceContent(this.record,
{autoSave:false})},onSetMeetingRequest:function(){this.record.convertToMeeting()},onCancelMeetingRequest:function(){if(this.record.isMeetingSent())this.record.isAppointmentInPast()?this.dialog.deleteRecord():Zarafa.calendar.Actions.openSendCancellationContent(this.record);else this.record.convertToAppointment()},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.openCategoriesContent(this.record,
{autoSave:false})},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()},onCheckNamesButton:function(){this.record.getRecipientStore().resolve(undefined,{cancelPreviousRequest:true})},onSendButton:function(){this.dialog.sendRecord()},onSaveButton:function(){this.dialog.saveRecord()},onDeleteButton:function(){this.dialog.deleteRecord()},
onSaveButtonBeforeShow:function(a){if(this.record.isMeetingReceived()){var b={title:_("Save & Close"),text:_("Save meeting request and close dialog")+" (Ctrl + S)"};a.setTooltip(b)}},update:function(a,b){var c=false;this.record=a;if(a.isSubMessage()){this.sendInvitation.setVisible(false);this.saveAppointment.setVisible(false);this.saveMeeting.setVisible(false);this.checkNames.setVisible(false);this.deleteAppointment.setVisible(false);this.inviteAttendees.setVisible(false);this.cancelInvitation.setVisible(false);
this.setPrivate.setVisible(false);this.highPriority.setVisible(false);this.lowPriority.setVisible(false);c=true}else{this.setPrivate.setVisible(true);this.highPriority.setVisible(true);this.lowPriority.setVisible(true);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")){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);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);
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(true);this.deleteAppointment.setVisible(true);this.checkNames.setVisible(false);this.inviteAttendees.setVisible(false);this.cancelInvitation.setVisible(false);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)}if(b===true){if(a.isRecurringOccurence()){this.occurenceAttachmentsButton.setVisible(true);this.normalAttachmentsButton.setVisible(false)}else{this.occurenceAttachmentsButton.setVisible(false);this.normalAttachmentsButton.setVisible(true)}c=true}c===true&&this.doLayout()}});
Ext.reg("zarafa.appointmenttoolbar",Zarafa.calendar.dialogs.AppointmentToolbar);Ext.namespace("Zarafa.calendar.printer");
Zarafa.calendar.printer.DaysViewRenderer=Ext.extend(Zarafa.common.printer.renderers.BaseRenderer,{customStylesheetPath:"client/resources/css/external/print.calendar.css",timeStyle:"",prepareData:function(a){var b=Zarafa.calendar.printer.DaysViewRenderer.superclass.prepareData.apply(this,arguments),c=a.getModel(),d=c.dateRange,e=d.getDuration(Date.DAY),f=d.getStartDate().clone();d=d.getDueDate().clone();f.setHours(12);d.setHours(12);b.currenttime=new Date;b.startdate=f.clearTime();b.duedate=d.add(Date.DAY,
-1).clearTime();for(var g=0,i=e;g<i;g++){var h="date"+(g+1);b[h]=f.add(Date.DAY,g).clearTime();b[h+"_table_data"]=""}c=c.getStore().getRange();h=f.getDay();g=0;for(i=c.length;g<i;g++){var k=c[g].get("commonstart"),j=c[g].get("commonend");if(Ext.isDate(k)&&Ext.isDate(j)){var l=k;if(k<f)l=f.clone();var m=j;if(j>d)m=d.clone();var n=c[g].get("subject");Ext.isString(n)||(n="");var o,p=k.getDayOfYear()!==j.getDayOfYear()||k.getYear()!==j.getYear();o=p?_("jS F Y G:i"):_("G:i");var q=Math.floor(Date.diff(Date.DAY,
m,l)),r=c[g].get("alldayevent");r&&m===j&&q--;m='<tr class="calendar-'+(r?"allday":"normal")+'">';r||(m+='<td class="nowrap" style="'+this.timeStyle+'">'+k.format(o)+" - "+(p?"<br>":"")+j.format(o)+"</td>");m+='<td class="calendar-item" colspan='+(r?"2":"1")+">"+Ext.util.Format.htmlEncode(n)+"</td></tr>";k=l.getDay();if(k<h)k+=7;k-=h-1;for(j=0;j<=q&&j<e;j++)b["date"+(k+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);if(Ext.isIE11){a=new Ext.DatePicker({renderTo:Ext.getBody(),hidden:true,width:"200px",value:a,showToday:false});c=new Ext.DatePicker({renderTo:Ext.getBody(),hidden:true,width:"200px",value:c,showToday:false});b.getElementById("datepicker_left").innerHTML=a.el.dom.innerHTML;b.getElementById("datepicker_right").innerHTML=c.el.dom.innerHTML;a.destroy();c.destroy()}else{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.ui");
Zarafa.calendar.ui.AbstractCalendarBoxView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarView,{dayBoxConfigurations:undefined,firstDayOfWeek:1,dayHeaderHeight:24,headerHeight:30,appointmentHeight:30,expandThreshold:10,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});
a.enableDD===true&&Ext.apply(a,{enableDD:false,enableBodyDD:true});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},screenLocationToDateRange:function(a,b){var c=this.screenLocationToDate(a,b);if(Ext.isDate(c)){c.setHours(12);var d=c.add(Date.DAY,1);return new Zarafa.core.DateRange({startDate:c.clearTime(),dueDate:d.clearTime()})}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=e.getStartDate();e=a.getStartDate();var i=a.getDueDate();g=g.clone();g.setHours(12);e=e.clone();
e.setHours(12);i=i.clone();i.setHours(12);var h=[],k=d?this.appointmentBodyLeftMargin:0;d=d?this.appointmentBodyRightMargin:0;for(var j=0;j<c;j++){var l=g.add(Date.DAY,this.numDaysInWeek);l.setHours(12);var m=Math.floor(Date.diff(Date.DAY,e,g));g=Math.floor(Date.diff(Date.DAY,i,g));var n=a.getDueDate();if(n.getTime()==n.clearTime(true).getTime())a.isZeroMinuteRange()||g--;m=Math.max(m,0);g=Math.min(g,6);if(m<7&&g>=0){m=this.dayBoxConfigurations[j*7+m];g=this.dayBoxConfigurations[j*7+g];n=m.top+this.dayHeaderHeight+
this.appointmentHeight*b-3*b;var o=f?m.bottom:n+this.appointmentHeight;if(f||o<m.bottom-this.expandThreshold)h.push({left:m.left+k+1,right:g.right-d-1,top:n,bottom:o,firstBox:true,lastBox:true})}g=l;if(g>i)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().clone();b.setHours(12);for(var e=(new Date).clearTime().getTime(),f=0;f<c;f++)for(var g=0;g<this.numDaysInWeek;g++){var i=0,h=b.add(Date.DAY,f*this.numDaysInWeek+g),k=h.add(Date.DAY,1);h.clearTime();k.clearTime();k=new Zarafa.core.DateRange({startDate:h,dueDate:k});var j=this.parentView.workingDays.indexOf(h.getDay())>=0,l=this.findAppointmentsByRange(k);Ext.each(l,function(n){n=n.getRecord().get("busystatus");i=Math.max(i,n)});l=Math.floor((Math.round((f+
1)*a)+1-Math.round(f*a)-this.headerHeight-this.expandThreshold)/this.appointmentHeight);var m=this.contextModel.getActiveDateRange();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:h,today:e==h.getTime(),workingDay:j,busyStatus:i,overflow:this.maxSlotInRange(k)>=l,active:h.getTime()>=m.getStartDate().getTime()&&h.getTime()<m.getDueDate().getTime()}))}return this.dayBoxConfigurations}});
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;b=b.clone();b.setHours(12);this.dayLayoutPositions=[];for(var e=0;e<c;e++){var f=b.add(Date.DAY,
e).clearTime(),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}c=this.getDateRange().getStartDate().clone();c.setHours(12);c=c.add(Date.DAY,e).clearTime();d=b/d*Date.dayInMillis;if(d>0)d-=(c.getHours()*60*60+c.getMinutes()*60)*1E3;return c.add(Date.MILLI,d)},screenLocationToDate:function(a,b){return Zarafa.core.Util.inside(this.header.parent().getBox(),a,b)?this.locationToDate(a-this.header.getX(),0):this.locationToDate(a-this.body.getX(),
b-this.body.getY())},screenLocationToDateRange:function(a,b){var c;if(Zarafa.core.Util.inside(this.header.parent().getBox(),a,b)){c=this.locationToDate(a-this.header.getX(),0).clearTime();var d=c.clone();d.setHours(12);d=d.add(Date.DAY,1).clearTime();return new Zarafa.core.DateRange({startDate:c,dueDate:d})}else{c=this.locationToDate(a-this.body.getX(),b-this.body.getY());d=this.getZoomLevel()*60*1E3;c=c.getTime()-c.getTime()%d;return new Zarafa.core.DateRange({startDate:new Date(c),dueDate:new Date(c+
d)})}},getDayColumn:function(a){var b=this.getDateRange().getStartDate();b=b.clearTime(true);a=a.clearTime(true);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(),i=d?this.appointmentBodyLeftMargin:0;d=d?this.appointmentBodyRightMargin:0;var h=a.getStartDate(),k=a.getDueDate();b=b||0;c=c||1;if(k.getTime()<=h.getTime())return[];var j=this.getDayColumn(h);a=this.getDayColumn(k);if(a<0||j>=f)return[];h=Math.floor(this.getDateVerticalPosition(h)*g);k=Math.floor(this.getDateVerticalPosition(k)*g);h--;if(j==a){var l=(this.dayLayoutPositions[j].right-this.dayLayoutPositions[j].left-
1-d-i)/c,m=this.dayLayoutPositions[j].left+l*b+i+1;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(m),right:Math.round(m+l),top:h,bottom:k,firstBox:true,lastBox:true}))}else{if(j>=0){l=(this.dayLayoutPositions[j].right-this.dayLayoutPositions[j].left-1-d-i)/c;m=this.dayLayoutPositions[j].left+l*b+i;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(m),right:Math.round(m+l),top:h,bottom:g,firstBox:true}))}for(j=Math.max(j+1,0);j<=Math.min(a-1,f-1);j++){l=(this.dayLayoutPositions[j].right-
this.dayLayoutPositions[j].left-1-d-i)/c;m=this.dayLayoutPositions[j].left+l*b+i;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(m),right:Math.round(m+l),top:-1,bottom:g}))}if(a<f&&k>0){l=(this.dayLayoutPositions[a].right-this.dayLayoutPositions[a].left-1-d-i)/c;m=this.dayLayoutPositions[a].left+l*b+i;e.push(new Zarafa.calendar.data.AppointmentBounds({left:Math.round(m),right:Math.round(m+l),top:-1,bottom:k,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,i=a.getStartDate();a=a.getDueDate();i=this.getDayColumn(i);var h=this.getDayColumn(a);b=b||0;c=c||this.rowCount;a.clearTime(true).getTime()===a.getTime()&&h--;if(h<0||i>=e)return[];return i<0&&h>=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}):i<0?new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[0].left,right:this.dayLayoutPositions[h].right-d,top:g+b*this.parentView.headerItemHeight,bottom:g+(b+c)*this.parentView.headerItemHeight,lastBox:true}):h>=e?new Zarafa.calendar.data.AppointmentBounds({left:this.dayLayoutPositions[i].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[i].left+f,right:this.dayLayoutPositions[h].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(),i=f.getAdjustedDateRange().getDueTime();if(b.length===0){d=i;b.push(f)}else if(g<d){d=Math.max(i,d);b.push(f)}else{c.push(b);
b=[f];d=i}}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,this.doGreedyColoring,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.AppointmentView=Ext.extend(Zarafa.calendar.ui.AbstractDateRangeView,{timeFormat:_("G:i"),stripVisible:true,stripWidth:6,record:undefined,selected:false,active:false,adjustedDateRange:undefined,calendarColorScheme:undefined,focusEl:undefined,init:function(){Zarafa.calendar.ui.AppointmentView.superclass.init.call(this);this.record&&this.updateDateRange(this.record)},render:function(){Zarafa.calendar.ui.AppointmentView.superclass.render.apply(this,arguments);this.create({tag:"a",href:"#",
tabindex:-1,style:"position: absolute; left:-10000px; top:-10000px;"},this.container,"focusEl")},focus:function(){this.focusEl&&this.focusEl.focus()},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(),b=[];a.get("private")===true&&b.push("private");if(a.isRecurringOccurence()===true)a.isRecurringException()===true?b.push("exception"):
b.push("recurring");return b},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()},
getLabel:function(){return this.record.get("label")},isAllDay:function(){return this.getDateRange().isAllDay()},getStripWidth:function(){return this.stripVisible?this.stripWidth:0},getAppointmentColorScheme:function(){return this.isActive()?this.getLabel()!=Zarafa.core.mapi.AppointmentLabels.NONE?Zarafa.calendar.ui.LabelColorSchemes[this.getLabel()]:this.calendarColorScheme:this.calendarColorScheme}});Ext.namespace("Zarafa.calendar.ui");
Zarafa.calendar.ui.CalendarGridView=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{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"});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.on("rowcontextmenu",this.onRowContextMenu,this);this.on("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.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY()})},onRowDblClick:function(a){Zarafa.calendar.Actions.openAppointmentContent(a.getSelectionModel().getSelections())},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},getRowClass:function(){return"zarafa-calendar-grid-row"}});Ext.reg("zarafa.calendargrid",Zarafa.calendar.ui.CalendarGridView);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(a,b){Zarafa.contact.ContactContextModel.superclass.enable.call(this,
a,true);this.setRestrictionCharacter(this.getRestrictionCharacter(),true);b!==true&&this.resumeLoading()},createRecord:function(a,b){a=a||this.getDefaultFolder();return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass(b?"IPM.Distlist":"IPM.Contact",{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},saveCharacterChangeState:function(a,b,c){b!=c&&this.saveState()},initStateEvents:function(){Zarafa.contact.ContactContextModel.superclass.initStateEvents.call(this);
this.on("characterchange",this.saveCharacterChangeState,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.contact");
Zarafa.contact.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.C,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewContact,scope:this,settingsCfg:{description:_("New contact"),category:_("Creating an item")}},{key:Ext.EventObject.D,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewDistributionList,scope:this,settingsCfg:{description:_("New distribution list"),category:_("Creating an item")}}];Zarafa.core.KeyMapMgr.register("global",a)},
onNewContact:function(){Zarafa.contact.Actions.openCreateContactContent(container.getContextByName("contact").getModel())},onNewDistributionList:function(){Zarafa.contact.Actions.openCreateDistlistContent(container.getContextByName("contact").getModel())}});Zarafa.contact.KeyMapping=new Zarafa.contact.KeyMapping;Ext.namespace("Zarafa.contact.attachitem");
Zarafa.contact.attachitem.AttachContactRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{constructor:function(a){Zarafa.contact.attachitem.AttachContactRenderer.superclass.constructor.call(this,a);Ext.apply(this.labels,{display_name:_("Full Name"),last_name:_("Last Name"),first_name:_("First Name"),job_title:_("Job Title"),department_name:_("Department Name"),company_name:_("Company Name"),im:_("IM Address"),home_address:_("Home Address"),business_address:_("Business Address"),
other_address:_("Other Address"),office_telephone_number:_("Business Phone"),business2_telephone_number:_("Business 2 Phone"),assistant_telephone_number:_("Assistant Phone"),company_telephone_number:_("Company Main Phone"),home_telephone_number:_("Home Phone"),home2_telephone_number:_("Home 2 Phone"),cellular_telephone_number:_("Mobile"),car_telephone_number:_("Car Phone"),radio_telephone_number:_("Radio"),pager_telephone_number:_("Pager"),callback_telephone_number:_("Callback Phone"),other_telephone_number:_("Other Phone"),
primary_telephone_number:_("Primary Phone"),telex_telephone_number:_("Telex"),ttytdd_telephone_number:_("TTY/TDD Phone"),isdn_number:_("ISDN"),other_fax_number:_("Other Fax"),business_fax_number:_("Business Fax"),home_fax_number:_("Home Fax"),email_address_1:_("Email"),email_address_display_name_1:_("Email Display As"),email_address_2:_("Email 2"),email_address_display_name_2:_("Email2 Display As"),email_address_3:_("Email 3"),email_address_display_name_3:_("Email3 Display As"),birthday:_("Birthday"),
wedding_anniversary:_("Wedding Anniversary"),spouse_name:_("Spouse/Partner"),profession:_("Profession"),assistant:_("Assistant's Name"),webpage:_("Webpage")})},generateHTMLTemplate:function(){var a="";a+=this.addHTMLRowGroup({display_name:"{display_name:htmlEncode}",last_name:"{last_name:htmlEncode}",first_name:"{first_name:htmlEncode}",job_title:"{job_title:htmlEncode}",department_name:"{department_name:htmlEncode}",company_name:"{company_name:htmlEncode}"});a+=this.addHTMLRowGroup({business_address:"{business_address:htmlEncode}",
home_address:"{home_address:htmlEncode}",other_address:"{other_address:htmlEncode}",im:"{im:htmlEncode}"});a+=this.addHTMLRowGroup({office_telephone_number:"{office_telephone_number:htmlEncode}",business2_telephone_number:"{business2_telephone_number:htmlEncode}",assistant_telephone_number:"{assistant_telephone_number:htmlEncode}",company_telephone_number:"{company_telephone_number:htmlEncode}",home_telephone_number:"{home_telephone_number:htmlEncode}",home2_telephone_number:"{home2_telephone_number:htmlEncode}",
cellular_telephone_number:"{cellular_telephone_number:htmlEncode}",car_telephone_number:"{car_telephone_number:htmlEncode}",radio_telephone_number:"{radio_telephone_number:htmlEncode}",pager_telephone_number:"{pager_telephone_number:htmlEncode}",callback_telephone_number:"{callback_telephone_number:htmlEncode}",other_telephone_number:"{other_telephone_number:htmlEncode}",primary_telephone_number:"{primary_telephone_number:htmlEncode}",telex_telephone_number:"{telex_telephone_number:htmlEncode}",ttytdd_telephone_number:"{ttytdd_telephone_number:htmlEncode}",
isdn_number:"{isdn_number:htmlEncode}",other_fax_number:"{other_fax_number:htmlEncode}",business_fax_number:"{business_fax_number:htmlEncode}",home_fax_number:"{business_fax_number:htmlEncode}"});a+=this.addHTMLRowGroup({email_address_1:"{email_address_1:htmlEncode}",email_address_display_name_1:"{email_address_display_name_1:htmlEncode}",email_address_2:"{email_address_2:htmlEncode}",email_address_display_name_2:"{email_address_display_name_2:htmlEncode}",email_address_3:"{email_address_3:htmlEncode}",
email_address_display_name_3:"{email_address_display_name_3:htmlEncode}"});a+=this.addHTMLRowGroup({birthday:'{birthday:date("'+_("l jS F Y G:i")+'")}',wedding_anniversary:'{wedding_anniversary:date("'+_("l jS F Y G:i")+'")}',spouse_name:"{spouse_name:htmlEncode}",profession:"{profession:htmlEncode}",assistant:"{assistant:htmlEncode}",webpage:"{webpage:htmlEncode}"});a+=this.addHTMLRowGroup({sensitivity:"{sensitivity:sensitivityString}",categories:"{categories:htmlEncode}",attachment_names:"{attachment_names:htmlEncode}"});
a+="{body}";return a},generatePlainTemplate:function(){var a="";a+=this.addPlainRowGroup({display_name:"{display_name}",last_name:"{last_name}",first_name:"{first_name}",job_title:"{job_title}",department_name:"{department_name}",company_name:"{company_name}"});a+=this.addPlainRowGroup({business_address:"{business_address}",home_address:"{home_address}",other_address:"{other_address}",im:"{im}"});a+=this.addPlainRowGroup({office_telephone_number:"{office_telephone_number}",business2_telephone_number:"{business2_telephone_number}",
assistant_telephone_number:"{assistant_telephone_number}",company_telephone_number:"{company_telephone_number}",home_telephone_number:"{home_telephone_number}",home2_telephone_number:"{home2_telephone_number}",cellular_telephone_number:"{cellular_telephone_number}",car_telephone_number:"{car_telephone_number}",radio_telephone_number:"{radio_telephone_number}",pager_telephone_number:"{pager_telephone_number}",callback_telephone_number:"{callback_telephone_number}",other_telephone_number:"{other_telephone_number}",
primary_telephone_number:"{primary_telephone_number}",telex_telephone_number:"{telex_telephone_number}",ttytdd_telephone_number:"{ttytdd_telephone_number}",isdn_number:"{isdn_number}",other_fax_number:"{other_fax_number}",business_fax_number:"{business_fax_number}",home_fax_number:"{business_fax_number}"});a+=this.addPlainRowGroup({email_address_1:"{email_address_1}",email_address_display_name_1:"{email_address_display_name_1}",email_address_2:"{email_address_2}",email_address_display_name_2:"{email_address_display_name_2}",
email_address_3:"{email_address_3}",email_address_display_name_3:"{email_address_display_name_3}"});a+=this.addPlainRowGroup({birthday:'{birthday:date("'+_("l jS F Y G:i")+'")}',wedding_anniversary:'{wedding_anniversary:date("'+_("l jS F Y G:i")+'")}',spouse_name:"{spouse_name}",profession:"{profession}",assistant:"{assistant}",webpage:"{webpage}"});a+=this.addPlainRowGroup({sensitivity:"{sensitivity:sensitivityString}",categories:"{categories}",attachment_names:"{attachment_names}"});a+="{body}";
return a}});Ext.namespace("Zarafa.contact.attachitem");
Zarafa.contact.attachitem.AttachDistlistRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{constructor:function(a){Zarafa.contact.attachitem.AttachDistlistRenderer.superclass.constructor.call(this,a);Ext.apply(this.labels,{display_name:_("Distribution List Name"),members:_("Members")})},generateHTMLTemplate:function(){var a="";a+=this.addHTMLRowGroup({display_name:"{display_name:htmlEncode}"});a+=this.addHTMLRowGroup({sensitivity:"{sensitivity:sensitivityString}",categories:"{categories:htmlEncode}",
attachment_names:"{attachment_names:htmlEncode}"});a+=this.addHTMLRowGroup({members:"{members:htmlEncode}"});a+="{body}";return a},generatePlainTemplate:function(){var a="";a+=this.addPlainRowGroup({display_name:"{display_name}"});a+=this.addPlainRowGroup({sensitivity:"{sensitivity:sensitivityString}",categories:"{categories}",attachment_names:"{attachment_names}"});a+=this.addPlainRowGroup({members:"{members}"});a+="{body}";return a},prepareData:function(a){var b=Zarafa.contact.attachitem.AttachDistlistRenderer.superclass.prepareData.apply(this,
arguments);b.members=a.getMemberNames();return b}});Ext.namespace("Zarafa.contact.data");Zarafa.contact.data.DataModes=Zarafa.core.Enum.create({ALL:0,CHARACTER_RESTRICT: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.Views=Zarafa.core.Enum.create({ICON:0,LIST:1,SEARCH:2});
Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactAddressContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{parser:null,property:null,parsedData:null,constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",border:false,xtype:"zarafa.contactaddresscontentpanel",title:_("Check address"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),autoSave:false,width:400,height:300,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.ContactAddressContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.contactaddresscontentpanel",Zarafa.contact.dialogs.ContactAddressContentPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{contactParser:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactcontentpanel",layout:"fit",title:_("Contact"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),closeOnSave:true,confirmClose:true,items:this.createPanel()});Zarafa.contact.dialogs.ContactContentPanel.superclass.constructor.call(this,a);this.initContactDetailsParser()},createPanel:function(){return[{xtype:"zarafa.contactpanel",
tbar:{xtype:"zarafa.contacttoolbar"}}]},initContactDetailsParser:function(){var a=container.getSharedComponent(Zarafa.core.data.SharedComponentType["contact.detailsparser"]);if(a)this.contactParser=new a},update:function(a,b){b&&this.updateIconFromRecord(a);this.updateTitleFromRecord(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},updateTitleFromRecord:function(a){a=a.get("display_name");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)}});
Ext.reg("zarafa.contactcontentpanel",Zarafa.contact.dialogs.ContactContentPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactNameContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{parser:null,parsedData:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactnamecontentpanel",layout:"fit",border:false,title:_("Check full name"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{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.ContactNameContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.contactnamecontentpanel",Zarafa.contact.dialogs.ContactNameContentPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactPanel=Ext.extend(Ext.Panel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactpanel",cls:"zarafa-contactcreatepanel",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,defaults:{layout:"column",autoHeight:false},items:[{xtype:"zarafa.contactgeneraltab"},{xtype:"zarafa.contactdetailtab"},container.populateInsertionPoint("context.contact.contactcontentpanel.tabs",
this)]}]}});Ext.reg("zarafa.contactpanel",Zarafa.contact.dialogs.ContactPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactPhoneContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{parser:null,property:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.contactphonecontentpanel",layout:"fit",border:false,title:_("Check phone number"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{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.ContactPhoneContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.contactphonecontentpanel",Zarafa.contact.dialogs.ContactPhoneContentPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.ContactToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.contact.contactcontentpanel",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.contact.dialogs.ContactToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",ref:"saveCloseBtn",
text:_("Save"),overflowText:_("Save & Close"),tooltip:{title:_("Save & Close"),text:_("Save contact and close dialog")+" (Ctrl + S)"},cls:"zarafa-action",iconCls:"buttons-icon_save_white",handler:this.onSave,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:"zarafa.attachmentbutton",ref:"addAttachment",plugins:["zarafa.recordcomponentupdaterplugin"],
overflowText:_("Add Attachment"),tooltip:{title:_("Add Attachment"),text:_("Add attachments to this contact.")},iconCls:"icon_attachment",listeners:{added:this.onAttachmentButtonAdded,scope:this}},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this contact")},iconCls:"icon_print",handler:this.onPrint,scope:this}]},onAttachmentButtonAdded:function(a){if(a.isXType("menuitem"))a.update=Zarafa.common.attachment.ui.AttachmentButton.prototype.update.createDelegate(this.addAttachment)},
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()},onDelete:function(){this.dialog.deleteRecord()},
onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.record)},onCategories:function(){Zarafa.common.Actions.openCategoriesContent(this.record,{autoSave:false})},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;if(a.isSubMessage()){this.deleteBtn.setVisible(false);this.setPrivate.setVisible(false);
this.saveCloseBtn.setVisible(false);this.addAttachment.setVisible(false)}else{this.deleteBtn.setVisible(true);this.setPrivate.setVisible(true);this.saveCloseBtn.setVisible(true);this.addAttachment.setVisible(true);this.deleteBtn.setDisabled(a.phantom===true);if(b===true||a.isModifiedSinceLastUpdate("private"))this.setPrivate.toggle(a.get("private"),true)}this.doLayout()}});Ext.reg("zarafa.contacttoolbar",Zarafa.contact.dialogs.ContactToolbar);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{layout:"fit",xtype:"zarafa.distlistcontentpanel",title:_("Distribution List"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),confirmClose:true,closeOnSave:true,items:[this.createPanel()]});Zarafa.contact.dialogs.DistlistContentPanel.superclass.constructor.call(this,a)},createPanel:function(){return{xtype:"zarafa.distlistpanel",
tbar:{xtype:"zarafa.distlistcontentpaneltoolbar"}}},update:function(a,b){b&&this.updateIconFromRecord(a);this.updateTitleFromRecord(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},updateTitleFromRecord:function(a){a=a.get("display_name");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)}});Ext.reg("zarafa.distlistcontentpanel",Zarafa.contact.dialogs.DistlistContentPanel);Ext.namespace("Zarafa.contact.dialogs");
Zarafa.contact.dialogs.DistlistContentPanelToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.contact.distlistcontentpanel",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.contact.dialogs.DistlistContentPanelToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",
text:_("Save"),overflowText:_("Save & Close"),tooltip:{title:_("Save & Close"),text:_("Save distribution list and close dialog")+" (Ctrl + S)"},cls:"zarafa-action",iconCls:"buttons-icon_save_white",handler:this.onSave,scope:this,ref:"saveCloseBtn"},{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()},onDelete:function(){this.dialog.deleteRecord()},onPrint:function(){Zarafa.common.Actions.openPrintDialog(this.record)},onCategories:function(){Zarafa.common.Actions.openCategoriesContent(this.record,{autoSave:false})},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;if(a.isSubMessage()){this.deleteBtn.setVisible(false);this.setPrivate.setVisible(false);this.saveCloseBtn.setVisible(false)}else{this.deleteBtn.setVisible(true);this.setPrivate.setVisible(true);this.saveCloseBtn.setVisible(true);this.deleteBtn.setDisabled(a.phantom===true);if(b===true||a.isModified("private"))this.setPrivate.toggle(a.get("private"),true)}}});Ext.reg("zarafa.distlistcontentpaneltoolbar",Zarafa.contact.dialogs.DistlistContentPanelToolbar);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",cls:"zarafa-distlist-createpanel-memberstab",title:_("Members"),layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},defaults:{header:false,margins:{top:0,right:0,bottom:6,left:0},border:false},items:this.getMembersTabItems()});Zarafa.contact.dialogs.DistlistMembersTab.superclass.constructor.call(this,
a)},getMembersTabItems:function(){return[{layout:"form",items:[{xtype:"textfield",name:"subject",labelStyle:"text-align: left",fieldLabel:_("Name"),anchor:"100%",listeners:{change:this.onPropertyChange,scope:this}}]},{layout:"table",cls:"buttons",layoutConfig:{columns:5},items:[{xtype:"button",autoWidth:true,text:_("Select Members")+"...",handler:this.showAddressBookContent,scope:this},{xtype:"spacer",width:6},{xtype:"button",autoWidth:true,handler:this.addExternalMember,scope:this,text:_("Add New")+
"..."},{xtype:"spacer",width:6},{xtype:"button",autoWidth:true,text:_("Remove"),handler:this.removeMembers,scope:this}]},{xtype:"grid",flex:1,viewConfig:{autoFill:true},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("display_name",a.get("subject"));a.endEdit()},showAddressBookContent:function(){Zarafa.contact.Actions.openMembersSelectionContent(this.record)},addExternalMember:function(){Zarafa.contact.Actions.openDistlistExternalMemberContent(undefined,{parentRecord: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,this.record)}});Ext.reg("zarafa.distlistmemberstab",Zarafa.contact.dialogs.DistlistMembersTab);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:"container",autoScroll:true,region:"center",items:[{xtype:"zarafa.contactcardview",context:a.context}]},{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.ui");
Zarafa.contact.ui.ContactGrid=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{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.contactgrid",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"});Zarafa.contact.ui.ContactGrid.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.ContactGrid.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.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY()})},onRowDblClick:function(a){Zarafa.contact.Actions.openDialog(a.getSelectionModel().getSelections())},
onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())}});Ext.reg("zarafa.contactgrid",Zarafa.contact.ui.ContactGrid);Ext.namespace("Zarafa.contact.ui");
Zarafa.contact.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.contact.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.contact.ui.MemberBox);Ext.namespace("Zarafa.hierarchy");
Zarafa.hierarchy.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.F,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewFolder,scope:this,settingsCfg:{description:_("New folder"),category:_("Creating an item")}},{key:Ext.EventObject.S,ctrl:false,alt:true,shift:false,stopEvent:true,handler:this.onOpenSharedFolder,scope:this,settingsCfg:{description:_("Open shared folder/store"),category:_("Basic navigation")}}];Zarafa.core.KeyMapMgr.register("global",a)},
onNewFolder:function(){Zarafa.hierarchy.Actions.openCreateFolderContent()},onOpenSharedFolder:function(){var a;switch(container.getCurrentContext().getName()){case "calendar":a=Zarafa.hierarchy.data.SharedFolderTypes.APPOINTMENT;break;case "contact":a=Zarafa.hierarchy.data.SharedFolderTypes.CONTACT;break;case "note":a=Zarafa.hierarchy.data.SharedFolderTypes.NOTE;break;case "task":a=Zarafa.hierarchy.data.SharedFolderTypes.TASK;break;case "inbox":default:a=Zarafa.hierarchy.data.SharedFolderTypes.MAIL}Zarafa.hierarchy.Actions.openSharedFolderContent(a)}});
Zarafa.hierarchy.KeyMapping=new Zarafa.hierarchy.KeyMapping;Ext.namespace("Zarafa.hierarchy.data");Zarafa.hierarchy.data.CounterTypes=Zarafa.core.Enum.create({NONE:0,TOTAL:1,UNREAD:2});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})},idComparison:function(a,b){return Zarafa.core.EntryId.compareStoreEntryIds(a,b)},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,
this.remove,this);else a.isSharedStore()&&Zarafa.hierarchy.data.HierarchyStore.superclass.remove.call(this,a)},open:function(a,b,c){a=a.toLowerCase();var d=container.getSettingsModel().get("zarafa/v1/contexts/hierarchy/shared_stores/"+a,true);if(d&&(d[b]||d.all))return false;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(e){this.handleException(e);
return false}},loadRecords:function(a,b,c){if(!this.isDestroyed){if(a&&c===true&&b&&b.actionType==="opensharedfolder")for(var d=a.records,e=0,f=d.length;e<f;e++){var g=d[e],i=this.getById(g.get("store_entryid"));if(i)if(b.params.folder_type==="all"){this.remove(i);this.save(i)}else{g.createSubStores();i=i.getSubStore("folders");var h=g.getSubStore("folders");i.each(function(k){h.getById(h.data.getKey(k))||h.add(k.copy())},this)}}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"){var d=container.getSettingsModel(),e=c.params.user_name.toLowerCase();a=c.params.folder_type||
"all";c=c.params.show_subfolders||false;e="zarafa/v1/contexts/hierarchy/shared_stores/"+e;var f=d.get(e,true);if(f&&(f[a]||f.all))return;d.set(e+"/"+a,{folder_type:a,show_subfolders:c});if(a==="all"){a=container.getCurrentContext().getName();switch(a){case "calendar":case "contacts":case "tasks":case "notes":break;default:a="inbox";break}}d=this.getFolder(b[0].get("default_folder_"+a));Ext.isDefined(d)&&a!=="calendar"&&Zarafa.hierarchy.Actions.openFolder(d)}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],i=g.get("user_name").toLowerCase();c.remove("zarafa/v1/contexts/hierarchy/shared_stores/"+
i);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()){var d=true;a.each(function(e){if(e.isSharedFolder())return d=false},this);if(d){a.rejectChanges();a=a.getParentRecord();this.remove(a);this.save(a);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.compareABEntryIds(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.getById(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},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)if(b[a].lastOptions.actionType===Zarafa.core.Actions.updatelist){delete b[a].lastOptions.add;Ext.apply(b[a].lastOptions.params.restriction,{start:0,limit:b[a].getCount()});b[a].reload(b[a].lastOptions)}else b[a].reload();Ext.isEmpty(c)||Ext.each(c.item,function(f){var g=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"),g);if(g=this.getFolder(f.entryid)){g.set("content_unread",f.content_unread);g.set("content_count",f.content_count)}},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)},sendDestroySession:function(){var a={params:{},actionType:Zarafa.core.Actions.destroysession};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)},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)}}});Ext.reg("zarafa.hierarchystore",Zarafa.hierarchy.data.HierarchyStore);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.reject()})},containsStoreInLastLoad:function(a){Ext.isArray(a)||(a=[a]);if(this.parentRecord)for(var b=this.parentRecord.get("store_entryid"),c=0,d=a.length;c<d;c++)if(Zarafa.core.EntryId.compareStoreEntryIds(b,a[c]))return true;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],i=g.getMAPIStore().get("user_name").toLowerCase(),
h=g.getSharedFolderKey();c.remove("zarafa/v1/contexts/hierarchy/shared_stores/"+i+"/"+h);g.addIdProp("user_name");g.addIdProp("folder_type");g.removeIdProp("entryid");g.removeIdProp("parent_entryid");g.removeIdProp("store_entryid");g.set("user_name",i);g.set("folder_type",h)}c.endEdit()}}});Ext.reg("zarafa.ipfsubstore",Zarafa.hierarchy.data.IPFSubStore);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.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.dialogs");
Zarafa.hierarchy.dialogs.FolderPropertiesContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.folderpropertiescontentpanel",layout:"fit",title:_("Properties"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{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.FolderPropertiesContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.folderpropertiescontentpanel",Zarafa.hierarchy.dialogs.FolderPropertiesContentPanel);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.FolderSizeContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.foldersizecontentpanel",layout:"fit",title:_("Folder Size"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{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.FolderSizeContentPanel.superclass.constructor.call(this,
a)}});Ext.reg("zarafa.foldersizecontentpanel",Zarafa.hierarchy.dialogs.FolderSizeContentPanel);Ext.namespace("Zarafa.hierarchy.ui");
Zarafa.hierarchy.ui.MultiSelectHierarchyTree=Ext.extend(Zarafa.hierarchy.ui.HierarchyTreePanel,{colored:false,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.on("checkchange",this.onTreeNodeCheckChange,this);this.on("click",this.onTreeNodeClick,this);this.mon(this.model,"folderchange",this.onFolderChange,this);this.mon(this.model,"activate",this.onCalendarActivate,
this)}},initEvents:function(){Zarafa.hierarchy.ui.MultiSelectHierarchyTree.superclass.initEvents.call(this);this.un("click",this.onFolderClicked,this)},onTreeNodeClick:function(a){var b=a.getUI();if(b.checkbox.checked&&a.isNodeSelected){b.toggleCheck(false);return false}this.model.addFolder(a.getFolder());a.isNodeSelected=true;b.toggleCheck(true)},onTreeNodeCheckChange:function(a,b){var c=a.getFolder();if(b)a.isNodeSelected||this.fireEvent("click",a);else{a.isNodeSelected=false;this.model.removeFolder(c)}},
onFolderChange:function(){this.updateAll()},onCalendarActivate:function(a){(a=this.getNodeById(a.get("entryid")))&&a.select()}});Ext.reg("zarafa.multiselecthierarchytree",Zarafa.hierarchy.ui.MultiSelectHierarchyTree);Ext.namespace("Zarafa.mail");
Zarafa.mail.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.X,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewMail,scope:this,settingsCfg:{description:_("New mail"),category:_("Creating an item")}}],b=[{key:Ext.EventObject.R,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onReplyMail,scope:this,settingsCfg:{description:_("Reply"),category:_("Mail")}},{key:Ext.EventObject.R,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onReplyAllMail,
scope:this,settingsCfg:{description:_("Reply all"),category:_("Mail")}},{key:Ext.EventObject.F,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onForwardMail,scope:this,settingsCfg:{description:_("Forward"),category:_("Mail")}},{key:Ext.EventObject.E,ctrl:true,alt:false,shift:false,stopEvent:true,handler:this.onEditAsNewMail,scope:this,settingsCfg:{description:_("Edit as New Message"),category:_("Mail")}}],c=[{key:Ext.EventObject.U,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onReadUnreadToggle,
scope:this,settingsCfg:{description:_("Toggle read/unread"),category:_("Mail")}},{key:Ext.EventObject.G,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onFlagToggle,scope:this,settingsCfg:{description:_("Toggle red/complete flag"),category:_("Mail")}}];Zarafa.core.KeyMapMgr.register("global",a);Zarafa.core.KeyMapMgr.register("grid.mapimessage.mail",c);Zarafa.core.KeyMapMgr.register("grid.mapimessage.mail",b);Zarafa.core.KeyMapMgr.register("previewpanel.mail",b);Zarafa.core.KeyMapMgr.register("contentpanel.record.message.showmail",
b)},onNewMail:function(){Zarafa.mail.Actions.openCreateMailContent(container.getContextByName("mail").getModel())},getSelectedRecord:function(a){if(Ext.isDefined(a.record))return a.record;else if(Ext.isFunction(a.getSelectionModel))return a.getSelectionModel().getSelected();return false},getModel:function(a){if(Ext.isFunction(a.getContextModel))return a.getContextModel();else if(Ext.isDefined(a.model))return a.model;return false},onReplyMail:function(a,b,c){a=this.getSelectedRecord(c);c=this.getModel(c);
a&&Zarafa.mail.Actions.openCreateMailResponseContent(a,c,Zarafa.mail.data.ActionTypes.REPLY)},onReplyAllMail:function(a,b,c){a=this.getSelectedRecord(c);c=this.getModel(c);a&&Zarafa.mail.Actions.openCreateMailResponseContent(a,c,Zarafa.mail.data.ActionTypes.REPLYALL)},onForwardMail:function(a,b,c){a=this.getSelectedRecord(c);c=this.getModel(c);a&&Zarafa.mail.Actions.openCreateMailResponseContent(a,c,Zarafa.mail.data.ActionTypes.FORWARD)},onEditAsNewMail:function(a,b,c){a=this.getSelectedRecord(c);
c=this.getModel(c);a&&Zarafa.mail.Actions.openCreateMailResponseContent(a,c,Zarafa.mail.data.ActionTypes.EDIT_AS_NEW)},onReadUnreadToggle:function(a,b,c){a=c.model.getSelectedRecords();Ext.isEmpty(a)||(a[0].isRead()?Zarafa.common.Actions.markAsRead(a,false):Zarafa.common.Actions.markAsRead(a,true))},onFlagToggle:function(a,b,c){a=c.model.getSelectedRecords();if(!Ext.isEmpty(a)){b=a[0].get("flag_status");c=a[0].getStore();for(var d=0,e=a.length;d<e;d++){var f=a[d];if(!(f.isFaultyMessage()||!f.isMessageClass(["IPM.Note",
"IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true)))if(b==Zarafa.core.mapi.FlagStatus.cleared){f.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged);f.set("flag_icon",Zarafa.core.mapi.FlagIcon.red)}else if(b==Zarafa.core.mapi.FlagStatus.completed){f.set("flag_status",Zarafa.core.mapi.FlagStatus.flagged);f.set("flag_icon",Zarafa.core.mapi.FlagIcon.red)}else{f.set("flag_status",Zarafa.core.mapi.FlagStatus.completed);f.set("flag_icon",Zarafa.core.mapi.FlagIcon.clear)}}c&&c.save(a)}}});
Zarafa.mail.KeyMapping=new Zarafa.mail.KeyMapping;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:container.getSettingsModel().get("zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor")})},createResponseRecord:function(a,b,c){if(!(Ext.isEmpty(b)||!a)){var d=false;if(Ext.isDefined(c))d=true;else 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.setSourceMessageInfo(a,b,c);var e=a.get("attach_num");!Ext.isEmpty(e)&&b!==Zarafa.mail.data.ActionTypes.EDIT_AS_NEW&&c.addMessageAction("source_attach_num",e);if(b===Zarafa.mail.data.ActionTypes.EDIT_AS_NEW)this.copyRecordRecipients(c,a);else{e=this.getDefaultFolder().getMAPIFolderStore();var f=e.find("entryid",a.get("parent_entryid"));e=(e=e.getAt(f))?e.getDefaultFolderKey()===
"sent":false;this.initRecordRecipients(c,a,b,e)}this.initRecordSubject(c,a,b);if(b===Zarafa.mail.data.ActionTypes.FORWARD_ATTACH)c.getAttachmentStore().addEmbeddedAttachment(a);else{b===Zarafa.mail.data.ActionTypes.EDIT_AS_NEW?this.copyRecordBody(c,a):this.initRecordBody(c,a,b);this.initRecordAttachments(c,a,b)}d&&c.set("subject",_("FW")+": ");if(!Ext.isFunction(a.userIsStoreOwner)||!a.userIsStoreOwner())(a=container.getHierarchyStore().getById(a.get("store_entryid")))&&c.setDelegatorInfo(a);return c}},
setSourceMessageInfo:function(a,b,c){var d;switch(b){case "reply":d="0501000066000000";break;case "replyall":d="0501000067000000";break;case "forward":case "forward_attach":d="0601000068000000";break}a="01000E000C000000"+d+"0200000030000000"+a.get("entryid");c.set("source_message_info",a)},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:case Zarafa.mail.data.ActionTypes.FORWARD_ATTACH:d=
_("FW")+": ";break;case Zarafa.mail.data.ActionTypes.EDIT_AS_NEW:d="";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;c=this.getSignatureId(c);var e=Ext.apply({},b.data);if(b.isOpened()){d=b.getRecipientStore();var f=[],g=[];if(d.getCount()>0){d.each(function(i){switch(i.get("recipient_type")){case Zarafa.core.mapi.RecipientType.MAPI_TO:f.push(i.formatRecipient());break;
case Zarafa.core.mapi.RecipientType.MAPI_CC:g.push(i.formatRecipient());break}},this);e.display_to=f.join("; ");e.display_cc=g.join("; ")}}d=new Ext.XTemplate(Zarafa.mail.data.Templates.htmlQuotedTemplate,{compiled:true});e.body=b.getBody(true);e.signatureData=this.getSignatureData(true,c);a.set("html_body",d.apply(e));d=new Ext.XTemplate(Zarafa.mail.data.Templates.plaintextQuotedTemplate,{compiled:true});e.body=b.getBody(false);e.signatureData=this.getSignatureData(false,c);e.body=e.body.replace(/^/g,
"> ").replace(/\n/g,"\n> ");a.set("body",d.apply(e))},initRecordRecipients:function(a,b,c,d){if(!(c===Zarafa.mail.data.ActionTypes.FORWARD||c===Zarafa.mail.data.ActionTypes.FORWARD_ATTACH)){var e=a.getRecipientStore(),f=[];if(!d){a=container.getUser().getEntryId();f.push(a);b.getSubStore("reply-to").each(function(g){this.addRecipientToStore(e,g,true);g=g.get("entryid");f.push(g)},this)}if(c===Zarafa.mail.data.ActionTypes.REPLYALL||c===Zarafa.mail.data.ActionTypes.REPLY&&d){b.getRecipientStore().each(function(g){if(!(c===
Zarafa.mail.data.ActionTypes.REPLY&&g.get("recipient_type")!==Zarafa.core.mapi.RecipientType.MAPI_TO)){var i=g.get("entryid"),h=false;if(i)for(var k=0;k<f.length;k++)if(Zarafa.core.EntryId.compareABEntryIds(f[k],i)){h=true;break}if(!h){this.addRecipientToStore(e,g,false);f.push(i)}}},this);d&&e.find("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_TO)===-1&&this.addRecipientToStore(e,b.getSender(),true)}}},addRecipientToStore:function(a,b,c){b=Ext.apply({},b.data);b=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,
b);c&&b.set("recipient_type",Zarafa.core.mapi.RecipientType.MAPI_TO);b.set("rowid",undefined);a.add(b)},copyRecordBody:function(a,b){a.set("body",b.getBody(false));var c=b.getBody(true);c=c.replace(/<\!\-\-.*?\-\->/gi,"");c=c.replace(/^\s*<div\s+class=['"]bodyclass['"]\s*>/gi,"");c=c.replace(/\s*<\/div\s*>\s*$/gi,"");a.set("html_body",c)},copyRecordRecipients:function(a,b){var c=a.getRecipientStore();b.getRecipientStore().each(function(d){d=Ext.apply({},d.data);d=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,
d);d.set("rowid",undefined);c.add(d)},this)},initRecordAttachments:function(a,b,c){var d=a.getAttachmentStore();switch(c){case Zarafa.mail.data.ActionTypes.FORWARD:case Zarafa.mail.data.ActionTypes.FORWARD_ATTACH:case Zarafa.mail.data.ActionTypes.EDIT_AS_NEW: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.FORWARD_ATTACH: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);if(!Ext.isDefined(c.content))return"";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=c.content}c.content=this.replaceSignatureTemplates(c.content,a);return c.content},replaceSignatureTemplates:function(a,b){if(!/{%.*}/gi.test(a))return a;var c=container.getUser();c={firstname:c.getFirstName(),initials:c.getInitials(),lastname:c.getLastName(),displayname:c.getDisplayName(),title:c.getTitle(),company:c.getCompany(),department:c.getDepartment(),office:c.getOffice(),assistant:c.getAssistant(),
phone:c.getPhone(),primary_email:c.getSMTPAddress(),address:c.getAddress(),city:c.getCity(),state:c.getState(),zipcode:c.getZipCode(),country:c.getCountry(),phone_business:c.getPhoneBusiness(),phone_business2:c.getPhoneBusiness2(),phone_fax:c.getFax(),phone_assistant:c.getPhoneAssistant(),phone_home:c.getPhoneHome(),phone_home2:c.getPhoneHome2(),phone_mobile:c.getPhoneMobile(),phone_pager:c.getPhonePager()};Ext.iterate(c,function(d,e){if(Ext.isDefined(e)){if(b)e=Zarafa.core.HTMLParser.nl2br(Ext.util.Format.htmlEncode(e))}else e=
"";a=a.replace(RegExp("{%"+d+"}","gi"),e)});return a},onDataModeChange:function(a,b,c){Zarafa.mail.MailContextModel.superclass.onDataModeChange.call(this,a,b,c);if(b!==c&&c===Zarafa.mail.data.DataModes.SEARCH){this.stopSearch();this.stopLiveScroll()}switch(b){case Zarafa.mail.data.DataModes.SEARCH:case Zarafa.mail.data.DataModes.LIVESCROLL:break;case Zarafa.mail.data.DataModes.ALL:this.load();break}},onFolderChange:function(a,b){if(!Ext.isEmpty(b)){var c=b[0].getDefaultFolderKey(),d="message_delivery_time";
if(c==="drafts")d="last_modification_time";else if(c==="sent"||c==="outbox")d="client_submit_time";this.store.defaultSortInfo.field=d}Zarafa.mail.MailContextModel.superclass.onFolderChange.call(this,a,b)},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.mail");
Zarafa.mail.URLAction=Ext.extend(Object,{constructor:function(){Zarafa.core.URLActionMgr.register("mailto",{handler:this.handleMailTo,scope:this})},handleMailTo:function(a,b){b=b.replace(/^mailto:/ig,"to=");b=b.replace(/\?/i,"&");var c=Ext.urlDecode(b);c=Zarafa.core.Util.objectKeysToLowerCase(c);var d=container.getHierarchyStore().getDefaultFolder("drafts");d=container.getContextByFolder(d).getModel().createRecord(d);Ext.isEmpty(c.subject)||d.set("subject",c.subject);if(!Ext.isEmpty(c.body)){d.set("body",
c.body);d.set("isHTML",false)}var e=[],f={to:Zarafa.core.mapi.RecipientType.MAPI_TO,cc:Zarafa.core.mapi.RecipientType.MAPI_CC,bcc:Zarafa.core.mapi.RecipientType.MAPI_BCC};for(var g in f)if(!Ext.isEmpty(c[g]))for(var i=c[g].split(/[;,]/),h=0;h<i.length;h++)e.push(Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,{display_name:i[h],smtp_address:i[h],address_type:"SMTP",recipient_type:f[g]}));d.getSubStore("recipients").add(e);Zarafa.mail.Actions.openMailContent(d)}});
Zarafa.mail.URLAction=new Zarafa.mail.URLAction;Ext.namespace("Zarafa.mail.attachitem");
Zarafa.mail.attachitem.AttachMailRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{constructor:function(a){Zarafa.mail.attachitem.AttachMailRenderer.superclass.constructor.call(this,a);Ext.apply(this.labels,{message_delivery_time:_("Sent")})},generateHTMLTemplate:function(){var a="";a+=this.addHTMLRowGroup({from:"{from:htmlEncode}",message_delivery_time:'{message_delivery_time:date("'+_("l jS F Y G:i")+'")}',display_to:"{display_to:htmlEncode}",display_cc:"{display_cc:htmlEncode}",
display_bcc:"{display_bcc:htmlEncode}",subject:"{subject:htmlEncode}",attachment_names:"{attachment_names:htmlEncode}"});a+=this.addHTMLRowGroup({sensitivity:"{sensitivity:sensitivityString}",importance:"{importance:importanceString}"});a+=this.addHTMLRow("categories","{categories:htmlEncode}");a+="{body}";return a},generatePlainTemplate:function(){var a="";a+=this.addPlainRowGroup({from:"{from}",message_delivery_time:'{message_delivery_time:date("'+_("l jS F Y G:i")+'")}',display_to:"{display_to}",
display_cc:"{display_cc}",display_bcc:"{display_bcc}",subject:"{subject}",attachment_names:"{attachment_names}"});a+=this.addPlainRowGroup({sensitivity:"{sensitivity:sensitivityString}",importance:"{importance:importanceString}"});a+=this.addPlainRow("categories","{categories}");a+="{body}";return a}});Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.DataModes=Zarafa.core.Enum.create({ALL: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,LIVESCROLL:4,isMainViewMode:function(a){return a===this.NO_PREVIEW||a===this.RIGHT_PREVIEW||a===this.BOTTOM_PREVIEW}});Ext.namespace("Zarafa.mail.data");Zarafa.mail.data.Views=Zarafa.core.Enum.create({LIST:0,SEARCH:1,LIVESCROLL:2});Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateOptionsContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailcreateoptionscontentpanel",layout:"fit",title:_("Message Options"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),autoSave:a.modal?false:true,width:320,height:220,items:[{xtype:"zarafa.mailcreateoptionspanel",buttons:[{text:_("Ok"),handler:this.onOk,scope:this},{text:_("Cancel"),handler:this.onCancel,
scope:this}]}]});Zarafa.mail.dialogs.MailCreateOptionsContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.mailcreateoptionscontentpanel",Zarafa.mail.dialogs.MailCreateOptionsContentPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailCreateToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{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.mailcreatecontentpanel",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.onContentPanelBccToggle,this);this.mon(this.dialog,"fromtoggle",this.onContentPanelFromToggle,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")+" (Ctrl + ENTER)"},
cls:"zarafa-action",iconCls:"buttons-icon_send_white",handler:this.onSendButton,scope:this},container.populateInsertionPoint("context.mail.mailcreatecontentpanel.toolbar.aftersendbutton",this),{xtype:"button",overflowText:_("Save email"),tooltip:{title:_("Save email"),text:_("Save email")+" (Ctrl + S)"},iconCls:"icon_saveEmail",handler:this.onSaveButton,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this mail")},iconCls:"icon_delete",
handler:this.onDeleteButton,scope:this},{xtype:"zarafa.attachmentbutton",plugins:["zarafa.recordcomponentupdaterplugin"],overflowText:_("Add attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this email")},iconCls:"icon_attachment",ref:"attachmentButton",listeners:{added:this.onAttachmentButtonAdded,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}]},onAttachmentButtonAdded:function(a){if(a.isXType("menuitem"))a.update=Zarafa.common.attachment.ui.AttachmentButton.prototype.update.createDelegate(this.attachmentButton)},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 mail 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 mail 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()},
onCheckNamesButton:function(){this.record.getRecipientStore().resolve(undefined,{cancelPreviousRequest:true})},onMailOptionsButton:function(){Zarafa.mail.Actions.openMailOptionsContent(this.record,{autoSave:false})},onSetFlagButton:function(){Zarafa.mail.Actions.openMailFlagsContent(this.record,{autoSave:false})},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)},onContentPanelBccToggle:function(a,b){this.showBcc.toggle(b,true)},onContentPanelFromToggle: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,
false);break;case Zarafa.core.mapi.Importance.NONURGENT:this.lowPriority.toggle(true,false);break;default:this.highPriority.toggle(false,true);this.lowPriority.toggle(false,true);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.MailFlagsContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{disableFlagColor:false,disableCompleted:false,constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailflagscontentpanel",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,title:_("E-Mail Flags"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true})});Zarafa.mail.dialogs.MailFlagsContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.mailflagscontentpanel",Zarafa.mail.dialogs.MailFlagsContentPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.MailViewOptionsContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{xtype:"zarafa.mailviewoptionscontentpanel",layout:"fit",title:_("Message Options"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{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.MailViewOptionsContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.mailviewoptionscontentpanel",Zarafa.mail.dialogs.MailViewOptionsContentPanel);Ext.namespace("Zarafa.mail.dialogs");
Zarafa.mail.dialogs.ShowMailToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{xtype:"mail.showmailtoolbar",insertionPointBase:"context.mail.showmailcontentpanel",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});Zarafa.mail.dialogs.ShowMailToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",
rowspan:2,text:_("Reply"),tooltip:_("Reply")+" (Ctrl + R)",overflowText:_("Reply"),cls:"zarafa-action",iconCls:"icon_replyEmail",ref:"replyBtn",actionType:Zarafa.mail.data.ActionTypes.REPLY,handler:this.onMailResponseButton,scope:this},{xtype:"button",text:_("Reply All"),tooltip:_("Reply All")+" (Ctrl + Alt + R)",overflowText:_("Reply All"),iconCls:"icon_replyAllEmail",ref:"replyAllBtn",actionType:Zarafa.mail.data.ActionTypes.REPLYALL,handler:this.onMailResponseButton,scope:this},{xtype:"button",
text:_("Forward"),tooltip:_("Forward")+" (Ctrl + F)",overflowText:_("Forward"),iconCls:"icon_forwardEmail",ref:"forwardBtn",actionType:Zarafa.mail.data.ActionTypes.FORWARD,handler:this.onMailResponseButton,scope:this},{xtype:"button",text:_("Edit as New Message"),tooltip:_("Edit as New Message")+" (Ctrl + E)",overflowText:_("Edit as New Message"),iconCls:"icon_editAsNewEmail",ref:"editAsNewBtn",actionType:Zarafa.mail.data.ActionTypes.EDIT_AS_NEW,handler:this.onMailResponseButton,scope:this},{xtype:"button",
ref:"deleteBtn",overflowText:_("Delete this item."),tooltip:{title:_("Delete mail"),text:_("Delete this mail.")},iconCls:"icon_delete",handler:this.onDeleteButton,scope:this}]},createOptionButtons:function(){return[{xtype:"button",ref:"optionsBtn",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",ref:"flagsBtn",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;var b=false,c=false;if(a){b=a.isSubMessage();c=a.isFaultyMessage()}this.deleteBtn.setVisible(!b);this.optionsBtn.setVisible(!b&&!c);this.flagsBtn.setVisible(!b&&!c);this.replyBtn.setVisible(!c);this.replyAllBtn.setVisible(!c);this.forwardBtn.setVisible(!c);
a=this.record.get("parent_entryid");b=container.getHierarchyStore().getDefaultFolder("sent");this.editAsNewBtn.setVisible((Ext.isDefined(b)?Zarafa.core.EntryId.compareEntryIds(a,b.get("entryid")):false)&&!c)},onSetFlagButton:function(){Zarafa.mail.Actions.openMailFlagsContent(this.record,{autoSave:true})},onMailOptionsButton:function(){Zarafa.mail.Actions.openMailOptionsContent(this.record,{autoSave:true})},onDeleteButton:function(){this.dialog.deleteRecord()},onPrintButton:function(){Zarafa.common.Actions.openPrintDialog(this.record)},
onMailResponseButton:function(a){var b=this.dialog.getContextModel();Zarafa.mail.Actions.openCreateMailResponseContent(this.record,b,a.actionType);container.getSettingsModel().get("zarafa/v1/contexts/mail/close_on_respond")===true&&this.dialog.close()}});Ext.reg("zarafa.showmailtoolbar",Zarafa.mail.dialogs.ShowMailToolbar);Ext.namespace("Zarafa.mail.ui");
Zarafa.mail.ui.MailGrid=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{context:undefined,model:undefined,sentFolderTypes:undefined,unSentFolderTypes:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.sentFolderTypes))a.sentFolderTypes=["outbox","sent"];if(!Ext.isDefined(a.unSentFolderTypes))a.unSentFolderTypes=["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"});Zarafa.mail.ui.MailGrid.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.mail.ui.MailGrid.superclass.initEvents.call(this);this.on({cellcontextmenu:this.onCellContextMenu,cellclick:this.onCellClick,
rowbodycontextmenu:this.onRowBodyContextMenu,rowdblclick:this.onRowDblClick,scope:this});this.mon(this.getView(),"livescrollstart",this.onLiveScrollStart,this);this.mon(this.getView(),"beforesort",this.onBeforeSort,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.mon(this.context,"viewchange",this.onContextViewChange,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=Ext.isFunction(a.isRead)&&!a.isRead()?"mail_unread":"mail_read";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 grid_compact_subject_cell {0}">{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="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="width: 24px;">{1}</div></td>',d.css,e);a=container.populateInsertionPoint("context.mail.gridrow",a);for(d=0;d<a.length;d++)c.body+=a[d];c.body+="</tr></table>";return"x-grid3-row-expanded "+b}return"x-grid3-row-collapsed "+b},initSelectionModel:function(){return new Zarafa.mail.ui.MailRowSelectionModel({singleSelect:false})},initColumnModel:function(){return new Zarafa.mail.ui.MailGridColumnModel},
onContextViewChange:function(a,b,c){c===Zarafa.mail.data.Views.LIVESCROLL&&this.getView().resetScroll()},onContextViewModeChange:function(a,b){switch(b){case Zarafa.mail.data.ViewModes.RIGHT_PREVIEW:case Zarafa.mail.data.ViewModes.NO_PREVIEW:case Zarafa.mail.data.ViewModes.BOTTOM_PREVIEW:var c=b===Zarafa.mail.data.ViewModes.RIGHT_PREVIEW;this.getView().enableRowBody=c;this.getColumnModel().setCompactView(c);break;case Zarafa.mail.data.ViewModes.SEARCH:case Zarafa.mail.data.ViewModes.LIVESCROLL:break}},
onBeforeConfigChange:function(a,b){if(this.currentEntryId){var c=container.getHierarchyStore().getById(this.currentStoreEntryId).getFolder(this.currentEntryId).getDefaultFolderKey(),d=this.sentFolderTypes.indexOf(c)>=0;c=this.unSentFolderTypes.indexOf(c)>=0;for(var e=!d&&!c,f=0,g=b.length;f<g;f++){var i=b[f];if(i.dataIndex==="sent_representing_name")i.hidden=!e;else if(i.dataIndex==="display_to")i.hidden=!(d||c);else if(i.dataIndex==="message_delivery_time")i.hidden=!e;else if(i.dataIndex==="client_submit_time")i.hidden=
!d;else if(i.dataIndex==="last_modification_time")i.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=c>=0?e.getDataIndex(c):undefined;c=a.getSelections();switch(b){case "importance":Zarafa.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu.importance"],
c,{position:d.getXY()});break;case "flag_status":var f=true;Ext.each(c,function(g){if(g.isFaultyMessage()||!g.isMessageClass(["IPM.Note","IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true))f=false},this);if(f){Zarafa.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["mail.contextmenu.flags"],c,{position:d.getXY()});break}default:Zarafa.core.data.UIFactory.openDefaultContextMenu(c,{position:d.getXY(),context:this.context});break}},onCellClick:function(a,b,c){a=this.store.getAt(b);
if(Ext.isDefined(a))switch(this.getColumnModel().config[c].dataIndex){case "flag_status":if(!a.isMessageClass(["IPM.Note","IPM.Schedule.Meeting","REPORT.IPM","REPORT.IPM.Note"],true))break;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)}a.dirty&&a.save();break;case "icon_index":Zarafa.common.Actions.markAsRead(a,
!a.isRead());break}},onRowBodyContextMenu:function(a,b,c){this.onCellContextMenu(a,b,-1,c)},onRowDblClick:function(){Zarafa.mail.Actions.openMailContent(this.getSelectionModel().getSelected())},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)}},onLiveScrollStart:function(a){this.model.startLiveScroll(a)},onBeforeSort:function(){this.model.stopLiveScroll()}});Ext.reg("zarafa.mailgrid",Zarafa.mail.ui.MailGrid);Ext.namespace("Zarafa.note");
Zarafa.note.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.S,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewNote,scope:this,settingsCfg:{description:_("New note"),category:_("Creating an item")}}];Zarafa.core.KeyMapMgr.register("global",a)},onNewNote:function(){Zarafa.note.Actions.openCreateNoteContent(container.getContextByName("note").getModel())}});Zarafa.note.KeyMapping=new Zarafa.note.KeyMapping;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",
{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:a=new Date;a.setHours(12);var d=a.add(Date.DAY,-7).clearTime();
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.note.attachitem");
Zarafa.note.attachitem.AttachNoteRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{generateHTMLTemplate:function(){var a="";a+=this.addHTMLRow("categories","{categories:htmlEncode}");a+="{body}";return a},generatePlainTemplate:function(){var a="";a+=this.addPlainRow("categories","{categories}");a+="{body}";return a}});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.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.Views=Zarafa.core.Enum.create({LIST:0,ICON:1,SEARCH:2});Ext.namespace("Zarafa.note.dialogs");
Zarafa.note.dialogs.NoteEditContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.noteeditcontentpanel",layout:"fit",title:_("Note"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),confirmClose:true,items:[this.createPanel()]});Zarafa.note.dialogs.NoteEditContentPanel.superclass.constructor.call(this,a)},createPanel:function(){return{iconCls:"icon_folder_note",border:false,tbar:{xtype:"zarafa.noteedittoolbar"},
xtype:"zarafa.noteeditpanel",layout:"fit"}},update:function(a,b){b===true&&this.inputAutoFocusPlugin.setAutoFocus("zarafa.editorfield");this.updateIconFromRecord(a);this.updateTitleFromRecord(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},updateTitleFromRecord:function(a){a=a.get("subject");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)}});Ext.reg("zarafa.noteeditcontentpanel",Zarafa.note.dialogs.NoteEditContentPanel);Ext.namespace("Zarafa.note.dialogs");
Zarafa.note.dialogs.NoteEditToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.note.noteeditcontentpanel",actionItems:this.createActionButtons()});Zarafa.note.dialogs.NoteEditToolbar.superclass.constructor.call(this,a)},createActionButtons:function(){return[{xtype:"button",ref:"saveBtn",text:_("Save"),overflowText:_("Save Note"),tooltip:{title:_("Save"),
text:_("Save note")+" (Ctrl + S)"},cls:"zarafa-action",iconCls:"buttons-icon_save_white",handler:this.onSaveButton,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete Note"),tooltip:{title:_("Delete"),text:_("Delete this note")},cls:"tb-notes-btn-delete",iconCls:"icon_delete",handler:this.onDeleteButton,scope:this},{xtype:"button",overflowText:_("Set Category"),tooltip:{title:_("Categories"),text:_("Open the categories dialog.")},cls:"tb-notes-btn-categories",iconCls:"icon_categories",
handler:this.onOpenCategories,scope:this},{xtype:"button",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this note")},cls:"tb-notes-btn-print",iconCls:"icon_print",handler:this.onPrintRecord,scope:this},{xtype:"combo",width:75,fieldLabel:_("Color"),overflowText:_("Color"),ref:"colorCombo",cls:"tb-notes-combo-color",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},plugins:["zarafa.fieldlabeler"]}]},onSaveButton:function(){this.dialog.saveRecord()},onDeleteButton:function(){this.dialog.deleteRecord()},onComboSelect:function(a,b){this.record.set("icon_index",b.get("icon_index"));this.record.set("color",Zarafa.core.mapi.NoteColor.getColorValue(b.get("icon_index")))},onOpenCategories:function(){Zarafa.common.Actions.openCategoriesContent(this.record,
{autoSave:false})},onPrintRecord:function(){Zarafa.common.Actions.openPrintDialog(this.record)},update:function(a){this.record=a;if(a.isSubMessage()){this.deleteBtn.setVisible(false);this.saveBtn.setVisible(false)}else{this.saveBtn.setVisible(true);this.deleteBtn.setDisabled(a.phantom===true)}this.colorCombo.setValue(a.get("icon_index"));this.doLayout()},updateRecord:function(a){a.set("icon_index",this.colorCombo.getValue())}});Ext.reg("zarafa.noteedittoolbar",Zarafa.note.dialogs.NoteEditToolbar);
Ext.namespace("Zarafa.note.ui");
Zarafa.note.ui.NoteGrid=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{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"});Zarafa.note.ui.NoteGrid.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.NoteGrid.superclass.initEvents.call(this);this.on({rowcontextmenu:this.onNoteRowContextMenu,rowdblclick:this.onNoteRowDblClick,scope:this})},onNoteRowContextMenu:function(a,b,c){a=this.getSelectionModel();a.isSelected(b)||a.selectRow(b);Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY()})},onNoteRowDblClick:function(a){Zarafa.note.Actions.openNoteContent(a.getSelectionModel().getSelected())},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())}});
Ext.reg("zarafa.notegrid",Zarafa.note.ui.NoteGrid);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,
remove:this.onRemoveSetting,scope: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},getRealSettingsModel:function(){return this.realModel},hasChanges:function(){return this.dirty},setDirty:function(){this.dirty=true},applyChanges:function(){if(this.fireEvent("beforesavesettings",this,this.editModel)!==false)if(this.hasChanges()){this.fireEvent("savesettings",
this,this.editModel);this.realModel.requiresReload=this.editModel.requiresReload;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.editModel.commit();this.dirty=false;delete this.setlist;delete this.dellist}},discardChanges:function(){this.editModel.initialize(this.realModel.get(undefined,
true));this.editModel.commit();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.settings.data");
Zarafa.settings.data.KeyboardSettings=Zarafa.core.Enum.create({NO_KEYBOARD_SHORTCUTS:"disabled",ALL_KEYBOARD_SHORTCUTS:"full",BASIC_KEYBOARD_SHORTCUTS:"basic"});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.on("afteredit",this.onAfterEdit,this);
this.on("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.core.data.UIFactory.openDefaultContextMenu(a,
{position: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.task");Zarafa.task.KeyMapping=Ext.extend(Object,{constructor:function(){var a=[{key:Ext.EventObject.K,ctrl:true,alt:true,shift:false,stopEvent:true,handler:this.onNewTask,scope:this,settingsCfg:{description:_("New task"),category:_("Creating an item")}}];Zarafa.core.KeyMapMgr.register("global",a)},onNewTask:function(){Zarafa.task.Actions.openCreateTaskContent(container.getContextByName("task").getModel())}});
Zarafa.task.KeyMapping=new Zarafa.task.KeyMapping;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",
{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.task.attachitem");
Zarafa.task.attachitem.AttachTaskRenderer=Ext.extend(Zarafa.common.attachment.dialogs.AttachItemBaseRenderer,{constructor:function(a){Zarafa.task.attachitem.AttachTaskRenderer.superclass.constructor.call(this,a);Ext.apply(this.labels,{startdate:_("Start Date"),duedate:_("Due Date"),status:_("Task Status"),percent_complete:_("Percent Complete"),totalwork:_("Total Work"),actualwork:_("Actual Work"),owner:_("Owner"),companies:_("Companies"),billinginformation:_("Billing Information"),mileage:_("Mileage")})},
generateHTMLTemplate:function(){var a="";a+=this.addHTMLRowGroup({subject:"{subject:htmlEncode}",startdate:'{startdate:date("'+_("l jS F Y G:i")+'")}',duedate:'{duedate:date("'+_("l jS F Y G:i")+'")}',importance:"{importance:importanceString}",sensitivity:"{sensitivity:sensitivityString}"});a+=this.addHTMLRowGroup({status:"{status:taskStatusString}",percent_complete:"{percent_complete:percentage}",datecompleted:'{datecompleted:date("'+_("l jS F Y G:i")+'")}'});a+=this.addHTMLRowGroup({totalwork:"{totalwork:duration}",
actualwork:"{actualwork:duration}",owner:"{owner:htmlEncode}",categories:"{categories:htmlEncode}",companies:"{companies:htmlEncode}",billinginformation:"{billinginformation:htmlEncode}",mileage:"{mileage:htmlEncode}"});a+=this.addHTMLRowGroup({categories:"{categories:htmlEncode}",companies:"{companies:htmlEncode}",billinginformation:"{billinginformation:htmlEncode}",mileage:"{mileage:htmlEncode}"});a+=this.addHTMLRow("attachment_names","{attachment_names:htmlEncode}");a+="{body}";return a},generatePlainTemplate:function(){var a=
"";a+=this.addPlainRowGroup({subject:"{subject}",startdate:'{startdate:date("'+_("l jS F Y G:i")+'")}',duedate:'{duedate:date("'+_("l jS F Y G:i")+'")}',importance:"{importance:importanceString}",sensitivity:"{sensitivity:sensitivityString}"});a+=this.addPlainRowGroup({status:"{status:taskStatusString}",percent_complete:"{percent_complete:percentage}",datecompleted:'{datecompleted:date("'+_("l jS F Y G:i")+'")}'});a+=this.addPlainRowGroup({totalwork:"{totalwork:duration}",actualwork:"{actualwork:duration}",
owner:"{owner}",categories:"{categories}",companies:"{companies}",billinginformation:"{billinginformation}",mileage:"{mileage}"});a+=this.addPlainRowGroup({categories:"{categories}",companies:"{companies}",billinginformation:"{billinginformation}",mileage:"{mileage}"});a+=this.addPlainRow("attachment_names","{attachment_names}");a+="{body}";return a},prepareData:function(){var a=Zarafa.task.attachitem.AttachTaskRenderer.superclass.prepareData.apply(this,arguments);a.status===Zarafa.core.mapi.TaskStatus.NOT_STARTED&&
delete a.status;a.percent_complete===0&&delete a.percent_complete;a.actualwork===0&&delete a.actualwork;a.totalwork===0&&delete a.totalwork;return a}});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.data");Zarafa.task.data.ViewModes=Zarafa.core.Enum.create({NORMAL:0,SEARCH:1});Ext.namespace("Zarafa.task.data");Zarafa.task.data.Views=Zarafa.core.Enum.create({LIST:0,SEARCH:1});
Ext.namespace("Zarafa.task.dialogs");
Zarafa.task.dialogs.TaskToolbar=Ext.extend(Zarafa.core.ui.ContentPanelToolbar,{constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");Ext.applyIf(a,{insertionPointBase:"context.task.taskcontentpanel",actionItems:this.createActionButtons(),optionItems:this.createOptionButtons()});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:"sendBtn",handler:this.onSendTask,scope:this},{xtype:"button",ref:"saveBtn",text:_("Save"),overflowText:_("Save task"),tooltip:{title:_("Save & Close"),text:_("Save task and close dialog")+" (Ctrl + S)"},cls:"zarafa-action",iconCls:"buttons-icon_save_white",handler:this.onSave,scope:this},{xtype:"button",ref:"deleteBtn",overflowText:_("Delete"),tooltip:{title:_("Delete"),text:_("Delete this task")},iconCls:"icon_delete",
handler:this.onDelete,scope:this},{xtype:"zarafa.attachmentbutton",plugins:["zarafa.recordcomponentupdaterplugin"],overflowText:_("Add Attachment"),tooltip:{title:_("Add attachment"),text:_("Add attachments to this task")},iconCls:"icon_attachment",ref:"attachmentButton",listeners:{added:this.onAttachmentButtonAdded,scope:this}},{xtype:"button",ref:"markCompleteBtn",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",overflowText:_("Print"),tooltip:{title:_("Print"),text:_("Print this task")},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:"checkNamesBtn",handler:this.onCheckNames,scope:this}]},onAttachmentButtonAdded:function(a){if(a.isXType("menuitem"))a.update=Zarafa.common.attachment.ui.AttachmentButton.prototype.update.createDelegate(this.attachmentButton)},
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:"cancelAssignmetBtn",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 task as private")},iconCls:"icon_private",ref:"setPrivate",toggleGroup:"privateGroup",handler:this.onPrivateGroupToggle,scope:this}]},onSave:function(){this.dialog.saveRecord()},onCheckNames:function(){this.record.getRecipientStore().resolve(undefined,{cancelPreviousRequest:true})},onRecurrence:function(){Zarafa.common.Actions.openRecurrenceContent(this.record,false)},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.openCategoriesContent(this.record,{autoSave:false})},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){var c=false;this.record=a;if(a.isSubMessage()){this.deleteBtn.setVisible(false);this.sendBtn.setVisible(false);this.saveBtn.setVisible(false);this.checkNamesBtn.setVisible(false);this.cancelAssignmetBtn.setVisible(false);this.markCompleteBtn.setVisible(false);this.setPrivate.setVisible(false);c=true}else{this.saveBtn.setVisible(true);this.deleteBtn.setVisible(true);this.markCompleteBtn.setVisible(true);this.setPrivate.setVisible(true);this.deleteBtn.setDisabled(a.phantom===
true);if(b===true||a.isModifiedSinceLastUpdate("complete"))this.markCompleteBtn.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.sendBtn.setVisible(false);this.checkNamesBtn.setVisible(false);this.cancelAssignmetBtn.setVisible(false);break}c=true}}c&&this.doLayout()},onSendTask:function(){this.dialog.sendRecord()}});
Ext.reg("zarafa.tasktoolbar",Zarafa.task.dialogs.TaskToolbar);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>\n";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>\n</tpl>';a+="</table>\n";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.task.printer.TaskListViewRenderer.superclass.prepareData.apply(this,arguments),c=a.getModel();b.currenttime=new Date;b.tasks=c.getStore().getRange();return b},customStylesheetPath:"client/resources/css/external/print.task.css"});Ext.namespace("Zarafa.task.ui");
Zarafa.task.ui.TaskGridView=Ext.extend(Zarafa.common.ui.grid.MapiMessageGrid,{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,{xtype:"zarafa.taskgrid",border:false,stateful:true,statefulRelativeDimensions:false,loadMask:this.initLoadMask(),viewConfig:this.initViewConfig(),selModel:this.initSelectionModel(),
colModel:this.initColumnModel(),enableDragDrop:true,ddGroup:"dd.mapiitem"});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(){return new Zarafa.task.ui.TaskGridColumnModel},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.on({cellcontextmenu:this.onCellContextMenu,rowdblclick:this.onRowDblClick,rowbodycontextmenu:this.onRowBodyContextMenu,scope:this})},onRowDblClick:function(a){Zarafa.task.Actions.openTaskContent(a.getSelectionModel().getSelections())},onRowBodyContextMenu:function(a,b,c){a=this.getSelectionModel();a.isSelected(b)||a.selectRow(b);Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),
{position: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.core.data.UIFactory.openContextMenu(Zarafa.core.data.SharedComponentType["common.contextmenu.importance"],c,{position:d.getXY()});break;default:Zarafa.core.data.UIFactory.openDefaultContextMenu(c,
{position:d.getXY()});break}},onSelectionChange:function(a){this.model.setSelectedRecords(a.getSelections())},viewConfigGetRowClass:function(a){var b="",c=a.get("complete");a=a.get("duedate");if(Ext.isDate(a)&&a.getTime()<(new Date).getTime())b+="zarafa-task-overdue ";if(c)b+="zarafa-task-complete ";return b}});Ext.reg("zarafa.taskgrid",Zarafa.task.ui.TaskGridView);Ext.namespace("Zarafa.today");
Zarafa.today.TodayContextModel=Ext.extend(Zarafa.core.ContextModel,{constructor:function(a){a=a||{};Ext.applyIf(a,{stateful:false});Zarafa.today.TodayContextModel.superclass.constructor.call(this,a)},disable:Ext.emptyFn,setFolders:Ext.emptyFn,getDefaultFolder:function(){if(!this.defaultFolder){var a=container.getHierarchyStore().getDefaultStore();if(a)this.defaultFolder=a.getSubtreeFolder()}return this.defaultFolder}});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.core.data");
Zarafa.core.data.IPMAttachmentRecordFields=[{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_ATTACH},{name:"attach_num",type:"int",defaultValue:-1},{name:"attach_method",type:"int",defaultValue:Zarafa.core.mapi.AttachMethod.NO_ATTACHMENT},{name:"attach_message_class",type:"string",defaultValue:"IPM.Note"},{name:"size",type:"int",defaultValue:0},{name:"cid"},{name:"filetype"},{name:"hidden",type:"boolean",defaultValue:false},{name:"name",type:"string",defaultValue:_("Untitled")},
{name:"tmpname"},{name:"attachment_contactphoto",type:"boolean",defaultValue:false},{name:"attachment_contactphoto_sizex",type:"int"},{name:"attachment_contactphoto_sizey",type:"int"},{name:"entryid"},{name:"store_entryid"}];
Zarafa.core.data.IPMAttachmentRecord=Ext.extend(Ext.data.Record,{uploadAttempted:false,inline:false,applyData:function(a){this.beginEdit();Ext.apply(this.data,a.data);Ext.apply(this.modified,a.modified);this.inline=a.inline;this.uploadAttempted=a.uploadAttempted;this.dirty=a.dirty;this.endEdit(false);return this},setInline:function(a){this.inline=a},isUploaded:function(){return!Ext.isEmpty(this.get("tmpname"))||this.get("attach_num")>-1},isTmpFile:function(){return this.get("attach_num")<=-1},isInline:function(){return this.inline},
isHidden:function(){return this.get("hidden")},isRecurrenceException:function(){return this.isHidden()&&Zarafa.core.MessageClass.isClass(this.get("attach_message_class"),"IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}")},isContactPhoto:function(){return this.get("attachment_contactphoto")},isEmbeddedMessage:function(){return this.get("attach_method")===Zarafa.core.mapi.AttachMethod.ATTACH_EMBEDDED_MSG&&!this.isRecurrenceException()},getInlineImageUrl:function(){return this.store.getInlineImageUrl(this)},
getAttachmentUrl:function(a){return this.store.getAttachmentUrl(this,a)},getParentAttachNum:function(a){a||(a=this.store.getParentRecord());a=a.get("attach_num");return!Ext.isEmpty(a)&&a[0]!==-1?[].concat(a):[]},attemptedToUpload:function(){return this.uploadAttempted},convertToIPMRecord:function(){var a=this.get("attach_message_class");if(!Ext.isEmpty(a))if(this.isTmpFile()){var b=this.get("entryid");c=[].concat(this.get("attach_num"));return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass(a,
{message_class:a,object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,attach_num:c,entryid:b,store_entryid:this.get("store_entryid")},b+c.join(""))}else{b=this.store.getParentRecord();c=[];if(!Ext.isFunction(b.isRecurringException)||Ext.isFunction(b.isRecurringException)&&!b.isRecurringException())c=this.getParentAttachNum(b);var c=c.concat(this.get("attach_num")),d=b.get("entryid");return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass(a,{message_class:a,object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,
attach_num:c,entryid:d,store_entryid:b.get("store_entryid")},d+c.join(""))}}});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.IPMAttachmentResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doUpdate:function(a){this.receivedRecords=this.receivedRecords.concat(this.correlateRecordFromResponse(a))},compareResponseDataToRecord:function(a,b){return a.props.name==b.get("name")}});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMAttachmentStore=Ext.extend(Zarafa.core.data.MAPISubStore,{id:null,attachmentRecordType:Zarafa.core.mapi.ObjectType.MAPI_ATTACH,constructor:function(a){a=a||{};Ext.applyIf(a,{id:Zarafa.generateId(32),proxy:new Zarafa.core.data.IPMAttachmentProxy({listModuleName:"attachments",itemModuleName:"attachments"}),writer:new Zarafa.core.data.JsonAttachmentWriter,reader:new Zarafa.core.data.JsonAttachmentReader({},Zarafa.core.data.RecordFactory.getRecordClassByCustomType(this.attachmentRecordType))});
Zarafa.core.data.IPMAttachmentStore.superclass.constructor.call(this,a);this.on({update:this.onAttachmentsChange,add:this.onAttachmentsChange,remove:this.onAttachmentsChange,datachanged:this.onAttachmentsChange,scope:this});Zarafa.core.data.ZarafaCustomEventDispatcher.addEvents("attachmentstorebeforecheck","attachmentstorebeforeupload","attachmentstorebeforedestroyrecord","attachmentstorebeforegetbaseurl")},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){a=this.getAttachmentBaseUrl(a);return Ext.urlAppend(a,"contentDispositionType=inline")},getAttachmentUrl:function(a,b){var c=this.getAttachmentBaseUrl(a,b);return Ext.urlAppend(c,"contentDispositionType=attachment")},getAttachmentBaseUrl:function(a,b){var c=this.getParentRecord(),d=c.isSubMessage(),e=container.getBaseURL();e=Ext.urlAppend(e,"load=download_attachment");
e=Ext.urlAppend(e,"store="+c.get("store_entryid"));e=Ext.urlAppend(e,"entryid="+this.getAttachmentParentRecordEntryId());if(!b||b&&d){var f=[];if(!Ext.isFunction(c.isRecurringException)||Ext.isFunction(c.isRecurringException)&&!c.isRecurringException())f=a.getParentAttachNum(c);if(a.get("attach_num")!=-1){f.push(a.get("attach_num"));for(var g=0,i=f.length;g<i;g++)e=Ext.urlAppend(e,"attachNum[]="+f[g])}else e=Ext.urlAppend(e,"attachNum[]="+a.get("tmpname"))}if(b){e=Ext.urlAppend(e,"AllAsZip=true");
if(d)e=Ext.urlAppend(e,"isSubMessage=true");e=Ext.urlAppend(e,"subject="+c.get("subject"))}e=Ext.urlAppend(e,"dialog_attachments="+this.getId());c={url:e};Zarafa.core.data.ZarafaCustomEventDispatcher.fireEvent("attachmentstorebeforegetbaseurl",this,a,b,c);return c.url},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=container.getBaseURL();a=Ext.urlAppend(a,"load=upload_attachment");a=Ext.urlAppend(a,"store="+this.getParentRecord().get("store_entryid"));a=Ext.urlAppend(a,"entryid="+this.getParentRecord().get("entryid"));return a=Ext.urlAppend(a,"dialog_attachments="+this.getId())},canUploadFiles:function(a,b){if(Ext.isEmpty(a)||a.length===0)return false;var c={handledfiles:[],checkfailed:false};Zarafa.core.data.ZarafaCustomEventDispatcher.fireEvent("attachmentstorebeforecheck",
this,a,b,c);if(c.checkfailed)return false;var d=container.getServerConfig(),e=d.getMaxAttachments(),f=d.getMaxAttachmentSize(),g=d.getMaxAttachmentTotalSize();if(Ext.isDefined(e))if(this.getCount()+a.length-c.handledfiles.length>=e){container.getNotifier().notify("error.attachment",_("Attachment error"),String.format(_("Cannot upload attachment, only {0} attachments are allowed to be added to the message"),e),b);return false}e=0;for(var i=this.sum("size"),h=0;h<a.length;h++){var k=a[h],j=k.fileSize||
k.size;if(c.handledfiles.indexOf(k)===-1){e+=j;i+=j;if(Ext.isDefined(f))if(j>f){container.getNotifier().notify("error.attachment",_("Attachment error"),String.format(_("Cannot upload attachment, attachment is {0} while the allowed maximum is {1}."),Ext.util.Format.fileSize(j),Ext.util.Format.fileSize(f)),b);return false}}}if(Ext.isDefined(g))if(i>g){container.getNotifier().notify("error.attachment",_("Attachment error"),String.format(_("Cannot upload attachment, the total attachment size is {0} while the allowed maximum is {1}"),
Ext.util.Format.fileSize(i),Ext.util.Format.fileSize(g)),b);return false}c=d.getMaxFileUploads();d=d.getMaxPostRequestSize();if(Ext.isDefined(d))if(e>d){container.getNotifier().notify("error.attachment",_("Attachment error"),String.format(_("Cannot upload attachment, total attachment is {0} while the allowed maximum attachment in single request is {1}."),Ext.util.Format.fileSize(e),Ext.util.Format.fileSize(d)),b);return false}d=a.length;if(Ext.isDefined(c))if(d>c){container.getNotifier().notify("error.attachment",
_("Attachment error"),String.format(_("Cannot upload attachment, total attachments are {0} files while the maximum {1} files are allowed in single request."),d,c),b);return false}return true},uploadFiles:function(a,b,c,d){var e=[],f=[],g=Zarafa.supportsFilesAPI()&&a instanceof FileList,i={handledfiles:[]};Zarafa.core.data.ZarafaCustomEventDispatcher.fireEvent("attachmentstorebeforeupload",this,a,b,c,d,i);for(var h=0;h<a.length;h++){var k=a[h];if(i.handledfiles.indexOf(k)===-1){var j;if(g){f.push(k);
j=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(this.attachmentRecordType,{name:k.name,size:k.size,filetype:k.type,hidden:Ext.isDefined(c)?c:false,attach_method:Zarafa.core.mapi.AttachMethod.ATTACH_BY_VALUE})}else j=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(this.attachmentRecordType,{name:Ext.util.Format.basename(k),hidden:Ext.isDefined(c)?c:false});j.file=k;e.push(j)}}this.add(e);a={};a=Ext.apply(a,d);if(g)a.attachments=f;b={params:a,requestUrl:this.getUploadAttachmentUrl(),
requestForm:b};this.batch&&this.addToBatch(++this.batchCounter);if(e.length>0){d=Ext.data.Api.actions.create;f=this.createCallback(d,e,false);this.proxy.request(d,e,b.params,this.reader,f,this,b)}},addEmbeddedAttachment:function(a){var b={entryid:a.get("entryid"),store_entryid:a.get("store_entryid"),attach_method:Zarafa.core.mapi.AttachMethod.ATTACH_EMBEDDED_MSG};Ext.isEmpty(a.get("subject"))||(b.name=a.get("subject"));Ext.isEmpty(a.get("message_class"))||(b.attach_message_class=a.get("message_class"));
Ext.isEmpty(a.get("message_size"))||(b.size=a.get("message_size"));a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.mapi.ObjectType.MAPI_ATTACH,b);this.add(a);b={params:a.data,requestUrl:this.getUploadAttachmentUrl()};var c=Ext.data.Api.actions.create,d=this.createCallback(c,a,false);this.proxy.request(c,a,b.params,this.reader,d,this,b)},destroyRecord:function(a,b){Zarafa.core.data.IPMAttachmentStore.superclass.destroyRecord.apply(this,arguments);var c={};if(b.isTmpFile()){c.deleteattachment=
true;c.attach_num=b.get("tmpname")}else{c.deleteattachment=true;c.attach_num=b.get("attach_num")}c={params:c,requestUrl:this.getUploadAttachmentUrl()};var d={options:c};Zarafa.core.data.ZarafaCustomEventDispatcher.fireEvent("attachmentstorebeforedestroyrecord",this,b,d);var e=Ext.data.Api.actions.destroy,f=this.createCallback(e,b,false);this.proxy.request(e,b,c.params,this.reader,f,this,d.options)},handleException:Ext.data.Store.prototype.handleException,createCallback:Ext.data.Store.prototype.createCallback,
onCreateRecords:Ext.data.Store.prototype.onCreateRecords,onDestroyRecords:Ext.data.Store.prototype.onDestroyRecords,reMap:Ext.data.Store.prototype.reMap,addToBatch:Ext.emptyFn,removeFromBatch:Ext.emptyFn});Ext.namespace("Zarafa.core.data");
Zarafa.core.data.IPMExpandDistlistRecord=Ext.data.Record.create([{name:"display_name"},{name:"address_type"},{name:"smtp_address"},{name:"email_address"},{name:"entryid"},{name:"search_key"},{name:"object_type",type:"int"},{name:"display_type",type:"int"},{name:"display_type_ex",type:"int"}]);
Zarafa.core.data.IPMExpandDistlistRecord=Ext.extend(Zarafa.core.data.IPMExpandDistlistRecord,{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"),entryid:this.get("entryid"),search_key:this.get("search_key"),
display_type_ex:this.get("display_type_ex"),recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO})}});Ext.namespace("Zarafa.core.data");Zarafa.core.data.IPMExpandDistlistResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doExpand:function(a){a=a.results||[];Ext.isArray(a)||(a=[a]);this.receivedRecords=this.reader.readRecords({result:a}).records}});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.getById(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.getById(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.IPMRecipientRecordFields=[{name:"entryid"},{name:"search_key"},{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:"presence_status",
type:"int"},{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}];
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(){if(this.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_MAILUSER&&Zarafa.core.EntryId.hasContactProviderGUID(this.get("entryid")))return true;return false},isPersonalDistList:function(){if(this.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&Zarafa.core.EntryId.hasContactProviderGUID(this.get("entryid")))return true;return false},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"),b=a.indexOf("_");if(b>0)a=a.substr(0,b);if(Zarafa.core.EntryId.hasContactProviderGUID(a))a=
Zarafa.core.EntryId.unwrapContactProviderEntryId(a);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)},convertToDistListRecord:function(){var a=this.get("entryid"),b=a.indexOf("_");if(b>0)a=a.substr(0,b);if(Zarafa.core.EntryId.hasContactProviderGUID(a))a=Zarafa.core.EntryId.unwrapContactProviderEntryId(a);
return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.DistList",{entryid:a,message_class:"IPM.DistList",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();this.set("entryid",a.get("entryid"));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.set("search_key",a.get("search_key"));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},formatRecipient:function(a){var b=[],c=this.get("display_name"),d=this.get("smtp_address");Ext.isEmpty(c)||b.push(c);!Ext.isEmpty(d)&&c!=d&&b.push("<"+d+">");b=b.join(" ");if(a)b=Ext.util.Format.htmlEncode(b);return b},generateOneOffEntryId:function(){var a=this.get("display_name"),b=this.get("address_type"),c=this.get("smtp_address");this.set("entryid",Zarafa.core.EntryId.createOneOffEntryId(a,b,c))},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.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.IPMResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doList:function(a){if(a.folder)this.metaData.folder=Ext.apply({},a.folder);this.receivedRecords=this.readRecordsFromResponse(a,"item")},doUpdatelist:function(a){if(a.folder)this.metaData.folder=Ext.apply({},a.folder);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},compareResponseDataToRecord:function(a,b){if(!b.phantom&&!Ext.isEmpty(b.get("attach_num")))if(Zarafa.core.EntryId.compareEntryIds(a.entryid,b.get("entryid")))if(b.get("attach_num").equals(a.props.attach_num))return true;return Zarafa.core.data.IPMResponseHandler.superclass.compareResponseDataToRecord.apply(this,arguments)}});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.RestrictionFactory={createResAnd:function(a){return[Zarafa.core.mapi.Restrictions.RES_AND,a.clone()]},createResOr:function(a){return[Zarafa.core.mapi.Restrictions.RES_OR,a.clone()]},createResNot:function(a){return[Zarafa.core.mapi.Restrictions.RES_NOT,a]},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){var d=[];if(Ext.isEmpty(c))c=a;d[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;d[Zarafa.core.mapi.Restrictions.VALUE]={};d[Zarafa.core.mapi.Restrictions.VALUE][c]=b;return d},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]=b;c.push(d);c.push(e);return c},dataResProperty:function(a,b,c,d){var e=[],f=Zarafa.core.mapi.Restrictions.RES_PROPERTY,g={};if(Ext.isEmpty(d))d=a;g[Zarafa.core.mapi.Restrictions.RELOP]=b;g[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;g[Zarafa.core.mapi.Restrictions.VALUE]={};g[Zarafa.core.mapi.Restrictions.VALUE][d]=c;e.push(f);e.push(g);return e},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){var e=[],f=Zarafa.core.mapi.Restrictions.RES_CONTENT,g={};if(Ext.isEmpty(d))d=a;g[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]=Zarafa.core.mapi.Restrictions.FL_FULLSTRING;if(Ext.isObject(b))Ext.each(b,function(i){g[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]+=i});else g[Zarafa.core.mapi.Restrictions.FUZZYLEVEL]=b;g[Zarafa.core.mapi.Restrictions.ULPROPTAG]=a;g[Zarafa.core.mapi.Restrictions.VALUE]={};g[Zarafa.core.mapi.Restrictions.VALUE][d]=c;e.push(f);e.push(g);
return e}};Ext.namespace("Zarafa.core.themes");Zarafa.core.themes.ThemeDark=Ext.extend(Zarafa.core.ThemePlugin,{});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"dark",displayName:_("Dark"),allowUserDisable:false,allowUserVisible:false,pluginConstructor:Zarafa.core.themes.ThemeDark}))});Ext.namespace("Zarafa.core.themes");Zarafa.core.themes.ThemeHighContrast=Ext.extend(Zarafa.core.ThemePlugin,{});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"highcontrast",displayName:_("High Contrast"),allowUserDisable:false,allowUserVisible:false,pluginConstructor:Zarafa.core.themes.ThemeHighContrast}))});Ext.namespace("Zarafa.core.themes");Zarafa.core.themes.ThemeLime=Ext.extend(Zarafa.core.ThemePlugin,{isCorePlugin:true});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"lime",displayName:_("Lime"),allowUserDisable:false,allowUserVisible:false,pluginConstructor:Zarafa.core.themes.ThemeLime}))});Ext.namespace("Zarafa.core.themes");Zarafa.core.themes.ThemeOrange=Ext.extend(Zarafa.core.ThemePlugin,{});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"orange",displayName:_("Orange"),allowUserDisable:false,allowUserVisible:false,pluginConstructor:Zarafa.core.themes.ThemeOrange}))});
Ext.namespace("Zarafa.core.themes");Zarafa.core.themes.ThemePurple=Ext.extend(Zarafa.core.ThemePlugin,{});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"purple",displayName:_("Purple"),allowUserDisable:false,allowUserVisible:false,pluginConstructor:Zarafa.core.themes.ThemePurple}))});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.DropdownBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.SliderNotifierPlugin,{constructor:function(a){a=a||{};Ext.applyIf(a,{itemCls:"zarafa-notifier-dropdown-item",sliderContainerPosition:"t"});Zarafa.core.ui.notifier.DropdownBoxPlugin.superclass.constructor.call(this,a)}});
Zarafa.onReady(function(){container.getNotifier().registerPlugin("dropdown",new Zarafa.core.ui.notifier.DropdownBoxPlugin);container.getNotifier().registerPlugin("eventdropdown",new Zarafa.core.ui.notifier.DropdownBoxPlugin);container.getNotifier().registerPlugin("persistentmessageplugin",new Zarafa.core.ui.notifier.DropdownBoxPlugin);container.getNotifier().registerPlugin("dialognotifier",new Zarafa.core.ui.notifier.DropdownBoxPlugin)});Ext.namespace("Zarafa.core.ui.notifier");
Zarafa.core.ui.notifier.PopupBoxPlugin=Ext.extend(Zarafa.core.ui.notifier.SliderNotifierPlugin,{constructor:function(a){a=a||{};Ext.apply(a,{itemCls:"zarafa-notifier-popup-item",sliderContainerPosition:"br",msgLifetime:5});Zarafa.core.ui.notifier.PopupBoxPlugin.superclass.constructor.call(this,a)}});Zarafa.onReady(function(){container.getNotifier().registerPlugin("popup",new Zarafa.core.ui.notifier.PopupBoxPlugin)});Ext.namespace("Zarafa.common");
Zarafa.common.CommonContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{hasToolbar:false,hasContentPanel:false});Zarafa.common.CommonContext.superclass.constructor.call(this,a);this.registerInsertionPoint("context.settings.categories",this.createDelegateSettingsCategory,this);this.registerInsertionPoint("context.settings.categories",this.createSendAsSettingsCategory,this);this.registerInsertionPoint("context.settings.categories",this.createRuleSettingsCategory,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.widgets");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");Zarafa.core.data.SharedComponentType.addProperty("common.rules.dialog.ruleswordsedit");Zarafa.core.data.SharedComponentType.addProperty("common.attachment.dialog.attachitem");Zarafa.core.data.SharedComponentType.addProperty("common.attachment.dialog.mixattachitem");Zarafa.core.data.SharedComponentType.addProperty("common.attachment.dialog.attachitem.columnmodel");Zarafa.core.data.SharedComponentType.addProperty("common.attachment.dialog.attachitem.textrenderer");
Zarafa.core.data.SharedComponentType.addProperty("common.attachment.dialog.legacyfileselection");Zarafa.core.data.SharedComponentType.addProperty("common.sendas.dialog.sendaseditcontentpanel")},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.attachment.dialog.legacyfileselection"]:case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem"]:case Zarafa.core.data.SharedComponentType["common.attachment.dialog.mixattachitem"]:case Zarafa.core.data.SharedComponentType["common.dialog.widgets"]: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"]:case Zarafa.core.data.SharedComponentType["common.rules.dialog.ruleswordsedit"]:case Zarafa.core.data.SharedComponentType["common.sendas.dialog.sendaseditcontentpanel"]: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;else if(b instanceof Zarafa.common.rules.data.RulesRecord)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.CopyMoveContentPanel;break;case Zarafa.core.data.SharedComponentType["common.dialog.recurrence"]:c=
Zarafa.common.recurrence.dialogs.RecurrenceContentPanel;break;case Zarafa.core.data.SharedComponentType["common.dialog.categories"]:c=Zarafa.common.categories.dialogs.CategoriesContentPanel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.legacyfileselection"]:c=Zarafa.common.attachment.dialogs.LegacyFileSelectionContentPanel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem"]:c=Zarafa.common.attachment.dialogs.AttachItemContentPanel;break;
case Zarafa.core.data.SharedComponentType["common.attachment.dialog.mixattachitem"]:c=Zarafa.common.attachment.dialogs.MixAttachItemContentPanel;break;case Zarafa.core.data.SharedComponentType["common.dialog.widgets"]:c=Zarafa.core.ui.widget.WidgetContentPanel;break;case Zarafa.core.data.SharedComponentType["common.dialog.checknames"]:c=Zarafa.common.checknames.dialogs.CheckNamesContentPanel;break;case Zarafa.core.data.SharedComponentType["common.dialog.restoreitems"]:c=Zarafa.common.restoreitem.dialogs.RestoreItemContentPanel;
break;case Zarafa.core.data.SharedComponentType["common.dialog.reminder"]:c=Zarafa.common.reminder.dialogs.ReminderContentPanel;break;case Zarafa.core.data.SharedComponentType["common.rules.dialog.ruleswordsedit"]:c=Zarafa.common.rules.dialogs.RulesWordsEditContentPanel;break;case Zarafa.core.data.SharedComponentType["common.sendas.dialog.sendaseditcontentpanel"]:c=Zarafa.common.sendas.dialogs.SendAsEditContentPanel;break;case Zarafa.core.data.SharedComponentType["common.create"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=
Zarafa.common.recipientfield.ui.EditRecipientContentPanel;else if(b instanceof Zarafa.common.delegates.data.DelegateRecord)c=Zarafa.common.delegates.dialogs.DelegatePermissionContentPanel;else if(b instanceof Zarafa.common.rules.data.RulesRecord)c=Zarafa.common.rules.dialogs.RulesEditContentPanel;break;case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMRecipientRecord)c=Zarafa.common.recipientfield.ui.ViewRecipientContentPanel;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)},createDelegateSettingsCategory:function(a,b,c){return{xtype:"zarafa.settingsdelegatecategory",settingsContext:c}},createSendAsSettingsCategory:function(a,b,c){return{xtype:"zarafa.settingssendascategory",settingsContext:c}},createRuleSettingsCategory:function(a,b,c){return{xtype:"zarafa.settingsrulecategory",settingsContext:c}}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"default",allowUserVisible:false,pluginConstructor:Zarafa.common.CommonContext}))});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.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.delegates.data");
Zarafa.common.delegates.data.DelegateRecordFields=[{name:"entryid",type:"string"},{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:"int"},{name:"rights_tasks",type:"int"},{name:"rights_inbox",type:"int"},{name:"rights_contacts",type:"int"},{name:"rights_notes",type:"int"},{name:"rights_journal",type:"int"}];
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){if(this===a)return true;return Zarafa.core.EntryId.compareABEntryIds(this.get("entryid"),a.get("entryid"))}});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.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.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.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.ui");
Zarafa.common.recipientfield.ui.RecipientField=Ext.extend(Zarafa.common.ui.BoxField,{defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO,filterRecipientType:undefined,delimiterCharacter:";",enableDrag:true,enableDrop:true,enableDragDrop:true,dragZone:undefined,dropZone:undefined,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"),boxMinHeight:24,boxMaxHeight:66,height:24,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.on("boxdblclick",this.onBoxDblClick,this);this.on("boxcontextmenu",this.onBoxContextMenu,this);this.on("afterrender",function(){if(this.width)this.width=undefined})},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()},update:function(a,b){if(a&&a instanceof Zarafa.core.data.MAPIRecord)b&&a.isOpened()&&this.setRecipientStore(a.getRecipientStore());else Zarafa.common.recipientfield.ui.RecipientField.superclass.update.apply(this,arguments)},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=b[c],e=this.getBoxForRecord(d);e&&e.update(d)}},onBoxStoreBeforeResolve:function(a,b){b=this.filterRecords(this.getBoxStore(),
b);for(var c=0;c<b.length;c++){var d=b[c],e=this.getBoxForRecord(d);e&&e.update(d)}},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.openViewRecipientContent(c,{manager:Ext.WindowMgr}):Zarafa.core.data.UIFactory.openCreateRecord(c,{manager:Ext.WindowMgr})},onBoxContextMenu:function(a,b,c){Zarafa.core.data.UIFactory.openDefaultContextMenu(c,
{position:b.getEl().getXY(),editable:b.editable})},initEvents:function(){Zarafa.common.recipientfield.ui.RecipientField.superclass.initEvents.apply(this,arguments);if((this.enableDrag||this.enableDragDrop)&&!this.dragZone)this.dragZone=new Zarafa.common.ui.BoxFieldDragZone(this.container,{ddGroup:"dd.mapiitem",field:this});if((this.enableDrop||this.enableDragDrop)&&!this.dropZone)this.dropZone=new Zarafa.common.recipientfield.ui.RecipientDropZone(this.container,{ddGroup:"dd.mapiitem",field:this})}});
Ext.reg("zarafa.recipientfield",Zarafa.common.recipientfield.ui.RecipientField);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.restoreitem.data");
Zarafa.common.restoreitem.data.RestoreItemRecordFields=[{name:"entryid"},{name:"parent_entryid"},{name:"store_entryid"},{name:"icon_index"},{name:"display_name"},{name:"deleted_on",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"content_count",type:"int",defaultValue:0},{name:"sender_name"},{name:"subject"},{name:"message_size",type:"int",defaultValue:0},{name:"message_class"},{name:"object_type"},{name:"message_delivery_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"message_flags",
type:"int",defaultValue:Zarafa.core.mapi.MessageFlags.MSGFLAG_READ},{name:"hasattach",type:"boolean",defaultValue:false}];
Zarafa.common.restoreitem.data.RestoreItemRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{getDefaultFolderKey:function(){},getMAPIStore:function(){return container.getHierarchyStore().getById(this.get("store_entryid"))},isIPMSubTree:function(){return false},isRead:function(){return Ext.isDefined(this.get("message_flags"))?(this.get("message_flags")&Zarafa.core.mapi.MessageFlags.MSGFLAG_READ)>0:true}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_RESTOREITEM");
Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RESTOREITEM,Zarafa.common.restoreitem.data.RestoreItemRecordFields);Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RESTOREITEM,Zarafa.common.restoreitem.data.RestoreItemRecord);Ext.namespace("Zarafa.common.rules.data");
Zarafa.common.rules.data.ActionProfiles=[{name:_("Move the message to folder ..."),value:Zarafa.common.rules.data.ActionFlags.MOVE},{name:_("Copy the message to folder ..."),value:Zarafa.common.rules.data.ActionFlags.COPY},{name:_("Delete the message"),value:Zarafa.common.rules.data.ActionFlags.DELETE},{name:_("Redirect the message to ..."),value:Zarafa.common.rules.data.ActionFlags.REDIRECT},{name:_("Forward the message to ..."),value:Zarafa.common.rules.data.ActionFlags.FORWARD},{name:_("Forward the message as attachment to ..."),
value:Zarafa.common.rules.data.ActionFlags.FORWARD_ATTACH}];Ext.namespace("Zarafa.common.rules.data");
Zarafa.common.rules.data.ConditionProfiles=[{name:_("is received from ..."),value:Zarafa.common.rules.data.ConditionFlags.RECEIVED_FROM},{name:_("includes these words in the sender's address ..."),value:Zarafa.common.rules.data.ConditionFlags.SENDER_WORDS},{name:_("includes these words in the subject ..."),value:Zarafa.common.rules.data.ConditionFlags.SUBJECT_WORDS},{name:_("includes these words in the body ..."),value:Zarafa.common.rules.data.ConditionFlags.BODY_WORDS},{name:_("has importance ..."),
value:Zarafa.common.rules.data.ConditionFlags.IMPORTANCE},{name:_("is sent to ..."),value:Zarafa.common.rules.data.ConditionFlags.SENT_TO},{name:_("is sent only to me"),value:Zarafa.common.rules.data.ConditionFlags.SENT_TO_ME_ONLY}];Ext.namespace("Zarafa.common.rules.data");
Zarafa.common.rules.data.RulesRecordFields=[{name:"rule_id",type:"number"},{name:"rule_name",type:"string"},{name:"rule_provider",type:"string",defaultValue:"RuleOrganizer"},{name:"rule_level",type:"number",defaultValue:0},{name:"rule_sequence",type:"number"},{name:"rule_state",type:"number",defaultValue:Zarafa.core.mapi.RuleStates.ST_ENABLED},{name:"rule_condition",allowBlank:false},{name:"rule_actions",allowBlank:false}];
Zarafa.common.rules.data.RulesRecord=Ext.extend(Zarafa.core.data.MAPIRecord,{baseIdProperties:["rule_id"],conditionsValid:true,actionsValid:true,copy:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RULE,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){if(this===a)return true;return this.get("rule_id")===a.get("rule_id")},isOpened:function(){return true},isValid:function(){return this.conditionsValid&&this.actionsValid&&Zarafa.common.rules.data.RulesRecord.superclass.isValid.apply(this,arguments)},setConditionsValid:function(a){this.conditionsValid=a},setActionsValid:function(a){this.actionsValid=a}});Zarafa.core.data.RecordCustomObjectType.addProperty("ZARAFA_RULE");
Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RULE,Zarafa.common.rules.data.RulesRecord);Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RULE,Zarafa.common.rules.data.RulesRecordFields);Ext.namespace("Zarafa.addressbook");
Zarafa.addressbook.AddressBookContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{hasToolbar:false,hasContentPanel:false});Zarafa.addressbook.AddressBookContext.superclass.constructor.call(this,a);Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.addressbook");Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.abuserselection");Zarafa.core.data.SharedComponentType.addProperty("addressbook.dialog.abmultiuserselection")},bidSharedComponent:function(a,
b){var c=-1;if(Ext.isArray(b))b=b[0];switch(a){case Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"]:case Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"]:case Zarafa.core.data.SharedComponentType["addressbook.dialog.abmultiuserselection"]: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&&!Zarafa.core.EntryId.hasContactProviderGUID(b.get("entryid")))c=1}break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["addressbook.dialog.addressbook"]:c=Zarafa.addressbook.dialogs.AddressBookContentPanel;break;case Zarafa.core.data.SharedComponentType["common.view"]:switch(b.get("object_type")){case Zarafa.core.mapi.ObjectType.MAPI_MAILUSER:c=
Zarafa.addressbook.dialogs.ABUserDetailContentPanel;break;case Zarafa.core.mapi.ObjectType.MAPI_DISTLIST:c=Zarafa.addressbook.dialogs.ABGroupDetailContentPanel;break;case Zarafa.core.mapi.ObjectType.MAPI_ABCONT:c=Zarafa.addressbook.dialogs.ABGroupDetailContentPanel;break}break;case Zarafa.core.data.SharedComponentType["addressbook.dialog.abuserselection"]:c=Zarafa.addressbook.dialogs.ABUserSelectionContentPanel;break;case Zarafa.core.data.SharedComponentType["addressbook.dialog.abmultiuserselection"]:c=
Zarafa.addressbook.dialogs.ABMultiUserSelectionContentPanel;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.addressbook.ui.AddressBookContextMenu;break}return c}});Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"addressbook",allowUserVisible:false,pluginConstructor:Zarafa.addressbook.AddressBookContext}))});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.AddressBookHierarchyStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"addressbook",standalone:true,proxy:new Zarafa.addressbook.AddressBookHierarchyProxy,sortInfo:{field:"display_name",direction:"desc"}});Zarafa.addressbook.AddressBookHierarchyStore.superclass.constructor.call(this,a)},idComparison:function(a,b){return Zarafa.core.EntryId.compareABEntryIds(a,b)}});Ext.reg("zarafa.addressbookhierarchystore",Zarafa.addressbook.AddressBookHierarchyStore);
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)},idComparison:function(a,b){return Zarafa.core.EntryId.compareABEntryIds(a,
b)},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.advancesearch");
Zarafa.advancesearch.AdvanceSearchContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{hasToolbar:false,hasContentPanel:false,current_view:Zarafa.common.data.Views.LIST,current_view_mode:Zarafa.common.data.ViewModes.RIGHT_PREVIEW});Zarafa.advancesearch.AdvanceSearchContext.superclass.constructor.call(this,a);this.registerInsertionPoint("main.toolbar.actions.last",this.createMainToolbarSearchViewButton,this)},createMainToolbarSearchViewButton:function(){return{xtype:"button",
scale:"large",ref:"searchView",hidden:true,iconCls:"view_icon",menu:new Zarafa.common.CommonViewButtons({context:this})}},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},getModel:function(){if(!Ext.isDefined(this.model))this.model=new Zarafa.advancesearch.AdvanceSearchContextModel;return this.model},bidSharedComponent:function(a){var b=-1;switch(a){case Zarafa.core.data.SharedComponentType["common.search"]:b=1;break}return b},
getSharedComponent:function(a){var b;switch(a){case Zarafa.core.data.SharedComponentType["common.search"]:b=Zarafa.advancesearch.dialogs.SearchContentPanel;break}return b}});Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"advancesearch",allowUserVisible:false,pluginConstructor:Zarafa.advancesearch.AdvanceSearchContext}))});Ext.namespace("Zarafa.advancesearch");
Zarafa.advancesearch.AdvanceSearchStore=Ext.extend(Zarafa.core.data.ListModuleStore,{searchFolderEntryId:undefined,searchStoreUniqueId:undefined,isBusySearching:false,constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.Search"});Zarafa.advancesearch.AdvanceSearchStore.superclass.constructor.call(this,a)},initEvents:function(){this.on("load",this.onLoad,this)},getSearchStoreUniqueId:function(){return this.searchStoreUniqueId},onLoad:function(a,b){Ext.each(b,function(c){var d=
"";switch(c.get("message_class")){case "IPM.Note":d=c.get("message_delivery_time")||c.get("last_modification_time");break;case "IPM.Task":d=c.get("task_duedate");break;case "IPM.StickyNote":d=c.get("creation_time");break;case "IPM.Appointment":d=c.get("commonstart");break;case "IPM.Schedule":case "IPM.Schedule.Meeting":case "IPM.Schedule.Meeting.Request":case "IPM.Schedule.Meeting.Canceled":d=c.get("startdate")}c.data.searchdate=d;c.commit()})},setSearchEntryId:function(a){this.searchFolderEntryId=
a},search:function(a){this.remoteSort=true;delete this.sortInfo;if(this.isExecuting(Zarafa.core.Actions.updatesearch)||this.isExecuting(Zarafa.core.Actions.search)){this.proxy.cancelRequests(Zarafa.core.Actions.updatesearch);this.proxy.cancelRequests(Zarafa.core.Actions.search)}this.hasSearchResults=false;a.useSearchFolder||this.setSearchEntryId(undefined);Zarafa.advancesearch.AdvanceSearchStore.superclass.search.apply(this,arguments)}});Ext.reg("zarafa.advancesearchstore",Zarafa.advancesearch.AdvanceSearchStore);
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 Ext.isDefined(a.isRecurringOccurence)&&a.isRecurringOccurence()?a.id+""+a.get("basedate"):a.id},destroyRecord:function(a,b,c){if(!(this.removed.indexOf(b)>-1)){if(b.isRecurring&&b.isRecurring()){var d=
[];this.each(function(i){i.id===b.id&&d.push(i)});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.isMessageClass("IPM.Appointment")||f.isMessageClass("IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"))if(f.isRecurringOccurence()){var g=this.findBy(function(j){return Zarafa.core.EntryId.compareEntryIds(f.get("entryid"),j.get("entryid"))&&Ext.isDate(f.get("basedate"))&&Ext.isDate(j.get("basedate"))&&f.get("basedate").getTime()===j.get("basedate").getTime()});if(g>=0){c.records.push(this.getAt(g));c.updatedRecords.push(f)}}else if(f.isRecurring()){g=-1;do{g=this.findBy(function(j){return(b===
Ext.data.Api.actions.destroy||!j.isRecurringException())&&Zarafa.core.EntryId.compareEntryIds(f.get("entryid"),j.get("entryid"))},undefined,g+1);if(g>=0){var i=this.getAt(g),h=f.copy(),k=i.get("basedate");Ext.isDate(k)&&h.set("basedate",k.clone());h.set("recurrence",i.get("recurrence"));h.set("startdate",i.get("startdate").clearTime(true).add(Date.MINUTE,f.get("recurrence_startocc")));h.set("duedate",i.get("startdate").clearTime(true).add(Date.MINUTE,f.get("recurrence_endocc")));h.set("commonstart",
h.get("startdate").clone());h.set("commonend",h.get("duedate").clone());h.set("duration",(h.get("duedate")-h.get("startdate"))/6E4);c.records.push(i);c.updatedRecords.push(h)}}while(g!=-1)}else if(g=this.getById(f.get("entryid"))){c.records.push(g);c.updatedRecords.push(f)}}return c},onNotifyObjectdeleted:function(){Zarafa.calendar.AppointmentStore.superclass.onNotifyObjectdeleted.apply(this,arguments);this.reload()}});Ext.reg("zarafa.appointmentstore",Zarafa.calendar.AppointmentStore);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,{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("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.showmailcontentpanel.toolbar.actions",
this.getMeetingRequestToolbarButtons,this);this.addEvents(["zoomchange"]);Zarafa.calendar.CalendarContext.superclass.constructor.call(this,a);Zarafa.core.data.SharedComponentType.addProperty("calendar.dialogs.proposenewtimecontentpanel");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);if(!Zarafa.supportsCanvas()&&this.current_view===Zarafa.calendar.data.Views.BLOCKS){this.switchView(Zarafa.calendar.data.Views.LIST,Zarafa.calendar.data.ViewModes.LIST);this.getModel().setDataMode(Zarafa.calendar.data.DataModes.ALL)}},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"]:case Zarafa.core.data.SharedComponentType["common.preview"]: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.proposenewtimecontentpanel"]: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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:if(b instanceof Zarafa.hierarchy.data.MAPIFolderRecord)if(b.isContainerClass("IPF.Appointment",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]: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"],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.AppointmentContentPanel;break;case Zarafa.core.data.SharedComponentType["common.preview"]:c=Zarafa.calendar.ui.AppointmentPreviewPanel;
break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=Zarafa.calendar.ui.CalendarContextMenu;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.proposenewtimecontentpanel"]:c=Zarafa.calendar.dialogs.ProposeNewTimeContentPanel;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestconfirmation"]:c=Zarafa.calendar.dialogs.SendMeetingRequestConfirmationContentPanel;break;case Zarafa.core.data.SharedComponentType["calendar.dialogs.sendmeetingrequestcancellation"]:c=
Zarafa.calendar.dialogs.SendMeetingRequestCancellationContentPanel;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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:c=
Zarafa.calendar.attachitem.AttachCalendarColumnModel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:c=Zarafa.calendar.attachitem.AttachCalendarRenderer;break}return c},createCalendarNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",id:"zarafa-navigationpanel-calendar-navigation",cls:"zarafa-context-navigation-block",layout:"fit",items:[{xtype:"zarafa.multiselecthierarchytree",id:"zarafa-navigationpanel-calendar-navigation-tree",
model:this.getModel(),IPMFilter:"IPF.Appointment",hideDeletedFolders:true,multiSelect:true,enableDD:true,enableItemDrop:true,deferredLoading:true,colored:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.APPOINTMENT,buttonText:_("Add Shared Calendar")}}]}]}},createDatePicker:function(){var a=new Zarafa.calendar.ui.DatePicker({id:"zarafa-navigationpanel-calendar-datepicker",navigationContext:this,showWeekNumber:true,showToday:true,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",id:"zarafa-mainpanel-contentpanel-calendar",context:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.calendar",
this)||[],b=[];if(Zarafa.supportsCanvas())b=b.concat([{id:"zarafa-maintoolbar-view-calendar-day",text:_("Day"),iconCls:"icon-calendar-day",ref:"calendarDay",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.DAY,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-calendar-workweek",text:_("Workweek"),iconCls:"icon-calendar-workweek",ref:"calendarWorkweek",valueView:Zarafa.calendar.data.Views.BLOCKS,
valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.WORKWEEK,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-calendar-week",text:_("Week"),iconCls:"icon-calendar-week",ref:"calendarWeek",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.DAYS,valueDataMode:Zarafa.calendar.data.DataModes.WEEK,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-calendar-month",text:_("Month"),
iconCls:"icon-calendar-month",ref:"calendarMonth",valueView:Zarafa.calendar.data.Views.BLOCKS,valueViewMode:Zarafa.calendar.data.ViewModes.BOX,valueDataMode:Zarafa.calendar.data.DataModes.MONTH,handler:this.onContextSelectView,scope:this}]);b.push({id:"zarafa-maintoolbar-view-calendar-list",text:_("List"),iconCls:"icon-calendar-grid",ref:"calendarList",valueView:Zarafa.calendar.data.Views.LIST,valueViewMode:Zarafa.calendar.data.ViewModes.LIST,valueDataMode:Zarafa.calendar.data.DataModes.ALL,handler:this.onContextSelectView,
scope:this});return b.concat(a)},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},setVisiblityMainToolbarButton:function(a,b){b=b||container.getCurrentContext();var c=b.getCurrentView();b===this&&c==Zarafa.calendar.data.Views.BLOCKS?a.show():a.hide()},createNewAppointmentButton:function(){return{xtype:"menuitem",id:"zarafa-maintoolbar-newitem-appointment",tooltip:_("Appointment")+" (Ctrl + Alt + A)",plugins:"zarafa.menuitemtooltipplugin",
text:_("Appointment"),handler:function(){Zarafa.calendar.Actions.openCreateAppointmentContent(this.getModel())},scope:this,iconCls:"icon_create_appointment",newMenuIndex:2,context:"calendar"}},createNewMeetingRequestButton:function(){return{xtype:"menuitem",id:"zarafa-maintoolbar-newitem-meetingrequest",tooltip:_("Meeting request")+" (Ctrl + Alt + V)",plugins:"zarafa.menuitemtooltipplugin",text:_("Meeting request"),handler:function(){Zarafa.calendar.Actions.openCreateMeetingRequestContent(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",id:"zarafa-maintoolbar-print-selectedappointment",overflowText:_("Print selected appointment"),iconCls:"icon_print_single_appt",tooltip:_("Print selected appointment")+" (Ctrl + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print selected appointment"),hideOnDisabled:false,
singleSelectOnly:true,handler:this.onPrintSelected,scope:this},{xtype:"zarafa.conditionalitem",id:"zarafa-maintoolbar-print-calendaroverview",overflowText:_("Print overview"),iconCls:"icon_print_view",text:_("Print overview"),tooltip:_("Print overview")+" (Ctrl + Alt + P)",plugins:"zarafa.menuitemtooltipplugin",handler:this.onPrintView,scope:this,hideOnDisabled:false,beforeShow:function(b){var c=b.scope.getModel().getCurrentDataMode();b.setDisabled(c==Zarafa.calendar.data.DataModes.DAY||c==Zarafa.calendar.data.DataModes.MONTH)}}].concat(a)},
onPrintSelected:function(){var a=this.getModel().getSelectedRecords();Ext.isEmpty(a)?Ext.MessageBox.alert(_("Print"),_("No appointment selected")):Zarafa.common.Actions.openPrintDialog(a)},onPrintView:function(){Zarafa.common.Actions.openPrintDialog(this)},createSettingCategories:function(a,b,c){return[{xtype:"zarafa.settingscalendarcategory",settingsContext:c}]},createMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:3,context:this.getName(),id:"mainmenu-button-calendar"}}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"calendar",displayName:_("Calendar"),allowUserVisible:false,pluginConstructor:Zarafa.calendar.CalendarContext}))});Ext.namespace("Zarafa.calendar");
Zarafa.calendar.CalendarContextModel=Ext.extend(Zarafa.core.MultiFolderContextModel,{dateRange:undefined,ignoreDateRange:false,date:undefined,oldDataMode:undefined,activeDateRange:undefined,constructor:function(a){a=a||{};if(!Ext.isDefined(a.store))a.store=new Zarafa.calendar.AppointmentStore;Ext.applyIf(a,{colorScheme:Zarafa.core.ColorSchemes.getColorSchemes(),current_data_mode:Zarafa.calendar.data.DataModes.WORKWEEK});this.date=(new Date).clearTime(true);this.dateRange=new Zarafa.core.DateRange;
this.addEvents(["datechange","daterangechange","activate"]);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,b){this.default_merge_state=container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_merge_state");Zarafa.calendar.CalendarContextModel.superclass.enable.call(this,a,true);this.setDate(this.date,true);b!==true&&this.resumeLoading()},
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,i=Date.diff(Date.SECOND,e,d);if(b){d=b.getStartDate();e=b.getDueDate();i=b.getDuration(Date.MINUTE);if(b.isAllDay()){f=true;g=Zarafa.core.mapi.BusyStatus.FREE}}return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Appointment",
{store_entryid:c.get("store_entryid"),parent_entryid:a.get("entryid"),busystatus:g,startdate:d,duedate:e,commonstart:d,commonend:e,duration:i,alldayevent:f})},load:function(){this.ignoreDateRange?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){var b=this.dateRange.clone(),c=this.ignoreDateRange;
a=a.clone();a.setHours(12);switch(this.current_data_mode){case Zarafa.calendar.data.DataModes.DAY:this.dateRange.set(a.clearTime(true),a.add(Date.DAY,1).clearTime());this.ignoreDateRange=false;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(Ext.isEmpty(e)){this.setWeekView(a);break}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.clearTime(true),d.add(Date.DAY,e).clearTime());this.ignoreDateRange=false;break;case Zarafa.calendar.data.DataModes.WEEK:this.setWeekView(a);break;case Zarafa.calendar.data.DataModes.MONTH:d=container.getSettingsModel().get("zarafa/v1/main/week_start");a=a.getFirstDateOfMonth();e=a.add(Date.MONTH,1).clearTime();this.setActiveDateRange(a,e);a=a.getPreviousWeekDay(d);d=e.getNextWeekDay(d);
this.dateRange.set(a,d);this.ignoreDateRange=false;break}if(!b.equals(this.dateRange)||c!==this.ignoreDateRange){this.load();this.fireEvent("daterangechange",this,this.dateRange,b)}},setWeekView:function(a){var b=container.getSettingsModel().get("zarafa/v1/main/week_start");a=a.getPreviousWeekDay(b);this.dateRange.set(a.clearTime(true),a.add(Date.DAY,7).clearTime());this.ignoreDateRange=false},setActiveDateRange:function(a,b){if(!Ext.isObject(this.activeDateRange))this.activeDateRange=new Zarafa.core.DateRange;
this.activeDateRange.set(a,b)},getActiveDateRange:function(){return Ext.isDefined(this.activeDateRange)?this.activeDateRange:this.dateRange},setDate:function(a,b){var c=this.date;a=a.clearTime(true);if(!(!b&&c.getTime()===a.getTime())){this.date=a;this.fireEvent("datechange",this,a,this.oldDate);this.calculateDateRange(this.date)}},moveDate:function(a){var b=this.date.clone();b.setHours(12);switch(this.current_data_mode){case Zarafa.calendar.data.DataModes.DAY:b=b.add(Date.DAY,1*a);break;case Zarafa.calendar.data.DataModes.WEEK:case Zarafa.calendar.data.DataModes.WORKWEEK:b=
b.add(Date.DAY,7*a);break;case Zarafa.calendar.data.DataModes.MONTH:b=b.add(Date.MONTH,1*a);break}this.setDate(b.clearTime())},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();switch(b){case Zarafa.calendar.data.DataModes.SEARCH:this.ignoreDateRange=true;break;case Zarafa.calendar.data.DataModes.ALL:this.ignoreDateRange=
true;this.load();break;default:this.calculateDateRange(this.date);break}},setModeAndDate:function(a,b){this.date=b.clearTime(true);this.setDataMode(a,true)},getMonthRangeText:function(){return this.date.getFirstDateOfMonth().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},setActiveFolder:function(a){this.fireEvent("activate",a,this)}});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.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.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.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.dialogs");
Zarafa.calendar.dialogs.AppointmentContentPanel=Ext.extend(Zarafa.core.ui.MessageContentPanel,{newAppointmentProps:undefined,activeTab:undefined,isPropertyChanged:false,isRecipientChanged:false,constructor:function(a){a=a||{};if(Ext.isDefined(a.activeTab))this.activeTab=a.activeTab;Ext.applyIf(a,{xtype:"zarafa.appointmentcontentpanel",layout:"fit",recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),title:_("Appointment"),confirmClose:true,items:[{xtype:"zarafa.appointmentpanel",
activeTab:this.activeTab,tbar:{xtype:"zarafa.appointmenttoolbar"}}]});Zarafa.calendar.dialogs.AppointmentContentPanel.superclass.constructor.call(this,a)},createSendValidationQueue:function(){Zarafa.calendar.dialogs.AppointmentContentPanel.superclass.createSendValidationQueue.apply(this,arguments);this.sendValidationQueue.add(this.validateSendUpdateToRecipients,this);this.sendValidationQueue.add(this.validateBusyRecipients,this)},update:function(a,b){this.updateTitleFromRecord(a,b);b&&this.updateIconFromRecord(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.MEETING_RECEIVED:if(!Ext.isDefined(this.initialConfig.closeOnSave))this.closeOnSave=true;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}}if(this.newAppointmentProps){a.beginEdit();Ext.iterate(this.newAppointmentProps,a.set,a);delete this.newAppointmentProps;a.endEdit()}var c=a.getSubStore("recipients");c&&a.isMeetingOrganized()&&this.mon(c,"resolved",this.setRecipientTypeOnResolve,this)}},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},
updateTitleFromRecord:function(a){var b=a.get("subject");if(Ext.isEmpty(b))a.get("meeting")==Zarafa.core.mapi.MeetingStatus.NONMEETING?this.setTitle(this.initialConfig.title):this.setTitle(_("Meeting"));else this.setTitle(b)},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){if(b===Ext.data.Record.COMMIT){c.isMeetingOrganized()&&this.isSending===true&&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."));this.isRecipientChanged=this.isPropertyChanged=false}else{if(c.updateModifications&&Object.keys(c.updateModifications).length>0)this.isPropertyChanged=
true;if(c.updateSubStoreModifications){if(c.updateSubStoreModifications.recipients)this.isRecipientChanged=true;else if(c.updateSubStoreModifications.attachments)this.isPropertyChanged=true;if(Object.keys(c.updateSubStoreModifications).length>1)this.isPropertyChanged=true}}Zarafa.calendar.dialogs.AppointmentContentPanel.superclass.onUpdateRecord.apply(this,arguments)},saveRecord:function(){var a=this.record;if(a.isMeetingSent()&&!a.isAppointmentInPast()&&a.getMessageAction("send")!==true)this.isRecipientChanged&&
!this.isPropertyChanged?this.sendRecord():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});else return Zarafa.calendar.dialogs.AppointmentContentPanel.superclass.saveRecord.apply(this,arguments)},sendRecord:function(){if(this.record.isMeeting())return Zarafa.calendar.dialogs.AppointmentContentPanel.superclass.sendRecord.apply(this,
arguments)},sendMeetingUpdate:function(a){a=="yes"&&this.sendRecord()},validateSendUpdateToRecipients:function(a){this.record.get("request_sent")&&!this.isPropertyChanged&&this.isRecipientChanged?Zarafa.common.dialogs.MessageBox.select(_("Send update to attendees"),_("You have made changes to the list of attendees, Choose one of the following")+":",function(b,c){if(b==="ok"){c.id=="sendModified"?this.record.addMessageAction("send_update","modified"):this.record.addMessageAction("send_update","all");
a(true)}else a(false)},this,[{boxLabel:_("Send updates to only added or deleted attendees."),id:"sendModified",name:"select",checked:true},{boxLabel:_("Send updates to all attendees."),id:"sendAll",name:"select"}]):a(true)},validateBusyRecipients:function(a){var b=this.findByType("zarafa.freebusypanel")[0],c=this.record,d=false;if(b)d=b.getModel().checkAttendeesBusyStatus(c.get("startdate"),c.get("duedate"),c.get("request_sent"));d?Ext.MessageBox.confirm(_("Zarafa WebApp"),_("One or more attendees you have invited are busy. Are you sure to invite?"),
function(e){a(e=="yes")},this):a(true)}});Ext.reg("zarafa.appointmentcontentpanel",Zarafa.calendar.dialogs.AppointmentContentPanel);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||{};Ext.applyIf(a,{xtype:"zarafa.proposenewtimepanel",layout:{type:"vbox",align:"stretch"},border:false,defaults:{border:false,bodyStyle:"padding-bottom: 5px; background-color: inherit;"},items:this.createProposeTimePanel()});Zarafa.calendar.dialogs.ProposeNewTimePanel.superclass.constructor.call(this,a);this.update(this.record,
true)},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.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.apply(this,arguments);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.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.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.ui");
Zarafa.calendar.ui.CalendarViewDropZone=Ext.extend(Ext.dd.DropZone,{dropAllowedAdd:"x-dd-drop-ok-add",headerMode:false,selectingSnapMode:Zarafa.calendar.data.SnapModes.ZOOMLEVEL,draggingSnapMode: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});Ext.EventManager.on(Ext.getDoc(),"keydown",this.onDragKeyDown,this);Ext.EventManager.on(Ext.getDoc(),"keyup",this.onDragKeyUp,this);this.proxy.setShowTime(this.selectingSnapMode===Zarafa.calendar.data.SnapModes.ZOOMLEVEL);this.proxy.setDateRange(this.dateRange);
this.updateProxy(c.getXY(),d.selections);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){Ext.EventManager.un(Ext.getDoc(),"keydown",this.onDragKeyDown,this);Ext.EventManager.un(Ext.getDoc(),"keyup",this.onDragKeyUp,this);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:if(b.calendar!==this.calendar)this.calendar.onDrop(c,
b.calendar,d.target,this.dateRange);else{b=d.selections[0];if(b.get("access")&Zarafa.core.mapi.Access.ACCESS_MODIFY)this.calendar.onMove(c,d.target,this.dateRange);else{c=b.isMeeting()?_("a meeting request"):_("an appointment");Ext.MessageBox.show({title:_("Insufficient privileges"),msg:_("You have insufficient privileges to move "+c+" in this calendar. The calendar owner can grant you these rights from: settings > delegates."),icon:"zarafa-calendar-delegate-permission",buttons:Ext.MessageBox.OK});
return false}}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,i=this.state===f.SELECTING||this.state===f.DRAGGING||this.state===f.RESIZING_DUE,h=this.dateRange.getStartDate(),k=this.dateRange.getDueDate(),
j=this.dateRange.getDuration(Date.MINUTE);if(Ext.isDate(d)){var l;l=this.state===f.DRAGGING?this.draggingSnapMode:this.selectingSnapMode;if(l===Zarafa.calendar.data.SnapModes.DAY)if(g){h=d.clearTime();if(i)k=c?c.get("alldayevent")?h.add(Date.MINUTE,c.get("duration")):h.add(Date.DAY,1):h.add(Date.DAY,1)}else{k=d.add(Date.DAY,1);if(k===h)k=k.add(Date.DAY,1)}else if(l===Zarafa.calendar.data.SnapModes.ZOOMLEVEL)if(g){h=d.floor(Date.MINUTE,e);if(i)k=c?c.get("alldayevent")?h.add(Date.MINUTE,e):h.add(Date.MINUTE,
c.get("duration")):h.add(Date.MINUTE,e)}else{k=d.ceil(Date.MINUTE,e);if(k===h)k=k.add(Date.MINUTE,e)}else{c=h.getHours()*60+h.getMinutes();h=d.getHours()*60+d.getMinutes();c=Math.max(0,c-h);h=d.clone();h=h.add(Date.MINUTE,c);h=h.add(Date.MILLI,Date.getDSTDiff(h,d));k=h.add(Date.MINUTE,j)}}switch(this.state){case f.SELECTING:if(h>this.initDate){this.dateRange.set(this.initDateRange.getStartDate(),k);this.state=f.RESIZING_DUE}else if(k<this.initDate||l===Zarafa.calendar.data.SnapModes.DAY){this.state=
f.RESIZING_START;this.dateRange.set(h,this.initDateRange.getDueDate())}break;case f.DRAGGING:this.dateRange.set(h,k);break;case f.RESIZING_START:if(h>=k){this.state=f.RESIZING_DUE;this.dateRange.set(this.initDateRange.getStartDate(),h)}else this.dateRange.setStartDate(h);break;case f.RESIZING_DUE:if(h>=k){this.state=f.RESIZING_START;this.dateRange.set(k,this.initDateRange.getDueDate())}else this.dateRange.setDueDate(k);break}}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentProxy=Ext.extend(Zarafa.calendar.ui.AppointmentView,{showTime:false,body:undefined,headerClassName:"",bodyClassName:"",constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"selection"});this.addEvents("keypress","keydown","keyup");Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.constructor.call(this,a)},init:function(){Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.init.call(this);this.body=[]},setDateRange:function(a){this.dateRange&&
this.mun(this.dateRange,"update",this.onDateRangeUpdate,this);Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.setDateRange.call(this,a);this.dateRange&&this.mon(this.dateRange,"update",this.onDateRangeUpdate,this)},render:function(){Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.render.apply(this,arguments);this.focusEl.relayEvent("keypress",this);this.focusEl.relayEvent("keydown",this);this.focusEl.relayEvent("keyup",this)},setHeaderClass:function(a){this.headerClassName=a},setBodyClass:function(a){this.bodyClassName=
a},setShowTime:function(a){this.showTime=a},createTimeText:function(){if(this.body.length>=1){var a=this.getDateRange(),b=a.getStartDate();a=a.getDueDate();b=String.format("{0} - {1}",b.format(_("G:i")),a.format(_("G:i")));if(this.getFirstBodyElement().dom.innerHTML!==b)this.getFirstBodyElement().dom.innerHTML=b}},clearTimeText:function(){if(this.body.length>0)this.getFirstBodyElement().dom.innerHTML=""},setVisible:function(a){Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.setVisible.call(this,
a);if(a){this.setBodyClass("zarafa-calendar-selection zarafa-calendar-selection-dragging zarafa-calendar-dragproxy-time");this.setHeaderClass("zarafa-calendar-selection zarafa-calendar-selection-dragging")}else{this.setBodyClass("zarafa-calendar-selection");this.setHeaderClass("zarafa-calendar-selection")}this.focusEl&&this.focusEl.show();this.rendered&&this.layout()},layoutBodyElements:function(a){this.showTime?this.createTimeText():this.clearTimeText();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)}},onDateRangeUpdate:function(){this.rendered&&this.isVisible()&&this.layout()},createBodyElement:function(){var a=this.createDiv(this.parentView.getCalendarBody(),"body");this.mon(a,"contextmenu",this.onContextMenu,this);this.mon(a,"dblclick",this.onDoubleClick,this)},destroyBodyElement:function(){var a=this.body.pop();this.mun(a,"contextmenu",this.onContextMenu,this);this.mun(a,
"dblclick",this.onDoubleClick,this);this.remove(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},layoutInHeader:function(){var a=this.parentView.dateRangeToHeaderBounds(this.getDateRange());
for(this.header||this.createHeader();this.body.length;)this.destroyBodyElement();this.header.dom.className=this.headerClassName;this.header.setLeftTop(a.left,a.top);this.header.setSize(a.right-a.left,this.parentView.getAppointmentHeaderheight())},layoutInBody:function(){var a=this.parentView.dateRangeToBodyBounds(this.dateRange);for(this.header&&this.destroyHeader();this.body.length<a.length;)this.createBodyElement();for(;this.body.length>a.length;)this.destroyBodyElement();this.layoutBodyElements(a)},
onLayout:function(){Zarafa.calendar.ui.canvas.AppointmentProxy.superclass.onLayout.call(this);this.focus()},getFirstBodyElement:function(){return this.body[0]},onContextMenu:function(a){var b=this.parentView.parentView.model.createRecord(this.parentView.getSelectedFolder(),this.getDateRange());this.parentView.fireEvent("contextmenu",this.parentView,a,b)},onDoubleClick:function(a){var b=this.parentView.parentView.model.createRecord(this.parentView.getSelectedFolder(),this.getDateRange());this.parentView.fireEvent("dblclick",
this.parentView,a,b)}});Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentView=Ext.extend(Zarafa.calendar.ui.AppointmentView,{dragHandleWidth:6,dragHandleHeight:6,opacityNonActiveAppointment:0.4,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",itemCls:"appointment"});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.canvas");
Zarafa.calendar.ui.canvas.CalendarBoxView=Ext.extend(Zarafa.calendar.ui.AbstractCalendarBoxView,{expandButtonRadius:8,expandButtonMargin:2,headerBackgroundCanvas:undefined,bodyBackgroundCanvas:undefined,bodyAppointmentCanvas:undefined,bodySelectionCanvas:undefined,appointmentOver:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",enableDD:true,ddGroup:"dd.mapiitem",bodyDropConfig:{ddGroup:"dd.mapiitem",headerMode:false,selectingSnapMode:Zarafa.calendar.data.SnapModes.DAY,
draggingSnapMode:Zarafa.calendar.data.SnapModes.NONE}});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 zarafa-canvas-header-background");this.create("div",this.headerBackgroundCanvas,"headerBackgroundCanvasStylingElement","zarafa-styling-element");this.create("div",this.headerBackgroundCanvas,
"headerBackgroundCanvasStylingElementCurrentDay","zarafa-styling-element-current-day");this.headerBackgroundCanvasStylingElement.styling={font:this.headerBackgroundCanvasStylingElement.getStyle("font"),fontSize:parseInt(this.headerBackgroundCanvasStylingElement.getStyle("font-size"),10),paddingTop:this.headerBackgroundCanvasStylingElementCurrentDay.getPadding("t"),paddingLeft:this.headerBackgroundCanvasStylingElementCurrentDay.getPadding("l"),paddingRight:this.headerBackgroundCanvasStylingElementCurrentDay.getPadding("r")};
this.headerBackgroundCanvasStylingElementCurrentDay.styling={backgroundColor:this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("background-color"),color:this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("color")};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,mouseout:this.onBodyOut,click:this.onBodyClick,dblclick:this.onBodyDblClick,contextmenu:this.onBodyContextMenu,scope:this})},createAppointment:function(a){return new Zarafa.calendar.ui.canvas.AppointmentBoxView({parentView:this,record:a,calendarColorScheme:this.calendarColorScheme})},createAppointmentProxy:function(){return new Zarafa.calendar.ui.canvas.AppointmentProxy({showTime:false})},getBodyActionCanvas:function(){return this.bodySelectionCanvas},
getBodyAppointmentCanvas:function(){return this.bodyAppointmentCanvas},getBodySelectionCanvas:function(){return this.bodySelectionCanvas},getHeaderActionCanvas:function(){return this.headerSelectionCanvas},getDesiredHeaderHeight:function(){return this.rendered?parseInt(this.headerBackgroundCanvasStylingElement.getStyle("height"),10):0},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.calendarColorScheme.base;c.fillRect(0,0,a,b);c.fillStyle=this.headerBackgroundCanvasStylingElement.getStyle("color");c.setFont(this.headerBackgroundCanvasStylingElement.getStyle("font"));a=a/this.numDaysInWeek;var d=this.getVisibleDateRange().getStartDate().clone(),e=c.lineWidth;d.setHours(12);for(var f=0;f<this.numDaysInWeek;f++){var g=d.add(Date.DAY,f).clearTime(),i=Math.round(a*f);g=this.getDayHeaderTitle(g,Math.round(a*(f+1))+e-i);c.drawText(g,i+this.headerBackgroundCanvasStylingElement.getPadding("l"),
b-Math.ceil((b-parseInt(this.headerBackgroundCanvasStylingElement.getStyle("font-size")))/2,10))}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.beginPath();for(var e=this.expandButtonRadius-2,f=0;f<4;f++){var g=Math.sin(f*2/3*Math.PI)*e+c,i=Math.cos(f*2/3*Math.PI)*e+d;f===0?a.moveTo(g,i):a.lineTo(g,i)}a.closePath();a.fillStyle=this.calendarColorScheme.base;a.fill();
a.strokeStyle="white";a.stroke()},drawDayBox:function(a,b){var c=b.right-b.left,d=b.bottom-b.top;a.save();a.translate(b.left,b.top);var e=a.convertHexRgbToDecRgba(this.calendarColorScheme.base,0.2),f;if(b.today){e=this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("background-color");f=this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("color");a.setFont(this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("font"))}else{this.headerBackgroundCanvasStylingElement.getStyle("color");
f="black";a.setFont(this.headerBackgroundCanvasStylingElement.getStyle("font"))}a.fillStyle=e;a.fillRect(0,0,c,this.dayHeaderHeight);a.fillStyle=f;a.drawText(b.date.format(_("jS")),this.headerBackgroundCanvasStylingElement.getPadding("l"),this.dayHeaderHeight-Math.ceil((this.dayHeaderHeight-parseInt(this.headerBackgroundCanvasStylingElement.getStyle("font-size")))/2)-1);if(b.active)switch(b.busyStatus){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle="white";break;case Zarafa.core.mapi.BusyStatus.BUSY:a.fillStyle=
"#d7e2f1";break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=this.calendarColorScheme.stripnormal;break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle="#e7d7ef";break;default:break}else a.fillStyle=a.convertHexRgbToDecRgba(this.calendarColorScheme.base,0.1);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)}a.beginPath();if(b.left){a.moveTo(0.5,d-0.5);a.lineTo(0.5,0.5)}else a.moveTo(0.5,0.5);b.top&&a.lineTo(c-0.5,0.5);a.strokeStyle=this.calendarColorScheme.base;a.stroke();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.lineWidth=3;b.strokeStyle=this.headerBackgroundCanvasStylingElementCurrentDay.getStyle("background-color");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},getCursorForBodyAppointment:function(a,b){return a.eventOverBodyStartHandle(b)?"w-resize":a.eventOverBodyDueHandle(b)?"e-resize":"move"},onBodyMove:function(a){var b=
"default",c=false;if(this.eventInHeader(a)||this.eventInExpandButton(a))b="pointer";else if(this.appointmentOver&&this.appointmentOver.eventOverBody(a))c=this.appointmentOver;else for(var d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverBody(a)){c=f;break}}if(c)b=this.getCursorForBodyAppointment(c,a);if(this.appointmentOver!==c){this.appointmentOver&&this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),a);(this.appointmentOver=c)&&this.fireEvent("appointmentmouseover",
this,c.getRecord(),a)}this.getBodyActionCanvas().dom.style.cursor=b},onBodyOut:function(a){if(this.appointmentOver&&!this.appointmentOver.eventOverBody(a)){this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),a);this.appointmentOver=false}},onBodyClick:function(a){if(this.eventInHeader(a)||this.eventInExpandButton(a)){a=a.getXY();this.fireEvent("dayclick",this,this.screenLocationToDate(a[0],a[1]))}},onMouseMove:function(a){this.onBodyMove(a)},getRecordForEvent:function(a){if(this.eventInDay(a))for(var b=
0,c=this.appointments.length;b<c;b++){var d=this.appointments[b];if(d.eventOverBody(a))return d.getRecord()}},onBodyDblClick:function(a){var b=this.getRecordForEvent(a);this.fireEvent("dblclick",this,a,b)},onBodyContextMenu:function(a){var b=this.getRecordForEvent(a),c;if(!b){c=a.getXY();c=this.screenLocationToDateRange(c[0],c[1])}this.fireEvent("contextmenu",this,a,b,c)},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())},removeChildView:function(a){if(this.appointmentOver&&
this.appointmentOver===a){this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord());this.appointmentOver=false}return Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.removeChildView.apply(this,arguments)},onLayout:function(){this.doGreedyColoring(this.appointments,true);Zarafa.calendar.ui.canvas.CalendarBoxView.superclass.onLayout.call(this);Zarafa.core.ColorSchemes.getLuma(this.calendarColorScheme.base)<155?this.headerBackgroundCanvasStylingElement.removeClass("light-background"):
this.headerBackgroundCanvasStylingElement.addClass("light-background");this.body.setHeight(this.parentView.scrollable.getHeight());this.calculateDayBoxConfigurations();this.drawDayHeaders();this.drawDays()}});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,appointmentOver:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{baseCls:"zarafa-calendar",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 zarafa-canvas-header-background");this.create("div",this.headerBackgroundCanvas,"headerBackgroundCanvasStylingElement","zarafa-styling-element");this.create("div",this.headerBackgroundCanvas,"headerBackgroundCanvasStylingElementActive","zarafa-styling-element-active");this.create("canvas",this.header,"headerAppointmentCanvas",
"zarafa-canvas zarafa-canvas-layer-2 zarafa-canvas-header-appointment");this.create("canvas",this.header,"headerSelectionCanvas","zarafa-canvas zarafa-canvas-layer-3 zarafa-canvas-header-selection");this.create("canvas",this.body,"bodyBackgroundCanvas","zarafa-canvas zarafa-canvas-layer-1 zarafa-canvas-body-background");this.create("canvas",this.body,"bodyAppointmentCanvas","zarafa-canvas zarafa-canvas-layer-2 zarafa-canvas-body-appointment");this.create("canvas",this.body,"bodySelectionCanvas","zarafa-canvas zarafa-canvas-layer-3 zarafa-canvas-body-selection");
this.mon(this.getHeaderActionCanvas(),{mousemove:this.onHeaderMove,mouseout:this.onHeaderOut,dblclick:this.onHeaderDblClick,contextmenu:this.onHeaderContextMenu,click:this.onHeaderClick,scope:this});this.mon(this.getBodyActionCanvas(),{mousemove:this.onBodyMove,mouseout:this.onBodyOut,dblclick:this.onBodyDblClick,contextmenu:this.onBodyContextMenu,scope:this})},createAppointment:function(a){return new Zarafa.calendar.ui.canvas.AppointmentDaysView({parentView:this,record:a,calendarColorScheme:this.calendarColorScheme})},
removeChildView:function(a){if(this.appointmentOver&&this.appointmentOver===a){this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord());this.appointmentOver=false}return Zarafa.calendar.ui.canvas.CalendarDaysView.superclass.removeChildView.apply(this,arguments)},createAppointmentProxy:function(){return new Zarafa.calendar.ui.canvas.AppointmentProxy({showTime:true})},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.calendarColorScheme.header;e.fillRect(0,0,c,d);for(var f=0,g=a.length;f<g;f++){var i=a[f];if(i.today)b=i}c=this.parentView.headerTextHeight;if(Ext.isDefined(b)){f=b.left;g=b.right;e.fillStyle=this.headerBackgroundCanvasStylingElementActive.getStyle("background-color");e.fillRect(f,0,g-f-1,c);e.strokeStyle=this.headerBackgroundCanvasStylingElementActive.getStyle("background-color");e.strokeRect(f+0.5,0.5,g-f-1,d)}e.fillStyle=
this.headerBackgroundCanvasStylingElement.getStyle("color");e.setFont(this.headerBackgroundCanvasStylingElement.getStyle("font"));f=0;for(g=a.length;f<g;f++){i=a[f];b=i.right-i.left;d=this.getDayHeaderTitle(i.date,b);b=e.textWidth(d)-b-this.headerBackgroundCanvasStylingElement.getPadding("lr");if(b>0){d=Ext.util.Format.substr(d,0,d.length-(b/e.getFontSize()+2));e.textWidth(d)}if(i.today){e.save();e.fillStyle=this.headerBackgroundCanvasStylingElementActive.getStyle("color");e.setFont(this.headerBackgroundCanvasStylingElementActive.getStyle("font"))}e.drawText(d,
i.left+this.headerBackgroundCanvasStylingElement.getPadding("l"),(c+e.getFontSize())/2-2);i.today&&e.restore()}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.calendarColorScheme.stripnormal;g.fillRect(0,0,c,f);g.fillStyle=this.calendarColorScheme.stripworking;for(var i=0,h=a.length;i<h;i++){var k=a[i];k.workingDay&&g.fillRect(k.left,e,k.right-k.left,d-e)}d=this.parentView.timeUnitHeight;e=Math.round(f/d);for(i=0;i<e;i++){g.strokeStyle=this.calendarColorScheme.linenormal;h=(i+1)*d-1;g.strokeLine(0,h+0.5,c,h+0.5)}g.strokeStyle=this.calendarColorScheme.linenormal;i=0;for(h=a.length;i<h;i++){k=a[i];g.strokeLine(k.left+0.5,0,k.left+
0.5,f);if(k.today)b=k}g.strokeLine(c-0.5,0,c-0.5,f);if(Ext.isDefined(b)){g.strokeStyle=this.headerBackgroundCanvasStylingElementActive.getStyle("background-color");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))},getCursorForBodyAppointment:function(a,
b){return a.eventOverBodyStartHandle(b)?"n-resize":a.eventOverBodyDueHandle(b)?"s-resize":"move"},onBodyMove:function(a){var b="default",c=false;if(this.appointmentOver&&this.appointmentOver.eventOverBody(a))c=this.appointmentOver;else for(var d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverBody(a)){c=f;break}}if(c)b=this.getCursorForBodyAppointment(c,a);if(this.appointmentOver!==c&&(!this.bodyDragZone||this.bodyDragZone.dragging===false)&&(!this.headerDragZone||this.headerDragZone.dragging===
false)){this.appointmentOver&&this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),a);(this.appointmentOver=c)&&this.fireEvent("appointmentmouseover",this,c.getRecord(),a)}this.getBodyActionCanvas().dom.style.cursor=b},onBodyOut:function(a){if(this.appointmentOver&&!this.appointmentOver.eventOverBody(a)){this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),a);this.appointmentOver=false}},getCursorForHeaderAppointment:function(a,b){return a.eventOverHeaderStartHandle(b)?
"w-resize":a.eventOverHeaderDueHandle(b)?"e-resize":"move"},onHeaderMove:function(a){var b="default",c=false;if(this.eventInHeader(a))b="pointer";else if(this.appointmentOver&&this.appointmentOver.eventOverHeader(a))c=this.appointmentOver;else for(var d=0,e=this.appointments.length;d<e;d++){var f=this.appointments[d];if(f.eventOverHeader(a)){c=f;break}}if(c)b=this.getCursorForHeaderAppointment(c,a);if(this.appointmentOver!==c){this.appointmentOver&&this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),
a);(this.appointmentOver=c)&&this.fireEvent("appointmentmouseover",this,c.getRecord(),a)}this.getHeaderActionCanvas().dom.style.cursor=b},onHeaderOut:function(a){if(this.appointmentOver&&!this.appointmentOver.eventOverBody(a)){this.fireEvent("appointmentmouseout",this,this.appointmentOver.getRecord(),a);this.appointmentOver=false}},onHeaderClick:function(a){if(this.eventInHeader(a)){a=a.getXY();this.fireEvent("dayclick",this,this.screenLocationToDate(a[0],a[1]))}},onMouseMove:function(a){var b={x:this.header.getX(),
y:this.header.getY(),width:this.header.getWidth(),height:this.header.getHeight()};Zarafa.core.Util.inside(b,a.getPageX(),a.getPageY())?this.onHeaderMove(a):this.onBodyMove(a)},getRecordForHeaderEvent:function(a){for(var b=0,c=this.appointments.length;b<c;b++){var d=this.appointments[b];if(d.eventOverHeader(a))return d.getRecord()}},onHeaderDblClick:function(a){var b=this.getRecordForHeaderEvent(a);this.fireEvent("dblclick",this,a,b)},onHeaderContextMenu:function(a){var b=this.getRecordForHeaderEvent(a),
c;if(!b){c=a.getXY();c=this.screenLocationToDateRange(c[0],c[1])}this.fireEvent("contextmenu",this,a,b,c)},getRecordForBodyEvent:function(a){for(var b=0,c=this.appointments.length;b<c;b++){var d=this.appointments[b];if(d.eventOverBody(a))return d.getRecord()}},onBodyDblClick:function(a){var b=this.getRecordForBodyEvent(a);this.fireEvent("dblclick",this,a,b)},onBodyContextMenu:function(a){var b=this.getRecordForBodyEvent(a),c;if(!b){c=a.getXY();c=this.screenLocationToDateRange(c[0],c[1])}this.fireEvent("contextmenu",
this,a,b,c)},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);Zarafa.core.ColorSchemes.getLuma(this.calendarColorScheme.base)<155?this.headerBackgroundCanvasStylingElement.removeClass("light-background"):this.headerBackgroundCanvasStylingElement.addClass("light-background");
var a=this.calculateDayLayoutPositions();this.drawHeader(a);this.drawBody(a)}});Ext.namespace("Zarafa.contact");
Zarafa.contact.ContactContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{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("context.common.recipientfield.contextmenu.actions",
this.createContactFromRecipientButton,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");a=container.getServerConfig().getContactPrefix();if(Ext.isDefined(a)&&Ext.isArray(a))Zarafa.contact.data.config.Prefix=Zarafa.contact.data.config.Prefix.concat(a);a=container.getServerConfig().getContactSuffix();if(Ext.isDefined(a)&&Ext.isArray(a))Zarafa.contact.data.config.Suffix=Zarafa.contact.data.config.Suffix.concat(a)},
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"]:case Zarafa.core.data.SharedComponentType["common.preview"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass(["IPM.Contact","IPM.DistList"],
true))c=1;else if(b instanceof Zarafa.core.data.MAPIRecord){var d=b.get("entryid");if(d&&Zarafa.core.EntryId.hasContactProviderGUID(d))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;else if(b instanceof Zarafa.core.data.IPMAttachmentRecord&&b.isContactPhoto())c=2;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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:if(b instanceof Zarafa.hierarchy.data.MAPIFolderRecord)if(b.isContainerClass("IPF.Contact",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass(["IPM.Contact","IPM.DistList"],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"]:if(b instanceof
Zarafa.core.data.IPMRecord)if(b.isMessageClass("IPM.Contact",true))c=Zarafa.contact.dialogs.ContactContentPanel;else{if(b.isMessageClass("IPM.DistList",true))c=Zarafa.contact.dialogs.DistlistContentPanel}else if(b instanceof Zarafa.core.data.MAPIRecord){var d=b.get("entryid");if(d&&Zarafa.core.EntryId.hasContactProviderGUID(d))if(b.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_MAILUSER)c=Zarafa.contact.dialogs.ContactContentPanel;else if(b.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_DISTLIST)c=
Zarafa.contact.dialogs.DistlistContentPanel}break;case Zarafa.core.data.SharedComponentType["common.preview"]:c=Zarafa.contact.ui.ContactPreviewPanel;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.namedetails"]:c=Zarafa.contact.dialogs.ContactNameContentPanel;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.addressdetails"]:c=Zarafa.contact.dialogs.ContactAddressContentPanel;break;case Zarafa.core.data.SharedComponentType["contact.dialog.contact.phonedetails"]:c=
Zarafa.contact.dialogs.ContactPhoneContentPanel;break;case Zarafa.core.data.SharedComponentType["contact.dialog.distlist.externalmember"]:c=Zarafa.contact.dialogs.DistlistExternalMemberContentPanel;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=b instanceof Zarafa.core.data.IPMAttachmentRecord&&b.isContactPhoto()?Zarafa.contact.ui.ContactPhotoContextMenu: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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:c=Zarafa.contact.attachitem.AttachContactColumnModel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:c=
b.isMessageClass("IPM.DistList",true)?Zarafa.contact.attachitem.AttachDistlistRenderer:Zarafa.contact.attachitem.AttachContactRenderer;break}return c},createContactNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",id:"zarafa-navigationpanel-contacts-navigation",cls:"zarafa-context-navigation-block",layout:"fit",items:[{xtype:"zarafa.hierarchytreepanel",id:"zarafa-navigationpanel-contacts-navigation-tree",model:this.getModel(),IPMFilter:"IPF.Contact",
hideDeletedFolders:true,enableDD:true,enableItemDrop:true,deferredLoading: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",id:"zarafa-mainpanel-contentpanel-contacts",context:this}},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.contact",
this)||[];return[{id:"zarafa-maintoolbar-view-contacts-businesscards",text:_("Business Cards"),overflowText:_("Business Cards"),iconCls:"icon_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},{id:"zarafa-maintoolbar-view-contacts-phonlist",text:_("Phone List"),overflowText:_("Phone List"),iconCls:"icon_contact_list",valueView:Zarafa.contact.data.Views.LIST,
valueViewMode:Zarafa.contact.data.ViewModes.PHONE_LIST,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",id:"zarafa-maintoolbar-newitem-contact",text:_("Contact"),tooltip:_("Contact")+" (Ctrl + Alt + C)",plugins:"zarafa.menuitemtooltipplugin",handler:function(){Zarafa.contact.Actions.openCreateContactContent(this.getModel())},
scope:this,iconCls:"icon_createContact",newMenuIndex:3,context:"contact"}},createContactFromRecipientButton:function(){return{xtype:"zarafa.conditionalitem",text:_("Add to contacts"),iconCls:"icon_new_contact",handler:Zarafa.contact.Actions.openRecipientContactContent,scope:this}},getMainToolbarPrintButtons:function(){var a=container.populateInsertionPoint("main.toolbar.print.contact",this)||[];return[{xtype:"zarafa.conditionalitem",id:"zarafa-maintoolbar-print-selectedcontact",overflowText:_("Print selected contact"),
iconCls:"icon_print_single_contact",tooltip:_("Print selected contact")+" (Ctrl + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print selected contact"),hideOnDisabled:false,singleSelectOnly:true,handler:this.onPrintSingle,scope:this}].concat(a)},onPrintSingle:function(){var a=this.getModel().getSelectedRecords();Ext.isEmpty(a)?Ext.MessageBox.alert(_("Print"),_("No contact selected")):Zarafa.common.Actions.openPrintDialog(a)},createNewDistributionListButton:function(){return{xtype:"menuitem",
id:"zarafa-maintoolbar-newitem-distlist",tooltip:_("Distribution list")+" (Ctrl + Alt + D)",plugins:"zarafa.menuitemtooltipplugin",text:_("Distribution list"),handler:function(){Zarafa.contact.Actions.openCreateDistlistContent(this.getModel())},scope:this,iconCls:"icon_createDistributionList",newMenuIndex:3,context:"contact"}},createMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:4,context:this.getName(),id:"mainmenu-button-contacts"}},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.core.ContextMetaData({name:"contact",displayName:_("Contacts"),allowUserVisible:false,pluginConstructor:Zarafa.contact.ContactContext}))});Ext.namespace("Zarafa.contact");
Zarafa.contact.ContactStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.Contact",defaultSortInfo:{field:"fileas",direction:"desc"}});Zarafa.contact.ContactStore.superclass.constructor.call(this,a)}});Ext.reg("zarafa.contactstore",Zarafa.contact.ContactStore);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";
if(Zarafa.core.EntryId.hasContactProviderGUID(a))a=Zarafa.core.EntryId.unwrapContactProviderEntryId(a);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.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.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.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.apply(this,arguments);b.members=Ext.pluck(a.getMemberStore().getRange(),"data");for(var c=0;c<b.members.length;c++){b.members[c]=Ext.apply({},b.members[c]);var d=b.members[c];for(var e in d)if(Ext.isString(d[e]))d[e]=Ext.util.Format.htmlEncode(d[e])}return b}});Ext.namespace("Zarafa.hierarchy");
Zarafa.hierarchy.HierarchyContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{hasToolbar:false,hasContentPanel:false});Zarafa.hierarchy.HierarchyContext.superclass.constructor.call(this,a);Zarafa.core.data.SharedComponentType.addProperty("hierarchy.dialog.folderselection");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.folderselection"]: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.CreateFolderContentPanel;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderselection"]:b=Zarafa.hierarchy.dialogs.FolderSelectionContentPanel;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.folderproperties"]:b=Zarafa.hierarchy.dialogs.FolderPropertiesContentPanel;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.foldersize"]:b=
Zarafa.hierarchy.dialogs.FolderSizeContentPanel;break;case Zarafa.core.data.SharedComponentType["hierarchy.dialog.opensharedfolder"]:b=Zarafa.hierarchy.dialogs.SharedFolderContentPanel;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:b=Zarafa.hierarchy.ui.ContextMenu;break}return b}});Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"hierarchy",allowUserVisible:false,pluginConstructor:Zarafa.hierarchy.HierarchyContext}))});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],i=this.store.getById(g.entryid);if(i)f.folderdelete?this.addNotification(Zarafa.core.data.Notifications.objectDeleted,i,g):this.addNotification(Zarafa.core.data.Notifications.objectModified,
i,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)},doStores:function(a){a=a.item;for(var b=Ext.pluck(a,"store_entryid"),c=[],d=0,e=b.length;d<e;d++){var f=this.store.getById(b[d]);Ext.isDefined(f)&&c.push(f)}this.addNotification(Zarafa.core.data.Notifications.objectModified,
c,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.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},{name:"is_unavailable",type:"boolean",defaultValue:false}];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,{commit:function(){if(this.cacheParentFolder)Zarafa.core.EntryId.compareEntryIds(this.get("parent_entryid"),this.cacheParentFolder.get("entryid"))||delete this.cacheParentFolder;Zarafa.hierarchy.data.MAPIFolderRecord.superclass.commit.apply(this,arguments)},getMAPIStore:function(){var a=this.getStore();if(a&&a instanceof Zarafa.hierarchy.data.IPFSubStore)return a.getParentRecord();else{a=container.getHierarchyStore();return a.getById(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(){var a=this.getMAPIStore();
if(a)return a.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},isRSSFolder:function(){return Zarafa.core.ContainerClass.isClass(this.get("container_class"),"IPF.Note.OutlookHomepage",true)&&this.getParentFolder().isIPMSubTree()},getDisplayName:function(){return this.isIPMSubTree()?
this.getMAPIStore().get("display_name"):this.get("display_name")},getFullyQualifiedDisplayName:function(){var a=this.getMAPIStore();return this.isIPMSubTree()?this.getDisplayName():a.isPublicStore()?String.format(_("{0} in {1}"),this.getDisplayName(),a.get("display_name")):a.isSharedStore()?String.format(_("{0} of {1}"),this.getDisplayName(),a.get("mailbox_owner_name")):this.getDisplayName()},getParentFolder:function(){if(!this.cacheParentFolder){var a=this.get("parent_entryid");if(!this.isIPMSubTree()&&
!Ext.isEmpty(a))this.cacheParentFolder=this.getMAPIFolderStore().getById(a);if(this.cacheParentFolder)this.cacheParentFolder.data.has_subfolder=true}return this.cacheParentFolder},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(){var a=[];this.get("has_subfolder")&&
this.getMAPIFolderStore().each(function(b){this===b.getParentFolder()&&a.push(b)},this);return a},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.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:"mapping_signature"},{name:"subtree_entryid"},{name:"store_support_mask",type:"int"},{name:"store_size",type:"int",defaultValue:null},{name:"quota_warning",type:"int",defaultValue:null},{name:"quota_soft",type:"int",defaultValue:null},{name:"quota_hard",type:"int",defaultValue:null},
{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.getById(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},isArchiveStore:function(){return this.get("mdb_provider")===Zarafa.core.mapi.MDBProvider.ZARAFA_STORE_ARCHIVER_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,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.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.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.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.mail");
Zarafa.mail.MailContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{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.common.ui.PreviewPanelToolbarButtons({model:this.getModel()});this.registerInsertionPoint("previewpanel.toolbar.right",a.getToolbarButtons,a);this.registerInsertionPoint("context.addressbook.contextmenu.actions",this.createSendEmailContextItem,this);this.registerInsertionPoint("context.contact.contextmenu.actions",this.createSendEmailContextItem,this);this.registerInsertionPoint("context.contact.contactcontentpanel.toolbar.actions",
this.createSendEmailButton,this);this.registerInsertionPoint("context.contact.distlistcontentpanel.toolbar.actions",this.createSendEmailButton,this);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,livescrollstart:this.onModelLiveScrollStart,livescrollstop:this.onModelLiveScrollStop,scope:this})}return this.model},onModelLiveScrollStart:function(){if(this.getCurrentView()!==Zarafa.mail.data.Views.LIVESCROLL&&this.getCurrentViewMode()!==Zarafa.mail.data.ViewModes.LIVESCROLL){if(Zarafa.mail.data.ViewModes.isMainViewMode(this.getCurrentViewMode())){this.oldView=this.getCurrentView();this.oldViewMode=this.getCurrentViewMode()}this.switchView(Zarafa.mail.data.Views.LIVESCROLL,
Zarafa.mail.data.ViewModes.LIVESCROLL)}},onModelLiveScrollStop:function(){Zarafa.mail.data.ViewModes.isMainViewMode(this.getCurrentViewMode())?this.switchView(this.getCurrentView(),this.getCurrentViewMode()):this.switchView(this.oldView,this.oldViewMode);delete this.oldView;delete this.oldViewMode},onModelSearchStart:function(){if(this.getCurrentView()!==Zarafa.mail.data.Views.SEARCH&&this.getCurrentViewMode()!==Zarafa.mail.data.ViewModes.SEARCH){if(Zarafa.mail.data.ViewModes.isMainViewMode(this.getCurrentViewMode())){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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:if(b instanceof
Zarafa.hierarchy.data.MAPIFolderRecord)if(b.isContainerClass("IPF.Note",true))c=1;else if(b.isContainerClass("IPF",true))c=0;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:if(b instanceof Zarafa.core.data.IPMRecord)if(b.isMessageClass(["IPM.Note","REPORT.IPM","REPORT.IPM.Note"],true))c=1;else if(b.isMessageClass("IPM",true))c=0;break}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.create"]:c=
Zarafa.mail.dialogs.MailCreateContentPanel;break;case Zarafa.core.data.SharedComponentType["common.view"]:c=Zarafa.mail.dialogs.ShowMailContentPanel;break;case Zarafa.core.data.SharedComponentType["mail.dialog.options"]:c=!b||b.phantom||b.isUnsent()?Zarafa.mail.dialogs.MailCreateOptionsContentPanel:Zarafa.mail.dialogs.MailViewOptionsContentPanel;break;case Zarafa.core.data.SharedComponentType["mail.dialog.flags"]:c=Zarafa.mail.dialogs.MailFlagsContentPanel;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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:c=Zarafa.mail.attachitem.AttachMailColumnModel;
break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:c=Zarafa.mail.attachitem.AttachMailRenderer;break}return c},createContentPanel:function(){return{xtype:"zarafa.mailpanel",id:"zarafa-mainpanel-contentpanel-mail",context:this}},createMailNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",id:"zarafa-navigationpanel-mail-navigation",cls:"zarafa-context-navigation-block",ref:"mailnavigation",layout:"fit",
items:[{xtype:"zarafa.hierarchytreepanel",id:"zarafa-navigationpanel-mail-navigation-tree",model:this.getModel(),IPMFilter:"IPF.Note",hideDeletedFolders:false,enableDD:true,enableItemDrop:true,deferredLoading:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.MAIL,buttonText:_("Open Shared Mails")}}]}]}},createNewMailButton:function(){return{xtype:"menuitem",id:"zarafa-maintoolbar-newitem-mail",tooltip:_("Email message")+" (Ctrl + Alt + X)",plugins:"zarafa.menuitemtooltipplugin",
text:_("Email message"),iconCls:"icon_createEmailMessage",newMenuIndex:1,context:"mail",handler:function(){Zarafa.mail.Actions.openCreateMailContent(this.getModel())},scope:this}},createSendEmailContextItem:function(){return{text:_("Send E-mail"),iconCls:"icon_send_email_to_recipient",scope:this,handler:function(a){Zarafa.mail.Actions.openCreateMailContentForContacts(this.getModel(),a.parentMenu.records)},beforeShow:function(a,b){for(var c=false,d=0,e=b.length;d<e;d++)if(this.isSendEmailButtonVisible(b[d])){c=
true;break}a.setVisible(c)}}},createSendEmailButton:function(){return{xtype:"button",plugins:["zarafa.recordcomponentupdaterplugin"],iconCls:"icon_send_email_to_recipient",overflowText:_("Send E-mail"),tooltip:{title:_("Send E-mail"),text:_("Create a new email message addressed to this recipient.")},handler:function(a){Zarafa.mail.Actions.openCreateMailContentForContacts(this.getModel(),a.record)},scope:this,update:function(a,b){this.record=a;if(b)this.scope.isSendEmailButtonVisible(a)||this.hide()}}},
isSendEmailButtonVisible:function(a){if(a.phantom)return false;else if(a.isMessageClass("IPM.Contact"))if(!a.hasEmailAddress())return false;return true},createSettingCategories:function(a,b,c){return[{xtype:"zarafa.settingsmailcategory",settingsContext:c},{xtype:"zarafa.settingsoutofofficecategory",settingsContext:c}]},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.mail",this)||[];return[{id:"zarafa-maintoolbar-view-mail-nopreview",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},{id:"zarafa-maintoolbar-view-mail-previewright",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},{id:"zarafa-maintoolbar-view-mail-previewbottom",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",id:"zarafa-maintoolbar-print-singlemail",overflowText:_("Print single e-mail"),iconCls:"icon_print_single",tooltip:_("Print single e-mail")+" (Ctrl + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print single e-mail"),hideOnDisabled:false,singleSelectOnly:true,handler:this.onPrintSingle,scope:this}].concat(a)},onPrintSingle:function(){var a=this.getModel().getSelectedRecords();
Ext.isEmpty(a)?Ext.MessageBox.alert(_("Print"),_("No message selected")):Zarafa.common.Actions.openPrintDialog(a)},onPrintList:function(){Zarafa.common.Actions.openPrintDialog(this)},createMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:2,context:this.getName(),id:"mainmenu-button-mail"}}});Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"mail",displayName:_("Mail"),allowUserVisible:false,pluginConstructor:Zarafa.mail.MailContext}))});Ext.namespace("Zarafa.mail");
Zarafa.mail.MailStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.Note",defaultSortInfo:{field:"message_delivery_time",direction:"desc"}});Zarafa.mail.MailStore.superclass.constructor.call(this,a);Zarafa.core.PresenceManager.registerStore(this,["sender","received_by","sent_representing"])},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 i=-1;do{i=this.findExact("goid2",g,i+1);if(i>=0){var h=this.getAt(i);if(f.equals(h)){c.records.push(this.getAt(i));c.updatedRecords.push(f)}else if(h.isOpened()){h.opened=false;c.records.push(h);c.updatedRecords.push({})}}}while(i!=
-1)}}else return Zarafa.mail.MailStore.superclass.getRecordsForUpdateData.apply(this,arguments)}return c}});Ext.reg("zarafa.mailstore",Zarafa.mail.MailStore);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.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.dialogs");
Zarafa.mail.dialogs.MailCreateContentPanel=Ext.extend(Zarafa.core.ui.MessageContentPanel,{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");a.plugins=Ext.value(a.plugins,[]);container.getSettingsModel().get("zarafa/v1/contexts/mail/autosave_enable")===true&&a.plugins.push({ptype:"zarafa.autosavemessageplugin"});Ext.applyIf(a,
{xtype:"zarafa.mailcreatecontentpanel",layout:"fit",title:_("E-Mail"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),closeOnSend:true,confirmClose:true,items:[{xtype:"zarafa.mailcreatepanel",ref:"mainPanel",use_html_editor:a.use_html_editor,tbar:{xtype:"zarafa.mailcreatetoolbar"}}]});this.addEvents("bcctoggle","fromtoggle");Zarafa.mail.dialogs.MailCreateContentPanel.superclass.constructor.call(this,a)},displayInfoMask:function(){if(this.showInfoMask!==
false)if(this.isSaving&&!this.isSending)this.savingEl=container.getNotifier().notify("info.mailsaving",_("Saving..."),{toolbar:this.mainPanel.getTopToolbar()});else Zarafa.mail.dialogs.MailCreateContentPanel.superclass.displayInfoMask.apply(this,arguments)},hideInfoMask:function(a){if(this.showInfoMask!==false)if(this.isSaving&&!this.isSending){var b;b=a===false?_("Message saving failed."):String.format(_("Message Saved at {0}."),this.record.get("last_modification_time").format(_("g:i A")));container.getNotifier().notify("info.mailsaved",
b,{toolbar:this.mainPanel.getTopToolbar()})}else Zarafa.mail.dialogs.MailCreateContentPanel.superclass.hideInfoMask.apply(this,arguments)},update:function(a,b){var c=false;if(b){if(!a.userIsStoreOwner()){var d=container.getHierarchyStore().getById(a.get("store_entryid"));a.setDelegatorInfo(d)}d=container.getSettingsModel().get("zarafa/v1/contexts/mail/sendas",true);Ext.isEmpty(d)||(c=true);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,false);this.fireEvent("fromtoggle",this,this.showfrom||c,false);if(this.inputAutoFocusPlugin)switch(a.getMessageAction("action_type")){case Zarafa.mail.data.ActionTypes.REPLY:case Zarafa.mail.data.ActionTypes.REPLYALL:case Zarafa.mail.data.ActionTypes.EDIT_AS_NEW:this.inputAutoFocusPlugin.setAutoFocus("zarafa.editorfield");
break;case Zarafa.mail.data.ActionTypes.FORWARD:case Zarafa.mail.data.ActionTypes.FORWARD_ATTACH:default:this.inputAutoFocusPlugin.setAutoFocus(this.mainPanel.toRecipientField);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,false)}if(a.isModifiedSinceLastUpdate("sent_representing_email_address")){Ext.isEmpty(a.get("sent_representing_email_address"))||
(c=true);this.fireEvent("fromtoggle",this,this.showfrom||c,false)}}this.updateTitleFromRecord(a);b&&this.updateIconFromRecord(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},updateTitleFromRecord:function(a){a=a.get("subject");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)},initStateEvents:function(){Zarafa.mail.dialogs.MailCreateContentPanel.superclass.initStateEvents.call(this);this.on("bcctoggle",this.saveState,this);this.on("fromtoggle",
this.saveState,this)},saveState:function(a,b,c){c&&Zarafa.mail.dialogs.MailCreateContentPanel.superclass.saveState.call(this)},getState:function(){var a=Zarafa.mail.dialogs.MailCreateContentPanel.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,true)},toggleFromState:function(a){this.showfrom=a;this.fireEvent("fromtoggle",this,a,true)},getContextModel:function(){if(!this.model){var a=
this.get("parent_entryid");Ext.isEmpty(a)||(a=container.getHierarchyStore().getById(a));if(Ext.isEmpty(a))a=container.getHierarchyStore().getDefaultFolder("drafts");this.model=container.getContextByFolder(a).getModel()}return this.model}});Ext.reg("zarafa.mailcreatecontentpanel",Zarafa.mail.dialogs.MailCreateContentPanel);Ext.namespace("Zarafa.mail.dialogs");
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.ShowMailContentPanel=Ext.extend(Zarafa.core.ui.MessageContentPanel,{model:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.showmailcontentpanel",layout:"fit",title:_("no subject"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),closeOnSend:true,items:[this.createPanel()]});Zarafa.mail.dialogs.ShowMailContentPanel.superclass.constructor.call(this,a)},createPanel:function(){return{xtype:"zarafa.mailviewpanel",tbar:{xtype:"zarafa.showmailtoolbar"}}},
getContextModel:function(){if(!this.model){var a=container.getHierarchyStore(),b=this.get("parent_entryid");Ext.isEmpty(b)||(b=a.getById(b));if(Ext.isEmpty(b))b=a.getDefaultFolder("drafts");this.model=container.getContextByFolder(b).getModel()}return this.model},update:function(a,b){b&&this.updateIconFromRecord(a);this.updateTitleFromRecord(a)},updateTitleFromRecord:function(a){a=a.get("subject");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))}});
Ext.reg("zarafa.showmailcontentpanel",Zarafa.mail.dialogs.ShowMailContentPanel);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).replace(/{/g,"&#123;").replace(/}/g,"&#125;").replace(/\u2028/g,"").replace(/\u2029/g,"");b+="</p>\n";return b}});Ext.namespace("Zarafa.note");
Zarafa.note.NoteContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{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;case Zarafa.core.data.SharedComponentType["common.printer.renderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.isMessageClass("IPM.StickyNote",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:if(b instanceof Zarafa.hierarchy.data.MAPIFolderRecord)if(b.isContainerClass("IPF.StickyNote",
true))c=1;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:if(b instanceof Zarafa.core.data.IPMRecord&&b.get("object_type")===Zarafa.core.mapi.ObjectType.MAPI_MESSAGE)if(b.isMessageClass("IPM.StickyNote",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.note.dialogs.NoteEditContentPanel;break;case Zarafa.core.data.SharedComponentType["common.contextmenu"]:c=
Zarafa.note.ui.NoteContextMenu;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)c=Zarafa.note.printer.NoteRenderer;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:c=Zarafa.note.attachitem.AttachNoteColumnModel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:c=Zarafa.note.attachitem.AttachNoteRenderer;
break}return c},createNoteNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",id:"zarafa-navigationpanel-notes-navigation",cls:"zarafa-context-navigation-block",layout:"fit",items:[{xtype:"zarafa.hierarchytreepanel",id:"zarafa-navigationpanel-notes-navigation-tree",model:this.getModel(),IPMFilter:"IPF.StickyNote",hideDeletedFolders:true,enableDD:true,enableItemDrop:true,deferredLoading:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.NOTE,
buttonText:_("Open Shared Notes")}}]}]}},createContentPanel:function(){return{xtype:"zarafa.notemainpanel",id:"zarafa-mainpanel-contentpanel-notes",context:this}},createNewNoteButton:function(){return{xtype:"menuitem",id:"zarafa-maintoolbar-newitem-note",tooltip:_("Sticky note")+" (Ctrl + Alt + S)",plugins:"zarafa.menuitemtooltipplugin",text:_("Sticky note"),iconCls:"icon_createNote",newMenuIndex:5,context:"note",handler:function(){Zarafa.note.Actions.openCreateNoteContent(this.getModel())},scope:this}},
getMainToolbarPrintButtons:function(){var a=container.populateInsertionPoint("main.toolbar.print.note",this)||[];return[{xtype:"zarafa.conditionalitem",id:"zarafa-maintoolbar-print-selectednote",overflowText:_("Print selected note"),iconCls:"icon_print_single_note",tooltip:_("Print selected note")+" (Ctrl + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print selected note"),hideOnDisabled:false,singleSelectOnly:true,handler:this.onPrintSelected,scope:this}].concat(a)},onPrintSelected:function(){var a=
this.getModel().getSelectedRecords();Ext.isEmpty(a)?Ext.MessageBox.alert(_("Print"),_("No note selected")):Zarafa.common.Actions.openPrintDialog(a)},getMainToolbarViewButtons:function(){var a=container.populateInsertionPoint("main.maintoolbar.view.note",this)||[];return[{id:"zarafa-maintoolbar-view-notes-icons",text:_("Icons"),overflowText:_("Icons"),iconCls:"icon_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},{id:"zarafa-maintoolbar-view-notes-list",text:_("List view"),overflowText:_("List view"),iconCls:"icon_contact_list",valueView:Zarafa.note.data.Views.LIST,valueViewMode:Zarafa.note.data.ViewModes.NORMAL,valueDataMode:Zarafa.note.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-notes-listlastsevendays",text:_("List Last Seven Days"),overflowText:_("List Last Seven Days"),iconCls:"icon_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}].concat(a)},onContextSelectView:function(a){this.getModel().setDataMode(a.valueDataMode);this.switchView(a.valueView,a.valueViewMode)},createMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:6,context:this.getName(),id:"mainmenu-button-notes"}},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.core.ContextMetaData({name:"note",displayName:_("Notes"),allowUserVisible:false,pluginConstructor:Zarafa.note.NoteContext}))});Ext.namespace("Zarafa.note");
Zarafa.note.NoteStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.StickyNote",defaultSortInfo:{field:"subject",direction:"asc"}});Zarafa.note.NoteStore.superclass.constructor.call(this,a)}});Ext.reg("zarafa.notestore",Zarafa.note.NoteStore);Ext.namespace("Zarafa.note.printer");
Zarafa.note.printer.NoteRenderer=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(_("Modified"),'{last_modification_time:date("'+_("l jS F Y G:i")+'")}');b+=this.optionalRow(_("Categories"),"categories","{categories:htmlEncode}");b+="</table><br><p>\n";b+=a.getBody(true);b+="</p>\n";return b}});Ext.namespace("Zarafa.settings");
Zarafa.settings.SettingsContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){a=a||{};Ext.applyIf(a,{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);this.addEvents("afterrequiredreload")},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);this.getModel().getRealSettingsModel().on("save",this.onSaveSettings,this);container.getNavigationBar().collapse()},disable:function(){container.getNavigationBar().expand();
container.un("beforecontextswitch",this.onBeforeContextSwitch,this);Zarafa.settings.SettingsContext.superclass.disable.apply(this,arguments)},onSaveSettings:function(a,b){if(b.requiresReload){var c=_("In order for the changes to take effect, please reload WebApp.")+"<br>"+_("NOTE: Any unsaved changes will be lost.");Zarafa.common.dialogs.MessageBox.addCustomButtons({title:_("Zarafa WebApp"),msg:c,icon:Ext.MessageBox.QUESTION,fn:this.reloadWebapp,customButton:[{text:_("Reload"),name:"reload"},{text:_("Cancel"),
name:"cancel"}],scope:this})}},reloadWebapp:function(a){if(a==="reload"){this.getModel().getRealSettingsModel().un("save",this.onSaveSettings,this);Zarafa.core.Util.reloadWebapp()}this.fireEvent("afterrequiredreload",this,a)},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",id:"zarafa-mainpanel-contentpanel-settings",title:this.getDisplayName(),context:this}},createSettingsMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:1,context:this.getName(),id:"mainmenu-button-settings"}},createSettingCategories:function(){var a=[{xtype:"zarafa.settingsgeneralcategory",settingsContext:this}];container.getServerConfig().isPluginsEnabled()&&
a.push({xtype:"zarafa.settingspluginscategory",settingsContext:this});container.getServerConfig().isAdvancedSettingsEnabled()&&a.push({xtype:"zarafa.settingsadvancedcategory",settingsContext:this});return a=a.concat([{xtype:"zarafa.settingskeyshortcutcategory",settingsContext:this},{xtype:"zarafa.settingscopyrightcategory",settingsContext:this}])},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();d.getRealSettingsModel().requiresReload?this.on("afterrequiredreload",this.onAfterRequiredReload.createDelegate(this,[b,c],1),this,{single:true}):container.switchContext(c,b)}},onAfterRequiredReload:function(a,b,c,d){d==="cancel"&&container.switchContext(c,
b)}});Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"settings",displayName:_("Settings"),allowUserVisible:false,pluginConstructor:Zarafa.settings.SettingsContext}))});Ext.namespace("Zarafa.task");
Zarafa.task.TaskContext=Ext.extend(Zarafa.core.Context,{oldView:undefined,oldViewMode:undefined,constructor:function(a){a=a||{};Ext.applyIf(a,{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);this.registerInsertionPoint("context.mail.contextmenu.actions",this.convertToTask,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"]:case Zarafa.core.data.SharedComponentType["common.preview"]: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;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:if(b instanceof
Zarafa.hierarchy.data.MAPIFolderRecord)if(b.isContainerClass("IPF.Task",true))c=1;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]: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;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.TaskEditContentPanel;break;case Zarafa.core.data.SharedComponentType["common.preview"]:c=Zarafa.task.ui.TaskPreviewPanel;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;
case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.columnmodel"]:c=Zarafa.task.attachitem.AttachTaskColumnModel;break;case Zarafa.core.data.SharedComponentType["common.attachment.dialog.attachitem.textrenderer"]:c=Zarafa.task.attachitem.AttachTaskRenderer;break}return c},createTaskNavigationPanel:function(){return{xtype:"zarafa.contextnavigation",context:this,items:[{xtype:"panel",id:"zarafa-navigationpanel-tasks-navigation",cls:"zarafa-context-navigation-block",layout:"fit",
items:[{xtype:"zarafa.hierarchytreepanel",id:"zarafa-navigationpanel-tasks-navigation-tree",model:this.getModel(),IPMFilter:"IPF.Task",hideDeletedFolders:true,enableDD:true,enableItemDrop:true,deferredLoading:true,bbarConfig:{defaultSelectedSharedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.TASK,buttonText:_("Open Shared Tasks")}}]}]}},createContentPanel:function(){return{xtype:"zarafa.taskmainpanel",id:"zarafa-mainpanel-contentpanel-tasks",context:this}},getMainToolbarViewButtons:function(){var a=
container.populateInsertionPoint("main.maintoolbar.view.task",this)||[];return[{id:"zarafa-maintoolbar-view-tasks-simple",text:_("Simple Tasks"),overflowText:_("Simple Tasks"),iconCls:"icon_task_simple",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.ALL,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-tasks-active",text:_("Active Tasks"),overflowText:_("Active Tasks"),iconCls:"icon_task_active",
valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.ACTIVE,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-tasks-nextsevendays",text:_("Next Seven Days"),overflowText:_("Next Seven Days"),iconCls:"icon_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},
{id:"zarafa-maintoolbar-view-tasks-overdue",text:_("Overdue Tasks"),overflowText:_("OverDue Tasks"),iconCls:"icon_task_overdue",valueView:Zarafa.task.data.Views.LIST,valueViewMode:Zarafa.task.data.ViewModes.NORMAL,valueDataMode:Zarafa.task.data.DataModes.OVERDUE,handler:this.onContextSelectView,scope:this},{id:"zarafa-maintoolbar-view-tasks-completed",text:_("Completed Tasks"),overflowText:_("Completed Tasks"),iconCls:"icon_task_completed",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",id:"zarafa-maintoolbar-newitem-task",tooltip:_("Task")+" (Ctrl + Alt + K)",plugins:"zarafa.menuitemtooltipplugin",text:_("Task"),handler:function(){Zarafa.task.Actions.openCreateTaskContent(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",id:"zarafa-maintoolbar-print-selectedtask",overflowText:_("Print selected task"),iconCls:"icon_print_single_task",tooltip:_("Print selected task")+" (Ctrl + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print selected task"),hideOnDisabled:false,singleSelectOnly:true,handler:this.onPrintSelected,
scope:this},{overflowText:_("Print task list"),id:"zarafa-maintoolbar-print-tasklist",iconCls:"icon_print_task_list",tooltip:_("Print task list")+" (Ctrl + Alt + P)",plugins:"zarafa.menuitemtooltipplugin",text:_("Print task list"),handler:this.onPrintList,scope:this}].concat(a)},onPrintSelected:function(){var a=this.getModel().getSelectedRecords();Ext.isEmpty(a)?Ext.MessageBox.alert(_("Print"),_("No task selected")):Zarafa.common.Actions.openPrintDialog(a)},onPrintList:function(){Zarafa.common.Actions.openPrintDialog(this)},
createMainTab:function(){return{text:this.getDisplayName(),tabOrderIndex:5,context:this.getName(),id:"mainmenu-button-tasks"}},convertToTask:function(){return{xtype:"zarafa.conditionalitem",text:_("Create task"),iconCls:"icon_createTask",singleSelectOnly:true,hidden:true,handler:this.onContextItemCreateTask,scope:this}},onContextItemCreateTask:function(a){a=a.getRecords();Zarafa.task.Actions.createTaskFromMail(a,this.getModel())}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"task",displayName:_("Tasks"),allowUserVisible:false,pluginConstructor:Zarafa.task.TaskContext}))});Ext.namespace("Zarafa.task");Zarafa.task.TaskStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{preferredMessageClass:"IPM.Task",defaultSortInfo:{field:"duedate",direction:"desc"}});Zarafa.task.TaskStore.superclass.constructor.call(this,a)}});
Ext.reg("zarafa.taskstore",Zarafa.task.TaskStore);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.dialogs");
Zarafa.task.dialogs.TaskEditContentPanel=Ext.extend(Zarafa.core.ui.MessageContentPanel,{constructor:function(a){a=a||{};a=Ext.applyIf(a,{layout:"fit",xtype:"zarafa.taskeditcontentpanel",closeOnSave:true,title:_("Task"),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:true}),confirmClose:true,items:[{xtype:"zarafa.taskpanel",tbar:{xtype:"zarafa.tasktoolbar"}}]});Zarafa.task.dialogs.TaskEditContentPanel.superclass.constructor.call(this,a)},update:function(a,b){b&&
this.updateIconFromRecord(a);this.updateTitleFromRecord(a)},updateIconFromRecord:function(a){this.setIcon(Zarafa.common.ui.IconClass.getIconClass(a))},updateTitleFromRecord:function(a){a=a.get("subject");Ext.isEmpty(a)?this.setTitle(this.initialConfig.title):this.setTitle(a)},sendRecord:function(){}});Ext.reg("zarafa.taskeditcontentpanel",Zarafa.task.dialogs.TaskEditContentPanel);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.today");
Zarafa.today.TodayContext=Ext.extend(Zarafa.core.Context,{constructor:function(a){this.registerInsertionPoint("main.maintabbar.left",this.createMainTab,this);Zarafa.today.TodayContext.superclass.constructor.call(this,a)},getModel:function(){if(!Ext.isDefined(this.model))this.model=new Zarafa.today.TodayContextModel;return this.model},bid:function(a){if(a.isOwnRoot())return 2;return 0},createContentPanel:function(){return{xtype:"zarafa.widgetpanel",id:"zarafa-mainpanel-contentpanel-today",settingsPath:"zarafa/v1/contexts/today",
showDefaultWidgets:["mail","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:this.getDisplayName(),tabOrderIndex:1,context:this.getName(),id:"mainmenu-button-today"}}});
Zarafa.onReady(function(){container.registerContext(new Zarafa.core.ContextMetaData({name:"today",displayName:_("Zarafa"),allowUserVisible:false,pluginConstructor:Zarafa.today.TodayContext}))});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,allowResolvingToLocalContacts:true,allowResolvingToGABGroups:true,expandProxy:undefined,expandReader:undefined,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.expandProxy=new Zarafa.core.data.IPMExpandDistlistProxy;this.relayEvents(this.resolveProxy,["exception"]);this.resolveReader=new Ext.data.JsonReader({root:"result"},Zarafa.core.data.IPMRecipientResolveRecord);this.expandReader=new Zarafa.core.data.JsonReader({root:"result",id:"entryid",
dynamicRecord:false},Zarafa.core.data.IPMExpandDistlistRecord);this.on({add:this.onRecipientAdd,update:this.onRecipientUpdate,exception:this.onResolveException,scope:this})},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).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(),i=f.get("smtp_address").trim(),h=f.get("address_type"),
k=f.get("email_address");Ext.isEmpty(k)||(k=k.trim());if(Ext.isEmpty(k))k=Zarafa.core.Util.validateEmailAddress(i)?i:"";d.push({id:f.id,display_name:g,email_address:k,address_type:h});c.push(f)}d={resolverequests:d,exclude_local_contacts:!this.allowResolvingToLocalContacts,exclude_gab_groups:!this.allowResolvingToGABGroups};e=Ext.apply({},b,{actionType:Zarafa.core.Actions.checknames,listRequest:true,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.openCheckNamesContent(d.result.records,e)}e.resolveAttempted=true}}this.fireEvent("resolved",this,b.pendingRecords)},expand:function(a,
b,c){b={entryid:a.get("entryid"),recurse:b||false};c=Ext.apply({},c,{actionType:Zarafa.core.Actions.expand,listRequest:true,recipientType:a.get("recipient_type"),params:b});this.expandProxy.request(Zarafa.core.Actions.expand,a,b,this.expandReader,this.onExpandResult,this,c)},onExpandResult:function(a,b,c){if(c){Ext.isArray(a)||(a=[a]);c=[];for(var d=0;d<a.length;d++){var e=a[d];Ext.isEmpty(e)||c.push(e.convertToRecipient(b.recipientType))}this.add(c)}},onRecipientAdd:function(a,b){this.autoResolve&&
Ext.each(b,function(c){if(c.dirty){this.resolve(b);return false}},this)},onRecipientUpdate:function(a,b){this.autoResolve&&this.resolve(b)},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.common.rules.data");
Zarafa.common.rules.data.RulesResponseHandler=Ext.extend(Zarafa.core.data.IPMResponseHandler,{correlateRecordFromResponse:function(a){a=this.reader.readResponse(Ext.data.Api.actions.read,a);var b=[];if(!Ext.isEmpty(a.data)&&!Ext.isEmpty(this.sendRecords))b=a.data.clone();return b}});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.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.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:24});Zarafa.addressbook.ui.AddressBookBoxField.superclass.constructor.call(this,a)}});Ext.reg("zarafa.addressbookboxfield",Zarafa.addressbook.ui.AddressBookBoxField);Ext.namespace("Zarafa.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentBoxView=Ext.extend(Zarafa.calendar.ui.canvas.AppointmentView,{bounds:undefined,mainRenderedText:"",subRenderedText:"",setSelected:function(a){Zarafa.calendar.ui.canvas.AppointmentBoxView.superclass.setSelected.call(this,a);if(a&&!Ext.isEmpty(this.bounds)){this.drawBodySelectionOutline(this.bounds);this.focus()}},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,i=e.right-e.left-1,h=e.bottom-e.top-1;b.strokeRect(f,g,i,h);if(e.firstBox){g+=Math.ceil(h/2);this.drawDragHandle(b,
f,g)}if(e.lastBox){e.firstBox||(g+=Math.ceil(h/2));this.drawDragHandle(b,f+i,g)}}b.restore()},drawBodyElement:function(a,b,c){var d=b.right-b.left,e=b.bottom-b.top;a.save();a.translate(b.left,b.top);a.lineWidth=1;a.fillStyle="white";a.fillRect(3,3,d-6,e-6);var f=this.getAppointmentColorScheme(),g=Zarafa.core.ColorSchemes.rgbToHsl(this.calendarColorScheme.startcolorappointmentbox)[2]<0.5;b=1;if(!this.isActive())b=this.opacityNonActiveAppointment;var i=this.getStripWidth();a.globalAlpha=b;a.fillStyle=
f.startcolorappointment;a.fillRect(3+i,3,d-6-i,e-6);switch(this.getBusyStatus()){case Zarafa.core.mapi.BusyStatus.FREE:a.fillStyle="white";a.fillRect(3,3,i,e-6);a.strokeStyle=this.calendarColorScheme.startcolorappointmentbox;a.strokeRect(3.5,3.5,i,e-7);break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillStyle=this.calendarColorScheme.startcolorappointmentbox;a.fillRect(3,3,i,e-6);a.globalAlpha=1;a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");a.fillRect(3,3,
i,e-6);break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle="#912787";a.fillRect(3,3,i,e-6);break;default:a.fillStyle="#0f70bd";a.fillRect(3,3,i,e-6);break}b=i+this.parentView.headerBackgroundCanvasStylingElement.getPadding("l");a.globalAlpha=this.isActive()?1:this.opacityNonActiveAppointment;i=this.parentView.headerBackgroundCanvasStylingElement.getStyle("font");g=Zarafa.core.ColorSchemes.getLuma(f.startcolorappointment)<155;f=this.isActive()&&g?"white":"black";g=this.iconRenderer();for(var h=
0,k=g.length;h<k;h++){var j=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(g[h])+"Icon"+(f==="white"?"Active":"")]();a.drawImage(j,b,Math.ceil((e-j.height)/2));b+=j.width+5}a.beginPath();a.rect(3,3,d-6,e-6);a.clip();g=Math.min(1,Math.max(0.1,(d-b)/d));h=a.createLinearGradient(0,0,d,0);h.addColorStop(0,this.isActive()?"black":"#666666");h.addColorStop(g,this.isActive()?"black":"#666666");h.addColorStop(1,"rgba(0,0,0,0)");a.fillStyle=h;a.lineWidth=1;a.setFont(i);a.fillStyle=f;d={xPosition:b,
yPosition:e-Math.ceil((e-parseInt(this.parentView.headerBackgroundCanvasStylingElement.getStyle("font-size")))/2)-2,width:d,showStartTime:false,showEndTime:false};if(!this.isAllDay()){d.startTimeText=Ext.util.Format.htmlDecode(this.startTimeTextRenderer());d.endTimeText=Ext.util.Format.htmlDecode(this.endTimeTextRenderer());if(this.bounds.length>1)if(c===0)d.showStartTime=true;else{if(this.bounds.length-1===c)d.showEndTime=true}else if(this.bounds.length===1)if(this.getDateRange().getNumDays()>0){d.showStartTime=
true;d.showEndTime=true}else d.showStartTime=true}this.drawTextOnAppointment(a,d);a.restore()},drawTextOnAppointment:function(a,b){var c=this.mainRenderedText+" "+this.subRenderedText,d=a.textWidth(b.endTimeText),e=a.textWidth(b.startTimeText+" "),f=b.width-(d+this.leftPadding+this.getStripWidth());if(b.showEndTime&&!b.showStartTime){a.drawText(b.endTimeText,f,b.yPosition);e=d/b.endTimeText.length;e=Math.floor(f/e);c=Ext.util.Format.ellipsis(c,e,false)}else if(b.showStartTime&&!b.showEndTime){a.drawText(b.startTimeText,
b.xPosition,b.yPosition);b.xPosition+=e}else if(b.showStartTime&&b.showEndTime){a.drawText(b.endTimeText,f,b.yPosition);a.drawText(b.startTimeText,b.xPosition,b.yPosition);b.xPosition+=e;f=f-b.xPosition;e=e/b.startTimeText.length;e=Math.floor(f/e);c=Ext.util.Format.ellipsis(c,e,false)}a.drawText(c,b.xPosition,b.yPosition)},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],c);this.isSelected()&&
this.drawBodySelectionOutline(a)},layoutInBody:function(){this.bounds=this.parentView.dateRangeToBodyBounds(this.getDateRange(),this.slot,undefined,false);Ext.isEmpty(this.bounds)||this.drawBodyElements(this.bounds)},startTimeTextRenderer:function(){return Ext.util.Format.htmlEncode(this.record.get("startdate").format(this.timeFormat))},endTimeTextRenderer:function(){return Ext.util.Format.htmlEncode(this.record.get("duedate").format(this.timeFormat))},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.calendar.ui.canvas");
Zarafa.calendar.ui.canvas.AppointmentDaysView=Ext.extend(Zarafa.calendar.ui.canvas.AppointmentView,{bounds:undefined,appointmentRadius:0,lineHeight:13,bodyTextTopOffset:4,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);
this.focus()}},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,i=a.lastBox?this.appointmentRadius:1;b.save();b.lineWidth=1;b.strokeStyle="black";b.roundedRect2(c,d,e,f,g,i,i,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,i=e.right-e.left-1,h=e.bottom-e.top-1,k=e.firstBox?this.appointmentRadius:1,j=e.lastBox?this.appointmentRadius:1;b.roundedRect2(f,g,i,h,k,k,j,j);b.stroke();if(e.firstBox){f+=Math.ceil(i/2);this.drawDragHandle(b,f,g)}if(e.lastBox){e.firstBox||(f+=Math.ceil(i/2));this.drawDragHandle(b,
f,g+h)}}b.restore()},drawBodyText:function(a,b,c,d,e){if(!(d<=0)){for(var f=this.getAppointmentColorScheme(),g=Zarafa.core.ColorSchemes.getLuma(f.startcolorappointment)<155,i=this.isActive()&&g?"white":"black",h=this.iconRenderer(),k=0,j=c,l,m=0,n=h.length;m<n;m++){l=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(h[m])+"Icon"+(this.isActive()&&g?"Active":"")]();a.drawImage(l,b+k,j+this.bodyTextTopOffset);k+=l.width+this.iconSpacing}if(h.length>0){l=Zarafa.calendar.ui.IconCache["get"+
Ext.util.Format.capitalize(h[0])+"Icon"]();j+=l.height}g=a.createLinearGradient(b,c,b+d,c);h=Math.min(1,Math.max(0.1,(d-12)/d));g.addColorStop(0,i);g.addColorStop(h,i);g.addColorStop(1,f.startcolorappointment);a.fillStyle=g;a.lineWidth=1;a.setFont(this.parentView.headerBackgroundCanvasStylingElement.getStyle("font"));f=a.drawWrappedText(this.mainRenderedText,b,c+this.lineHeight,d,this.lineHeight,e,k,j);if(f+this.lineHeight<e){a.lineWidth=1;a.setFont(this.parentView.headerBackgroundCanvasStylingElement.getStyle("font"));
a.drawWrappedText(this.subRenderedText,b,c+this.lineHeight+f,d,this.lineHeight,e-f)}}},layoutInHeader:function(){var a=this.getAppointmentColorScheme(),b=Zarafa.core.ColorSchemes.getLuma(a.startcolorappointment)<155,c=this.isActive()&&b?"white":"black";this.bounds=this.parentView.dateRangeToHeaderBounds(this.getDateRange(),this.slot,1,true);var d=this.bounds.right-this.bounds.left,e=this.bounds.bottom-this.bounds.top,f=this.parentView.getHeaderAppointmentCanvas().dom.getContext("2d");f.save();f.translate(this.bounds.left,
this.bounds.top);f.lineWidth=1;var g=0.8;if(!this.isActive())g=this.opacityNonActiveAppointment;f.fillStyle="white";f.fillRect(0,0,d,e-1);var i=this.getStripWidth();f.fillStyle=a.startcolorappointment;f.globalAlpha=g;f.fillRect(i+1,1,d-2-i,e-3);g=this.getBusyStatus();var h=e-3;switch(g){case Zarafa.core.mapi.BusyStatus.FREE:break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:f.fillStyle=a.startcolorappointment;f.fillRect(1,1,i,h);f.globalAlpha=1;f.fillStyle=f.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),
"repeat");f.fillRect(1,1,i,h);break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:f.fillStyle="#912787";f.fillRect(1,1,i,h);break;default:f.fillStyle="#0f70bd";f.fillRect(1,1,i,h);break}a=this.leftPadding+i;f.globalAlpha=this.isActive()?1:this.opacityNonActiveAppointment;i=this.iconRenderer();g=0;for(h=i.length;g<h;g++){var k=Zarafa.calendar.ui.IconCache["get"+Ext.util.Format.capitalize(i[g])+"Icon"+(this.isActive()&&b?"Active":"")]();f.drawImage(k,a,6);a+=k.width+5}b=Math.min(1,Math.max(0.1,(d-12)/
d));i=f.createLinearGradient(0,0,d,0);i.addColorStop(0,c);i.addColorStop(b,c);i.addColorStop(1,this.isActive()?"rgba(255, 255, 255, 0)":"rgba(0, 0, 0, 0)");f.fillStyle=i;f.save();f.beginPath();f.rect(a,0,d-a,e);f.clip();f.lineWidth=1;f.setFont(this.parentView.headerBackgroundCanvasStylingElement.getStyle("font"));f.drawText(this.mainRenderedText,a,e-8);a+=f.textWidth(this.mainRenderedText+" ");f.drawText(this.subRenderedText,a,e-8);f.restore();this.isSelected()&&this.drawHeaderSelectionOutline(this.bounds);
f.restore()},drawBodyElement:function(a,b){var c=this.getBusyStatus(),d=b.right-b.left-2,e=b.bottom-b.top,f=this.parentView.getRangeVerticalHeight(this.getDateRange());a.save();a.translate(b.left,b.top);a.lineWidth=1;var g=this.getAppointmentColorScheme(),i=0.8;if(!this.isActive())i=this.opacityNonActiveAppointment;a.globalAlpha=i;a.fillStyle=g.startcolorappointment;var h=this.getStripWidth(),k=f+1<e,j=!k&&h>0;a.fillRect(h+1,1,d-h,e);var l=1,m=1,n=h,o=e-1;if(j){a.strokeStyle="white";a.globalAlpha=
1;a.strokeRect(0.5,0.5,d,e);a.globalAlpha=i}else if(k)o=f-1;switch(c){case Zarafa.core.mapi.BusyStatus.FREE:a.strokeStyle=a.convertHexRgbToDecRgba(g.startcolorappointment);a.strokeRect(l+0.5,m+0.5,n-1,o-1);a.fillStyle="white";l+=1;m+=1;n-=1;o-=2;a.fillRect(l,m,n,o);break;case Zarafa.core.mapi.BusyStatus.TENTATIVE:a.fillRect(l,m,n,o);a.globalAlpha=1;a.fillStyle=a.createPattern(Zarafa.calendar.ui.IconCache.getDashedImage(),"repeat");a.fillRect(l,m,n,o);break;case Zarafa.core.mapi.BusyStatus.OUTOFOFFICE:a.fillStyle=
"#912787";a.fillRect(l,m,n,o);break;default:a.fillRect(l,m,n,o);break}a.beginPath();a.rect(h+1,1,d-h-2,e-1);a.clip();a.globalAlpha=this.isActive()?1:this.opacityNonActiveAppointment;this.drawBodyText(a,h+this.leftPadding,this.bodyTextTopOffset,d-h-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,false);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.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.ui");
Zarafa.contact.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.contact.ui.MemberBoxField.superclass.constructor.call(this,a)},setMemberStore:function(){return this.setBoxStore.apply(this,arguments)},getMemberStore:function(){return this.getBoxStore()},update:function(a,
b){if(a&&a instanceof Zarafa.core.data.MAPIRecord)b&&a.isOpened()&&this.setMemberStore(a.getMemberStore());else Zarafa.contact.ui.MemberBoxField.superclass.update.apply(this,arguments)},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.contact.ui.MemberBoxField);Ext.namespace("Zarafa.hierarchy.dialogs");
Zarafa.hierarchy.dialogs.SharedFolderContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{defaultSelectedFolderType:Zarafa.hierarchy.data.SharedFolderTypes.ALL,store:undefined,constructor:function(a){a=a||{};if(!a.store)a.store=new Zarafa.core.data.IPMRecipientStore({allowResolvingToLocalContacts:false,allowResolvingToGABGroups:false});a=Ext.applyIf(a,{xtype:"zarafa.sharedfoldercontentpanel",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.SharedFolderContentPanel.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()}});Ext.reg("zarafa.sharedfoldercontentpanel",Zarafa.hierarchy.dialogs.SharedFolderContentPanel);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,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.openABUserSelectionContent({callback:this.abCallBack,scope:this,hierarchyRestriction:{hide_contacts:true},listRestriction:{hide_users:["contact","system"],hide_groups:true,hide_companies:true}})},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.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.core.data");
Zarafa.core.data.IPMRecordFields=[{name:"body",type:"string"},{name:"html_body",type:"string"},{name:"isHTML",type:"boolean",defaultValue:false},{name:"entryid"},{name:"creation_time",type:"date",dateFormat:"timestamp",defaultValue:null,sortDir:"DESC"},{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:"read_receipt_requested",type:"boolean",defaultValue:false},{name:"parent_entryid"},{name:"store_entryid"},{name:"subject"},{name:"object_type",type:"int",defaultValue:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE},{name:"normalized_subject"},{name:"last_modification_time",type:"date",dateFormat:"timestamp",defaultValue:null,sortDir:"DESC"},{name:"last_verb_execution_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"last_verb_executed",
type:"int"},{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_username"},{name:"sent_representing_address_type"},{name:"sent_representing_entryid"},{name:"sent_representing_search_key"},{name:"sent_representing_presence_status"},{name:"sender_name"},{name:"sender_email_address"},{name:"sender_username"},{name:"sender_address_type"},{name:"sender_entryid"},
{name:"sender_search_key"},{name:"sender_presence_status"},{name:"message_size",type:"int"},{name:"categories"},{name:"deleted_on",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"attach_num",defaultValue:null}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM",Zarafa.core.data.IPMRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("REPORT.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,baseIdProperties:["entryid","store_entryid","parent_entryid","attach_num"],equals:function(a){if(this===a)return true;if(this.fields!==a.fields)return false;if(this.phantom!==a.phantom)return false;if(this.phantom)return this.id==a.id;else{var b=Zarafa.core.EntryId.compareEntryIds(this.get("entryid"),a.get("entryid"));if(b)if(this.isSubMessage()&&a.isSubMessage())b=this.get("attach_num").equals(a.get("attach_num"));
else if(this.isSubMessage()||a.isSubMessage())b=false;return b}},isMessageClass:function(a,b){return Zarafa.core.MessageClass.isClass(this.get("message_class"),a,b)},getSenderString:function(){var a="";a=this.get("sender_entryid");var b=this.get("sent_representing_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b)&&!Zarafa.core.EntryId.compareABEntryIds(a,b)){a=!Ext.isEmpty(this.get("sender_name"))?this.get("sender_name"):this.get("sender_email_address");b=!Ext.isEmpty(this.get("sent_representing_name"))?
this.get("sent_representing_name"):this.get("sent_representing_email_address");a=String.format(_("{0} on behalf of {1}"),a,b)}else a=!Ext.isEmpty(this.get("sender_name"))?this.get("sender_name"):this.get("sender_email_address");return a},getBody:function(a){var b=this.get("isHTML");return a===false?b?Zarafa.core.HTMLParser.convertHTMLToPlain(this.get("html_body")):this.get("body"):a===true?b?this.inlineImgOutlookToZarafa(this.get("html_body")):Zarafa.core.HTMLParser.convertPlainToHTML(this.get("body")):
b?this.inlineImgOutlookToZarafa(this.get("html_body")):this.get("body")},setBody:function(a,b){if(b){a=this.inlineImgZarafaToOutlook(a);if(this.get("html_body")!==a){this.set("isHTML",true,true);this.set("html_body",a)}}else if(this.get("body")!==a){this.set("isHTML",false,true);this.set("body",a)}},inlineImgOutlookToZarafa:function(a){var b=undefined,c=undefined;b=this.getMessageAction("action_type");var d=this.get("attach_num");if(this.phantom&&(Zarafa.mail.data.ActionTypes.isSendOrForward(b)||
b===Zarafa.mail.data.ActionTypes.EDIT_AS_NEW)){b=this.getMessageAction("source_entryid");c=this.getMessageAction("source_store_entryid")}else{b=this.get("entryid");c=this.get("store_entryid")}if(c&&b)a=Zarafa.core.HTMLParser.inlineImgOutlookToZarafa(a,c,b,d);return a},inlineImgZarafaToOutlook:function(a){return Zarafa.core.HTMLParser.inlineImgZarafaToOutlook(a)},isRead:function(){return this.isSubMessage()||(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},isSubMessage:function(){return!Ext.isEmpty(this.get("attach_num"))},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");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")},
getAttachmentNames:function(){if(!this.get("hasattach")||this.get("hide_attachments"))return"";var a=[];this.getSubStore("attachments").each(function(b){b.get("hidden")||a.push(b.get("name"))},this);return a.join("; ")},isFaultyMessage:function(){var a=this.get("message_class");if(Ext.isEmpty(a))return true;return this.isMessageClass(["IPM","MEMO","REPORT"],false)},fixFaultyMessage:function(){if(this.isFaultyMessage()){this.set("message_class","IPM.Note");this.save()}},getDownloadMessageUrl:function(a){var b=
container.getBaseURL();b=Ext.urlAppend(b,"load=download_message");b=Ext.urlAppend(b,"storeid="+this.get("store_entryid"));return b=a?Ext.urlAppend(b,"AllAsZip=true"):Ext.urlAppend(b,"entryid="+this.get("entryid"))},hasVisibleAttachments:function(){var a=false,b=this.getAttachmentStore().getRange();Ext.each(b,function(c){if(c.get("hidden")===false)a=true},this);return a}});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("REPORT.IPM",Zarafa.core.data.IPMRecord);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("REPORT.IPM","recipients",Zarafa.core.data.IPMRecipientStore);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("REPORT.IPM","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM",Zarafa.core.data.IPMRecord);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM","recipients",Zarafa.core.data.IPMRecipientStore);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM","attachments",Zarafa.core.data.IPMAttachmentStore);Zarafa.core.data.RecordFactory.setBaseClassToObjectType(Zarafa.core.mapi.ObjectType.MAPI_MESSAGE,Zarafa.core.data.IPMRecord);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.core.data.UIFactory.openContextMenu(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.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"),search_key:this.get("search_key"),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;var b=this.get("entryid");if(Zarafa.core.EntryId.hasContactProviderGUID(b)){a=a===Zarafa.core.mapi.DistlistType.DL_USER_AB?Zarafa.core.mapi.DistlistType.DL_USER:Zarafa.core.mapi.DistlistType.DL_DIST;b=Zarafa.core.EntryId.unwrapContactProviderEntryId(b)}a=
{entryid:b,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)},isPersonalContact:function(){if(Zarafa.core.MessageClass.isClass(this.get("message_class"),"IPM.CONTACT",true))return true;else if(this.get("object_type")==
Zarafa.core.mapi.ObjectType.MAPI_MAILUSER&&Zarafa.core.EntryId.hasContactProviderGUID(this.get("entryid")))return true;return false},isPersonalDistList:function(){if(Zarafa.core.MessageClass.isClass(this.get("message_class"),"IPM.DISTLIST",true))return true;else if(this.get("object_type")==Zarafa.core.mapi.ObjectType.MAPI_DISTLIST&&Zarafa.core.EntryId.hasContactProviderGUID(this.get("entryid")))return true;return false},convertToContactRecord:function(){var a=this.get("entryid"),b=a.indexOf("_");
if(b>0)a=a.substr(0,b);if(Zarafa.core.EntryId.hasContactProviderGUID(a))a=Zarafa.core.EntryId.unwrapContactProviderEntryId(a);return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Contact",{entryid:a,message_class:"IPM.Contact",object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE},a)},convertToDistListRecord:function(){var a=this.get("entryid"),b=a.indexOf("_");if(b>0)a=a.substr(0,b);if(Zarafa.core.EntryId.hasContactProviderGUID(a))a=Zarafa.core.EntryId.unwrapContactProviderEntryId(a);
return Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.DistList",{entryid:a,message_class:"IPM.DistList",object_type:Zarafa.core.mapi.ObjectType.MAPI_MESSAGE},a)},equals:function(a){if(this===a)return true;return Zarafa.core.EntryId.compareABEntryIds(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.core.data");
Zarafa.core.data.MessageRecordFields=[{name:"received_by_name"},{name:"received_by_email_address"},{name:"received_by_username"},{name:"received_by_address_type"},{name:"received_by_entryid"},{name:"received_by_search_key"},{name:"received_by_presence_status"},{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,sortDir:"DESC"},{name:"client_submit_time",type:"date",dateFormat:"timestamp",defaultValue:null,sortDir:"DESC"},{name:"transport_message_headers"},{name:"hide_attachments",type:"boolean",defaultValue:false},{name:"x_original_to"}];
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.isUnsent()||!this.isExternalContentBlocked(c))return c;return Zarafa.core.HTMLParser.blockExternalContent(c)}else return c},convertToTask:function(a){var b=a.getMAPIStore();a=Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass("IPM.Task",{store_entryid:a.get("store_entryid"),parent_entryid:a.get("entryid"),icon_index:Zarafa.core.mapi.IconIndex.task_normal,subject:this.get("subject"),body:this.getBody(false),importance:this.get("importance"),owner:b.isPublicStore()?
container.getUser().getFullName():b.get("mailbox_owner_name")});a.addMessageAction("source_entryid",this.get("entryid"));a.addMessageAction("source_store_entryid",this.get("store_entryid"));var c=a.getAttachmentStore();this.getAttachmentStore().each(function(d){c.add(d.copy())},this);return a},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.compareABEntryIds(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.compareABEntryIds(a,b);return false},senderIsStoreOwner:function(){var a=this.get("sent_representing_entryid")||this.get("sender_entryid"),b=container.getHierarchyStore().getById(this.get("store_entryid"));if(b){b=b.get("mailbox_owner_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return Zarafa.core.EntryId.compareABEntryIds(a,b)}return false},userIsStoreOwner:function(){var a=
container.getUser().getEntryId(),b=container.getHierarchyStore().getById(this.get("store_entryid"));if(b){b=b.get("mailbox_owner_entryid");if(!Ext.isEmpty(a)&&!Ext.isEmpty(b))return Zarafa.core.EntryId.compareABEntryIds(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("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().getById(a.get("store_entryid")))&&a.setDelegatorInfo(b);a.endEdit()};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:"has_picture"},
{name:"hide_attachments"},{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",defaultValue:null},{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:Zarafa.core.EntryId.wrapContactProviderEntryId(this.get("entryid"),Zarafa.core.mapi.ObjectType.MAPI_MAILUSER),object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,
display_type:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_type_ex:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_name:this.get("email_address_display_name_"+d)||this.get("display_name"),smtp_address:this.get("email_address_"+d),email_address:this.get("email_address_"+d),address_type:this.get("email_address_type_"+d)||"SMTP",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:Zarafa.core.EntryId.wrapContactProviderEntryId(this.get("entryid"),Zarafa.core.mapi.ObjectType.MAPI_MAILUSER),object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,display_type:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_type_ex:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_name:this.get("email_address_display_name")||this.get("display_name"),smtp_address:this.get("email_address"),email_address:this.get("email_address"),address_type:"SMTP",
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"),b=a.indexOf("_");if(b>0)a=a.substr(0,b);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.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"),true);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"),true);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"),true);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);b.length>0?this.set("address_book_mv",
b.sort()):this.set("address_book_mv",null);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.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,{entryid:Zarafa.core.EntryId.wrapContactProviderEntryId(this.get("entryid"),Zarafa.core.mapi.ObjectType.MAPI_DISTLIST),object_type:Zarafa.core.mapi.ObjectType.MAPI_DISTLIST,display_type:Zarafa.core.mapi.DisplayType.DT_DISTLIST,display_type_ex:Zarafa.core.mapi.DisplayType.DT_DISTLIST,
display_name:this.get("display_name"),email_address:this.get("fileas"),address_type:"MAPIPDL",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:"MAPIPDL",email_address:this.get("fileas"),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")},getMemberNames:function(){var a=[];this.getSubStore("members").each(function(b){var c=b.get("display_name");Ext.isEmpty(c)?a.push(b.get("email_address")):a.push(c)},this);return a.join("; ")}});Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.DistList",Zarafa.contact.DistListRecordFields);
Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.DistList","members",Zarafa.contact.DistlistMemberStore);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.DistList",Zarafa.contact.DistlistRecord);Ext.namespace("Zarafa.note");Zarafa.note.NoteRecordFields=[{name:"icon_index",type:"int",defaultValue:Zarafa.core.mapi.IconIndex.note_yellow},{name:"color",type:"int",defaultValue:Zarafa.core.mapi.NoteColor.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.ellipsis(a,28);a=a.split(/\r\n|\r|\n/)[0];this.set("subject",a);return a}});Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.StickyNote",Zarafa.note.NoteRecord);Ext.namespace("Zarafa.advancesearch");
Zarafa.advancesearch.AdvanceSearchRecordFields=[{name:"searchdate",type:"date",dateFormat:"timestamp",defaultValue:null,sortDir:"DESC"}];Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Search",Zarafa.advancesearch.AdvanceSearchRecordFields);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.Search",Zarafa.core.data.MessageRecord);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM",Zarafa.advancesearch.AdvanceSearchRecordFields);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,sortDir:"DESC"},{name:"duedate",type:"date",dateFormat:"timestamp",allowBlank:false,sortDir:"DESC"},{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,sortDir:"DESC"},{name:"enddate_recurring",type:"date",dateFormat:"timestamp",defaultValue:null,sortDir:"DESC"},{name:"exception",type:"boolean",defaultValue:false},{name:"reply_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"reply_name",type:"string",defaultValue:""},{name:"busystatus",type:"int",defaultValue:Zarafa.core.mapi.BusyStatus.BUSY},
{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.addFieldToMessageClass("IPM.Appointment",Zarafa.calendar.AppointmentRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.Appointment",Zarafa.core.data.MessageRecordFields);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Appointment","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Appointment","createphantom",function(a,b){a.beginEdit();if(Ext.isNumber(a.get("duration"))){var c=a.get("startdate")||a.get("commonstart"),d=a.get("duedate")||a.get("commonend");c&&d&&a.set("duration",(d-c)/6E4)}c=container.getSettingsModel();if(!b||!Ext.isDefined(b.reminder)){d=false;var e=container.getHierarchyStore().getById(a.get("store_entryid"));if(!e||!e.isPublicStore())d=c.get("zarafa/v1/contexts/calendar/default_reminder");a.set("reminder",
d)}if(!b||!Ext.isDefined(b.reminder_minutes))a.get("alldayevent")?a.set("reminder_minutes",c.get("zarafa/v1/contexts/calendar/default_allday_reminder_time")):a.set("reminder_minutes",c.get("zarafa/v1/contexts/calendar/default_reminder_time"));if(a.get("reminder")){c=a.get("startdate");if(Ext.isDate(c)){a.set("reminder_time",c);a.set("flagdueby",c.add(Date.MINUTE,-a.get("reminder_minutes")))}}a.endEdit()});
Zarafa.calendar.AppointmentRecord=Ext.extend(Zarafa.core.data.MessageRecord,{baseIdProperties:["entryid","store_entryid","parent_entryid","basedate","attach_num"],equals:function(a){if(Zarafa.calendar.AppointmentRecord.superclass.equals.apply(this,arguments)===true)return 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").toUTC(),d=this.get("recurrence_end").toUTC(),
e=this.get("recurrence_term"),f=this.get("recurrence_numoccur"),g=this.get("recurrence_startocc"),i=this.get("recurrence_endocc"),h=undefined,k=false,j=g!==0&&i!==0;switch(a){case Zarafa.common.recurrence.data.RecurrenceType.DAILY:if(b==1){a=_("workday");k=true}else if(b==1440){a=_("day");k=true}else{b/=1440;a=_("days");k=false}break;case Zarafa.common.recurrence.data.RecurrenceType.WEEKLY:if(b==1){a=_("week");k=true}else{a=_("weeks");k=false}a+=_(" on ")+this.prepareWeekDaysString();break;case Zarafa.common.recurrence.data.RecurrenceType.MONTHLY:if(b==
1){a=_("month");k=true}else{a=_("months");k=false}break;case Zarafa.common.recurrence.data.RecurrenceType.YEARLY:if(b<=12){b=1;a=_("year");k=true}else{b/=12;a=_("years");k=false}break}var l=c.clone();l.setHours(g/60);l.setMinutes(g%60);g=l.format(_("G:i"));l.setHours(i/60);l.setMinutes(i%60);i=l.format(_("G:i"));c=c.format(_("d/m/Y"));d=d.format(_("d/m/Y"));if(e==Zarafa.common.recurrence.data.RecurrenceEnd.NEVER)h=j?k?String.format(_("Occurs every {0} effective {1} from {2} to {3}."),a,c,g,i):String.format(_("Occurs every {0} {1} effective {2} from {3} to {4}."),
b,a,c,g,i):k?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)h=j?k?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,i):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,i):k?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)h=j?k?String.format(_("Occurs every {0} effective {1} until {2} from {3} to {4}."),a,c,d,g,i):String.format(_("Occurs every {0} {1} effective {2} until {3} from {4} to {5}."),
b,a,c,d,g,i):k?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 h},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())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&&!this.hasIdProp("basedate")},isRecurringOccurence:function(){return Ext.isDate(this.get("basedate"))},isRecurringException:function(){return Ext.isDate(this.get("basedate"))&&this.get("exception")===true},isSubMessage:function(){if(this.isRecurringOccurence())return false;return Zarafa.calendar.AppointmentRecord.superclass.isSubMessage.apply(this,arguments)},hasRecurringExceptions:function(){if(this.isOpened()){if(!this.isRecurring())return false;
if(this.isRecurring()&&this.get("recurrence_numexcept")>0)return true;var a=this.getSubStore("attachments");if(!a)return false;return a.findBy(function(b){return b.isRecurrenceException()})>=0}},afterOpen:function(){if(this.isRecurring()){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.openedSeries=!this.opened;this.updateMeetingRecipients()},isOpened:function(){return this.isRecurring()?this.openedSeries===true:this.opened===true},addMessageAction:function(a){Zarafa.calendar.AppointmentRecord.superclass.addMessageAction.apply(this,arguments);a==="send"&&
this.addMessageAction("meetingTimeInfo",this.generateMeetingTimeInfo(this.getBody()));if(a==="meetingTimeInfo")this.isOpened()?this.deleteMessageAction("append_body"):this.addMessageAction("append_body",true)},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(d){if(d.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);var c=[];a.each(function(d){c.push(d.copy())});
c.push(b);a.loadRecords({records:c},undefined,true);container.getShadowStore().on("update",this.addOrganizerAfterUpdate,this)}a.sortBy("ASC",function(d,e){var f=d.isMeetingOrganizer(),g=e.isMeetingOrganizer();return f!==g?f?-1:1:d.get("rowid")-e.get("rowid")})}else a.getCount()>0&&a.removeAll()},addOrganizerAfterUpdate:function(a,b,c){if(c===Ext.data.Record.COMMIT){container.getShadowStore().un("update",this.addOrganizerAfterUpdate,this);this.updateMeetingRecipients()}},convertToMeeting:function(){this.beginEdit();
this.set("meeting",Zarafa.core.mapi.MeetingStatus.MEETING);this.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_ORGANIZED);this.updateMeetingRecipients();this.endEdit()},convertToAppointment:function(){this.beginEdit();this.set("meeting",Zarafa.core.mapi.MeetingStatus.NONMEETING);this.set("responsestatus",Zarafa.core.mapi.ResponseStatus.RESPONSE_NONE);this.updateMeetingRecipients();this.endEdit()},convertToOccurenceRecord:function(){if(this.hasIdProp("basedate")===false){var a=this.copy();
a.set("recurring",false);a.addIdProp("basedate");if(!a.userIsStoreOwner()){var b=container.getHierarchyStore().getById(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("recurring",true);a.set("basedate","");a.set("exception",false);a.removeIdProp("basedate");return a}return this},prepareWeekDaysString:function(){for(var a=new Ext.util.MixedCollection,b=container.getSettingsModel().get("zarafa/v1/main/week_start"),
c=[],d=0;d<Date.dayNames.length;d++)a.add({dayName:Date.dayNames[(b+d)%7],dayValue:Math.pow(2,(b+d)%7)});var e=this.get("recurrence_weekdays");a.each(function(f){f.dayValue&e&&c.push(f.dayName)});if(c.length>1){a=c.length-1;c[a]=_("and ")+c[a]}return c.length===2?c.join(" "):c.join(", ")}});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.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:"flag_status"},{name:"flag_icon"},{name:"reply_time",type:"date",dateFormat:"timestamp",defaultValue:null},{name:"reply_requested"},{name:"response_requested"},{name:"source_message_info"},{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","reply-to",Zarafa.core.data.IPMRecipientStore);
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","reply-to",Zarafa.core.data.IPMRecipientStore);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.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.addFieldToMessageClass("IPM.TaskRequest",Zarafa.task.TaskRecordFields);Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.TaskRequest",Zarafa.core.data.MessageRecordFields);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.TaskRequest","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Task","createphantom",function(a,b){a.beginEdit();if(!b||!Ext.isDefined(b.reminder)){var c=false,d=container.getHierarchyStore().getById(a.get("store_entryid"));if(!d||!d.isPublicStore())c=container.getSettingsModel().get("zarafa/v1/contexts/task/default_reminder");a.set("reminder",c)}if(a.get("reminder")){c=(new Date).clearTime().add(Date.MINUTE,container.getSettingsModel().get("zarafa/v1/contexts/task/default_reminder_time"));a.set("reminder_time",
c)}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.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","reply-to",Zarafa.core.data.IPMRecipientStore);Zarafa.core.data.RecordFactory.addListenerToMessageClass("IPM.Schedule","createphantom",Zarafa.core.data.MessageRecordPhantomHandler);
Zarafa.calendar.MeetingRequestRecord=Ext.extend(Zarafa.calendar.AppointmentRecord,{isMeetingReceived:function(){return true},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 Ext.isDate(this.get("appointment_basedate"))},
isRecurringException:function(){return Ext.isDate(this.get("appointment_basedate"))&&this.get("appointment_exception")===true},isMeetingOutOfDate:function(){return this.get("meetingtype")===Zarafa.core.mapi.MeetingType.MEETING_OUT_OF_DATE},isAppointmentInPast:function(){var a=this.get("appointment_duedate");if(Ext.isDate(a)&&a.getTime()<(new Date).getTime())return true;return false},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,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);
