X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3193141f55df20910cf8ba35f9e669d79c90d3f4..a9efc708bce6a636b314c58b3c9769488e8d5999:/platforma/static/js/button_scripts.js?ds=inline diff --git a/platforma/static/js/button_scripts.js b/platforma/static/js/button_scripts.js old mode 100644 new mode 100755 index 40f45f6f..4af9d72d --- a/platforma/static/js/button_scripts.js +++ b/platforma/static/js/button_scripts.js @@ -6,6 +6,7 @@ function ScriptletCenter() { var text = this.XMLEditorSelectedText(context); var start_tag = '<'+params.tag; + var move_cursor = false; for (var attr in params.attrs) { start_tag += ' '+attr+'="' + params.attrs[attr] + '"'; @@ -39,14 +40,23 @@ function ScriptletCenter() output += token; } else { - output = start_tag + end_tag; + if(params.nocontent) { + output = "<"+params.tag +" />"; + } + else { + output = start_tag + end_tag; + move_cursor = true; + } } this.XMLEditorReplaceSelectedText(context, output); - if (text.length == 0) { - this.XMLEditorMoveCursorForward(context, -params.tag.length-3); - } + try { + if (move_cursor) { + this.XMLEditorMoveCursorForward(context, params.tag.length+2); + } + } catch(e) {} + }.bind(this); this.scriptlets['lineregexp'] = function(context, params) {