ldapsaisie/src/includes/js/LSformElement_mail.js
Benjamin Renard 7098b3ee79 Massive change of files organisation to move all files outside web-root
The web-root directory now contains URL rewrite stuff. All PHP & static files are
in root src directory and are served via LSurl routes.
2020-05-06 12:17:35 +02:00

85 lines
2.6 KiB
JavaScript

var LSformElement_mail = new Class({
initialize: function(){
this.fields = [];
this.initialiseLSformElement_mail();
if (typeof(varLSform) != "undefined") {
varLSform.addModule("LSformElement_mail",this);
}
this.LSmail_open = 0;
},
initialiseLSformElement_mail: function(el) {
if (typeof(el) == 'undefined') {
el = document;
}
el.getElements('input.LSformElement_mail').each(function(input) {
if (!input.hasClass('LSformElement_mail_disableMailSending')) {
this.addBtnAfter.bind(this)(input);
}
}, this);
el.getElements('a.LSformElement_mail').each(function(a) {
if (!a.hasClass('LSformElement_mail_disableMailSending')) {
this.addBtnAfter.bind(this)(a);
}
}, this);
var getName = /^(.*)\[\]$/;
el.getElements('input.LSformElement_mail_autocomplete').each(function(input) {
this.fields.push(
new LSformElement_mail_field(
getName.exec(input.name)[1],
input
)
);
}, this);
},
addBtnAfter: function(el) {
var btn = new Element('img');
btn.setProperties({
src: varLSdefault.imagePath('mail')
});
btn.addClass('btn');
btn.injectAfter(el);
btn.addEvent('click',this.onBtnClick.bind(this,btn));
varLSdefault.addHelpInfo(btn,'LSformElement_mail','mail');
},
reinitialize: function(el) {
varLSform.initializeModule('LSformElement_text',el);
this.initialiseLSformElement_mail(el);
},
onBtnClick: function(btn) {
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]);
this.LSmail.setObject(varLSform.objecttype,varLSform.objectdn);
this.LSmail.open(btn);
}
}
},
onLSmailClose: function(LSmail) {
LSdebug('LSformElement_mail : close LSmail');
this.LSmail_open = 0;
},
onLSmailValid: function(LSmail) {
LSdebug('LSformElement_mail : valid LSmail');
LSmail.send();
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSformElement_mail = new LSformElement_mail();
});