X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c446cd5aed63e0ea7ee52c05bf3d0ca8951969b2..421fbd31647ecb40540f767b1d506e0843dfc3a9:/redakcja/static/js/wiki/view_editor_wysiwyg.js diff --git a/redakcja/static/js/wiki/view_editor_wysiwyg.js b/redakcja/static/js/wiki/view_editor_wysiwyg.js index 2beb4d4a..d5fa29dd 100644 --- a/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -305,7 +305,7 @@ } // start edition on this node - var $overlay = $('
').css({ + var $overlay = $('
').css({ position: 'absolute', height: h, left: x, @@ -315,6 +315,7 @@ if ($origin.is('.motyw')) { + $('.akap-edit-button').remove(); withThemes(function(canonThemes){ $('textarea', $overlay).autocomplete(canonThemes, { autoFill: true, @@ -398,6 +399,39 @@ }); } + $('.akap-edit-button', $overlay).click(function(){ + var textAreaOpened = $('textarea', $overlay)[0]; + var startTag = ""; + var endTag = ""; + var buttonName = this.innerHTML; + + if(buttonName == "słowo obce") { + startTag = ""; + endTag = ""; + } else if (buttonName == "wyróżnienie") { + startTag = ""; + endTag = ""; + } else if (buttonName == "tytuł dzieła") { + startTag = ""; + endTag = ""; + } + var myField = textAreaOpened; + + //IE support + if (document.selection) { + textAreaOpened.focus(); + sel = document.selection.createRange(); + sel.text = startTag + sel.text + endTag; + } + //MOZILLA/NETSCAPE support + else if (textAreaOpened.selectionStart || textAreaOpened.selectionStart == '0') { + var startPos = textAreaOpened.selectionStart; + var endPos = textAreaOpened.selectionEnd; + textAreaOpened.value = textAreaOpened.value.substring(0, startPos) + + startTag + textAreaOpened.value.substring(startPos, endPos) + endTag + textAreaOpened.value.substring(endPos, textAreaOpened.value.length); + } + }); + $('.accept-button', $overlay).click(function(){ save(); });