2008-07-31 11:16:25 +02:00
|
|
|
var LSformElement_mail = new Class({
|
|
|
|
initialize: function(){
|
|
|
|
this.initialiseLSformElement_mail();
|
|
|
|
if (typeof(varLSform) != "undefined") {
|
|
|
|
varLSform.addModule("LSformElement_mail",this);
|
|
|
|
}
|
2008-09-25 17:15:33 +02:00
|
|
|
this.LSmail_open = 0;
|
2008-07-31 11:16:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
initialiseLSformElement_mail: function(el) {
|
|
|
|
if (typeof(el) == 'undefined') {
|
|
|
|
el = document;
|
|
|
|
}
|
2008-09-27 02:55:58 +02:00
|
|
|
el.getElements('input.LSformElement_mail').each(function(input) {
|
|
|
|
this.addBtnAfter.bind(this)(input);
|
2008-07-31 11:16:25 +02:00
|
|
|
}, this);
|
2008-09-27 02:55:58 +02:00
|
|
|
el.getElements('a.LSformElement_mail').each(function(a) {
|
|
|
|
this.addBtnAfter.bind(this)(a);
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
addBtnAfter: function(el) {
|
|
|
|
var btn = new Element('img');
|
|
|
|
btn.setProperties({
|
2008-10-09 03:31:33 +02:00
|
|
|
src: varLSdefault.imagePath('mail.png'),
|
2008-09-27 02:55:58 +02:00
|
|
|
alt: 'Envoyer un mail',
|
|
|
|
title: 'Envoyer un mail'
|
|
|
|
});
|
|
|
|
btn.addClass('btn');
|
|
|
|
btn.injectAfter(el);
|
|
|
|
btn.addEvent('click',this.onBtnClick.bind(this,btn));
|
2008-07-31 11:16:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
reinitialize: function(el) {
|
2008-10-15 19:40:04 +02:00
|
|
|
varLSform.initializeModule('LSformElement_text',el);
|
2008-07-31 11:16:25 +02:00
|
|
|
this.initialiseLSformElement_mail(el);
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnClick: function(btn) {
|
2008-09-25 17:15:33 +02:00
|
|
|
if (this.LSmail_open==0) {
|
|
|
|
var mail = btn.getParent().getFirst().innerHTML;
|
|
|
|
if ((typeof(mail)!='string')||(mail=='')) {
|
|
|
|
mail = btn.getParent().getFirst().value;
|
|
|
|
}
|
|
|
|
if(!$type(this.LSmail)) {
|
|
|
|
this.LSmail = new LSmail();
|
|
|
|
this.LSmail.addEvent('close',this.onLSmailClose.bind(this));
|
|
|
|
this.LSmail.addEvent('valid',this.onLSmailValid.bind(this));
|
|
|
|
}
|
|
|
|
if ((mail!="")) {
|
|
|
|
this.LSmail_open = 1;
|
|
|
|
this.LSmail.setMails([mail]);
|
2008-11-03 20:25:22 +01:00
|
|
|
this.LSmail.setObject(varLSform.objecttype,varLSform.objectdn);
|
2008-09-25 17:15:33 +02:00
|
|
|
this.LSmail.open(btn);
|
|
|
|
}
|
2008-07-31 11:16:25 +02:00
|
|
|
}
|
2008-09-25 17:15:33 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onLSmailClose: function(LSmail) {
|
|
|
|
LSdebug('LSformElement_mail : close LSmail');
|
|
|
|
this.LSmail_open = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
onLSmailValid: function(LSmail) {
|
|
|
|
LSdebug('LSformElement_mail : valid LSmail');
|
|
|
|
LSmail.send();
|
2008-07-31 11:16:25 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
|
|
|
varLSformElement_mail = new LSformElement_mail();
|
|
|
|
});
|