| 147 | //runModal("running modal...", completme, "Field-modal") |
| 148 | |
| 149 | function runModalAtCursor(placeholder, completeme, initialText) { |
| 150 | var m = runModal(placeholder, completeme, "Field-modal-positioned", initialText); |
| 151 | var cc = cm.cursorCoords(); |
| 152 | var h = $(m).height(); |
| 153 | if (cc.bottom > $(".CodeMirror").height() / 2) |
| 154 | $(m).css("top", Math.max(100, cc.bottom - h)); |
| 155 | else { |
| 156 | $(m).css("top", cc.bottom) |
| 157 | } |
| 158 | |
| 159 | var p = $(m).position(); |
| 160 | if (p.top + h > $(".CodeMirror").height() - 40) { |
| 161 | h = $(".CodeMirror").height() - p.top - 100; |
| 162 | $($(m).children()[1]).height(h) |
| 163 | } |
| 164 | $(m).css("left", Math.min($(".CodeMirror").width() - 500, cc.right)); |
| 165 | } |
| 166 | |
| 167 | //runModalAtCursor("banana", completme) |