mirror of
https://github.com/rabbibotton/clog.git
synced 2026-01-05 16:51:33 -08:00
Ability to handle plugin custom controls
This commit is contained in:
parent
26ee03c937
commit
99db046549
2 changed files with 71 additions and 57 deletions
|
|
@ -1658,7 +1658,14 @@
|
||||||
:attr "data-clog-one-row-limit")
|
:attr "data-clog-one-row-limit")
|
||||||
(:name "join to slot-name (optional)"
|
(:name "join to slot-name (optional)"
|
||||||
:attr "data-clog-one-row-master")
|
:attr "data-clog-one-row-master")
|
||||||
,@*props-form-element*))))
|
,@*props-form-element*))
|
||||||
|
'(:name "group"
|
||||||
|
:description "custom controls"
|
||||||
|
:create nil
|
||||||
|
:create-type nil
|
||||||
|
:events nil
|
||||||
|
:properties nil)))
|
||||||
|
|
||||||
|
|
||||||
(defparameter *supported-templates*
|
(defparameter *supported-templates*
|
||||||
(list
|
(list
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@
|
||||||
(defun remove-deleted-from-control-list (app panel-id)
|
(defun remove-deleted-from-control-list (app panel-id)
|
||||||
"Remove any deleted control from control-list"
|
"Remove any deleted control from control-list"
|
||||||
(maphash (lambda (html-id control)
|
(maphash (lambda (html-id control)
|
||||||
(when (equalp (clog:js-query control (format nil "$.contains(document.documentElement, ~A)"
|
(when (equalp (js-query control (format nil "$.contains(document.documentElement, ~A)"
|
||||||
(clog::script-id control))) "false")
|
(clog::script-id control))) "false")
|
||||||
(remove-from-control-list app panel-id html-id)))
|
(remove-from-control-list app panel-id html-id)))
|
||||||
(get-control-list app panel-id)))
|
(get-control-list app panel-id)))
|
||||||
|
|
||||||
|
|
@ -179,7 +179,7 @@
|
||||||
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
||||||
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
||||||
z.html()"
|
z.html()"
|
||||||
(clog::jquery content)))
|
(jquery content)))
|
||||||
fname)
|
fname)
|
||||||
(destroy data))
|
(destroy data))
|
||||||
(maphash
|
(maphash
|
||||||
|
|
@ -387,7 +387,7 @@ create-div's"
|
||||||
(place-after control placer)
|
(place-after control placer)
|
||||||
(setf (box-sizing placer) :content-box)
|
(setf (box-sizing placer) :content-box)
|
||||||
(setf (positioning placer) :absolute)
|
(setf (positioning placer) :absolute)
|
||||||
(clog::jquery-execute placer "draggable().resizable()")
|
(jquery-execute placer "draggable().resizable()")
|
||||||
;; setup control events
|
;; setup control events
|
||||||
(set-on-focus control (lambda (obj)
|
(set-on-focus control (lambda (obj)
|
||||||
(declare (ignore obj))
|
(declare (ignore obj))
|
||||||
|
|
@ -403,23 +403,23 @@ create-div's"
|
||||||
(when win
|
(when win
|
||||||
(window-focus win)))
|
(window-focus win)))
|
||||||
:cancel-event t)
|
:cancel-event t)
|
||||||
(clog::set-on-event placer "resizestop"
|
(set-on-event placer "resizestop"
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(set-geometry control :units ""
|
(set-geometry control :units ""
|
||||||
:width (width placer)
|
:width (width placer)
|
||||||
:height (height placer))
|
:height (height placer))
|
||||||
(set-geometry placer :units ""
|
(set-geometry placer :units ""
|
||||||
:width (client-width control)
|
:width (client-width control)
|
||||||
:height (client-height control))
|
:height (client-height control))
|
||||||
(on-populate-control-properties-win content :win win)))
|
(on-populate-control-properties-win content :win win)))
|
||||||
(clog::set-on-event placer "dragstop"
|
(set-on-event placer "dragstop"
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(set-geometry control :units ""
|
(set-geometry control :units ""
|
||||||
:top (top placer)
|
:top (top placer)
|
||||||
:left (left placer))
|
:left (left placer))
|
||||||
(set-geometry placer :top (top control)
|
(set-geometry placer :top (top control)
|
||||||
:left (left control))
|
:left (left control))
|
||||||
(on-populate-control-properties-win content :win win)))))
|
(on-populate-control-properties-win content :win win)))))
|
||||||
|
|
||||||
;; Control selection utilities
|
;; Control selection utilities
|
||||||
|
|
||||||
|
|
@ -479,7 +479,7 @@ not a temporary attached one when using select-control."
|
||||||
~{~A~}~
|
~{~A~}~
|
||||||
if(e.attr('data-clog-type') === undefined){e.attr('data-clog-type','span')}})"
|
if(e.attr('data-clog-type') === undefined){e.attr('data-clog-type','span')}})"
|
||||||
panel-uid
|
panel-uid
|
||||||
(clog::jquery parent)
|
(jquery parent)
|
||||||
(if paste
|
(if paste
|
||||||
(prog1
|
(prog1
|
||||||
(format nil "e.attr('data-clog-name', e.attr('data-clog-name')+'-'+~A);"
|
(format nil "e.attr('data-clog-name', e.attr('data-clog-name')+'-'+~A);"
|
||||||
|
|
@ -490,7 +490,7 @@ not a temporary attached one when using select-control."
|
||||||
(format nil "if(p === undefined && t=='~A'){e.attr('data-clog-type','~A')}"
|
(format nil "if(p === undefined && t=='~A'){e.attr('data-clog-type','~A')}"
|
||||||
(getf l :tag) (getf l :control)))
|
(getf l :tag) (getf l :control)))
|
||||||
*import-types*))))
|
*import-types*))))
|
||||||
(clog::js-execute parent tmp))
|
(js-execute parent tmp))
|
||||||
(let* ((data (first-child content))
|
(let* ((data (first-child content))
|
||||||
(name (attribute data "data-clog-title"))
|
(name (attribute data "data-clog-title"))
|
||||||
(next-id (attribute data "data-clog-next-id"))
|
(next-id (attribute data "data-clog-next-id"))
|
||||||
|
|
@ -544,51 +544,58 @@ not a temporary attached one when using select-control."
|
||||||
(setf dct (attribute control "data-clog-name"))
|
(setf dct (attribute control "data-clog-name"))
|
||||||
(unless (equal dct "undefined")
|
(unless (equal dct "undefined")
|
||||||
(setf control (get-from-control-list app panel-id (html-id control)))
|
(setf control (get-from-control-list app panel-id (html-id control)))
|
||||||
(let ((vname (attribute control "data-clog-name")))
|
(let ((vname (attribute control "data-clog-name"))
|
||||||
|
(control-record (control-info (attribute control "data-clog-type"))))
|
||||||
(unless (and (>= (length vname) 5)
|
(unless (and (>= (length vname) 5)
|
||||||
(equalp (subseq vname 0 5) "none-"))
|
(equalp (subseq vname 0 5) "none-"))
|
||||||
|
;; Add to members of the panel's class for each control
|
||||||
(push (format nil
|
(push (format nil
|
||||||
" \(~A :reader ~A\)~%"
|
" \(~A :reader ~A\)~%"
|
||||||
vname
|
vname
|
||||||
vname)
|
vname)
|
||||||
cmembers)
|
cmembers)
|
||||||
|
;; On instance of class, set member value for each control
|
||||||
(push (format nil
|
(push (format nil
|
||||||
" \(setf (slot-value panel '~A\) ~
|
" \(setf (slot-value panel '~A\) ~
|
||||||
\(attach-as-child clog-obj \"~A\" :clog-type \'~A\ :new-id t)\)~%"
|
\(attach-as-child clog-obj \"~A\" :clog-type \'~A\ :new-id t)\)~%"
|
||||||
vname
|
vname
|
||||||
(html-id control)
|
(html-id control)
|
||||||
(format nil "CLOG:~A" (type-of control)))
|
(format nil "~S" (getf control-record :clog-type)))
|
||||||
vars)
|
vars)
|
||||||
(let ((control-record (control-info (attribute control "data-clog-type"))))
|
;; On instance of class, set handers defined for each control
|
||||||
(dolist (event (getf control-record :events))
|
(dolist (event (getf control-record :events))
|
||||||
(let ((handler (attribute control (format nil "data-~A" (getf event :name)))))
|
;; Set regular handlers
|
||||||
(unless (or (equalp handler "undefined")
|
(let ((handler (attribute control (format nil "data-~A" (getf event :name)))))
|
||||||
(equal handler ""))
|
(unless (or (equalp handler "undefined")
|
||||||
(unless (equalp (getf event :name) "on-create")
|
(equal handler ""))
|
||||||
|
(unless (equalp (getf event :name) "on-create")
|
||||||
|
(let ((event-package (or (getf event :package) "clog")))
|
||||||
(push (format nil
|
(push (format nil
|
||||||
" \(set-~A \(~A panel\) \(lambda \(~A\) \(declare \(ignorable ~A\)\) ~A\)\)~%"
|
" \(~A:set-~A \(~A panel\) \(lambda \(~A\) \(declare \(ignorable ~A\)\) ~A\)\)~%"
|
||||||
(getf event :name)
|
event-package
|
||||||
vname
|
(getf event :name)
|
||||||
(getf event :parameters)
|
vname
|
||||||
(getf event :parameters)
|
(getf event :parameters)
|
||||||
handler)
|
(getf event :parameters)
|
||||||
events)))))
|
handler)
|
||||||
(let ((handler (attribute control "data-on-create")))
|
events))))))
|
||||||
(when (equalp handler "undefined")
|
;; Set on-create (from user in builder) and on-setup (from control-record)
|
||||||
(setf handler ""))
|
(let ((handler (attribute control "data-on-create")))
|
||||||
(when (getf control-record :on-setup)
|
(when (equalp handler "undefined")
|
||||||
(setf handler (format nil "~A~A"
|
(setf handler ""))
|
||||||
(funcall (getf control-record :on-setup)
|
(when (getf control-record :on-setup)
|
||||||
control control-record)
|
(setf handler (format nil "~A~A"
|
||||||
handler)))
|
(funcall (getf control-record :on-setup)
|
||||||
(unless (equal handler "")
|
control control-record)
|
||||||
(push (format nil
|
handler)))
|
||||||
" \(let \(\(target \(~A panel\)\)\) ~
|
(unless (equal handler "")
|
||||||
|
(push (format nil
|
||||||
|
" \(let \(\(target \(~A panel\)\)\) ~
|
||||||
\(declare \(ignorable target\)\) ~
|
\(declare \(ignorable target\)\) ~
|
||||||
~A\)~%"
|
~A\)~%"
|
||||||
vname
|
vname
|
||||||
handler)
|
handler)
|
||||||
events))))))
|
events)))))
|
||||||
(add-siblings (first-child control)))
|
(add-siblings (first-child control)))
|
||||||
(setf control (next-sibling control))))))
|
(setf control (next-sibling control))))))
|
||||||
(add-siblings (first-child content)))
|
(add-siblings (first-child content)))
|
||||||
|
|
@ -610,7 +617,7 @@ not a temporary attached one when using select-control."
|
||||||
"var z=~a.clone();~
|
"var z=~a.clone();~
|
||||||
z.find('*').each(function(){for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}});~
|
z.find('*').each(function(){for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}});~
|
||||||
z.html()"
|
z.html()"
|
||||||
(clog::jquery content)))
|
(jquery content)))
|
||||||
"\\\"")
|
"\\\"")
|
||||||
cname
|
cname
|
||||||
vars
|
vars
|
||||||
|
|
@ -729,7 +736,7 @@ not a temporary attached one when using select-control."
|
||||||
,(lambda (obj)
|
,(lambda (obj)
|
||||||
(place-inside-bottom-of
|
(place-inside-bottom-of
|
||||||
(attach-as-child control
|
(attach-as-child control
|
||||||
(clog::js-query
|
(js-query
|
||||||
control
|
control
|
||||||
(format nil "$(\"[data-clog-name='~A']\").attr('id')"
|
(format nil "$(\"[data-clog-name='~A']\").attr('id')"
|
||||||
(text obj))))
|
(text obj))))
|
||||||
|
|
@ -1023,7 +1030,7 @@ of controls and double click to select control."
|
||||||
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
||||||
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
||||||
z.html()"
|
z.html()"
|
||||||
(clog::jquery (current-control app)))))
|
(jquery (current-control app)))))
|
||||||
(maphash
|
(maphash
|
||||||
(lambda (html-id control)
|
(lambda (html-id control)
|
||||||
(declare (ignore html-id))
|
(declare (ignore html-id))
|
||||||
|
|
@ -1235,7 +1242,7 @@ of controls and double click to select control."
|
||||||
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
z.find('*').each(function(){if($(this).attr('id') !== undefined && ~
|
||||||
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
||||||
z.html()"
|
z.html()"
|
||||||
(clog::jquery (current-control app)))))
|
(jquery (current-control app)))))
|
||||||
(maphash
|
(maphash
|
||||||
(lambda (html-id control)
|
(lambda (html-id control)
|
||||||
(declare (ignore html-id))
|
(declare (ignore html-id))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue