FEATURE: on iPad bluetooth keyboard use ALT-ENTER for post submit
Command and Control can not be properly detected via JavaScript so lean on Alt that can be detected.
This commit is contained in:
parent
0b86a99c39
commit
06abecdb41
|
@ -10,7 +10,7 @@ import {
|
||||||
setLocalTheme
|
setLocalTheme
|
||||||
} from "discourse/lib/theme-selector";
|
} from "discourse/lib/theme-selector";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { safariHacksDisabled } from "discourse/lib/utilities";
|
import { safariHacksDisabled, isiPad } from "discourse/lib/utilities";
|
||||||
|
|
||||||
const USER_HOMES = {
|
const USER_HOMES = {
|
||||||
1: "latest",
|
1: "latest",
|
||||||
|
@ -49,10 +49,7 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
|
|
||||||
@computed()
|
@computed()
|
||||||
isiPad() {
|
isiPad() {
|
||||||
return (
|
return isiPad();
|
||||||
navigator.userAgent.match(/iPad/g) &&
|
|
||||||
!navigator.userAgent.match(/Trident/g)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed()
|
@computed()
|
||||||
|
|
|
@ -550,6 +550,17 @@ export function isAppleDevice() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let iPadDetected = undefined;
|
||||||
|
|
||||||
|
export function isiPad() {
|
||||||
|
if (iPadDetected === undefined) {
|
||||||
|
iPadDetected =
|
||||||
|
navigator.userAgent.match(/iPad/g) &&
|
||||||
|
!navigator.userAgent.match(/Trident/g);
|
||||||
|
}
|
||||||
|
return iPadDetected;
|
||||||
|
}
|
||||||
|
|
||||||
export function safariHacksDisabled() {
|
export function safariHacksDisabled() {
|
||||||
let pref = localStorage.getItem("safari-hacks-disabled");
|
let pref = localStorage.getItem("safari-hacks-disabled");
|
||||||
let result = false;
|
let result = false;
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
|
import { isiPad } from "discourse/lib/utilities";
|
||||||
|
|
||||||
// A mixin where hitting ESC calls `cancelled` and ctrl+enter calls `save.
|
// A mixin where hitting ESC calls `cancelled` and ctrl+enter calls `save.
|
||||||
export default {
|
export default {
|
||||||
keyDown(e) {
|
keyDown(e) {
|
||||||
if (e.which === 27) {
|
if (e.which === 27) {
|
||||||
this.cancelled();
|
this.cancelled();
|
||||||
return false;
|
return false;
|
||||||
} else if (e.which === 13 && (e.ctrlKey || e.metaKey)) {
|
} else if (
|
||||||
|
e.which === 13 &&
|
||||||
|
(e.ctrlKey || e.metaKey || (isiPad() && e.altKey))
|
||||||
|
) {
|
||||||
// CTRL+ENTER or CMD+ENTER
|
// CTRL+ENTER or CMD+ENTER
|
||||||
|
//
|
||||||
|
// iPad physical keyboard does not offer Command or Control detection
|
||||||
|
// so use ALT-ENTER
|
||||||
this.save();
|
this.save();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue