org.querki.jquery

JQuery

Related Doc: package jquery

trait JQuery extends 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 are currently dealing with the messy cases by defining a polymorphic type in package.scala, using the "tor" type-union trick, and then defining a mid-level facade for that method in JQueryTyped. Then we put a primitive "Internal" version of the method in here. As a rule, you should not directly use any methods here named [something]Internal -- they should always have a more precisely-typed version in JQueryTyped.

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.

TODO: we should probably mark the XXXInternal methods as private [jquery]. See if that works.

Annotations
@RawJSType()
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. JQuery
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def addClass(func: ThisFunction2[Element, Int, String, String]): JQuery

  5. def addClass(classNames: String): JQuery

    Adds the specified class(es) to each of the set of matched elements.

  6. def afterInternal(content: Any*): JQuery

    Annotations
    @JSName( "after" )
  7. def appendInternal(content: Any*): JQuery

    Annotations
    @JSName( "append" )
  8. def appendToInternal(target: Any): JQuery

    Annotations
    @JSName( "appendTo" )
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def attrInternal(attributeName: String, v: Any): JQuery

    Annotations
    @JSName( "attr" )
  11. def attrInternal(attributes: Dictionary[String]): JQuery

    Annotations
    @JSName( "attr" )
  12. def attrInternal(attributeName: String): UndefOr[String]

    Annotations
    @JSName( "attr" )
  13. def change(): JQuery

  14. def change(eventData: Any, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  15. def change(handler: Function1[JQueryEventObject, Any]): JQuery

  16. def change(handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  17. def change(handler: ThisFunction0[Element, Any]): JQuery

    Bind an event handler to the "change" JavaScript event, or trigger that event on an element.

    Bind an event handler to the "change" JavaScript event, or trigger that event on an element.

    NOTE: the jQuery documentation is very fuzzy on this point, but implies in an example that "this" gets set appropriately.

  18. def children(): JQuery

  19. def children(selector: String): JQuery

    Get the children of each element in the set of matched elements, optionally filtered by a selector.

  20. def click(): JQuery

  21. def click(func: Function0[Any]): JQuery

  22. def click(func: Function1[JQueryEventObject, Any]): JQuery

  23. def click(func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  24. def click(func: ThisFunction0[Element, Any]): JQuery

    Bind an event handler to the "click" JavaScript event, or trigger that event on an element.

    Bind an event handler to the "click" JavaScript event, or trigger that event on an element.

    This is the simpler version, and usually what you want.

  25. def clone(withDataAndEvents: Boolean, deepWithDataAndEvents: Boolean): JQuery

  26. def clone(withDataAndEvents: Boolean): JQuery

  27. def clone(): JQuery

    Create a deep copy of the set of matched elements.

    Create a deep copy of the set of matched elements.

    Note that this requires an override because Scala.Object declares a clone() method which is entirely unrelated.

    Definition Classes
    JQuery → AnyRef
  28. def css(properties: Dictionary[Any]): JQuery

  29. def css(propertyName: String, value: Int): JQuery

  30. def css(propertyName: String, value: String): JQuery

  31. def css(propertyNames: Array[String]): Dictionary[String]

  32. def css(propertyName: String): String

    Get the computed style properties for the first element in the set of matched elements.

  33. def data(): Dictionary[Any]

    Calling .data() with no parameters retrieves all of the values as a JavaScript object.

    Calling .data() with no parameters retrieves all of the values as a JavaScript object. This object can be safely cached in a variable as long as a new object is not set with .data(obj). Using the object directly to get or set values is faster than making individual calls to .data() to get or set each value.

  34. def data(key: String): Any

    Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.

  35. def data(obj: Dictionary[Any]): JQuery

  36. def data(key: String, value: Any): JQuery

    Store arbitrary data associated with the matched elements.

    Store arbitrary data associated with the matched elements.

    undefined is not recognised as a data value. Calls such as .data( "name", undefined ) will return the corresponding data for "name", and is therefore the same as .data( "name" ).

  37. def dblclick(func: Function0[Any]): JQuery

  38. def dblclick(func: Function1[JQueryEventObject, Any]): JQuery

  39. def dblclick(func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  40. def dblclick(func: ThisFunction0[Element, Any]): JQuery

    Bind an event handler to the "dblclick" JavaScript event.

    Bind an event handler to the "dblclick" JavaScript event.

    This is the simpler version, and usually what you want.

  41. def delay(duration: Int, queueName: String): JQuery

  42. def delay(duration: Int): JQuery

    Set a timer to delay execution of subsequent items in the queue.

  43. def detach(selector: String): JQuery

  44. def detach(): JQuery

    Remove the set of matched elements from the DOM.

  45. def each(func: ThisFunction1[Element, Int, Any]): JQuery

  46. def each(func: ThisFunction0[Element, Any]): JQuery

    Iterate over a jQuery object, executing a function for each matched element.

    Iterate over a jQuery object, executing a function for each matched element.

    Note that we do not bother with the full jQuery signature, since the "element" parameter simply matches "this".

    You can stop the loop from within the callback function by returning false. Otherwise, the return value is irrelevant.

  47. def empty(): JQuery

    Remove all child nodes of the set of matched elements from the DOM.

  48. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  49. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  50. def filterInternal(selectorOrFunc: Any): JQuery

    Annotations
    @JSName( "filter" )
  51. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  52. def findInternal(selector: Any): JQuery

    Annotations
    @JSName( "find" )
  53. def first(): JQuery

    Reduce the set of matched elements to the first in the set.

  54. def focus(eventData: Any, func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  55. def focus(func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  56. def focus(): JQuery

    Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.

  57. def get(): Array[_]

    Retrieve the elements matched by the jQuery object.

  58. def get(index: Int): UndefOr[Element]

    Retrieve one of the elements matched by the jQuery object.

    Retrieve one of the elements matched by the jQuery object.

    If the value of index is out of bounds - less than the negative number of elements or equal to or greater than the number of elements - it returns undefined.

  59. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  60. def hasClass(className: String): Boolean

    Determine whether any of the matched elements are assigned the given class.

  61. def hasOwnProperty(v: String): Boolean

    Definition Classes
    Object
  62. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  63. def height(value: String): JQuery

  64. def height(value: Double): JQuery

    Set the CSS height of every matched element.

  65. def height(): Double

    Get the current computed height for the first element in the set of matched elements.

  66. def hide(duration: Int, easing: String, complete: Function): JQuery

  67. def hide(duration: Int, easing: String): JQuery

  68. def hide(duration: Int, complete: Function): JQuery

  69. def hide(duration: Int): JQuery

  70. def hide(duration: String, easing: String, complete: Function): JQuery

  71. def hide(duration: String, easing: String): JQuery

  72. def hide(duration: String, complete: Function): JQuery

  73. def hide(duration: String): JQuery

  74. def hide(): JQuery

    Hide the matched elements.

  75. def html(func: ThisFunction2[Element, Int, String, String]): JQuery

  76. def html(t: String): JQuery

    Set the HTML contents of every matched element.

  77. def html(): String

    Get the HTML contents of the first element in the set of matched elements.

  78. def indexInternal(selector: Any): Int

    Annotations
    @JSName( "index" )
  79. def indexInternal(): Int

    Annotations
    @JSName( "index" )
  80. def insertBeforeInternal(selector: Any): JQuery

    Annotations
    @JSName( "insertBefore" )
  81. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  82. def isInternal(selector: Any): Boolean

    Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

    Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

    Annotations
    @JSName( "is" )
  83. def isPrototypeOf(v: Object): Boolean

    Definition Classes
    Object
  84. def keydown(): JQuery

  85. def keydown(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  86. def keydown(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element.

  87. def keypress(): JQuery

  88. def keypress(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  89. def keypress(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element.

  90. def keyup(): JQuery

  91. def keyup(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  92. def keyup(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element.

  93. def length: Int

    The number of elements in the jQuery object.

  94. def map(func: ThisFunction1[Element, Int, Any]): JQuery

  95. def map(func: ThisFunction0[Element, Any]): JQuery

    Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

    Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

    For Scala code, it is often more convenient to use the mapElems() extension function.

    Within the callback function, this refers to the current DOM element for each iteration. The function can return an individual data item or an array of data items to be inserted into the resulting set.

    If a js.Array is returned, the elements inside the array are inserted into the set. If the function returns null or undefined, no element will be inserted. (Note the implication: this doesn't quite match the usual Scala semantics of map() -- there is a flatten component as well.)

  96. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  97. final def notify(): Unit

    Definition Classes
    AnyRef
  98. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  99. def off(event: JQueryEventObject): JQuery

  100. def off(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]]): JQuery

  101. def off(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String): JQuery

  102. def off(): JQuery

  103. def off(events: String): JQuery

  104. def off(events: String, selector: String): JQuery

  105. def off(events: String, selector: String, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

    Remove an event handler.

  106. def offset(): JQueryPosition

    Get the current coordinates of the first element in the set of matched elements, relative to the document.

  107. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]]): JQuery

  108. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String): JQuery

  109. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String, data: Any): JQuery

  110. def on(events: String): JQuery

  111. def on(events: String, turnOff: Boolean): JQuery

  112. def on(events: String, selector: String): JQuery

  113. def on(events: String, selector: String, data: Any): JQuery

  114. def on(events: String, selector: String, data: Any, turnOff: Boolean): JQuery

    Attach an event handler function for one or more events to the selected elements.

    Attach an event handler function for one or more events to the selected elements.

    This version of the signature allows you to pass in "false" as the handler. This is kind of magical in jQuery -- it is shorthand for a function that just does "return false", which stops propagation on the event. Note that true is *not* a legal value, only false.

  115. def on(events: String, handler: Function1[JQueryEventObject, Any]): JQuery

  116. def on(events: String, handler: ThisFunction0[Element, Any]): JQuery

  117. def on(events: String, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  118. def on(events: String, selector: String, data: Any, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

    Attach an event handler function for one or more events to the selected elements.

  119. def parent(): JQuery

  120. def parent(selector: String): JQuery

    Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

    Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

    TBD: is the parameter really a Selector, or just a String? The JQuery API docs are unclear.

  121. def parents(): JQuery

  122. def parents(selector: String): JQuery

    Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

  123. def prependInternal(contents: Any*): JQuery

    Insert content, specified by the parameters, to the beginning of each element in the set of matched elements.

    Insert content, specified by the parameters, to the beginning of each element in the set of matched elements.

    Annotations
    @JSName( "prepend" )
  124. def prop(propertyName: String, func: ThisFunction2[Element, Int, Any, Any]): JQuery

  125. def prop(properties: Dictionary[Any]): JQuery

  126. def prop(propertyName: String, value: Any): JQuery

    Set one or more properties for the set of matched elements.

  127. def prop(propertyName: String): Any

    Get the value of a property for the first element in the set of matched elements.

  128. def propertyIsEnumerable(v: String): Boolean

    Definition Classes
    Object
  129. def remove(childSelector: String): JQuery

  130. def remove(): JQuery

    Remove the set of matched elements from the DOM.

  131. def removeClass(func: ThisFunction2[Element, Int, String, String]): JQuery

  132. def removeClass(classNames: String): JQuery

  133. def removeClass(): JQuery

    Remove a single class, multiple classes, or all classes from each element in the set of matched elements.

  134. def replaceWithInternal(content: Any): JQuery

    Annotations
    @JSName( "replaceWith" )
  135. def scrollTop(value: Double): JQuery

    Set the current vertical position of the scroll bar for each of the set of matched elements.

    Set the current vertical position of the scroll bar for each of the set of matched elements.

    Note that this intentionally takes Double -- while you usually want to set it to an Int, there are occasions when being able to take a Double (that is, a full JS Number) is convenient in code.

  136. def scrollTop(): Int

    Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.

  137. def show(duration: Int, easing: String, complete: Function): JQuery

  138. def show(duration: Int, easing: String): JQuery

  139. def show(duration: Int, complete: Function): JQuery

  140. def show(duration: Int): JQuery

  141. def show(duration: String, easing: String, complete: Function): JQuery

  142. def show(duration: String, easing: String): JQuery

  143. def show(duration: String, complete: Function): JQuery

  144. def show(duration: String): JQuery

  145. def show(): JQuery

    Hide the matched elements.

  146. def slideDown(duration: Int, complete: Function): JQuery

  147. def slideDown(duration: Int): JQuery

  148. def slideDown(duration: String, complete: Function): JQuery

  149. def slideDown(duration: String): JQuery

  150. def slideDown(): JQuery

    Display the matched elements with a sliding motion.

  151. def slideUp(duration: Int, complete: Function): JQuery

  152. def slideUp(duration: Int): JQuery

  153. def slideUp(duration: String, complete: Function): JQuery

  154. def slideUp(duration: String): JQuery

  155. def slideUp(): JQuery

    Hide the matched elements with a sliding motion.

  156. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  157. def text(func: Function2[Int, String, String]): JQuery

  158. def text(t: String): JQuery

    Set the content of each element in the set of matched elements to the specified text.

  159. def text(): String

    Get the combined text contents of each element in the set of matched elements, including their descendants.

  160. def toArray(): Array[Element]

    Retrieve all the elements contained in the jQuery set, as an array.

  161. def toLocaleString(): String

    Definition Classes
    Object
  162. def toString(): String

    Definition Classes
    AnyRef → Any
  163. def trigger(event: JQueryEventObject): JQuery

  164. def trigger(eventType: String): JQuery

    Execute all handlers and behaviors attached to the matched elements for the given event type.

  165. def val(func: Function2[Int, String, String]): JQuery

  166. def val(value: String): JQuery

  167. def val(value: Array[String]): JQuery

  168. def val(): Dynamic

    Get the value of this JQuery.

    Get the value of this JQuery.

    "value" is highly context-dependent. The signature is loose because it can return a String, a Number (?) or an Array, depending on circumstances. See the extension methods in JQueryExtensions for more strongly-typed versions that you can use when you expect a specific return type.

  169. def value(func: Function2[Int, String, String]): JQuery

    Annotations
    @JSName( "val" )
  170. def value(value: String): JQuery

    Annotations
    @JSName( "val" )
  171. def value(value: Array[String]): JQuery

    Annotations
    @JSName( "val" )
  172. def value(): Dynamic

    Annotations
    @JSName( "val" )
  173. def valueOf(): Any

    Definition Classes
    Object
  174. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  175. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  176. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  177. def width(value: String): JQuery

  178. def width(value: Double): JQuery

    Set the CSS width of every matched element.

  179. def width(): Double

    Get the current computed width for the first element in the set of matched elements.

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped