Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 1 | /** |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 2 | * Hint menu for Kalamar. |
Nils Diewald | 47f366b | 2015-04-15 20:06:35 +0000 | [diff] [blame] | 3 | * Based on menu object. |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 4 | * |
| 5 | * @author Nils Diewald |
| 6 | */ |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 7 | /* |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 8 | * TODO: Check for cnx/syn= |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 9 | * TODO: List can be shown when prefix is like 'base/s=pcorenlp/' |
| 10 | * TODO: Sometimes the drop-down box down vanish when list is shown |
| 11 | * TODO: Create should expect an input text field |
| 12 | * TODO: Embed only one single menu (not multiple) |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 13 | * By holding the current menu in _active |
| 14 | * TODO: show() should accept a context field (especially for no-context fields, |
| 15 | * like fragments) |
| 16 | * TODO: Improve context analyzer from hint! |
| 17 | * TODO: Marked annotations should be addable to "fragments" |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 18 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 19 | define([ |
| 20 | 'hint/input', |
| 21 | 'hint/menu', |
| 22 | 'hint/contextanalyzer', |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 23 | 'hint/alert', |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 24 | 'util' |
| 25 | ], function (inputClass, |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 26 | menuClass, |
| 27 | analyzerClass, |
| 28 | alertClass) { |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 29 | "use strict"; |
| 30 | |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 31 | /** |
| 32 | * @define {regex} Regular expression for context |
| 33 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 34 | KorAP.context = KorAP.context || |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 35 | "(?:^|[^-_a-zA-Z0-9])" + // Anchor |
| 36 | "((?:[-_a-zA-Z0-9]+?)\/" + // Foundry |
| 37 | "(?:" + |
| 38 | "(?:[-_a-zA-Z0-9]+?)=" + // Layer |
Akron | 113cc1a | 2016-01-22 21:17:57 +0100 | [diff] [blame] | 39 | "(?:"+ |
| 40 | "(?:[^:=\/ ]+?):|" + // Key |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 41 | "(?:[^-=\/ ]+?)-" + // Node |
Akron | 113cc1a | 2016-01-22 21:17:57 +0100 | [diff] [blame] | 42 | ")?" + |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 43 | ")?" + |
| 44 | ")$"; |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 45 | // KorAP.annotationHelper = KorAP.annotationHelper || { "-" : [] }; |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 46 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 47 | /** |
| 48 | * Return keycode based on event |
| 49 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 50 | |
| 51 | // Initialize hint array |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * KorAP.Hint.create({ |
| 55 | * inputField : node, |
| 56 | * context : context regex |
| 57 | * }); |
| 58 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 59 | return { |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 60 | |
| 61 | // Some variables |
| 62 | // _firstTry : true, |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 63 | // active : false, |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 64 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 65 | /** |
| 66 | * Create new hint helper. |
| 67 | */ |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 68 | create : function (param) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 69 | return Object.create(this)._init(param); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 70 | }, |
| 71 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 72 | // Initialize hint helper |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 73 | _init : function (param) { |
| 74 | param = param || {}; |
| 75 | |
| 76 | // Holds all menus per prefix context |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 77 | this._menu = {}; |
| 78 | this._alert = alertClass.create(); |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 79 | this._active = null; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 80 | |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 81 | // No annotation helper available |
| 82 | if (!KorAP.annotationHelper) { |
| 83 | console.log("No annotationhelper defined"); |
| 84 | return; |
| 85 | }; |
| 86 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 87 | // Get input field |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 88 | var qfield = param["inputField"] || document.getElementById("q-field"); |
| 89 | if (!qfield) |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 90 | return null; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 91 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 92 | // Create input field |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 93 | this._inputField = inputClass.create(qfield); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 94 | |
| 95 | var inputFieldElement = this._inputField.element(); |
| 96 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 97 | var c = this._inputField.container(); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 98 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 99 | // create alert |
| 100 | c.appendChild(this._alert.element()); |
| 101 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 102 | var that = this; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 103 | |
Nils Diewald | 47f366b | 2015-04-15 20:06:35 +0000 | [diff] [blame] | 104 | this._inputField.container().addEventListener('click', function (e) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 105 | if (!this.classList.contains('active')) { |
| 106 | that.show(false); |
| 107 | }; |
Nils Diewald | 47f366b | 2015-04-15 20:06:35 +0000 | [diff] [blame] | 108 | }); |
| 109 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 110 | var _down = function (e) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 111 | var code = _codeFromEvent(e); |
| 112 | if (code === 40) { |
| 113 | this.show(false); |
| 114 | e.halt(); |
| 115 | }; |
Nils Diewald | 47f366b | 2015-04-15 20:06:35 +0000 | [diff] [blame] | 116 | }; |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 117 | |
Nils Diewald | 47f366b | 2015-04-15 20:06:35 +0000 | [diff] [blame] | 118 | // Move infobox |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 119 | inputFieldElement.addEventListener("keyup", this.update.bind(this)); |
| 120 | inputFieldElement.addEventListener("click", this.update.bind(this)); |
| 121 | |
| 122 | // Add event listener for key pressed down |
| 123 | inputFieldElement.addEventListener( |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 124 | "keydown", _down.bind(this), false |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 125 | ); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 126 | |
| 127 | // Set Analyzer for context |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 128 | this._analyzer = analyzerClass.create( |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 129 | param["context"] || KorAP.context |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 130 | ); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 131 | return this; |
| 132 | }, |
| 133 | |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Return the input field attached to the hint helper. |
| 137 | */ |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 138 | inputField : function () { |
| 139 | return this._inputField; |
| 140 | }, |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 141 | |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 142 | |
| 143 | /** |
| 144 | * Altert at a specific character position. |
| 145 | */ |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 146 | alert : function (charPos, msg) { |
| 147 | |
| 148 | if (arguments.length === 0) |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 149 | return this._alert; |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 150 | |
| 151 | // Do not alert if already alerted! |
| 152 | if (this._alert.active) |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 153 | return false; |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 154 | |
| 155 | // Move to the correct position |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 156 | this._inputField.moveto(charPos); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 157 | |
| 158 | // Set container to active (aka hide the hint helper button) |
| 159 | |
| 160 | this._alert.show(msg); |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 161 | this.active(this._alert); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 162 | return true; |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 163 | }, |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 164 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 165 | _unshowAlert : function () { |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 166 | this._alert.hide(); |
| 167 | this.active(null); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 168 | }, |
| 169 | |
| 170 | update : function () { |
| 171 | this._inputField.update(); |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 172 | if (this._alert.hide()) |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 173 | this.active(null); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 174 | }, |
| 175 | |
| 176 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 177 | /** |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 178 | * Return hint menu and probably init based on an action |
| 179 | */ |
| 180 | menu : function (action) { |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 181 | if (this._menu[action] === undefined) { |
| 182 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 183 | // No matching hint menu |
Akron | e91da78 | 2017-12-15 17:17:50 +0100 | [diff] [blame] | 184 | if (KorAP.annotationHelper[action] === undefined) |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 185 | return; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 186 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 187 | // Create matching hint menu |
| 188 | this._menu[action] = menuClass.create( |
Akron | e91da78 | 2017-12-15 17:17:50 +0100 | [diff] [blame] | 189 | this, action, KorAP.annotationHelper[action] |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 190 | ); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | // Return matching hint menu |
| 194 | return this._menu[action]; |
| 195 | }, |
| 196 | |
| 197 | /** |
| 198 | * Get the correct menu based on the context |
| 199 | */ |
| 200 | contextMenu : function (ifContext) { |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 201 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 202 | // Get context (aka left text) |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 203 | var context = this._inputField.context(); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 204 | |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 205 | if (context === undefined || context.length === 0) { |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 206 | return ifContext ? undefined : this.menu("-"); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 207 | }; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 208 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 209 | // Get context (aka left text matching regex) |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 210 | context = this._analyzer.test(context); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 211 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 212 | if (context === undefined || context.length == 0) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 213 | return ifContext ? undefined : this.menu("-"); |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 214 | }; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 215 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 216 | return this.menu(context) || (ifContext ? undefined : this.menu('-')); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 217 | }, |
| 218 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 219 | /** |
| 220 | * Activate a certain menu. |
| 221 | * If a menu is passed, the menu will be activated. |
| 222 | * If null is passed, the active menu will be deactivated. |
| 223 | * If nothing is passed, returns the active menu. |
| 224 | */ |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 225 | active : function (obj) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 226 | |
| 227 | // A menu or null was passed |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 228 | if (arguments.length === 1) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 229 | var c = this._inputField.container(); |
| 230 | |
| 231 | // Make the menu active |
| 232 | if (obj !== null) { |
| 233 | c.classList.add('active'); |
| 234 | this._active = obj; |
| 235 | } |
| 236 | |
| 237 | // Make the menu inactive |
| 238 | else { |
| 239 | c.classList.remove('active'); |
| 240 | this._active = null; |
| 241 | } |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 242 | }; |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 243 | |
| 244 | // Return |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 245 | return this._active; |
| 246 | }, |
| 247 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 248 | |
| 249 | /** |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 250 | * Show the menu. |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 251 | * Remove all old menus. |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 252 | * |
| 253 | * @param {boolean} Boolean value to indicate if context |
| 254 | * is necessary (true) or if the main context should |
| 255 | * be shown if context fails. |
| 256 | * |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 257 | */ |
| 258 | show : function (ifContext) { |
| 259 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 260 | // Remove the active object |
| 261 | this._unshow(); |
Akron | e39cc86 | 2018-04-25 15:16:11 +0200 | [diff] [blame] | 262 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 263 | // Get the menu |
| 264 | var menu; |
| 265 | if (menu = this.contextMenu(ifContext)) { |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 266 | this.active(menu); |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 267 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 268 | var c = this._inputField.container(); |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 269 | c.appendChild(menu.element()); |
| 270 | menu.show(); |
| 271 | menu.focus(); |
| 272 | // Focus on input field |
| 273 | // this.inputField.element.focus(); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 274 | } |
| 275 | else { |
| 276 | this._inputField.element().focus(); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 277 | }; |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 278 | }, |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 279 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 280 | // This will get the context of the field |
| 281 | getContext : function () {}, |
| 282 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 283 | /** |
| 284 | * Deactivate the current menu and focus on the input field. |
| 285 | */ |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 286 | unshow_old : function () { |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 287 | this.active(null); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 288 | this.inputField().element().focus(); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 289 | }, |
| 290 | |
| 291 | /** |
| 292 | * Deactivate the current menu and focus on the input field. |
| 293 | */ |
| 294 | unshow : function () { |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 295 | this._unshow(); |
| 296 | this._inputField.element().focus(); |
| 297 | }, |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 298 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 299 | |
| 300 | _unshow : function () { |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 301 | if (this.active() !== null) { |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 302 | // var act = this.active(); |
Akron | e39cc86 | 2018-04-25 15:16:11 +0200 | [diff] [blame] | 303 | |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 304 | // This does not work for alert currently! |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 305 | //if (act._type !== 'alert') { |
| 306 | if (!this._alert.active) { |
| 307 | var c = this._inputField.container(); |
Akron | e39cc86 | 2018-04-25 15:16:11 +0200 | [diff] [blame] | 308 | c.removeChild(this._active.element()); |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 309 | } |
| 310 | else { |
| 311 | this._unshowAlert(); |
| 312 | }; |
| 313 | |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 314 | // this._active.hide(); |
| 315 | this.active(null); |
| 316 | }; |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 317 | } |
| 318 | }; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 319 | }); |