'use strict'; /*@ Ox.Element Basic UI element object # Arguments ---------------------------------------------------------------- options Options of the element, or just the `element` option element Tagname or CSS selector tooltip Tooltip title, or a function that returns one (e) -> Tooltip title e Mouse event self Shared private variable # Usage -------------------------------------------------------------------- ([options[, self]]) -> Element object # Events --------------------------------------------------------------- anyclick anyclick Fires on mouseup, but not on any subsequent mouseup within 250 ms (this is useful if one wants to listen for singleclicks, but not doubleclicks, since it will fire immediately, and won't fire again in case of a doubleclick) * <*> Original event properties doubleclick doubleclick Fires on the second mousedown within 250 ms (this is useful if one wants to listen for both singleclicks and doubleclicks, since it will not trigger a singleclick event) * <*> Original event properties drag drag Fires on mousemove after dragstart, stops firing on mouseup clientDX Horizontal drag delta in px clientDY Vertical drag delta in px * <*> Original event properties dragend dragpause Fires on mouseup after dragstart clientDX Horizontal drag delta in px clientDY Vertical drag delta in px * <*> Original event properties dragenter dragenter Fires when entering an element during drag (this fires on the element being dragged -- the target element is the event's target property) clientDX Horizontal drag delta in px clientDY Vertical drag delta in px * <*> Original event properties dragleave dragleave Fires when leaving an element during drag (this fires on the element being dragged -- the target element is the event's target property) clientDX Horizontal drag delta in px clientDY Vertical drag delta in px * <*> Original event properties dragpause dragpause Fires once when the mouse doesn't move for 250 ms during drag (this is useful in order to execute operations that are too expensive to be attached to the drag event) clientDX Horizontal drag delta in px clientDY Vertical drag delta in px * <*> Original event properties dragstart dragstart Fires when the mouse is down for 250 ms * <*> Original event properties mousedown mousedown Fires on mousedown (this is useful if one wants to listen for singleclicks, but not doubleclicks or drag events, and wants the event to fire as early as possible) * <*> Original event properties mouserepeat mouserepeat Fires every 50 ms after the mouse was down for 250 ms, stops firing on mouseleave or mouseup (this fires like a key that is being pressed and held, and is useful for buttons like scrollbars arrows that need to react to both clicking and holding) mousewheel mousewheel Fires on mousewheel scroll or trackpad swipe deltaFactor Original delta = normalized delta * delta factor deltaX Normalized horizontal scroll delta in px deltaY Vertical scroll delta in px * <*> Original event properties singleclick singleclick Fires 250 ms after mouseup, if there was no subsequent mousedown (this is useful if one wants to listen for both singleclicks and doubleclicks, since it will not fire for doubleclicks) * <*> Original event properties */ Ox.Element = function(options, self) { // create private object self = self || {}; // create defaults and options objects self.defaults = {}; // allow for Ox.TestElement('') or Ox.TestElement('cssSelector') self.options = Ox.isString(options) ? {element: options} : options || {}; // stack of callbacks bound to option updates self.updateCallbacks = self.updateCallbacks || []; // create public object var that = new Ox.JQueryElement($(self.options.element || '
')) .addClass('OxElement') .on({ mousedown: mousedown, mousewheel: mousewheel }); if (self.options.element == '