mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
26 lines
681 B
JavaScript
26 lines
681 B
JavaScript
'use strict';
|
|
|
|
(function(){
|
|
|
|
angular
|
|
.module('habitrpg')
|
|
.directive('submitOnMetaEnter', submitOnMetaEnter);
|
|
|
|
function submitOnMetaEnter() {
|
|
return {
|
|
restrict: 'A',
|
|
link: function($scope, element, attrs) {
|
|
element.on('keydown', function(event) {
|
|
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
|
// Note that we use the normal browser way to invoke the submit
|
|
// event, because jquery's triggerHandler executes events in a
|
|
// strange order!
|
|
var event = new Event('submit');
|
|
element[0].form.dispatchEvent(event);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}());
|