1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Switch from govendor to go modules. (#587)

Thanks to @BenoitKnecht for leading the way on this.
This commit is contained in:
Tom Limoncelli
2020-01-18 14:40:28 -05:00
committed by GitHub
parent 31188c3a70
commit 16d0043cce
1554 changed files with 400867 additions and 98222 deletions

24
vendor/github.com/gopherjs/gopherjs/LICENSE generated vendored Normal file
View File

@ -0,0 +1,24 @@
Copyright (c) 2013 Richard Musiol. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

168
vendor/github.com/gopherjs/gopherjs/js/js.go generated vendored Normal file
View File

@ -0,0 +1,168 @@
// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax.
//
// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed:
//
// | Go type | JavaScript type | Conversions back to interface{} |
// | --------------------- | --------------------- | ------------------------------- |
// | bool | Boolean | bool |
// | integers and floats | Number | float64 |
// | string | String | string |
// | []int8 | Int8Array | []int8 |
// | []int16 | Int16Array | []int16 |
// | []int32, []int | Int32Array | []int |
// | []uint8 | Uint8Array | []uint8 |
// | []uint16 | Uint16Array | []uint16 |
// | []uint32, []uint | Uint32Array | []uint |
// | []float32 | Float32Array | []float32 |
// | []float64 | Float64Array | []float64 |
// | all other slices | Array | []interface{} |
// | arrays | see slice type | see slice type |
// | functions | Function | func(...interface{}) *js.Object |
// | time.Time | Date | time.Time |
// | - | instanceof Node | *js.Object |
// | maps, structs | instanceof Object | map[string]interface{} |
//
// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa.
package js
// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key.
type Object struct{ object *Object }
// Get returns the object's property with the given key.
func (o *Object) Get(key string) *Object { return o.object.Get(key) }
// Set assigns the value to the object's property with the given key.
func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) }
// Delete removes the object's property with the given key.
func (o *Object) Delete(key string) { o.object.Delete(key) }
// Length returns the object's "length" property, converted to int.
func (o *Object) Length() int { return o.object.Length() }
// Index returns the i'th element of an array.
func (o *Object) Index(i int) *Object { return o.object.Index(i) }
// SetIndex sets the i'th element of an array.
func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) }
// Call calls the object's method with the given name.
func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) }
// Invoke calls the object itself. This will fail if it is not a function.
func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) }
// New creates a new instance of this type object. This will fail if it not a function (constructor).
func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) }
// Bool returns the object converted to bool according to JavaScript type conversions.
func (o *Object) Bool() bool { return o.object.Bool() }
// String returns the object converted to string according to JavaScript type conversions.
func (o *Object) String() string { return o.object.String() }
// Int returns the object converted to int according to JavaScript type conversions (parseInt).
func (o *Object) Int() int { return o.object.Int() }
// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt).
func (o *Object) Int64() int64 { return o.object.Int64() }
// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt).
func (o *Object) Uint64() uint64 { return o.object.Uint64() }
// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat).
func (o *Object) Float() float64 { return o.object.Float() }
// Interface returns the object converted to interface{}. See table in package comment for details.
func (o *Object) Interface() interface{} { return o.object.Interface() }
// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use.
func (o *Object) Unsafe() uintptr { return o.object.Unsafe() }
// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object.
type Error struct {
*Object
}
// Error returns the message of the encapsulated JavaScript error object.
func (err *Error) Error() string {
return "JavaScript error: " + err.Get("message").String()
}
// Stack returns the stack property of the encapsulated JavaScript error object.
func (err *Error) Stack() string {
return err.Get("stack").String()
}
// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js).
var Global *Object
// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'.
var Module *Object
// Undefined gives the JavaScript value "undefined".
var Undefined *Object
// Debugger gets compiled to JavaScript's "debugger;" statement.
func Debugger() {}
// InternalObject returns the internal JavaScript object that represents i. Not intended for public use.
func InternalObject(i interface{}) *Object {
return nil
}
// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords.
func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object {
return Global.Call("$makeFunc", InternalObject(fn))
}
// Keys returns the keys of the given JavaScript object.
func Keys(o *Object) []string {
if o == nil || o == Undefined {
return nil
}
a := Global.Get("Object").Call("keys", o)
s := make([]string, a.Length())
for i := 0; i < a.Length(); i++ {
s[i] = a.Index(i).String()
}
return s
}
// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript.
func MakeWrapper(i interface{}) *Object {
v := InternalObject(i)
o := Global.Get("Object").New()
o.Set("__internal_object__", v)
methods := v.Get("constructor").Get("methods")
for i := 0; i < methods.Length(); i++ {
m := methods.Index(i)
if m.Get("pkg").String() != "" { // not exported
continue
}
o.Set(m.Get("name").String(), func(args ...*Object) *Object {
return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args)
})
}
return o
}
// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice.
func NewArrayBuffer(b []byte) *Object {
slice := InternalObject(b)
offset := slice.Get("$offset").Int()
length := slice.Get("$length").Int()
return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length)
}
// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion).
type M map[string]interface{}
// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion).
type S []interface{}
func init() {
// avoid dead code elimination
e := Error{}
_ = e
}

