[2] | 1 | <html> |
---|
| 2 | |
---|
| 3 | <head> |
---|
| 4 | <title>Insert/Modify Link</title> |
---|
| 5 | <script type="text/javascript" src="popup.js"></script> |
---|
| 6 | <script type="text/javascript"> |
---|
| 7 | window.resizeTo(400, 200); |
---|
| 8 | |
---|
| 9 | I18N = window.opener.HTMLArea.I18N.dialogs; |
---|
| 10 | |
---|
| 11 | function i18n(str) { |
---|
| 12 | return (I18N[str] || str); |
---|
| 13 | }; |
---|
| 14 | |
---|
| 15 | function onTargetChanged() { |
---|
| 16 | var f = document.getElementById("f_other_target"); |
---|
| 17 | if (this.value == "_other") { |
---|
| 18 | f.style.visibility = "visible"; |
---|
| 19 | f.select(); |
---|
| 20 | f.focus(); |
---|
| 21 | } else f.style.visibility = "hidden"; |
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | function Init() { |
---|
| 25 | __dlg_translate(I18N); |
---|
| 26 | __dlg_init(); |
---|
| 27 | var param = window.dialogArguments; |
---|
| 28 | var target_select = document.getElementById("f_target"); |
---|
| 29 | if (param) { |
---|
| 30 | document.getElementById("f_href").value = param["f_href"]; |
---|
| 31 | document.getElementById("f_title").value = param["f_title"]; |
---|
| 32 | comboSelectValue(target_select, param["f_target"]); |
---|
| 33 | if (target_select.value != param.f_target) { |
---|
| 34 | var opt = document.createElement("option"); |
---|
| 35 | opt.value = param.f_target; |
---|
| 36 | opt.innerHTML = opt.value; |
---|
| 37 | target_select.appendChild(opt); |
---|
| 38 | opt.selected = true; |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | var opt = document.createElement("option"); |
---|
| 42 | opt.value = "_other"; |
---|
| 43 | opt.innerHTML = i18n("Other"); |
---|
| 44 | target_select.appendChild(opt); |
---|
| 45 | target_select.onchange = onTargetChanged; |
---|
| 46 | document.getElementById("f_href").focus(); |
---|
| 47 | document.getElementById("f_href").select(); |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | function onOK() { |
---|
| 51 | var required = { |
---|
| 52 | // f_href shouldn't be required or otherwise removing the link by entering an empty |
---|
| 53 | // url isn't possible anymore. |
---|
| 54 | // "f_href": i18n("You must enter the URL where this link points to") |
---|
| 55 | }; |
---|
| 56 | for (var i in required) { |
---|
| 57 | var el = document.getElementById(i); |
---|
| 58 | if (!el.value) { |
---|
| 59 | alert(required[i]); |
---|
| 60 | el.focus(); |
---|
| 61 | return false; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | // pass data back to the calling window |
---|
| 65 | var fields = ["f_href", "f_title", "f_target" ]; |
---|
| 66 | var param = new Object(); |
---|
| 67 | for (var i in fields) { |
---|
| 68 | var id = fields[i]; |
---|
| 69 | var el = document.getElementById(id); |
---|
| 70 | param[id] = el.value; |
---|
| 71 | } |
---|
| 72 | if (param.f_target == "_other") |
---|
| 73 | param.f_target = document.getElementById("f_other_target").value; |
---|
| 74 | __dlg_close(param); |
---|
| 75 | return false; |
---|
| 76 | }; |
---|
| 77 | |
---|
| 78 | function onCancel() { |
---|
| 79 | __dlg_close(null); |
---|
| 80 | return false; |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | </script> |
---|
| 84 | |
---|
| 85 | <style type="text/css"> |
---|
| 86 | html, body { |
---|
| 87 | background: ButtonFace; |
---|
| 88 | color: ButtonText; |
---|
| 89 | font: 11px Tahoma,Verdana,sans-serif; |
---|
| 90 | margin: 0px; |
---|
| 91 | padding: 0px; |
---|
| 92 | } |
---|
| 93 | body { padding: 5px; } |
---|
| 94 | table { |
---|
| 95 | font: 11px Tahoma,Verdana,sans-serif; |
---|
| 96 | } |
---|
| 97 | select, input, button { font: 11px Tahoma,Verdana,sans-serif; } |
---|
| 98 | button { width: 70px; } |
---|
| 99 | table .label { text-align: right; width: 8em; } |
---|
| 100 | |
---|
| 101 | .title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; |
---|
| 102 | border-bottom: 1px solid black; letter-spacing: 2px; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #buttons { |
---|
| 106 | margin-top: 1em; border-top: 1px solid #999; |
---|
| 107 | padding: 2px; text-align: right; |
---|
| 108 | } |
---|
| 109 | </style> |
---|
| 110 | |
---|
| 111 | </head> |
---|
| 112 | |
---|
| 113 | <body onload="Init()"> |
---|
| 114 | <div class="title">Insert/Modify Link</div> |
---|
| 115 | |
---|
| 116 | <table border="0" style="width: 100%;"> |
---|
| 117 | <tr> |
---|
| 118 | <td class="label">URL:</td> |
---|
| 119 | <td><input type="text" id="f_href" style="width: 100%" /></td> |
---|
| 120 | </tr> |
---|
| 121 | <tr> |
---|
| 122 | <td class="label">Title (tooltip):</td> |
---|
| 123 | <td><input type="text" id="f_title" style="width: 100%" /></td> |
---|
| 124 | </tr> |
---|
| 125 | <tr> |
---|
| 126 | <td class="label">Target:</td> |
---|
| 127 | <td><select id="f_target"> |
---|
| 128 | <option value="">None (use implicit)</option> |
---|
| 129 | <option value="_blank">New window (_blank)</option> |
---|
| 130 | <option value="_self">Same frame (_self)</option> |
---|
| 131 | <option value="_top">Top frame (_top)</option> |
---|
| 132 | </select> |
---|
| 133 | <input type="text" name="f_other_target" id="f_other_target" size="10" style="visibility: hidden" /> |
---|
| 134 | </td> |
---|
| 135 | </tr> |
---|
| 136 | </table> |
---|
| 137 | |
---|
| 138 | <div id="buttons"> |
---|
| 139 | <button type="button" name="ok" onclick="return onOK();">OK</button> |
---|
| 140 | <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> |
---|
| 141 | </div> |
---|
| 142 | |
---|
| 143 | </body> |
---|
| 144 | </html> |
---|