Documentation ¶
Index ¶
- Constants
- Variables
- func AjaxDelete(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError)
- func AjaxGet(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError)
- func AjaxIndex(ptrToSliceOfPtrToStruct interface{}, path string) (chan interface{}, chan AjaxError)
- func AjaxPost(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError)
- func AjaxPut(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError)
- func AjaxRawChannels(output interface{}, body string, contentChan chan interface{}, ...) error
- func Bind(attr Attribute, cons Constraint) option
- func BindEqual(attr Attribute) option
- func Class(cl CssClass) option
- func CssExistence(c CssClass, b BooleanAttribute) option
- func DrainEagerQueue()
- func Equality(dest, src Attribute)
- func Event(name EventName, fn EventFunc) option
- func HtmlAttrConstant(h htmlAttrName, str string) option
- func HtmlAttrEqual(h htmlAttrName, attr Attribute) option
- func Id(id HtmlId) option
- func IdConstant(id string) option
- func Main(app Application)
- func ModelId(m ModelName) option
- func NewFormValidConstraint(fn formValidFunc, id ...FormElement) formValidConstraint
- func PropEqual(n propName, b BooleanAttribute) option
- func Style(s string) option
- func Text(str string) option
- func TextEqual(attr Attribute) option
- type AjaxError
- type Application
- type ArithmeticConstraint
- func AdditionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint
- func NewArithmeticConstraint(op ArithmeticOp, attr []Attribute, fn func([]int) int) ArithmeticConstraint
- func ProductConstraint(attr ...IntegerAttribute) ArithmeticConstraint
- func SubtractionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint
- func SumConstraint(attr ...IntegerAttribute) ArithmeticConstraint
- type ArithmeticOp
- type Attribute
- type AttributeImpl
- type BoolEq
- type BoolEqualer
- type BooleanAttribute
- type BooleanInverter
- type BooleanSimple
- type Collection
- func (self *Collection) Add(m Model)
- func (self *Collection) All() []Model
- func (self *Collection) AllFold(targ Attribute, initial interface{}, puller Puller, folder FoldingIterator, ...) Constraint
- func (self *Collection) EmptyAttribute() BooleanAttribute
- func (self *Collection) LengthAttribute() IntegerAttribute
- func (self *Collection) PopRaw() Model
- func (self *Collection) PushRaw(m Model)
- func (self *Collection) Remove(m Model)
- type Constraint
- type ConstraintFunc
- type CssClass
- type DomAttribute
- func NewCssExistenceAttr(t NarrowDom, clazz CssClass) DomAttribute
- func NewDisplayAttr(t NarrowDom) DomAttribute
- func NewHtmlAttrAttr(t NarrowDom, a htmlAttrName) DomAttribute
- func NewPropAttr(t NarrowDom, n propName) DomAttribute
- func NewStyleAttr(n string, t NarrowDom) DomAttribute
- func NewTextAttr(t NarrowDom) DomAttribute
- type EqList
- type Equaler
- type EventFunc
- type EventName
- type FloatAttribute
- type FloatEq
- type FloatEqualer
- type FloatSimple
- type FoldingIterator
- type FormElement
- type HtmlId
- type InputTextId
- type IntEqualer
- type IntegerAttribute
- type IntegerEq
- type IntegerSimple
- type Joiner
- type Model
- type ModelImpl
- type ModelName
- type NarrowDom
- type NodeType
- type PasswordAuthParameters
- type Puller
- type RadioGroup
- type SelectGroup
- type SelectableAttribute
- func (s *SelectableAttribute) Attach(cons Constraint)
- func (s *SelectableAttribute) Chooser() BooleanAttribute
- func (s *SelectableAttribute) Demand() Equaler
- func (s *SelectableAttribute) Detach()
- func (s *SelectableAttribute) Selectable() Attribute
- func (s *SelectableAttribute) Selected() bool
- func (s *SelectableAttribute) SetDebugName(n string)
- func (s *SelectableAttribute) SetEqualer(e Equaler)
- func (s *SelectableAttribute) SetSelected(b bool)
- type SideEffectFunc
- type StringAttribute
- type StringEqualer
- type StringSimple
- type ValueFunc
- type ViewImpl
- func A(obj ...interface{}) *ViewImpl
- func BUTTON(obj ...interface{}) *ViewImpl
- func DIV(obj ...interface{}) *ViewImpl
- func EM(obj ...interface{}) *ViewImpl
- func FORM(obj ...interface{}) *ViewImpl
- func H1(obj ...interface{}) *ViewImpl
- func H2(obj ...interface{}) *ViewImpl
- func H3(obj ...interface{}) *ViewImpl
- func H4(obj ...interface{}) *ViewImpl
- func H5(obj ...interface{}) *ViewImpl
- func H6(obj ...interface{}) *ViewImpl
- func HR(obj ...interface{}) *ViewImpl
- func HtmlConstant(s string) *ViewImpl
- func IMG(obj ...interface{}) *ViewImpl
- func INPUT(obj ...interface{}) *ViewImpl
- func LABEL(obj ...interface{}) *ViewImpl
- func LI(obj ...interface{}) *ViewImpl
- func OL(obj ...interface{}) *ViewImpl
- func OPTION(obj ...interface{}) *ViewImpl
- func P(obj ...interface{}) *ViewImpl
- func PRE(obj ...interface{}) *ViewImpl
- func SPAN(obj ...interface{}) *ViewImpl
- func STRONG(obj ...interface{}) *ViewImpl
- func TABLE(obj ...interface{}) *ViewImpl
- func TD(obj ...interface{}) *ViewImpl
- func TEXTAREA(obj ...interface{}) *ViewImpl
- func TH(obj ...interface{}) *ViewImpl
- func TR(obj ...interface{}) *ViewImpl
- func UL(obj ...interface{}) *ViewImpl
Constants ¶
const ( ADD_OP = iota SUB_OP MULT_OP DIV_OP MOD_OP FUNC_OP )
const ( AUTH_OP_LOGIN = "login" AUTH_OP_LOGOUT = "logout" AUTH_OP_PWD_RESET = "pwdreset" AUTH_OP_PWD_RESET_REQ = "pwdresetreq" )
const ( SEVEN5_DATA = "seven5_%s" CONSTRAINT_MARKER = "constraint" )
const ( NORMAL = iota VALUE_ONLY = 1 EAGER = 2 DEBUG_MESSAGES = false )
Variables ¶
var ( REL = newAttrName("rel") LINK = newAttrName("link") TYPE = newAttrName("type") PLACEHOLDER = newAttrName("placeholder") HREF = newAttrName("href") SRC = newAttrName("src") WIDTH = newAttrName("width") HEIGHT = newAttrName("height") VALUE = newAttrName("value") SIZE = newAttrName("size") MAXLENGTH = newAttrName("maxlength") TARGET = newAttrName("target") CHECKED = newPropName("checked") SELECTED = newPropName("selected") DISABLED = newPropName("disabled") )
var ForEffect = forEffect{}
ForEffect is a singleton value that is not equal to itself. It's useful when you want to return a value that is never equal to the previous value.
var (
TestMode = false
)
Functions ¶
func AjaxDelete ¶
AjaxDelete behaves indentically to AjaxPost other than using the method DELETE and not sending the object to be deleted's contents, just its id. First parameter here is just for the type.
func AjaxGet ¶
AjaxGet retreives an instance of a wire type from the server and decodes the result as Json. If the first argument is not a pointer to a struct, it will panic. The first argument should be a wire type that you expect to receive in the success case. The returned values are a content channel and an error channel. The content channel will receive the same type as your first argument if anything. The error channel is used for non-200 http responses and the special error code 418 is used to indicate that the received json from the server could not be successfully parsed as the type of the first argument. The error code 0 indicates that the server could not be contacted at all.
func AjaxIndex ¶
AjaxIndex retreives a collection of wire types from the server. If the first argument is not a pointer to a slice of pointer to struct, it will panic. The first element should be a slice of wire types. The returned values are a content channel and an error channel. The content channel will receive the same type as your first argument if anything. The error channel is used for non-200 http responses and the special error code 418 is used to indicate that the received json from the server could not be successfully parsed as the type of the first argument.
func AjaxPost ¶
AjaxPost sends an instance of a wire type to the server. The first argument should be a wire type and must be a pointer to a struct or this function will panic. The value sent to the server is supplied in the first argument. The two returned values are a content channel and an error channel. If the call succeeds, the content channel will be sent a different instance of the same type as the first argument. If the result from the server cannot be understood as the type of the first argument, the special error code 418 will be sent on the error channel. If we fail to encode the object to be sent, the error code 420 will be sent on the error channel and no call to the server is made.
func AjaxRawChannels ¶
func AjaxRawChannels(output interface{}, body string, contentChan chan interface{}, errChan chan AjaxError, method string, path string, extraHeaders map[string]interface{}) error
AjaxRawChannels is the lower level interface to the "raw" Ajax call. Most users should use AjaxGet, AjaxPost, AjaxIndex or AjaxPut.
func Bind ¶
func Bind(attr Attribute, cons Constraint) option
Bind constrains the attribute provided to be a function of the value of the tag this call is located in. Typically, this is an INPUT tag. Data flows _from_ the input text that the user types to the attribute via this constraint given, not the other way around. There is a strange, but useful, edge case in the initialization of the INPUT tag: ff the attr provided returns a string value, that value is used to initialize INPUT field.
func BindEqual ¶
func BindEqual(attr Attribute) option
BindEqual constrains the attribute provided to be the same as the value of the tag this is located in. Typically, this is an INPUT tag. Data flows _from_ the input text that the user types to the attribute, not the other way around. There is a strange, but useful, edge case in the initialization of the INPUT tag: ff the attr provided returns a string value, that value is used to initialize INPUT field.
func CssExistence ¶
func CssExistence(c CssClass, b BooleanAttribute) option
func DrainEagerQueue ¶
func DrainEagerQueue()
DrainEagerQueue tells eager attributes to update themselves
func HtmlAttrConstant ¶
func HtmlAttrConstant(h htmlAttrName, str string) option
func HtmlAttrEqual ¶
func HtmlAttrEqual(h htmlAttrName, attr Attribute) option
func IdConstant ¶
func IdConstant(id string) option
func Main ¶
func Main(app Application)
func NewFormValidConstraint ¶
func NewFormValidConstraint(fn formValidFunc, id ...FormElement) formValidConstraint
NewFormValidConstraint creates a constraint that uses the function supplied to compute a value and has dependencies on all the remaining parameters.
func PropEqual ¶
func PropEqual(n propName, b BooleanAttribute) option
Types ¶
type Application ¶
type Application interface {
Start()
}
type ArithmeticConstraint ¶
type ArithmeticConstraint interface { Constraint }
ArithmeticConstraint allows simple arithmetic operations on integers.
func AdditionConstraint ¶
func AdditionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint
AdditionConstraint creates a constraint that adds two values. The only reason to pass the function argument is to create a result that differs from the sum by a constant. Note that the function, if provided, must return the "sum" as well as adding any constants.
func NewArithmeticConstraint ¶
func NewArithmeticConstraint(op ArithmeticOp, attr []Attribute, fn func([]int) int) ArithmeticConstraint
NewArithmeticConstraint creates a constraint object with the default operation given. If the fn is set to nil, the arithmetic operation provided is applied to all the arguments. For subtraction, modulus, and division, this may not be what you want since this operations are more commonly binary (two parameters). If you have a complex function of integers, it is useful to call this method directly but most users will want to use AdditionConstraint(), SubtractionConstraint() or similar since these have types and semantics "baked in".
func ProductConstraint ¶
func ProductConstraint(attr ...IntegerAttribute) ArithmeticConstraint
ProductConstraint creates a constraint that multiplies any number of attributes. The attribute vaules are copied so the slice can be discarded.
func SubtractionConstraint ¶
func SubtractionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint
SubtractionConstraint creates a constraint that subtractions two values. The only reason to pass the function argument is to create a result that differs from the sum by a constant. Note that the function, if provided, must return the "difference" as well as subtracting anyok, constants.
func SumConstraint ¶
func SumConstraint(attr ...IntegerAttribute) ArithmeticConstraint
SumConstraint creates a constraint that add any number of attributes. The attribute values are copied so the caller can discard the slice after this use.
type ArithmeticOp ¶
type ArithmeticOp int
Arithmetic op represents one of the binary operators of arithmetic plus the mod (%) operator. It also has a special case, FUNC_OP meaning the user will supply a function to compute the operation.
func (ArithmeticOp) String ¶
func (self ArithmeticOp) String() string
type Attribute ¶
type Attribute interface { Attach(Constraint) Detach() Demand() Equaler SetEqualer(Equaler) SetDebugName(n string) }
Attribute represents a value that can be manipulated by a constraint function. Note that this object has no public set or get methods because typically consumers will use a typed version of this such as BooleanAttribute or IntegerAttribute. An attribute can have a constraint attached to indicate that the value of the Attribute is computed from other attributes. Note that setting an attribute which has a Constraint attached will result in a panic.
func NewValueAttr ¶
NewValueAttr creates a _source_ attribute from a value in the DOM. In other words you use this as a constraint INPUT not as a value output (such as with NewDisplayAttr or NewCssExistenceAttr). This is useful for using the value of input fields as a source in constraint graph. This should probably be used only with tags of type INPUT although this is not enforced.
type AttributeImpl ¶
type AttributeImpl struct {
// contains filtered or unexported fields
}
AttributeImpl is the implementation of a node.
func NewAttribute ¶
func NewAttribute(nt NodeType, v ValueFunc, s SideEffectFunc) *AttributeImpl
NewAttribute returns a new attribute implementation. The node type should be one of NORMAL (constrainable), VALUE_ONLY (not constrainable) or EAGER (constrainable and always up to date). Note that if you supply both funcs it is assumed that the v and s communicate and so the s is not called when the v produced the value.
func (*AttributeImpl) Attach ¶
func (self *AttributeImpl) Attach(c Constraint)
attach does the work of constraining this value to a set of inputs given by the constraint. Note that this will panic if this node has a current value (meaning its a source and thus cannot be constrained)
func (*AttributeImpl) Demand ¶
func (self *AttributeImpl) Demand() Equaler
Demand forces all the dependencies up to date and then calls the function to get the new value.
func (*AttributeImpl) Detach ¶
func (self *AttributeImpl) Detach()
Detach removes any existing constraint dependency edges from this node. This method has no effect if the object has no constraint.
func (*AttributeImpl) SetDebugName ¶
func (self *AttributeImpl) SetDebugName(n string)
func (*AttributeImpl) SetEqualer ¶
func (self *AttributeImpl) SetEqualer(i Equaler)
Set can set simple values, but only on a source (not something that needs computing).
type BoolEq ¶
type BoolEq struct {
// contains filtered or unexported fields
}
Booleq is a boolean equality constraint.
type BoolEqualer ¶
type BoolEqualer struct {
B bool
}
BoolEqualer is a wrapper around bool types for use with attributes. It has the Equal() method for comparison.
func (BoolEqualer) Equal ¶
func (self BoolEqualer) Equal(e Equaler) bool
Equal compares two values, must be BoolEqualers, to see if they are the same.
func (BoolEqualer) String ¶
func (self BoolEqualer) String() string
String returns this value as a string (via fmt.Sprintf)
type BooleanAttribute ¶
Boolean attributes are Attributes that have boolean values.
func NewBooleanSimple ¶
func NewBooleanSimple(b bool) BooleanAttribute
NewBooleanSimple creates a new BooleanAttribute with a simple boolean initial value.
type BooleanInverter ¶
type BooleanInverter struct {
// contains filtered or unexported fields
}
BooleanInverter is an attribute that can invert the value of the value it depends on.
func (*BooleanInverter) Fn ¶
func (self *BooleanInverter) Fn(in []Equaler) Equaler
func (*BooleanInverter) Inputs ¶
func (self *BooleanInverter) Inputs() []Attribute
type BooleanSimple ¶
type BooleanSimple struct {
*AttributeImpl
}
BooleanSimple is a BooleanAttribute that holds a simple value. Attempts to Attach() a constraint to this value will panic.
func (*BooleanSimple) Set ¶
func (self *BooleanSimple) Set(b bool)
func (*BooleanSimple) Value ¶
func (self *BooleanSimple) Value() bool
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a collection models. Note that the type of the collection elements are Model which implies Equaler. TODO: Convert to Collection and collectionImpl
func NewList ¶
func NewList(joiner Joiner) *Collection
NewCollection returns an empty Collection. You should a supply a joiner here if you want to run a transform on insert or remove from thelist. You can pass nil if you don't need any joiner at the point you create the collection.
func (*Collection) Add ¶
func (self *Collection) Add(m Model)
Add checks to see that the model is not already in the collection then adds it if it is not. If the object is already in the collection, this has no effect (but does request the value of all the items in the list). If the list has any joiners, they are notified about the new element, but after the change has taken place.
func (*Collection) All ¶
func (self *Collection) All() []Model
All returns all the models in this collection. This is a copy of the objects internal data.
func (*Collection) AllFold ¶
func (self *Collection) AllFold( targ Attribute, initial interface{}, puller Puller, folder FoldingIterator, empty Equaler) Constraint
AllFold creates a constraint that depends on the same attribute in _every_ model in the collection. The attribute to be computed is the first parameter. The initial value of the iterative folding is the second argument, and fed to the Folder on the first iteration. The puller is used whenever the models in the collection change to extract a particular Attribute that the constraint depends on.
func (*Collection) EmptyAttribute ¶
func (self *Collection) EmptyAttribute() BooleanAttribute
EmptyAttribute should be used by callers to assess if the list is is empty or not. It is a BooleanAttribute so it can be used in constraint functions.
func (*Collection) LengthAttribute ¶
func (self *Collection) LengthAttribute() IntegerAttribute
LengthAttribute should be used by callers to assess how many items are in the list. The return value is an attribute that can be used in constraint functions.
func (*Collection) PopRaw ¶
func (self *Collection) PopRaw() Model
PopRaw is the way to access the last node of the list without any checking. This will panic if the list is empty. This implies an update to the length and empty attribute. If there are Joiners they are called after the PopRaw completes.
func (*Collection) PushRaw ¶
func (self *Collection) PushRaw(m Model)
PushRaw the way to push a Model into the list _without_ having any checking done about the value of that model. Note that most callers would probably prefer Add() that checks to see if the item is already in the list before doing the addition. Note this does imply updating of the empty and length attributes. If the collection has joiners, it is called after the PushRaw has completed.
func (*Collection) Remove ¶
func (self *Collection) Remove(m Model)
Remove checks to see that the model is in the collection and then removes it. If the element is in the collection multiple times, only the first one is removed. Calling this on an empty collection is useless but not an error. If the list has joiners, they are notified about the removal of the element but after the removal has occured. The object that was removed is supplied to the Joiner.
type Constraint ¶
Constraint is a function of Attributes that results in an attribute. Note that the implementation of a constraint. The implementation of the Fn() will be passed the current values of the Attributes returned by Inputs(). The implementation of Fn() must be careful to not use other values that affect the result since these are not known to the system and unexpected/wrong results will occur. Most users of this interface will find it easier to use some specialized version of the interface that offers typed values to the computing function.
func NewBooleanInverter ¶
func NewBooleanInverter(attr BooleanAttribute) Constraint
NewBooleanInverter returns constraint that inverts a boolean input.
func NewSimpleConstraint ¶
func NewSimpleConstraint(fn ConstraintFunc, attr ...Attribute) Constraint
NewSimpleConstraint returns a new constraint that can derive its value from a fixed set of inputs. The function fn is called to compute the vaule of the constraints and the parameters to fn are the vaules (in order) of the attributes at the current time.
func StringEquality ¶
func StringEquality(src Attribute) Constraint
type ConstraintFunc ¶
type CssClass ¶
type CssClass interface {
ClassName() string
}
CssClass represents a single CSS class defined elsewhere. This interface is useful in conjunction with Concorde creation of HTML.
func NewCssClass ¶
NewCssClass returns a selctor that can find .name
type DomAttribute ¶
DomAttribute is a constrainable entity that references a portion of the dom. The referenced dom element may be either a fixed portion of the dom or part of a dynamically created (sub)tree.
func NewCssExistenceAttr ¶
func NewCssExistenceAttr(t NarrowDom, clazz CssClass) DomAttribute
NewCssExistenceAttr returns a dom attribute that should be computed via a constraint yielding a boolean (BoolEqualer). If the boolean is true, the css class provided is attached to the elements that match j. If the boolean value is provided, the css class is removed. Most users will probably prefer to use the CssExistenceBuilder interface, this is the lower level access to the dom attribute.
func NewDisplayAttr ¶
func NewDisplayAttr(t NarrowDom) DomAttribute
NewDisplayAttr returns a dom element that is connected to the css "display" attribute. This is a special case of NewStyleAttribute that understands that a boolean can be used to display (true) or hide a given dom element. This is the lower level interface and most users will prefer the DisplayAttrBuilder or DisplayAttribute calls.
func NewHtmlAttrAttr ¶
func NewHtmlAttrAttr(t NarrowDom, a htmlAttrName) DomAttribute
NewHtmlAttrAttr provides an interface to the dom "attribute" (in the constraint sense) for the given html attribute name, on the elements that are matched by j. Most users will probably prefer to use the HtmlAttrBuilder interface, this is the lower level access to the raw DomAttribute(). This attribute uses fmt.Sprintf() to compute the final value assigned to the dom element, so the constraint result can be any type.
func NewPropAttr ¶
func NewPropAttr(t NarrowDom, n propName) DomAttribute
NewPropAttr provides an interface to the dom attribute for the property named, for the elements that are matched by j. This is primarily useful for things that have true/false state (such checked, selected, or disabled state) so it expects a boolean attribute.
func NewStyleAttr ¶
func NewStyleAttr(n string, t NarrowDom) DomAttribute
NewStyleAttribute returns a dom attribute connected to the css style value named by n and selected by the selector j. This results in a call to SetCSS and uses fmt.Sprintf() to format it's value, so the constraint result may be any type. This the lower level interface, most users will probably prefer to use the StyleAttrBuilder interface.
func NewTextAttr ¶
func NewTextAttr(t NarrowDom) DomAttribute
NewTextAttr returns a dom attribute connected to the text property of the elements matched by j. Most users will probably prefer to use the TextBuilder API, this is the lower level access to the raw DomAttribute. This attribute uses fmt.Sprintf() to compute the final text value written, so the constraint result can be any type.
type EqList ¶
type EqList []Model
EqList is a convenience for talking about the contents of the collection. You can use collection.AttributeImpl.(EqList) to read the contents of the list.
type Equaler ¶
Equaler is an interface that forces objects to be comparable for equality. The constraint algorithm needs this to know when a value changes.
type EventFunc ¶
EventFunc is something that can handle an event. It should not return anything, it should use the event object to stop default event handling and similar.
type FloatAttribute ¶
FloatAttributes are attributes are Attributes that have float64 values.
func NewFloatSimple ¶
func NewFloatSimple(f float64) FloatAttribute
NewFloatSimple creates a new FloatAttribute with a simple float64 initial value.
type FloatEq ¶
type FloatEq struct {
// contains filtered or unexported fields
}
FloatEq is an float equality constraint.
type FloatEqualer ¶
type FloatEqualer struct {
F float64
}
FloatEqualer is a wrapper around float64 types for use with attributes. It has the Equal() method for comparison.
func (FloatEqualer) Equal ¶
func (self FloatEqualer) Equal(e Equaler) bool
Equal compares two values, must be FloatEqualers, to see if they are the same.
func (FloatEqualer) String ¶
func (self FloatEqualer) String() string
Float returns this Float as a string (via fmt.Sprintf)
type FloatSimple ¶
type FloatSimple struct {
*AttributeImpl
}
FloatSimple is an FloatAttribute which cannot have any incoming edges, it is just a source of a simple float64 value.
func (*FloatSimple) Set ¶
func (self *FloatSimple) Set(f float64)
func (*FloatSimple) Value ¶
func (self *FloatSimple) Value() float64
type FoldingIterator ¶
FoldingIterator is a function of the previous value and the next input attribute. The latter is extracted via a Puller function, so one can think of this second parameter as a model. This function returns two values, the first of which is passed to this function again on all but the last iteration. On the last iteration, the 2nd value is the final result.
type FormElement ¶
type HtmlId ¶
type HtmlId interface { Dom() NarrowDom TagName() string Id() string StyleAttribute(string) DomAttribute TextAttribute() DomAttribute DisplayAttribute() DomAttribute CssExistenceAttribute(clazz CssClass) DomAttribute }
HtmlId represents a particular item in the DOM tree.
func HtmlIdFromModel ¶
HtmlIdFromModel returns an HtmlId object from the given modelname and tagname. Resulting id is unique to the modelname and tag, but not between tags with the same name.
type InputTextId ¶
type InputTextId interface { FormElement }
InputTextId is a special case of HtmlId that is the exported text of a type in field.
func NewInputTextId ¶
func NewInputTextId(id string) InputTextId
NewInputTextId returns a reference to a static part of the DOM that is the an input tag with the given id.
type IntEqualer ¶
type IntEqualer struct {
I int
}
IntEqualer is a wrapper around int types for use with attributes. It has the Equal() method for comparison.
func (IntEqualer) Equal ¶
func (self IntEqualer) Equal(e Equaler) bool
Equal compares two values, must be IntEqualers, to see if they are the same.
func (IntEqualer) String ¶
func (self IntEqualer) String() string
String returns this integer as a string (via fmt.Sprintf)
type IntegerAttribute ¶
IntegerAttributes are attributes are Attributes that have int values.
func NewIntegerSimple ¶
func NewIntegerSimple(i int) IntegerAttribute
NewIntegerSimple creates a new IntegerAttribute with a simple int initial value.
type IntegerEq ¶
type IntegerEq struct {
// contains filtered or unexported fields
}
IntegerEq is an integer equality constraint.
type IntegerSimple ¶
type IntegerSimple struct {
*AttributeImpl
}
IntegerSimple is an IntegerAttribute which cannot have any incoming edges, it is just a source of a simple int value.
func (*IntegerSimple) Set ¶
func (self *IntegerSimple) Set(i int)
func (*IntegerSimple) Value ¶
func (self *IntegerSimple) Value() int
type Joiner ¶
Joiners connect a list to something that will manipulate elements of the list. Typically this is used for connecting models to views.
type ModelName ¶
type ModelName interface {
Id() string
}
Models represent a collection of stuff to be displayed in a view.
func NewModelName ¶
func NewModelName(i interface{}) ModelName
type NarrowDom ¶
type NarrowDom interface { SetData(string, string) Data(string) string RemoveData(string) Css(string) string SetCss(string, string) Text() string SetText(string) Attr(string) string SetAttr(string, string) Prop(string) bool SetProp(string, bool) On(EventName, EventFunc) Trigger(EventName) HasClass(string) bool AddClass(string) RemoveClass(string) Val() string SetVal(string) Clear() Append(...NarrowDom) Prepend(...NarrowDom) Before(NarrowDom) Remove() Focus() Blur() Select() }
NarrowDom is a narrow interface to accessing the DOM that can be simulated for test purposes.
func ParseHtml ¶
ParseHtml returns a NarrowDom that points at the fragment of HTML provided in t. No attempt is made to validate that the HTML is sensible, much less syntatically correct.
func WrapJQuery ¶
WrapJQuery takes a Jquery object and converts it to a NarrowDom instance. The use of this function usually indicates that the NarrowDom interface is broken in some way as it subverts the typing and goes down into the implementation. It's always better to fix the NarrowDom to have the feature, if possible.
type PasswordAuthParameters ¶
type RadioGroup ¶
type RadioGroup interface { FormElement }
func NewRadioGroup ¶
func NewRadioGroup(name string) RadioGroup
NewRadioGroup selects a named set of radio button elements with a given name.
type SelectGroup ¶
type SelectGroup interface { FormElement }
func NewSelectGroupId ¶
func NewSelectGroupId(id string) SelectGroup
NewSelectGroup selects one of a named set of elements, usually rendered as a drop down list.
type SelectableAttribute ¶
type SelectableAttribute struct { *AttributeImpl // contains filtered or unexported fields }
SelectableAttribute provides an abstraction which allows an attribute to be turned on an off by another boolean attribute, called the chooser. When the chooser is false, this attribute's value is a constant (typically provided at construction time). If the chooser is true then this attribute is a shim over another attribute, also provided at construction-time. Note that assignemnts to this attribute are logically passed through to the attribute, but are ignored if the chooser is false. Calls to SetEqualer will be honored, and passed through, if the chooser is true.
func NewSelectableAttribute ¶
func NewSelectableAttribute(chooser BooleanAttribute, unselectedValue Equaler, attr Attribute) *SelectableAttribute
NewSelectableAttribute creates a new SelectableAttribute with a given chooser a boolean attribute, a constant to be used when the chooser is false, and attribute to used when the chooser is true. If you pass nil as the chooser this call will create a new boolean attribute to use as the chooser and it's initial value will be false. The attribute provided must not be nil.
func (*SelectableAttribute) Attach ¶
func (s *SelectableAttribute) Attach(cons Constraint)
Attach attaches a constraint to this selectable attribute. Note that this constraint will be called on any changes to the SelectableAttribute's boolean chooser or its underlying attribute.
func (*SelectableAttribute) Chooser ¶
func (s *SelectableAttribute) Chooser() BooleanAttribute
Chooser return the chooser that is in use for this selectable attribute. This is useful when you want feedabck about the chooser itself, rather than the composite output provided by SelectableAttribute.
func (*SelectableAttribute) Demand ¶
func (s *SelectableAttribute) Demand() Equaler
Demand returns the value of the attribute that is selectable if the chooser is true, otherwise the constant value provided at construction time.
func (*SelectableAttribute) Detach ¶
func (s *SelectableAttribute) Detach()
Detach removes a constraint attached to this SelectableAttribute.
func (*SelectableAttribute) Selectable ¶
func (s *SelectableAttribute) Selectable() Attribute
Selectable returns the attribute that is turned on and off inside this atribute.
func (*SelectableAttribute) Selected ¶
func (s *SelectableAttribute) Selected() bool
Selected returns the current selected state.
func (*SelectableAttribute) SetDebugName ¶
func (s *SelectableAttribute) SetDebugName(n string)
SetDebugName is useful when examining debug messages from seven5 itself.
func (*SelectableAttribute) SetEqualer ¶
func (s *SelectableAttribute) SetEqualer(e Equaler)
SetEqualer assigns the value provided to the underlying attribute of this type, only if the chooser of this SelectableAttribute is true. If the chooser is false, this call is ignored.
func (*SelectableAttribute) SetSelected ¶
func (s *SelectableAttribute) SetSelected(b bool)
SetSelected sets the selected state of this attribute to the value provided.
type SideEffectFunc ¶
type SideEffectFunc func(Equaler)
SideEffectFunc is one that is called AFTER a value has been computed to consume the value.
type StringAttribute ¶
StringAttributes are attributes are Attributes that have string values.
func NewStringSimple ¶
func NewStringSimple(s string) StringAttribute
NewStringSimple creates a new StringAttribute with a simple int initial value.
type StringEqualer ¶
type StringEqualer struct {
S string
}
StringEqualer is a wrapper around string types for use with attributes. It has the Equal() method for comparison.
func (StringEqualer) Equal ¶
func (self StringEqualer) Equal(e Equaler) bool
Equal compares two values, must be StringEqualers, to see if they are the same.
func (StringEqualer) String ¶
func (self StringEqualer) String() string
String returns this value as a string (via fmt.Sprintf)
type StringSimple ¶
type StringSimple struct {
*AttributeImpl
}
StringSimple is an StringAttribute which cannot have any incoming edges, it is just a source of a simple string value.
func (*StringSimple) Set ¶
func (self *StringSimple) Set(s string)
func (*StringSimple) Value ¶
func (self *StringSimple) Value() string
type ViewImpl ¶
type ViewImpl struct {
// contains filtered or unexported fields
}
func HtmlConstant ¶
HtmlConstant is a wrapper for creating an entire subtree from HTML text. It makes no attempt to guarantee that the provided text is safe or sensible or anything. This takes a constant not an attribute because it's not clear that we can meaningfully do anything other than just add the HTML provided as text to the DOM.