0
vendor/github.com/gopherjs/jquery/.gitattributes generated vendored Normal file
View File

2
vendor/github.com/gopherjs/jquery/.gitignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
/test/jquery-tests.ts.cs
/test/jquery.d.ts.cs

27
vendor/github.com/gopherjs/jquery/LICENSE generated vendored Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2019 The jQuery Bindings for GopherJS Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Vecty nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

88
vendor/github.com/gopherjs/jquery/README.md generated vendored Normal file
View File

@ -0,0 +1,88 @@
## jQuery Bindings for [GopherJS](http://github.com/gopherjs/gopherjs)
## Install
$ go get github.com/gopherjs/jquery
### How To Use
welcome.html file:
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to GopherJS with jQuery</title>
<script src="resources/jquery-2.1.0.js"></script>
</head>
<body>
<input id="name" type="text" value="" placeholder="What is your name ?" autofocus/>
<span id="output"></span>
<script src="welcome.js"></script>
</body>
</html>
```
welcome.go file:
```go
package main
import "github.com/gopherjs/jquery"
//convenience:
var jQuery = jquery.NewJQuery
const (
INPUT = "input#name"
OUTPUT = "span#output"
)
func main() {
//show jQuery Version on console:
print("Your current jQuery version is: " + jQuery().Jquery)
//catch keyup events on input#name element:
jQuery(INPUT).On(jquery.KEYUP, func(e jquery.Event) {
name := jQuery(e.Target).Val()
name = jquery.Trim(name)
//show welcome message:
if len(name) > 0 {
jQuery(OUTPUT).SetText("Welcome to GopherJS, " + name + " !")
} else {
jQuery(OUTPUT).Empty()
}
})
}
```
Compile welcome.go:
$ gopherjs build welcome.go
### Tests
In the "tests" folder are QUnit Tests, run the server with:
"go run server.go" and open a browser: http://localhost:3000
The relevant QUnit Test cases are defined in the test/index.go file.
### Sample Apps ported from Javascript/Coffeescript to GopherJS
Look at the Sample Apps to find out what is working and how. Any feedback is welcome !
- [TodoMVC, jQuery Example](https://github.com/gopherjs/todomvc)
- [Flappy Bird, Math Edition](https://github.com/rusco/flappy-math-saga)
- [Simple Tabata Timer](https://github.com/rusco/tabata-timer)
- [QUnit](https://github.com/rusco/qunit)
### Status
The normal DOM / Ajax / Deferreds Api is done and can be considered stable.
Please look up the index.go file in the test folder to see how it works.

883
vendor/github.com/gopherjs/jquery/jquery.go generated vendored Normal file
View File

@ -0,0 +1,883 @@
package jquery
import "github.com/gopherjs/gopherjs/js"
const (
JQ = "jQuery"
//keys
BLUR = "blur"
CHANGE = "change"
CLICK = "click"
DBLCLICK = "dblclick"
FOCUS = "focus"
FOCUSIN = "focusin"
FOCUSOUT = "focusout"
HOVER = "hover"
KEYDOWN = "keydown"
KEYPRESS = "keypress"
KEYUP = "keyup"
//form
SUBMIT = "submit"
LOAD = "load"
UNLOAD = "unload"
RESIZE = "resize"
//mouse
MOUSEDOWN = "mousedown"
MOUSEENTER = "mouseenter"
MOUSELEAVE = "mouseleave"
MOUSEMOVE = "mousemove"
MOUSEOUT = "mouseout"
MOUSEOVER = "mouseover"
MOUSEUP = "mouseup"
//touch
TOUCHSTART = "touchstart"
TOUCHMOVE = "touchmove"
TOUCHEND = "touchend"
TOUCHENTER = "touchenter"
TOUCHLEAVE = "touchleave"
TOUCHCANCEL = "touchcancel"
//ajax Events
AJAXSTART = "ajaxStart"
BEFORESEND = "beforeSend"
AJAXSEND = "ajaxSend"
SUCCESS = "success"
AJAXSUCESS = "ajaxSuccess"
ERROR = "error"
AJAXERROR = "ajaxError"
COMPLETE = "complete"
AJAXCOMPLETE = "ajaxComplete"
AJAXSTOP = "ajaxStop"
)
type JQuery struct {
o *js.Object
Jquery string `js:"jquery"`
Selector string `js:"selector"` //deprecated according jquery docs
Length int `js:"length"`
Context string `js:"context"`
}
type Event struct {
*js.Object
KeyCode int `js:"keyCode"`
Target *js.Object `js:"target"`
CurrentTarget *js.Object `js:"currentTarget"`
DelegateTarget *js.Object `js:"delegateTarget"`
RelatedTarget *js.Object `js:"relatedTarget"`
Data *js.Object `js:"data"`
Result *js.Object `js:"result"`
Which int `js:"which"`
Namespace string `js:"namespace"`
MetaKey bool `js:"metaKey"`
ShiftKey bool `js:"shiftKey"`
CtrlKey bool `js:"ctrlKey"`
PageX int `js:"pageX"`
PageY int `js:"pageY"`
Type string `js:"type"`
}
type JQueryCoordinates struct {
Left int
Top int
}
func (event *Event) PreventDefault() {
event.Call("preventDefault")
}
func (event *Event) IsDefaultPrevented() bool {
return event.Call("isDefaultPrevented").Bool()
}
func (event *Event) IsImmediatePropogationStopped() bool {
return event.Call("isImmediatePropogationStopped").Bool()
}
func (event *Event) IsPropagationStopped() bool {
return event.Call("isPropagationStopped").Bool()
}
func (event *Event) StopImmediatePropagation() {
event.Call("stopImmediatePropagation")
}
func (event *Event) StopPropagation() {
event.Call("stopPropagation")
}
func log(i ...interface{}) {
js.Global.Get("console").Call("log", i...)
}
//JQuery constructor
func NewJQuery(args ...interface{}) JQuery {
return JQuery{o: js.Global.Get(JQ).New(args...)}
}
//static function
func Trim(text string) string {
return js.Global.Get(JQ).Call("trim", text).String()
}
//static function
func GlobalEval(cmd string) {
js.Global.Get(JQ).Call("globalEval", cmd)
}
//static function
func Type(sth interface{}) string {
return js.Global.Get(JQ).Call("type", sth).String()
}
//static function
func IsPlainObject(sth interface{}) bool {
return js.Global.Get(JQ).Call("isPlainObject", sth).Bool()
}
//static function
func IsEmptyObject(sth interface{}) bool {
return js.Global.Get(JQ).Call("isEmptyObject", sth).Bool()
}
//static function
func IsFunction(sth interface{}) bool {
return js.Global.Get(JQ).Call("isFunction", sth).Bool()
}
//static function
func IsNumeric(sth interface{}) bool {
return js.Global.Get(JQ).Call("isNumeric", sth).Bool()
}
//static function
func IsXMLDoc(sth interface{}) bool {
return js.Global.Get(JQ).Call("isXMLDoc", sth).Bool()
}
//static function
func IsWindow(sth interface{}) bool {
return js.Global.Get(JQ).Call("isWindow", sth).Bool()
}
//static function
func InArray(val interface{}, arr []interface{}) int {
return js.Global.Get(JQ).Call("inArray", val, arr).Int()
}
//static function
func Contains(container interface{}, contained interface{}) bool {
return js.Global.Get(JQ).Call("contains", container, contained).Bool()
}
//static function
func ParseHTML(text string) []interface{} {
return js.Global.Get(JQ).Call("parseHTML", text).Interface().([]interface{})
}
//static function
func ParseXML(text string) interface{} {
return js.Global.Get(JQ).Call("parseXML", text).Interface()
}
//static function
func ParseJSON(text string) interface{} {
return js.Global.Get(JQ).Call("parseJSON", text).Interface()
}
//static function
func Grep(arr []interface{}, fn func(interface{}, int) bool) []interface{} {
return js.Global.Get(JQ).Call("grep", arr, fn).Interface().([]interface{})
}
//static function
func Noop() interface{} {
return js.Global.Get(JQ).Get("noop").Interface()
}
//static function
func Now() float64 {
return js.Global.Get(JQ).Call("now").Float()
}
//static function
func Unique(arr *js.Object) *js.Object {
return js.Global.Get(JQ).Call("unique", arr)
}
//methods
func (j JQuery) Each(fn func(int, interface{})) JQuery {
j.o = j.o.Call("each", fn)
return j
}
func (j JQuery) Call(name string, args ...interface{}) JQuery {
return NewJQuery(j.o.Call(name, args...))
}
func (j JQuery) Underlying() *js.Object {
return j.o
}
func (j JQuery) Get(i ...interface{}) *js.Object {
return j.o.Call("get", i...)
}
func (j JQuery) Append(i ...interface{}) JQuery {
j.o = j.o.Call("append", i...)
return j
}
func (j JQuery) Empty() JQuery {
j.o = j.o.Call("empty")
return j
}
func (j JQuery) Detach(i ...interface{}) JQuery {
j.o = j.o.Call("detach", i...)
return j
}
func (j JQuery) Eq(idx int) JQuery {
j.o = j.o.Call("eq", idx)
return j
}
func (j JQuery) FadeIn(i ...interface{}) JQuery {
j.o = j.o.Call("fadeIn", i...)
return j
}
func (j JQuery) Delay(i ...interface{}) JQuery {
j.o = j.o.Call("delay", i...)
return j
}
func (j JQuery) ToArray() []interface{} {
return j.o.Call("toArray").Interface().([]interface{})
}
func (j JQuery) Remove(i ...interface{}) JQuery {
j.o = j.o.Call("remove", i...)
return j
}
func (j JQuery) Stop(i ...interface{}) JQuery {
j.o = j.o.Call("stop", i...)
return j
}
func (j JQuery) AddBack(i ...interface{}) JQuery {
j.o = j.o.Call("addBack", i...)
return j
}
func (j JQuery) Css(name string) string {
return j.o.Call("css", name).String()
}
func (j JQuery) CssArray(arr ...string) map[string]interface{} {
return j.o.Call("css", arr).Interface().(map[string]interface{})
}
func (j JQuery) SetCss(i ...interface{}) JQuery {
j.o = j.o.Call("css", i...)
return j
}
func (j JQuery) Text() string {
return j.o.Call("text").String()
}
func (j JQuery) SetText(i interface{}) JQuery {
switch i.(type) {
case func(int, string) string, string:
default:
print("SetText Argument should be 'string' or 'func(int, string) string'")
}
j.o = j.o.Call("text", i)
return j
}
func (j JQuery) Val() string {
return j.o.Call("val").String()
}
func (j JQuery) SetVal(i interface{}) JQuery {
j.o.Call("val", i)
return j
}
//can return string or bool
func (j JQuery) Prop(property string) interface{} {
return j.o.Call("prop", property).Interface()
}
func (j JQuery) SetProp(i ...interface{}) JQuery {
j.o = j.o.Call("prop", i...)
return j
}
func (j JQuery) RemoveProp(property string) JQuery {
j.o = j.o.Call("removeProp", property)
return j
}
func (j JQuery) Attr(property string) string {
attr := j.o.Call("attr", property)
if attr == js.Undefined {
return ""
}
return attr.String()
}
func (j JQuery) SetAttr(i ...interface{}) JQuery {
j.o = j.o.Call("attr", i...)
return j
}
func (j JQuery) RemoveAttr(property string) JQuery {
j.o = j.o.Call("removeAttr", property)
return j
}
func (j JQuery) HasClass(class string) bool {
return j.o.Call("hasClass", class).Bool()
}
func (j JQuery) AddClass(i interface{}) JQuery {
switch i.(type) {
case func(int, string) string, string:
default:
print("addClass Argument should be 'string' or 'func(int, string) string'")
}
j.o = j.o.Call("addClass", i)
return j
}
func (j JQuery) RemoveClass(property string) JQuery {
j.o = j.o.Call("removeClass", property)
return j
}
func (j JQuery) ToggleClass(i ...interface{}) JQuery {
j.o = j.o.Call("toggleClass", i...)
return j
}
func (j JQuery) Focus() JQuery {
j.o = j.o.Call("focus")
return j
}
func (j JQuery) Blur() JQuery {
j.o = j.o.Call("blur")
return j
}
func (j JQuery) ReplaceAll(i interface{}) JQuery {
j.o = j.o.Call("replaceAll", i)
return j
}
func (j JQuery) ReplaceWith(i interface{}) JQuery {
j.o = j.o.Call("replaceWith", i)
return j
}
func (j JQuery) After(i ...interface{}) JQuery {
j.o = j.o.Call("after", i)
return j
}
func (j JQuery) Before(i ...interface{}) JQuery {
j.o = j.o.Call("before", i...)
return j
}
func (j JQuery) Prepend(i ...interface{}) JQuery {
j.o = j.o.Call("prepend", i...)
return j
}
func (j JQuery) PrependTo(i interface{}) JQuery {
j.o = j.o.Call("prependTo", i)
return j
}
func (j JQuery) AppendTo(i interface{}) JQuery {
j.o = j.o.Call("appendTo", i)
return j
}
func (j JQuery) InsertAfter(i interface{}) JQuery {
j.o = j.o.Call("insertAfter", i)
return j
}
func (j JQuery) InsertBefore(i interface{}) JQuery {
j.o = j.o.Call("insertBefore", i)
return j
}
func (j JQuery) Show(i ...interface{}) JQuery {
j.o = j.o.Call("show", i...)
return j
}
func (j JQuery) Hide(i ...interface{}) JQuery {
j.o.Call("hide", i...)
return j
}
func (j JQuery) Toggle(i ...interface{}) JQuery {
j.o = j.o.Call("toggle", i...)
return j
}
func (j JQuery) Contents() JQuery {
j.o = j.o.Call("contents")
return j
}
func (j JQuery) Html() string {
return j.o.Call("html").String()
}
func (j JQuery) SetHtml(i interface{}) JQuery {
switch i.(type) {
case func(int, string) string, string:
default:
print("SetHtml Argument should be 'string' or 'func(int, string) string'")
}
j.o = j.o.Call("html", i)
return j
}
func (j JQuery) Closest(i ...interface{}) JQuery {
j.o = j.o.Call("closest", i...)
return j
}
func (j JQuery) End() JQuery {
j.o = j.o.Call("end")
return j
}
func (j JQuery) Add(i ...interface{}) JQuery {
j.o = j.o.Call("add", i...)
return j
}
func (j JQuery) Clone(b ...interface{}) JQuery {
j.o = j.o.Call("clone", b...)
return j
}
func (j JQuery) Height() int {
return j.o.Call("height").Int()
}
func (j JQuery) SetHeight(value string) JQuery {
j.o = j.o.Call("height", value)
return j
}
func (j JQuery) Width() int {
return j.o.Call("width").Int()
}
func (j JQuery) SetWidth(i interface{}) JQuery {
switch i.(type) {
case func(int, string) string, string:
default:
print("SetWidth Argument should be 'string' or 'func(int, string) string'")
}
j.o = j.o.Call("width", i)
return j
}
func (j JQuery) Index(i interface{}) int {
return j.o.Call("index", i).Int()
}
func (j JQuery) InnerHeight() int {
return j.o.Call("innerHeight").Int()
}
func (j JQuery) InnerWidth() int {
return j.o.Call("innerWidth").Int()
}
func (j JQuery) Offset() JQueryCoordinates {
obj := j.o.Call("offset")
return JQueryCoordinates{Left: obj.Get("left").Int(), Top: obj.Get("top").Int()}
}
func (j JQuery) SetOffset(jc JQueryCoordinates) JQuery {
j.o = j.o.Call("offset", jc)
return j
}
func (j JQuery) OuterHeight(includeMargin ...bool) int {
if len(includeMargin) == 0 {
return j.o.Call("outerHeight").Int()
}
return j.o.Call("outerHeight", includeMargin[0]).Int()
}
func (j JQuery) OuterWidth(includeMargin ...bool) int {
if len(includeMargin) == 0 {
return j.o.Call("outerWidth").Int()
}
return j.o.Call("outerWidth", includeMargin[0]).Int()
}
func (j JQuery) Position() JQueryCoordinates {
obj := j.o.Call("position")
return JQueryCoordinates{Left: obj.Get("left").Int(), Top: obj.Get("top").Int()}
}
func (j JQuery) ScrollLeft() int {
return j.o.Call("scrollLeft").Int()
}
func (j JQuery) SetScrollLeft(value int) JQuery {
j.o = j.o.Call("scrollLeft", value)
return j
}
func (j JQuery) ScrollTop() int {
return j.o.Call("scrollTop").Int()
}
func (j JQuery) SetScrollTop(value int) JQuery {
j.o = j.o.Call("scrollTop", value)
return j
}
func (j JQuery) ClearQueue(queueName string) JQuery {
j.o = j.o.Call("clearQueue", queueName)
return j
}
func (j JQuery) SetData(key string, value interface{}) JQuery {
j.o = j.o.Call("data", key, value)
return j
}
func (j JQuery) Data(key string) interface{} {
result := j.o.Call("data", key)
if result == js.Undefined {
return nil
}
return result.Interface()
}
func (j JQuery) Dequeue(queueName string) JQuery {
j.o = j.o.Call("dequeue", queueName)
return j
}
func (j JQuery) RemoveData(name string) JQuery {
j.o = j.o.Call("removeData", name)
return j
}
func (j JQuery) OffsetParent() JQuery {
j.o = j.o.Call("offsetParent")
return j
}
func (j JQuery) Parent(i ...interface{}) JQuery {
j.o = j.o.Call("parent", i...)
return j
}
func (j JQuery) Parents(i ...interface{}) JQuery {
j.o = j.o.Call("parents", i...)
return j
}
func (j JQuery) ParentsUntil(i ...interface{}) JQuery {
j.o = j.o.Call("parentsUntil", i...)
return j
}
func (j JQuery) Prev(i ...interface{}) JQuery {
j.o = j.o.Call("prev", i...)
return j
}
func (j JQuery) PrevAll(i ...interface{}) JQuery {
j.o = j.o.Call("prevAll", i...)
return j
}
func (j JQuery) PrevUntil(i ...interface{}) JQuery {
j.o = j.o.Call("prevUntil", i...)
return j
}
func (j JQuery) Siblings(i ...interface{}) JQuery {
j.o = j.o.Call("siblings", i...)
return j
}
func (j JQuery) Slice(i ...interface{}) JQuery {
j.o = j.o.Call("slice", i...)
return j
}
func (j JQuery) Children(selector interface{}) JQuery {
j.o = j.o.Call("children", selector)
return j
}
func (j JQuery) Unwrap() JQuery {
j.o = j.o.Call("unwrap")
return j
}
func (j JQuery) Wrap(obj interface{}) JQuery {
j.o = j.o.Call("wrap", obj)
return j
}
func (j JQuery) WrapAll(i interface{}) JQuery {
j.o = j.o.Call("wrapAll", i)
return j
}
func (j JQuery) WrapInner(i interface{}) JQuery {
j.o = j.o.Call("wrapInner", i)
return j
}
func (j JQuery) Next(i ...interface{}) JQuery {
j.o = j.o.Call("next", i...)
return j
}
func (j JQuery) NextAll(i ...interface{}) JQuery {
j.o = j.o.Call("nextAll", i...)
return j
}
func (j JQuery) NextUntil(i ...interface{}) JQuery {
j.o = j.o.Call("nextUntil", i...)
return j
}
func (j JQuery) Not(i ...interface{}) JQuery {
j.o = j.o.Call("not", i...)
return j
}
func (j JQuery) Filter(i ...interface{}) JQuery {
j.o = j.o.Call("filter", i...)
return j
}
func (j JQuery) Find(i ...interface{}) JQuery {
j.o = j.o.Call("find", i...)
return j
}
func (j JQuery) First() JQuery {
j.o = j.o.Call("first")
return j
}
func (j JQuery) Has(selector string) JQuery {
j.o = j.o.Call("has", selector)
return j
}
func (j JQuery) Is(i ...interface{}) bool {
return j.o.Call("is", i...).Bool()
}
func (j JQuery) Last() JQuery {
j.o = j.o.Call("last")
return j
}
func (j JQuery) Ready(handler func()) JQuery {
j.o = j.o.Call("ready", handler)
return j
}
func (j JQuery) Resize(i ...interface{}) JQuery {
j.o = j.o.Call("resize", i...)
return j
}
func (j JQuery) Scroll(i ...interface{}) JQuery {
j.o = j.o.Call("scroll", i...)
return j
}
func (j JQuery) FadeOut(i ...interface{}) JQuery {
j.o = j.o.Call("fadeOut", i...)
return j
}
func (j JQuery) FadeToggle(i ...interface{}) JQuery {
j.o = j.o.Call("fadeToggle", i...)
return j
}
func (j JQuery) SlideDown(i ...interface{}) JQuery {
j.o = j.o.Call("slideDown", i...)
return j
}
func (j JQuery) SlideToggle(i ...interface{}) JQuery {
j.o = j.o.Call("slideToggle", i...)
return j
}
func (j JQuery) SlideUp(i ...interface{}) JQuery {
j.o = j.o.Call("slideUp", i...)
return j
}
func (j JQuery) Select(i ...interface{}) JQuery {
j.o = j.o.Call("select", i...)
return j
}
func (j JQuery) Submit(i ...interface{}) JQuery {
j.o = j.o.Call("submit", i...)
return j
}
func (j JQuery) Trigger(i ...interface{}) JQuery {
j.o = j.o.Call("trigger", i...)
return j
}
func (j JQuery) On(i ...interface{}) JQuery {
j.o = j.o.Call("on", i...)
return j
}
func (j JQuery) One(i ...interface{}) JQuery {
j.o = j.o.Call("one", i...)
return j
}
func (j JQuery) Off(i ...interface{}) JQuery {
j.o = j.o.Call("off", i...)
return j
}
//ajax
func Param(params map[string]interface{}) {
js.Global.Get(JQ).Call("param", params)
}
func (j JQuery) Load(i ...interface{}) JQuery {
j.o = j.o.Call("load", i...)
return j
}
func (j JQuery) Serialize() string {
return j.o.Call("serialize").String()
}
func (j JQuery) SerializeArray() *js.Object {
return j.o.Call("serializeArray")
}
func Ajax(options map[string]interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("ajax", options)}
}
func AjaxPrefilter(i ...interface{}) {
js.Global.Get(JQ).Call("ajaxPrefilter", i...)
}
func AjaxSetup(options map[string]interface{}) {
js.Global.Get(JQ).Call("ajaxSetup", options)
}
func AjaxTransport(i ...interface{}) {
js.Global.Get(JQ).Call("ajaxTransport", i...)
}
func Get(i ...interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("get", i...)}
}
func Post(i ...interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("post", i...)}
}
func GetJSON(i ...interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("getJSON", i...)}
}
func GetScript(i ...interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("getScript", i...)}
}
func (d Deferred) Promise() *js.Object {
return d.Call("promise")
}
type Deferred struct {
*js.Object
}
func (d Deferred) Then(fn ...interface{}) Deferred {
return Deferred{d.Call("then", fn...)}
}
func (d Deferred) Always(fn ...interface{}) Deferred {
return Deferred{d.Call("always", fn...)}
}
func (d Deferred) Done(fn ...interface{}) Deferred {
return Deferred{d.Call("done", fn...)}
}
func (d Deferred) Fail(fn ...interface{}) Deferred {
return Deferred{d.Call("fail", fn...)}
}
func (d Deferred) Progress(fn interface{}) Deferred {
return Deferred{d.Call("progress", fn)}
}
func When(d ...interface{}) Deferred {
return Deferred{js.Global.Get(JQ).Call("when", d...)}
}
func (d Deferred) State() string {
return d.Call("state").String()
}
func NewDeferred() Deferred {
return Deferred{js.Global.Get(JQ).Call("Deferred")}
}
func (d Deferred) Resolve(i ...interface{}) Deferred {
return Deferred{d.Call("resolve", i...)}
}
func (d Deferred) Reject(i ...interface{}) Deferred {
return Deferred{d.Call("reject", i...)}
}
func (d Deferred) Notify(i interface{}) Deferred {
return Deferred{d.Call("notify", i)}
}
//2do: animations api
//2do: test values against "undefined" values
//2do: more docs