Enkodowanie nazw plików do UTF-8 przed przekazaniem ich do localrepo.commit. Powinno...
[redakcja.git] / project / static / js / jquery.fieldselection.js
1 (function() { 
2     jQuery.fn.getSelection = function() {
3         var e = (this.jquery) ? this[0] : this;
4
5         return (
6             // Mozilla / dom 3.0
7             ('selectionStart' in e && function() {
8                 var l = e.selectionEnd - e.selectionStart;
9                 return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) };
10             }) ||
11             
12             // Internet Explorer
13             (document.selection && function() {
14                 e.focus();
15                 
16                 var r = document.selection.createRange();
17                 if (r === null) {
18                     return { start: 0, end: e.value.length, length: 0 }
19                 }
20                 
21                 var re = e.createTextRange();
22                 var rc = re.duplicate();
23                 re.moveToBookmark(r.getBookmark());
24                 rc.setEndPoint('EndToStart', re);
25                 
26                 return { start: rc.text.length, end: rc.text.length + r.text.length, length: r.text.length, text: r.text };
27             }) ||
28             
29             // browser not supported
30             function() { return null; }
31         )();
32     },
33         
34     jQuery.fn.replaceSelection = function() {
35         var e = this.jquery ? this[0] : this;
36         var text = arguments[0] || '';
37         var scrollTop = $(this).scrollTop();
38                 
39         return (
40             // Mozilla / dom 3.0
41             ('selectionStart' in e && function() {
42                 var selectionStart = e.selectionStart;
43                 console.log(e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length));
44                 e.value = e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length);
45                 $(e).scrollTop(scrollTop).focus();
46                 e.selectionStart = selectionStart + text.length;
47                 e.selectionEnd = selectionStart + text.length;
48                 return this;
49             }) ||
50
51             // Internet Explorer
52             (document.selection && function() {
53                 e.focus();
54                 document.selection.createRange().text = text;
55                 return this;
56             }) ||
57
58             // browser not supported
59             function() {
60                 e.value += text;
61                 return jQuery(e);
62             }
63         )();
64     }
65 })();