1/* 2 * Copyright (c) 2012 takashi shinohara 3 * this Library is licensed. http://aulta.jp/library/ 4 * http://aulta.jp/library/wordpress/contactForm7Confirm.html 5 * last update: 2012-02-15, 0.0.1. 6 */ 7jQuery(document).ready(function(){ 8 9 var option = { 10 pages : [ 11 { 12 'path' : ['/contactus/','/requestform/','/about/recruit/career/recruitform/','/career/recruitform/'], 13 'button' : { 14 'areaClassName' : 'submit-button', // <p class="submit-button">[submit "éä¿¡"]</p> 15 'confirm' : '<div class="formtbl"><input class="button-confirm formbtn" type="button" value="確èªç»é¢ã¸" /></div>', // html 16 'rewrite' : '<div class="formtbl"><input class="button-rewrite formbtn" type="button" value="åã®ç»é¢ã«æ»ã" /></div>' // html 17 } 18 } 19 ], 20 validates : { 21 required : { 22 before : '', 23 after : 'ã¯å¿ é ã§ãã' 24 }, 25 email : { 26// match : /^[A-Za-z0-9]+[\w-]+@[\w\.-]+\.\w{2,}$/, 27 match : /^[A-Za-z0-9]+[\w\.-]+@[\w\.-]+\.\w{2,}$/, 28 before : '', 29 after : 'ã確èªãã¦ãã ããã' 30 } 31 } 32 }; 33 34 var flg = false; 35 for(var i in option.pages){ 36 var page = option.pages[i]; 37 for(var j in page.path){ 38 var path = page.path[j]; 39 if (path == document.location.pathname){ 40 flg = true; 41 option.page = page; 42 break; 43 } 44 } 45 } 46 if ( ! flg) return; 47 48 jQuery('form.wpcf7-form') 49 .each(function(){ 50 51 jQuery(this).find('.wpcf7-form-control-wrap') 52 .each(function(){ 53 54 var child = jQuery(this).children(0); 55 56 if (child.hasClass('wpcf7-text')){ 57 jQuery(this) 58 .after( 59 jQuery('<span>').addClass('wpcf7-form-control-wrap-confirm') 60 ); 61 child 62 .change(function(){ 63 jQuery(this).parent().next().text( 64 jQuery(this).val() 65 ); 66 }) 67 .change() 68 ; 69 } else if (child.get(0).tagName.toLowerCase() == 'textarea'){ 70 jQuery(this) 71 .after( 72 jQuery('<span>').addClass('wpcf7-form-control-wrap-confirm') 73 ); 74 child 75 .change(function(){ 76 jQuery(this).parent().next().html( 77 jQuery('<span>').text(jQuery(this).val()).html().replace(/\n/g, '<br />') 78 ); 79 }) 80 .change() 81 ; 82 } else if (child.hasClass('wpcf7-select')){ 83 jQuery(this) 84 .after( 85 jQuery('<span>').addClass('wpcf7-form-control-wrap-confirm') 86 ); 87 child 88 .change(function(){ 89 jQuery(this).parent().next().text( 90 jQuery(this).find('option[value="' + jQuery(this).val() + '"]').text() 91 ); 92 }) 93 .change() 94 ; 95 } if (child.hasClass('wpcf7-radio')){ 96 jQuery(this) 97 .after( 98 jQuery('<span>').addClass('wpcf7-form-control-wrap-confirm') 99 ); 100 child.find('input[type="radio"]') 101 .change(function(){ 102 jQuery(this).parents('.wpcf7-form-control-wrap').find('input[type="radio"]') 103 .each(function(){ 104 if (this.checked){ 105 jQuery(this).parents('.wpcf7-form-control-wrap').next().text( 106 jQuery(this).parent().text() 107 ); 108 } 109 }); 110 }) 111 .change() 112 ; 113 } if (child.hasClass('wpcf7-checkbox')){ 114 jQuery(this) 115 .after( 116 jQuery('<span>').addClass('wpcf7-form-control-wrap-confirm') 117 ); 118 child.find('input[type="checkbox"]') 119 .change(function(){ 120 var a = []; 121 jQuery(this).parents('.wpcf7-form-control-wrap').find('input[type="checkbox"]') 122 .each(function(){ 123 if (this.checked){ 124 a.push(jQuery('<span>').text(jQuery(this).parent().text()).html()); 125 } 126 }); 127 jQuery(this).parents('.wpcf7-form-control-wrap').next().html( 128 a.join('<br />') 129 ); 130 }) 131 .change() 132 ; 133 } 134 135 }); 136 137 jQuery(this) 138 .prepend( 139 jQuery('<ul>').addClass('error-messages').hide() 140 ); 141 142 jQuery(this).find('.' + option.page.button.areaClassName) 143 .addClass('buttons-area'); 144 145 jQuery(this).find('.buttons-area') 146 .prepend( 147 option.page.button.rewrite 148 ) 149 .after( 150 jQuery('<p>') 151 .addClass('buttons-area-confirm') 152 .html(option.page.button.confirm) 153 ); 154 155 jQuery(this).addClass('wpcf7-form-mode-edit'); 156 jQuery(this).find('.wpcf7-form-control-wrap-confirm').hide(); 157 jQuery(this).find('.wpcf7-form-control-wrap').show(); 158 jQuery(this).find('.buttons-area').hide(); 159 jQuery(this).find('.buttons-area-confirm').show(); 160 161 jQuery(this).submit(function(){ 162 jQuery(this).find('.buttons-area input[type="submit"]').hide(); 163 }); 164 165 jQuery(this).find('.buttons-area .button-rewrite') 166 .click(function(){ 167 var form = jQuery(this).parents('form.wpcf7-form'); 168 form.addClass('wpcf7-form-mode-edit').removeClass('wpcf7-form-mode-confirm'); 169 form.find('.buttons-area input[type="submit"]').show(); 170 form.find('.wpcf7-response-output').empty().removeClass('wpcf7-mail-sent-ok'); 171 form.find('.wpcf7-form-control-wrap-confirm').hide(); 172 form.find('.wpcf7-form-control-wrap').show(); 173 form.find('.buttons-area').hide(); 174 form.find('.buttons-area-confirm').show(); 175 jQuery('html,body').animate({ scrollTop: form.offset().top - 30}, 'slow', null); 176 return false;
177 }) 178 ; 179 180 jQuery(this).find('.buttons-area-confirm .button-confirm') 181 .click(function(){ 182 var form = jQuery(this).parents('form.wpcf7-form') 183 , error = form.find('ul.error-messages'); 184 error.empty(); 185 form.find('table tr').removeClass('error'); 186 form.find('.wpcf7-form-control-wrap') 187 .each(function(){ 188 var child = jQuery(this).children(0) 189 , title = child.parents('tr').find('th').text(); 190 if (title.length == 0){ 191 title = child.parents('dt').find('.title').text(); 192 } 193 if (child.hasClass('wpcf7-text')){ 194 if (child.hasClass('wpcf7-validates-as-required') && child.val().length == 0){ 195 error.append(jQuery('<li>').text(option.validates.required.before + title.replace('å¿ é ', '') + option.validates.required.after)); 196 jQuery(this).parents('tr').addClass('error'); 197 } else if (child.hasClass('wpcf7-validates-as-email') && ( ! child.val().match(option.validates.email.match))){ 198 error.append(jQuery('<li>').text(option.validates.email.before + title.replace('å¿ é ', '') + option.validates.email.after)); 199 jQuery(this).parents('tr').addClass('error'); 200 } 201 } else if (child.get(0).tagName.toLowerCase() == 'textarea'){ 202 if (child.hasClass('wpcf7-validates-as-required') && child.val().length == 0){ 203 error.append(jQuery('<li>').text(option.validates.required.before + title.replace('å¿ é ', '') + option.validates.required.after)); 204 jQuery(this).parents('tr').addClass('error'); 205 } 206 } else if (child.hasClass('wpcf7-select')){ 207 if (child.hasClass('wpcf7-validates-as-required') && (( ! child.val()) || child.val().length == 0 || child.val() == '---')){ 208 error.append(jQuery('<li>').text(option.validates.required.before + title.replace('å¿ é ', '') + option.validates.required.after)); 209 jQuery(this).parents('tr').addClass('error'); 210 } 211 } if (child.hasClass('wpcf7-radio')){ 212 if (child.hasClass('wpcf7-validates-as-required')){ 213 var flg = false; 214 jQuery(this).find('input[type="radio"]') 215 .each(function(){ 216 if (this.checked){ 217 flg = true; 218 return; 219 } 220 }); 221 if ( ! flg){ 222 error.append(jQuery('<li>').text(option.validates.required.before + title.replace('å¿ é ', '') + option.validates.required.after)); 223 jQuery(this).parents('tr').addClass('error'); 224 } 225 } 226 } if (child.hasClass('wpcf7-checkbox')){ 227 if (child.hasClass('wpcf7-validates-as-required')){ 228 var flg = false; 229 jQuery(this).find('input[type="checkbox"]') 230 .each(function(){ 231 if (this.checked){ 232 flg = true; 233 return; 234 } 235 }); 236 if ( ! flg){ 237 error.append(jQuery('<li>').text(option.validates.required.before + title.replace('å¿ é ', '') + option.validates.required.after)); 238 jQuery(this).parents('tr').addClass('error'); 239 } 240 } 241 } 242 }); 243 if (error.children().length > 0){ 244 error.show(); 245 } else { 246 form.addClass('wpcf7-form-mode-confirm').removeClass('wpcf7-form-mode-edit'); 247 form.find('.wpcf7-form-control-wrap').hide(); 248 form.find('.wpcf7-form-control-wrap-confirm').show(); 249 form.find('.buttons-area-confirm').hide(); 250 form.find('.buttons-area').show(); 251 } 252 jQuery('html,body').animate({ scrollTop: form.offset().top - 30}, 'slow', null); 253 return false; 254 }); 255 256 }); 257 258}); 259
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.