X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/061f517181630ee982c33aee63965b18965fd5aa..58e0903a3f0e1e105a11638b18b588e9eb6a8b9e:/platforma/static/js/button_scripts.js?ds=sidebyside diff --git a/platforma/static/js/button_scripts.js b/platforma/static/js/button_scripts.js old mode 100755 new mode 100644 index 4af9d72d..fe1c4ecd --- a/platforma/static/js/button_scripts.js +++ b/platforma/static/js/button_scripts.js @@ -1,3 +1,32 @@ +(function() { + var slice = Array.prototype.slice; + + function update(array, args) { + var arrayLength = array.length, length = args.length; + while (length--) array[arrayLength + length] = args[length]; + return array; + }; + + function merge(array, args) { + array = slice.call(array, 0); + return update(array, args); + }; + + Function.prototype.bind = function(context) { + if (arguments.length < 2 && typeof arguments[0] === 'undefined') { + return this; + } + var __method = this; + var args = slice.call(arguments, 1); + return function() { + var a = merge(args, arguments); + return __method.apply(context, a); + } + } + +})(); + + function ScriptletCenter() { this.scriptlets = {}; @@ -93,19 +122,6 @@ function ScriptletCenter() } }.bind(this); - this.scriptlets['codemirror_fontsize'] = function(context, params) { - var frameBody = this.XMLEditorBody(context); - - if(params.fontSize) { - frameBody.css('font-size', params.fontSize); - } - else { - var old_size = parseInt(frameBody.css('font-size'), 10); - frameBody.css('font-size', old_size + (params.change || 0) ); - } - - }.bind(this); - this.scriptlets['fulltextregexp'] = function(context, params) { var exprs = $.map(params.exprs, function(expr) { var opts = "mg"; @@ -198,19 +214,19 @@ function ScriptletCenter() } ScriptletCenter.prototype.XMLEditorSelectedText = function(panel) { - return panel.contentView.editor.selection(); + return panel.selection(); }; ScriptletCenter.prototype.XMLEditorReplaceSelectedText = function(panel, replacement) { - panel.contentView.editor.replaceSelection(replacement); + panel.replaceSelection(replacement); // Tell XML view that it's data has changed - panel.contentView.editorDataChanged(); + // panel.contentView.editorDataChanged(); }; ScriptletCenter.prototype.XMLEditorMoveCursorForward = function(panel, n) { - var pos = panel.contentView.editor.cursorPosition(); - panel.contentView.editor.selectLines(pos.line, pos.character + n); + var pos = panel.cursorPosition(); + panel.selectLines(pos.line, pos.character + n); }; var scriptletCenter;