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 setTopButton(topURL) { |
---|
24 | if(!topURL){ |
---|
25 | topURL = "/"; |
---|
26 | } |
---|
27 | var buttonText = "TOPへ"; |
---|
28 | var buttonId = "btn-top"; |
---|
29 | |
---|
30 | //ボタンの生成・設定 |
---|
31 | var btn = document.createElement('div'); |
---|
32 | var a = document.createElement('a'); |
---|
33 | btn.id = buttonId; |
---|
34 | btn.onclick = function(){location=topURL;}; |
---|
35 | a.href = topURL; |
---|
36 | a.innerText = buttonText; |
---|
37 | |
---|
38 | /* 背景色の設定 ---------------------*/ |
---|
39 | //最初の見出しの背景色を取得、設定 |
---|
40 | var obj = document.getElementsByTagName('h2')[0]; |
---|
41 | var col = document.defaultView.getComputedStyle(obj,null).getPropertyValue('background-color'); |
---|
42 | btn.style.backgroundColor = col; |
---|
43 | |
---|
44 | //省略表示用テキストの生成 |
---|
45 | var spn = document.createElement('span'); |
---|
46 | spn.innerText = obj.innerText; |
---|
47 | obj.innerText = ""; |
---|
48 | spn.style.display = "inline-block"; |
---|
49 | spn.style.maxWidth = "50%"; |
---|
50 | spn.style.overflow = "hidden"; |
---|
51 | spn.style.textOverflow = "ellipsis"; |
---|
52 | obj.appendChild(spn); |
---|
53 | |
---|
54 | //ボタンを追加 |
---|
55 | btn.appendChild(a); |
---|
56 | document.getElementsByTagName('body')[0].appendChild(btn);; |
---|
57 | } |
---|
58 | |
---|
59 | function smartRollover() { |
---|
60 | if (document.getElementsByTagName) { |
---|
61 | var images = document.getElementsByTagName("img"); |
---|
62 | |
---|
63 | for (var i=0; i < images.length; i++) { |
---|
64 | if (images[i].getAttribute("src").match("_off.")) { |
---|
65 | images[i].onmouseover = function() { |
---|
66 | this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); |
---|
67 | } |
---|
68 | images[i].onmouseout = function() { |
---|
69 | this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | if (window.addEventListener) { |
---|
77 | window.addEventListener("load", smartRollover, false); |
---|
78 | } else if (window.attachEvent) { |
---|
79 | window.attachEvent("onload", smartRollover); |
---|
80 | } |
---|
81 | |
---|
82 | /*------------------------------------------ |
---|
83 | お気に入りを登録する |
---|
84 | ------------------------------------------*/ |
---|
85 | function fnAddFavoriteSphone(favoriteProductId) { |
---|
86 | $.mobile.showPageLoadingMsg(); |
---|
87 | //送信データを準備 |
---|
88 | var postData = {}; |
---|
89 | $("#form1").find(':input').each(function(){ |
---|
90 | postData[$(this).attr('name')] = $(this).val(); |
---|
91 | }); |
---|
92 | postData["mode"] = "add_favorite_sphone"; |
---|
93 | postData["favorite_product_id"] = favoriteProductId; |
---|
94 | |
---|
95 | $.ajax({ |
---|
96 | type: "POST", |
---|
97 | url: $("#form1").attr('action'), |
---|
98 | data: postData, |
---|
99 | cache: false, |
---|
100 | dataType: "text", |
---|
101 | error: function(XMLHttpRequest, textStatus, errorThrown){ |
---|
102 | alert(textStatus); |
---|
103 | $.mobile.hidePageLoadingMsg(); |
---|
104 | }, |
---|
105 | success: function(result){ |
---|
106 | if (result == "true") { |
---|
107 | alert("お気に入りに登録しました"); |
---|
108 | $(".btn_favorite").html("<p>お気に入り登録済み</p>"); |
---|
109 | } else { |
---|
110 | alert("お気に入りの登録に失敗しました"); |
---|
111 | } |
---|
112 | $.mobile.hidePageLoadingMsg(); |
---|
113 | } |
---|
114 | }); |
---|
115 | } |
---|