Ext.namespace("Zarafa.plugins.passwd"),Zarafa.plugins.passwd.PasswdPlugin=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){Zarafa.plugins.passwd.PasswdPlugin.superclass.initPlugin.apply(this,arguments),this.registerInsertionPoint("context.settings.categories",this.createSettingsCategory,this)},createSettingsCategory:function(s,t,e){return{xtype:"zarafa.settingspasswdcategory",settingsContext:e}}}),Zarafa.onReady((function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"passwd",displayName:_("Change Password"),about:Zarafa.plugins.passwd.ABOUT,pluginConstructor:Zarafa.plugins.passwd.PasswdPlugin}))})),Ext.namespace("Zarafa.plugins.passwd.data"),Zarafa.plugins.passwd.data.PasswdResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{callbackFn:void 0,scope:void 0,doError:function(s){var t=_("An unknown error occurred while changing password.");s.info&&(t=s.info.display_message),Ext.MessageBox.alert(_("Error"),t),this.callbackFn.apply(this.scope||this,[!1,s])},doSuccess:function(s){var t=_("Password is changed successfully.");s.info&&(t=s.info.display_message),Ext.MessageBox.alert(_("Success"),t),this.callbackFn.apply(this.scope||this,[!0,s])}}),Ext.namespace("Ext.ux.form.field"),
/**
 * @class Ext.ux.form.field.PasswordMeter
 * @extends Ext.form.TextField
 * @xtype ux.passwordmeterfield
 *
 * @author Christoph Haas <christoph.h@sprinternet.at>
 * @version 0.1
 * @license MIT License: http://www.opensource.org/licenses/mit-license.php
 *
 * This implementation of the password fields shows a nice graph of how
 * secure the password is.
 * Original implementation for ExtJS 1.1 from http://testcases.pagebakers.com/PasswordMeter/.
 */
