X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/78644811ca0c6042212788dc67add42bc41fb74c..084544e4f7c9269b1445a9e5109fa641a3e1aaac:/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) {