From 25400813a0ea9828e39975bf166672b97d3c16b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Mon, 28 Sep 2009 00:03:35 +0200 Subject: [PATCH] Basic buttons fixed. --- project/static/js/views/button_toolbar.js | 4 ++-- project/templates/toolbar_api/scriptlets.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) 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 -- 2.20.1