mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-22 04:13:09 -07:00
Merge 9fc659be67
into 3178676fba
This commit is contained in:
commit
381102da1e
2 changed files with 32 additions and 30 deletions
|
@ -275,7 +275,7 @@ haste.prototype.configureButtons = function() {
|
|||
$where: $('#box2 .new'),
|
||||
label: 'New',
|
||||
shortcut: function(evt) {
|
||||
return evt.ctrlKey && evt.keyCode === 78
|
||||
return evt.ctrlKey && evt.keyCode === 78;
|
||||
},
|
||||
shortcutDescription: 'control + n',
|
||||
action: function() {
|
||||
|
@ -361,35 +361,37 @@ haste.prototype.configureShortcuts = function() {
|
|||
|
||||
///// Tab behavior in the textarea - 2 spaces per tab
|
||||
$(function() {
|
||||
|
||||
$('textarea').keydown(function(evt) {
|
||||
if (evt.keyCode === 9) {
|
||||
evt.preventDefault();
|
||||
var myValue = ' ';
|
||||
// http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery
|
||||
// For browsers like Internet Explorer
|
||||
if (document.selection) {
|
||||
this.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
this.focus();
|
||||
}
|
||||
// Mozilla and Webkit
|
||||
else if (this.selectionStart || this.selectionStart == '0') {
|
||||
var startPos = this.selectionStart;
|
||||
var endPos = this.selectionEnd;
|
||||
var scrollTop = this.scrollTop;
|
||||
this.value = this.value.substring(0, startPos) + myValue +
|
||||
this.value.substring(endPos,this.value.length);
|
||||
this.focus();
|
||||
this.selectionStart = startPos + myValue.length;
|
||||
this.selectionEnd = startPos + myValue.length;
|
||||
this.scrollTop = scrollTop;
|
||||
}
|
||||
else {
|
||||
this.value += myValue;
|
||||
this.focus();
|
||||
}
|
||||
var sel, startPos, endPos, scrollTop,
|
||||
myValue = ' ';
|
||||
if (evt.ctrlKey || evt.keyCode !== 9) {
|
||||
return true;
|
||||
}
|
||||
|
||||
evt.preventDefault();
|
||||
// http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery
|
||||
// For browsers like Internet Explorer
|
||||
if (document.selection) {
|
||||
this.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
this.focus();
|
||||
}
|
||||
// Mozilla and Webkit
|
||||
else if (this.selectionStart || this.selectionStart == '0') {
|
||||
startPos = this.selectionStart;
|
||||
endPos = this.selectionEnd;
|
||||
scrollTop = this.scrollTop;
|
||||
this.value = this.value.substring(0, startPos) + myValue +
|
||||
this.value.substring(endPos,this.value.length);
|
||||
this.focus();
|
||||
this.selectionStart = startPos + myValue.length;
|
||||
this.selectionEnd = startPos + myValue.length;
|
||||
this.scrollTop = scrollTop;
|
||||
}
|
||||
else {
|
||||
this.value += myValue;
|
||||
this.focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue