From 3286b1544106066720fbf848466b66085dad2ebc Mon Sep 17 00:00:00 2001 From: inpos Date: Wed, 8 Aug 2018 20:34:22 +0300 Subject: [PATCH] renderTo --- orun/examples/cp.py | 2 +- orun/extjs/base.py | 4 ++-- orun/js.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/orun/examples/cp.py b/orun/examples/cp.py index 3127e38..210fe34 100644 --- a/orun/examples/cp.py +++ b/orun/examples/cp.py @@ -17,7 +17,7 @@ class MyApplication(cp.ExtApplication): 'items': [{'xtype': 'button', 'text': 'Click Here', 'handler': button_click}], 'buttons': [ {'text': 'OK', 'handler': js.FuncWithParams(ok_click, {'arg1': 1, 'arg2': 'val2'})}, - {'text': 'Close', 'handler': js.function('this.up(\'window\').close()')}]}) + {'text': 'Close', 'handler': str(js.function('this.up(\'window\').close()'))}]}) wnd.show() wnd.setHeight(200) diff --git a/orun/extjs/base.py b/orun/extjs/base.py index 2e08897..0df7f1f 100644 --- a/orun/extjs/base.py +++ b/orun/extjs/base.py @@ -59,5 +59,5 @@ class Component(js.JsObject): pass def __str__(self): - s = json.dumps(self._js, default=js._encoder) - return re.sub(r'(":\s+)("(function[^"]+)")', r'\1\3', s) + s = json.dumps(self._js, default=js._encoder, indent=4) + return re.sub(r'("(handler|renderTo)":\s+)("([^"]+)")', r'\1\4', s) diff --git a/orun/js.py b/orun/js.py index 2314bd4..fccf3f1 100644 --- a/orun/js.py +++ b/orun/js.py @@ -19,9 +19,9 @@ def _encoder(o): elif isinstance(o, JsNode): return block(str(o)) elif isinstance(o, types.FunctionType) and js_ajax: - return function(js_ajax(o)) + return str(function(js_ajax(o))) elif isinstance(o, FuncWithParams): - return function(js_ajax(o.func, o.params)) + return str(function(js_ajax(o.func, o.params))) def encode(o): if isinstance(o, JsNode): @@ -34,7 +34,7 @@ def encode(o): # trick json serialize javascript block class JsBlock(str): def __new__(cls, *args, **kwargs): - obj = super(JsBlock, cls).__new__(cls, 'function () { %s }' % args[0]) + obj = super(JsBlock, cls).__new__(cls, '%s' % args[0]) obj.code = args[0] return obj