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",qtip:_("Open in new tab"),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)},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()},onSave:function(){this.wrap.saveRecord()},onDiscard:function(){this.reset()}});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:"textfield",flex:1,name:"subject",emptyText:_("Subject")+":",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"),listeners:{change:this.onDateRangeFieldChange,scope:this},startFieldConfig:{minValue:(new Date).clearTime()},
endFieldConfig:{minValue:(new Date).clearTime()}},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",items:[{xtype:"checkbox",name:"alldayevent",ref:"../../alldayCheck",hideLabel:!1,boxLabel:_("All Day Event"),height:15,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"),cls:"zarafa-action",
style:"padding-bottom: 5px",handler:this.onSave,scope:this},{text:_("Discard"),style:"padding-bottom: 5px",handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickAppointmentWidget.superclass.constructor.call(this,a)},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(void 0,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()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quickappt",displayName:_("Quick Appointment"),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%",height:30,items:[{xtype:"textfield",flex:1,name:"display_name",emptyText:_("Full Name")+":",ref:"../../fullnameField",listeners:{scope:this,change:this.onFullNameChange}}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",height:33,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%",items:[{xtype:"textfield",flex:1,emptyText:_("Email")+":",ref:"../../mailAddressField",name:"email_address_1",height:30,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"),cls:"zarafa-action",style:"padding-bottom: 5px",handler:this.onSave,scope:this},{text:_("Discard"),style:"padding-bottom: 5px",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"),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:20,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:"textfield",flex:1,name:"subject",emptyText:_("Subject")+":",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"),cls:"zarafa-action",style:"padding-bottom: 5px",handler:this.onSend,scope:this},{text:_("Discard"),style:"padding-bottom: 5px",handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickMailWidget.superclass.constructor.call(this,a)},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()}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quickmail",displayName:_("Quick Mail"),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"),cls:"zarafa-action",style:"padding-bottom: 5px",
handler:this.onSave,scope:this},{text:_("Discard"),style:"padding-bottom: 5px",handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickNoteWidget.superclass.constructor.call(this,a)},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()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quicknote",displayName:_("Quick Note"),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:"textfield",flex:1,name:"subject",emptyText:_("Subject")+":",listeners:{change:this.onChange,scope:this}}]},{xtype:"zarafa.compositefield",hideLabel:!0,anchor:"100%",items:[{},{xtype:"datefield",ref:"../../dueDateField",emptyText:_("End date")+": "+_("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"),cls:"zarafa-action",style:"padding-bottom: 5px",handler:this.onSave,scope:this},{text:_("Discard"),style:"padding-bottom: 5px",handler:this.onDiscard,scope:this}]});Zarafa.widgets.quickitems.QuickTaskWidget.superclass.constructor.call(this,a)},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))},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()}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"quicktask",displayName:_("Quick Task"),widgetConstructor:Zarafa.widgets.quickitems.QuickTaskWidget}))});//# sourceMappingURL=quickitems.js.map
