- Timestamp:
- 2013/09/04 14:34:12 (11 years ago)
- Location:
- branches/version-2_13_0
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13_0/data/Smarty/templates/default/shopping/confirm.tpl
r23168 r23187 182 182 <col width="70%" /> 183 183 <tbody> 184 <!--{include file="`$smarty.const.TEMPLATE_REALDIR`frontparts/form_personal_confirm.tpl" flgFields=2 emailMobile=false prefix="order_"}--> 184 <tr> 185 <th scope="row">お名前</th> 186 <td><!--{$arrForm.order_name01|h}--> <!--{$arrForm.order_name02|h}--></td> 187 </tr> 188 <tr> 189 <th scope="row">お名前(フリガナ)</th> 190 <td><!--{$arrForm.order_kana01|h}--> <!--{$arrForm.order_kana02|h}--></td> 191 </tr> 192 <tr> 193 <th scope="row">会社名</th> 194 <td><!--{$arrForm.order_company_name|h}--></td> 195 </tr> 196 <!--{if $smarty.const.FORM_COUNTRY_ENABLE}--> 197 <tr> 198 <th scope="row">国</th> 199 <td><!--{$arrCountry[$arrForm.order_country_id]|h}--></td> 200 </tr> 201 <tr> 202 <th scope="row">ZIPCODE</th> 203 <td><!--{$arrForm.order_zipcode|h}--></td> 204 </tr> 205 <!--{/if}--> 206 <tr> 207 <th scope="row">郵便番号</th> 208 <td>〒<!--{$arrForm.order_zip01|h}-->-<!--{$arrForm.order_zip02|h}--></td> 209 </tr> 210 <tr> 211 <th scope="row">住所</th> 212 <td><!--{$arrPref[$arrForm.order_pref]}--><!--{$arrForm.order_addr01|h}--><!--{$arrForm.order_addr02|h}--></td> 213 </tr> 214 <tr> 215 <th scope="row">電話番号</th> 216 <td><!--{$arrForm.order_tel01}-->-<!--{$arrForm.order_tel02}-->-<!--{$arrForm.order_tel03}--></td> 217 </tr> 218 <tr> 219 <th scope="row">FAX番号</th> 220 <td> 221 <!--{if $arrForm.order_fax01 > 0}--> 222 <!--{$arrForm.order_fax01}-->-<!--{$arrForm.order_fax02}-->-<!--{$arrForm.order_fax03}--> 223 <!--{/if}--> 224 </td> 225 </tr> 226 <tr> 227 <th scope="row">メールアドレス</th> 228 <td><!--{$arrForm.order_email|h}--></td> 229 </tr> 230 <tr> 231 <th scope="row">性別</th> 232 <td><!--{$arrSex[$arrForm.order_sex]|h}--></td> 233 </tr> 234 <tr> 235 <th scope="row">職業</th> 236 <td><!--{$arrJob[$arrForm.order_job]|default:'(未登録)'|h}--></td> 237 </tr> 238 <tr> 239 <th scope="row">生年月日</th> 240 <td> 241 <!--{$arrForm.order_birth|regex_replace:"/ .+/":""|regex_replace:"/-/":"/"|default:'(未登録)'|h}--> 242 </td> 243 </tr> 185 244 </tbody> 186 245 </table> -
branches/version-2_13_0/data/Smarty/templates/sphone/frontparts/form_personal_confirm.tpl
r23168 r23187 62 62 〒 <!--{$arrForm[$key1].value|h}--> - <!--{$arrForm[$key2].value|h}--><br /> 63 63 <!--{assign var=key1 value="`$prefix`pref"}--> 64 <!--{assign var=key_pref value="`$arrForm[$key1].value`"}--> 64 65 <!--{assign var=key2 value="`$prefix`addr01"}--> 65 66 <!--{assign var=key3 value="`$prefix`addr02"}--> 66 <!--{$arrPref[$ arrForm[$key1].value]|h}--><!--{$arrForm[$key2].value|h}--><!--{$arrForm[$key3].value|h}-->67 <!--{$arrPref[$key_pref]|h}--><!--{$arrForm[$key2].value|h}--><!--{$arrForm[$key3].value|h}--> 67 68 </dd> 68 69 <dt>電話番号</dt> -
branches/version-2_13_0/data/Smarty/templates/sphone/frontparts/form_personal_input.tpl
r23168 r23187 30 30 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--></div> 31 31 <!--{/if}--> 32 <input type="text" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" class="boxHarf text data-role-none" placeholder="姓" /> 33 <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" class="boxHarf text data-role-none" placeholder="名" />32 <input type="text" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxHarf text data-role-none" placeholder="姓" /> 33 <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxHarf text data-role-none" placeholder="名" /> 34 34 </dd> 35 35 … … 41 41 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--></div> 42 42 <!--{/if}--> 43 <input type="text" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" class="boxHarf text data-role-none" placeholder="セイ"/> <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" class="boxHarf text data-role-none" placeholder="メイ"/>43 <input type="text" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxHarf text data-role-none" placeholder="セイ"/> <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxHarf text data-role-none" placeholder="メイ"/> 44 44 </dd> 45 45 … … 54 54 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--></div> 55 55 <!--{/if}--> 56 <p><input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" class="boxShort text data-role-none" /> <a href="http://search.post.japanpost.jp/zipcode/" target="_blank" rel="external"><span class="fn">郵便番号検索</span></a></p>56 <p><input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> <a href="http://search.post.japanpost.jp/zipcode/" target="_blank" rel="external"><span class="fn">郵便番号検索</span></a></p> 57 57 58 58 <a href="javascript:eccube.getAddress('<!--{$smarty.const.INPUT_ZIP_URLPATH}-->', '<!--{$key1}-->', '<!--{$key2}-->', '<!--{$key3}-->', '<!--{$key4}-->');" class="btn_sub btn_inputzip">郵便番号から住所自動入力</a> … … 69 69 </select> 70 70 71 <input type="text" name="<!--{$key4}-->" value="<!--{$arrForm[$key4].value|h}-->" class="boxLong text top data-role-none" placeholder="市区町村名" />72 <input type="text" name="<!--{$key5}-->" value="<!--{$arrForm[$key5].value|h}-->" class="boxLong text data-role-none" placeholder="番地・ビル名" />71 <input type="text" name="<!--{$key4}-->" value="<!--{$arrForm[$key4].value|h}-->" style="<!--{$arrErr[$key4]|sfGetErrorColor}-->" class="boxLong text top data-role-none" placeholder="市区町村名" /> 72 <input type="text" name="<!--{$key5}-->" value="<!--{$arrForm[$key5].value|h}-->" style="<!--{$arrErr[$key5]|sfGetErrorColor}-->" class="boxLong text data-role-none" placeholder="番地・ビル名" /> 73 73 </dd> 74 74 … … 81 81 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--><!--{$arrErr[$key3]}--></div> 82 82 <!--{/if}--> 83 <input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key3}-->" value="<!--{$arrForm[$key3].value|h}-->" maxlength="<!--{$arrForm[$key3].length}-->" class="boxShort text data-role-none" />83 <input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key3}-->" value="<!--{$arrForm[$key3].value|h}-->" maxlength="<!--{$arrForm[$key3].length}-->" style="<!--{$arrErr[$key3]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> 84 84 </dd> 85 85 … … 92 92 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--><!--{$arrErr[$key3]}--></div> 93 93 <!--{/if}--> 94 <input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key3}-->" value="<!--{$arrForm[$key3].value|h}-->" maxlength="<!--{$arrForm[$key3].length}-->" class="boxShort text data-role-none" />94 <input type="tel" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" maxlength="<!--{$arrForm[$key1].length}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" maxlength="<!--{$arrForm[$key2].length}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> - <input type="tel" name="<!--{$key3}-->" value="<!--{$arrForm[$key3].value|h}-->" maxlength="<!--{$arrForm[$key3].length}-->" style="<!--{$arrErr[$key3]|sfGetErrorColor}-->" class="boxShort text data-role-none" /> 95 95 </dd> 96 96 … … 104 104 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--></div> 105 105 <!--{/if}--> 106 <input type="email" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" class="boxLong text top data-role-none" />107 <input type="email" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" class="boxLong text data-role-none" placeholder="確認のため2回入力してください" />106 <input type="email" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxLong text top data-role-none" /> 107 <input type="email" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxLong text data-role-none" placeholder="確認のため2回入力してください" /> 108 108 </dd> 109 109 … … 116 116 <div class="attention"><!--{$arrErr[$key1]}--><!--{$arrErr[$key2]}--></div> 117 117 <!--{/if}--> 118 <input type="email" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" class="boxLong text top data-role-none" />119 <input type="email" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" class="boxLong text data-role-none" placeholder="確認のため2回入力してください" />118 <input type="email" name="<!--{$key1}-->" value="<!--{$arrForm[$key1].value|h}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxLong text top data-role-none" /> 119 <input type="email" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxLong text data-role-none" placeholder="確認のため2回入力してください" /> 120 120 </dd> 121 121 <!--{/if}--> … … 127 127 <div class="attention"><!--{$arrErr[$key1]}--></div> 128 128 <!--{/if}--> 129 < spanstyle="<!--{$arrErr[$key1]|sfGetErrorColor}-->">129 <p style="<!--{$arrErr[$key1]|sfGetErrorColor}-->"> 130 130 <!--{html_radios name=$key1 options=$arrSex selected=$arrForm[$key1].value separator=' '}--> 131 </ span>131 </p> 132 132 </dd> 133 133 … … 138 138 <div class="attention"><!--{$arrErr[$key1]}--></div> 139 139 <!--{/if}--> 140 <select name="<!--{$key1}-->" class="boxLong data-role-none">140 <select name="<!--{$key1}-->" style="<!--{$arrErr[$key1]|sfGetErrorColor}-->" class="boxLong data-role-none"> 141 141 <option value="">選択してください</option> 142 142 <!--{html_options options=$arrJob selected=$arrForm[$key1].value}--> … … 189 189 </select> 190 190 191 <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" class="boxLong text data-role-none" placeholder="質問の答えを入力してください" />191 <input type="text" name="<!--{$key2}-->" value="<!--{$arrForm[$key2].value|h}-->" style="<!--{$arrErr[$key2]|sfGetErrorColor}-->" class="boxLong text data-role-none" placeholder="質問の答えを入力してください" /> 192 192 </dd> 193 193 -
branches/version-2_13_0/data/class/SC_Product.php
r23126 r23187 78 78 $table = 'dtb_products AS alldtl'; 79 79 80 $objQuery->setGroupBy('alldtl.product_id');81 80 if (is_array($this->arrOrderData) and $objQuery->order == '') { 82 81 $o_col = $this->arrOrderData['col']; -
branches/version-2_13_0/data/class/pages/shopping/LC_Page_Shopping.php
r23182 r23187 390 390 public function lfCheckError(&$objFormParam) 391 391 { 392 $arrParams = $objFormParam->getHashArray(); 393 392 394 $objErr = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam, 'order_'); 393 395 -
branches/version-2_13_0/html/js/eccube.js
r23167 r23187 194 194 } 195 195 if (ret) { 196 var formElement = $("form#" + form);197 formElement.find("*[name=" + key + "]").val(val);198 formElement.submit();196 var values = {}; 197 values[key] = val; 198 eccube.submitForm(values, form); 199 199 } 200 200 return false; … … 202 202 203 203 eccube.setValue = function(key, val, form) { 204 if (typeof form === 'undefined') { 205 form = eccube.defaults.formId; 206 } 207 var formElement = $("form#" + form); 204 var formElement = eccube.getFormElement(form); 208 205 formElement.find("*[name=" + key + "]").val(val); 209 206 }; 210 207 211 eccube.changeAction = function(url) { 212 document['form1'].action = url; 208 eccube.changeAction = function(url, form) { 209 var formElement = eccube.getFormElement(form); 210 formElement.attr("action", url); 213 211 }; 214 212 215 213 // ページナビで使用する。 216 214 eccube.movePage = function(pageno, mode, form) { 217 if (form === undefined) { 218 form = eccube.defaults.formId; 219 } 220 var formElement = $("form#" + form); 221 formElement.find("input[name=pageno]").val(pageno); 215 var values = {pageno: pageno}; 222 216 if (mode !== undefined) { 223 formElement.find("input[name='mode']").val(mode); 217 values.mode = mode; 218 } 219 eccube.submitForm(values, form); 220 }; 221 222 /** 223 * フォームを送信する. 224 * 225 * @param values 226 * @param form 227 */ 228 eccube.submitForm = function(values, form){ 229 var formElement = eccube.getFormElement(form); 230 if (values !== undefined && typeof values === "object") { 231 $.each(values, function(index, value) { 232 eccube.setValue(index, value, formElement); 233 }); 224 234 } 225 235 formElement.submit(); 226 236 }; 227 237 228 eccube.submitForm = function(values, form){ 238 /** 239 * フォームを特定してエレメントを返す. 240 * 241 * @param form 242 * @returns {*} 243 */ 244 eccube.getFormElement = function(form){ 229 245 var formElement; 230 246 if (form !== undefined && typeof form === "string" && form !== "") { … … 235 251 formElement = $("form#" + eccube.defaults.formId); 236 252 } 237 if (values !== undefined && typeof values === "object") { 238 $.each(values, function(index, value) { 239 formElement.find("input,select").filter("[name='" + index + "']").val(value); 240 }); 241 } 242 formElement.submit(); 253 return formElement; 243 254 }; 244 255 -
branches/version-2_13_0/html/user_data/packages/sphone/js/jquery.autoResizeTextAreaQ-0.1.js
r22564 r23187 1 /* * jQuery autoResizeTextAreaQ plugin * @requires jQuery v1.4.2 or later * * Copyright (c) 2010 M. Brown (mbrowniebytes A gmail.com) * Licensed under the Revised BSD license: * http://www.opensource.org/licenses/bsd-license.php * http://en.wikipedia.org/wiki/BSD_licenses * * Versions: * 0.1 - 2010-07-21 * initial * * usage: * $(document).ready( function() { * $('textarea').autoResizeTextAreaQ({"max_rows":8}); * }); * */(function($) { $.fn.autoResizeTextAreaQ = function(options) { var opts = $.extend({ // ya prob want to use max_rows: 10, // # - max rows to resize too // ya may want to use, but defaults should be ok extra_rows: 1, // # - nbr extra rows after last line ie padding; 0|1 optimal // ya should really specify in html rows: null, // null|# - null infer from html; # override html cols: null, // null|# - null infer from html; # override html debug: false // true|false - turn on|off console.log() }, options); // extra padding based on browser if ($.browser.msie) { opts.extra_rows += 1; } else if ($.browser.webkit) { opts.extra_rows += 1; } // else $.browser.mozilla // iterate over passed in selector, only process actual textareas return $(this).filter('textarea').each(function(index) { var ta = $(this); var orig = {}; // textarea rows cols current state if (opts.cols != null && opts.cols > 0) { ta.attr('cols', opts.cols); } orig.cols = ta.attr('cols'); if (opts.rows != null && opts.rows > 0) { ta.attr('rows', opts.rows); } orig.rows = ta.attr('rows'); // validate max extra_rows if (opts.max_rows == null || opts.max_rows < orig.rows) { opts.max_rows = orig.rows; } if (opts.extra_rows == null || opts.extra_rows < 0) { opts.extra_rows = 0; } if (opts.debug) { console.log('opts: ', opts, ' orig: ', orig); } // resize textares on load resize(ta, orig); // check resize on key input ta.bind('keyup', function(e) { resize(ta, orig); }); }); // end each() function resize(ta, orig) { // nbr explicit rows var nl_rows = ta.val().split('\n'); // nbr inferred rows var nbr_ta_rows = 0; for (index in nl_rows) { // overly simple check to account for text being auto wrapped and thus a new line nbr_ta_rows += Math.floor((nl_rows[index].length / orig.cols)) + 1; } // get final nbr ta rows var final_nbr_ta_rows = nbr_ta_rows - 1; // deduct for current line final_nbr_ta_rows += opts.extra_rows; // add on extra rows // resize textarea // note: $.animate() doesnt work well here since only inc/dec row by one if (final_nbr_ta_rows >= opts.max_rows) { ta.attr('rows', opts.max_rows); } else if (final_nbr_ta_rows >= orig.rows) { ta.attr('rows', final_nbr_ta_rows); } else { ta.attr('rows', orig.rows); } if (opts.debug) { console.log('rows: ', ta.attr('rows'), ' nbr nl_rows: ', nl_rows.length, ' nbr_ta_rows: ', nbr_ta_rows, ' final_nbr_ta_rows: ', final_nbr_ta_rows); } } // end resize()}; // end autoResizeTextAreaQ()})(jQuery); 1 /* 2 * jQuery autoResizeTextAreaQ plugin 3 * @requires jQuery v1.4.2 or later 4 * 5 * Copyright (c) 2010 M. Brown (mbrowniebytes A gmail.com) 6 * Licensed under the Revised BSD license: 7 * http://www.opensource.org/licenses/bsd-license.php 8 * http://en.wikipedia.org/wiki/BSD_licenses 9 * 10 * Versions: 11 * 0.1 - 2010-07-21 12 * initial 13 * 14 * usage: 15 * $(document).ready( function() { 16 * $('textarea').autoResizeTextAreaQ({"max_rows":8}); 17 * }); 18 * 19 */ 20 21 (function($) { 22 23 $.fn.autoResizeTextAreaQ = function(options) { 24 var opts = $.extend({ 25 // ya prob want to use 26 max_rows: 10, // # - max rows to resize too 27 28 // ya may want to use, but defaults should be ok 29 extra_rows: 1, // # - nbr extra rows after last line ie padding; 0|1 optimal 30 31 // ya should really specify in html 32 rows: null, // null|# - null infer from html; # override html 33 cols: null, // null|# - null infer from html; # override html 34 35 debug: false // true|false - turn on|off console.log() 36 }, options); 37 38 // extra padding based on browser 39 /* Removed jQuery 1.9.x 40 if ($.browser.msie) { 41 opts.extra_rows += 1; 42 } else if ($.browser.webkit) { 43 opts.extra_rows += 1; 44 } // else $.browser.mozilla 45 */ 46 opts.extra_rows += 1; // use webkit only. 47 48 // iterate over passed in selector, only process actual textareas 49 return $(this).filter('textarea').each(function(index) { 50 51 var ta = $(this); 52 var orig = {}; 53 54 // textarea rows cols current state 55 if (opts.cols != null && opts.cols > 0) { 56 ta.attr('cols', opts.cols); 57 } 58 orig.cols = ta.attr('cols'); 59 60 if (opts.rows != null && opts.rows > 0) { 61 ta.attr('rows', opts.rows); 62 } 63 orig.rows = ta.attr('rows'); 64 65 // validate max extra_rows 66 if (opts.max_rows == null || opts.max_rows < orig.rows) { 67 opts.max_rows = orig.rows; 68 } 69 if (opts.extra_rows == null || opts.extra_rows < 0) { 70 opts.extra_rows = 0; 71 } 72 73 if (opts.debug) { 74 console.log('opts: ', opts, ' orig: ', orig); 75 } 76 77 // resize textares on load 78 resize(ta, orig); 79 80 // check resize on key input 81 ta.bind('keyup', function(e) { 82 resize(ta, orig); 83 }); 84 }); // end each() 85 86 function resize(ta, orig) { 87 88 // nbr explicit rows 89 var nl_rows = ta.val().split('\n'); 90 91 // nbr inferred rows 92 var nbr_ta_rows = 0; 93 for (index in nl_rows) { 94 // overly simple check to account for text being auto wrapped and thus a new line 95 nbr_ta_rows += Math.floor((nl_rows[index].length / orig.cols)) + 1; 96 } 97 98 // get final nbr ta rows 99 var final_nbr_ta_rows = nbr_ta_rows - 1; // deduct for current line 100 final_nbr_ta_rows += opts.extra_rows; // add on extra rows 101 102 // resize textarea 103 // note: $.animate() doesnt work well here since only inc/dec row by one 104 if (final_nbr_ta_rows >= opts.max_rows) { 105 ta.attr('rows', opts.max_rows); 106 107 } else if (final_nbr_ta_rows >= orig.rows) { 108 ta.attr('rows', final_nbr_ta_rows); 109 110 } else { 111 ta.attr('rows', orig.rows); 112 } 113 114 if (opts.debug) { 115 console.log('rows: ', ta.attr('rows'), ' nbr nl_rows: ', nl_rows.length, ' nbr_ta_rows: ', nbr_ta_rows, ' final_nbr_ta_rows: ', final_nbr_ta_rows); 116 } 117 } // end resize() 118 119 }; // end autoResizeTextAreaQ() 120 121 })(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.