1 | /* |
---|
2 | * This file is part of EC-CUBE |
---|
3 | * |
---|
4 | * Copyright(c) 2000-2007 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 | var obj; |
---|
23 | var offsetX; |
---|
24 | var offsetY; |
---|
25 | var arrObj; |
---|
26 | var objParam; |
---|
27 | |
---|
28 | // パラメータ管理クラスの定義 |
---|
29 | function SC_Param() { |
---|
30 | this.ITEM_MAX = 3; |
---|
31 | } |
---|
32 | |
---|
33 | // サイズ管理クラスの定義 |
---|
34 | function SC_Size() { |
---|
35 | this.id = ''; |
---|
36 | this.left = 0; |
---|
37 | this.top = 0; |
---|
38 | this.width = 0; |
---|
39 | this.height = 0; |
---|
40 | this.obj; |
---|
41 | }; |
---|
42 | |
---|
43 | // オンロード処理 |
---|
44 | onload=function () { |
---|
45 | // パラメータの初期化 |
---|
46 | objParam = new SC_Param(); |
---|
47 | |
---|
48 | // WIN-IE |
---|
49 | if (document.all) { |
---|
50 | objlist = document.all.tags("div"); |
---|
51 | // WIN-NN,WIN-FF |
---|
52 | } else if (document.getElementsByTagName) { |
---|
53 | objlist = document.getElementsByTagName("div"); |
---|
54 | } else { |
---|
55 | return; |
---|
56 | } |
---|
57 | |
---|
58 | arrObj = new Array(); |
---|
59 | for (i = 0; i < objlist.length; i++) { |
---|
60 | id = objlist[i].id; |
---|
61 | arrObj[id] = new SC_Size(); |
---|
62 | arrObj[id].id = id; |
---|
63 | arrObj[id].obj = objlist[id]; |
---|
64 | arrObj[id].left = objlist[id].style.left; |
---|
65 | arrObj[id].top = objlist[id].style.top; |
---|
66 | arrObj[id].width = objlist[id].style.width; |
---|
67 | arrObj[id].height = objlist[id].style.height; |
---|
68 | arrObj[id].left = Number(arrObj[id].left.replace(/px/, '')); |
---|
69 | arrObj[id].top = Number(arrObj[id].top.replace(/px/, '')); |
---|
70 | arrObj[id].width = Number(arrObj[id].width.replace(/px/, '')); |
---|
71 | arrObj[id].height = Number(arrObj[id].height.replace(/px/, '')); |
---|
72 | arrObj[id].right = Number(arrObj[id].left) + Number(arrObj[id].width); |
---|
73 | arrObj[id].bottom =Number(arrObj[id].top) + Number(arrObj[id].height); |
---|
74 | } |
---|
75 | |
---|
76 | // MouseDownイベント処理の入れ替え |
---|
77 | objlist['item0'].onmousedown = onMouseDown; |
---|
78 | objlist['item1'].onmousedown = onMouseDown; |
---|
79 | objlist['item2'].onmousedown = onMouseDown; |
---|
80 | |
---|
81 | document.onmousemove = onMouseMove; |
---|
82 | document.onmouseup = onMouseUp; |
---|
83 | } |
---|
84 | |
---|
85 | // MouseDownイベント |
---|
86 | function onMouseDown(e) { |
---|
87 | obj = this; |
---|
88 | // WIN-IE |
---|
89 | if (document.all) { |
---|
90 | offsetX = event.offsetX + 2; |
---|
91 | offsetY = event.offsetY + 2; |
---|
92 | // WIN-NN,WIN-FF |
---|
93 | } else if (obj.getElementsByTagName) { |
---|
94 | offsetX = e.pageX - parseInt(obj.style.left); |
---|
95 | offsetY = e.pageY - parseInt(obj.style.top); |
---|
96 | } |
---|
97 | return false; |
---|
98 | } |
---|
99 | |
---|
100 | // MouseMoveイベント |
---|
101 | function onMouseMove(e) { |
---|
102 | if (!obj) { |
---|
103 | return true; |
---|
104 | } |
---|
105 | // WIN-IE |
---|
106 | if (document.all) { |
---|
107 | x = event.clientX - offsetX; |
---|
108 | // 画面外に出ないように制御する |
---|
109 | if(x <= 0) { |
---|
110 | x = 0; |
---|
111 | } |
---|
112 | left_max = document.body.clientWidth - arrObj[obj.id].width; |
---|
113 | if(x >= left_max) { |
---|
114 | x =left_max; |
---|
115 | } |
---|
116 | obj.style.left = x; |
---|
117 | // 画面外に出ないように制御する |
---|
118 | y = event.clientY - offsetY; |
---|
119 | if(y <= 0) { |
---|
120 | y = 0; |
---|
121 | } |
---|
122 | top_max = document.body.clientHeight - arrObj[obj.id].height; |
---|
123 | if(y >= top_max) { |
---|
124 | y =top_max; |
---|
125 | } |
---|
126 | obj.style.top = y; |
---|
127 | // WIN-NN,WIN-FF |
---|
128 | } else if (obj.getElementsByTagName) { |
---|
129 | x = e.pageX - offsetX; |
---|
130 | // 画面外に出ないように制御する |
---|
131 | if(x <= 0) { |
---|
132 | x = 0; |
---|
133 | } |
---|
134 | left_max = window.innerWidth - arrObj[obj.id].width; |
---|
135 | if(x >= left_max) { |
---|
136 | x =left_max; |
---|
137 | } |
---|
138 | obj.style.left = x; |
---|
139 | |
---|
140 | y = e.pageY - offsetY; |
---|
141 | // 画面外に出ないように制御する |
---|
142 | if(y <= 0) { |
---|
143 | y = 0; |
---|
144 | obj.style.top = 0; |
---|
145 | } |
---|
146 | top_max = window.innerHeight - arrObj[obj.id].height; |
---|
147 | if(y >= top_max) { |
---|
148 | y =top_max; |
---|
149 | } |
---|
150 | obj.style.top = y; |
---|
151 | } |
---|
152 | |
---|
153 | if(isInFlame('flame0', obj)) { |
---|
154 | document.getElementById('td1').style.backgroundColor = '#fffadd'; |
---|
155 | } else { |
---|
156 | document.getElementById('td1').style.backgroundColor = '#ffffff'; |
---|
157 | } |
---|
158 | return false; |
---|
159 | } |
---|
160 | |
---|
161 | // MouseUpイベント |
---|
162 | function onMouseUp(e) { |
---|
163 | if (!obj) { |
---|
164 | return true; |
---|
165 | } |
---|
166 | |
---|
167 | if(!isInFlame('flame0', obj)) { |
---|
168 | // WIN-IE |
---|
169 | if (document.all) { |
---|
170 | // 最初の位置に戻す |
---|
171 | obj.style.left = arrObj[obj.id].left; |
---|
172 | obj.style.top = arrObj[obj.id].top; |
---|
173 | // WIN-NN,WIN-FF |
---|
174 | } else if (obj.getElementsByTagName) { |
---|
175 | // 最初の位置に戻す |
---|
176 | obj.style.left = arrObj[obj.id].left; |
---|
177 | obj.style.top = arrObj[obj.id].top; |
---|
178 | } |
---|
179 | } |
---|
180 | document.getElementById('td1').style.backgroundColor = '#ffffff'; |
---|
181 | obj = null; |
---|
182 | } |
---|
183 | |
---|
184 | // フレーム内にアイテムが存在するか判定する |
---|
185 | function isInFlame(flame_id, item) { |
---|
186 | top_val = item.style.top; |
---|
187 | top_val = Number(top_val.replace(/px/, '')); |
---|
188 | bottom_val = top_val + arrObj[item.id].height; |
---|
189 | left_val = item.style.left; |
---|
190 | left_val = Number(left_val.replace(/px/, '')) |
---|
191 | right_val = left_val + arrObj[item.id].width; |
---|
192 | if( |
---|
193 | top_val > arrObj[flame_id].top && |
---|
194 | bottom_val < arrObj[flame_id].bottom && |
---|
195 | left_val > arrObj[flame_id].left && |
---|
196 | right_val < arrObj[flame_id].right |
---|
197 | ) { |
---|
198 | return true; |
---|
199 | } |
---|
200 | return false; |
---|
201 | } |
---|
202 | |
---|
203 | // 送信前の処理 |
---|
204 | function preSubmit() { |
---|
205 | for(i = 0; i < 3; i++) { |
---|
206 | id = 'item' + i; |
---|
207 | obj = arrObj[id].obj; |
---|
208 | if(isInFlame ('flame0', obj)) { |
---|
209 | document.form1[obj.id].value = "in"; |
---|
210 | } else { |
---|
211 | document.form1[obj.id].value = "out"; |
---|
212 | } |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | |
---|
217 | |
---|