1
0
Fork 0
forked from 0x2620/oxjs

use Ox.Log

This commit is contained in:
j 2011-11-04 16:54:28 +01:00
commit dce2843303
50 changed files with 276 additions and 276 deletions

View file

@ -21,7 +21,7 @@ Ox.IconItem <f:Ox.Element> IconItem Object
Ox.IconItem = function(options, self) {
//Ox.print('IconItem', options, self)
//Ox.Log('List', 'IconItem', options, self)
self = self || {};
var that = Ox.Element({}, self)

View file

@ -63,7 +63,7 @@ Ox.InfoList = function(options, self) {
},
info: {}
};
Ox.print('DATA -=-------', data)
Ox.Log('List', 'DATA -=-------', data)
var $icon = Ox.Element()
.css({
@ -148,7 +148,7 @@ Ox.InfoList = function(options, self) {
if (key == 'items') {
that.$element.options(key, value);
} else if (key == 'selected') {
Ox.print('SELECTED', value)
Ox.Log('List', 'SELECTED', value)
that.$element.options(key, value);
} else if (key == 'sort') {
that.$element.options(key, value);
@ -160,7 +160,7 @@ Ox.InfoList = function(options, self) {
$parent.css({width: width - 144});
$parent.parent().css({width: width - 144});
$parent.parent().parent().css({width: width - 8});
Ox.print('@@@', this.className, id)
Ox.Log('List', '@@@', this.className, id)
Ox.UI.elements[id].options({width: width - 152});
});
}

View file

@ -44,7 +44,7 @@ Ox.ItemInput = function(options, self) {
.bindEvent({
change: function(data) {
self.options.height = data.value.split('\n').length * 13;
Ox.print('HEIGHT', self.options.height)
Ox.Log('List', 'HEIGHT', self.options.height)
self.$input.options({
height: self.options.height
});
@ -166,7 +166,7 @@ Ox.ItemInput = function(options, self) {
'text-align': 'right',
})
);
Ox.print($input);
Ox.Log('List', $input);
*/
return that;

View file

@ -427,7 +427,7 @@ Ox.List = function(options, self) {
var height = getHeight(),
lastItemHeight = height % self.options.itemHeight || self.options.itemHeight,
visibleItems = Math.ceil(height / self.options.itemHeight);
//Ox.print('FILL', self.listLength, visibleItems);
//Ox.Log('List', 'FILL', self.listLength, visibleItems);
if (self.listLength < visibleItems) {
Ox.range(self.listLength, visibleItems).forEach(function(v) {
var $item = Ox.ListItem({
@ -578,7 +578,7 @@ Ox.List = function(options, self) {
// fixme: is this really needed?
var pos = -1;
Ox.forEach(self.$items, function($item, i) {
//Ox.print('$item', i, self.options.unique, $item.options('data')[self.options.unique])
//Ox.Log('List', '$item', i, self.options.unique, $item.options('data')[self.options.unique])
if ($item.options('data')[self.options.unique] == id) {
pos = i;
return false;
@ -588,10 +588,10 @@ Ox.List = function(options, self) {
}
function getPositions(callback) {
//Ox.print('getPositions', self.options.selected);
//Ox.Log('List', 'getPositions', self.options.selected);
// fixme: optimize: send non-selected ids if more than half of the items are selected
if (self.options.selected.length /*&& ids.length < self.listLength*/) {
/*Ox.print('-------- request', {
/*Ox.Log('List', '-------- request', {
positions: ids,
sort: self.options.sort
});*/
@ -607,7 +607,7 @@ Ox.List = function(options, self) {
}
function getPositionsCallback(result, callback) {
//Ox.print('getPositionsCallback', result);
//Ox.Log('List', 'getPositionsCallback', result);
var pos = 0;
if (result) {
self.options.selected = [];
@ -672,7 +672,7 @@ Ox.List = function(options, self) {
}
function getWidth() {
//Ox.print('LIST THAT.WIDTH()', that.width())
//Ox.Log('List', 'LIST THAT.WIDTH()', that.width())
return that.width() - (that.$content.height() > that.height() ? Ox.UI.SCROLLBAR_SIZE : 0);
}
@ -719,7 +719,7 @@ Ox.List = function(options, self) {
});
fillFirstPage();
self.selected.length && scrollToPosition(self.selected[0]);
Ox.print('CONSTRUCT:', timeC, 'APPEND:', timeA);
Ox.Log('List', 'CONSTRUCT:', timeC, 'APPEND:', timeA);
// that.triggerEvent('init', {items: self.options.items.length});
// fixme: do sync lists need to trigger init?
// will this only be reached in sync lists?
@ -730,7 +730,7 @@ Ox.List = function(options, self) {
!Ox.isUndefined(callback) && callback();
return;
}
Ox.print(that.id, 'loadPage', page);
Ox.Log('List', that.id, 'loadPage', page);
var keys = Ox.merge(
self.options.keys.indexOf(self.options.unique) == -1
? [self.options.unique] : [], self.options.keys
@ -762,19 +762,19 @@ Ox.List = function(options, self) {
});
page == 0 && fillFirstPage();
// FIXME: why does emptyPage sometimes have no methods?
//Ox.print('emptyPage', $emptyPage)
//Ox.Log('List', 'emptyPage', $emptyPage)
$emptyPage && $emptyPage.removeElement && $emptyPage.removeElement();
self.$pages[page].appendTo(that.$content);
!Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event?
}));
} else {
//Ox.print('loading a page from cache, this should probably not happen -----------')
//Ox.Log('List', 'loading a page from cache, this should probably not happen -----------')
self.$pages[page].appendTo(that.$content);
}
}
function loadPages(page, callback) {
Ox.print('loadPages', page)
Ox.Log('List', 'loadPages', page)
var counter = 0,
fn = function() {
if (++counter == 3) {
@ -908,7 +908,7 @@ Ox.List = function(options, self) {
selectTimeout = false,
$element,
hadFocus = that.hasFocus();
//Ox.print('mousedown', pos)
//Ox.Log('List', 'mousedown', pos)
that.gainFocus();
if (pos > -1) {
if (!self.clickTimeout) {
@ -924,7 +924,7 @@ Ox.List = function(options, self) {
addAllToSelection(pos);
}
} else if (!isSelected(pos)) {
Ox.print('select', pos)
Ox.Log('List', 'select', pos)
select(pos);
} else if (self.selected.length > 1) {
// this could be the first click
@ -989,7 +989,7 @@ Ox.List = function(options, self) {
var $item = self.$items[startPos],
insert = startPos < stopPos ? 'insertAfter' : 'insertBefore';
$item.detach()[insert](self.$items[stopPos].$element); // fixme: why do we need .$element here?
//Ox.print('moveItem', startPos, stopPos, insert, self.ids);
//Ox.Log('List', 'moveItem', startPos, stopPos, insert, self.ids);
var $item = self.$items.splice(startPos, 1)[0];
self.$items.splice(stopPos, 0, $item);
self.$items.forEach(function($item, pos) {
@ -1079,7 +1079,7 @@ Ox.List = function(options, self) {
}
function scrollToPosition(pos, leftOrTopAlign) {
//Ox.print('scrollToPosition', pos)
//Ox.Log('List', 'scrollToPosition', pos)
var itemHeight = self.options.itemHeight + self.itemMargin,
itemWidth = self.options.itemWidth + self.itemMargin,
positions = [],
@ -1188,7 +1188,7 @@ Ox.List = function(options, self) {
// fixme: no case where callback is set
// note: can't use selectNone here,
// since it'd trigger a select event
Ox.print('SET SELECTED', ids)
Ox.Log('List', 'SET SELECTED', ids)
var counter = 0;
self.$items.forEach(function($item, pos) {
if (isSelected(pos)) {
@ -1242,7 +1242,7 @@ Ox.List = function(options, self) {
var ids = self.options.selected = getSelectedIds();
setTimeout(function() {
var ids_ = self.options.selected = getSelectedIds();
// Ox.print('ids', ids, 'ids after 100 msec', ids_, Ox.isEqual(ids, ids_))
// Ox.Log('List', 'ids', ids, 'ids after 100 msec', ids_, Ox.isEqual(ids, ids_))
if (Ox.isEqual(ids, ids_)) {
that.triggerEvent('select', {
ids: ids
@ -1251,7 +1251,7 @@ Ox.List = function(options, self) {
ids: ids
});
} else {
// Ox.print('select event not triggered after timeout');
// Ox.Log('List', 'select event not triggered after timeout');
}
}, 100);
}
@ -1267,9 +1267,9 @@ Ox.List = function(options, self) {
if (page < 0 || page >= self.pages) {
return;
}
//Ox.print('unloadPage', page)
//Ox.print('self.$pages', self.$pages)
//Ox.print('page not undefined', !Ox.isUndefined(self.$pages[page]))
//Ox.Log('List', 'unloadPage', page)
//Ox.Log('List', 'self.$pages', self.$pages)
//Ox.Log('List', 'page not undefined', !Ox.isUndefined(self.$pages[page]))
if (!Ox.isUndefined(self.$pages[page])) {
self.$pages[page].removeElement();
delete self.$pages[page];
@ -1310,11 +1310,11 @@ Ox.List = function(options, self) {
}
function updateQuery(callback) { // fixme: shouldn't this be setQuery?
//Ox.print('updateQuery', self.options)
//Ox.Log('List', 'updateQuery', self.options)
clear(); // fixme: bad function name ... clear what?
self.requests.push(self.options.items({}, function(result) {
var keys = {};
//Ox.print('INIT!!!', result.data)
//Ox.Log('List', 'INIT!!!', result.data)
that.triggerEvent('init', result.data);
self.rowLength = getRowLength();
self.pageLength = self.options.orientation == 'both'
@ -1343,7 +1343,7 @@ Ox.List = function(options, self) {
}
function updateSelected() {
//Ox.print('updateSelected')
//Ox.Log('List', 'updateSelected')
var oldSelectedIds = getSelectedIds(),
newSelectedIds = [];
Ox.forEach(self.options.items, function(item) {
@ -1395,7 +1395,7 @@ Ox.List = function(options, self) {
}
self.setOption = function(key, value) {
//Ox.print('list setOption', key, value);
//Ox.Log('List', 'list setOption', key, value);
var selectedIds;
if (key == 'items') {
// fixme: this could be used to change the list
@ -1408,13 +1408,13 @@ Ox.List = function(options, self) {
updateQuery();
}
} else if (key == 'selected') {
//Ox.print('setOption selected', value)
//Ox.Log('List', 'setOption selected', value)
setSelected(value);
// fixme: next line added to make text list find-as-you-type work,
// may break other things
!self.isAsync && triggerSelectEvent(value);
} else if (key == 'sort') {
//Ox.print('---sort---')
//Ox.Log('List', '---sort---')
updateSort();
}
};
@ -1584,7 +1584,7 @@ Ox.List = function(options, self) {
length <n> number of items to remove
@*/
that.removeItems = function(pos, length) {
Ox.print('removeItems', pos, length)
Ox.Log('List', 'removeItems', pos, length)
if (Ox.isUndefined(length)) { // pos is list of ids
pos.forEach(function(id) {
var p = getPositionById(id);
@ -1669,7 +1669,7 @@ Ox.List = function(options, self) {
// fixme: this (and others) should be deprecated,
// one should set options instead
that.sortList = function(key, operator, map) {
// Ox.print('sortList', key, operator, map)
// Ox.Log('List', 'sortList', key, operator, map)
if (key != self.options.sort[0].key || operator != self.options.sort[0].operator) {
self.options.sort[0] = {key: key, operator: operator, map: map};
updateSort();
@ -1689,7 +1689,7 @@ Ox.List = function(options, self) {
@*/
that.value = function(id, key, value) {
// id can be a number and will then be interpreted as position
Ox.print('that.value id key value', id, key, value)
Ox.Log('List', 'that.value id key value', id, key, value)
var pos = Ox.isNumber(id) ? id : getPositionById(id),
$item = self.$items[pos],
data = $item.options('data');

View file

@ -213,14 +213,14 @@ Ox.TextList = function(options, self) {
})
.bindEvent({
cancel: function(data) {
Ox.print('cancel edit', data);
Ox.Log('List', 'cancel edit', data);
},
edit: function(data) {
that.editCell(data.id, data.key);
},
init: function(data) {
// fixme: why does this never reach?
//Ox.print('INIT????')
//Ox.Log('List', 'INIT????')
//that.triggerEvent('init', data);
},
select: function() {
@ -233,10 +233,10 @@ Ox.TextList = function(options, self) {
width: getItemWidth() + 'px'
});
//Ox.print('s.vC', self.visibleColumns)
//Ox.Log('List', 's.vC', self.visibleColumns)
function addColumn(id) {
//Ox.print('addColumn', id);
//Ox.Log('List', 'addColumn', id);
var column, ids,
index = 0;
Ox.forEach(self.options.columns, function(v) {
@ -284,7 +284,7 @@ Ox.TextList = function(options, self) {
}
function clickColumn(id) {
Ox.print('clickColumn', id);
Ox.Log('List', 'clickColumn', id);
var i = getColumnIndexById(id),
isSelected = self.options.sort[0].key == self.options.columns[i].id;
self.options.sort = [{
@ -549,14 +549,14 @@ Ox.TextList = function(options, self) {
// fixme: works only if items are an array
var query = data.keys,
sort = self.options.sort[0];
Ox.print('QUERY', query)
Ox.Log('List', 'QUERY', query)
Ox.forEach(self.options.items, function(item, i) {
var value = (
sort.map ? sort.map(item[sort.key]) : item[sort.key]
).toString().toLowerCase();
if (Ox.startsWith(value, query)) {
that.$body.options({selected: [item[self.unique]]});
Ox.print('QUERY', query, 'VALUE', value)
Ox.Log('List', 'QUERY', query, 'VALUE', value)
return false;
}
});
@ -586,7 +586,7 @@ Ox.TextList = function(options, self) {
}
function getCell(id, key) {
Ox.print('getCell', id, key)
Ox.Log('List', 'getCell', id, key)
var $item = getItem(id);
key = key || '';
return $($item.find('.OxCell.OxColumn' + Ox.toTitleCase(key))[0]);
@ -609,7 +609,7 @@ Ox.TextList = function(options, self) {
}
function getItem(id) {
//Ox.print('getItem', id)
//Ox.Log('List', 'getItem', id)
var $item = null;
that.find('.OxItem').each(function() {
$this = $(this);
@ -641,7 +641,7 @@ Ox.TextList = function(options, self) {
}
function moveColumn(id, pos) {
//Ox.print('moveColumn', id, pos)
//Ox.Log('List', 'moveColumn', id, pos)
var startPos = getColumnPositionById(id),
stopPos = pos,
startSelector = '.OxColumn' + Ox.toTitleCase(id),
@ -649,7 +649,7 @@ Ox.TextList = function(options, self) {
insert = startPos < stopPos ? 'insertAfter' : 'insertBefore'
$column = $('.OxHeadCell' + startSelector),
$resize = $column.next();
//Ox.print(startSelector, insert, stopSelector)
//Ox.Log('List', startSelector, insert, stopSelector)
$column.detach()[insert](insert == 'insertAfter'
? $('.OxHeadCell' + stopSelector).next()
: $('.OxHeadCell' + stopSelector));
@ -679,7 +679,7 @@ Ox.TextList = function(options, self) {
}
function removeColumn(id) {
//Ox.print('removeColumn', id);
//Ox.Log('List', 'removeColumn', id);
var index = getColumnIndexById(id),
itemWidth,
position = getColumnPositionById(id),
@ -800,7 +800,7 @@ Ox.TextList = function(options, self) {
}
self.setOption = function(key, value) {
//Ox.print('---------------------------- TextList setOption', key, value)
//Ox.Log('List', '---------------------------- TextList setOption', key, value)
if (key == 'items') {
that.$body.options(key, value);
} else if (key == 'paste') {
@ -827,7 +827,7 @@ Ox.TextList = function(options, self) {
}
that.editCell = function(id, key) {
Ox.print('editCell', id, key)
Ox.Log('List', 'editCell', id, key)
var $item = getItem(id),
$cell = getCell(id, key),
$input,
@ -901,14 +901,14 @@ Ox.TextList = function(options, self) {
}
that.size = function() {
Ox.print('SIZE FUNCTION CALLED')
Ox.Log('List', 'SIZE FUNCTION CALLED')
setWidth();
that.$body.size();
}
// fixme: deprecated
that.sortList = function(key, operator) {
Ox.print('$$$$ DEPRECATED $$$$')
Ox.Log('List', '$$$$ DEPRECATED $$$$')
var isSelected = key == self.options.sort[0].key;
self.options.sort = [{
key: key,
@ -941,7 +941,7 @@ Ox.TextList = function(options, self) {
that.value = function(id, key, value) {
// fixme: make this accept id, {k: v, ...}
//Ox.print('value', id, key, value)
//Ox.Log('List', 'value', id, key, value)
var $cell,
$item = getItem(id);
//column = self.options.columns[getColumnIndexById(key)];

View file

@ -133,7 +133,7 @@ Ox.TreeList = function(options, self) {
}
function parseData(key, value) {
//Ox.print('parseData', key, value)
//Ox.Log('List', 'parseData', key, value)
var ret = {
expanded: false,
id: Ox.uid().toString(),