Ox.elements -> Ox.

This commit is contained in:
rlx 2014-09-25 18:47:29 +02:00
parent 775aa607c8
commit 8e335ba4f6
8 changed files with 21 additions and 21 deletions

View file

@ -124,7 +124,7 @@
that.self = function _self() { that.self = function _self() {
return arguments[0] === _ ? self : {}; return arguments[0] === _ ? self : {};
}; };
Ox.elements[that.oxid] = that; Ox.$elements[that.oxid] = that;
if (self.options.element == '<iframe>') { if (self.options.element == '<iframe>') {
self.messageCallbacks = self.messageCallbacks || {}; self.messageCallbacks = self.messageCallbacks || {};
@ -357,8 +357,8 @@
// return the Ox Element instead, so that we can do // return the Ox Element instead, so that we can do
// oxObj.jqFn().oxFn() // oxObj.jqFn().oxFn()
return ret && ret.jquery && ret.length == 1 return ret && ret.jquery && ret.length == 1
&& Ox.elements[oxid = ret.data('oxid')] && Ox.$elements[oxid = ret.data('oxid')]
? Ox.elements[oxid] : ret; ? Ox.$elements[oxid] : ret;
}; };
}); });
@ -648,9 +648,9 @@
Ox.Focus.removeElement(this.oxid); Ox.Focus.removeElement(this.oxid);
this.self(_).unbindKeyboard(); this.self(_).unbindKeyboard();
this.$tooltip && this.$tooltip.remove(); this.$tooltip && this.$tooltip.remove();
delete Ox.elements[this.oxid]; delete Ox.$elements[this.oxid];
// If setElement($element) was used, delete $element too // If setElement($element) was used, delete $element too
delete Ox.elements[this.$element.oxid]; delete Ox.$elements[this.$element.oxid];
return this; return this;
}; };

View file

@ -66,10 +66,10 @@
Ox.$parent.postMessage('init', {}) Ox.$parent.postMessage('init', {})
} else if (message.target) { } else if (message.target) {
// The outer window receives init from iframe // The outer window receives init from iframe
Ox.elements[message.target].triggerEvent('init'); Ox.$elements[message.target].triggerEvent('init');
} }
} else { } else {
(message.target ? Ox.elements[message.target] : Ox.$parent) (message.target ? Ox.$elements[message.target] : Ox.$parent)
.triggerMessage(message.event, message.data); .triggerMessage(message.event, message.data);
} }
} }

View file

