1 | /* |
---|
2 | * This file is part of EC-CUBE |
---|
3 | * |
---|
4 | * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved. |
---|
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 | (function($) { |
---|
23 | var o; |
---|
24 | |
---|
25 | $.fn.breadcrumbs = function(options) { |
---|
26 | var defaults = { |
---|
27 | bread_crumbs: '', |
---|
28 | start_node: '<span>ホーム</span>', |
---|
29 | anchor_node: '<a onclick="eccube.setModeAndSubmit(\'tree\', \'parent_category_id\', ' + |
---|
30 | '{category_id}); return false" href="javascript:;" />', |
---|
31 | delimiter_node: '<span> > </span>' |
---|
32 | }; |
---|
33 | |
---|
34 | return this.each(function() { |
---|
35 | if (options) { |
---|
36 | o = $.fn.extend(defaults, options); |
---|
37 | } |
---|
38 | var $this = $(this); |
---|
39 | var total = o.bread_crumbs.length; |
---|
40 | var $node = $(o.start_node); |
---|
41 | |
---|
42 | for (var i = total - 1; i >= 0; i--) { |
---|
43 | if (i == total -1) $node.append(o.delimiter_node); |
---|
44 | |
---|
45 | var anchor = o.anchor_node |
---|
46 | .replace(/{category_id}/ig, |
---|
47 | o.bread_crumbs[i].category_id); |
---|
48 | $(anchor) |
---|
49 | .text(o.bread_crumbs[i].category_name) |
---|
50 | .appendTo($node); |
---|
51 | |
---|
52 | if (i > 0) $node.append(o.delimiter_node); |
---|
53 | } |
---|
54 | $this.html($node); |
---|
55 | return this; |
---|
56 | }); |
---|
57 | }; |
---|
58 | })(jQuery); |
---|