LSmail : add possibilty to set some display options from JS

This commit is contained in:
Benjamin Renard 2016-11-17 11:51:49 +01:00
parent 71480875d4
commit d6e1257ed8
3 changed files with 34 additions and 3 deletions

View file

@ -52,6 +52,8 @@ class LSmail {
LStemplate :: assign('LSmail_msg',$msg);
LStemplate :: assign('LSmail_subject',$subject);
LStemplate :: assign('LSmail_options',$_REQUEST['options']);
if (is_array($_REQUEST['mails'])) {
LStemplate :: assign('LSmail_mails',$_REQUEST['mails']);
}

View file

@ -6,6 +6,10 @@ var LSmail = new Class({
this.setSubject(subject);
this.object = {};
this.opened = 0;
this.options = {
display_mail_field: 1,
display_subject_field: 1
};
this.listeners = {
close: new Array(),
valid: new Array()
@ -45,7 +49,23 @@ var LSmail = new Class({
dn: dn
};
},
setOption: function(option,value) {
this.options[option]=value;
},
hideMailField: function() {
this.setOption('display_mail_field',0);
},
hideSubjectField: function() {
this.setOption('display_subject_field',0);
},
setClass: function(c) {
this.setOption('class',c);
},
open: function(startElement) {
if (this.opened==0) {
var data = {
@ -54,7 +74,8 @@ var LSmail = new Class({
object: this.object,
mails: this.mails,
msg: this.msg,
subject: this.subject
subject: this.subject,
options: this.options
};
if ($type(startElement)) {

View file

@ -1,4 +1,5 @@
<dl class='LSform LSmail'>
<dl class='LSform{if $LSmail_options.class} {$LSmail_options.class}{/if}'>
{if $LSmail_options.display_mail_field}
<dt class='LSform'>{$LSmail_mail_label}</dt>
<dd class='LSform'>
{if $LSmail_mails != ""}
@ -13,10 +14,17 @@
<input type='text' name='LSmail_mail' id='LSmail_mail'/>
{/if}
</dd>
{else}
<input type='hidden' name='LSmail_mail' id='LSmail_mail' value='{$LSmail_mails[0]}'/>
{/if}
{if $LSmail_options.display_subject_field}
<dt class='LSform'>{$LSmail_subject_label}</dt>
<dd class='LSform'>
<input type='text' name='LSmail_subject' id='LSmail_subject' value="{$LSmail_subject}"/>
</dd>
{else}
<input type='hidden' name='LSmail_subject' id='LSmail_subject' value="{$LSmail_subject}"/>
{/if}
<dt class='LSform'>{$LSmail_msg_label}</dt>
<dd class='LSform'>
<textarea name='LSmail_msg' id='LSmail_msg'>{$LSmail_msg}</textarea>