- Modification de LSformElement_password_generate :

Modification du bouton view en hide (et vise versa)
This commit is contained in:
Benjamin Renard 2008-05-15 13:27:47 +00:00
parent a1b75aab6b
commit ab87eded0e
3 changed files with 12 additions and 2 deletions

View file

@ -219,6 +219,7 @@ var LSform = new Class({
var getAttrNameAndIdValues = getAttrNameAndId.exec(img.id); var getAttrNameAndIdValues = getAttrNameAndId.exec(img.id);
var attrName = getAttrNameAndIdValues[1]; var attrName = getAttrNameAndIdValues[1];
var fieldId = 'LSformElement_password_' + attrName + '_' + getAttrNameAndIdValues[2]; var fieldId = 'LSformElement_password_' + attrName + '_' + getAttrNameAndIdValues[2];
var viewBtnId = 'LSformElement_password_view_btn_userPassword_' + getAttrNameAndIdValues[2];
var data = { var data = {
template: 'LSform', template: 'LSform',
@ -226,6 +227,7 @@ var LSform = new Class({
attribute: attrName, attribute: attrName,
objecttype: $('LSform_objecttype').value, objecttype: $('LSform_objecttype').value,
idform: $('LSform_idform').value, idform: $('LSform_idform').value,
viewBtnId: viewBtnId,
fieldId: fieldId fieldId: fieldId
}; };
data.imgload=varLSdefault.loadingImgDisplay(img); data.imgload=varLSdefault.loadingImgDisplay(img);
@ -244,6 +246,7 @@ var LSform = new Class({
varLSdefault.loadingImgHide(data.imgload); varLSdefault.loadingImgHide(data.imgload);
this.changeInputType($(data.fieldId),'text'); this.changeInputType($(data.fieldId),'text');
$(data.fieldId).value=data.generatePassword; $(data.fieldId).value=data.generatePassword;
$(data.viewBtnId).setProperty('src','templates/images/hide.png');
this.LSformElement_password_generate_inputHistory[data.fieldId]=data.generatePassword; this.LSformElement_password_generate_inputHistory[data.fieldId]=data.generatePassword;
} }
} }
@ -260,6 +263,10 @@ var LSform = new Class({
onLSformElement_password_generate_inputModify: function(input) { onLSformElement_password_generate_inputModify: function(input) {
input.value=''; input.value='';
input = this.changeInputType(input,'password'); input = this.changeInputType(input,'password');
var getAttrNameAndId = /LSformElement_password_(.*)_([0-9]*)/
var attrNameAndId = getAttrNameAndId.exec(input.id);
var viewBtnId = 'LSformElement_password_view_btn_' + attrNameAndId[1] + '_' + attrNameAndId[2];
$(viewBtnId).setProperty('src','templates/images/view.png');
this.LSformElement_password_generate_inputHistory[input.id]=''; this.LSformElement_password_generate_inputHistory[input.id]='';
input.focus(); input.focus();
}, },
@ -274,9 +281,11 @@ var LSform = new Class({
if (input.type=='password') { if (input.type=='password') {
input = this.changeInputType(input,'text'); input = this.changeInputType(input,'text');
img.setProperty('src','templates/images/hide.png');
} }
else { else {
input = this.changeInputType(input,'password'); input = this.changeInputType(input,'password');
img.setProperty('src','templates/images/view.png');
} }
input.focus(); input.focus();
}, },

View file

@ -79,7 +79,7 @@ if (!isset($_ERRORS)) {
} }
break; break;
case 'generatePassword': case 'generatePassword':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) {
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
$field=$form -> getElement($_REQUEST['attribute']); $field=$form -> getElement($_REQUEST['attribute']);
@ -87,7 +87,8 @@ if (!isset($_ERRORS)) {
if ( $val ) { if ( $val ) {
$data = array( $data = array(
'generatePassword' => $val, 'generatePassword' => $val,
'fieldId' => $_REQUEST['fieldId'] 'fieldId' => $_REQUEST['fieldId'],
'viewBtnId' => $_REQUEST['viewBtnId']
); );
} }
else { else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B