Ext.ux.form.field.PasswordMeter=Ext.extend(Ext.form.TextField,{constructor:function(s){s=s||{},Ext.applyIf(s,{xtype:"ux.passwordmeterfield",inputType:"password",enableKeyEvents:!0}),Ext.ux.form.field.PasswordMeter.superclass.constructor.call(this,s)},initComponent:function(){Ext.ux.form.field.PasswordMeter.superclass.initComponent.apply(this,arguments)},reset:function(){Ext.ux.form.field.PasswordMeter.superclass.reset.call(this),this.updateMeter()},onKeyUp:function(s){Ext.ux.form.field.PasswordMeter.superclass.onKeyUp.call(this),this.updateMeter(this.getValue()),this.fireEvent("keyup",this,s)},afterRender:function(){Ext.ux.form.field.PasswordMeter.superclass.afterRender.call(this);var s=this.getEl().getWidth(),t=Ext.id();this.strengthMeterID=t,this.scoreBarID=Ext.id();var e=Ext.DomHelper.insertAfter(this.getEl(),{tag:"div",class:"x-form-strengthmeter",id:this.strengthMeterID,style:{width:s+"px"}});Ext.DomHelper.append(e,{tag:"div",class:"x-form-strengthmeter-scorebar",id:this.scoreBarID}),this.fireEvent("afterrender",this)},getScore:function(){return this.calcStrength(this.getValue())},updateMeter:function(s){var t,e,a,n;a=Ext.get(this.strengthMeterID),n=Ext.get(this.scoreBarID),t=a.getWidth(),s?(e=t-t/100*this.calcStrength(s),n.applyStyles({margin:"0 0 0 "+(t-e)+"px"}),n.setWidth(e,!1)):(n.applyStyles({margin:"0"}),n.setWidth(t,!1))},calcStrength:function(s){var t=s.length,e=t;return t>0&&t<=4?e+=t:t>=5&&t<=7?e+=6:t>=8&&t<=15?e+=12:t>=16&&(e+=18),s.match(/[a-z]/)&&(e+=1),s.match(/[A-Z]/)&&(e+=5),s.match(/\d/)&&(e+=5),s.match(/(?:.*?\d){3}/)&&(e+=5),s.match(/[\!,@,#,$,%,\^,&,\*,\?,_,~]/)&&(e+=5),s.match(/(?:.*?[\!,@,#,$,%,\^,&,\*,\?,_,~]){2}/)&&(e+=5),s.match(/(?=.*[a-z])(?=.*[A-Z])/)&&(e+=2),s.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/)&&(e+=2),s.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\!,@,#,$,%,\^,&,\*,\?,_,~])/)&&(e+=2),Math.min(Math.round(2*e),100)}}),Ext.reg("ux.passwordmeterfield",Ext.ux.form.field.PasswordMeter),Ext.namespace("Zarafa.plugins.passwd.settings"),Zarafa.plugins.passwd.settings.PasswdPanel=Ext.extend(Ext.form.FormPanel,{constructor:function(s){s=s||{},Ext.applyIf(s,{xtype:"zarafa.passwdpanel",labelWidth:200,defaults:{width:200},border:!1,items:[{xtype:"displayfield",name:"username",fieldLabel:_("Account")},{xtype:"textfield",name:"current_password",ref:"current_password",fieldLabel:_("Current password"),inputType:"password",allowBlank:!1,listeners:{change:this.onFieldChange,scope:this}},{xtype:"ux.passwordmeterfield",name:"new_password",ref:"new_password",allowBlank:!1,fieldLabel:_("New password"),listeners:{change:this.onFieldChange,scope:this}},{xtype:"ux.passwordmeterfield",name:"new_password_repeat",allowBlank:!1,ref:"new_password_repeat",fieldLabel:_("Retype new password"),listeners:{change:this.onFieldChange,scope:this}}]}),this.addEvents("userchange"),Zarafa.plugins.passwd.settings.PasswdPanel.superclass.constructor.apply(this,arguments),this.on("afterrender",this.initialize,this)},initialize:function(){this.getForm().setValues({username:container.getUser().getUserName()})},onFieldChange:function(s,t,e){this.fireEvent("userchange",this)}}),Ext.reg("zarafa.passwdpanel",Zarafa.plugins.passwd.settings.PasswdPanel),Ext.namespace("Zarafa.plugins.passwd.settings"),Zarafa.plugins.passwd.settings.SettingsPasswdCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(s){s=s||{},Ext.applyIf(s,{title:_("Change Password"),categoryIndex:9997,iconCls:"zarafa-settings-category-passwd",xtype:"zarafa.settingspasswdcategory",items:[{xtype:"zarafa.settingspasswdwidget",settingsContext:s.settingsContext},container.populateInsertionPoint("context.settings.category.passwd",this)]}),Zarafa.plugins.passwd.settings.SettingsPasswdCategory.superclass.constructor.call(this,s)}}),Ext.reg("zarafa.settingspasswdcategory",Zarafa.plugins.passwd.settings.SettingsPasswdCategory),Ext.namespace("Zarafa.plugins.passwd.settings"),Zarafa.plugins.passwd.settings.SettingsPasswdWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(s){s=s||{},Ext.applyIf(s,{title:_("Change Password"),xtype:"zarafa.settingspasswdwidget",layout:"form",items:[{xtype:"zarafa.passwdpanel",ref:"passwdPanel",listeners:{userchange:this.setModelDirty,scope:this}}]}),Zarafa.plugins.passwd.settings.SettingsPasswdWidget.superclass.constructor.call(this,s)},initEvents:function(){Zarafa.plugins.passwd.settings.SettingsPasswdWidget.superclass.initEvents.call(this);var s=this.settingsContext.getModel();this.mon(s,"beforesavesettings",this.onBeforeSaveSettings,this),this.mon(s,"savesettings",this.onSaveSettings,this),this.mon(s,"discardsettings",this.onDiscardSettings,this)},onBeforeSaveSettings:function(){return 0==this.ownerCt.isVisible()||(this.passwdPanel.new_password.getValue()!=this.passwdPanel.new_password_repeat.getValue()?(Ext.MessageBox.alert(_("Error"),_("New passwords do not match.")),!1):Ext.isEmpty(this.passwdPanel.current_password.getValue())?(Ext.MessageBox.alert(_("Error"),_("Current password is empty.")),!1):Ext.isEmpty(this.passwdPanel.new_password.getValue())||Ext.isEmpty(this.passwdPanel.new_password_repeat.getValue())?(Ext.MessageBox.alert(_("Error"),_("New password is empty.")),!1):this.passwdPanel.getForm().isValid()?!(container.getSettingsModel().get("zarafa/v1/plugins/passwd/enable_strict_check")&&this.passwdPanel.new_password.getScore()<70)||(Ext.MessageBox.alert(_("Error"),_("Password is weak. Password should contain capital, non-capital letters and numbers. Password should have 8 to 20 characters.")),!1):(Ext.MessageBox.alert(_("Error"),_("One or more fields does contain errors.")),!1))},onSaveSettings:function(){if(this.ownerCt.isVisible()){this.ownerCt.displaySavingMask();var s=this.passwdPanel.getForm().getFieldValues();container.getRequest().singleRequest("passwdmodule","save",s,new Zarafa.plugins.passwd.data.PasswdResponseHandler({callbackFn:function(s,t){this.ownerCt.hideSavingMask(s),s&&this.passwdPanel.getForm().reset()},scope:this}))}},onDiscardSettings:function(){this.passwdPanel.getForm().reset()},setModelDirty:function(){var s=this.settingsContext.getModel();s.hasChanges()||s.setDirty()}}),Ext.reg("zarafa.settingspasswdwidget",Zarafa.plugins.passwd.settings.SettingsPasswdWidget);
//# sourceMappingURL=passwd.js.map