Documentation
¶
Overview ¶
Package named provides named boolean values and collections used by select, option and radio widgets.
Index ¶
- func WriteHTMLSelect(w io.Writer, jid jid.Jid, nba *BoolArray, attrs []template.HTMLAttr) (err error)
- type Bool
- func (nb *Bool) Array() *BoolArray
- func (nb *Bool) Checked() (checked bool)
- func (nb *Bool) HTML() (h template.HTML)
- func (nb *Bool) JawsGet(elem *jaws.Element) (yes bool)
- func (nb *Bool) JawsGetHTML(elem *jaws.Element) (h template.HTML)
- func (nb *Bool) JawsSet(elem *jaws.Element, checked bool) (err error)
- func (nb *Bool) Name() (s string)
- func (nb *Bool) Set(checked bool) (changed bool)
- func (nb *Bool) String() string
- type BoolArray
- func (nba *BoolArray) Add(name string, text template.HTML) *BoolArray
- func (nba *BoolArray) Count(name string) (n int)
- func (nba *BoolArray) Get() (name string)
- func (nba *BoolArray) IsChecked(name string) (state bool)
- func (nba *BoolArray) JawsContains(elem *jaws.Element) (contents []jaws.UI)
- func (nba *BoolArray) JawsGet(elem *jaws.Element) string
- func (nba *BoolArray) JawsSet(elem *jaws.Element, name string) (err error)
- func (nba *BoolArray) ReadLocked(fn func(nbl []*Bool))
- func (nba *BoolArray) Set(name string, state bool) (changed bool)
- func (nba *BoolArray) String() string
- func (nba *BoolArray) WriteLocked(fn func(nbl []*Bool) []*Bool)
- type SelectHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool stores a named boolean value with an HTML representation.
Bool values are safe for concurrent use.
func NewBool ¶
NewBool returns a Bool with the given name, HTML and checked state.
If nba is non-nil, changing the value through Bool.JawsSet may dirty the containing BoolArray and deselect sibling values in single-select mode.
func (*Bool) JawsGetHTML ¶
JawsGetHTML returns the trusted HTML label for nb.
type BoolArray ¶
type BoolArray struct {
// contains filtered or unexported fields
}
BoolArray stores the data required to support HTML select elements and sets of HTML radio buttons. It is safe to use from multiple goroutines concurrently.
func NewBoolArray ¶
NewBoolArray returns an empty BoolArray.
If multi is false, setting one value clears other names in the array. If multi is true, multiple values may be checked at the same time.
func (*BoolArray) Add ¶
Add adds a Bool with the given name and trusted HTML text. Returns itself.
Note that while it is legal to have multiple Bool values with the same name because HTML allows it, it is usually not a good idea.
func (*BoolArray) Count ¶
Count returns the number of Bool values in the set that have the given name.
func (*BoolArray) Get ¶
Get returns the name of the first Bool in the group that has its checked value set to true. Returns an empty string if none are true.
In case you can have more than one selected or you need to distinguish between a blank name and the fact that none are set to true, use BoolArray.ReadLocked to inspect the data directly.
func (*BoolArray) IsChecked ¶
IsChecked returns true if any Bool in the set with the given name are Checked. Returns false if the name is not found.
func (*BoolArray) JawsContains ¶
JawsContains returns the option widgets for a select backed by nba.
func (*BoolArray) ReadLocked ¶
ReadLocked calls fn with the BoolArray locked for reading.
func (*BoolArray) Set ¶
Set sets the checked state for Bool values with the given name.
If the given name does not match any values in single-select mode, everything will be deselected.