@ -10,7 +10,7 @@ Ox.Focus = (function() {
that = { that = {
focusedElement: function() { focusedElement: function() {
return Ox.elements[Ox.last(stack)]; return Ox.$elements[Ox.last(stack)];
}, },
focusedElementIsInput: function() { focusedElementIsInput: function() {
var $element = that.focusedElement(); var $element = that.focusedElement();
@ -49,7 +49,7 @@ Ox.Focus = (function() {
.removeClass('OxFocus') .removeClass('OxFocus')
.triggerEvent('losefocus'); .triggerEvent('losefocus');
if (stack.length) { if (stack.length) {
Ox.elements[Ox.last(stack)] Ox.$elements[Ox.last(stack)]
.addClass('OxFocus') .addClass('OxFocus')
.triggerEvent('gainfocus'); .triggerEvent('gainfocus');
} }

View file

@ -12,17 +12,17 @@ Ox.GarbageCollection = (function() {
timeout; timeout;
that.collect = function() { that.collect = function() {
var len = Ox.len(Ox.elements); var len = Ox.len(Ox.$elements);
Object.keys(Ox.elements).forEach(function(id) { Object.keys(Ox.$elements).forEach(function(id) {
var $element = Ox.elements[id]; var $element = Ox.$elements[id];
if ($element && Ox.isUndefined($element.data('oxid'))) { if ($element && Ox.isUndefined($element.data('oxid'))) {
$element.remove(); $element.remove();
delete Ox.elements[id]; delete Ox.$elements[id];
} }
}); });
timeout && clearTimeout(timeout); timeout && clearTimeout(timeout);
timeout = setTimeout(that.collect, 60000); timeout = setTimeout(that.collect, 60000);
Ox.Log('GC', len, '-->', Ox.len(Ox.elements)); Ox.Log('GC', len, '-->', Ox.len(Ox.$elements));
}; };
/*@ /*@
@ -31,7 +31,7 @@ Ox.GarbageCollection = (function() {
@*/ @*/
that.debug = function() { that.debug = function() {
var classNames = {}, sorted = []; var classNames = {}, sorted = [];
Ox.forEach(Ox.elements, function($element, id) { Ox.forEach(Ox.$elements, function($element, id) {
var className = $element[0].className; var className = $element[0].className;
classNames[className] = (classNames[className] || 0) + 1; classNames[className] = (classNames[className] || 0) + 1;
}); });

View file

@ -38,8 +38,8 @@ Ox.SCROLLBAR_SIZE = Ox.UI.SCROLLBAR_SIZE = $.browser.webkit ? 8 : (function() {
//@ Ox.UI_PATH <str> Path of Ox UI //@ Ox.UI_PATH <str> Path of Ox UI
Ox.UI_PATH = Ox.UI.PATH = Ox.PATH + 'Ox.UI/'; Ox.UI_PATH = Ox.UI.PATH = Ox.PATH + 'Ox.UI/';
//@ Ox.elements <o> Reference to all Ox Elements //@ Ox.$elements <o> Reference to all Ox Elements
Ox.elements = Ox.$elements = Ox.UI.elements = {}; Ox.$elements = Ox.UI.elements = {};
/*@ /*@
Ox.getImageData <f> Returns properties of an Ox UI image Ox.getImageData <f> Returns properties of an Ox UI image
@ -109,7 +109,7 @@ Ox.getImageURL = Ox.cache(function(name, color, theme) {
//@ Ox.getOxElement <f> Returns the Ox.Element of a DOM element, or `undefined` //@ Ox.getOxElement <f> Returns the Ox.Element of a DOM element, or `undefined`
Ox.getOxElement = function(element) { Ox.getOxElement = function(element) {
return Ox.elements[$(element).data('oxid')]; return Ox.$elements[$(element).data('oxid')];
}; };
/*@ /*@

View file

@ -598,7 +598,7 @@ Ox.Map = function(options, self) {
function centerChanged() { function centerChanged() {
var tooltip = $('.OxMapMarkerTooltip'); var tooltip = $('.OxMapMarkerTooltip');
tooltip.length && Ox.elements[$(tooltip[0]).data('oxid')].hide(); tooltip.length && Ox.$elements[$(tooltip[0]).data('oxid')].hide();
self.center = self.map.getCenter(); self.center = self.map.getCenter();
self.centerChanged = true; self.centerChanged = true;
} }

View file

@ -206,7 +206,7 @@ Ox.AnnotationPanel = function(options, self) {
var id = data.id; var id = data.id;
Ox.InsertHTMLDialog(Ox.extend({ Ox.InsertHTMLDialog(Ox.extend({
callback: function(data) { callback: function(data) {
Ox.elements[id] Ox.$elements[id]
.value(data.value) .value(data.value)
.focusInput(data.position) .focusInput(data.position)
.triggerEvent('change', data.value); .triggerEvent('change', data.value);

View file

@ -1274,7 +1274,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
if (Ox.isUndefined(data)) { if (Ox.isUndefined(data)) {
// doubleclick on small timeline // doubleclick on small timeline
data = getAnnotation(); data = getAnnotation();
} else if (!data.id && Ox.elements[that.oxid]) { } else if (!data.id && Ox.$elements[that.oxid]) {
// focus only if in the dom // focus only if in the dom
that.gainFocus(); that.gainFocus();
} }