2008-10-16 15:03:45 +02:00
|
|
|
var LSformElement_password_field = new Class({
|
|
|
|
initialize: function(name,input){
|
|
|
|
this.name = name;
|
|
|
|
this.input = input;
|
|
|
|
this.params = varLSdefault.getParams(this.name);
|
|
|
|
this.initialiseLSformElement_password_field();
|
|
|
|
},
|
|
|
|
|
|
|
|
initialiseLSformElement_password_field: function() {
|
2010-04-27 15:52:45 +02:00
|
|
|
// ViewHashBtn
|
|
|
|
if (this.params['viewHash'] && varLSform.objectdn!= "") {
|
|
|
|
this.viewHashBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.viewHashBtn.src = varLSdefault.imagePath('view_hash');
|
2010-04-27 15:52:45 +02:00
|
|
|
this.viewHashBtn.addClass('btn');
|
|
|
|
this.viewHashBtn.addEvent('click',this.onViewHashBtnClick.bind(this));
|
|
|
|
this.viewHashBtn.injectAfter(this.input);
|
|
|
|
varLSdefault.addHelpInfo(this.viewHashBtn,'LSformElement_password','viewHash');
|
|
|
|
}
|
|
|
|
|
2008-10-31 13:12:31 +01:00
|
|
|
// Mail
|
|
|
|
if (this.params['mail']) {
|
|
|
|
if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) {
|
|
|
|
this.editMailBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.editMailBtn.src = varLSdefault.imagePath('mail-edit');
|
2008-10-31 13:12:31 +01:00
|
|
|
this.editMailBtn.addClass('btn');
|
|
|
|
this.editMailBtn.addEvent('click',this.onEditMailBtnClick.bind(this));
|
|
|
|
this.LSmail_open = 0;
|
|
|
|
this.editMailBtn.injectAfter(this.input);
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.addHelpInfo(this.editMailBtn,'LSformElement_password','editmail');
|
2008-10-31 13:12:31 +01:00
|
|
|
}
|
|
|
|
if (this.params.mail['ask']) {
|
|
|
|
this.mailBtn = new Element('img');
|
|
|
|
this.mailBtn.addClass('btn');
|
|
|
|
this.mailBtn.addEvent('click',this.onMailBtnClick.bind(this));
|
|
|
|
this.mailInput = new Element('input');
|
|
|
|
this.mailInput.setProperties({
|
|
|
|
name: 'LSformElement_password_' + this.name + '_send',
|
|
|
|
type: 'hidden'
|
|
|
|
});
|
|
|
|
if (this.params.mail['send']) {
|
|
|
|
this.mailInput.value = 1;
|
2013-06-19 02:17:39 +02:00
|
|
|
this.mailBtn.src = varLSdefault.imagePath('mail');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.addHelpInfo(this.mailBtn,'LSformElement_password','mail');
|
2008-10-31 13:12:31 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.mailInput.value = 0;
|
2013-06-19 02:17:39 +02:00
|
|
|
this.mailBtn.src = varLSdefault.imagePath('nomail');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.addHelpInfo(this.mailBtn,'LSformElement_password','nomail');
|
2008-10-31 13:12:31 +01:00
|
|
|
}
|
|
|
|
this.mailBtn.injectAfter(this.input);
|
|
|
|
this.mailInput.injectAfter(this.mailBtn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 15:03:45 +02:00
|
|
|
// ViewBtn
|
|
|
|
this.viewBtn = new Element('img');
|
2013-06-24 17:52:45 +02:00
|
|
|
if (this.params['clearEdit']) {
|
|
|
|
this.viewBtn.src = varLSdefault.imagePath('hide');
|
|
|
|
varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','hide');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.viewBtn.src = varLSdefault.imagePath('view');
|
|
|
|
varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','view');
|
|
|
|
}
|
2008-10-16 15:03:45 +02:00
|
|
|
this.viewBtn.addClass('btn');
|
|
|
|
this.viewBtn.addEvent('click',this.changeInputType.bind(this));
|
|
|
|
this.viewBtn.injectAfter(this.input);
|
|
|
|
|
|
|
|
// Verify
|
|
|
|
if (this.params['verify']) {
|
|
|
|
this.bgColor = this.input.getStyle('background-color');
|
|
|
|
this.verifyFx = new Fx.Tween(this.input,{property: 'background-color',duration:600});
|
|
|
|
this.verifyBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.verifyBtn.src = varLSdefault.imagePath('verify');
|
2008-10-16 15:03:45 +02:00
|
|
|
this.verifyBtn.addClass('btn');
|
|
|
|
this.verifyBtn.addEvent('click',this.onVerifyBtnClick.bind(this));
|
|
|
|
this.verifyBtn.injectAfter(this.input);
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.addHelpInfo(this.verifyBtn,'LSformElement_password','verify');
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.params['generate']) {
|
|
|
|
this.generateBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.generateBtn.src = varLSdefault.imagePath('generate');
|
2008-10-16 15:03:45 +02:00
|
|
|
this.generateBtn.addClass('btn');
|
|
|
|
this.generateBtn.addEvent('click',this.onGenerateBtnClick.bind(this));
|
|
|
|
this.generateBtn.injectAfter(this.input);
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.addHelpInfo(this.generateBtn,'LSformElement_password','generate');
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
2008-10-16 15:16:39 +02:00
|
|
|
|
|
|
|
this.initialize_input();
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize_input: function() {
|
|
|
|
// Verify
|
|
|
|
if (this.params['verify']) {
|
|
|
|
this.verifyFx = new Fx.Tween(this.input,{property: 'background-color',duration:600});
|
|
|
|
}
|
2008-10-16 15:03:45 +02:00
|
|
|
},
|
|
|
|
|
2008-10-31 13:12:31 +01:00
|
|
|
onMailBtnClick: function() {
|
2008-11-10 03:12:36 +01:00
|
|
|
if (this.mailInput.value==0) {
|
|
|
|
this.mailInput.value = 1;
|
2013-06-19 02:17:39 +02:00
|
|
|
this.mailBtn.src = varLSdefault.imagePath('mail');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.setHelpInfo(this.mailBtn,'LSformElement_password','mail');
|
2008-10-31 13:12:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-11-10 03:12:36 +01:00
|
|
|
this.mailInput.value = 0;
|
2013-06-19 02:17:39 +02:00
|
|
|
this.mailBtn.src = varLSdefault.imagePath('nomail');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.setHelpInfo(this.mailBtn,'LSformElement_password','nomail');
|
2008-10-31 13:12:31 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onEditMailBtnClick: function(btn) {
|
|
|
|
if(!$type(this.LSmail)) {
|
|
|
|
this.LSmail = new LSmail();
|
|
|
|
this.LSmail.addEvent('close',this.onLSmailClose.bind(this));
|
|
|
|
this.LSmail.addEvent('valid',this.onLSmailValid.bind(this));
|
|
|
|
}
|
|
|
|
|
2012-12-18 12:20:27 +01:00
|
|
|
var mails = []
|
|
|
|
if ($type(this.params.mail['mail_attr'])=='array') {
|
|
|
|
this.params.mail['mail_attr'].each(function(a) {
|
|
|
|
this.append(varLSform.getValue(a));
|
|
|
|
},mails);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mails.append(varLSform.getValue(this.params.mail['mail_attr']));
|
|
|
|
}
|
2008-10-31 13:12:31 +01:00
|
|
|
|
|
|
|
this.LSmail_open = 1;
|
2012-12-18 12:20:27 +01:00
|
|
|
this.LSmail.setMails(mails);
|
2008-10-31 13:12:31 +01:00
|
|
|
this.LSmail.setSubject(this.params.mail['subject']);
|
|
|
|
this.LSmail.setMsg(this.params.mail['msg']);
|
|
|
|
this.LSmail.open(this.editMailBtn);
|
|
|
|
},
|
|
|
|
|
|
|
|
onLSmailClose: function(LSmail) {
|
|
|
|
LSdebug('LSformElement_password : close LSmail');
|
|
|
|
this.LSmail_open = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
onLSmailValid: function(LSmail) {
|
|
|
|
LSdebug('LSformElement_password : valid LSmail');
|
|
|
|
this.setMail(LSmail.getMail());
|
|
|
|
},
|
|
|
|
|
|
|
|
setMail: function(mail) {
|
|
|
|
if ($type(mail)) {
|
|
|
|
if (!$type(this.msgInput)) {
|
|
|
|
this.msgInput = new Element('input');
|
|
|
|
this.msgInput.setProperties({
|
|
|
|
name: 'LSformElement_password_' + this.name + '_msg',
|
|
|
|
type: 'hidden'
|
|
|
|
});
|
|
|
|
this.msgInput.injectAfter(this.editMailBtn);
|
|
|
|
}
|
|
|
|
this.msgInput.value = JSON.encode(mail);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-10-16 15:03:45 +02:00
|
|
|
onGenerateBtnClick: function() {
|
|
|
|
var data = {
|
2009-02-20 15:05:22 +01:00
|
|
|
template: 'LSformElement_password',
|
2008-10-16 15:03:45 +02:00
|
|
|
action: 'generatePassword',
|
|
|
|
attribute: this.name,
|
|
|
|
objecttype: varLSform.objecttype,
|
2008-12-06 01:17:26 +01:00
|
|
|
objectdn: varLSform.objectdn,
|
2008-10-16 15:03:45 +02:00
|
|
|
idform: varLSform.idform
|
|
|
|
};
|
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.generateBtn);
|
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onGenerateBtnClickComplete.bind(this)}).send();
|
|
|
|
},
|
|
|
|
|
|
|
|
onGenerateBtnClickComplete: function(responseText, responseXML) {
|
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
|
|
this.input.value=data.generatePassword;
|
2008-10-16 15:16:39 +02:00
|
|
|
this.changeInputType('view');
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-10-16 15:16:39 +02:00
|
|
|
changeInputType: function(state) {
|
|
|
|
if (((this.input.type=='password')&&(state=='hide'))||((this.input.type=='text')&&(state=='view'))) {
|
|
|
|
return this.input;
|
|
|
|
}
|
2008-10-16 15:03:45 +02:00
|
|
|
if (this.input.type=='password') {
|
|
|
|
var newType = 'text';
|
2013-06-19 02:17:39 +02:00
|
|
|
this.viewBtn.src=varLSdefault.imagePath('hide');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.setHelpInfo(this.viewBtn,'LSformElement_password','hide');
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var newType = 'password';
|
2013-06-19 02:17:39 +02:00
|
|
|
this.viewBtn.src=varLSdefault.imagePath('view');
|
2008-11-10 03:12:36 +01:00
|
|
|
varLSdefault.setHelpInfo(this.viewBtn,'LSformElement_password','view');
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
|
|
|
var newInput = new Element('input');
|
|
|
|
newInput.setProperty('name',this.input.getProperty('name'));
|
|
|
|
newInput.setProperty('type',newType);
|
|
|
|
newInput.setProperty('class',this.input.getProperty('class'));
|
|
|
|
newInput.setProperty('value',this.input.getProperty('value'));
|
|
|
|
newInput.injectAfter(this.input);
|
|
|
|
this.input.destroy();
|
|
|
|
this.input = newInput;
|
2008-10-16 15:16:39 +02:00
|
|
|
this.initialize_input();
|
2008-10-16 15:03:45 +02:00
|
|
|
return newInput;
|
|
|
|
},
|
|
|
|
|
|
|
|
onVerifyBtnClick: function() {
|
|
|
|
var data = {
|
2009-02-20 15:05:22 +01:00
|
|
|
template: 'LSformElement_password',
|
2008-10-16 15:03:45 +02:00
|
|
|
action: 'verifyPassword',
|
|
|
|
attribute: this.name,
|
|
|
|
objecttype: varLSform.objecttype,
|
|
|
|
idform: varLSform.idform,
|
|
|
|
objectdn: varLSform.objectdn,
|
|
|
|
fieldValue: this.input.value
|
|
|
|
};
|
|
|
|
LSdebug(data);
|
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.verifyBtn);
|
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onVerifyBtnClickComplete.bind(this)}).send();
|
|
|
|
},
|
|
|
|
|
|
|
|
onVerifyBtnClickComplete: function(responseText, responseXML) {
|
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
|
|
if (data.verifyPassword) {
|
|
|
|
// ok
|
|
|
|
this.verifyFx.start('#73F386');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// nok
|
|
|
|
this.verifyFx.start('#f59a67');
|
|
|
|
}
|
|
|
|
(function(){this.verifyFx.start(this.bgColor);}).delay(1000, this);
|
|
|
|
}
|
2010-04-27 15:52:45 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onViewHashBtnClick: function() {
|
|
|
|
var data = {
|
|
|
|
template: 'LSformElement_password',
|
|
|
|
action: 'viewHash',
|
|
|
|
attribute: this.name,
|
|
|
|
objecttype: varLSform.objecttype,
|
|
|
|
objectdn: varLSform.objectdn
|
|
|
|
};
|
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.viewHashBtn);
|
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onViewHashBtnClickComplete.bind(this)}).send();
|
|
|
|
},
|
|
|
|
|
|
|
|
onViewHashBtnClickComplete: function(responseText, responseXML) {
|
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
|
|
if (data.hash) {
|
|
|
|
// ok
|
|
|
|
this.input.value=data.hash;
|
|
|
|
this.changeInputType('view');
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 15:03:45 +02:00
|
|
|
}
|
|
|
|
});
|