| 16 | | // Víceřádkový výběr |
| 17 | | if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) { |
| 18 | | var pre = t.value.slice(0,ss); |
| 19 | | var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab); |
| 20 | | var post = t.value.slice(se,t.value.length); |
| 21 | | t.value = pre.concat(tab).concat(sel).concat(post); |
| 22 | | t.selectionStart = ss + tab.length; |
| 23 | | t.selectionEnd = se + tab.length; |
| 24 | | } |
| | 16 | // Víceřádkový výběr |
| | 17 | if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) { |
| | 18 | var pre = t.value.slice(0,ss); |
| | 19 | var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab); |
| | 20 | var post = t.value.slice(se,t.value.length); |
| | 21 | t.value = pre.concat(tab).concat(sel).concat(post); |
| | 22 | t.selectionStart = ss + tab.length; |
| | 23 | t.selectionEnd = se + tab.length; |
| | 24 | } |
| 26 | | // Jednořádkový nebo žádný výběr |
| 27 | | else { |
| 28 | | t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length)); |
| 29 | | if (ss == se) { |
| 30 | | t.selectionStart = t.selectionEnd = ss + tab.length; |
| 31 | | } |
| 32 | | else { |
| 33 | | t.selectionStart = ss + tab.length; |
| 34 | | t.selectionEnd = se + tab.length; |
| 35 | | } |
| 36 | | } |
| 37 | | } |
| | 26 | // Jednořádkový nebo žádný výběr |
| | 27 | else { |
| | 28 | t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length)); |
| | 29 | if (ss == se) { |
| | 30 | t.selectionStart = t.selectionEnd = ss + tab.length; |
| | 31 | } |
| | 32 | else { |
| | 33 | t.selectionStart = ss + tab.length; |
| | 34 | t.selectionEnd = se + tab.length; |
| | 35 | } |
| | 36 | } |
| | 37 | } |
| 39 | | // Backspace |
| 40 | | else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) { |
| 41 | | evt.preventDefault(); |
| 42 | | t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length)); |
| 43 | | t.selectionStart = t.selectionEnd = ss - tab.length; |
| 44 | | } |
| | 39 | // Backspace |
| | 40 | else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) { |
| | 41 | evt.preventDefault(); |
| | 42 | t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length)); |
| | 43 | t.selectionStart = t.selectionEnd = ss - tab.length; |
| | 44 | } |
| 46 | | // Delete |
| 47 | | else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) { |
| 48 | | evt.preventDefault(); |
| 49 | | t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length)); |
| 50 | | t.selectionStart = t.selectionEnd = ss; |
| 51 | | } |
| | 46 | // Delete |
| | 47 | else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) { |
| | 48 | evt.preventDefault(); |
| | 49 | t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length)); |
| | 50 | t.selectionStart = t.selectionEnd = ss; |
| | 51 | } |