[19712] | 1 | /* |
---|
| 2 | * This file is part of EC-CUBE |
---|
| 3 | * |
---|
[21867] | 4 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
[19712] | 5 | * |
---|
| 6 | * http://www.lockon.co.jp/ |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 21 | */ |
---|
| 22 | // 親ウィンドウの存在確認. |
---|
| 23 | function fnIsopener() { |
---|
| 24 | var ua = navigator.userAgent; |
---|
| 25 | if( !!window.opener ) { |
---|
| 26 | if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) { |
---|
| 27 | return !window.opener.closed; |
---|
| 28 | } else { |
---|
| 29 | return typeof window.opener.document == 'object'; |
---|
| 30 | } |
---|
| 31 | } else { |
---|
| 32 | return false; |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | // 郵便番号入力呼び出し. |
---|
| 37 | function fnCallAddress(php_url, tagname1, tagname2, input1, input2) { |
---|
| 38 | zip1 = document.form1[tagname1].value; |
---|
| 39 | zip2 = document.form1[tagname2].value; |
---|
| 40 | |
---|
| 41 | if(zip1.length == 3 && zip2.length == 4) { |
---|
| 42 | $.get( |
---|
| 43 | php_url, |
---|
| 44 | {zip1: zip1, zip2: zip2, input1: input1, input2: input2}, |
---|
| 45 | function(data) { |
---|
| 46 | arrdata = data.split("|"); |
---|
| 47 | if (arrdata.length > 1) { |
---|
| 48 | fnPutAddress(input1, input2, arrdata[0], arrdata[1], arrdata[2]); |
---|
| 49 | } else { |
---|
| 50 | alert(data); |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | ); |
---|
| 54 | } else { |
---|
| 55 | alert("郵便番号を正しく入力して下さい。"); |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | // 郵便番号から検索した住所を渡す. |
---|
| 60 | function fnPutAddress(input1, input2, state, city, town) { |
---|
| 61 | if(state != "") { |
---|
| 62 | // 項目に値を入力する. |
---|
| 63 | document.form1[input1].selectedIndex = state; |
---|
| 64 | document.form1[input2].value = city + town; |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | function fnOpenNoMenu(URL) { |
---|
[20566] | 69 | window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no"); |
---|
[19712] | 70 | } |
---|
| 71 | |
---|
| 72 | function fnOpenWindow(URL,name,width,height) { |
---|
[20566] | 73 | window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no"); |
---|
[19712] | 74 | } |
---|
| 75 | |
---|
| 76 | function fnSetFocus(name) { |
---|
[20566] | 77 | if(document.form1[name]) { |
---|
| 78 | document.form1[name].focus(); |
---|
| 79 | } |
---|
[19712] | 80 | } |
---|
| 81 | |
---|
| 82 | // セレクトボックスに項目を割り当てる. |
---|
| 83 | function fnSetSelect(name1, name2, val) { |
---|
[20566] | 84 | sele1 = document.form1[name1]; |
---|
| 85 | sele2 = document.form1[name2]; |
---|
[19712] | 86 | |
---|
[20566] | 87 | if(sele1 && sele2) { |
---|
| 88 | index=sele1.selectedIndex; |
---|
[19712] | 89 | |
---|
[20566] | 90 | // セレクトボックスのクリア |
---|
| 91 | count=sele2.options.length |
---|
| 92 | for(i = count; i >= 0; i--) { |
---|
| 93 | sele2.options[i]=null; |
---|
| 94 | } |
---|
[19712] | 95 | |
---|
[20566] | 96 | // セレクトボックスに値を割り当てる。 |
---|
| 97 | len = lists[index].length |
---|
| 98 | for(i = 0; i < len; i++) { |
---|
| 99 | sele2.options[i]=new Option(lists[index][i], vals[index][i]); |
---|
| 100 | if(val != "" && vals[index][i] == val) { |
---|
| 101 | sele2.options[i].selected = true; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | } |
---|
[19712] | 105 | } |
---|
| 106 | |
---|
| 107 | // Enterキー入力をキャンセルする。(IEに対応) |
---|
| 108 | function fnCancelEnter() |
---|
| 109 | { |
---|
[20566] | 110 | if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) { |
---|
| 111 | if (window.event.keyCode == 13) |
---|
| 112 | { |
---|
| 113 | return false; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | return true; |
---|
[19712] | 117 | } |
---|
| 118 | |
---|
| 119 | // モードとキーを指定してSUBMITを行う。 |
---|
| 120 | function fnModeSubmit(mode, keyname, keyid) { |
---|
[20566] | 121 | switch(mode) { |
---|
| 122 | case 'delete_category': |
---|
| 123 | if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){ |
---|
| 124 | return; |
---|
| 125 | } |
---|
| 126 | break; |
---|
| 127 | case 'delete': |
---|
| 128 | if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){ |
---|
| 129 | return; |
---|
| 130 | } |
---|
| 131 | break; |
---|
| 132 | case 'delete_order': |
---|
| 133 | if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?\n\n※ 在庫数は手動で戻してください。')){ |
---|
| 134 | return; |
---|
| 135 | } |
---|
[19712] | 136 | mode = 'delete'; |
---|
[20566] | 137 | break; |
---|
| 138 | case 'confirm': |
---|
| 139 | if(!window.confirm('登録しても宜しいですか')){ |
---|
| 140 | return; |
---|
| 141 | } |
---|
| 142 | break; |
---|
| 143 | case 'delete_all': |
---|
| 144 | if(!window.confirm('検索結果をすべて削除しても宜しいですか')){ |
---|
| 145 | return; |
---|
| 146 | } |
---|
| 147 | break; |
---|
| 148 | default: |
---|
| 149 | break; |
---|
| 150 | } |
---|
| 151 | document.form1['mode'].value = mode; |
---|
| 152 | if(keyname != "" && keyid != "") { |
---|
| 153 | document.form1[keyname].value = keyid; |
---|
| 154 | } |
---|
| 155 | document.form1.submit(); |
---|
[19712] | 156 | } |
---|
| 157 | |
---|
| 158 | function fnFormModeSubmit(form, mode, keyname, keyid) { |
---|
[20566] | 159 | switch(mode) { |
---|
| 160 | case 'delete': |
---|
| 161 | if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){ |
---|
| 162 | return; |
---|
| 163 | } |
---|
| 164 | break; |
---|
| 165 | case 'confirm': |
---|
| 166 | if(!window.confirm('登録しても宜しいですか')){ |
---|
| 167 | return; |
---|
| 168 | } |
---|
| 169 | break; |
---|
| 170 | case 'regist': |
---|
| 171 | if(!window.confirm('登録しても宜しいですか')){ |
---|
| 172 | return; |
---|
| 173 | } |
---|
| 174 | break; |
---|
| 175 | default: |
---|
| 176 | break; |
---|
| 177 | } |
---|
| 178 | document.forms[form]['mode'].value = mode; |
---|
| 179 | if(keyname != "" && keyid != "") { |
---|
| 180 | document.forms[form][keyname].value = keyid; |
---|
| 181 | } |
---|
| 182 | document.forms[form].submit(); |
---|
[19712] | 183 | } |
---|
| 184 | |
---|
| 185 | function fnSetFormSubmit(form, key, val) { |
---|
[20566] | 186 | document.forms[form][key].value = val; |
---|
| 187 | document.forms[form].submit(); |
---|
| 188 | return false; |
---|
[19712] | 189 | } |
---|
| 190 | |
---|
| 191 | function fnSetVal(key, val) { |
---|
[20566] | 192 | fnSetFormVal('form1', key, val); |
---|
[19712] | 193 | } |
---|
| 194 | |
---|
| 195 | function fnSetFormVal(form, key, val) { |
---|
[20566] | 196 | document.forms[form][key].value = val; |
---|
[19712] | 197 | } |
---|
| 198 | |
---|
| 199 | function fnChangeAction(url) { |
---|
[20566] | 200 | document.form1.action = url; |
---|
[19712] | 201 | } |
---|
| 202 | |
---|
| 203 | // ページナビで使用する。 |
---|
| 204 | function fnNaviPage(pageno) { |
---|
[20566] | 205 | document.form1['pageno'].value = pageno; |
---|
| 206 | document.form1.submit(); |
---|
[19712] | 207 | } |
---|
| 208 | |
---|
| 209 | function fnSearchPageNavi(pageno) { |
---|
[20566] | 210 | document.form1['pageno'].value = pageno; |
---|
| 211 | document.form1['mode'].value = 'search'; |
---|
| 212 | document.form1.submit(); |
---|
| 213 | } |
---|
[19712] | 214 | |
---|
| 215 | function fnSubmit(){ |
---|
[20566] | 216 | document.form1.submit(); |
---|
[19712] | 217 | } |
---|
| 218 | |
---|
| 219 | // ポイント入力制限。 |
---|
| 220 | function fnCheckInputPoint() { |
---|
[20566] | 221 | if(document.form1['point_check']) { |
---|
| 222 | list = new Array( |
---|
| 223 | 'use_point' |
---|
| 224 | ); |
---|
[19712] | 225 | |
---|
[20566] | 226 | if(!document.form1['point_check'][0].checked) { |
---|
| 227 | color = "#dddddd"; |
---|
| 228 | flag = true; |
---|
| 229 | } else { |
---|
| 230 | color = ""; |
---|
| 231 | flag = false; |
---|
| 232 | } |
---|
[19712] | 233 | |
---|
[20566] | 234 | len = list.length |
---|
| 235 | for(i = 0; i < len; i++) { |
---|
| 236 | if(document.form1[list[i]]) { |
---|
[20702] | 237 | var current_color = document.form1[list[i]].style.backgroundColor; |
---|
| 238 | if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)")) |
---|
| 239 | { |
---|
| 240 | continue; |
---|
| 241 | } |
---|
[20566] | 242 | document.form1[list[i]].disabled = flag; |
---|
| 243 | document.form1[list[i]].style.backgroundColor = color; |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | } |
---|
[19712] | 247 | } |
---|
| 248 | |
---|
| 249 | // 別のお届け先入力制限。 |
---|
| 250 | function fnCheckInputDeliv() { |
---|
[20566] | 251 | if(!document.form1) { |
---|
| 252 | return; |
---|
| 253 | } |
---|
| 254 | if(document.form1['deliv_check']) { |
---|
| 255 | list = new Array( |
---|
| 256 | 'shipping_name01', |
---|
| 257 | 'shipping_name02', |
---|
| 258 | 'shipping_kana01', |
---|
| 259 | 'shipping_kana02', |
---|
| 260 | 'shipping_pref', |
---|
| 261 | 'shipping_zip01', |
---|
| 262 | 'shipping_zip02', |
---|
| 263 | 'shipping_addr01', |
---|
| 264 | 'shipping_addr02', |
---|
| 265 | 'shipping_tel01', |
---|
| 266 | 'shipping_tel02', |
---|
| 267 | 'shipping_tel03' |
---|
| 268 | ); |
---|
[19712] | 269 | |
---|
[20566] | 270 | if(!document.form1['deliv_check'].checked) { |
---|
| 271 | fnChangeDisabled(list, '#dddddd'); |
---|
| 272 | } else { |
---|
| 273 | fnChangeDisabled(list, ''); |
---|
| 274 | } |
---|
| 275 | } |
---|
[19712] | 276 | } |
---|
| 277 | |
---|
| 278 | // 最初に設定されていた色を保存しておく。 |
---|
| 279 | var g_savecolor = new Array(); |
---|
| 280 | |
---|
| 281 | function fnChangeDisabled(list, color) { |
---|
[20566] | 282 | len = list.length; |
---|
[19712] | 283 | |
---|
[20566] | 284 | for(i = 0; i < len; i++) { |
---|
| 285 | if(document.form1[list[i]]) { |
---|
| 286 | if(color == "") { |
---|
| 287 | // 有効にする。 |
---|
| 288 | document.form1[list[i]].disabled = false; |
---|
| 289 | document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]]; |
---|
| 290 | } else { |
---|
| 291 | // 無効にする。 |
---|
| 292 | document.form1[list[i]].disabled = true; |
---|
| 293 | g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor; |
---|
| 294 | document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | } |
---|
[19712] | 298 | } |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | // ログイン時の入力チェック |
---|
| 302 | function fnCheckLogin(formname) { |
---|
[20566] | 303 | var lstitem = new Array(); |
---|
[19712] | 304 | |
---|
[20566] | 305 | lstitem[0] = 'login_email'; |
---|
| 306 | lstitem[1] = 'login_pass'; |
---|
[21929] | 307 | |
---|
[20566] | 308 | var max = lstitem.length; |
---|
| 309 | var errflg = false; |
---|
| 310 | var cnt = 0; |
---|
[19712] | 311 | |
---|
[20566] | 312 | // 必須項目のチェック |
---|
| 313 | for(cnt = 0; cnt < max; cnt++) { |
---|
| 314 | if(document.forms[formname][lstitem[cnt]].value == "") { |
---|
| 315 | errflg = true; |
---|
| 316 | break; |
---|
| 317 | } |
---|
| 318 | } |
---|
[19712] | 319 | |
---|
[20566] | 320 | // 必須項目が入力されていない場合 |
---|
| 321 | if(errflg == true) { |
---|
| 322 | alert('メールアドレス/パスワードを入力して下さい。'); |
---|
| 323 | return false; |
---|
[21929] | 324 | } else { |
---|
| 325 | return true; |
---|
[20566] | 326 | } |
---|
[19712] | 327 | } |
---|
| 328 | |
---|
| 329 | // 時間の計測. |
---|
| 330 | function fnPassTime(){ |
---|
[20566] | 331 | end_time = new Date(); |
---|
| 332 | time = end_time.getTime() - start_time.getTime(); |
---|
| 333 | alert((time/1000)); |
---|
[19712] | 334 | } |
---|
| 335 | start_time = new Date(); |
---|
| 336 | |
---|
| 337 | //親ウィンドウのページを変更する. |
---|
| 338 | function fnUpdateParent(url) { |
---|
[20566] | 339 | // 親ウィンドウの存在確認 |
---|
| 340 | if(fnIsopener()) { |
---|
| 341 | window.opener.location.href = url; |
---|
| 342 | } else { |
---|
| 343 | window.close(); |
---|
| 344 | } |
---|
[19712] | 345 | } |
---|
| 346 | |
---|
| 347 | //特定のキーをSUBMITする. |
---|
| 348 | function fnKeySubmit(keyname, keyid) { |
---|
[20566] | 349 | if(keyname != "" && keyid != "") { |
---|
| 350 | document.form1[keyname].value = keyid; |
---|
| 351 | } |
---|
| 352 | document.form1.submit(); |
---|
[19712] | 353 | } |
---|
| 354 | |
---|
| 355 | //文字数をカウントする。 |
---|
| 356 | //引数1:フォーム名称 |
---|
| 357 | //引数2:文字数カウント対象 |
---|
| 358 | //引数3:カウント結果格納対象 |
---|
| 359 | function fnCharCount(form,sch,cnt) { |
---|
[20566] | 360 | document.forms[form][cnt].value= document.forms[form][sch].value.length; |
---|
[19712] | 361 | } |
---|
| 362 | |
---|
| 363 | |
---|
| 364 | // テキストエリアのサイズを変更する. |
---|
[19914] | 365 | function ChangeSize(buttonSelector, textAreaSelector, max, min) { |
---|
[19712] | 366 | |
---|
[19914] | 367 | if ($(textAreaSelector).attr('rows') <= min) { |
---|
| 368 | $(textAreaSelector).attr('rows', max); |
---|
| 369 | $(buttonSelector).text('縮小'); |
---|
| 370 | } else { |
---|
| 371 | $(textAreaSelector).attr('rows', min); |
---|
| 372 | $(buttonSelector).text('拡大'); |
---|
| 373 | } |
---|
[19712] | 374 | } |
---|