Ext.namespace("Zarafa.plugins.meet.ui");
Zarafa.plugins.meet.ui.AddMeetingDialog=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{};var b="xsedf";a.source&&a.source.record&&(b=a.source.record.get("subject"));a=Ext.applyIf(a,{xtype:"meet_addmeetingdialog",layout:"form",title:_("Add meeting"),width:320,height:135,style:{maxHeight:"135px"},items:[{xtype:"displayfield",hideLabel:!0,value:_("Room name:"),style:{marginTop:"5px",marginLeft:"5px"}},{xtype:"textfield",hideLabel:!0,value:b,ref:"roomNameBox",style:{marginTop:"0px",
marginLeft:"5px",paddingRight:"0px",width:"95%"},listeners:{blur:this.onRoomNameBlur.bind(this)}},{xtype:"displayfield",hideLabel:!0,value:_("Room URL:"),style:{marginTop:"5px",marginLeft:"5px"}},{xtype:"textfield",hideLabel:!0,ref:"roomUrlBox",style:{marginTop:"0px",marginLeft:"5px",paddingRight:"0px",width:"95%"}},{xtype:"button",text:_("Add meeting"),scope:this,handler:this.addMeeting,style:{marginTop:"0px",marginLeft:"5px",paddingRight:"0px",width:"95%"}}]});Zarafa.plugins.meet.ui.AddMeetingDialog.superclass.constructor.call(this,
a)},onRoomNameBlur:function(){this.roomUrlBox.setValue(container.getSettingsModel().get("zarafa/v1/plugins/meet/server")+this.roomNameBox.getValue().replace(/[^a-zA-Z0-9\-]/g,"_").replace(/_{2,}/g,"_").replace(/^_+|_+$/g,""))},addMeeting:function(){if(this.source&&this.source.record){this.source.record.jitsiCurrentUrl=this.roomUrlBox.getValue();var a=null;switch(this.source.record.get("message_class")){case "IPM.Note":a=this.source.ownerCt.ownerCt.editorField;break;case "IPM.Appointment":var b=this.source.record.get("location");
b&&!container.getSettingsModel().get("zarafa/v1/plugins/meet/locationoverride")?this.source.record.set("location",b+" / "+this.source.record.jitsiCurrentUrl):this.source.record.set("location",this.source.record.jitsiCurrentUrl);container.getSettingsModel().get("zarafa/v1/plugins/meet/noinvitation")||(a=this.source.ownerCt.ownerCt.appointmentTab.editorField)}if(a){b=this.source.record.jitsiCurrentUrl;var c=container.getSettingsModel().get("zarafa/v1/plugins/meet/invitationmessage")||"\n%url%\n";a.isHtmlEditor()&&
(b="<a href="+b+">"+b+"</a>",c=c.replace(/(\r\n|\n|\r)/gm,"<br/>"));a.insertAtCursor(c.replace(/%url%/g,b))}}this.doClose()}});Ext.reg("meet_addmeetingdialog",Zarafa.plugins.meet.ui.AddMeetingDialog);Ext.namespace("Zarafa.plugins.meet");
Zarafa.plugins.meet.Plugin=Ext.extend(Zarafa.core.Plugin,{plugin:void 0,initPlugin:function(){Zarafa.core.data.SharedComponentType.addProperty("plugins.meet.panel");Zarafa.core.data.SharedComponentType.addProperty("plugins.meet.addmeetingdialog");this.registerInsertionPoint("context.settings.categories",this.createSettingsCategory,this);container.getSettingsModel().get("zarafa/v1/plugins/meet/hidetabbarbutton")||this.registerInsertionPoint("main.toolbar.actions.last",this.createToolbarButton,this);
this.registerInsertionPoint("context.calendar.appointmentcontentpanel.toolbar.actions",this.createAddMeetingButton,this);this.registerInsertionPoint("context.calendar.appointmentcontentpanel.toolbar.actions",this.createJoinMeetingButton,this);this.registerInsertionPoint("context.mail.mailcreatecontentpanel.toolbar.actions",this.createAddMeetingButton,this);if(!container.getSettingsModel().get("zarafa/v1/plugins/meet/nolocationfix")){var a=Zarafa.calendar.dialogs.AppointmentTab.prototype.doSetLocation;
Zarafa.calendar.dialogs.AppointmentTab.prototype.doSetLocation=function(){"meetCurrentUrl"in this.record&&0>arguments[0].indexOf(this.record.meetCurrentUrl)&&(container.getSettingsModel().get("zarafa/v1/plugins/meet/locationoverride")?arguments[0]=this.record.meetCurrentUrl:arguments[0]+=(arguments[0]?" / ":"")+this.record.meetCurrentUrl);a.apply(this,arguments)};var b=Zarafa.calendar.dialogs.AppointmentTab.prototype.onFieldChange;Zarafa.calendar.dialogs.AppointmentTab.prototype.onFieldChange=function(){"location"==
arguments[0].getName()&&"meetCurrentUrl"in this.record&&0>arguments[1].indexOf(this.record.meetCurrentUrl)&&delete this.record.meetCurrentUrl;b.apply(this,arguments)}}},createSettingsCategory:function(){return{xtype:"grommunio.meet.settingscategory",plugin:this}},createToolbarButton:function(){return[{newMenuIndex:10,xtype:"button",scale:"large",tooltip:"Meet",iconCls:"icon_meet_32",handler:this.onToolbarButtonClick,scope:this}]},createAddMeetingButton:function(){return{xtype:"button",text:_("Add meeting"),
iconCls:"icon_meet",handler:this.onAddMeetingButtonClick,scope:this,plugins:["zarafa.recordcomponentupdaterplugin"],tooltip:_("Shift-click for advanced settings"),update:function(a,b){this.record=a;(new RegExp(container.getSettingsModel().get("zarafa/v1/plugins/meet/server").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"[-a-zA-Z0-9()@:%_+.~#?&/=]+")).test(a.get("location"))?this.setDisabled(!0):this.setDisabled(!1)}}},createJoinMeetingButton:function(){return{xtype:"button",text:_("Join webmeeting"),iconCls:"icon_meet",
handler:this.onJoinMeetingButtonClick,scope:this,plugins:["zarafa.recordcomponentupdaterplugin"],update:function(a,b){this.record=a;/https?:\/\/[a-zA-Z0-9-\.]+(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)?/.test(a.get("location"))?this.setDisabled(!1):this.setDisabled(!0)}}},onAddMeetingButtonClick:function(a,b){if(b.shiftKey)Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["plugins.meet.addmeetingdialog"],null,{modal:!0,source:a});else{b=0;var c,d=container.getUser().getUserName()+
navigator.userAgent+(new Date).valueOf();for(c=0;c<d.length;c++){var e=d.charCodeAt(c);b=(b<<5)-b+e;b|=0}0>b&&(b+=2147483647);c="";container.getSettingsModel().get("zarafa/v1/plugins/meet/mname_nosubject")||(c+=(a.record.get("subject")||"meet").replace(/[^a-zA-Z0-9\-@\.]/g,"_").replace(/_{2,}/g,"_").replace(/^_+|_+$/g,"")+"-");container.getSettingsModel().get("zarafa/v1/plugins/meet/mname_noorganizer")||(c+=container.getUser().getUserName().replace(/\./g,"_").replace("@","_")+"-");a.record.meetCurrentUrl=
container.getSettingsModel().get("zarafa/v1/plugins/meet/server")+c+b.toString(16);b=null;switch(a.record.get("message_class")){case "IPM.Note":b=a.ownerCt.ownerCt.editorField;break;case "IPM.Appointment":(b=a.record.get("location"))&&!container.getSettingsModel().get("zarafa/v1/plugins/meet/locationoverride")?a.record.set("location",b+" / "+a.record.meetCurrentUrl):a.record.set("location",a.record.meetCurrentUrl);if(container.getSettingsModel().get("zarafa/v1/plugins/meet/noinvitation"))return;b=
a.ownerCt.ownerCt.appointmentTab.editorField}b&&(a=a.record.meetCurrentUrl,c=container.getSettingsModel().get("zarafa/v1/plugins/meet/invitationmessage")||"\n%url%\n",b.isHtmlEditor()&&(a="<a href="+a+">"+a+"</a>",c=c.replace(/(\r\n|\n|\r)/gm,"<br/>")),b.insertAtCursor(c.replace(/%url%/g,a)))}},onJoinMeetingButtonClick:function(a){var b=/https?:\/\/[a-zA-Z0-9-\.]+(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)?/.exec(a.record.get("location"));b&&this.openMeeting(b[0],a.record.get("subject"))},onToolbarButtonClick:function(){this.openMeeting(container.getSettingsModel().get("zarafa/v1/plugins/meet/server"),
"Meet")},openMeeting:function(a,b){switch(container.getSettingsModel().get("zarafa/v1/plugins/meet/openin")){case "browser":window.open(a);break;case "popup":window.open(a,"_blank","location=no,height=768,width=1024,scrollbars=yes,status=yes");break;default:Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["plugins.meet.panel"],null,{url:a,title:"Meet",iconCls:"icon_meet",tabOrder:(new Date).valueOf()})}},bidSharedComponent:function(a,b){b=-1;switch(a){case Zarafa.core.data.SharedComponentType["plugins.meet.panel"]:b=
1;break;case Zarafa.core.data.SharedComponentType["plugins.meet.addmeetingdialog"]:b=1}return b},getSharedComponent:function(a,b){switch(a){case Zarafa.core.data.SharedComponentType["plugins.meet.panel"]:return Zarafa.plugins.meet.ui.ContentPanel;case Zarafa.core.data.SharedComponentType["plugins.meet.addmeetingdialog"]:return Zarafa.plugins.meet.ui.AddMeetingDialog}}});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"meet",displayName:"Meet",pluginConstructor:Zarafa.plugins.meet.Plugin}))});
Ext.namespace("Zarafa.plugins.meet");Zarafa.plugins.meet.SettingsCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:"Meet",categoryIndex:9947,xtype:"grommunio.meet.settingscategory",iconCls:"icon_meet",items:[{xtype:"grommunio.meet.settingswidget",settingsContext:a.settingsContext}]});Zarafa.plugins.meet.SettingsCategory.superclass.constructor.call(this,a)}});Ext.reg("grommunio.meet.settingscategory",Zarafa.plugins.meet.SettingsCategory);
Zarafa.plugins.meet.SettingsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"grommunio.meet.settingswidget",title:"Meet",layout:"form",items:[{xtype:"displayfield",hideLabel:!0,value:_("Open meeting in:")},{xtype:"radiogroup",ref:"openInRadio",hideLabel:!0,columns:1,items:[{xtype:"radio",name:"openin",inputValue:"web",boxLabel:_("Web tab")},{xtype:"radio",name:"openin",inputValue:"popup",boxLabel:"Popup"},{xtype:"radio",name:"openin",inputValue:"browser",
boxLabel:_("Browser window")}]},{xtype:"checkbox",ref:"hideTabbarButtonCheckbox",boxLabel:_("Hide the button in the main toolbar"),checked:!1,hideLabel:!0,style:"margin-top: 5px"},{xtype:"checkbox",ref:"mnameAddSubject",boxLabel:_("Add the subject to the room name"),checked:!0,hideLabel:!0,style:"margin-top: 5px"},{xtype:"checkbox",ref:"mnameAddOrganizer",boxLabel:_("Add the organizer name to the room name"),checked:!0,hideLabel:!0,style:"margin-top: 5px"},{xtype:"checkbox",ref:"locationAddCheckbox",
boxLabel:_("Add the URL to the meeting location rather than overwriting it"),checked:!0,hideLabel:!0,style:"margin-top: 5px"},{xtype:"checkbox",ref:"locationFixCheckbox",boxLabel:_("Prevent the URL in the meeting location from being overridden automatically (ex: when adding a meetingroom)")+'<span class="k-settings-label-minor">('+_("If you have problems when creating meetings, try disabling this setting")+")</span>",checked:!0,hideLabel:!0,style:"margin-top: 5px"},{xtype:"checkbox",ref:"addInvitationCheckbox",
boxLabel:_("Add an invitation to the appointment description"),checked:!0,hideLabel:!0,style:"margin-top: 5px"},{xtype:"displayfield",hideLabel:!0,style:"margin-top: 5px",value:_("Invitation text")+': <span class="k-settings-label-minor">('+_("must contain %url% as a placeholder for the meeting link, empty the textbox to reset to default")+")</span>"},{xtype:"textarea",ref:"invitationEditor",hideLabel:!0,grow:!0,anchor:"100%"}]});Zarafa.plugins.meet.SettingsWidget.superclass.constructor.call(this,
a)},update:function(a){this.openInRadio.setValue(a.get("zarafa/v1/plugins/meet/openin")||"web");this.hideTabbarButtonCheckbox.setValue(a.get("zarafa/v1/plugins/meet/hidetabbarbutton"));this.locationAddCheckbox.setValue(!a.get("zarafa/v1/plugins/meet/locationoverride"));this.locationFixCheckbox.setValue(!a.get("zarafa/v1/plugins/meet/nolocationfix"));this.addInvitationCheckbox.setValue(!a.get("zarafa/v1/plugins/meet/noinvitation"));this.invitationEditor.setValue(a.get("zarafa/v1/plugins/meet/invitationmessage")||
"");this.mnameAddSubject.setValue(!container.getSettingsModel().get("zarafa/v1/plugins/meet/mname_nosubject"));this.mnameAddOrganizer.setValue(!container.getSettingsModel().get("zarafa/v1/plugins/meet/mname_noorganizer"))},updateSettings:function(a){a.beginEdit();if(a.get("zarafa/v1/plugins/meet/hidetabbarbutton")!=this.hideTabbarButtonCheckbox.checked||a.get("zarafa/v1/plugins/meet/nolocationfix")==this.locationFixCheckbox.checked)a.requiresReload=!0;a.set("zarafa/v1/plugins/meet/openin",this.openInRadio.getValue().inputValue);
a.set("zarafa/v1/plugins/meet/hidetabbarbutton",this.hideTabbarButtonCheckbox.checked);a.set("zarafa/v1/plugins/meet/locationoverride",!this.locationAddCheckbox.checked);a.set("zarafa/v1/plugins/meet/nolocationfix",!this.locationFixCheckbox.checked);a.set("zarafa/v1/plugins/meet/noinvitation",!this.addInvitationCheckbox.checked);a.set("zarafa/v1/plugins/meet/mname_nosubject",!this.mnameAddSubject.checked);a.set("zarafa/v1/plugins/meet/mname_noorganizer",!this.mnameAddOrganizer.checked);this.invitationEditor.getValue()?
this.invitationEditor.getValue()!=a.get("zarafa/v1/plugins/meet/invitationmessage")&&a.set("zarafa/v1/plugins/meet/invitationmessage",this.invitationEditor.getValue()):(a.remove("zarafa/v1/plugins/meet/invitationmessage"),a.requiresReload=!0);a.endEdit()}});Ext.reg("grommunio.meet.settingswidget",Zarafa.plugins.meet.SettingsWidget);Ext.namespace("Zarafa.plugins.meet.ui");
Zarafa.plugins.meet.ui.ContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"meet_contentpanel",layout:"fit",iconCls:a.iconCls,border:!1,items:[{xtype:"meet_panel",url:a.url,tabOrder:a.tabOrder}]});Zarafa.plugins.meet.ui.ContentPanel.superclass.constructor.call(this,a)}});Ext.reg("meet_contentpanel",Zarafa.plugins.meet.ui.ContentPanel);
Zarafa.plugins.meet.ui.Panel=Ext.extend(Ext.Panel,{iframeId:void 0,isLoadMaskShown:!1,loadMask:void 0,constructor:function(a){a=a||{};this.iframeId="meet-iframe-"+a.tabOrder;this.tag="iframe";Ext.applyIf(a,{xtype:"meet_panel",layout:"fit",header:!1,html:{tag:this.tag,id:this.iframeId,cls:"meet-iframe",src:a.url,style:"display:block",allow:"microphone *; camera *; display-capture *;"},listeners:{afterrender:this.onAfterRender,scope:this}});Zarafa.plugins.meet.ui.Panel.superclass.constructor.call(this,
a)},onAfterRender:function(){this.showLoadMask();document.getElementById(this.iframeId).addEventListener("webview"===this.tag?"contentload":"load",function(){this.hideLoadMask()}.createDelegate(this))},handleDialogRequests:function(a){if("alert"===a.messageType)window.alert(a.messageText);else if("confirm"===a.messageType)window.confirm(a.messageText)?a.dialog.ok():a.dialog.cancel();else if("prompt"===a.messageType){var b=window.prompt(a.messageText);null===b?a.dialog.cancel():a.dialog.ok(b)}},handlePermissionRequests:function(a){a.preventDefault();
switch(a.permission){case "download":case "media":case "loadplugin":a.request.allow();break;case "pointerLock":case "fullscreen":case "geolocation":a.request.deny();break;default:a.request.deny()}},handleNewWindowRequests:function(a){a.window.discard()},showLoadMask:function(a){!0!==this.isLoadMaskShown&&(this.loadMask||(this.loadMask=new Zarafa.common.ui.LoadMask(this.ownerCt.el)),a?this.loadMask.showError():(this.loadMask.show(),this.isLoadMaskShown=!0))},hideLoadMask:function(){!1!==this.isLoadMaskShown&&
this.loadMask&&(this.loadMask.hide(),this.isLoadMaskShown=!1)}});Ext.reg("meet_panel",Zarafa.plugins.meet.ui.Panel);//# sourceMappingURL=meet.js.map
