Changeset 20180 for extensions/Piwecard/template
- Timestamp:
- Jan 16, 2013, 12:38:26 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Piwecard/template/ecard.tpl
r20162 r20180 11 11 height:"90%", 12 12 onComplete:function(){ 13 13 $(".ecard_defaultText").blur(); 14 14 } 15 15 }); 16 17 jQuery("#addECardForm form").submit(function(){ 18 //jQuery(".createECardOpen").colorbox.close(); 16 17 jQuery(document).on("focusin", ".ecard_defaultText", function() { 18 defaultTextFocusIn($(this)); 19 }); 20 21 jQuery(document).on("focusout", ".ecard_defaultText", function() { 22 defaultTextFocusOut($(this)); 23 }); 24 25 function defaultTextFocusIn(element) { 26 if (element.val() == element[0].title) { 27 element.removeClass("ecard_defaultTextActive"); 28 element.val(""); 29 } 30 } 31 32 function defaultTextFocusOut(element) { 33 if (element.val() == "") { 34 element.addClass("ecard_defaultTextActive"); 35 element.val(element[0].title); 36 } 37 } 38 39 $('#ecard_add_recipient').click(function() { 40 var num = $('.ecard_name_recipient').length-1; 41 var newNum = new Number(num + 1); 42 43 if (newNum < 5) { 44 var newRecipient = $('#ecard_field_recipient_' + num).clone().attr('id', 'ecard_field_recipient_' + newNum); 45 46 newRecipient.find('.ecard_mandatory_fields').remove(); 47 newRecipient.find('.ecard_error').css("display", "none"); 48 newRecipient.find('#ecard_recipient_name_' + num + '_error').attr('id', 'ecard_recipient_name_' + newNum + '_error'); 49 newRecipient.find('#ecard_recipient_email_' + num + '_error').attr('id', 'ecard_recipient_email_' + newNum + '_error'); 50 newRecipient.find('#ecard_recipient_name_' + num).attr({ 51 id: 'ecard_recipient_name_' + newNum, 52 name: 'ecard_recipient_name[' + newNum+']', 53 value: '' 54 }); 55 newRecipient.find('#ecard_recipient_email_' + num).attr({ 56 id: 'ecard_recipient_email_' + newNum, 57 name: 'ecard_recipient_email[' + newNum+']', 58 value: '' 59 }); 60 newRecipient.find('#ecard_recipient_name_' + newNum).removeClass("ecard_error_input"); 61 newRecipient.find('#ecard_recipient_email_' + newNum).removeClass("ecard_error_input"); 62 defaultTextFocusOut(newRecipient.find('#ecard_recipient_name_' + newNum)); 63 defaultTextFocusOut(newRecipient.find('#ecard_recipient_email_' + newNum)); 64 65 $('#ecard_field_recipient_' + num).after(newRecipient); 66 } 19 67 }); 20 68 }); … … 25 73 var senderNameOK = piwecard_checkField(form.ecard_sender_name, 0); 26 74 var senderEMailOK = piwecard_checkField(form.ecard_sender_email, 1); 27 var recipientNameOK = piwecard_checkField(form.ecard_recipient_name, 0); 28 var recipientEMailOK = piwecard_checkField(form.ecard_recipient_email, 1); 75 var recipientNameOK = new Array(); 76 var recipientEMailOK = new Array(); 77 var nbAdditionalRecipients = 0; 78 var allRecipientNamesOK = false; 79 var allRecipientEmailsOK = false; 29 80 30 if(titleOK && messageOK && senderNameOK && senderEMailOK && recipientNameOK && recipientEMailOK) 81 recipientNameOK[0] = piwecard_checkField(form.ecard_recipient_name_0, 0); 82 recipientEMailOK[0] = piwecard_checkField(form.ecard_recipient_email_0, 1); 83 84 while(document.getElementById("ecard_recipient_email_" + (nbAdditionalRecipients++))) { 85 var id_name = "ecard_recipient_name_"+nbAdditionalRecipients; 86 var id_email = "ecard_recipient_email_"+nbAdditionalRecipients; 87 recipientEMailOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_email), 1, true); 88 if (recipientEMailOK[nbAdditionalRecipients] && document.getElementById(id_email).value != '') 89 recipientNameOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_name), 0, true); 90 } 91 92 for (var i=0; i<=nbAdditionalRecipients; i++) { 93 if (recipientNameOK[i] && recipientEMailOK[i]) { 94 allRecipientNamesOK = true; 95 allRecipientEmailsOK = true; 96 } else { 97 allRecipientNamesOK = false; 98 allRecipientEmailsOK = false; 99 break; 100 } 101 } 102 103 if (titleOK && messageOK && senderNameOK && senderEMailOK && allRecipientNamesOK && allRecipientEmailsOK) 31 104 return true; 32 105 else … … 44 117 <div class="ecard_error" id="ecard_title_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 45 118 <span class="ecard_label">{'Title'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 46 <span class="ecard_input_right"><input name="ecard_title" type="text" id="ecard_title" value="{$ecard.title}" title="{$ecard.title}"></span>119 <span class="ecard_input_right"><input name="ecard_title" type="text" id="ecard_title" class="ecard_defaultText" title="{$ecard.title}"></span> 47 120 </div> 48 121 <div class="ecard_field"> 49 122 <div class="ecard_error" id="ecard_message_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 50 123 <span class="ecard_label">{'piwecard_message'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 51 <span class="ecard_input_right"><textarea name="ecard_message" id="ecard_message" value="{$ecard.message}" title="{$ecard.message}">{$ecard.message}</textarea></span>124 <span class="ecard_input_right"><textarea name="ecard_message" id="ecard_message" class="ecard_defaultText" title="{$ecard.message}"></textarea></span> 52 125 </div> 53 126 </fieldset> … … 59 132 <span class="ecard_label">{'piwecard_sender'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 60 133 <span class="ecard_name"><input name="ecard_sender_name" type="text" id="ecard_sender_name" maxlength="100" value="{$ecard.sender_name}"></span> 61 <span class="ecard_email"><input name="ecard_sender_email" type="text" id="ecard_sender_email" maxlength="100" {$ecard.changemail} value="{$ecard.sender_email}" onblur="piwecard_checkField(this, 1);"></span>134 <span class="ecard_email"><input name="ecard_sender_email" type="text" id="ecard_sender_email" maxlength="100" {$ecard.changemail} value="{$ecard.sender_email}"></span> 62 135 </div> 63 <div class="ecard_field" >64 <div class="ecard_error" id="ecard_recipient_name_ error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div>65 <div class="ecard_error" id="ecard_recipient_email_ error">{'piwecard_error'|@translate} {'piwecard_error_email'|@translate}</div>136 <div class="ecard_field" id="ecard_field_recipient_0"> 137 <div class="ecard_error" id="ecard_recipient_name_0_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 138 <div class="ecard_error" id="ecard_recipient_email_0_error">{'piwecard_error'|@translate} {'piwecard_error_email'|@translate}</div> 66 139 <span class="ecard_label">{'piwecard_recipient'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 67 <span class="ecard_name "><input name="ecard_recipient_name" type="text" id="ecard_recipient_name" maxlength="100" value="{$ecard.recipient_name}"></span>68 <span class="ecard_email"><input name="ecard_recipient_email " type="text" id="ecard_recipient_email" maxlength="100" value="{$ecard.recipient_email}" onblur="piwecard_checkField(this, 1);"></span>140 <span class="ecard_name ecard_name_recipient"><input name="ecard_recipient_name[0]" type="text" id="ecard_recipient_name_0" class="ecard_defaultText" maxlength="100" title="{$ecard.recipient_name}"></span> 141 <span class="ecard_email"><input name="ecard_recipient_email[0]" type="text" id="ecard_recipient_email_0" class="ecard_defaultText" maxlength="100" title="{$ecard.recipient_email}"></span> 69 142 </div> 143 <a href="javascript:void(0)" id="ecard_add_recipient">{'piwecard_add_recipient'|@translate}</a> 70 144 </fieldset> 71 145 <fieldset>
Note: See TracChangeset
for help on using the changeset viewer.