use Ox.$, not $; use .on, not .click

This commit is contained in:
rolux 2013-12-06 21:12:59 +01:00
parent b834bb2b4d
commit 60fe713e65

View file

@ -87,7 +87,7 @@ Ox.DocPage = function(options, self) {
function getItem(item, level, name) { function getItem(item, level, name) {
Ox.Log('Core', 'getItem', item, level, name); Ox.Log('Core', 'getItem', item, level, name);
var $elements = [ var $elements = [
$('<div>') Ox.$('<div>')
.css({paddingLeft: (level ? level * 32 - 16 : 0) + 'px'}) .css({paddingLeft: (level ? level * 32 - 16 : 0) + 'px'})
.html( .html(
'<code><b>' + (name || item.name) + '</b> ' '<code><b>' + (name || item.name) + '</b> '
@ -124,7 +124,7 @@ Ox.DocPage = function(options, self) {
isExpanded = !Ox.contains(section, 'inherited'); isExpanded = !Ox.contains(section, 'inherited');
if (item[section]) { if (item[section]) {
if (section == 'description') { if (section == 'description') {
$elements.push($('<div>') $elements.push(Ox.$('<div>')
.css({ .css({
paddingTop: (level ? 0 : 8) + 'px', paddingTop: (level ? 0 : 8) + 'px',
borderTopWidth: level ? 0 : '1px', borderTopWidth: level ? 0 : '1px',
@ -134,7 +134,7 @@ Ox.DocPage = function(options, self) {
.html(Ox.sanitizeHTML(item.description)) .html(Ox.sanitizeHTML(item.description))
); );
} else { } else {
$elements.push($('<div>') $elements.push(Ox.$('<div>')
.css({ .css({
paddingTop: (level ? 0 : 8) + 'px', paddingTop: (level ? 0 : 8) + 'px',
borderTopWidth: level ? 0 : '1px', borderTopWidth: level ? 0 : '1px',
@ -142,7 +142,7 @@ Ox.DocPage = function(options, self) {
marginLeft: (level * 32) + 'px' marginLeft: (level * 32) + 'px'
}) })
.append( .append(
$('<img>') Ox.$('<img>')
.attr({ .attr({
src: isExpanded src: isExpanded
? Ox.UI.getImageURL('symbolDown') ? Ox.UI.getImageURL('symbolDown')
@ -153,29 +153,31 @@ Ox.DocPage = function(options, self) {
height: '12px', height: '12px',
margin: '0 4px -1px 0' margin: '0 4px -1px 0'
}) })
.click(function() { .on({
var $this = $(this), click: function() {
isExpanded = $this.attr('src') == Ox.UI.getImageURL('symbolRight'); var $this = $(this),
$this.attr({ isExpanded = $this.attr('src') == Ox.UI.getImageURL('symbolRight');
src: isExpanded $this.attr({
? Ox.UI.getImageURL('symbolDown') src: isExpanded
: Ox.UI.getImageURL('symbolRight') ? Ox.UI.getImageURL('symbolDown')
}); : Ox.UI.getImageURL('symbolRight')
$('.' + className).each(function() { });
var $this = $(this), isHidden = false; $('.' + className).each(function() {
$this[isExpanded ? 'removeClass' : 'addClass'](className + 'Hidden'); var $this = $(this), isHidden = false;
if (isExpanded) { $this[isExpanded ? 'removeClass' : 'addClass'](className + 'Hidden');
Ox.forEach(this.className.split(' '), function(v) { if (isExpanded) {
if (/Hidden$/.test(v)) { Ox.forEach(this.className.split(' '), function(v) {
isHidden = true; if (/Hidden$/.test(v)) {
return false; // break isHidden = true;
} return false; // break
}); }
!isHidden && $this.show(); });
} else { !isHidden && $this.show();
$this.hide(); } else {
} $this.hide();
}); }
});
}
}) })
) )
.append('<span class="OxSection">' + ( .append('<span class="OxSection">' + (
@ -190,7 +192,7 @@ Ox.DocPage = function(options, self) {
item.tests.forEach(function(test) { item.tests.forEach(function(test) {
var isAsync = test.expected && /(.+Ox\.test\()/.test(test.statement); var isAsync = test.expected && /(.+Ox\.test\()/.test(test.statement);
$elements.push( $elements.push(
$('<div>') Ox.$('<div>')
.addClass(className) .addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'}) .css({marginLeft: (level * 32 + 16) + 'px'})
.html( .html(
@ -211,7 +213,7 @@ Ox.DocPage = function(options, self) {
); );
if (test.expected) { if (test.expected) {
$elements.push( $elements.push(
$('<div>') Ox.$('<div>')
.addClass(className) .addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'}) .css({marginLeft: (level * 32 + 16) + 'px'})
.html( .html(
@ -234,7 +236,7 @@ Ox.DocPage = function(options, self) {
}); });
} else if (section == 'source') { } else if (section == 'source') {
// fixme: not the right place to fix path // fixme: not the right place to fix path
$elements.push($('<div>') $elements.push(Ox.$('<div>')
.addClass(className) .addClass(className)
.css({marginLeft: 16 + 'px'}) .css({marginLeft: 16 + 'px'})
.html( .html(