Mercurial > urweb
comparison lib/js/urweb.js @ 1751:acadf9d1214a
'dynStyle' pseudo-attribute
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 06 May 2012 15:15:46 -0400 |
parents | 6f2f74cc4ead |
children | e9587120831a |
comparison
equal
deleted
inserted
replaced
1750:277480862cef | 1751:acadf9d1214a |
---|---|
942 x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; | 942 x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; |
943 | 943 |
944 return x; | 944 return x; |
945 } | 945 } |
946 | 946 |
947 function dynClass(html, s) { | 947 function dynClass(html, s_class, s_style) { |
948 var htmlCls = {v : null}; | 948 var htmlCls = {v : null}; |
949 html = flatten(htmlCls, html); | 949 html = flatten(htmlCls, html); |
950 htmlCls = htmlCls.v; | 950 htmlCls = htmlCls.v; |
951 | 951 |
952 var dummy = document.createElement("body"); | 952 var dummy = document.createElement("body"); |
954 runScripts(dummy); | 954 runScripts(dummy); |
955 var html = dummy.firstChild; | 955 var html = dummy.firstChild; |
956 dummy.removeChild(html); | 956 dummy.removeChild(html); |
957 addNode(html); | 957 addNode(html); |
958 | 958 |
959 var x = document.createElement("script"); | 959 if (s_class) { |
960 x.dead = false; | 960 var x = document.createElement("script"); |
961 x.signal = s; | 961 x.dead = false; |
962 x.sources = null; | 962 x.signal = s_class; |
963 x.closures = htmlCls; | 963 x.sources = null; |
964 | 964 x.closures = htmlCls; |
965 x.recreate = function(v) { | 965 |
966 for (var ls = x.closures; ls != htmlCls; ls = ls.next) | 966 x.recreate = function(v) { |
967 freeClosure(ls.data); | 967 for (var ls = x.closures; ls != htmlCls; ls = ls.next) |
968 | 968 freeClosure(ls.data); |
969 var cls = {v : null}; | 969 |
970 html.className = flatten(cls, v); | 970 var cls = {v : null}; |
971 x.closures = concat(cls.v, htmlCls); | 971 html.className = flatten(cls, v); |
972 }; | 972 x.closures = concat(cls.v, htmlCls); |
973 | 973 } |
974 addNode(x); | 974 |
975 populate(x); | 975 addNode(x); |
976 populate(x); | |
977 } | |
978 | |
979 if (s_style) { | |
980 var x = document.createElement("script"); | |
981 x.dead = false; | |
982 x.signal = s_style; | |
983 x.sources = null; | |
984 x.closures = htmlCls; | |
985 | |
986 x.recreate = function(v) { | |
987 for (var ls = x.closures; ls != htmlCls; ls = ls.next) | |
988 freeClosure(ls.data); | |
989 | |
990 var cls = {v : null}; | |
991 html.style.cssText = flatten(cls, v); | |
992 x.closures = concat(cls.v, htmlCls); | |
993 } | |
994 | |
995 addNode(x); | |
996 populate(x); | |
997 } | |
976 } | 998 } |
977 | 999 |
978 function addOnChange(x, f) { | 1000 function addOnChange(x, f) { |
979 var old = x.onchange; | 1001 var old = x.onchange; |
980 if (old == null) | 1002 if (old == null) |