diff --git a/source/Ox.UI/Ox.UI.js b/source/Ox.UI/Ox.UI.js index 20ee3809..c5c7ba1d 100644 --- a/source/Ox.UI/Ox.UI.js +++ b/source/Ox.UI/Ox.UI.js @@ -354,6 +354,13 @@ Ox.load.UI = function(options, callback) { }); }; Ox.UI.IMAGE_CACHE = []; + /*@ + Ox.UI.isElement check if object is an Ox.Element + (obj) -> true if object is an Ox.Element + @*/ + Ox.UI.isElement = function(obj) { + return Ox.isObject(obj) && 'oxid' in obj; + }; Ox.UI.PATH = Ox.PATH + 'Ox.UI/'; Ox.UI.SCROLLBAR_SIZE = $.browser.mozilla ? 16 : 12; // fixme: the follwing should be deprecated diff --git a/source/Ox.UI/js/Core/Ox.Element.js b/source/Ox.UI/js/Core/Ox.Element.js index 793e6764..cb41e786 100644 --- a/source/Ox.UI/js/Core/Ox.Element.js +++ b/source/Ox.UI/js/Core/Ox.Element.js @@ -324,7 +324,7 @@ Ox.Element = function(options, self) { () -> object @*/ that.bindKeyboard = function() { - Ox.Keyboard.bind(that.id); + Ox.Keyboard.bind(that.oxid); return that; }; @@ -353,7 +353,7 @@ Ox.Element = function(options, self) { () -> This element object @*/ that.gainFocus = function() { - Ox.Focus.focus(that.id); + Ox.Focus.focus(that.oxid); return that; }; @@ -362,7 +362,7 @@ Ox.Element = function(options, self) { () -> True if the element has focus @*/ that.hasFocus = function() { - return Ox.Focus.focused() == that.id; + return Ox.Focus.focused() == that.oxid; }; /*@ @@ -370,7 +370,7 @@ Ox.Element = function(options, self) { () -> This element object @*/ that.loseFocus = function() { - Ox.Focus.blur(that.id); + Ox.Focus.blur(that.oxid); return that; }; @@ -403,10 +403,10 @@ Ox.Element = function(options, self) { element = Ox.UI.elements[oxid]; element && element.remove(false); }); - Ox.Focus.remove(that.id); - Ox.Keyboard.unbind(that.id); + Ox.Focus.remove(that.oxid); + Ox.Keyboard.unbind(that.oxid); delete self.$eventHandler; - delete Ox.UI.elements[that.id]; + delete Ox.UI.elements[that.oxid]; that.$tooltip && that.$tooltip.remove(); remove !== false && that.$element.remove(); return that; @@ -417,8 +417,7 @@ Ox.Element = function(options, self) { ($element) -> null @*/ that.setElement = function($element) { - //$element[0].className = that.$element[0].className; - $element.addClass('OxElement').data({oxid: that.id}); + $element.addClass('OxElement').data({oxid: that.oxid}); that.$element.replaceWith($element); that.$element = $element; that[0] = that.$element[0]; @@ -453,7 +452,7 @@ Ox.Element = function(options, self) { 'playing', 'position', 'progress', 'request' ].indexOf(event) == -1) { if (!/^pandora_/.test(event)) { - Ox.Log('EVENT', that.id, self.options.id, 'trigger', event, data); + Ox.Log('EVENT', that.oxid, self.options.id, 'trigger', event, data); } } // it is necessary to check if self.$eventHandler exists, @@ -495,7 +494,7 @@ Ox.Element = function(options, self) { () -> object @*/ that.unbindKeyboard = function() { - Ox.Keyboard.unbind(that.id); + Ox.Keyboard.unbind(that.oxid); return that; }; diff --git a/source/Ox.UI/js/Core/Ox.JQueryElement.js b/source/Ox.UI/js/Core/Ox.JQueryElement.js index f6fce959..cac0ccbe 100644 --- a/source/Ox.UI/js/Core/Ox.JQueryElement.js +++ b/source/Ox.UI/js/Core/Ox.JQueryElement.js @@ -8,43 +8,30 @@ Ox.JQueryElement Wrapper for jQuery Ox.JQueryElement = function($element) { var that = this; //@ id Unique id - that.id = Ox.uid(); // fixme: rename to oxid! - //@ ox OxJS version - that.ox = Ox.VERSION; // fixme: remove! + that.oxid = Ox.uid(); //@ $element The jQuery-wrapped DOM element that.$element = $element.data({ - oxid: that.id + oxid: that.oxid }); - // FIXME: the following two lines should make it possible to do - // $('
').appendTo($element) ... check if it works, then replace all //@ 0 The DOM element that[0] = that.$element[0]; //@ length 1 (for compatibility with jQuery) that.length = 1; - Ox.UI.elements[that.id] = that; + 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, id, ret, that = this; - Ox.forEach(args, function(arg, i) { - // FIXME: with the changes above, is this still needed? - // if an ox object was passed - // then pass its $element instead - // so that we can do oxObj.jqFn(oxObj) - if (arg && arg.ox) { - args[i] = arg.$element; - } - }); + 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[id = ret.data('oxid')] - ? Ox.UI.elements[id] : ret; + && Ox.UI.elements[oxid = ret.data('oxid')] + ? Ox.UI.elements[oxid] : ret; }; }); diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js index 17fd6c13..5132908c 100644 --- a/source/Ox.UI/js/Form/Ox.Input.js +++ b/source/Ox.UI/js/Form/Ox.Input.js @@ -722,7 +722,7 @@ Ox.Input = function(options, self) { var input = self.$input[0]; that.triggerEvent('insert', { end: input.selectionEnd, - id: that.id, + id: that.oxid, selection: input.value.substring(input.selectionStart, input.selectionEnd), start: input.selectionStart, value: input.value diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index 16a63bd5..54885f11 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -783,7 +783,7 @@ Ox.List = function(options, self) { !Ox.isUndefined(callback) && callback(); return; } - Ox.Log('List', that.id, 'loadPage', page); + Ox.Log('List', that.oxid, 'loadPage', page); var keys = Ox.merge( self.options.keys.indexOf(self.options.unique) == -1 ? [self.options.unique] : [], self.options.keys diff --git a/source/Ox.UI/js/Window/Ox.Dialog.js b/source/Ox.UI/js/Window/Ox.Dialog.js index bc90262d..e650d154 100644 --- a/source/Ox.UI/js/Window/Ox.Dialog.js +++ b/source/Ox.UI/js/Window/Ox.Dialog.js @@ -518,7 +518,7 @@ Ox.Dialog = function(options, self) { function setContent() { var animate = !!self.$content, - isImage = !self.options.content.ox && self.options.content.is('img'); + isImage = !Ox.UI.isElement(self.options.content) && self.options.content.is('img'); if (animate) { self.$content.animate({ opacity: 0