| 1 | /* |
|---|
| 2 | * This file is part of EC-CUBE |
|---|
| 3 | * |
|---|
| 4 | * Copyright(c) 2000-2013 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 | |
|---|
| 23 | (function( window, undefined ){ |
|---|
| 24 | |
|---|
| 25 | // 名前空間の重複を防ぐ |
|---|
| 26 | if (window.eccube === undefined) { |
|---|
| 27 | window.eccube = {}; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | var eccube = window.eccube; |
|---|
| 31 | |
|---|
| 32 | eccube.smartRollover = function() { |
|---|
| 33 | if (document.getElementsByTagName) { |
|---|
| 34 | var images = $("img"); |
|---|
| 35 | var re = /_off¥./; |
|---|
| 36 | |
|---|
| 37 | images.each(function(){ |
|---|
| 38 | var target = $(this); |
|---|
| 39 | if (target.attr("src").match(re)) { |
|---|
| 40 | target.on("vmouseover", function(){ |
|---|
| 41 | this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); |
|---|
| 42 | }); |
|---|
| 43 | target.on("vmouseout", function(){ |
|---|
| 44 | this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); |
|---|
| 45 | }); |
|---|
| 46 | } |
|---|
| 47 | }); |
|---|
| 48 | } |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | if (window.addEventListener) { |
|---|
| 52 | window.addEventListener("load", eccube.smartRollover, false); |
|---|
| 53 | } else if (window.attachEvent) { |
|---|
| 54 | window.attachEvent("onload", eccube.smartRollover); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | /*------------------------------------------ |
|---|
| 58 | お気に入りを登録する |
|---|
| 59 | ------------------------------------------*/ |
|---|
| 60 | eccube.addFavoriteSphone = function(favoriteProductId) { |
|---|
| 61 | $.mobile.showPageLoadingMsg(); |
|---|
| 62 | //送信データを準備 |
|---|
| 63 | var postData = {}; |
|---|
| 64 | var form = $("#form1"); |
|---|
| 65 | form.find(':input').each(function(){ |
|---|
| 66 | postData[$(this).attr('name')] = $(this).val(); |
|---|
| 67 | }); |
|---|
| 68 | postData.mode = "add_favorite_sphone"; |
|---|
| 69 | postData.favorite_product_id = favoriteProductId; |
|---|
| 70 | |
|---|
| 71 | $.ajax({ |
|---|
| 72 | type: "POST", |
|---|
| 73 | url: form.attr('action'), |
|---|
| 74 | data: postData, |
|---|
| 75 | cache: false, |
|---|
| 76 | dataType: "text", |
|---|
| 77 | error: function(XMLHttpRequest, textStatus){ |
|---|
| 78 | window.alert(textStatus); |
|---|
| 79 | $.mobile.hidePageLoadingMsg(); |
|---|
| 80 | }, |
|---|
| 81 | success: function(result){ |
|---|
| 82 | if (result === "true") { |
|---|
| 83 | window.alert("お気に入りに登録しました"); |
|---|
| 84 | $(".btn_favorite").html("<p>お気に入り登録済み</p>"); |
|---|
| 85 | } else { |
|---|
| 86 | window.alert("お気に入りの登録に失敗しました"); |
|---|
| 87 | } |
|---|
| 88 | $.mobile.hidePageLoadingMsg(); |
|---|
| 89 | } |
|---|
| 90 | }); |
|---|
| 91 | }; |
|---|
| 92 | |
|---|
| 93 | // グローバルに使用できるようにする |
|---|
| 94 | window.eccube = eccube; |
|---|
| 95 | |
|---|
| 96 | /*------------------------------------------ |
|---|
| 97 | 初期化 |
|---|
| 98 | ------------------------------------------*/ |
|---|
| 99 | $(function(){ |
|---|
| 100 | //level?クラスを持つノード全てを走査し初期化 |
|---|
| 101 | $("#categorytree").find("li").each(function(){ |
|---|
| 102 | if ($(this).find("> ul").length) { |
|---|
| 103 | //▶を表示し、リストオープンイベントを追加 |
|---|
| 104 | var tgt = $(this).find("> span.category_header"); |
|---|
| 105 | var linkObj = $("<a>"); |
|---|
| 106 | linkObj.html('+'); |
|---|
| 107 | tgt |
|---|
| 108 | .click(function(){ |
|---|
| 109 | $(this).siblings("ul").toggle('fast', function(){ |
|---|
| 110 | if ($(this).css('display') === 'none') { |
|---|
| 111 | tgt.children('a').html('+'); |
|---|
| 112 | } else { |
|---|
| 113 | tgt.children('a').html('-'); |
|---|
| 114 | } |
|---|
| 115 | }); |
|---|
| 116 | }) |
|---|
| 117 | .addClass('plus') |
|---|
| 118 | .append(linkObj); |
|---|
| 119 | } |
|---|
| 120 | }); |
|---|
| 121 | }); |
|---|
| 122 | })(window); |
|---|