[16708] | 1 | /* |
---|
| 2 | * This file is part of EC-CUBE |
---|
| 3 | * |
---|
[22206] | 4 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[16708] | 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 | */ |
---|
[16757] | 22 | |
---|
[23129] | 23 | (function( window, undefined ){ |
---|
[16708] | 24 | |
---|
[23129] | 25 | // 名前空間の重複を防ぐ |
---|
| 26 | if (window.eccube === undefined) { |
---|
| 27 | window.eccube = {}; |
---|
[20566] | 28 | } |
---|
[16708] | 29 | |
---|
[23129] | 30 | var eccube = window.eccube; |
---|
[16708] | 31 | |
---|
[23129] | 32 | //指定されたidの削除を行うページを実行する。 |
---|
| 33 | eccube.deleteMember = function(id, pageno) { |
---|
| 34 | var url = "./delete.php?id=" + id + "&pageno=" + pageno; |
---|
| 35 | if(window.confirm('登録内容を削除しても宜しいでしょうか')){ |
---|
| 36 | location.href = url; |
---|
| 37 | } |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | // ラジオボタンチェック状態を保存 |
---|
| 41 | eccube.checkedRadios = ""; |
---|
| 42 | |
---|
| 43 | // ラジオボタンのチェック状態を取得する。 |
---|
| 44 | eccube.getRadioChecked = function() { |
---|
| 45 | var max; |
---|
| 46 | var cnt; |
---|
| 47 | var startname = ""; |
---|
| 48 | var ret; |
---|
| 49 | var name; |
---|
[23381] | 50 | max = document.form1.elements.length; |
---|
[23129] | 51 | eccube.checkedRadios = [max]; |
---|
| 52 | for(cnt = 0; cnt < max; cnt++) { |
---|
[23381] | 53 | if(document.form1.elements[cnt].type === 'radio') { |
---|
| 54 | name = document.form1.elements[cnt].name; |
---|
[23129] | 55 | /* radioボタンは同じ名前が2回続けて検出されるので、 |
---|
| 56 | 最初の名前の検出であるかどうかの判定 */ |
---|
| 57 | // 1回目の検出 |
---|
| 58 | if(startname !== name) { |
---|
| 59 | startname = name; |
---|
[23381] | 60 | ret = document.form1.elements[cnt].checked; |
---|
[23129] | 61 | if(ret === true){ |
---|
| 62 | // 稼働がチェックされている。 |
---|
| 63 | eccube.checkedRadios[name] = 1; |
---|
| 64 | } |
---|
| 65 | // 2回目の検出 |
---|
| 66 | } else { |
---|
[23381] | 67 | ret = document.form1.elements[cnt].checked; |
---|
[23129] | 68 | if(ret === true){ |
---|
| 69 | // 非稼働がチェックされている。 |
---|
| 70 | eccube.checkedRadios[name] = 0; |
---|
| 71 | } |
---|
[20566] | 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
[23129] | 75 | }; |
---|
[16708] | 76 | |
---|
[23129] | 77 | // 管理者メンバーページの切替 |
---|
| 78 | eccube.moveMemberPage = function(pageno) { |
---|
| 79 | location.href = "?pageno=" + pageno; |
---|
| 80 | }; |
---|
[16708] | 81 | |
---|
[23129] | 82 | // ページナビで使用する |
---|
| 83 | eccube.moveNaviPage = function(pageno, mode, form) { |
---|
| 84 | if (form === undefined) { |
---|
| 85 | form = eccube.defaults.formId; |
---|
| 86 | } |
---|
[23241] | 87 | var formElement = eccube.getFormElement(form); |
---|
[23129] | 88 | formElement.find("input[name='search_pageno']").val(pageno); |
---|
| 89 | if (mode !== undefined) { |
---|
| 90 | formElement.find("input[name='mode']").val(mode); |
---|
| 91 | } |
---|
| 92 | formElement.submit(); |
---|
| 93 | }; |
---|
[16708] | 94 | |
---|
[23129] | 95 | // ページナビで使用する(mode = search専用) |
---|
| 96 | eccube.moveSearchPage = function(pageno) { |
---|
| 97 | eccube.moveNaviPage(pageno, "search"); |
---|
| 98 | }; |
---|
[16708] | 99 | |
---|
[23129] | 100 | // ページナビで使用する(form2) |
---|
| 101 | eccube.moveSecondSearchPage = function(pageno) { |
---|
| 102 | eccube.moveNaviPage(pageno, "search", "form2"); |
---|
| 103 | }; |
---|
[16708] | 104 | |
---|
[23129] | 105 | // 項目に入った値をクリアする。 |
---|
| 106 | eccube.clearValue = function(name) { |
---|
[23381] | 107 | document.form1[name].value = ""; |
---|
[23129] | 108 | }; |
---|
[16708] | 109 | |
---|
[23129] | 110 | // 規格分類登録へ移動 |
---|
| 111 | eccube.moveClassCatPage = function(class_id) { |
---|
| 112 | location.href = "./classcategory.php?class_id=" + class_id; |
---|
| 113 | }; |
---|
[16708] | 114 | |
---|
[23129] | 115 | eccube.checkAllBox = function(input, selector) { |
---|
| 116 | if ($(input).attr('checked')) { |
---|
| 117 | $(selector).attr('checked', true); |
---|
| 118 | } else { |
---|
| 119 | $(selector).attr('checked', false); |
---|
| 120 | } |
---|
| 121 | }; |
---|
[16708] | 122 | |
---|
[23129] | 123 | //指定されたidの削除を行うページを実行する。 |
---|
| 124 | eccube.moveDeleteUrl = function(url) { |
---|
| 125 | if(window.confirm('登録内容を削除しても宜しいでしょうか')){ |
---|
| 126 | location.href = url; |
---|
| 127 | } |
---|
| 128 | return false; |
---|
| 129 | }; |
---|
[16708] | 130 | |
---|
[23129] | 131 | //配送料金を自動入力 |
---|
| 132 | eccube.setDelivFee = function(max) { |
---|
| 133 | var name; |
---|
| 134 | for(var cnt = 1; cnt <= max; cnt++) { |
---|
| 135 | name = "fee" + cnt; |
---|
[23381] | 136 | document.form1[name].value = document.form1.fee_all.value; |
---|
[23129] | 137 | } |
---|
| 138 | }; |
---|
[16708] | 139 | |
---|
[23129] | 140 | // 在庫数制限判定 |
---|
| 141 | eccube.checkStockLimit = function(icolor) { |
---|
[23381] | 142 | if(document.form1.stock_unlimited) { |
---|
[23129] | 143 | var list = ['stock']; |
---|
[23381] | 144 | if(document.form1.stock_unlimited.checked) { |
---|
[23129] | 145 | eccube.changeDisabled(list, icolor); |
---|
[23381] | 146 | document.form1.stock.value = ""; |
---|
[23129] | 147 | } else { |
---|
| 148 | eccube.changeDisabled(list, ''); |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | }; |
---|
[16708] | 152 | |
---|
[23129] | 153 | // 確認メッセージ |
---|
| 154 | eccube.doConfirm = function() { |
---|
| 155 | return window.confirm('この内容で登録しても宜しいでしょうか'); |
---|
| 156 | }; |
---|
[16708] | 157 | |
---|
[23129] | 158 | // フォームに代入してからサブミットする。 |
---|
| 159 | eccube.insertValueAndSubmit = function(fm, ele, val, msg){ |
---|
| 160 | var ret; |
---|
[23230] | 161 | if (msg){ |
---|
[23129] | 162 | ret = window.confirm(msg); |
---|
| 163 | } else { |
---|
| 164 | ret = true; |
---|
| 165 | } |
---|
| 166 | if(ret){ |
---|
| 167 | fm[ele].value = val; |
---|
| 168 | fm.submit(); |
---|
| 169 | return false; |
---|
| 170 | } |
---|
| 171 | return false; |
---|
| 172 | }; |
---|
[16708] | 173 | |
---|
[23129] | 174 | //制限数判定 |
---|
| 175 | eccube.checkLimit = function(elem1, elem2, icolor) { |
---|
[23381] | 176 | if(document.form1[elem2]) { |
---|
[23129] | 177 | var list = [elem1]; |
---|
[23381] | 178 | if(document.form1[elem2].checked) { |
---|
[23129] | 179 | eccube.changeDisabled(list, icolor); |
---|
[23381] | 180 | document.form1[elem1].value = ""; |
---|
[23129] | 181 | } else { |
---|
| 182 | eccube.changeDisabled(list, ''); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | }; |
---|
[16708] | 186 | |
---|
[23129] | 187 | /** |
---|
| 188 | * ファイル管理 |
---|
| 189 | */ |
---|
| 190 | eccube.fileManager = { |
---|
| 191 | tree:"", // 生成HTML格納 |
---|
| 192 | arrTreeStatus:[], // ツリー状態保持 |
---|
| 193 | old_select_id:'', // 前回選択していたファイル |
---|
| 194 | selectFileHidden:"", // 選択したファイルのhidden名 |
---|
| 195 | treeStatusHidden:"", // ツリー状態保存用のhidden名 |
---|
| 196 | modeHidden:"" // modeセットhidden名 |
---|
| 197 | }; |
---|
[16708] | 198 | |
---|
[23129] | 199 | // ツリー表示 |
---|
| 200 | eccube.fileManager.viewFileTree = function(view_id, arrTree, openFolder, selectHidden, treeHidden, mode) { |
---|
| 201 | eccube.fileManager.selectFileHidden = selectHidden; |
---|
| 202 | eccube.fileManager.treeStatusHidden = treeHidden; |
---|
| 203 | eccube.fileManager.modeHidden = mode; |
---|
[16708] | 204 | |
---|
[23129] | 205 | var id, level, old_id, old_level, tmp_level, rank_img, display, arrFileSplit, file_name, folder_img; |
---|
[16708] | 206 | |
---|
[23129] | 207 | for(var i = 0; i < arrTree.length; i++) { |
---|
| 208 | id = arrTree[i][0]; |
---|
| 209 | level = arrTree[i][3]; |
---|
[16708] | 210 | |
---|
[23129] | 211 | if(i === 0) { |
---|
| 212 | old_id = "0"; |
---|
| 213 | old_level = 0; |
---|
| 214 | } else { |
---|
| 215 | old_id = arrTree[i-1][0]; |
---|
| 216 | old_level = arrTree[i-1][3]; |
---|
| 217 | } |
---|
[16708] | 218 | |
---|
[23129] | 219 | // 階層上へ戻る |
---|
| 220 | if(level <= (old_level - 1)) { |
---|
| 221 | tmp_level = old_level - level; |
---|
| 222 | for(var up_roop = 0; up_roop <= tmp_level; up_roop++) { |
---|
| 223 | eccube.fileManager.tree += '</div>'; |
---|
| 224 | } |
---|
| 225 | } |
---|
[16708] | 226 | |
---|
[23129] | 227 | // 同一階層で次のフォルダへ |
---|
| 228 | if(id !== old_id && level === old_level) { |
---|
| 229 | eccube.fileManager.tree += '</div>'; |
---|
| 230 | } |
---|
[16708] | 231 | |
---|
[23129] | 232 | // 階層の分だけスペースを入れる |
---|
| 233 | for(var space_cnt = 0; space_cnt < arrTree[i][3]; space_cnt++) { |
---|
| 234 | eccube.fileManager.tree += " "; |
---|
| 235 | } |
---|
[16708] | 236 | |
---|
[23129] | 237 | // 階層画像の表示・非表示処理 |
---|
| 238 | if(arrTree[i][4]) { |
---|
| 239 | if(arrTree[i][1] === '_parent') { |
---|
[23381] | 240 | rank_img = eccube.fileManager.IMG_MINUS; |
---|
[23129] | 241 | } else { |
---|
[23381] | 242 | rank_img = eccube.fileManager.IMG_NORMAL; |
---|
[23129] | 243 | } |
---|
| 244 | // 開き状態を保持 |
---|
| 245 | eccube.fileManager.arrTreeStatus.push(arrTree[i][2]); |
---|
| 246 | display = 'block'; |
---|
| 247 | } else { |
---|
| 248 | if(arrTree[i][1] === '_parent') { |
---|
[23381] | 249 | rank_img = eccube.fileManager.IMG_PLUS; |
---|
[23129] | 250 | } else { |
---|
[23381] | 251 | rank_img = eccube.fileManager.IMG_NORMAL; |
---|
[23129] | 252 | } |
---|
| 253 | display = 'none'; |
---|
| 254 | } |
---|
[16757] | 255 | |
---|
[23129] | 256 | arrFileSplit = arrTree[i][2].split("/"); |
---|
| 257 | file_name = arrFileSplit[arrFileSplit.length-1]; |
---|
| 258 | |
---|
| 259 | // フォルダの画像を選択 |
---|
| 260 | if(arrTree[i][2] === openFolder) { |
---|
[23381] | 261 | folder_img = eccube.fileManager.IMG_FOLDER_OPEN; |
---|
[23129] | 262 | file_name = "<b>" + file_name + "</b>"; |
---|
[20566] | 263 | } else { |
---|
[23381] | 264 | folder_img = eccube.fileManager.IMG_FOLDER_CLOSE; |
---|
[20566] | 265 | } |
---|
[16708] | 266 | |
---|
[23129] | 267 | // 階層画像に子供がいたらオンクリック処理をつける |
---|
[23381] | 268 | if(rank_img !== eccube.fileManager.IMG_NORMAL) { |
---|
[23129] | 269 | eccube.fileManager.tree += '<a href="javascript:eccube.fileManager.toggleTreeMenu(\'tree'+ i +'\',\'rank_img'+ i +'\',\''+ arrTree[i][2] +'\')"><img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">'; |
---|
[20566] | 270 | } else { |
---|
[23129] | 271 | eccube.fileManager.tree += '<img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">'; |
---|
[20566] | 272 | } |
---|
[23130] | 273 | eccube.fileManager.tree += '<a href="javascript:eccube.fileManager.openFolder(\''+ arrTree[i][2] +'\')"><img src="'+ folder_img +'" border="0" name="tree_img'+ i +'" id="tree_img'+ i +'"> '+ file_name +'</a><br/>'; |
---|
[23129] | 274 | eccube.fileManager.tree += '<div id="tree'+ i +'" style="display:'+ display +'">'; |
---|
[20566] | 275 | } |
---|
[23129] | 276 | document.getElementById(view_id).innerHTML = eccube.fileManager.tree; |
---|
| 277 | //document.tree_form.tree_test2.focus(); |
---|
| 278 | }; |
---|
[16708] | 279 | |
---|
[23129] | 280 | // Tree状態をhiddenにセット |
---|
| 281 | eccube.fileManager.setTreeStatus = function(name) { |
---|
| 282 | var tree_status = ""; |
---|
| 283 | for(var i=0; i < eccube.fileManager.arrTreeStatus.length ;i++) { |
---|
| 284 | if(i !== 0) { |
---|
| 285 | tree_status += '|'; |
---|
| 286 | } |
---|
| 287 | tree_status += eccube.fileManager.arrTreeStatus[i]; |
---|
[20566] | 288 | } |
---|
[23381] | 289 | document.form1[name].value = tree_status; |
---|
[23129] | 290 | }; |
---|
[16757] | 291 | |
---|
[23129] | 292 | // 階層ツリーメニュー表示・非表示処理 |
---|
| 293 | eccube.fileManager.toggleTreeMenu = function(tName, imgName, path) { |
---|
| 294 | var tMenu = $("#" + tName); |
---|
[16708] | 295 | |
---|
[23129] | 296 | if(tMenu.css("display") === 'none') { |
---|
[23381] | 297 | $("#" +imgName).attr("src", eccube.fileManager.IMG_MINUS); |
---|
[23129] | 298 | tMenu.show(); |
---|
| 299 | // 階層の開いた状態を保持 |
---|
| 300 | eccube.fileManager.arrTreeStatus.push(path); |
---|
| 301 | } else { |
---|
[23381] | 302 | $("#" +imgName).attr("src", eccube.fileManager.IMG_PLUS); |
---|
[23129] | 303 | tMenu.hide(); |
---|
| 304 | // 閉じ状態を保持 |
---|
[23381] | 305 | eccube.fileManager.fnDelTreeStatus(path); |
---|
[23129] | 306 | } |
---|
| 307 | }; |
---|
[16757] | 308 | |
---|
[23129] | 309 | // Tree状態を削除する(閉じる状態へ) |
---|
| 310 | eccube.fileManager.deleteTreeStatus = function(path) { |
---|
| 311 | for(var i=0; i < eccube.fileManager.arrTreeStatus.length ;i++) { |
---|
| 312 | if(eccube.fileManager.arrTreeStatus[i] === path) { |
---|
| 313 | eccube.fileManager.arrTreeStatus[i] = ""; |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | }; |
---|
[16708] | 317 | |
---|
[23129] | 318 | // ファイルリストダブルクリック処理 |
---|
| 319 | eccube.fileManager.doubleClick = function(arrTree, path, is_dir, now_dir, is_parent) { |
---|
| 320 | if(is_dir) { |
---|
| 321 | if(!is_parent) { |
---|
| 322 | for(var cnt = 0; cnt < arrTree.length; cnt++) { |
---|
| 323 | if(now_dir === arrTree[cnt][2]) { |
---|
| 324 | var open_flag = false; |
---|
| 325 | for(var status_cnt = 0; status_cnt < eccube.fileManager.arrTreeStatus.length; status_cnt++) { |
---|
| 326 | if(eccube.fileManager.arrTreeStatus[status_cnt] === arrTree[cnt][2]) { |
---|
| 327 | open_flag = true; |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | if(!open_flag) { |
---|
| 331 | eccube.fileManager.toggleTreeMenu('tree'+cnt, 'rank_img'+cnt, arrTree[cnt][2]); |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | } |
---|
| 335 | } |
---|
| 336 | eccube.fileManager.openFolder(path); |
---|
[18777] | 337 | } else { |
---|
[23129] | 338 | // Download |
---|
| 339 | eccube.setModeAndSubmit('download','',''); |
---|
[18777] | 340 | } |
---|
[23129] | 341 | }; |
---|
[23079] | 342 | |
---|
[23129] | 343 | // フォルダオープン処理 |
---|
| 344 | eccube.fileManager.openFolder = function(path) { |
---|
| 345 | // クリックしたフォルダ情報を保持 |
---|
[23381] | 346 | document.form1[eccube.fileManager.selectFileHidden].value = path; |
---|
[23129] | 347 | // treeの状態をセット |
---|
| 348 | eccube.fileManager.setTreeStatus(eccube.fileManager.treeStatusHidden); |
---|
| 349 | // submit |
---|
| 350 | eccube.setModeAndSubmit(eccube.fileManager.modeHidden,'',''); |
---|
| 351 | }; |
---|
| 352 | |
---|
| 353 | // ファイル選択 |
---|
| 354 | eccube.fileManager.selectFile = function(id) { |
---|
| 355 | eccube.fileManager.old_select_id = id; |
---|
| 356 | }; |
---|
| 357 | |
---|
| 358 | // グローバルに使用できるようにする |
---|
| 359 | window.eccube = eccube; |
---|
| 360 | |
---|
| 361 | /** |
---|
| 362 | * Initialize. |
---|
| 363 | */ |
---|
| 364 | $(function() { |
---|
[23442] | 365 | var naviClicked = false; |
---|
[23129] | 366 | // ヘッダナビゲーション |
---|
[23441] | 367 | $("#navi").find("div").click(function(){ |
---|
[23442] | 368 | naviClicked = true; |
---|
[23443] | 369 | |
---|
[23446] | 370 | var parent = $(this).parent('li'); |
---|
| 371 | var level1 = $(this).parents('li.on_level1'); |
---|
| 372 | |
---|
| 373 | if (parent.hasClass('on_level1')) { |
---|
| 374 | // クリックしたメニューが第1階層なら開閉を切り替え. |
---|
[23450] | 375 | if (!parent.hasClass('sfhover')) { |
---|
| 376 | parent.addClass('clicked'); |
---|
| 377 | } else if (parent.hasClass('clicked')) { |
---|
| 378 | parent.removeClass('clicked'); |
---|
| 379 | } |
---|
[23446] | 380 | } else { |
---|
| 381 | // 第2階層以下なら第1階層を開いた状態にする. |
---|
| 382 | level1.addClass('clicked'); |
---|
| 383 | } |
---|
| 384 | // クリックしたメニュー以外のメニューを閉じる. |
---|
| 385 | level1.siblings('li') |
---|
| 386 | .removeClass('clicked') |
---|
| 387 | .removeClass('sfhover') |
---|
| 388 | .find('li').removeClass('sfhover'); |
---|
| 389 | |
---|
[23443] | 390 | // ナビゲーションがアクティブであれば、マウスオーバーを有効に. |
---|
| 391 | $("#navi") |
---|
[23450] | 392 | .on('mouseleave', function(){ |
---|
| 393 | $(this).not(':has(li.on_level1.clicked)').find('li') |
---|
| 394 | .off('mouseenter') |
---|
| 395 | .off('mouseleave'); |
---|
| 396 | }) |
---|
[23449] | 397 | .has('li.on_level1.clicked').find('li.on_level1').hover( |
---|
[23443] | 398 | function(){ |
---|
[23450] | 399 | $(this) |
---|
| 400 | .addClass('sfhover') |
---|
| 401 | .siblings('li') |
---|
| 402 | .removeClass('sfhover') |
---|
| 403 | .removeClass('clicked'); |
---|
| 404 | }, |
---|
| 405 | function(){ |
---|
| 406 | $(this).not('.clicked').removeClass('sfhover'); |
---|
[23443] | 407 | } |
---|
| 408 | ); |
---|
| 409 | |
---|
[23446] | 410 | if (parent.hasClass('clicked')) { |
---|
| 411 | parent.addClass('sfhover'); |
---|
| 412 | } else if (parent.hasClass('sfhover')) { |
---|
[23441] | 413 | parent |
---|
| 414 | .removeClass('sfhover') |
---|
| 415 | .find('li').removeClass('sfhover'); |
---|
| 416 | } else { |
---|
| 417 | parent |
---|
| 418 | .addClass('sfhover') |
---|
| 419 | .siblings('li') |
---|
| 420 | .removeClass('sfhover') |
---|
| 421 | .find('li').removeClass('sfhover'); |
---|
[23129] | 422 | } |
---|
[23441] | 423 | }); |
---|
[23442] | 424 | // ナビゲーション以外をクリックしたらナビを閉じる. |
---|
| 425 | $(document).click(function(){ |
---|
| 426 | if (!naviClicked) { |
---|
[23443] | 427 | $("#navi").find('li') |
---|
| 428 | .off('mouseenter') |
---|
| 429 | .off('mouseleave') |
---|
[23446] | 430 | .removeClass('sfhover') |
---|
| 431 | .removeClass('clicked'); |
---|
[23442] | 432 | } else { |
---|
| 433 | naviClicked = false; |
---|
| 434 | } |
---|
| 435 | }); |
---|
[23129] | 436 | }); |
---|
| 437 | })(window); |
---|
| 438 | |
---|
[23079] | 439 | (function($) { |
---|
| 440 | /** |
---|
| 441 | * パンくず |
---|
| 442 | */ |
---|
| 443 | var o; |
---|
| 444 | |
---|
| 445 | $.fn.breadcrumbs = function(options) { |
---|
| 446 | var defaults = { |
---|
| 447 | bread_crumbs: '', |
---|
| 448 | start_node: '<span>ホーム</span>', |
---|
[23129] | 449 | anchor_node: '<a onclick="eccube.setModeAndSubmit(\'tree\', \'parent_category_id\', ' + |
---|
| 450 | '{category_id}); return false" href="javascript:;" />', |
---|
[23079] | 451 | delimiter_node: '<span> > </span>' |
---|
| 452 | }; |
---|
| 453 | |
---|
| 454 | return this.each(function() { |
---|
| 455 | if (options) { |
---|
| 456 | o = $.fn.extend(defaults, options); |
---|
| 457 | } |
---|
| 458 | var $this = $(this); |
---|
| 459 | var total = o.bread_crumbs.length; |
---|
| 460 | var $node = $(o.start_node); |
---|
| 461 | |
---|
| 462 | for (var i = total - 1; i >= 0; i--) { |
---|
[23129] | 463 | if (i === total -1) { |
---|
| 464 | $node.append(o.delimiter_node); |
---|
| 465 | } |
---|
[23079] | 466 | |
---|
[23381] | 467 | var anchor = o.anchor_node.replace(/{category_id}/ig, o.bread_crumbs[i].category_id); |
---|
[23079] | 468 | $(anchor) |
---|
[23381] | 469 | .text(o.bread_crumbs[i].category_name) |
---|
[23079] | 470 | .appendTo($node); |
---|
| 471 | |
---|
[23129] | 472 | if (i > 0) { |
---|
| 473 | $node.append(o.delimiter_node); |
---|
| 474 | } |
---|
[23079] | 475 | } |
---|
| 476 | $this.html($node); |
---|
| 477 | return this; |
---|
| 478 | }); |
---|
| 479 | }; |
---|
| 480 | })(jQuery); |
---|