Basic buttons fixed.
authorŁukasz Rekucki <lrekucki@gmail.com>
Sun, 27 Sep 2009 22:03:35 +0000 (00:03 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Sun, 27 Sep 2009 22:03:35 +0000 (00:03 +0200)
project/static/js/views/button_toolbar.js
project/templates/toolbar_api/scriptlets.js

index 11cc148..3e0a148 100644 (file)
@@ -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');
index 801e5d3..6f5258c 100644 (file)
@@ -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