Documentation ¶
Index ¶
- Variables
- type AddClasses
- type Element
- func (e *Element) AddEventListener(event string, callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) Animate(keyframes []interface{}, options map[string]interface{}) jsext.Value
- func (e *Element) AppendChild(children ...*Element) *Element
- func (e *Element) AttrAccept(v string) *Element
- func (e *Element) AttrAcceptCharset(v string) *Element
- func (e *Element) AttrAccessKey(v string) *Element
- func (e *Element) AttrAction(v string) *Element
- func (e *Element) AttrAlt(v string) *Element
- func (e *Element) AttrAsync(v string) *Element
- func (e *Element) AttrAutocomplete(v string) *Element
- func (e *Element) AttrAutofocus(v string) *Element
- func (e *Element) AttrAutoplay(v string) *Element
- func (e *Element) AttrCharset(v string) *Element
- func (e *Element) AttrChecked(v bool) *Element
- func (e *Element) AttrCite(v string) *Element
- func (e *Element) AttrDisabled(v bool) *Element
- func (e *Element) AttrDownload(v string) *Element
- func (e *Element) AttrEncType(v string) *Element
- func (e *Element) AttrFor(v string) *Element
- func (e *Element) AttrHeight(v string) *Element
- func (e *Element) AttrHref(v string) *Element
- func (e *Element) AttrID(v string) *Element
- func (e *Element) AttrName(v string) *Element
- func (e *Element) AttrPlaceholder(v string) *Element
- func (e *Element) AttrReadOnly(v bool) *Element
- func (e *Element) AttrRequired(v bool) *Element
- func (e *Element) AttrSelected(v bool) *Element
- func (e *Element) AttrSrc(v string) *Element
- func (e *Element) AttrType(v string) *Element
- func (e *Element) AttrValue(v string) *Element
- func (e *Element) AttrWidth(v string) *Element
- func (e *Element) Attrs(m map[string]interface{}) *Element
- func (e *Element) Bool() bool
- func (e *Element) Call(m string, args ...any) jsext.Value
- func (e *Element) CallFunc(name string, args ...interface{})
- func (e *Element) Children() []*Element
- func (e *Element) ClassList(s ...string) jsext.Value
- func (e *Element) ClearInnerHTML()
- func (e *Element) ClientHeight() int
- func (e *Element) ClientLeft() int
- func (e *Element) ClientTop() int
- func (e *Element) ClientWidth() int
- func (e *Element) Dataset() jsext.Value
- func (e *Element) DelAttr(p string) *Element
- func (e *Element) Delete(p string)
- func (e *Element) EditState(value interface{}) error
- func (e *Element) Element() jsext.Element
- func (e *Element) Equal(other js.Value) bool
- func (e *Element) FirstElementChild() Element
- func (e *Element) Float() float64
- func (e *Element) Get(p string) jsext.Value
- func (e *Element) GetAttr(p string) string
- func (e *Element) GetElementById(id string) *Element
- func (e *Element) GetElementsByClassName(className string) *Element
- func (e *Element) GetElementsByTagName(tagName string) *Element
- func (e *Element) Height() int
- func (e *Element) Index(i int) jsext.Value
- func (e *Element) InlineClasses(classes ...string) *Element
- func (e *Element) InnerHTML(s string) *Element
- func (e *Element) InnerText(s string) *Element
- func (e *Element) InsertBefore(element, before *Element)
- func (e *Element) Int() int
- func (e *Element) Invoke(args ...any) jsext.Value
- func (e *Element) IsNaN() bool
- func (e *Element) IsNull() bool
- func (e *Element) IsUndefined() bool
- func (e *Element) IsZero() bool
- func (e *Element) JSValue() js.Value
- func (e *Element) Key() string
- func (e *Element) Length() int
- func (e *Element) MapDataset() map[string]string
- func (e *Element) MarshalJS() js.Value
- func (e *Element) NewElement(typ string, innerText ...string) *Element
- func (e *Element) NodeName() string
- func (e *Element) OnBlur(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnChange(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnClick(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnFocus(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnHoldClick(wait time.Duration, repeat time.Duration, ...) *Element
- func (e *Element) OnHoldKey(wait time.Duration, repeat time.Duration, f func(*Element, jsext.Event)) *Element
- func (e *Element) OnKeyDown(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnKeyPress(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnKeyUp(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseDown(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseEnter(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseLeave(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseMove(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseOut(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseOver(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnMouseUp(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnScroll(callback func(this *Element, event jsext.Event)) js.Func
- func (e *Element) OnScrolledToBottom(callEach time.Duration, pxFromBottom int, f func(*Element, jsext.Event)) js.Func
- func (e *Element) ParentElement() *Element
- func (e *Element) PrependChild(children ...*Element) *Element
- func (e *Element) Remove()
- func (e *Element) RemoveChildren(children ...*Element) *Element
- func (e *Element) Replace(elem *Element)
- func (e *Element) ReplaceChild(element, before *Element)
- func (e *Element) ScrollHeight() int
- func (e *Element) ScrollIntoView(center bool)
- func (e *Element) ScrollIntoViewIfNeeded(center bool)
- func (e *Element) ScrollLeft() int
- func (e *Element) ScrollTo(x, y int)
- func (e *Element) ScrollTop() int
- func (e *Element) ScrollWidth() int
- func (e *Element) Set(p string, x any)
- func (e *Element) SetAttr(p string, s ...string) *Element
- func (e *Element) SetAttrMap(m map[string]string) *Element
- func (e *Element) SetIndex(i int, x any)
- func (e *Element) SetKey(key string) *Element
- func (e *Element) String() string
- func (e *Element) Style() jsext.Style
- func (e *Element) Truthy() bool
- func (e *Element) Type() js.Type
- func (e *Element) Value() jsext.Value
- func (e *Element) Width() int
- type FormElement
- func (e *FormElement) AppendChild(children ...*Element) *FormElement
- func (e *FormElement) AttrDisabled(v bool) *FormElement
- func (e *FormElement) AttrFor(v string) *FormElement
- func (e *FormElement) AttrID(v string) *FormElement
- func (e *FormElement) AttrName(v string) *FormElement
- func (e *FormElement) AttrPlaceholder(v string) *FormElement
- func (e *FormElement) AttrReadOnly(v bool) *FormElement
- func (e *FormElement) AttrRequired(v bool) *FormElement
- func (e *FormElement) AttrType(v string) *FormElement
- func (e *FormElement) AttrValue(v string) *FormElement
- func (e *FormElement) Bool() bool
- func (e *FormElement) Button(innerText string, onClick func(this *Element, event jsext.Event)) *FormElement
- func (e *FormElement) Call(m string, args ...any) jsext.Value
- func (e *FormElement) ClassList(classes ...string) jsext.Value
- func (e *FormElement) DelAttr(key string) *FormElement
- func (e *FormElement) Delete(p string)
- func (e *FormElement) Element() *Element
- func (e *FormElement) Elements() []*FormElement
- func (e *FormElement) Equal(other js.Value) bool
- func (e *FormElement) Field(name string) *FormElement
- func (e *FormElement) Fields(name string) []*FormElement
- func (e *FormElement) Float() float64
- func (e *FormElement) FormGroup(classes ...string) *FormElement
- func (e *FormElement) Get(p string) jsext.Value
- func (e *FormElement) ID(s string) *FormElement
- func (e *FormElement) Index(i int) jsext.Value
- func (e *FormElement) Input(t, name string, opts *InputOptions) *FormElement
- func (e *FormElement) Int() int
- func (e *FormElement) Invoke(args ...any) jsext.Value
- func (e *FormElement) IsNaN() bool
- func (e *FormElement) IsNull() bool
- func (e *FormElement) IsUndefined() bool
- func (e *FormElement) IsZero() bool
- func (e *FormElement) JSValue() js.Value
- func (e *FormElement) Label(forElement, text string, classes ...string) *FormElement
- func (e *FormElement) Length() int
- func (e *FormElement) Name() string
- func (e *FormElement) OnSubmit(f func(this *Element, event jsext.Event, v url.Values)) js.Func
- func (e *FormElement) Reset() *FormElement
- func (e *FormElement) Set(p string, x any)
- func (e *FormElement) SetAttr(key, value string) *FormElement
- func (e *FormElement) SetIndex(i int, x any)
- func (e *FormElement) String() string
- func (e *FormElement) TextArea(name string, opts *InputOptions) *FormElement
- func (e *FormElement) TimeInput(name string, h, m, s int, opts *InputOptions) *Timer
- func (e *FormElement) Truthy() bool
- func (e *FormElement) Type() js.Type
- func (e *FormElement) Value() string
- type InnerHTML
- type InnerText
- type InputOptions
- type JavascriptConstraint
- type OptionElement
- type RemoveClasses
- type SVG
- func (s *SVG) Element() *Element
- func (s *SVG) Fill(color string) *SVG
- func (s *SVG) Height(height int) *SVG
- func (s *SVG) NewElement(name string) *Element
- func (s *SVG) SetAttr(name, value string) *SVG
- func (s *SVG) ViewBox(x, y, width, height int) *SVG
- func (s *SVG) Width(width int) *SVG
- func (s *SVG) XMLNS(u string) *SVG
- type SelectElement
- func (s *SelectElement) AddEventListener(name string, listener func(this *Element, event jsext.Event)) *SelectElement
- func (s *SelectElement) Append(child any) *SelectElement
- func (s *SelectElement) ClassList(cls ...string) jsext.Value
- func (s *SelectElement) Element() *Element
- func (s *SelectElement) FormValue() string
- func (s *SelectElement) InlineClasses(classes ...string) *SelectElement
- func (s *SelectElement) OnChange(listener func(this *Element, event jsext.Event)) *SelectElement
- func (s *SelectElement) Option(text, value string, selected ...bool) *OptionElement
- func (s *SelectElement) Set(name string, value any) *SelectElement
- func (s *SelectElement) Value() jsext.Value
- type Value
Constants ¶
This section is empty.
Variables ¶
var AUTO_KEY func(n int) string // = jsrand.String
AUTO_KEY is a function that returns a random string.
This can be used to manage state more easily, essentially providing each element with a unique id.
Functions ¶
This section is empty.
Types ¶
type AddClasses ¶ added in v2.7.2
type AddClasses []string
type Element ¶
type Element jsext.Element
func Make ¶
func Make[T JavascriptConstraint](e T) *Element
func (*Element) AddEventListener ¶
func (e *Element) AddEventListener(event string, callback func(this *Element, event jsext.Event)) js.Func
Add an event listener to the Element
This will return the function that was added to the element.
func (*Element) AppendChild ¶
func (*Element) AttrAccept ¶
func (*Element) AttrAcceptCharset ¶
func (*Element) AttrAccessKey ¶
func (*Element) AttrAction ¶
func (*Element) AttrAutocomplete ¶
func (*Element) AttrAutofocus ¶
func (*Element) AttrAutoplay ¶
func (*Element) AttrCharset ¶
func (*Element) AttrChecked ¶
func (*Element) AttrDisabled ¶
func (*Element) AttrDownload ¶
func (*Element) AttrEncType ¶
func (*Element) AttrHeight ¶
func (*Element) AttrPlaceholder ¶
func (*Element) AttrReadOnly ¶
func (*Element) AttrRequired ¶
func (*Element) AttrSelected ¶
func (*Element) Bool ¶
/////////////////////////////////////////////////////////
js.Value methods.
/////////////////////////////////////////////////////////
func (*Element) ClearInnerHTML ¶
func (e *Element) ClearInnerHTML()
func (*Element) ClientHeight ¶
Get the clientHeight of the Element
func (*Element) ClientWidth ¶
Get the clientWidth of the Element
func (*Element) FirstElementChild ¶
Get the *Element's first child.
func (*Element) GetElementById ¶
Get an inner element by ID.
func (*Element) GetElementsByClassName ¶
Get an inner element by class name.
func (*Element) GetElementsByTagName ¶
Get an inner element by tag name.
func (*Element) InlineClasses ¶
func (*Element) InsertBefore ¶
Insert the *Element before the before Element
func (*Element) IsUndefined ¶
func (*Element) MapDataset ¶
Return the *Element's dataset as map
func (*Element) OnHoldClick ¶
func (e *Element) OnHoldClick(wait time.Duration, repeat time.Duration, f func(this *Element, event jsext.Event)) *Element
OnHoldClick adds an event listener to the Element
wait is the time to wait after the first click before starting to repeat repeat is the time between each function call
Optionally, the function can call event.Get("stopTimer").Invoke() to stop the timer
func (*Element) OnHoldKey ¶
func (e *Element) OnHoldKey(wait time.Duration, repeat time.Duration, f func(*Element, jsext.Event)) *Element
OnHoldKey adds an event listener to the Element
wait is the time to wait before the first repeat repeat is the time between each function call
Optionally, the function can call event.Get("stopTimer").Invoke() to stop the timer
func (*Element) OnKeyPress ¶
OnKeyPress adds an event listener to the Element
func (*Element) OnMouseDown ¶
OnMouseDown adds an event listener to the Element
func (*Element) OnMouseEnter ¶
OnMouseEnter adds an event listener to the Element
func (*Element) OnMouseLeave ¶
OnMouseLeave adds an event listener to the Element
func (*Element) OnMouseMove ¶
OnMouseMove adds an event listener to the Element
func (*Element) OnMouseOut ¶
OnMouseOut adds an event listener to the Element
func (*Element) OnMouseOver ¶
OnMouseOver adds an event listener to the Element
func (*Element) OnScrolledToBottom ¶ added in v2.5.2
func (e *Element) OnScrolledToBottom(callEach time.Duration, pxFromBottom int, f func(*Element, jsext.Event)) js.Func
OnScrolledToBottom adds an event listener to the Element
callEach is the minimum time between each function call
pxFromBottom is the number of pixels from the bottom of the element to call the function
func (*Element) PrependChild ¶
func (*Element) RemoveChildren ¶
RemoveChildren removes multiple children from the Element
func (*Element) ReplaceChild ¶
Replace the *Element with the before Element
func (*Element) ScrollHeight ¶
Get the scroll height of the Element
func (*Element) ScrollIntoView ¶
Scroll the *Element into view.
func (*Element) ScrollIntoViewIfNeeded ¶
Scroll the *Element into view if needed.
func (*Element) ScrollWidth ¶
Get the scroll width of the Element
type FormElement ¶
type FormElement Element
func Form ¶
func Form(action, method, id string) *FormElement
Form returns a form with the action, method, and id specified.
func (*FormElement) AppendChild ¶
func (e *FormElement) AppendChild(children ...*Element) *FormElement
func (*FormElement) AttrDisabled ¶
func (e *FormElement) AttrDisabled(v bool) *FormElement
func (*FormElement) AttrFor ¶
func (e *FormElement) AttrFor(v string) *FormElement
func (*FormElement) AttrID ¶
func (e *FormElement) AttrID(v string) *FormElement
func (*FormElement) AttrName ¶
func (e *FormElement) AttrName(v string) *FormElement
func (*FormElement) AttrPlaceholder ¶
func (e *FormElement) AttrPlaceholder(v string) *FormElement
func (*FormElement) AttrReadOnly ¶
func (e *FormElement) AttrReadOnly(v bool) *FormElement
func (*FormElement) AttrRequired ¶
func (e *FormElement) AttrRequired(v bool) *FormElement
func (*FormElement) AttrType ¶
func (e *FormElement) AttrType(v string) *FormElement
func (*FormElement) AttrValue ¶
func (e *FormElement) AttrValue(v string) *FormElement
func (*FormElement) Bool ¶
func (e *FormElement) Bool() bool
/////////////////////////////////////////////////////////
js.Value methods.
/////////////////////////////////////////////////////////
func (*FormElement) Button ¶
func (e *FormElement) Button(innerText string, onClick func(this *Element, event jsext.Event)) *FormElement
Button returns a button with the text and classes specified.
func (*FormElement) Call ¶
func (e *FormElement) Call(m string, args ...any) jsext.Value
func (*FormElement) ClassList ¶
func (e *FormElement) ClassList(classes ...string) jsext.Value
func (*FormElement) DelAttr ¶
func (e *FormElement) DelAttr(key string) *FormElement
func (*FormElement) Delete ¶
func (e *FormElement) Delete(p string)
func (*FormElement) Element ¶
func (e *FormElement) Element() *Element
Value returns as a Value(js.Value) wrapper.
func (*FormElement) Elements ¶ added in v2.7.2
func (e *FormElement) Elements() []*FormElement
Elements returns all the elements of the form, keyed by their name.
func (*FormElement) Field ¶ added in v2.7.2
func (e *FormElement) Field(name string) *FormElement
GetElements returns the elements of the form, keyed by their name.
func (*FormElement) Fields ¶ added in v2.7.2
func (e *FormElement) Fields(name string) []*FormElement
Fields returns all fields of the form which have the name specified.
func (*FormElement) Float ¶
func (e *FormElement) Float() float64
func (*FormElement) FormGroup ¶
func (e *FormElement) FormGroup(classes ...string) *FormElement
FormGroup returns a div with the classes specified.
func (*FormElement) Get ¶
func (e *FormElement) Get(p string) jsext.Value
func (*FormElement) ID ¶
func (e *FormElement) ID(s string) *FormElement
func (*FormElement) Index ¶
func (e *FormElement) Index(i int) jsext.Value
func (*FormElement) Input ¶
func (e *FormElement) Input(t, name string, opts *InputOptions) *FormElement
Input returns an input with the type, name, placeholder, and value specified.
func (*FormElement) Int ¶
func (e *FormElement) Int() int
func (*FormElement) Invoke ¶
func (e *FormElement) Invoke(args ...any) jsext.Value
func (*FormElement) IsNaN ¶
func (e *FormElement) IsNaN() bool
func (*FormElement) IsNull ¶
func (e *FormElement) IsNull() bool
func (*FormElement) IsUndefined ¶
func (e *FormElement) IsUndefined() bool
func (*FormElement) IsZero ¶ added in v2.7.2
func (e *FormElement) IsZero() bool
func (*FormElement) JSValue ¶
func (e *FormElement) JSValue() js.Value
JSValue returns the underlying js.Value.
func (*FormElement) Label ¶
func (e *FormElement) Label(forElement, text string, classes ...string) *FormElement
Label returns a label with the forElement and text specified.
func (*FormElement) Length ¶
func (e *FormElement) Length() int
func (*FormElement) Name ¶ added in v2.7.2
func (e *FormElement) Name() string
Name returns the name of the element.
func (*FormElement) OnSubmit ¶
OnSubmit sets the onsubmit event handler.
This function will do nothing if the element on which this was called is not a html form.
func (*FormElement) Reset ¶ added in v2.7.2
func (e *FormElement) Reset() *FormElement
Reset resets the form.
This function will do nothing if the element on which this was called is not a html form.
func (*FormElement) Set ¶
func (e *FormElement) Set(p string, x any)
func (*FormElement) SetAttr ¶
func (e *FormElement) SetAttr(key, value string) *FormElement
func (*FormElement) SetIndex ¶
func (e *FormElement) SetIndex(i int, x any)
func (*FormElement) String ¶
func (e *FormElement) String() string
func (*FormElement) TextArea ¶
func (e *FormElement) TextArea(name string, opts *InputOptions) *FormElement
TextArea returns a textarea with the name, placeholder, and value specified.
func (*FormElement) TimeInput ¶
func (e *FormElement) TimeInput(name string, h, m, s int, opts *InputOptions) *Timer
TimeInput returns an input to edit time with the name, placeholder, and value specified.
func (*FormElement) Truthy ¶
func (e *FormElement) Truthy() bool
func (*FormElement) Type ¶
func (e *FormElement) Type() js.Type
func (*FormElement) Value ¶ added in v2.7.2
func (e *FormElement) Value() string
Value returns the value of the element.
type InputOptions ¶
type InputOptions struct { Required bool Disabled bool ReadOnly bool Autofocus bool Checked bool AutoComplete string Placeholder string Multiple bool Min int Max int Step int Value string Classlist []string ButtonClasses []string }
func (*InputOptions) Apply ¶
func (o *InputOptions) Apply(e jsext.Element)
type JavascriptConstraint ¶
type JavascriptConstraint interface { jsext.Element | jsext.Value | SVG | FormElement | SelectElement | Element | *Element | *SVG | *FormElement | *SelectElement }
type OptionElement ¶
type OptionElement jsext.Element
func Option ¶
func Option(text, value string, selected ...bool) *OptionElement
func (*OptionElement) Selected ¶
func (o *OptionElement) Selected(b bool)
func (*OptionElement) Value ¶
func (o *OptionElement) Value() jsext.Element
type RemoveClasses ¶ added in v2.7.2
type RemoveClasses []string
type SelectElement ¶
type SelectElement jsext.Element
func Select ¶
func Select(name, id string, opts *InputOptions) *SelectElement
func (*SelectElement) AddEventListener ¶
func (s *SelectElement) AddEventListener(name string, listener func(this *Element, event jsext.Event)) *SelectElement
func (*SelectElement) Append ¶
func (s *SelectElement) Append(child any) *SelectElement
func (*SelectElement) ClassList ¶
func (s *SelectElement) ClassList(cls ...string) jsext.Value
func (*SelectElement) Element ¶
func (s *SelectElement) Element() *Element
func (*SelectElement) FormValue ¶
func (s *SelectElement) FormValue() string
func (*SelectElement) InlineClasses ¶
func (s *SelectElement) InlineClasses(classes ...string) *SelectElement
func (*SelectElement) OnChange ¶
func (s *SelectElement) OnChange(listener func(this *Element, event jsext.Event)) *SelectElement
func (*SelectElement) Option ¶
func (s *SelectElement) Option(text, value string, selected ...bool) *OptionElement
func (*SelectElement) Set ¶
func (s *SelectElement) Set(name string, value any) *SelectElement
func (*SelectElement) Value ¶
func (s *SelectElement) Value() jsext.Value