diff --git a/source/clog-base.lisp b/source/clog-base.lisp index 7179fd7..de39278 100644 --- a/source/clog-base.lisp +++ b/source/clog-base.lisp @@ -349,19 +349,16 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)")) (let ((hook (format nil "~A:~A" (html-id obj) event))) (cond (handler (bind-event-script - obj event (format nil "~Aws.send('E:~A '~A)~A~A~A" + obj event (format nil "~Aws.send('E:~A '~A)~A~@[~A~]~@[~A~]" eval-script hook call-back-script post-eval - (if one-time - (format nil "; ~A.off('~A')" - (jquery obj) - event) - "") - (if cancel-event - "; return false" - ""))) + (when one-time + (format nil "; ~A.off('~A')" + (jquery obj) + event)) + (when cancel-event "; return false"))) (setf (gethash hook (connection-data obj)) handler)) (t (unbind-event-script obj event) diff --git a/source/clog-element-common.lisp b/source/clog-element-common.lisp index 846815c..fe55960 100644 --- a/source/clog-element-common.lisp +++ b/source/clog-element-common.lisp @@ -20,7 +20,8 @@ ;;;;;;;;;;;;;; (defgeneric create-a (clog-obj - &key link content target hidden class html-id auto-place) + &key link content target + style hidden class html-id auto-place) (:documentation "Create a new CLOG-A as child of CLOG-OBJ with :LINK and :CONTENT (default \"\") and :TARGET (\"_self\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. @@ -35,17 +36,18 @@ place-inside-bottom-of CLOG-OBJ. &key (link "#") (content "") (target "_self") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" - (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string target) (escape-string link) (escape-string content)) @@ -98,22 +100,23 @@ place-inside-bottom-of CLOG-OBJ. ;; create-br ;; ;;;;;;;;;;;;;;; -(defgeneric create-br (clog-obj &key hidden class html-id auto-place) +(defgeneric create-br (clog-obj &key style hidden class html-id auto-place) (:documentation "Create a new CLOG-BR as child of CLOG-OBJ that creates a line break and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) -(defmethod create-br ((obj clog-obj) &key (hidden nil) +(defmethod create-br ((obj clog-obj) &key (style nil) + (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-br :html-id html-id :auto-place auto-place)) @@ -129,24 +132,26 @@ line break and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-button ;; ;;;;;;;;;;;;;;;;;;; -(defgeneric create-button (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-button (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Button as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-button ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" - (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-button :html-id html-id @@ -182,23 +187,26 @@ CLOG-OBJ")) ;; create-div ;; ;;;;;;;;;;;;;;;; -(defgeneric create-div (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-div (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Div as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. If hidden is true visiblep is set to nil.")) (defmethod create-div ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-div :html-id html-id @@ -215,24 +223,27 @@ CLOG-OBJ. If hidden is true visiblep is set to nil.")) ;; create-dialog ;; ;;;;;;;;;;;;;;;;;;; -(defgeneric create-dialog (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-dialog (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Dialog as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. If hidden is true visiblep is set to nil. Modal does not work on -firefox and does not work at all on IE.")) +firefox and dialog does not work at all on IE.")) (defmethod create-dialog ((obj clog-obj) &key (content "") - (hidden nil) - (class nil) - (html-id nil) - (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (style nil) + (hidden nil) + (class nil) + (html-id nil) + (auto-place t)) + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-dialog :html-id html-id @@ -308,23 +319,25 @@ firefox and does not work at all on IE.")) ;; create-hr ;; ;;;;;;;;;;;;;;; -(defgeneric create-hr (clog-obj &key hidden class html-id auto-place) +(defgeneric create-hr (clog-obj &key hidden + style class html-id auto-place) (:documentation "Create a new CLOG-HR as child of CLOG-OBJ that creates a horizontal rule (line) and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-hr ((obj clog-obj) &key (hidden nil) + (style nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-hr :html-id html-id :auto-place auto-place)) @@ -342,7 +355,7 @@ CLOG-OBJ")) (defgeneric create-img (clog-obj &key url-src alt-text - hidden class html-id auto-place) + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Img as child of CLOG-OBJ with :URL-SRC (default \"\") and :ALT-TEXT (default \"\") if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. Use width and height properties before @@ -351,18 +364,19 @@ placing image to constrain image size.")) (defmethod create-img ((obj clog-obj) &key (url-src "") (alt-text "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil ")" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil ")" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string url-src) (escape-string alt-text)) :clog-type 'clog-img @@ -415,6 +429,7 @@ placing image to constrain image size.")) ;;;;;;;;;;;;;;;;;; (defgeneric create-meter (clog-obj &key value high low maximum minimum optimum + style hidden class html-id @@ -431,20 +446,21 @@ place-inside-bottom-of CLOG-OBJ.")) (maximum 100) (minimum 0) (optimum 50) + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) (create-child obj (format nil - "" + "" value high low maximum minimum optimum - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-meter :html-id html-id :auto-place auto-place)) @@ -569,26 +585,27 @@ place-inside-bottom-of CLOG-OBJ.")) (defgeneric create-progress-bar (clog-obj &key value maximum - hidden class html-id auto-place) + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Progress-Bar as child of CLOG-OBJ with VALUE (default 0) MAXIMUM (default 100) and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ.")) (defmethod create-progress-bar ((obj clog-obj) &key (value 0) (maximum 100) + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" + (create-child obj (format nil "" value maximum - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-progress-bar :html-id html-id :auto-place auto-place)) @@ -643,24 +660,26 @@ place-inside-bottom-of CLOG-OBJ.")) ;; create-p ;; ;;;;;;;;;;;;;; -(defgeneric create-p (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-p (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-P as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-p ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A

" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A

" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-p :html-id html-id @@ -678,25 +697,27 @@ CLOG-OBJ")) ;; create-span ;; ;;;;;;;;;;;;;;;;; -(defgeneric create-span (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-span (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Span as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. A span is an inline element while a div is a block element (one that takes up the entire browser width).")) (defmethod create-span ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-span :html-id html-id @@ -718,25 +739,27 @@ browser width).")) :hgroup)) (defgeneric create-section (clog-obj section - &key content hidden class html-id auto-place) + &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Section of section type as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-section ((obj clog-obj) section &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "<~A~A~A>~A" + (create-child obj (format nil "<~A~@[~A~]~@[~A~]>~A" section - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content) section) :clog-type 'clog-section @@ -759,33 +782,34 @@ CLOG-OBJ")) :i :b :u :sub :su :center)) (defgeneric create-phrase (clog-obj phrase - &key content hidden class html-id auto-place) + &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Phrase of phrase type as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-phrase ((obj clog-obj) phrase &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "<~A~A~A>~A" + (create-child obj (format nil "<~A~@[~A~]~@[~A~]>~A" phrase - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content) phrase) :clog-type 'clog-phrase :html-id html-id :auto-place auto-place)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-ordered-list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -797,23 +821,25 @@ CLOG-OBJ")) ;; create-ordered-list ;; ;;;;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-ordered-list (clog-obj &key hidden class html-id auto-place) +(defgeneric create-ordered-list (clog-obj &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Ordered-List as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-ordered-list ((obj clog-obj) &key (hidden nil) + (style nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-ordered-list :html-id html-id :auto-place auto-place)) @@ -874,22 +900,24 @@ is outside.")) ;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric create-unordered-list (clog-obj - &key hidden class html-id auto-place) + &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Unordered-List as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-unordered-list ((obj clog-obj) &key (hidden nil) + (style nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-unordered-list :html-id html-id :auto-place auto-place)) @@ -905,18 +933,24 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-list-item ;; ;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-list-item (clog-obj &key content class html-id auto-place) +(defgeneric create-list-item (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-List-Item as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-list-item ((obj clog-obj) &key (content "") + (style nil) + (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-list-item :html-id html-id @@ -951,21 +985,24 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric create-definition-list (clog-obj - &key hidden class html-id auto-place) + &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Definition-List as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) -(defmethod create-definition-list ((obj clog-obj) &key (hidden nil) +(defmethod create-definition-list ((obj clog-obj) &key (style nil) + (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-definition-list :html-id html-id :auto-place auto-place)) @@ -983,23 +1020,24 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defgeneric create-term (clog-obj &key content - hidden class html-id auto-place) + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Term as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-term ((obj clog-obj) - &key (hidden nil) + &key (style nil) + (hidden nil) (content "") (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-term :html-id html-id @@ -1017,24 +1055,26 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric create-description (clog-obj - &key hidden content class html-id auto-place) + &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Description as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-description ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-description :html-id html-id @@ -1051,21 +1091,21 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-table ;; ;;;;;;;;;;;;;;;;;; -(defgeneric create-table (clog-obj &key hidden class html-id auto-place) +(defgeneric create-table (clog-obj &key style hidden class html-id auto-place) (:documentation "Create a new CLOG-Table as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table :html-id html-id :auto-place auto-place)) @@ -1081,21 +1121,22 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-table-row ;; ;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-table-row (clog-obj &key hidden class html-id auto-place) +(defgeneric create-table-row (clog-obj &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Table-Row as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-row ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-row :html-id html-id :auto-place auto-place)) @@ -1114,6 +1155,7 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defgeneric create-table-column (clog-obj &key content column-span row-span + style hidden class html-id @@ -1124,20 +1166,21 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-column ((obj clog-obj) &key (content "") (column-span 1) (row-span 1) + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" + (create-child obj (format nil "~A" column-span row-span - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-table-column :html-id html-id @@ -1157,6 +1200,7 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defgeneric create-table-heading (clog-obj &key content column-span row-span + style hidden class html-id @@ -1167,20 +1211,21 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-heading ((obj clog-obj) &key (content "") (column-span 1) (row-span 1) + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" + (create-child obj (format nil "~A" column-span row-span - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-table-heading :html-id html-id @@ -1197,21 +1242,22 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-table-head ;; ;;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-table-head (clog-obj &key hidden class html-id auto-place) +(defgeneric create-table-head (clog-obj &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Table-Head as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-head ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-head :html-id html-id :auto-place auto-place)) @@ -1227,21 +1273,22 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-table-body ;; ;;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-table-body (clog-obj &key hidden class html-id auto-place) +(defgeneric create-table-body (clog-obj &key style + hidden class html-id auto-place) (:documentation "Create a new CLOG-Table-Body as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-body ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-body :html-id html-id :auto-place auto-place)) @@ -1259,24 +1306,25 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defgeneric create-table-caption (clog-obj &key content - hidden class html-id auto-place) + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Table-Caption as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-caption ((obj clog-obj) &key (content "") + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "~A" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-table-caption :html-id html-id @@ -1293,22 +1341,22 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-table-footer ;; ;;;;;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-table-footer (clog-obj &key hidden +(defgeneric create-table-footer (clog-obj &key style hidden class html-id auto-place) (:documentation "Create a new CLOG-Table-Footer as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-footer ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-footer :html-id html-id :auto-place auto-place)) @@ -1325,21 +1373,22 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric create-table-column-group (clog-obj - &key hidden class html-id auto-place) + &key style hidden + class html-id auto-place) (:documentation "Create a new CLOG-Table-Column-Group as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-column-group ((obj clog-obj) - &key (hidden nil) + &key (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (create-child obj (format nil "" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-column-group :html-id html-id :auto-place auto-place)) @@ -1357,25 +1406,27 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defgeneric create-table-column-group-item (clog-obj &key column-span - hidden class html-id auto-place) + style hidden + class html-id auto-place) (:documentation "Create a new CLOG-Table-Column-Group-Item as child of CLOG-OBJ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-table-column-group-item ((obj clog-obj) &key (column-span 1) + (style nil) (hidden nil) (class nil) (html-id nil) (auto-place t)) - (create-child obj (format nil "" + (create-child obj (format nil "" column-span - (if hidden - " style='visibility:hidden;'" - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) :clog-type 'clog-table-column-group-item :html-id html-id :auto-place auto-place)) @@ -1391,23 +1442,26 @@ and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) ;; create-details ;; ;;;;;;;;;;;;;;;;;;;; -(defgeneric create-details (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-details (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Details as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. If hidden is true visiblep is set to nil.")) (defmethod create-details ((obj clog-obj) &key (content "") - (hidden nil) - (class nil) - (html-id nil) - (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (style nil) + (hidden nil) + (class nil) + (html-id nil) + (auto-place t)) + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-details :html-id html-id @@ -1444,24 +1498,27 @@ CLOG-OBJ. If hidden is true visiblep is set to nil.")) ;; create-summary ;; ;;;;;;;;;;;;;;;;;;;; -(defgeneric create-summary (clog-obj &key content hidden class html-id auto-place) +(defgeneric create-summary (clog-obj &key content + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Summary as child of CLOG-OBJ with :CONTENT (default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. If hidden is true visiblep is set to nil. Use inside a CLOG-DETAILS object for drop reveal.")) (defmethod create-summary ((obj clog-obj) &key (content "") - (hidden nil) - (class nil) - (html-id nil) - (auto-place t)) - (create-child obj (format nil "~A" - (if class - (format nil " class='~A'" (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") + (style nil) + (hidden nil) + (class nil) + (html-id nil) + (auto-place t)) + (create-child obj (format nil "~A" + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-summary :html-id html-id diff --git a/source/clog-element.lisp b/source/clog-element.lisp index f7adcd9..03dc928 100644 --- a/source/clog-element.lisp +++ b/source/clog-element.lisp @@ -132,7 +132,7 @@ after attachment is changed to one unique to this session.")) (defsetf style set-style) (defgeneric set-styles (clog-element style-list) - (:documentation "Set css styles using a list of list of name value pairs.")) + (:documentation "Set css styles using a list of lists of name value pairs.")) (defmethod set-styles ((obj clog-element) style-list) (jquery-execute obj (format nil "css({~{~A~^,~}})" @@ -1470,25 +1470,19 @@ parent in the DOM.")) (defmethod set-geometry ((obj clog-element) &key left top right bottom width height (units :px)) - (jquery-execute obj (format nil "css({~A~A~A~A~A~A})" - (if left - (format nil "'left':'~A~A'," left units) - "") - (if top - (format nil "'top':'~A~A'," top units) - "") - (if right - (format nil "'right':'~A~A'," right units) - "") - (if bottom - (format nil "'bottom':'~A~A'," bottom units) - "") - (if width - (format nil "'width':'~A~A'," width units) - "") - (if height - (format nil "'height':'~A~A'," height units) - "")))) + (jquery-execute obj (format nil "css({~@[~a~]~@[~a~]~@[~a~]~@[~a~]~@[~a~]~@[~a~]})" + (when left + (format nil "'left':'~A~A'," left units)) + (when top + (format nil "'top':'~A~A'," top units)) + (when right + (format nil "'right':'~A~A'," right units)) + (when bottom + (format nil "'bottom':'~A~A'," bottom units)) + (when width + (format nil "'width':'~A~A'," width units)) + (when height + (format nil "'height':'~A~A'," height units))))) ;;;;;;;;;; ;; left ;; diff --git a/source/clog-form.lisp b/source/clog-form.lisp index 3f19afb..9320be2 100644 --- a/source/clog-form.lisp +++ b/source/clog-form.lisp @@ -62,7 +62,7 @@ never be GC'd. File upload items will be a four part list (defgeneric create-form (clog-obj &key action method target encoding - class html-id auto-place) + style hidden class html-id auto-place) (:documentation "Create a new CLOG-Form as child of CLOG-OBJ that organizes a collection of form elements in to a single form if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ. In CLOG a form's on-submit handler should be @@ -78,22 +78,29 @@ doing file upload use multipart/form-data")) (method :none) (target "_self") (encoding "application/x-www-form-urlencoded") + (style nil) + (hidden nil) (class nil) (html-id nil) (auto-place t)) (create-child obj - (format nil "
" + (format nil "" action (if (eq method :none) "onSubmit='return false;'" (format nil "method='~A'" method)) encoding target - (if class - (format nil " class='~A'" - (escape-string class)) - "")) - :clog-type 'clog-form :html-id html-id :auto-place auto-place)) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) + :clog-type 'clog-form + :html-id html-id + :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;; ;; form-element-count ;; @@ -202,7 +209,7 @@ elements.")) (defgeneric create-form-element (clog-obj element-type &key name value label class - hidden html-id) + style hidden html-id) (:documentation "Create a new clog-form-element as child of CLOG-OBJ. It is importamt that clog-form-elements are a child or descendant of a clog-form in the DOM. The radio ELEMENT-TYPE groups by NAME.")) @@ -212,24 +219,21 @@ clog-form in the DOM. The radio ELEMENT-TYPE groups by NAME.")) (value nil) (label nil) (class nil) + (style nil) (hidden nil) (html-id nil)) (let ((element (create-child - obj (format nil "" + obj (format nil "" (escape-string element-type) - (if class - (format nil " class='~A'" - (escape-string class)) - "") - (if hidden - " style='visibility:hidden;'" - "") - (if value - (format nil " value='~A'" value) - "") - (if name - (format nil " name='~A'" name) - "")) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) + (when value (format nil " value='~A'" value)) + (when name (format nil " name='~A'" name))) :clog-type 'clog-form-element :html-id html-id :auto-place t))) @@ -746,21 +750,25 @@ virtual keyboards.")) ;;;;;;;;;;;;;;;;;; -(defgeneric create-label (clog-obj &key content label-for class html-id) +(defgeneric create-label (clog-obj &key content + style hidden label-for class html-id) (:documentation "Create a new clog-label as child of CLOG-OBJ.")) (defmethod create-label ((obj clog-obj) &key (content "") (label-for nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) - (create-child obj (format nil "" - (if label-for - (html-id label-for) - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "" + (when label-for (html-id label-for)) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string content)) :clog-type 'clog-label :html-id html-id :auto-place t)) @@ -785,20 +793,24 @@ virtual keyboards.")) ;; create-fieldset ;; ;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-fieldset (clog-obj &key legend class html-id) +(defgeneric create-fieldset (clog-obj &key legend hidden style class html-id) (:documentation "Create a new clog-fieldset as child of CLOG-OBJ.")) (defmethod create-fieldset ((obj clog-obj) &key (legend nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) - (create-child obj (format nil "~A" - (if class + (create-child obj (format nil "~@[~A~]" + (when class (format nil " class='~A'" - (escape-string class)) - "") - (if legend - (format nil "~A" legend) - "")) + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) + (when legend + (format nil "~A" legend))) :clog-type 'clog-fieldset :html-id html-id :auto-place t)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -813,7 +825,8 @@ virtual keyboards.")) ;;;;;;;;;;;;;;;;;;;;;; (defgeneric create-text-area (clog-obj - &key columns rows name value label class html-id) + &key columns rows name value label + style hidden class html-id) (:documentation "Create a new clog-text-area as child of CLOG-OBJ.")) (defmethod create-text-area ((obj clog-obj) @@ -822,16 +835,21 @@ virtual keyboards.")) (name "") (value "") (label nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) (let ((element (create-child obj - (format nil "" + (format nil "" name columns rows - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) (escape-string value)) :clog-type 'clog-text-area :html-id html-id :auto-place t))) @@ -928,18 +946,24 @@ virtual keyboards.")) ;; create-legend ;; ;;;;;;;;;;;;;;;;;;; -(defgeneric create-legend (clog-obj &key content class html-id) +(defgeneric create-legend (clog-obj &key content + style hidden class html-id) (:documentation "Create a new clog-legend as child of CLOG-OBJ.")) (defmethod create-legend ((obj clog-obj) &key (content "") - (class nil) - (html-id nil)) - (create-child obj (format nil "~A" - (if class + (style nil) + (hidden nil) + (class nil) + (html-id nil)) + (create-child obj (format nil "~A" + (when class (format nil " class='~A'" - (escape-string class)) - "") - content) + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) + (escape-string content)) :clog-type 'clog-legend :html-id html-id :auto-place t)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -999,28 +1023,30 @@ optionally fill in with contents of data-list.")) ;; create-select ;; ;;;;;;;;;;;;;;;;;;; -(defgeneric create-select (clog-obj &key name multiple label class html-id) +(defgeneric create-select (clog-obj &key name multiple label + style hidden class html-id) (:documentation "Create a new clog-select as child of CLOG-OBJ.")) (defmethod create-select ((obj clog-obj) &key (name nil) (multiple nil) (label nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) (let ((element (create-child - obj (format nil "" - (if multiple - " multiple" - "") - (if name - (format nil " name='~A'" name) - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "")) - :clog-type 'clog-select :html-id html-id :auto-place t))) + obj (format nil "" + (when multiple " multiple") + (when name (format nil " name='~A'" name)) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style))) + :clog-type 'clog-select :html-id html-id :auto-place t))) (when label (label-for label element)) element)) @@ -1033,13 +1059,9 @@ optionally fill in with contents of data-list.")) (:documentation "Add option VALUE to select.")) (defmethod add-select-option ((obj clog-select) value content &key selected disabled) - (create-child obj (format nil "~A" - (if selected - " selected" - "") - (if disabled - " disabled" - "") + (create-child obj (format nil "~A" + (when selected " selected") + (when disabled " disabled") (escape-string value) (escape-string content)) :clog-type 'clog-element :auto-place t)) @@ -1091,7 +1113,8 @@ or CLOG Data-List objects.")); ;;;;;;;;;;;;;;;;;;; (defgeneric create-option (clog-obj - &key content value selected disabled class html-id) + &key content value selected disabled + style hidden class html-id) (:documentation "Create a new clog-option as child of CLOG-OBJ.")) (defmethod create-option ((obj clog-obj) &key @@ -1099,22 +1122,22 @@ or CLOG Data-List objects.")); (value nil) (selected nil) (disabled nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) - (create-child obj (format nil "~A" - (if selected - " selected" - "") - (if disabled - " disabled" - "") - (if value - (format nil " value='~A'" value) - "") - (if class - (format nil " class='~A'" - (escape-string class)) - "") + (create-child obj (format nil "~A" + (when selected " selected") + (when disabled " disabled") + (when value (format nil " value='~A'" + (escape-string value))) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) content) :clog-type 'clog-option :html-id html-id :auto-place t)) @@ -1146,20 +1169,24 @@ or CLOG Data-List objects.")); ;; create-optgroup ;; ;;;;;;;;;;;;;;;;;;;;; -(defgeneric create-optgroup (clog-obj &key content disabled html-id) +(defgeneric create-optgroup (clog-obj &key content disabled + style hidden class html-id) (:documentation "Create a new clog-optgroup as child of CLOG-OBJ.")) (defmethod create-optgroup ((obj clog-obj) &key (content "") (disabled nil) + (style nil) + (hidden nil) (class nil) (html-id nil)) - (create-child obj (format nil "" + (create-child obj (format nil "" content - (if class - (format nil " class='~A'" - (escape-string class)) - "") - (if disabled - " disabled" - "")) + (when class + (format nil " class='~A'" + (escape-string class))) + (when (or hidden style) + (format nil " style='~@[~a~]~@[~a~]'" + (when hidden "visibility:hidden;") + style)) + (when disabled " disabled")) :clog-type 'clog-optgroup :html-id html-id :auto-place t))