File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 30373037 return cradio
30383038 }
30393039
3040+ function fieldset ( args ) { // a form fieldset
3041+ if ( ! ( this instanceof fieldset ) ) return new fieldset ( args ) // so fieldset() is like new fieldset()
3042+ var cvs = canvas . get_selected ( )
3043+ var attrs = { pos :cvs . caption_anchor , legend :'' , width :cvs . width }
3044+
3045+ for ( a in attrs ) {
3046+ if ( args [ a ] !== undefined ) {
3047+ attrs [ a ] = args [ a ]
3048+ delete args [ a ]
3049+ }
3050+ }
3051+
3052+ let fs_css = { width :`${ attrs . width } px` }
3053+ attrs . jfieldset = $ ( '<fieldset>' ) . css ( fs_css ) . appendTo ( attrs . pos )
3054+ $ ( `<legend>${ attrs . legend } </legend>` ) . appendTo ( attrs . jfieldset )
3055+
3056+ var cfieldset = { // this structure implements a JavaScript "closure"
3057+ get legend ( ) {
3058+ if ( attrs . legend === undefined ) return ""
3059+ return attrs . legend
3060+ } ,
3061+ set legend ( value ) {
3062+ throw new Error ( "Cannot change a fieldsets legend." )
3063+ } ,
3064+ get pos ( ) {
3065+ return attrs . jfieldset
3066+ } ,
3067+ set pos ( value ) {
3068+ throw new Error ( "Cannot change a fieldsets pos." )
3069+ }
3070+ }
3071+
3072+ return cfieldset
3073+ }
3074+
3075+
30403076 function checkbox ( args ) { // a checkbox
30413077 if ( ! ( this instanceof checkbox ) ) return new checkbox ( args ) // so checkbox() is like new checkbox()
30423078 var cvs = canvas . get_selected ( )
36833719 wtext : wtext ,
36843720 winput : winput ,
36853721 radio : radio ,
3722+ fieldset :fieldset ,
36863723 checkbox : checkbox ,
36873724 button : button ,
36883725 slider : slider ,
You can’t perform that action at this time.
0 commit comments