(function(){"use strict";u8.Crm.Widgets.ChangePasswordBox=function(e,s){this.Widget(e,$.extend({},u8.Crm.Widgets.ChangePasswordBox.defaults,s));this.commandBindings={Apply:this._onCommandApply.bind(this),Cancel:this._onCommandCancel.bind(this)};this._validator=u8.Base.ValidationManager.addToWidget(this,$.extend({summarySelector:"#"+this.id+"_validationsummary"},this.validator));this._create()};u8.Crm.Widgets.ChangePasswordBox.defaults={template:"~/crm/changePassword.utml.htm",showCancel:true};u8.Crm.Widgets.ChangePasswordBox.makeClass({name:"ChangePasswordBox",deriveFrom:u8.Base.Widgets.Widget,events:["Apply","Cancel"]});$.extend(u8.Crm.Widgets.ChangePasswordBox.prototype,{dispose:function(){if(this._isDisposed){return}this.Widget_dispose()},_create:function(e){this.empty();var s=this,t=u8.resolveUrl(this.template);this.context=this.model={id:this.id,oldPassword:"",newPassword:"",newPasswordConfirm:"",showCancel:this.showCancel};u8.Base.Templates.execute(this.element,{url:t,name:"changePasswordTemplate",data:this.model,itemOptions:{parent:this}},function(){var e=u8.Base.Widgets.Tools.getFirstFocusableDescendant(s);if(e){e.focus()}}.chain(e))},_onCommandApply:function(){var e=this.model.oldPassword,s=this.model.newPassword,t=this.model.newPasswordConfirm;if(s!=t){return this.notify($t("TXT_changepw_text_6"),this.children.get("txtNewPasswordConfirm"))}var i=this.children.get("btnApply");if(i){i.setDisabled(true)}var n={userName:this.userName||u8.session.identity.userName,oldPassword:e,newPassword:s};this.raiseAsync("Apply",n,function(e,s){if(i){i.setDisabled(false)}if(s.error){return this.notify(s.error)}else{u8.services.notification.info("TXT_changepw_text_7")}}.bind(this))},_onCommandCancel:function(){this.raise("Cancel",{cancel:true})}});$.extend(u8.Crm.Widgets.ChangePasswordBox,{showAsPopup:function(e,s){var t=new u8.Base.Widgets.Popup("<div class='u8-validator-no-error-indicator'></div>",{size:{width:700},sizing:"fit",title:"TXT_changepw_text_1",allowClose:!!e.showCancel,onCreate:function(t){e=$.extend(e,{parent:t});var i=t.getContent().widget("ChangePasswordBox",e)[0];i.bind("Apply",function(e,i){s(t,i)}).bind("Cancel",function(e,i){s(t,i)})}});t.open();return t}})})();