/********************************************************************* * * Dynamic website agreement dialog functions * Country: Korea * Language: Korean * Version 1.0 * Code dependancies: dialogCore.js/jsp * Author: Oliver Ammann * **********************************************************************/ // Add loadlistener for initDialog function addLoadListener(initDialog); // Preload app images to improve preformance preLoad('/content/images/kr/modules/common/dots.gif', '/content/images/kr/modules/transitionPage/loading_sequence1.gif'); /** * Function: initDialog() * Calls the create dialog function when the anchor with unique * id "agreement" is clicked */ function initDialog() { var agreement = document.getElementById("agreement"); agreement.onclick = createDialog; return true; } /** * Function: createDialog() * Dynamically creates the custom dialog using the dom * CSS classes referenced by this code are in amadeus_apps.css */ function createDialog() { var body = document.getElementsByTagName("body")[0]; var pageDimensions = getPageDimensions(); var viewportSize = getViewportSize(); if (viewportSize[1] > pageDimensions[1]) { pageDimensions[1] = viewportSize[1]; } var dropSheet = document.createElement("div"); dropSheet.setAttribute("id", "dropSheet"); dropSheet.style.position = "absolute"; dropSheet.style.left = "0"; dropSheet.style.top = "0"; dropSheet.style.width = pageDimensions[0] + "px"; dropSheet.style.height = pageDimensions[1] + "px"; body.appendChild(dropSheet); try { // Creates IFrame element, which will sit behind the dialog div // This is required to stop form controls from showing through in IE // if the dialog happens to sit above such an element. // Form elements in IE are rendered by the OS and therefore have // a z-index of infinity. Iframes are also treated as an OS element // and can therefore be manipulated to cover the form elements. var dialogIframe = document.createElement("iframe"); dialogIframe.className = "dIframeKO"; dialogIframe.setAttribute("frameborder", "0"); dialogIframe.setAttribute("border", "0"); dialogIframe.setAttribute("id", "frameId"); dialogIframe.tabIndex = '-1'; dialogIframe.style.visibility = "hidden"; dialogIframe.style.position = "absolute"; // Create dialog parent div var dialog = document.createElement("div"); dialog.className = "customDialogKO"; dialog.style.visibility = "hidden"; dialog.style.position = "absolute"; // Create dialog title and append to dialog var dialogTitle = document.createElement("h1"); dialogTitle.appendChild(document.createTextNode("\uB2E4\uC74C\uC0AC\uD56D\uC5D0 \uB3D9\uC758" + "\uD569\uB2C8\uB2E4: ")); dialog.appendChild(dialogTitle); // Create dialog main message paragraph and append to dialog var dialogMessage = document.createElement("p"); dialogMessage.appendChild(document.createTextNode("\uACC4\uC18D \uC9C4\uD589\uD558\uAE30" + "\uC704\uD574 \uC544\uB798 \uD56D\uBAA9" + "\uC5D0 \uB300\uD55C \uB3D9\uC758 \uC5EC" + "\uBD80\uB97C \uD655\uC778\uD558\uC2ED" + "\uC2DC\uC624.")); dialog.appendChild(dialogMessage); // Create optin checkbox and attach the doUpdateState function, which will // be used to track the checkbox state when a user checks or unchecks it var dialogCheckBox = document.createElement("input"); dialogCheckBox.className = "leftSpace"; dialogCheckBox.setAttribute("type", "checkbox"); dialogCheckBox.setAttribute("id", "privacy"); attachEventListener(dialogCheckBox, "click", function(e) { return doUpdateState("privacyState") }, false); // create hidden form field, which will store the current checkbox state var dialogCheckBoxState = document.createElement("input"); dialogCheckBoxState.setAttribute("type", "hidden"); dialogCheckBoxState.setAttribute("id", "privacyState"); dialogCheckBoxState.setAttribute("value", "false"); // Create anchor 1 which will link to the web site agreement. We also attach // the popup function to the anchor, which displays the link in a popup var dialogAnchor1 = document.createElement("a"); dialogAnchor1.setAttribute("href", "#"); dialogAnchor1.appendChild(document.createTextNode("\uAC1C\uC778\uC815\uBCF4\uBCF4\uD638" + "\uC815\uCC45 ")); attachEventListener(dialogAnchor1, "click", function(e) { return doPopUp("http://www.aa.com/intl/kr/footer/privacyPU.jsp", "500", "500", "y") }, false); // Create anchor 2 which will link to the privacy policy. We also attach // the popup function to the anchor, which displays the link in a popup var dialogAnchor2 = document.createElement("a"); dialogAnchor2.setAttribute("href", "#"); dialogAnchor2.appendChild(document.createTextNode("\uC0AC\uC774\uD2B8 \uC774\uC6A9\uC57D\uAD00 ")); attachEventListener(dialogAnchor2, "click", function(e) { return doPopUp("http://www.aa.com/intl/kr/footer/websiteAgreementPU.jsp", "500", "500", "y") }, false); // Create the acceptance message, incorporating the anchors and checkbox // we created above. Append this message to the parent dialog var dialogMessage2 = document.createElement("p"); dialogMessage2.appendChild(document.createTextNode("\uBCF8\uC778\uC740 \uC544\uBA54\uB9AC\uCE78" + "\uD56D\uACF5\uC758 ")); dialogMessage2.appendChild(dialogAnchor1); dialogMessage2.appendChild(document.createTextNode("\uC5D0 \uB300\uD574 \uBAA8\uB450" + "\uC77D\uC5C8\uC73C\uBA70 ")); dialogMessage2.appendChild(dialogAnchor2); //dialogMessage2.appendChild(document.createElement("br")); dialogMessage2.appendChild(document.createTextNode("\uC5D0 \uB3D9\uC758\uD569\uB2C8\uB2E4.")); dialogMessage2.appendChild(document.createTextNode(" *")); dialogMessage2.appendChild(dialogCheckBox); dialogMessage2.appendChild(dialogCheckBoxState); dialog.appendChild(dialogMessage2); // Create button container and continue and cancel buttons. Attach the // dialogClick function, which will handle the button click event // Append buttons to the button container and then the button container // to the dialog var dialogBtnContainer = document.createElement("p"); var dialogButton1 = document.createElement("input"); dialogButton1.className = "customDialogCold"; dialogButton1.setAttribute("type", "button"); dialogButton1.setAttribute("value", "\uCDE8\uC18C"); attachEventListener(dialogButton1, "click", dialogClick, false); var dialogButton2 = document.createElement("input"); dialogButton2.className = "customDialogHot"; dialogButton2.setAttribute("type", "button"); dialogButton2.setAttribute("value", "\uC608\uC57D\uD558\uAE30"); attachEventListener(dialogButton2, "click", dialogClick, false); dialogBtnContainer.appendChild(dialogButton2); dialogBtnContainer.appendChild(dialogButton1); dialog.appendChild(dialogBtnContainer); // Add the Iframe and dialog to the dom body body.appendChild(dialogIframe); body.appendChild(dialog); // Gets scrolling position used for dialog positioning var scrollingPosition = getScrollingPosition(); // Position the dialog and iframe at the relevent position dialog.style.left = scrollingPosition[0] + parseInt(viewportSize[0] / 2) - parseInt(dialog.offsetWidth / 2) + "px"; dialog.style.top = scrollingPosition[1] + parseInt(viewportSize[1] / 2) - parseInt(dialog.offsetHeight / 2) + "px"; dialog.style.visibility = "visible"; dialogIframe.style.left = scrollingPosition[0] + parseInt(viewportSize[0] / 2) - parseInt(dialogIframe.offsetWidth / 2) + "px"; dialogIframe.style.top = scrollingPosition[1] + parseInt(viewportSize[1] / 2) - parseInt(dialogIframe.offsetHeight / 2) + "px"; dialogIframe.style.visibility = "visible"; // Set focus to the continue button dialogButton2.focus(); } catch(error) { // Remove our dropsheet if an error occurs during DOM element creation dropSheet.parentNode.removeChild(dropSheet); return true; } return false; } /** * Function: dialogClick(event) * This function determines what action needs to be taken * depending on which element generated the event */ function dialogClick(event) { if (typeof event == "undefined") { event = window.event; } var target = getEventTarget(event); while (target.nodeName.toLowerCase() != "input") { target = target.parentNode; } var value = target.getAttribute("value"); var isChecked = document.getElementById('privacyState').value; // Gets checkbox state // If event occured on the cancel button close the dialog and remove dropsheet // If event occured on the continue button check if the check box has been checked // If checkbox is checked remove the opt in text and UI nodes, replace with processing // message and submit multi-city form. If checkbox is not checked alert user by // highlighting the opt in message and inhibit form submission if (value == "\uCDE8\uC18C") { var dialog = target; while (dialog.className != "customDialogKO") { dialog = dialog.parentNode; } closeDialog(dialog, 'dropSheet'); closeIframe(); } else if (isChecked == "true" && value == "\uC608\uC57D\uD558\uAE30") { var dialog = target; while (dialog.className != "customDialogKO") { dialog = dialog.parentNode; } removeChildNodes(dialog); attachProgressToElement(dialog, 'waitMsgKO', '\uC694\uCCAD\uC744\uCC98\uB9AC\uD558\uB294\uC911' + '\uC785\uB2C8\uB2E4. \uAE30\uB2E4\uB824 \uC8FC' + '\uC2ED\uC2DC\uC624...', '#6C6C6D'); setTimeout(function() { document.mcf.submit(); closeDialog(dialog, 'dropSheet');closeIframe(); dialog=null}, 1000); } else if (value == "\uC608\uC57D\uD558\uAE30") { var dialog = target; while (dialog.className != "customDialogKO") { dialog = dialog.parentNode; } dialog.style.color = "#cc0000"; } return true; }