X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/1e71d943e17f0011d65d9e92969ff2aa3b73ff31..8132fc186eb0c5fd02c86828c3a4735754296d02:/redakcja/static/js/button_scripts.js diff --git a/redakcja/static/js/button_scripts.js b/redakcja/static/js/button_scripts.js index ff17eea4..37f37a7d 100644 --- a/redakcja/static/js/button_scripts.js +++ b/redakcja/static/js/button_scripts.js @@ -48,6 +48,11 @@ function ScriptletCenter() { this.scriptlets = {}; + this.scriptlets['insert_text'] = function(context, params, text, move_forward, move_up, done) + { + done(params.text, move_forward, move_up); + }.bind(this); + this.scriptlets['insert_tag'] = function(context, params, text, move_forward, move_up, done) { var padding_top = ''; @@ -282,6 +287,12 @@ function ScriptletCenter() done(output, move_forward, move_up); }.bind(this); + + this.scriptlets['slugify'] = function(context, params, text, move_forward, move_up, done) + { + done(slugify(text.replace(/_/g, '-')), move_forward, move_up); + }.bind(this); + } ScriptletCenter.prototype.callInteractive = function(opts) { @@ -296,22 +307,26 @@ ScriptletCenter.prototype.callInteractive = function(opts) { $.blockUI({message: $progress, showOverlay: false}); + $('#save-button').attr('disabled', true); var input = self.XMLEditorSelectedText(opts.context); - self.scriptlets[opts.action](opts.context, opts.extra, input, 0, 0, function(output, move_forward, move_up){ - /*if(timer) - clearTimeout(timer); - else */ - if (input != output) { - self.XMLEditorReplaceSelectedText(opts.context, output) - } - if (move_forward || move_up) { - try { - self.XMLEditorMoveCursorForward(opts.context, move_forward, move_up) + window.setTimeout(function() { + self.scriptlets[opts.action](opts.context, opts.extra, input, 0, 0, function(output, move_forward, move_up){ + /*if(timer) + clearTimeout(timer); + else */ + if (input != output) { + self.XMLEditorReplaceSelectedText(opts.context, output) } - catch(e) {} - } - $.unblockUI(); // done - }); + if (move_forward || move_up) { + try { + self.XMLEditorMoveCursorForward(opts.context, move_forward, move_up) + } + catch(e) {} + } + $.unblockUI({onUnblock: function() { $('#save-button').attr('disabled', null)}}); // done + }); + }, 0); + } ScriptletCenter.prototype.XMLEditorSelectedText = function(editor) { @@ -349,4 +364,4 @@ var scriptletCenter; $(function() { scriptletCenter = new ScriptletCenter(); -}); \ No newline at end of file +});