webui-aria2/js/directives/textarea.js
kuoruan f6793e5fb3 Fix "Cannot read property 'replace' of undefined"
Signed-off-by: kuoruan <kuoruan@gmail.com>
2017-05-05 10:26:46 +08:00

23 lines
557 B
JavaScript

webui.directive("textarea", function() {
return {
restrict: "E",
link: function(scope, element) {
element.attr(
"placeholder",
function(index, placeholder) {
if (placeholder !== undefined) {
return placeholder.replace(/\\n/g, "\n");
} else {
return placeholder;
}
}
).bind("keydown keypress", function(event) {
if (event.ctrlKey && event.which === 13) {
event.preventDefault();
scope.$close();
}
});
}
};
});