Documentation ¶
Index ¶
- Constants
- Variables
- func Alert(text string)
- func ExecJS(js string)
- func ExecJSNow(js string)
- func Run(body *Element) error
- type Element
- func NewElement(tag string) *Element
- func NewElementFromNode(node *html.Node, em ElementsMap) *Element
- func NewStyledText(text string, style string) *Element
- func NewText(text string) *Element
- func ParseElement(innerHTML string, em ElementsMap) (*Element, error)
- func ParseElementFromFile(fileName string, em ElementsMap) (*Element, error)
- func ParseElements(r io.Reader, em ElementsMap) ([]*Element, error)
- func (e *Element) AddElement(elem *Element) *Element
- func (e *Element) AddHTML(innerHTML string, em ElementsMap) ([]*Element, error)
- func (e *Element) AutoFocus()
- func (e *Element) Disable()
- func (e *Element) Enable()
- func (e *Element) Find(id string) *Element
- func (e *Element) GetAttribute(key string) (string, bool)
- func (e *Element) GetID() string
- func (e *Element) GetValue() string
- func (e *Element) Hide()
- func (e *Element) OnEvent(event string, handler EventHandler)
- func (e *Element) OnKeyPressEvent(event string, keyCode int, handler EventHandler)
- func (e *Element) ProcessEvent(event *Event)
- func (e *Element) RemoveAttribute(key string)
- func (e *Element) RemoveElement(elem *Element)
- func (e *Element) RemoveElements()
- func (e *Element) Render() error
- func (e *Element) SetAttribute(key, val string)
- func (e *Element) SetAttributes(event *EventElement)
- func (e *Element) SetClass(class string)
- func (e *Element) SetElement(elem *Element) *Element
- func (e *Element) SetID(id string)
- func (e *Element) SetText(text string)
- func (e *Element) SetValue(val string)
- func (e *Element) Show()
- func (e *Element) UnsetClass(class string)
- type ElementsMap
- type Event
- type EventElement
- type EventHandler
Constants ¶
const ( //OnClick onclick event OnClick = "onclick" //OnChange onchange event OnChange = "onchange" //OnKeyPress onkeypress event OnKeyPress = "onkeypress" )
const ( //BoldText <b> BoldText = "b" //StrongText <strong> StrongText = "strong" //ItalicText <i> ItalicText = "i" //EmphasizedText <em> EmphasizedText = "em" //MarkedText <mark> MarkedText = "mark" //SmallText <small> SmallText = "small" //DeletedText <del> DeletedText = "del" //InsertedText <ins> InsertedText = "ins" //SubscriptText <sub> SubscriptText = "sub" //SuperscriptText <sup> SuperscriptText = "sup" //TitleText <title> TitleText = "title" //Paragraph <p> Paragraph = "p" //Heading1 <h1> Heading1 = "h1" //Heading2 <h2> Heading2 = "h2" //Heading3 <h3> Heading3 = "h3" //Heading4 <h4> Heading4 = "h4" //Heading5 <h5> Heading5 = "h5" //Heading6 <h6> Heading6 = "h6" )
Variables ¶
Functions ¶
Types ¶
type Element ¶
type Element struct { //Parent the parent element Parent *Element //Kids child elements Kids []*Element //Attributes element attributes... Attributes []html.Attribute //Object arbitrary user object that can be associated with element. Object interface{} //Hidden if true the element will not be rendered Hidden bool // contains filtered or unexported fields }
Element represents a DOM element and its state.
func NewElementFromNode ¶
func NewElementFromNode(node *html.Node, em ElementsMap) *Element
NewElementFromNode creates an element from existing node
func NewStyledText ¶
NewStyledText creates new text element using a specific style
func ParseElement ¶
func ParseElement(innerHTML string, em ElementsMap) (*Element, error)
ParseElement parses an html with only one root tag, returns the root element.
func ParseElementFromFile ¶
func ParseElementFromFile(fileName string, em ElementsMap) (*Element, error)
ParseElementFromFile like ParseElement, but reads input from a file
func ParseElements ¶
func ParseElements(r io.Reader, em ElementsMap) ([]*Element, error)
ParseElements parse an html fragment and return a list of elements
func (*Element) AddElement ¶
AddElement adds a child element
func (*Element) AddHTML ¶
func (e *Element) AddHTML(innerHTML string, em ElementsMap) ([]*Element, error)
AddHTML parses the provided element and adds it to the current element. Returns a list of root elements from `html`. If em is not nil, for each HTML tag that has the `id` attribute set the corresponding element will be stored in the given ElementMap.
func (*Element) AutoFocus ¶
func (e *Element) AutoFocus()
AutoFocus adds the auto-focus atribute to the element
func (*Element) GetAttribute ¶
GetAttribute returns value for attribute
func (*Element) OnEvent ¶
func (e *Element) OnEvent(event string, handler EventHandler)
OnEvent register an DOM element event.
func (*Element) OnKeyPressEvent ¶
func (e *Element) OnKeyPressEvent(event string, keyCode int, handler EventHandler)
OnKeyPressEvent register handler as an OnKeyPressed event.
func (*Element) ProcessEvent ¶
ProcessEvent fires the event provided
func (*Element) RemoveAttribute ¶
RemoveAttribute removes the provided attribute by name
func (*Element) RemoveElement ¶
RemoveElement remove a specific kid
func (*Element) SetAttribute ¶
SetAttribute adds or set the attribute
func (*Element) SetAttributes ¶
func (e *Element) SetAttributes(event *EventElement)
SetAttributes sets attributes from an event element.
func (*Element) SetElement ¶
SetElement removes all child elemens and adds elem as first child
func (*Element) UnsetClass ¶
UnsetClass removes the given class name from the class attribute
type ElementsMap ¶
ElementsMap maps Elements by their `id` attributes
type Event ¶
type Event struct { Name string `json:"name"` Sender EventElement `json:"sender"` Inputs []EventElement `json:"inputs"` }
Event represents a DOM event
type EventElement ¶
EventElement represents the DOM element sending an event
func (*EventElement) GetID ¶
func (e *EventElement) GetID() string
GetID get the id of the event sender.
func (*EventElement) GetValue ¶
func (e *EventElement) GetValue() string
GetValue gets the value of the event sender.
type EventHandler ¶
type EventHandler func(sender *Element, event *EventElement)
EventHandler handler for DOM event.