2020-03-21 13:04:54 +05:00
|
|
|
package metas
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gopherjs/gopherjs/js"
|
|
|
|
|
|
|
|
"go.dev.pztrn.name/bulpherjs/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InnerItems is a meta structure that should be embedded in all other
|
|
|
|
// structures (notably element controlling ones). It provide ability to
|
|
|
|
// add child elements.
|
|
|
|
type InnerItems struct {
|
|
|
|
innerItems []Buildable
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddChild adds child to element.
|
|
|
|
func (it *InnerItems) AddChild(object Buildable) {
|
|
|
|
it.innerItems = append(it.innerItems, object)
|
|
|
|
}
|
|
|
|
|
|
|
|
// BuildChilds build child elements and adds them to parent.
|
|
|
|
func (it *InnerItems) BuildChilds(parent *js.Object) {
|
|
|
|
for _, item := range it.innerItems {
|
2020-03-23 11:10:49 +05:00
|
|
|
parent.Call(common.JSCallAppendChild, item.Build())
|
2020-03-21 13:04:54 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initializes child elements storage.
|
|
|
|
func (it *InnerItems) initializeInnerItems() {
|
|
|
|
it.innerItems = make([]Buildable, 0)
|
|
|
|
}
|