forked from skypher/weblocks
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new file for Javascript-centric utilities. Added collapsible se…
…ctions convenience layer.
- Loading branch information
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
(in-package :weblocks) | ||
|
||
(export '(begin-section | ||
end-section | ||
begin-collapsible-section | ||
end-collapsible-section)) | ||
|
||
(defun begin-section (title &key (container-class "") (container-id (gen-id)) (heading t) | ||
heading-onclick heading-class) | ||
"Begin a section (a DIV container) on the client. | ||
The section is preceded by a heading 3 unless HEADING is NIL." | ||
(when heading | ||
(write | ||
(with-html-to-string | ||
(:h3 :class heading-class :onclick heading-onclick (esc title))) | ||
:stream *weblocks-output-stream* | ||
:escape nil)) | ||
(format *weblocks-output-stream* "<div id='~D' class='~A'>" container-id container-class)) | ||
|
||
(defun end-section () | ||
"End a client section." | ||
(format *weblocks-output-stream* "</div>")) | ||
|
||
(defun begin-collapsible-section (title) | ||
"Begin a section that is expandable/collapsible via clicks on | ||
its heading." | ||
(let ((id (gen-id))) | ||
(begin-section title | ||
:container-id id | ||
:heading-onclick (format nil "toggleExpandCollapse(this,document.getElementById(\"~D\"));" id) | ||
:heading-class "collapsible-heading collapsed" | ||
:container-class "collapsible-container collapsed"))) | ||
|
||
(defun end-collapsible-section () | ||
(end-section)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters