From: Łukasz Rekucki Date: Sun, 27 Sep 2009 22:03:35 +0000 (+0200) Subject: Basic buttons fixed. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/25400813a0ea9828e39975bf166672b97d3c16b7?hp=84132f4ec69d46ec216d1fe1d5adc5e5ee8a4798 Basic buttons fixed. --- diff --git a/project/static/js/views/button_toolbar.js b/project/static/js/views/button_toolbar.js index 11cc1487..3e0a1488 100644 --- a/project/static/js/views/button_toolbar.js +++ b/project/static/js/views/button_toolbar.js @@ -39,14 +39,14 @@ var ButtonToolbarView = View.extend({ $(self.element).trigger('resize'); }); - $('.buttontoolbarview-button', this.element).bind('click.buttontoolbarview', function() { + $('.buttontoolbarview-button', this.element).bind('click.buttontoolbarview', function(event) { var groupIndex = parseInt($(this).attr('ui:groupindex'), 10); var buttonIndex = parseInt($(this).attr('ui:buttonindex'), 10); var button = self.get('buttons')[groupIndex].buttons[buttonIndex]; var scriptletId = button.scriptlet_id; var params = eval('(' + button.params + ')'); // To nie powinno być potrzebne console.log('Executing', scriptletId, 'with params', params); - scriptletCenter[scriptletId](self.parent, params); + scriptletCenter.scriptlets[scriptletId](self.parent, params); }); $(this.element).trigger('resize'); diff --git a/project/templates/toolbar_api/scriptlets.js b/project/templates/toolbar_api/scriptlets.js index 801e5d3e..6f5258c9 100644 --- a/project/templates/toolbar_api/scriptlets.js +++ b/project/templates/toolbar_api/scriptlets.js @@ -8,8 +8,23 @@ function ScriptletCenter() { {% endfor %} _none: null - }; + }; } +ScriptletCenter.prototype.XMLEditorSelectedText = function(panel) { + return panel.contentView.editor.selection(); +} + +ScriptletCenter.prototype.XMLEditorReplaceSelectedText = function(panel, replacement) +{ + panel.contentView.editor.replaceSelection(replacement); + /* TODO: fire the change event */ +} + +ScriptletCenter.prototype.XMLEditorMoveCursorForward = function(panel, n) { + var pos = panel.contentView.editor.cursorPosition(); + panel.contentView.editor.selectLines(pos.line, pos.character + n); +} + scriptletCenter = new ScriptletCenter(); \ No newline at end of file