This union type represents valid types that you can set an attribute to.
This union type gets used for several functions that really allow anything that can describe an Element.
This union type gets used for several functions that really allow anything that can describe an Element. This is similar to Selector, but allows you to pass in a JQuery as well.
This union type covers the possible signatures of functions to pass into event-registration functions like "click" or "hover".
A shorter alias for JQuery events, just to reduce keystrokes.
A facade for the main jQuery object.
A facade for the main jQuery object.
This is a reimplementation, very loosely based on the existing scalajs-jquery. It aims to be much more strongly and precisely typed, while being as literal a translation of the functionality of jQuery as possible. It is intentionally pretty close to scalajs-jquery, and many files can be switched over by simply switching the import, but compatibility has *not* been a priority, and a modest number of functions have changed in breaking ways. (This is one reason why I treated this as a rewrite rather than as an evolution of the existing library.)
TODO: as of this writing, this is *quite* incomplete; I am only adding functions as I use them, and at least half of them are currently missing. Pull requests are greatly welcomed. In particular, we are lacking many overloads -- I've added some of them, but many jQuery functions have a considerable number of potential overloads.
Many parameters are polymorphic. We often use | (type union) to define these, but | and UndefOr don't mix, so we often have to spell things out in more detail. Also, you can't use a js.Function or js.ThisFunction in a | expression, because it interferes with the compiler's implicit conversion from a Scala function to a js.Function. Note that there are several common unions such as Selector defined in package.scala.
Things are also often spelled out more explicitly than you might expect, because Scala restricts us to one overload per method with default parameters; this limits our usage of UndefOr.
We don't necessarily spell out every possible overload here, although we've made a serious effort to make every version of the JS calls possible. In some cases, we only have versions that involve some extra parameters. If you find yourself really wanting an overload that takes fewer parameters, pull requests are welcome.
NOTE: discussion on scalajs Gitter, 1/28/15, says that facades should *return* Any, but *take* js.Any *if* the Javascript is going to process the value in any way. This is the guiding principle here.
Also: when a facade function takes a property bag, if it is understood to be name/value pairs in JS, declare it as js.Dictionary[T]. Often, we can constrain T; if not, just put js.Any, and it is at least explicit that it is name/value pairs.
Long-deprecated functions are, by and large, simply omitted. Please see the jQuery documentation to see what to use instead.
The facade over an event from JQuery.
The facade over an event from JQuery.
These are extensions to jQuery -- useful higher-level functions, which mostly tighten up the types.
These are extensions to jQuery -- useful higher-level functions, which mostly tighten up the types.
Basically, when you want to express a common idiom, especially one that is particularly helpful in the Scala environment, it belongs here. But this isn't for complex high-level logic, just for stuff that makes JQuery easier to use in Scala.
Within those constraints, pull requests are welcome for additional utility functions that seem to be at the same level.
Returned by offset() and position().
Returned by offset() and position().
Note that the values in here are intentionally not Integers. From the JQuery docs:
"The number returned by dimensions-related APIs, including .offset(), may be fractional in some cases. Code should not assume it is an integer. Also, dimensions may be incorrect when the page is zoomed by the user; browsers do not expose an API to detect this condition."
Returned by serializeArray().
Returned by serializeArray().
This is a particularly important union type.
This is a particularly important union type. Selector is a common parameter type in jQuery, meaning essentially a filter for choosing some elements. It can be a string describing a kind of node (using a CSS-ish syntax), an Element, or an Array of Elements.
Note that the jQuery API documentation is *extremely* inconsistent about how it treats the term "Selector" -- sometimes it just uses the term to mean Strings, sometimes it means all of the possible types. So use this with some care.
The main entry point into jQuery.
The main entry point into jQuery. We alias it to $, to match jQuery idiom.
Constructor facade for JQueryEventObject.
Constructor facade for JQueryEventObject. See the documentation of the JQueryEventObject trait for more information about the various constructor methods.
TBD: does this need to use jsext? Possibly not. Look at this more closely, and see if switching to a more straightforward constructor is more appropriate in this case. If all of the parameters are singly-typed, then jsext is overkill.
In general, this is rather half-baked, and needs enhancement and sanity-checking.
Convenience conversion, so that you can use a Scala Seq[Element] where the API expects a js.Array[Element].