diff options
| author | czaks <marcin@6irc.net> | 2013-09-17 10:43:44 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-09-17 10:43:44 -0400 |
| commit | 6cb7eb939e549f978ca6dd7d2afe2dabc0f18025 (patch) | |
| tree | 8b2342bbf5c15847717db733ecf4f2f46718dacb /templates/main.js | |
| parent | 069f1def9bf8c8d769afdc5740e9ff13271065bd (diff) | |
| parent | 803f0c8ce1487ea791824197de9d1ee140127838 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into vichan-devel-4.5
Conflicts:
inc/config.php
inc/display.php
inc/mod/pages.php
install.php
js/quick-reply.js
post.php
templates/index.html
Diffstat (limited to 'templates/main.js')
| -rw-r--r-- | templates/main.js | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/templates/main.js b/templates/main.js index 7e8793cb..6136b11f 100644 --- a/templates/main.js +++ b/templates/main.js @@ -67,6 +67,9 @@ function changeStyle(styleName, link) { if (link) { link.className = 'selected'; } + + if (typeof $ != 'undefined') + $(window).trigger('stylesheet', styleName); } @@ -181,22 +184,28 @@ function dopost(form) { return form.elements['body'].value != "" || form.elements['file'].value != "" || (form.elements.file_url && form.elements['file_url'].value != ""); } -function citeReply(id) { - var body = document.getElementById('body'); +function citeReply(id, with_link) { + var textarea = document.getElementById('body'); if (document.selection) { // IE - body.focus(); + textarea.focus(); var sel = document.selection.createRange(); sel.text = '>>' + id + '\n'; - } else if (body.selectionStart || body.selectionStart == '0') { - // Mozilla - var start = body.selectionStart; - var end = body.selectionEnd; - body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length); + } else if (textarea.selectionStart || textarea.selectionStart == '0') { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length); + + textarea.selectionStart += ('>>' + id).length + 1; + textarea.selectionEnd = textarea.selectionStart; } else { // ??? - body.value += '>>' + id + '\n'; + textarea.value += '>>' + id + '\n'; + } + if (typeof $ != 'undefined') { + $(window).trigger('cite', [id, with_link]); + $(textarea).change(); } } @@ -214,7 +223,7 @@ function rememberStuff() { document.forms.post.elements['email'].value = localStorage.email; if (window.location.hash.indexOf('q') == 1) - citeReply(window.location.hash.substring(2)); + citeReply(window.location.hash.substring(2), true); if (sessionStorage.body) { var saved = JSON.parse(sessionStorage.body); |
