AJAX outliners work better now
parent
cfdb6aef7b
commit
7176754832
|
@ -20,10 +20,9 @@ global [
|
||||||
"callback" [ callback-responder ] add-simple-responder
|
"callback" [ callback-responder ] add-simple-responder
|
||||||
|
|
||||||
! Javascript source used by ajax libraries
|
! Javascript source used by ajax libraries
|
||||||
"javascript" [
|
"resources" [
|
||||||
[
|
[
|
||||||
"contrib/httpd/javascript/" resource-path
|
"" resource-path "doc-root" set
|
||||||
"doc-root" set
|
|
||||||
file-responder
|
file-responder
|
||||||
] with-scope
|
] with-scope
|
||||||
] add-simple-responder
|
] add-simple-responder
|
||||||
|
|
|
@ -156,7 +156,7 @@ M: html-stream stream-format ( str style stream -- )
|
||||||
: html-outliner ( caption contents -- )
|
: html-outliner ( caption contents -- )
|
||||||
"+ " get-random-id dup >r
|
"+ " get-random-id dup >r
|
||||||
rot make-outliner-quot updating-anchor call
|
rot make-outliner-quot updating-anchor call
|
||||||
<span r> =id span> </span> ;
|
<span r> =id "display: none; " =style span> </span> ;
|
||||||
|
|
||||||
: outliner-tag ( style quot -- )
|
: outliner-tag ( style quot -- )
|
||||||
outline pick hash [ html-outliner ] [ call ] if* ;
|
outline pick hash [ html-outliner ] [ call ] if* ;
|
||||||
|
@ -172,12 +172,27 @@ M: html-stream with-nested-stream ( quot style stream -- )
|
||||||
] outliner-tag
|
] outliner-tag
|
||||||
] with-stream* ;
|
] with-stream* ;
|
||||||
|
|
||||||
|
: border-spacing-css,
|
||||||
|
"padding: " % first2 max 2 /i # "px; " % ;
|
||||||
|
|
||||||
|
: table-style ( style -- str )
|
||||||
|
[
|
||||||
|
H{
|
||||||
|
{ table-border [ border-css, ] }
|
||||||
|
{ table-gap [ border-spacing-css, ] }
|
||||||
|
} hash-apply
|
||||||
|
] "" make ;
|
||||||
|
|
||||||
|
: table-attrs ( style -- )
|
||||||
|
table-style " border-collapse: collapse;" append =style ;
|
||||||
|
|
||||||
M: html-stream with-stream-table ( grid quot style stream -- )
|
M: html-stream with-stream-table ( grid quot style stream -- )
|
||||||
[
|
[
|
||||||
<table> rot [
|
<table dup table-attrs table> rot [
|
||||||
<tr> [
|
<tr> [
|
||||||
<td "top" =valign td>
|
<td "top" =valign over table-style =style td>
|
||||||
pick pick stdio get with-nested-stream </td>
|
pick H{ } swap with-nesting
|
||||||
|
</td>
|
||||||
] each </tr>
|
] each </tr>
|
||||||
] each 2drop </table>
|
] each 2drop </table>
|
||||||
] with-stream* ;
|
] with-stream* ;
|
||||||
|
|
|
@ -11,7 +11,8 @@ strings ;
|
||||||
: include-prototype-js ( -- )
|
: include-prototype-js ( -- )
|
||||||
#! Write out the HTML script tag to include the prototype
|
#! Write out the HTML script tag to include the prototype
|
||||||
#! javascript library.
|
#! javascript library.
|
||||||
<script "text/javascript" =type "/responder/javascript/prototype.js" =src script>
|
<script "text/javascript" =type "/responder/resources/contrib/httpd/javascript/prototype.js"
|
||||||
|
=src script>
|
||||||
</script> ;
|
</script> ;
|
||||||
|
|
||||||
: updating-javascript ( id quot -- string )
|
: updating-javascript ( id quot -- string )
|
||||||
|
@ -20,9 +21,19 @@ strings ;
|
||||||
t register-html-callback swap
|
t register-html-callback swap
|
||||||
[ "new Ajax.Updater(\"" % % "\",\"" % % "\", { method: \"get\" });" % ] "" make ;
|
[ "new Ajax.Updater(\"" % % "\",\"" % % "\", { method: \"get\" });" % ] "" make ;
|
||||||
|
|
||||||
|
: toggle-javascript ( string id -- string )
|
||||||
|
[
|
||||||
|
"if(Element.visible(\"" % dup % "\"))" %
|
||||||
|
"Element.hide(\"" % dup % "\");" %
|
||||||
|
"else {" %
|
||||||
|
swap %
|
||||||
|
" Element.show(\"" % % "\"); }" %
|
||||||
|
] "" make ;
|
||||||
|
|
||||||
: updating-anchor ( text id quot -- )
|
: updating-anchor ( text id quot -- )
|
||||||
#! Write the HTML for an anchor that when clicked will
|
#! Write the HTML for an anchor that when clicked will
|
||||||
#! call the given quotation on the server. The output generated
|
#! call the given quotation on the server. The output generated
|
||||||
#! from that quotation will replace the DOM element on the page with
|
#! from that quotation will replace the DOM element on the page with
|
||||||
#! the given id. The 'text' is the anchor text.
|
#! the given id. The 'text' is the anchor text.
|
||||||
<a updating-javascript =onclick a> write </a> ;
|
over >r updating-javascript r> toggle-javascript
|
||||||
|
<a =onclick a> write </a> ;
|
||||||
|
|
Loading…
Reference in New Issue