LSmail : add possibilty to set some display options from JS
authorBenjamin Renard <brenard@easter-eggs.com>
Thu, 17 Nov 2016 10:51:49 +0000 (11:51 +0100)
committerBenjamin Renard <brenard@easter-eggs.com>
Thu, 17 Nov 2016 10:51:49 +0000 (11:51 +0100)
public_html/includes/class/class.LSmail.php
public_html/includes/js/LSmail.js
public_html/templates/default/LSmail.tpl

index 636e00b..4f0fe9d 100644 (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']);
     }
index f32da87..c17eaa8 100644 (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)) {
index 8f550cc..66bb002 100644 (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 != ""}
       <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>