Ignore:
Timestamp:
Jan 16, 2013, 2:15:29 AM (11 years ago)
Author:
mistic100
Message:

impove display, add LiveValidation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GuestBook/template/guestbook.tpl

    r17732 r20181  
    11{combine_css path=$GUESTBOOK_PATH|@cat:"template/style.css"}
    2 {if $themeconf.name|in_array:$clear_themes}
    3   {combine_css path=$GUESTBOOK_PATH|@cat:"template/style-clear.css"}
     2{combine_script id="livevalidation" load="footer" path=$GUESTBOOK_PATH|@cat:"template/livevalidation.min.js"}
     3
     4{footer_script require='livevalidation'}
     5{if !$comment_add.IS_LOGGED}
     6var author = new LiveValidation('author', {ldelim} onlyOnSubmit: true });
     7author.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your username'|@translate}" });
    48{/if}
     9
     10{if $add_comment.EMAIL_MANDATORY and (!$add_comment.IS_LOGGED or empty($add_comment.EMAIL))}
     11var email = new LiveValidation('email', {ldelim} onlyOnSubmit: true });
     12email.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your e-mail'|@translate}" });
     13email.add(Validate.Email, {ldelim} failureMessage: "{'mail address must be like xxx@yyy.eee (example : jack@altern.org)'|@translate}" });
     14{/if}
     15
     16var website = new LiveValidation('website', {ldelim} onlyOnSubmit: true });
     17website.add(Validate.Format, {ldelim} pattern: /^https?:\/\/(-\.)?([^\s\/?\.#-]+\.?)+(\/[^\s]*)?$/i,
     18  failureMessage: "{'invalid website address'|@translate}"});
     19
     20var content = new LiveValidation('contentid', {ldelim} onlyOnSubmit: true });
     21content.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a message'|@translate}" });
     22 
     23jQuery("#addComment").hide();
     24jQuery("#guestbookAdd").css('width','180px');
     25jQuery("#expandForm").click(function() {ldelim}
     26  jQuery("#guestbookAdd").animate({ldelim}"width": "550px"}, function() {ldelim}
     27    jQuery("#expandForm").slideUp();
     28    jQuery("#addComment").slideDown("slow");
     29  });
     30});
     31{/footer_script}
    532
    633{if $comment_add.ACTIVATE_RATING}
     
    1340  {/footer_script}
    1441{/if}
    15 
    16 {footer_script}
    17 jQuery("#expandForm").click(function() {ldelim}
    18   jQuery("#guestbookAdd").animate({ldelim}"width": "500px"}, function() {ldelim}
    19     jQuery("#addComment").slideDown("slow");
    20   });
    21 });
    22 {/footer_script}
    2342
    2443
     
    4160{if isset($comment_add)}
    4261<div id="guestbookAdd">
    43 <h4 id="expandForm">{'Sign the guestbook'|@translate}</h4>
    44 <form method="post" action="{$comment_add.F_ACTION}" id="addComment" style="display:none;">
    45   <table>
    46   {if $comment_add.SHOW_AUTHOR}
    47     <tr>
    48     <td>
    49       <p><label for="author">{'Author'|@translate}* :</label></p>
    50       <p><input type="text" name="author" id="author" value="{$comment_add.AUTHOR}"></p>
    51     </td>
    52     <td>
    53       <p><label for="email">{'Email address'|@translate} ({'not publicly visible'|@translate}) :</label></p>
    54       <p><input type="text" name="email" id="email" size="30" value="{$comment_add.EMAIL}"></p>
    55     </td>
    56     </tr>
    57   {/if}
    58     <tr>
    59   {if $comment_add.ACTIVATE_RATING}
    60     <td>
    61       <p>{'Rate'|@translate} :</p>
    62       <p><span id="comment_rate"></span></p>
    63     </td>
    64   {/if}
    65     <td>
    66       <p><label for="website">{'Website'|@translate} :</label></p>
    67       <p><input type="text" name="website" id="website" size="30" value="{$comment_add.WEBSITE}"></p>
    68     </td>
    69     </tr>
    70   </table>
    71  
    72   <p><label for="contentid">{'Comment'|@translate}* :</label></p>
    73   <p><textarea name="content" id="contentid" rows="10" style="width:100%;">{$comment_add.CONTENT}</textarea></p>
    74   <p><input type="hidden" name="key" value="{$comment_add.KEY}">
    75     <input type="submit" value="{'Submit'|@translate}"> {'* : mandatory fields'|@translate}</p>
    76 </form>
     62  <h4 id="expandForm">{'Sign the guestbook'|@translate}</h4>
     63  <form method="post" action="{$comment_add.F_ACTION}" id="addComment" class="contact">
     64    <table>
     65    {if not $comment_add.IS_LOGGED or empty($comment_add.EMAIL)}
     66      <tr>
     67        <td>
     68          <label for="author">{'Author'|@translate}* :</label>
     69        {if $comment_add.IS_LOGGED}
     70          {$comment_add.AUTHOR}
     71          <input type="hidden" name="author" value="{$comment_add.AUTHOR}">
     72        {else}
     73          <input type="text" name="author" id="author" value="{$comment_add.AUTHOR}">
     74        {/if}
     75        </td>
     76        <td>
     77          <label for="email">{'Email address'|@translate}{if $comment_add.EMAIL_MANDATORY}*{/if} ({'not publicly visible'|@translate}) :</label>
     78          <input type="text" name="email" id="email" value="{$comment_add.EMAIL}">
     79        </td>
     80      </tr>
     81    {/if}
     82      <tr>
     83      {if $comment_add.ACTIVATE_RATING}
     84        <td>
     85          <label>{'Rate'|@translate} :</label>
     86          <span id="comment_rate"></span>
     87        </td>
     88      {/if}
     89        <td>
     90          <label for="website">{'Website'|@translate} :</label>
     91          <input type="text" name="website" id="website" value="{$comment_add.WEBSITE}">
     92        </td>
     93      </tr>
     94      <tr>
     95        <td colspan="2">
     96          <label for="contentid">{'Comment'|@translate}* :</label>
     97          <textarea name="content" id="contentid" rows="7">{$comment_add.CONTENT}</textarea>
     98        </td>
     99      </tr>
     100      <tr>
     101        <td colspan="2">
     102          <input type="submit" value="{'Send'|@translate}">
     103          {'* : mandatory fields'|@translate}
     104        </td>
     105      </tr>
     106    </table>
     107   
     108    <input type="hidden" name="key" value="{$comment_add.KEY}">
     109  </form>
    77110</div>
    78111{/if}
Note: See TracChangeset for help on using the changeset viewer.