|
63 | 63 | RESIZEEND = "resizeEnd", |
64 | 64 | DRAGSTART = "dragstart", |
65 | 65 | DRAGEND = "dragend", |
| 66 | + KENDOKEYDOWN = "kendoKeydown", |
66 | 67 | ERROR = "error", |
67 | 68 | OVERFLOW = "overflow", |
68 | 69 | DATADOCOVERFLOWRULE = "original-overflow-rule", |
|
220 | 221 | } |
221 | 222 |
|
222 | 223 | windowContent = wrapper.children(KWINDOWCONTENT); |
223 | | - that._tabindex(windowContent); |
224 | 224 |
|
225 | 225 | if (options.visible && options.modal) { |
226 | 226 | that._overlay(wrapper.is(VISIBLE)).css({ opacity: 0.5 }); |
|
230 | 230 | .on("mouseenter" + NS, TITLEBAR_BUTTONS, proxy(that._buttonEnter, that)) |
231 | 231 | .on("mouseleave" + NS, TITLEBAR_BUTTONS, proxy(that._buttonLeave, that)) |
232 | 232 | .on("click" + NS, "> " + TITLEBAR_BUTTONS, proxy(that._windowActionHandler, that)) |
233 | | - .on("keydown" + NS, proxy(that._keydown, that)) |
| 233 | + .on("keydown" + NS, that, proxy(that._keydown, that)) |
234 | 234 | .on("focus" + NS, proxy(that._focus, that)) |
235 | 235 | .on("blur" + NS, proxy(that._blur, that)); |
236 | 236 |
|
237 | 237 | windowContent |
238 | | - .on("keydown" + NS, proxy(that._keydown, that)) |
239 | | - .on("focus" + NS, proxy(that._focus, that)) |
240 | | - .on("blur" + NS, proxy(that._blur, that)); |
| 238 | + .on("keydown" + NS, that, proxy(that._keydownContent, that)); |
241 | 239 |
|
242 | 240 | windowFrame = windowContent.find("." + KCONTENTFRAME)[0]; |
243 | 241 |
|
|
304 | 302 | this._tabKeyTrap = new TabKeyTrap(wrapper); |
305 | 303 | this._tabKeyTrap.trap(); |
306 | 304 | this._tabKeyTrap.shouldTrap = function () { |
307 | | - return windowContent.data("isFront"); |
| 305 | + return wrapper.data("isFront"); |
308 | 306 | }; |
309 | 307 | } |
310 | 308 | }, |
|
553 | 551 | RESIZEEND, |
554 | 552 | DRAGSTART, |
555 | 553 | DRAGEND, |
| 554 | + KENDOKEYDOWN, |
556 | 555 | ERROR |
557 | 556 | ], |
558 | 557 |
|
|
596 | 595 | return $.inArray("close", $.map(this.options.actions, function(x) { return x.toLowerCase(); })) > -1; |
597 | 596 | }, |
598 | 597 |
|
| 598 | + _keydownContent: function(e) { |
| 599 | + var that = this, |
| 600 | + keys = kendo.keys, |
| 601 | + keyCode = e.keyCode; |
| 602 | + |
| 603 | + if (keyCode == keys.ESC && that._closable()) { |
| 604 | + e.stopPropagation(); |
| 605 | + that._close(false); |
| 606 | + } |
| 607 | + }, |
| 608 | + |
599 | 609 | _keydown: function(e) { |
600 | 610 | var that = this, |
601 | 611 | options = that.options, |
|
635 | 645 | if(e.altKey && keyCode == keys.UP){ |
636 | 646 | if (isMinimized) { |
637 | 647 | that.restore(); |
638 | | - that.element.focus(); |
| 648 | + that.wrapper.focus(); |
639 | 649 | } else if (!isMaximized) { |
640 | 650 | that.maximize(); |
641 | | - that.element.focus(); |
| 651 | + that.wrapper.focus(); |
642 | 652 | } |
| 653 | + |
643 | 654 | } else if (e.altKey && keyCode == keys.DOWN){ |
644 | 655 | if (!isMinimized && !isMaximized) { |
645 | 656 | that.minimize(); |
646 | 657 | that.wrapper.focus(); |
647 | 658 | } else if (isMaximized) { |
648 | 659 | that.restore(); |
649 | | - that.element.focus(); |
650 | 660 | } |
| 661 | + |
651 | 662 | } |
652 | 663 |
|
653 | 664 | offset = kendo.getOffset(wrapper); |
|
950 | 961 | that.toFront(); |
951 | 962 |
|
952 | 963 | if (options.autoFocus) { |
953 | | - that.element.focus(); |
| 964 | + that.wrapper.focus(); |
954 | 965 | } |
955 | 966 |
|
956 | 967 | options.visible = true; |
|
973 | 984 | overlay.show(); |
974 | 985 |
|
975 | 986 | $(window).on("focus" + MODAL_NS, function() { |
976 | | - if (contentElement.data("isFront") && !$(document.activeElement).closest(contentElement).length) { |
977 | | - that.element.focus(); |
| 987 | + if (wrapper.data("isFront") && !$(document.activeElement).closest(wrapper).length) { |
| 988 | + that.wrapper.focus(); |
978 | 989 | } |
979 | 990 | }); |
980 | 991 | } |
|
1009 | 1020 | var scrollable = this.options.scrollable !== false; |
1010 | 1021 |
|
1011 | 1022 | if (this.options.autoFocus) { |
1012 | | - this.element.focus(); |
| 1023 | + this.wrapper.focus(); |
1013 | 1024 | } |
1014 | 1025 |
|
1015 | 1026 | this.element.css(OVERFLOW, scrollable ? "" : "hidden"); |
|
1123 | 1134 |
|
1124 | 1135 | _shouldFocus: function(target) { |
1125 | 1136 | var active = activeElement(), |
1126 | | - element = this.element; |
| 1137 | + element = this.wrapper; |
1127 | 1138 |
|
1128 | 1139 | return this.options.autoFocus && |
1129 | 1140 | !$(active).is(element) && |
|
1149 | 1160 | zIndex = Math.max(+zIndexNew, zIndex); |
1150 | 1161 | } |
1151 | 1162 |
|
1152 | | - contentElement.data("isFront", element == currentWindow); |
| 1163 | + wrapper.data("isFront", element == currentWindow); |
1153 | 1164 | // Add overlay to windows with iframes and lower z-index to prevent |
1154 | 1165 | // trapping of events when resizing / dragging |
1155 | 1166 | if (element != currentWindow && contentElement.find("> ." + KCONTENTFRAME).length > 0) { |
|
1163 | 1174 | that.element.find("> .k-overlay").remove(); |
1164 | 1175 |
|
1165 | 1176 | if (that._shouldFocus(target)) { |
1166 | | - if (that.isMinimized()) { |
| 1177 | + setTimeout(function(){ |
1167 | 1178 | that.wrapper.focus(); |
1168 | | - } else if ($(target).is(KOVERLAY)) { |
1169 | | - setTimeout(function(){ |
1170 | | - that.element.focus(); |
1171 | | - }); |
1172 | | - } else { |
1173 | | - that.element.focus(); |
1174 | | - } |
| 1179 | + }); |
1175 | 1180 |
|
1176 | 1181 | var scrollTop = containmentContext ? that.containment.scrollTop() : $(window).scrollTop(), |
1177 | 1182 | windowTop = parseInt(wrapper.position().top, 10); |
|
1265 | 1270 |
|
1266 | 1271 | options.isMaximized = options.isMinimized = false; |
1267 | 1272 |
|
1268 | | - that.wrapper.removeAttr("tabindex"); |
1269 | 1273 | that.wrapper.removeAttr("aria-labelled-by"); |
1270 | 1274 |
|
1271 | 1275 | that.resize(); |
|
1423 | 1427 | that.options.isMinimized = true; |
1424 | 1428 | }); |
1425 | 1429 |
|
1426 | | - this.wrapper.attr("tabindex", 0); |
1427 | 1430 | this.wrapper.attr("aria-labelled-by", this.element.attr("aria-labelled-by")); |
1428 | 1431 |
|
1429 | 1432 | this._updateBoundaries(); |
|
1715 | 1718 | // Make sure the wrapper is appended to the body only once. IE9+ will throw exceptions if you move iframes in DOM |
1716 | 1719 | wrapper |
1717 | 1720 | .toggleClass("k-rtl", isRtl) |
| 1721 | + .attr("tabindex", 0) |
1718 | 1722 | .append(contentHtml) |
1719 | 1723 | .find("iframe:not(.k-content-frame)").each(function(index) { |
1720 | 1724 | // Restore the src attribute of the iframes when they are part of the live DOM tree |
|
0 commit comments