1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* popup関係の関数
* $Id: do_select_popup.php
* @author zhouz
* @access public
* @package manager.public_html.dynamicscripts
*/
// クラス・設定読み込み
require_once("../manager_include.inc");
?>
// <!--
/**
* doHelpPopup();
* @return
*/
function doHelpPopup(html_data , event) {
var event = event || window.event;
var width_min = 320;
var width_max = 320;
var height_min = 320;
var height_max = 320;
var win_x = document.body.clientWidth;
var win_y = document.body.clientHeight;
var mouse_x = event.pageX;
var mouse_y = event.pageY;
var selectdialogouterframe = document.getElementById('selectdialogouterframe');
if (mouse_x <= (win_x - 340) && mouse_y <= (win_y - 325)) {
selectdialogouterframe.style.top = (mouse_y + 5) + "px";
selectdialogouterframe.style.left = (mouse_x + 20) + "px";
} else if (mouse_x <= (win_x - 340) && mouse_y > (win_y - 325)) {
selectdialogouterframe.style.top = (mouse_y - 325) + "px";
selectdialogouterframe.style.left = (mouse_x + 20) + "px";
} else if (mouse_x > (win_x - 340) && mouse_y <= (win_y - 325)) {
selectdialogouterframe.style.top = (mouse_y + 5) + "px";
selectdialogouterframe.style.left = (mouse_x - 325) + "px";
} else {
selectdialogouterframe.style.top = (mouse_y - 325) + "px";
selectdialogouterframe.style.left = (mouse_x - 325) + "px";
}
selectdialogouterframe.style.zIndex = "3";
selectdialogouterframe.style.visibility = "visible";
selectdialogouterframe.style.position = "absolute";
selectdialogouterframe.style.margin = "0px";
doPopup(html_data,width_min, width_max, height_min, height_max);
$("#selectdialogouterframe").mouseout(function(){
$("body").click(function(){
closeSelectPopup();
});
});
}
/**
* doSelectPopup();
* @return
*/
function doSelectPopup(html_data) {
var width_min = <?=POPUP_WINDOW_INFO_MIN_WIDTH ?>;
var width_max = <?=POPUP_WINDOW_INFO_MAX_WIDTH ?>;
var height_min = <?=POPUP_WINDOW_INFO_MIN_HEIGHT ?>;
var height_max = <?=POPUP_WINDOW_INFO_MAX_HEIGHT ?>;
var selectpopup = window.parent.document.getElementById('selectpopup');
selectpopup.className = "showdialog";
doPopup(html_data,width_min, width_max, height_min, height_max);
}
/**
* setCheckboxValue
* @param viewTarget
* @param valueTarget
* @param requestUrl
*/
function setCheckboxValue(viewTarget, valueTarget, requestUrl, formName) {
var arr = new Array();
var checkbox = document.getElementsByName("id_array[]");
for(var i = 0;i < checkbox.length; i++){
if(checkbox[i].checked) {
arr.push(checkbox[i].value);
}
}
var id_array = arr.toString();
if (valueTarget == "category_name") {
if (id_array.length > 0) {
requestUrl = requestUrl + "&category_name=" + id_array;
$.getJSON(requestUrl, function(json){
var view = new Array();
for (var i=0; i < json.length; i++) {
view[i] = json[i]["title"];
}
document.getElementsByName(viewTarget)[0].value = view.join(",");
})
} else {
selectClear(formName, 'category_title', 'category_name');
}
} else {
document.getElementById('contentFrame').contentWindow.document.getElementsByName(viewTarget)[0].value = id_array;
}
document.getElementById('contentFrame').contentWindow.document.getElementsByName(valueTarget)[0].value = id_array;
// セットしたら閉める
closeSelectPopup();
}
/**
* setRadioboxValue
* @param viewTarget
* @param valueTarget
* @param requestUrl
*/
function setRadioboxValue(viewTarget, valueTarget, requestUrl, formName) {
var radios = document.getElementsByName("radio_array[]");
var checked_value = 0;
for (var i = 0; i < radios.length; i++) {
var radio = radios[i];
if (radio.checked) {
var checked_value = radio.value;
}
}
if (valueTarget == "course_id") {
if (checked_value != 0) {
requestUrl = requestUrl + "&id=" + checked_value;
$.getJSON(requestUrl, function(json){
document.getElementById('contentFrame').contentWindow.document.getElementsByName(viewTarget)[0].value = json[0]["title"];
})
} else {
selectClear(formName, 'course_name', 'course_id');
}
} else {
document.getElementById('contentFrame').contentWindow.document.getElementById('contentFrame').contentWindow.document.getElementsByName(viewTarget)[0].value = checked_value;
}
document.getElementById('contentFrame').contentWindow.document.getElementsByName(valueTarget)[0].value = checked_value;
// セットしたら閉める
closeSelectPopup();
}
/**
* 選んだ候補をセットします。
* @param formName
* @param viewTarget
* @param valueTarget
* @param viewValue
* @param valueValue
*/
function setSelectValue(obj, formName, viewTarget, valueTarget, viewValue, valueValue) {
// TODO 存在チェック
var targetForm = document.getElementsByName(formName)[0];
//alert("DEBUG:" + " " + viewTarget + " " + valueTarget + " " + viewValue + " " + valueValue);
// 複数
// if (targetForm.elements[viewTarget].value != "") {
// targetForm.elements[viewTarget].value += "," + viewValue;
// } else {
// targetForm.elements[viewTarget].value = viewValue;
// }
// if (targetForm.elements[valueTarget].value != "") {
// targetForm.elements[valueTarget].value += "," + valueValue;
// } else {
// targetForm.elements[valueTarget].value = valueValue;
// }
// 一つだけ
targetForm.elements[viewTarget].value = viewValue;
targetForm.elements[valueTarget].value = valueValue;
obj.disabled = true;
// セットしたら閉める
closeSelectPopup();
}
/**
* ポップアップを閉めます。
* @return
*/
function closeSelectPopup() {
var selectpopup = document.getElementById('selectpopup');
selectpopup.className = "hiddendialog";
var innerframe = document.getElementById('innerframe');
innerframe.innerHTML = "";
var selectdialogouterframe = document.getElementById('selectdialogouterframe');
selectdialogouterframe.style.zIndex = "0";
selectdialogouterframe.style.visibility = "hidden";
selectdialogouterframe.style.position = "relative";
selectdialogouterframe.style.marginTop = "40px";
selectdialogouterframe.style.marginLeft = "auto";
selectdialogouterframe.style.marginRight = "auto";
$("body").unbind("click");
}
/**
* 選択クリア。
* @return
*/
function selectClear(formName,name1,name2) {
var targetForm = document.getElementsByName(formName)[0];
targetForm.elements[name1].value = "";
if (name2 != "") {
targetForm.elements[name2].value = "";
}
}
/**
* 選択クリア。
* @return
*/
function in_array(val, arr) {
for (key in arr) {
if (arr[key] == val) {
return true;
}
}
return false;
}
// -->