Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.AbstractQuickItemWidget=Ext.extend(Zarafa.core.ui.widget.Widget,{record:void 0,wrapCfg:void 0,wrap:void 0,resetOnSave:!0,resetOnSend:!0,hasDialog:!0,constructor:function(a){a=a||{};a.wrapCfg=Ext.applyIf(a.wrapCfg||{},{stateful:!1,height:200,closeOnSave:!1,closeOnSend:!1});a.wrapCfg.recordComponentPluginConfig=Ext.applyIf(a.wrapCfg.recordComponentPluginConfig||{},{useShadowStore:!1});this.wrap=new Zarafa.core.ui.MessageContentPanel(a.wrapCfg);this.wrap.update=this.update.createDelegate(this);
this.wrap.updateRecord=this.updateRecord.createDelegate(this);Ext.applyIf(a,{name:"quickitem",layout:"fit",items:[this.wrap]});Zarafa.widgets.quickitems.AbstractQuickItemWidget.superclass.constructor.call(this,a)},initWidget:function(){Zarafa.widgets.quickitems.AbstractQuickItemWidget.superclass.initWidget.apply(this,arguments);this.hasDialog&&this.tools.unshift({id:"plus",handler:this.dialog,scope:this})},initEvents:function(){Zarafa.widgets.quickitems.AbstractQuickItemWidget.superclass.initEvents.apply(this,
arguments);this.mon(this,"afterlayout",this.onAfterFirstLayout,this,{single:!0});this.resetOnSave&&this.mon(this.wrap,"aftersaverecord",this.reset,this,{buffer:1});this.resetOnSend&&this.mon(this.wrap,"aftersendrecord",this.reset,this,{buffer:1})},dialog:function(){this.wrap.inputAutoFocusPlugin.beginFocusEl.focus();this.wrap.saveRecord(!1);Zarafa.core.data.UIFactory.openCreateRecord(this.record);this.record=null;this.reset()},reset:function(){var a=container.getShadowStore();this.record&&a.remove(this.record,
!0);this.record=this.createRecord();a.add(this.record);this.wrap.setRecord(this.record)},createRecord:Ext.emptyFn,update:Ext.emptyFn,updateRecord:Ext.emptyFn,onAfterFirstLayout:function(){var a=container.getHierarchyStore();a.getDefaultStore()?this.reset():this.mon(a,"load",this.reset,this,{single:!0})},onDestroy:function(){Zarafa.widgets.quickitems.AbstractQuickItemWidget.superclass.onDestroy.apply(this,arguments);this.record&&container.getShadowStore().remove(this.record,!0)}});Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.QuickAppointmentWidget=Ext.extend(Zarafa.widgets.quickitems.AbstractQuickItemWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{wrapCfg:{recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0}),layout:"fit",items:[{xtype:"form",ref:"formPanel",layout:{type:"vbox",align:"stretch"},border:!1,bodyStyle:"background-color: inherit; padding: 5px;",defaults:{border:!1,labelLength:100,style:"padding-bottom: 2px"},items:[{xtype:"zarafa.compositefield",
hideLabel:!0,anchor:"100%",items:[{xtype:"label",width:100,text:_("Subject")+":"},{xtype:"textfield",flex:1,name:"subject",value:void 0,listeners:{change:this.onChange,scope:this}}]},{xtype:"zarafa.datetimeperiodfield",ref:"../datetimePeriod",defaultPeriod:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_appointment_period"),timeIncrement:container.getSettingsModel().get("zarafa/v1/contexts/calendar/default_zoom_level"),width:300,listeners:{change:this.onDateRangeFieldChange,
scope:this},startFieldConfig:{fieldLabel:_("Start time"),labelWidth:100,minValue:(new Date).clearTime()},endFieldConfig:{fieldLabel:_("End time"),labelWidth:100,minValue:(new Date).clearTime()}},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",items:[{xtype:"spacer",width:100},{xtype:"checkbox",name:"alldayevent",ref:"../../alldayCheck",hideLabel:!1,boxLabel:_("All Day Event"),handler:this.onToggleAllDay,scope:this}]},{xtype:"zarafa.editorfield",ref:"../editorField",htmlName:"html_body",
plaintextName:"body",hideLabel:!0,flex:1,useHtml:!1,defaultValue:"",listeners:{change:this.onBodyChange,scope:this}}]}]},buttons:[{text:_("Save"),handler:this.onSave,scope:this},{text:_("Discard"),handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickAppointmentWidget.superclass.constructor.call(this,a)},onChange:function(a,b){this.wrap.record.set(a.name,b)},onBodyChange:function(a,b,c){this.wrap.record.beginEdit();a instanceof Ext.form.HtmlEditor?this.wrap.record.set("isHTML",!0):
this.wrap.record.set("isHTML",!1);this.wrap.record.set(a.name,b);this.wrap.record.endEdit()},onDateRangeFieldChange:function(a,b,c){this.updateStartDueDate(this.wrap.record,b)},onToggleAllDay:function(a,b){if(this.wrap.record.get("alldayevent")!==b){var c=container.getSettingsModel();this.wrap.record.beginEdit();this.wrap.record.set("alldayevent",b);if(b)this.updateStartDueDate(this.wrap.record,this.wrap.datetimePeriod.getValue()),this.wrap.record.set("reminder_minutes",c.get("zarafa/v1/contexts/calendar/default_allday_reminder_time")),
this.wrap.record.set("busystatus",Zarafa.core.mapi.BusyStatus.FREE);else{var d=c.get("zarafa/v1/contexts/calendar/default_zoom_level"),f=c.get("zarafa/v1/contexts/calendar/default_appointment_period"),e=new Date;this.wrap.record.get("startdate")&&(e=this.wrap.record.get("startdate").clearTime(!0));e=e.ceil(Date.MINUTE,d);d=e.add(Date.MINUTE,f);this.wrap.record.set("reminder_minutes",c.get("zarafa/v1/contexts/calendar/default_reminder_time"));this.wrap.record.set("busystatus",Zarafa.core.mapi.BusyStatus.BUSY);
this.wrap.record.set("startdate",e);this.wrap.record.set("duedate",d);this.wrap.record.set("commonstart",e);this.wrap.record.set("commonend",d);this.wrap.record.set("duration",(d-e)/6E4)}this.wrap.record.endEdit()}},updateStartDueDate:function(a,b){var c=b.getStartDate().clone(),d=b.getDueDate().clone();!0===a.get("alldayevent")&&(c=c.clearTime(),d=d.add(Date.DAY,1).clearTime());a.beginEdit();a.set("startdate",c);a.set("duedate",d);a.set("commonstart",c);a.set("commonend",d);a.set("duration",(d-c)/
6E4);a.endEdit()},createRecord:function(){var a=container.getHierarchyStore().getDefaultFolder("calendar");return container.getContextByName("calendar").getModel().createRecord(a)},update:function(a,b){if(!0===b||a.isModifiedSinceLastUpdate("alldayevent"))a.get("alldayevent")?this.wrap.datetimePeriod.setEnabledTimeSelection(!1):this.wrap.datetimePeriod.setEnabledTimeSelection(!0);this.wrap.formPanel.getForm().loadRecord(a);var c=a.get("startdate"),d=!1;Ext.isDate(c)&&(c=c.clone(),d=b||a.isModifiedSinceLastUpdate("startdate"));
var f=a.get("duedate"),e=!1;Ext.isDate(f)&&(f=f.clone(),e=b||a.isModifiedSinceLastUpdate("duedate"));a.get("alldayevent")&&(f=f.add(Date.DAY,-1));(d||e)&&this.wrap.datetimePeriod.getValue().set(c,f)},updateRecord:function(a){a.beginEdit();this.wrap.formPanel.getForm().updateRecord(a);this.updateStartDueDate(a,this.wrap.datetimePeriod.getValue());this.onToggleAllDay(this.wrap.alldayCheck,this.wrap.alldayCheck.getValue());this.onBodyChange(this.wrap.editorField,this.wrap.editorField.getValue());a.endEdit()},
onSave:function(){this.wrap.saveRecord()},onDiscard:function(){this.reset()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quickappt",displayName:_("Quick Appointment"),iconPath:"plugins/quickitems/resources/images/quickappt.png",widgetConstructor:Zarafa.widgets.quickitems.QuickAppointmentWidget}))});Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.QuickContactWidget=Ext.extend(Zarafa.widgets.quickitems.AbstractQuickItemWidget,{contactParser:void 0,constructor:function(a){a=a||{};if(!a.contactParser){var b=container.getSharedComponent(Zarafa.core.data.SharedComponentType["contact.detailsparser"]);b&&(a.contactParser=new b)}Ext.applyIf(a,{wrapCfg:{recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0}),layout:"fit",items:[{xtype:"form",ref:"formPanel",layout:{type:"vbox",align:"stretch"},
border:!1,bodyStyle:"background-color: inherit; padding: 5px;",defaults:{border:!1,labelLength:100,style:"padding-bottom: 2px"},items:[{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",autoHeight:!0,items:[{xtype:"label",width:100,text:_("Full Name")+":"},{xtype:"textfield",flex:1,name:"display_name",ref:"../../fullnameField",listeners:{scope:this,change:this.onFullNameChange}}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",autoHeight:!0,items:[{xtype:"splitbutton",width:100,
text:_("Mobile")+":",handler:this.onPhoneButtonClick,scope:this,menu:this.initPhoneButtonMenu("cellular_telephone_number")},{xtype:"textfield",ref:"../../telephoneField",flex:1,name:"telephone_number",property:"cellular_telephone_number",listeners:{scope:this,change:this.onTelephoneNumberChange}}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",autoHeight:!0,items:[{xtype:"label",width:100,text:_("Email")+":"},{xtype:"textfield",flex:1,ref:"../../mailAddressField",name:"email_address_1",
listeners:{scope:this,change:this.onChange}}]},{xtype:"zarafa.editorfield",ref:"../editorField",htmlName:"html_body",plaintextName:"body",hideLabel:!0,flex:1,useHtml:!1,defaultValue:"",listeners:{change:this.onBodyChange,scope:this}}]}]},buttons:[{text:_("Save"),handler:this.onSave,scope:this},{text:_("Discard"),handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickContactWidget.superclass.constructor.call(this,a)},initPhoneButtonMenu:function(a){return{xtype:"menu",listeners:{click:this.onMenuItemSelection,
scope:this},defaults:{xtype:"menucheckitem",group:"phone_number"},items:[{text:_("Business"),property:"business_telephone_number",checked:"business_telephone_number"==a},{text:_("Company"),property:"company_telephone_number",checked:"company_telephone_number"==a},{text:_("Home"),property:"home_telephone_number",checked:"home_telephone_number"==a},{text:_("Mobile"),property:"cellular_telephone_number",checked:"cellular_telephone_number"==a},{text:_("Other"),property:"other_telephone_number",checked:"other_telephone_number"==
a}]}},onMenuItemSelection:function(a,b,c){Ext.isEmpty(b)||(c=a.findParentByType("zarafa.compositefield"),a=c.findByType("splitbutton")[0],c=c.findByType("textfield")[0],Ext.isEmpty(a)||Ext.isEmpty(c)||(a.setText(b.initialConfig.text),c.setValue(this.record.get(b.property)),c.property=b.property))},onPhoneButtonClick:function(a,b){this.showDetailedPhoneContent(a.ownerCt.findByType("textfield")[0].property)},onChange:function(a,b){this.wrap.record.set(a.name,b)},onTelephoneNumberChange:function(a,b){this.wrap.record.set(a.property,
b)},onFullNameChange:function(a,b){var c=this.contactParser.parseInfo("name",b);this.wrap.record.set("display_name",b);this.wrap.record.set("display_name_prefix",c.display_name_prefix);this.wrap.record.set("given_name",c.given_name);this.wrap.record.set("middle_name",c.middle_name);this.wrap.record.set("surname",c.surname);this.wrap.record.set("generation",c.generation);!0===c.incomplete_info&&(1!=container.getSettingsModel().get("zarafa/v1/contexts/contact/show_name_dialog")||Ext.isEmpty(b)||this.showDetailedNameContent(c))},
onBodyChange:function(a,b,c){this.wrap.record.beginEdit();a instanceof Ext.form.HtmlEditor?this.wrap.record.set("isHTML",!0):this.wrap.record.set("isHTML",!1);this.wrap.record.set(a.name,b);this.wrap.record.endEdit()},showDetailedNameContent:function(a){Zarafa.contact.Actions.openDetailedNameContent(this.wrap.record,{parser:this.contactParser,parsedData:a})},showDetailedPhoneContent:function(a){Zarafa.contact.Actions.openDetailedPhoneContent(this.wrap.record,{parser:this.contactParser,property:a})},
createRecord:function(){var a=container.getHierarchyStore().getDefaultFolder("contact");return container.getContextByName("contact").getModel().createRecord(a)},update:function(a,b){this.wrap.formPanel.getForm().loadRecord(a);this.wrap.telephoneField.setValue(a.get(this.wrap.telephoneField.property))},updateRecord:function(a){a.beginEdit();this.wrap.formPanel.getForm().updateRecord(a);this.onFullNameChange(this.wrap.fullnameField,this.wrap.fullnameField.getValue());a.updateSubject();a.updateAddressbookProps();
a.endEdit()},onSave:function(){this.wrap.saveRecord()},onDiscard:function(){this.reset()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quickcontact",displayName:_("Quick Contact"),iconPath:"plugins/quickitems/resources/images/quickcontact.png",widgetConstructor:Zarafa.widgets.quickitems.QuickContactWidget}))});Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.QuickMailWidget=Ext.extend(Zarafa.widgets.quickitems.AbstractQuickItemWidget,{useHtml:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{wrapCfg:{recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0}),layout:"fit",items:[{xtype:"form",ref:"formPanel",layout:{type:"vbox",align:"stretch"},border:!1,bodyStyle:"background-color: inherit; padding: 5px;",defaults:{border:!1,labelLength:100,style:"padding-bottom: 2px"},items:[{xtype:"zarafa.compositefield",
hideLabel:!0,anchor:"100%",autoHeight:!0,items:[{xtype:"label",width:100,text:_("To")+":"},{xtype:"zarafa.recipientfield",ref:"../toRecipientField",flex:1,height:30,defaultRecipientType:Zarafa.core.mapi.RecipientType.MAPI_TO}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",items:[{xtype:"label",width:100,text:_("Subject")+":"},{xtype:"textfield",flex:1,name:"subject",value:void 0,listeners:{change:this.onChange,scope:this}}]},{xtype:"zarafa.editorfield",ref:"../editorField",htmlName:"html_body",
plaintextName:"body",hideLabel:!0,flex:1,useHtml:a.useHtml,defaultValue:"",listeners:{change:this.onBodyChange,scope:this}}]}]},buttons:[{text:_("Send"),handler:this.onSend,scope:this},{text:_("Discard"),handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickMailWidget.superclass.constructor.call(this,a)},onChange:function(a,b){this.wrap.record.set(a.name,b)},onBodyChange:function(a,b,c){this.wrap.record.beginEdit();a instanceof Ext.form.HtmlEditor?this.wrap.record.set("isHTML",!0):
this.wrap.record.set("isHTML",!1);this.wrap.record.set(a.name,b);this.wrap.record.endEdit()},createRecord:function(){var a=container.getHierarchyStore().getDefaultFolder("drafts");return container.getContextByName("mail").getModel().createRecord(a)},update:function(a,b){this.wrap.formPanel.getForm().loadRecord(a);b&&this.wrap.formPanel.toRecipientField.setRecipientStore(a.getSubStore("recipients"))},updateRecord:function(a){a.beginEdit();this.wrap.formPanel.getForm().updateRecord(a);this.onBodyChange(this.wrap.editorField,
this.wrap.editorField.getValue());a.endEdit()},onSend:function(){this.wrap.sendRecord()},onDiscard:function(){this.reset()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quickmail",displayName:_("Quick Mail"),iconPath:"plugins/quickitems/resources/images/quickmail.png",widgetConstructor:Zarafa.widgets.quickitems.QuickMailWidget}))});Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.QuickNoteWidget=Ext.extend(Zarafa.widgets.quickitems.AbstractQuickItemWidget,{currentColorCls:void 0,constructor:function(a){a=a||{};Ext.applyIf(a,{wrapCfg:{recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0}),layout:"fit",items:[{xtype:"form",ref:"formPanel",layout:"fit",items:[{xtype:"textarea",ref:"../editorField",name:"body",listeners:{change:this.onChange,scope:this}}]}]},buttons:[{text:_("Save"),handler:this.onSave,scope:this},
{text:_("Discard"),handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickNoteWidget.superclass.constructor.call(this,a)},onChange:function(a,b){this.wrap.record.set(a.name,b)},createRecord:function(){var a=container.getHierarchyStore().getDefaultFolder("note");return container.getContextByName("note").getModel().createRecord(a)},update:function(a,b){this.wrap.formPanel.getForm().loadRecord(a);if(b||a.isModifiedSinceLastUpdate("icon_index")){var c;switch(a.get("icon_index")){case Zarafa.core.mapi.IconIndex.note_blue:c=
"stickynote_dialog_blue";break;case Zarafa.core.mapi.IconIndex.note_green:c="stickynote_dialog_green";break;case Zarafa.core.mapi.IconIndex.note_pink:c="stickynote_dialog_pink";break;default:c="stickynote_dialog_yellow";break;case Zarafa.core.mapi.IconIndex.note_white:c="stickynote_dialog_white"}this.wrap.editorField.removeClass(this.currentColorCls);this.currentColorCls=c;this.wrap.editorField.addClass(this.currentColorCls)}},updateRecord:function(a){a.beginEdit();this.wrap.formPanel.getForm().updateRecord(a);
this.record.generateSubject();a.endEdit()},onSave:function(){this.wrap.saveRecord()},onDiscard:function(){this.reset()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quicknote",displayName:_("Quick Note"),iconPath:"plugins/quickitems/resources/images/quicknote.png",widgetConstructor:Zarafa.widgets.quickitems.QuickNoteWidget}))});Ext.namespace("Zarafa.widgets.quickitems");
Zarafa.widgets.quickitems.QuickTaskWidget=Ext.extend(Zarafa.widgets.quickitems.AbstractQuickItemWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{wrapCfg:{recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0}),layout:"fit",items:[{xtype:"form",ref:"formPanel",layout:{type:"vbox",align:"stretch"},border:!1,bodyStyle:"background-color: inherit; padding: 5px;",defaults:{border:!1,labelLength:100,style:"padding-bottom: 2px"},items:[{xtype:"zarafa.compositefield",
hideLabel:!0,anchor:"100%",items:[{xtype:"label",width:100,text:_("Subject")+":"},{xtype:"textfield",flex:1,name:"subject",value:void 0,listeners:{change:this.onChange,scope:this}}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",items:[{xtype:"label",width:100,text:_("End date")+":"},{xtype:"datefield",ref:"../../dueDateField",emptyText:_("None"),flex:1,name:"commonend",utcname:"duedate",format:_("d/m/Y"),minValue:new Date,listeners:{change:this.onDueDateChange,scope:this}}]},{xtype:"zarafa.editorfield",
ref:"../editorField",htmlName:"html_body",plaintextName:"body",hideLabel:!0,flex:1,useHtml:!1,defaultValue:"",listeners:{change:this.onBodyChange,scope:this}}]}]},buttons:[{text:_("Save"),handler:this.onSave,scope:this},{text:_("Discard"),handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickTaskWidget.superclass.constructor.call(this,a)},onChange:function(a,b){this.wrap.record.set(a.name,b)},onDueDateChange:function(a,b,c){Ext.isDate(b)?(this.wrap.record.set(a.name,b.clone()),this.wrap.record.set(a.utcname,
b.toUTC())):(this.wrap.record.set(a.name,null),this.wrap.record.set(a.utcname,null))},onBodyChange:function(a,b,c){this.wrap.record.beginEdit();a instanceof Ext.form.HtmlEditor?this.wrap.record.set("isHTML",!0):this.wrap.record.set("isHTML",!1);this.wrap.record.set(a.name,b);this.wrap.record.endEdit()},createRecord:function(){var a=container.getHierarchyStore().getDefaultFolder("task");return container.getContextByName("task").getModel().createRecord(a)},update:function(a,b){this.wrap.formPanel.getForm().loadRecord(a)},
updateRecord:function(a){a.beginEdit();this.wrap.formPanel.getForm().updateRecord(a);this.onDueDateChange(this.wrap.dueDateField,this.wrap.dueDateField.getValue());this.onBodyChange(this.wrap.editorField,this.wrap.editorField.getValue());a.endEdit()},onSave:function(){this.wrap.saveRecord()},onDiscard:function(){this.reset()}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quicktask",displayName:_("Quick Task"),iconPath:"plugins/quickitems/resources/images/quicktask.png",widgetConstructor:Zarafa.widgets.quickitems.QuickTaskWidget}))});//# sourceMappingURL=quickitems.js.map
