/** * 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 = 640; var width_max = 640; var height_min = 160; var height_max = 480; var selectpopup = 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 = ""; for (var i=0; i < json.length; i++) { view += json[i]["title"]; } document.getElementsByName(viewTarget)[0].value = view; }) } else { selectClear(formName, 'category_title', 'category_name'); } } else { document.getElementsByName(viewTarget)[0].value = id_array; } document.getElementsByName(valueTarget)[0].value = id_array; // セットしたら閉める closeSelectPopup(); } /** * 選んだ候補をセットします。 * @param formName * @param viewTarget * @param valueTarget * @param viewValue * @param valueValue */ function setSelectValue(formName, viewTarget, valueTarget, viewValue, valueValue) { // TODO 存在チェック var targetForm = document.getElementsByName(formName)[0]; //alert("DEBUG:" + " " + viewTarget + " " + valueTarget + " " + viewValue + " " + valueValue); // TODO 存在チェック targetForm.elements[viewTarget].value = viewValue; // TODO 存在チェック targetForm.elements[valueTarget].value = valueValue; // セットしたら閉める 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; }