mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-01 01:30:21 +01:00
Don't save blank docs
This commit is contained in:
parent
4a435a4be5
commit
fe68e42b90
1 changed files with 7 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
///// represents a single document
|
///// represents a single document
|
||||||
|
|
||||||
|
// TODO change name to haste
|
||||||
|
|
||||||
var heist_document = function() {
|
var heist_document = function() {
|
||||||
this.locked = false;
|
this.locked = false;
|
||||||
};
|
};
|
||||||
|
@ -130,11 +132,13 @@ heist.prototype.lockDocument = function() {
|
||||||
// Configure keyboard shortcuts for the textarea
|
// Configure keyboard shortcuts for the textarea
|
||||||
heist.prototype.configureShortcuts = function() {
|
heist.prototype.configureShortcuts = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.$textarea.keyup(function(evt) {
|
$('body').keyup(function(evt) {
|
||||||
// ^L or ^S for lock
|
// ^L or ^S for lock
|
||||||
if (evt.ctrlKey && (evt.keyCode === 76 || evt.keyCode === 83)) {
|
if (evt.ctrlKey && (evt.keyCode === 76 || evt.keyCode === 83)) {
|
||||||
evt.preventDefault();
|
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
|
||||||
_this.lockDocument();
|
evt.preventDefault();
|
||||||
|
_this.lockDocument();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ^N for new document
|
// ^N for new document
|
||||||
else if (evt.ctrlKey && evt.keyCode === 78) {
|
else if (evt.ctrlKey && evt.keyCode === 78) {
|
||||||
|
@ -149,9 +153,6 @@ heist.prototype.configureShortcuts = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO refuse to lock empty documents
|
|
||||||
|
|
||||||
///// Tab behavior in the textarea - 2 spaces per tab
|
///// Tab behavior in the textarea - 2 spaces per tab
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue