Documentation ¶
Index ¶
- Constants
- Variables
- func ElementRender(e *Element, w io.Writer) error
- func EventSend(clientid, js string, reply chan string) event
- func JqFuncCont(textinner string) string
- func JqIdProp(id, property string) string
- func JqIdPropCont(id, property, textinner string) string
- func JsAlert(alert string) string
- func JsSendFunc(send func())
- func JsSendJson(json string)
- func SendEvent(clientid, js string, reply chan string)
- func SendEventDataToClient(eventtype string, data interface{}, renderelement *Element, ...)
- func SetResource(files map[string][]byte)
- type Body
- type CheckBoxInput
- type Css
- type Element
- func NewButton(caption, buttontype string) *Element
- func NewElement(tag string) *Element
- func NewElementFromNode(node *html.Node, em ElementsMap) *Element
- func NewLink(caption, href string) *Element
- func NewMeta(meta map[string]string) *Element
- func NewStyledText(text string, style string) *Element
- func NewTableCaption(text string) *Element
- func NewText(text string) *Element
- func NewTextInput(value string) *Element
- func ParseElement(innerHTML string, em ElementsMap) (*Element, error)
- func ParseElements(r io.Reader, em ElementsMap) ([]*Element, error)
- func (e *Element) AddElement(elem *Element) *Element
- func (e *Element) AddElements(elems ...*Element) []*Element
- func (e *Element) AddHTML(innerHTML string, em ElementsMap) ([]*Element, error)
- 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, change *Element)
- 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) SetID(id string)
- func (e *Element) SetText(text string)
- func (e *Element) SetValue(value string)
- func (e *Element) Show()
- func (e *Element) UnsetClass(class string)
- type ElementsMap
- type Event
- type EventElement
- type EventHandler
- type EventHandlerStruct
- type Fieldset
- type FileInput
- type Form
- type Head
- func (h *Head) AddCss(css *Css)
- func (h *Head) AddCsss(csss ...*Css)
- func (h *Head) AddMeta(meta *Element)
- func (h *Head) AddMetas(metas ...*Element)
- func (h *Head) AddNewCss(href string)
- func (h *Head) AddNewMeta(meta map[string]string)
- func (h *Head) AddNewScript(src string)
- func (h *Head) AddScript(script *Script)
- func (h *Head) AddScripts(scripts ...*Script)
- type Html
- type Image
- type Input
- type Label
- type List
- type ListItems
- type Optgroup
- type Option
- type Progress
- type Script
- type Select
- func (s *Select) AddOptgroup(g *Optgroup) error
- func (s *Select) AddOptgroups(optgroups ...*Optgroup)
- func (s *Select) AddOption(o *Option)
- func (s *Select) AddOptions(options ...*Option)
- func (s *Select) Disable()
- func (s *Select) Enable()
- func (s *Select) GetSelected() []string
- func (s *Select) RemoveMultiple()
- func (s *Select) SetMultiple()
- func (s *Select) SetSize(size int)
- type Sse
- type Table
- type TableBody
- type TableCell
- type TableCol
- type TableColgroup
- type TableFooter
- type TableHead
- type TableRow
- type Textarea
Constants ¶
const ( OnClick = "onclick" OnChange = "onchange" OnKeyPress = "onkeypress" OnAbort = "onabort" OnBlur = "onblur" OnDblclick = "ondblclick" OnError = "onerror" OnFocus = "onfocus" OnKeydown = "onkeydown" OnKeyup = "onkeyup" OnLoad = "onload" OnMousedown = "onmousedown" OnMousemove = "onmousemove" OnMouseout = "onmouseout" OnMouseover = "onmouseover" OnMouseup = "onmouseup" OnReset = "onreset" OnResize = "onresize" OnSelect = "onselect" OnSubmit = "onsubmit" OnUnload = "onunload" )
const ( TypeTextHtml = "text/html" TypeJavascript = "text/javascript" TypeCss = "text/css" )
Content types
const ( ButtonButton = "button" ButtonReset = "reset" ButtonSubmit = "submit" )
Button types
const ( //ListUnordered is <ul> ListUnordered = "ul" //ListOrdered is <ol> ListOrdered = "ol" //DescriptionList is <dl> DescriptionList = "dl" )
Lists types
const ( InputButton = "button" InputCheckbox = "checkbox" InputColor = "color" InputDate = "date" InputDatetime = "datetime" InputDatetimeLocal = "datetime-local" InputEmail = "email" InputFile = "file" InputHidden = "hidden" InputImage = "image" InputMonth = "month" InputNumber = "number" InputPassword = "password" InputRadio = "radio" InputRange = "range" InputReset = "reset" InputSearch = "search" InputSubmit = "submit" InputTel = "tel" InputText = "text" InputTime = "time" InputUrl = "url" InputWeek = "week" )
Input types
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 ¶
var ( //Order counts the number of elements rendered (for generating auto-ids) Order int //Output output render target (configurable for unit-tests) Output bytes.Buffer )
var (
Ids unique //Id for widgets
)
var (
SseData = &Sse{}
)
Functions ¶
func JqFuncCont ¶
func JqIdPropCont ¶
func SendEventDataToClient ¶
func SendEventDataToClient(eventtype string, data interface{}, renderelement *Element, sender, change *Element)
func sendEventDataToClient(eventtype string, data interface{}, elementrender *wgui.Element, sender, change *wgui.Element) {
func SetResource ¶
=============================================
Practical //
=============================================
Types ¶
type CheckBoxInput ¶
type CheckBoxInput struct { *Element // contains filtered or unexported fields }
Checkbox represents a checkbox with label
func NewCheckBoxInput ¶
func NewCheckBoxInput(caption string, checked bool) *CheckBoxInput
NewCheckBox creates a bootstrap checkbox with label
func (*CheckBoxInput) Checked ¶
func (cb *CheckBoxInput) Checked() bool
Checked is true if the checkbox is checked
type Css ¶
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 NewMeta ¶
=============================================
<meta> Meta //
============================================= Create Meta element
func NewStyledText ¶
NewStyledText creates new text element using a specific style
func NewTextInput ¶
NewTextInput creates a new "text" input
func ParseElement ¶
func ParseElement(innerHTML string, em ElementsMap) (*Element, error)
ParseElement parses an html with only one root tag, returns the root element.
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) AddElements ¶
AddElements adds a multiple child elements
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) GetAttribute ¶
GetAttribute returns value for attribute
func (*Element) OnEvent ¶
func (e *Element) OnEvent(event string, handler EventHandler, change *Element)
OnEvent register an DOM element 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) 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 { //Сlid string `json:"clientid"` Name string `json:"name"` Sender EventElement `json:"sender"` //Change Element `json:"change"` Inputs []EventElement `json:"inputs"` Data string `json:"data"` }
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, change *Element)
EventHandler handler for DOM event.
type EventHandlerStruct ¶
type EventHandlerStruct struct { Func EventHandler Sender *Element Change *Element }
Element represents a DOM element and its state.
type Fieldset ¶
type Fieldset struct { *Element // contains filtered or unexported fields }
func NewFieldset ¶
type FileInput ¶
type FileInput struct { *Element // contains filtered or unexported fields }
FileButton is an file-input linked to a button
func NewFileInput ¶
NewFileButton creates new 'file' input with a button
type Form ¶
type Head ¶
type Head struct { *Element Charset string `json:"charset"` Meta []*Element `json:"meta"` Css []*Css `json:"css"` Script []*Script `json:"script"` }
=============================================
<head> Head //
=============================================
func (*Head) AddNewMeta ¶
AddMeta add new Meta attr/value to header
func (*Head) AddNewScript ¶
AddScript add new Script to header
func (*Head) AddScripts ¶
AddScripts adds a Script array to header
type Html ¶
type Input ¶
type Input struct { *Element // contains filtered or unexported fields }
Checkbox represents a checkbox with label
type Option ¶
func NewOptions ¶
type Progress ¶
func NewProgress ¶
type Select ¶
type Select struct { *Element Optgroups []*Optgroup Options []*Option Size int Multiple bool Name string Autofocus bool Required bool Form *Element Disabled bool }
func (*Select) AddOptgroup ¶
func (*Select) AddOptgroups ¶
func (*Select) AddOptions ¶
func (*Select) GetSelected ¶
func (*Select) RemoveMultiple ¶
func (s *Select) RemoveMultiple()
func (*Select) SetMultiple ¶
func (s *Select) SetMultiple()
type Table ¶
type Table struct { *Element Head *TableHead Body *TableBody Colgroup *TableColgroup Caption *Element Rows []*TableRow }
Table represents <table>
func QuickTable ¶
QuickTable creates a table from a given map with key-value pairs
type TableCol ¶
TableCol represents a <col>
func NewTableCol ¶
NewTableCol creates a new table colgroup col
type TableColgroup ¶
TableColgroup represents a <colgroup>
func NewTableColgroup ¶
func NewTableColgroup(span int, cols ...*TableCol) *TableColgroup
NewTableColgroup adds an colgroup row
func (*TableColgroup) AddColgroupCol ¶
func (c *TableColgroup) AddColgroupCol(col *TableCol)
AddColgroupCol adds a col
func (*TableColgroup) AddColgroupCols ¶
func (c *TableColgroup) AddColgroupCols(cols ...*TableCol)
AddColgroupCols adds a cols
type TableFooter ¶
type TableFooter struct {}
TableFooter
func NewTableFooter ¶
func NewTableFooter(rows ...*TableRow) *TableFooter
NewTableFooter adds footer
func (*TableFooter) AddFooterRow ¶
func (f *TableFooter) AddFooterRow(row *TableRow)
AddFooterRow adds a row
func (*TableFooter) AddFooterRows ¶
func (f *TableFooter) AddFooterRows(rows ...*TableRow)
AddFooterRows adds a rows