'use strict'; /*@ Ox.JQueryElement Wrapper for jQuery ($element) -> Wrapped jQuery DOM element $element jQuery DOM Element @*/ Ox.JQueryElement = function($element) { var that = this; //@ id Unique id that.oxid = Ox.uid(); //@ $element The jQuery-wrapped DOM element that.$element = $element.data({ oxid: that.oxid }); //@ 0 The DOM element that[0] = that.$element[0]; //@ length 1 (for compatibility with jQuery) that.length = 1; Ox.UI.elements[that.oxid] = that; return that; }; // add all jQuery functions to the prototype of Ox.JQueryElement Ox.methods($('
'), true).forEach(function(method) { Ox.JQueryElement.prototype[method] = function() { var args = arguments, oxid, ret, that = this; ret = that.$element[method].apply(that.$element, args); // if exactly one $element of an ox object was returned // then return the ox object instead // so that we can do oxObj.jqFn().oxFn() return ret && ret.jquery && ret.length == 1 && Ox.UI.elements[oxid = ret.data('oxid')] ? Ox.UI.elements[oxid] : ret; }; });