1
0
Fork 0
forked from 0x2620/oxjs

remove new for all Ox.Elements, dont declare arguments again, add some semicolons

This commit is contained in:
j 2011-06-19 19:48:32 +02:00
commit b27ed00356
69 changed files with 430 additions and 440 deletions

View file

@ -20,8 +20,8 @@ Ox.IconItem = function(options, self) {
//Ox.print('IconItem', options, self)
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
height: 128,
id: '',
@ -31,7 +31,7 @@ Ox.IconItem = function(options, self) {
width: 128,
url: ''
})
.options(options || {})
.options(options || {});
$.extend(self, {
fontSize: self.options.size == 64 ? 6 : 9,

View file

@ -23,8 +23,8 @@ Ox.IconList <f:Ox.Element> IconList Object
Ox.IconList = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
centerSelection: false,
draggable: true,
@ -46,7 +46,7 @@ Ox.IconList = function(options, self) {
itemWidth: self.options.size
});
that.$element = new Ox.List({
that.$element = Ox.List({
centered: self.options.centered,
construct: constructItem,
draggable: self.options.draggable,
@ -55,10 +55,9 @@ Ox.IconList = function(options, self) {
items: self.options.items,
itemWidth: self.itemWidth,
keys: self.options.keys,
orientation: self.options.orientation,
keys: self.options.keys,
max: self.options.max,
min: self.options.min,
orientation: self.options.orientation,
selected: self.options.selected,
size: self.options.size,
sort: self.options.sort,
@ -81,7 +80,7 @@ Ox.IconList = function(options, self) {
self.options.item(data, self.options.sort, self.options.size) :
{height: 8, width: 5},
ratio = data.width / data.height;
return new Ox.IconItem($.extend(data, {
return Ox.IconItem($.extend(data, {
height: Math.round(self.options.size / (ratio <= 1 ? 1 : ratio)),
size: self.options.size,
width: Math.round(self.options.size * (ratio >= 1 ? 1 : ratio))
@ -115,7 +114,7 @@ Ox.IconList = function(options, self) {
} else if (key == 'selected') {
that.$element.options(key, value);
}
}
};
/*@
closePreview <f> close preview
@ -189,7 +188,7 @@ Ox.IconList = function(options, self) {
that.$element.value(id, key, value);
return that;
}
}
};
return that;

View file

@ -17,8 +17,8 @@ Ox.ItemInput <f:Ox.Element> ItemInput Object
Ox.ItemInput = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
type: 'textarea',
value: '',
@ -27,7 +27,6 @@ Ox.ItemInput = function(options, self) {
})
.options(options || {});
self.$input = Ox.Input({
changeOnKeypress: true,
height: self.options.height,
@ -130,7 +129,7 @@ Ox.ItemInput = function(options, self) {
/*
that.append(
$input = new Ox.Input({
$input = Ox.Input({
height: self.options.height,
style: 'square',
type: self.options.type,
@ -144,15 +143,15 @@ Ox.ItemInput = function(options, self) {
}
})
)
.append(new Ox.Element()
.append(new Ox.Button({type: 'text', title: 'Cancel'})
.append(Ox.Element()
.append(Ox.Button({type: 'text', title: 'Cancel'})
.css('width', '42%')
.bindEvent({
'click': function() {
that.triggerEvent('cancel');
}
}))
.append(new Ox.Button({type: 'text', title: 'Save'})
.append(Ox.Button({type: 'text', title: 'Save'})
.css('width', '42%')
.bindEvent({
'click': function() {
@ -172,4 +171,4 @@ Ox.ItemInput = function(options, self) {
return that;
}
};

View file

@ -41,8 +41,8 @@ Ox.List <f:Ox.Element> List Element
Ox.List = function(options, self) {
var self = self || {},
that = new Ox.Container({}, self)
self = self || {};
var that = Ox.Container({}, self)
.defaults({
centered: false,
construct: null,
@ -274,11 +274,11 @@ Ox.List = function(options, self) {
function constructEmptyPage(page) {
//Ox.print('cEP', page)
var i, $page = new Ox.ListPage().css(getPageCSS(page));
var i, $page = Ox.ListPage().css(getPageCSS(page));
for (i = 0; i < getPageLength(page); i++
) {
// fixme: why does chainging fail here?
new Ox.ListItem({
Ox.ListItem({
construct: self.options.construct
}).appendTo($page);
}
@ -427,7 +427,7 @@ Ox.List = function(options, self) {
visibleItems = Math.ceil(height / self.options.itemHeight);
if (self.listLength < visibleItems) {
Ox.range(self.listLength, visibleItems).forEach(function(v) {
var $item = new Ox.ListItem({
var $item = Ox.ListItem({
construct: self.options.construct,
});
$item.addClass('OxEmpty').removeClass('OxTarget');
@ -472,7 +472,7 @@ Ox.List = function(options, self) {
function getAbove() {
var pos = -1;
if (self.selected.length) {
pos = self.selected[self.selected.length - 1] - self.rowLength
pos = self.selected[self.selected.length - 1] - self.rowLength;
if (pos < 0) {
pos = -1;
}
@ -543,7 +543,7 @@ Ox.List = function(options, self) {
} : {
top: (page * self.pageHeight + self.listMargin / 2) + 'px',
width: self.pageWidth + 'px'
}
};
}
function getPageHeight() {
@ -622,7 +622,7 @@ Ox.List = function(options, self) {
function getRowLength() {
return self.options.orientation == 'both' ?
Math.floor((getWidth() - self.listMargin) /
(self.options.itemWidth + self.itemMargin)) : 1
(self.options.itemWidth + self.itemMargin)) : 1;
}
function getScrollPosition() {
@ -703,10 +703,10 @@ Ox.List = function(options, self) {
sort: self.options.sort
}, function(result) {
var $emptyPage = Ox.clone(self.$pages[page]);
self.$pages[page] = new Ox.ListPage().css(getPageCSS(page));
self.$pages[page] = Ox.ListPage().css(getPageCSS(page));
result.data.items.forEach(function(v, i) {
var pos = offset + i;
self.$items[pos] = new Ox.ListItem({
self.$items[pos] = Ox.ListItem({
construct: self.options.construct,
data: v,
draggable: self.options.draggable,
@ -1342,7 +1342,7 @@ Ox.List = function(options, self) {
});
items.forEach(function(item, i) {
var $item;
$items.push($item = new Ox.ListItem({
$items.push($item = Ox.ListItem({
construct: self.options.construct,
data: item,
draggable: self.options.draggable,
@ -1383,7 +1383,7 @@ Ox.List = function(options, self) {
.empty()
.addClass('OxEdit');
$input = new Ox.ItemInput({
$input = Ox.ItemInput({
type: 'textarea',
value: item.value,
height: height,

View file

@ -18,8 +18,8 @@ Ox.ListItem <f:Ox.Element> ListItem Object
Ox.ListItem = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
construct: function() {},
data: {},
@ -52,7 +52,7 @@ Ox.ListItem = function(options, self) {
if (key == 'data') {
constructItem(true);
}
}
};
return that;

View file

@ -8,8 +8,8 @@ Ox.ListPage <f:Ox.Element> ListPage Object
self <o> shared private variable
@*/
Ox.ListPage = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.addClass('OxPage');
return that;
};

View file

@ -39,8 +39,8 @@ Ox.TextList = function(options, self) {
// fixme: rename to TableList
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
columns: [],
columnsMovable: false,
@ -114,7 +114,7 @@ Ox.TextList = function(options, self) {
if (!Ox.isUndefined(v.position)) {
self.visibleColumns[v.position] = v;
}
})
});
$.extend(self, {
columnWidths: $.map(self.visibleColumns, function(v, i) {
return v.width;
@ -132,11 +132,11 @@ Ox.TextList = function(options, self) {
// Head
if (self.options.columnsVisible) {
that.$bar = new Ox.Bar({
that.$bar = Ox.Bar({
orientation: 'horizontal',
size: 16
}).appendTo(that);
that.$head = new Ox.Container()
that.$head = Ox.Container()
.addClass('OxHead')
.css({
right: self.options.scrollbarVisible ? Ox.UI.SCROLLBAR_SIZE + 'px' : 0
@ -145,7 +145,7 @@ Ox.TextList = function(options, self) {
that.$head.$content.addClass('OxTitles');
constructHead();
if (self.options.columnsRemovable) {
that.$select = new Ox.Select({
that.$select = Ox.Select({
id: self.options.id + 'SelectColumns',
items: $.map(self.options.columns, function(v, i) {
return {
@ -166,7 +166,7 @@ Ox.TextList = function(options, self) {
// Body
that.$body = new Ox.List({
that.$body = Ox.List({
construct: constructItem,
id: self.options.id,
items: self.options.items,
@ -299,7 +299,7 @@ Ox.TextList = function(options, self) {
var $order, $resize, $left, $center, $right;
offset += self.columnWidths[i];
self.columnOffsets[i] = offset - self.columnWidths[i] / 2;
that.$titles[i] = new Ox.Element()
that.$titles[i] = Ox.Element()
.addClass('OxTitle OxColumn' + Ox.toTitleCase(v.id))
.css({
width: (self.columnWidths[i] - 9) + 'px',
@ -338,7 +338,7 @@ Ox.TextList = function(options, self) {
$(this).prev().trigger('click')
})
.appendTo(that.$head.$content.$element);
$resize = new Ox.Element()
$resize = Ox.Element()
.addClass('OxResize')
.appendTo(that.$head.$content.$element);
// if columns are resizable, bind click and drag events
@ -741,7 +741,7 @@ Ox.TextList = function(options, self) {
.css({
width: width + 'px'
});
$input = new Ox.Input({
$input = Ox.Input({
autovalidate: column.input ? column.input.autovalidate : null,
style: 'square',
value: html,

View file

@ -19,8 +19,8 @@ Ox.TreeList = function(options, self) {
// fixme: expanding the last item should cause some scroll
var self = self || {},
that = new Ox.Element({}, self)
self = self || {};
var that = Ox.Element({}, self)
.defaults({
data: null,
items: [],
@ -40,7 +40,7 @@ Ox.TreeList = function(options, self) {
//Ox.print('d', self.options.data, 'i', self.options.items)
}
that.$element = new Ox.List({
that.$element = Ox.List({
construct: constructItem,
itemHeight: 16,
items: parseItems(),
@ -114,9 +114,9 @@ Ox.TreeList = function(options, self) {
}
function getItemById(id, items, level) {
var items = items || self.options.items,
level = level || 0,
ret = null;
var ret = null;
items = items || self.options.items;
level = level || 0;
Ox.forEach(items, function(item) {
if (item.id == id) {
ret = $.extend(item, {
@ -151,15 +151,15 @@ Ox.TreeList = function(options, self) {
type == 'function' ?
value.toString().split('{')[0] :
JSON.stringify(value)
)
);
}
return ret;
}
function parseItems(items, level) {
var items = items || self.options.items,
level = level || 0,
ret = [];
var ret = [];
items = items || self.options.items;
level = level || 0;
items.forEach(function(item, i) {
var item_ = $.extend({
level: level