#NEWLINE# def __init__( self , rdoc , html , m = None , vm = None , prerender = None , run = True ) : #NEWLINE# #INDENT# self . rdoc = rdoc #NEWLINE# class c ( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . e = c ( ) #NEWLINE# self . model = ( m or self . rdoc . dict ( ) ) #NEWLINE# self . viewmodel = ( vm or self . rdoc . dict ( ) ) #NEWLINE# self . prerender = prerender #NEWLINE# self . cls = self . rdoc . jsfunction ( 'vm' , 'm' , 'e' , 'newval' , 'i' , 'cls' , body = '\n            if (newval)\n                e.classList.add(cls);\n            else\n                e.classList.remove(cls);\n            ' ) #NEWLINE# self . style = self . rdoc . jsfunction ( 'vm' , 'm' , 'e' , 'newval' , 'i' , 'style_att' , 'style_opt' , body = "\n            if (newval)\n                e.style[style_att]=style_opt;\n            else\n                e.style[style_att]='';\n        " ) #NEWLINE# self . repeat = self . rdoc . jsfunction ( 'vm' , 'm' , 'e' , 'newval' , 'i' , body = "\n            if (typeof e.app.template=='undefined') {\n                e.app.template = e.children[0];\n                e.removeChild(e.children[0]);\n            }\n\n            var ec = e.children;\n            var ecl = ec.length;\n            var arr = newval;\n            var arrl = arr.length;\n            var c = arrl-ecl;\n            var te = e.app.template;\n            var tag = te.tagName;\n            var ih = te.innerHTML;\n            var app = te.app;\n            var eid = String(e.getAttribute('id'));\n            var tid = String(te.getAttribute('id'));\n            var id = eid+'_'+tid+'_';\n\n            function copy_app_execute_controller(to, from, i) {\n                if (typeof to.app=='undefined')\n                    to.app = {};\n                if ((typeof from.app!='undefined')&&\n                    (typeof from.app.execute_controller!='undefined')) {\n                    to.app.execute_controller = from.app.execute_controller;\n                    to.app.oldval = new Array(from.app.oldval.length);\n                }\n                to.app.i = i;\n                to.app.m = m;\n                to.app.vm = vm;\n\n                var fc = from.children;\n                if (typeof fc=='undefined')\n                    return;\n                var tc = to.children;\n                var l = tc.length;\n                for (var ci=0; ci<l; ci++)\n                    copy_app_execute_controller(tc[ci], fc[ci], i)\n            }\n\n            if (c>0)\n                // add new elements\n                for (var i=0; i<c; i++) {\n                    var ee = te.cloneNode(true);\n                    var eid = id+(i+ecl);\n                    ee.setAttribute('id', eid);\n                    ee.innerHTML = ih;\n                    ee.app = {};\n                    copy_app_execute_controller(ee, te, ecl+i);\n                    e.appendChild(ee);\n                }\n            else\n                // remove un-needed elements\n                for (var i=c; i<0; i++)\n                    e.removeChild(ec[ec.length-1]);\n        " ) #NEWLINE# self . property = self . rdoc . jsfunction ( 'vw' , 'm' , 'e' , 'newval' , 'i' , 'prop' , body = '\n            e[prop] = newval;\n        ' ) #NEWLINE# self . code = self . rdoc . jsfunction ( 'vm' , 'm' , 'e' , 'newval' , 'i' , 'code' , body = '\n            eval(code);\n        ' ) #NEWLINE# self . ismuttable = self . rdoc . jsfunction ( 'test' , body = "return (test && (typeof test == 'object' || typeof test == 'function'))" ) #NEWLINE# self . bind_html ( html ) #NEWLINE# if run : #NEWLINE# #INDENT# self . call_on_request_frame ( )