diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-11-22 15:30:15 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-11-22 15:30:15 -0500 |
commit | 1da43b401a4ebcd11ea4bd568326ec70fa1cc3b9 (patch) | |
tree | cebfef1afa9861c1cc5fb5263cc438406e0f28a0 | |
parent | ba9cbd82cbd87250308519ae0d9570959d53d75b (diff) |
grid0 working in IE
-rw-r--r-- | demo/more/grid0.ur | 34 | ||||
-rw-r--r-- | demo/more/grid0.urp | 7 | ||||
-rw-r--r-- | lib/js/urweb.js | 42 | ||||
-rw-r--r-- | tests/snest.ur | 15 | ||||
-rw-r--r-- | tests/snest.urp | 3 | ||||
-rw-r--r-- | tests/snest.urs | 1 |
6 files changed, 89 insertions, 13 deletions
diff --git a/demo/more/grid0.ur b/demo/more/grid0.ur new file mode 100644 index 00000000..3e3d27ab --- /dev/null +++ b/demo/more/grid0.ur @@ -0,0 +1,34 @@ +open Dbgrid + +sequence s +table t : {Id : int, A : int} + PRIMARY KEY Id + +open Make(struct + val tab = t + con key = [Id = _] + + val raw = {Id = {New = nextval s, + Inj = _}, + A = {New = return 0, + Inj = _}} + + val cols = {Id = Direct.readOnly [#Id] ! "Id" Direct.int, + A = Direct.editable [#A] ! "A" Direct.int} + + val aggregates = {} + + val pageLength = None + end) + +fun main () = + grid <- grid; + set (showSelection grid) True; + return <xml> + <head> + <link rel="stylesheet" type="text/css" href="../../grid.css"/> + </head> + <body onload={sync grid}> + {render grid} + </body> + </xml> diff --git a/demo/more/grid0.urp b/demo/more/grid0.urp new file mode 100644 index 00000000..2cb16ec9 --- /dev/null +++ b/demo/more/grid0.urp @@ -0,0 +1,7 @@ +debug +database dbname=test +library grid +sql grid0.sql +allow url ../../grid.css + +grid0 diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 71a1a53d..15ff7bf2 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -116,7 +116,7 @@ function onFail(f) { function doExn(v) { if (v == null || v.uw_error == null) { - var s = (v == null ? "null" : v.toString()); + var s = (v == null ? "null" : v.message ? v.message : v.toString()); if (v != null && v.fileName && v.lineNumber) s += " (" + v.fileName + ":" + v.lineNumber + ")"; runHandlers("Fail", failHandlers, s); @@ -289,7 +289,9 @@ function lastParent() { while (pos.lastChild && pos.lastChild.nodeType == 1) pos = pos.lastChild; - return pos.parentNode; + pos = pos.parentNode; + + return pos; } function parent() { @@ -315,6 +317,7 @@ function runScripts(node) { scriptsCopy[i] = scripts[i]; for (var i = 0; i < len; ++i) { thisScript = scriptsCopy[i]; + try { eval(thisScript.text); } catch (v) { @@ -355,6 +358,7 @@ function dyn(pnode, s) { var next; for (var child = firstChild; child && child != x; child = next) { next = child.nextSibling; + killScript(child); if (child.getElementsByTagName) { var arr = child.getElementsByTagName("script"); @@ -367,7 +371,9 @@ function dyn(pnode, s) { } var cls = {v : null}; - var html = dynPrefix + flatten(cls, v); + var html = flatten(cls, v); + if (pnode != "table" && pnode != "tr") + html = dynPrefix + html; x.closures = cls.v; if (pnode == "table") { @@ -377,12 +383,22 @@ function dyn(pnode, s) { var table = x.parentNode; if (table) { - var arr = dummy.getElementsByTagName("tbody"); firstChild = null; var tbody; - if (arr.length > 0 && table != null) + + var arr = dummy.getElementsByTagName("tbody"); + + var tbody; + if (arr.length > 0 && arr[0].parentNode == dummy.firstChild) { tbody = arr[0]; - else + var next; + for (var node = dummy.firstChild.firstChild; node; node = next) { + next = node.nextSibling; + + if (node.tagName != "TBODY") + tbody.appendChild(node); + } + } else tbody = dummy.firstChild; var next; @@ -402,16 +418,16 @@ function dyn(pnode, s) { if (table) { var arr = dummy.getElementsByTagName("tr"); firstChild = null; - var tbody; + var tr; if (arr.length > 0 && table != null) - tbody = arr[0]; + tr = arr[0]; else - tbody = dummy.firstChild; + tr = dummy.firstChild; var next; firstChild = document.createElement("script"); table.insertBefore(firstChild, x); - for (var node = tbody.firstChild; node; node = next) { + for (var node = tr.firstChild; node; node = next) { next = node.nextSibling; table.insertBefore(node, x); } @@ -429,8 +445,9 @@ function dyn(pnode, s) { populate(x); } -function input(t, s, recreate) { +function input(t, s, recreate, type) { var x = document.createElement(t); + if (type) x.type = type; x.dead = false; x.signal = ss(s); x.sources = null; @@ -461,8 +478,7 @@ function sel(s, content) { } function chk(s) { - var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }); - x.type = "checkbox"; + var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }, "checkbox"); x.checked = s.data; x.onchange = function() { sv(s, x.checked) }; diff --git a/tests/snest.ur b/tests/snest.ur new file mode 100644 index 00000000..c7daae3c --- /dev/null +++ b/tests/snest.ur @@ -0,0 +1,15 @@ +fun main () = + s1 <- source False; + s2 <- source False; + + return <xml><body> + <dyn signal={s1 <- signal s1; + return (if s1 then + <xml><dyn signal={s2 <- signal s2; + return <xml>{[s2]}</xml>}/></xml> + else + <xml>Not yet</xml>)}/> + <hr/> + <button value="s1" onclick={set s1 True}/> + <button value="s2" onclick={set s2 True}/> + </body></xml> diff --git a/tests/snest.urp b/tests/snest.urp new file mode 100644 index 00000000..3e68a597 --- /dev/null +++ b/tests/snest.urp @@ -0,0 +1,3 @@ +debug + +snest diff --git a/tests/snest.urs b/tests/snest.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/snest.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |