').addClass('OxRight').appendTo($resize.$element);
});
that.$head.$content.css({
width: (Ox.sum(self.columnWidths) + 2) + 'px'
});
if (getColumnPositionById(self.options.columns[self.selectedColumn].id) > -1) { // fixme: save in var
toggleSelected(self.options.columns[self.selectedColumn].id);
- that.$titles[getColumnPositionById(self.options.columns[self.selectedColumn].id)].css({
+ self.$titles[getColumnPositionById(self.options.columns[self.selectedColumn].id)].css({
width: (self.options.columns[self.selectedColumn].width - 25) + 'px'
});
}
@@ -419,56 +424,39 @@ Ox.TextList = function(options, self) {
return $item;
}
- function formatValue(key, value, data) {
- // fixme: this may be obscure...
- // since the format of a value may depend on another value,
- // we pass all data as a second parameter to the supplied format function
- var format = self.format[key];
- if (value === null) {
- value = '';
- } else if (format) {
- value = Ox.isObject(format) ?
- Ox['format' + Ox.toTitleCase(format.type)]
- .apply(this, Ox.merge([value], format.args || [])) :
- format(value, data);
- } else if (Ox.isArray(value)) {
- value = value.join(', ');
- }
- return value;
- }
-
function dragstartColumn(id, e) {
self.drag = {
- startX: e.clientX,
+ columnOffsets: getColumnOffsets(),
+ // fixme: doesn't take into account horizontal scroll
+ listOffset: that.$element.offset().left,
startPos: getColumnPositionById(id)
}
- $.extend(self.drag, {
- stopPos: self.drag.startPos,
- offsets: $.map(self.visibleColumns, function(v, i) {
- return self.columnOffsets[i] - self.columnOffsets[self.drag.startPos]
- })
- });
- $('.OxColumn' + Ox.toTitleCase(id)).css({
- opacity: 0.25
- });
- that.$titles[self.drag.startPos].addClass('OxDrag').css({ // fixme: why does the class not work?
+ self.drag.stopPos = self.drag.startPos;
+ $('.OxColumn' + Ox.toTitleCase(id)).css({opacity: 0.25});
+ self.drag.startPos > 0 && self.$heads[self.drag.startPos].prev().children().eq(2).css({opacity: 0.25});
+ self.$heads[self.drag.startPos].next().children().eq(0).css({opacity: 0.25});
+ self.$heads[self.drag.startPos].addClass('OxDrag').css({ // fixme: why does the class not work?
cursor: 'move'
});
+ //Ox.print('columnOffsets', self.drag.columnOffsets)
}
function dragColumn(id, e) {
- var d = e.clientX - self.drag.startX,
- pos = self.drag.stopPos;
- Ox.forEach(self.drag.offsets, function(v, i) {
- if (d < 0 && d < v) {
+ var pos = self.drag.stopPos;
+ Ox.forEach(self.drag.columnOffsets, function(offset, i) {
+ var x = self.drag.listOffset + offset + self.columnWidths[i] / 2;
+ if (i < self.drag.startPos && e.clientX < x) {
self.drag.stopPos = i;
return false;
- } else if (d > 0 && d > v) {
+ } else if (i > self.drag.startPos && e.clientX > x) {
self.drag.stopPos = i;
}
});
if (self.drag.stopPos != pos) {
moveColumn(id, self.drag.stopPos);
+ self.drag.columnOffsets = getColumnOffsets();
+ self.drag.startPos = self.drag.stopPos;
+ //Ox.print('columnOffsets', self.drag.columnOffsets)
}
}
@@ -479,10 +467,8 @@ Ox.TextList = function(options, self) {
self.columnWidths.splice(self.drag.stopPos, 0, width);
that.$head.$content.empty();
constructHead();
- $('.OxColumn' + Ox.toTitleCase(id)).css({
- opacity: 1
- });
- that.$titles[self.drag.stopPos].removeClass('OxDrag').css({
+ $('.OxColumn' + Ox.toTitleCase(id)).css({opacity: 1});
+ self.$heads[self.drag.stopPos].removeClass('OxDrag').css({
cursor: 'pointer'
});
that.$body.clearCache();
@@ -492,14 +478,13 @@ Ox.TextList = function(options, self) {
function dragstartResize(id, e) {
var pos = getColumnPositionById(id);
self.drag = {
- startX: e.clientX,
startWidth: self.columnWidths[pos]
};
}
function dragResize(id, e) {
var width = Ox.limit(
- self.drag.startWidth - self.drag.startX + e.clientX,
+ self.drag.startWidth + e.clientDX,
self.options.columnWidth[0],
self.options.columnWidth[1]
);
@@ -531,6 +516,24 @@ Ox.TextList = function(options, self) {
});
}
+ function formatValue(key, value, data) {
+ // fixme: this may be obscure...
+ // since the format of a value may depend on another value,
+ // we pass all data as a second parameter to the supplied format function
+ var format = self.format[key];
+ if (value === null) {
+ value = '';
+ } else if (format) {
+ value = Ox.isObject(format) ?
+ Ox['format' + Ox.toTitleCase(format.type)]
+ .apply(this, Ox.merge([value], format.args || [])) :
+ format(value, data);
+ } else if (Ox.isArray(value)) {
+ value = value.join(', ');
+ }
+ return value;
+ }
+
function getCell(id, key) {
Ox.print('getCell', id, key)
var $item = getItem(id);
@@ -538,6 +541,14 @@ Ox.TextList = function(options, self) {
return $($item.find('.OxCell.OxColumn' + Ox.toTitleCase(key))[0]);
}
+ function getColumnOffsets() {
+ return self.visibleColumns.map(function(column, i) {
+ return Ox.sum(self.visibleColumns.map(function(column_, i_) {
+ return i_ < i ? self.columnWidths[i_] : 0;
+ }));
+ });
+ }
+
function getColumnIndexById(id) {
return Ox.getPositionById(self.options.columns, id);
}
@@ -549,10 +560,10 @@ Ox.TextList = function(options, self) {
function getItem(id) {
//Ox.print('getItem', id)
var $item = null;
- $.each(that.find('.OxItem'), function(i, v) {
- $v = $(v);
- if ($v.data('id') == id) {
- $item = $v;
+ that.find('.OxItem').each(function() {
+ $this = $(this);
+ if ($this.data('id') == id) {
+ $item = $this;
return false;
}
});
@@ -579,37 +590,50 @@ Ox.TextList = function(options, self) {
}
function moveColumn(id, pos) {
- // fixme: column head should be one element, not three
//Ox.print('moveColumn', id, pos)
var startPos = getColumnPositionById(id),
stopPos = pos,
- startClassName = '.OxColumn' + Ox.toTitleCase(id),
- stopClassName = '.OxColumn' + Ox.toTitleCase(self.visibleColumns[stopPos].id),
+ startSelector = '.OxColumn' + Ox.toTitleCase(id),
+ stopSelector = '.OxColumn' + Ox.toTitleCase(self.visibleColumns[stopPos].id),
insert = startPos < stopPos ? 'insertAfter' : 'insertBefore'
- $column = $('.OxTitle' + startClassName),
- $order = $column.next(),
- $resize = $order.next();
- //Ox.print(startClassName, insert, stopClassName)
- $column.detach()[insert](insert == 'insertAfter' ? $('.OxTitle' + stopClassName).next().next() : $('.OxTitle' + stopClassName));
- $order.detach().insertAfter($column);
- $resize.detach().insertAfter($order);
- $.each(that.$body.find('.OxItem'), function(i, v) {
- var $v = $(v);
- $v.children(startClassName).detach()[insert]($v.children(stopClassName));
+ $column = $('.OxHeadCell' + startSelector),
+ $resize = $column.next();
+ //Ox.print(startSelector, insert, stopSelector)
+ $column.detach()[insert](insert == 'insertAfter'
+ ? $('.OxHeadCell' + stopSelector).next()
+ : $('.OxHeadCell' + stopSelector));
+ $resize.detach().insertAfter($column);
+ that.$body.find('.OxItem').each(function() {
+ var $this = $(this);
+ $this.children(startSelector).detach()[insert](
+ $this.children(stopSelector)
+ );
});
- var column = self.visibleColumns.splice(startPos, 1)[0],
- width = self.columnWidths.splice(startPos, 1)[0];
- self.visibleColumns.splice(stopPos, 0, column);
- self.columnWidths.splice(stopPos, 0, width);
+ var $head = self.$heads.splice(startPos, 1)[0],
+ columnWidth = self.columnWidths.splice(startPos, 1)[0],
+ visibleColumn = self.visibleColumns.splice(startPos, 1)[0];
+ self.$heads.splice(stopPos, 0, $head);
+ self.columnWidths.splice(stopPos, 0, columnWidth);
+ self.visibleColumns.splice(stopPos, 0, visibleColumn);
+ var pos = getColumnPositionById(self.options.columns[self.selectedColumn].id);
+ if (pos > -1) {
+ that.$element.find('.OxResize .OxSelected').removeClass('OxSelected');
+ pos > 0 && self.$heads[pos].prev().children().eq(2).addClass('OxSelected');
+ self.$heads[pos].next().children().eq(0).addClass('OxSelected');
+ if (pos == stopPos) {
+ pos > 0 && self.$heads[pos].prev().children().eq(2).css({opacity: 0.25});
+ self.$heads[pos].next().children().eq(0).css({opacity: 0.25});
+ }
+ }
}
function removeColumn(id) {
//Ox.print('removeColumn', id);
- var className = '.OxColumn' + Ox.toTitleCase(id),
- index = getColumnIndexById(id),
+ var index = getColumnIndexById(id),
itemWidth,
position = getColumnPositionById(id),
- $column = $('.OxTitle' + className),
+ selector = '.OxColumn' + Ox.toTitleCase(id),
+ $column = $('.OxHeadCell ' + selector),
$order = $column.next(),
$resize = $order.next();
self.options.columns[index].visible = false;
@@ -618,19 +642,17 @@ Ox.TextList = function(options, self) {
that.$head.$content.empty();
constructHead();
itemWidth = getItemWidth();
- $.each(that.$body.find('.OxItem'), function(i, v) {
- var $v = $(v);
- $v.children(className).remove();
- $v.css({
- width: itemWidth + 'px'
- });
+ that.$body.find('.OxItem').each(function() {
+ var $this = $(this);
+ $this.children(selector).remove();
+ $this.css({width: itemWidth + 'px'});
});
that.$body.$content.css({
width: itemWidth + 'px'
});
that.$body.options({
keys: Ox.merge(self.visibleColumns.map(function(column) {
- return colum.id;
+ return column.id;
}), self.options.keys)
});
//that.$body.clearCache();
@@ -654,12 +676,15 @@ Ox.TextList = function(options, self) {
that.$head.$content.css({
width: (Ox.sum(self.columnWidths) + 2) + 'px'
});
- that.$titles[pos].css({
- width: (width - 9 - (i == self.selectedColumn ? 16 : 0)) + 'px'
+ self.$heads[pos].css({
+ width: width - 5 + 'px'
+ });
+ self.$titles[pos].css({
+ width: width - 9 - (i == self.selectedColumn ? 16 : 0) + 'px'
});
}
that.$element.find('.OxCell.OxColumn' + Ox.toTitleCase(self.options.columns[i].id)).css({
- width: (width - (self.options.columnsVisible ? 9 : 8)) + 'px'
+ width: width - (self.options.columnsVisible ? 9 : 8) + 'px'
});
setWidth();
}
@@ -678,13 +703,12 @@ Ox.TextList = function(options, self) {
var pos = getColumnPositionById(id);
if (pos > -1) {
updateOrder(id);
- pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass('OxSelected');
- that.$titles[pos].toggleClass('OxSelected');
- that.$titles[pos].next().toggleClass('OxSelected');
- that.$titles[pos].next().next().children().eq(0).toggleClass('OxSelected');
- that.$titles[pos].css({
+ pos > 0 && self.$heads[pos].prev().children().eq(2).toggleClass('OxSelected');
+ self.$heads[pos].toggleClass('OxSelected');
+ self.$heads[pos].next().children().eq(0).toggleClass('OxSelected');
+ self.$titles[pos].css({
width: (
- that.$titles[pos].width() + (that.$titles[pos].hasClass('OxSelected') ? -16 : 16)
+ self.$titles[pos].width() + (self.$heads[pos].hasClass('OxSelected') ? -16 : 16)
) + 'px'
});
}
@@ -692,8 +716,8 @@ Ox.TextList = function(options, self) {
function triggerColumnChangeEvent() {
that.triggerEvent('columnchange', {
- ids: $.map(self.visibleColumns, function(v, i) {
- return v.id;
+ ids: self.visibleColumns.map(function(column) {
+ return column.id;
})
});
}
@@ -713,11 +737,14 @@ Ox.TextList = function(options, self) {
}
function updateOrder(id) {
- var pos = getColumnPositionById(id);
+ var operator = self.options.sort[0].operator,
+ pos = getColumnPositionById(id);
if (pos > -1) {
- that.$titles[pos].next().html(Ox.UI.symbols[
- 'triangle_' + (self.options.sort[0].operator == '+' ? 'up' : 'down')
- ]);
+ self.$orderButtons[pos].options({
+ title: operator == '+' ? 'up' : 'down'
+ }).css({
+ marginTop: (operator == '+' ? 1 : -1) + 'px'
+ });
}
}
diff --git a/source/Ox.UI/js/Menu/Ox.MainMenu.js b/source/Ox.UI/js/Menu/Ox.MainMenu.js
index 74352949..5ba0a513 100644
--- a/source/Ox.UI/js/Menu/Ox.MainMenu.js
+++ b/source/Ox.UI/js/Menu/Ox.MainMenu.js
@@ -61,8 +61,8 @@ Ox.MainMenu = function(options, self) {
function click(event) {
var $target = $(event.target),
- position = typeof $target.data('position') != 'undefined' ?
- $target.data('position') : -1;
+ position = typeof $target.data('position') != 'undefined'
+ ? $target.data('position') : -1;
clickTitle(position);
}
@@ -84,8 +84,8 @@ Ox.MainMenu = function(options, self) {
function mousemove(event) {
var $target = $(event.target),
focused,
- position = typeof $target.data('position') != 'undefined' ?
- $target.data('position') : -1;
+ position = typeof $target.data('position') != 'undefined'
+ ? $target.data('position') : -1;
if (self.focused && position != self.selected) {
if (position > -1) {
clickTitle(position);
@@ -125,25 +125,23 @@ Ox.MainMenu = function(options, self) {
itemId = ids.pop(),
menuId = ids.join('_');
that.getMenu(menuId).checkItem(itemId);
+ return that;
};
/*@
disableItem
disableItem
@*/
that.disableItem = function(id) {
- that.getItem(id).options({
- disabled: true
- });
+ that.getItem(id).options({disabled: true});
+ return that;
};
/*@
enableItem enableItem
@*/
that.enableItem = function(id) {
- Ox.print('ENABLE ITEM', id)
- that.getItem(id).options({
- disabled: false
- });
+ that.getItem(id).options({disabled: false});
+ return that;
};
/*@
@@ -180,7 +178,6 @@ Ox.MainMenu = function(options, self) {
} else {
menu = that.getMenu(ids.shift()).getSubmenu(ids.join('_'));
}
- //Ox.print('getMenu', id, menu);
return menu;
};
@@ -195,6 +192,7 @@ Ox.MainMenu = function(options, self) {
if (self.selected < self.options.menus.length - 1) {
clickTitle(self.selected + 1);
}
+ return that;
};
/*@
@@ -204,15 +202,15 @@ Ox.MainMenu = function(options, self) {
if (self.selected) {
clickTitle(self.selected - 1);
}
+ return that;
};
/*@
uncheckItem uncheckItem
@*/
that.uncheckItem = function(id) {
- that.getItem(id).options({
- checked: false
- });
+ that.getItem(id).options({checked: false});
+ return that;
};
return that;
diff --git a/source/Ox.UI/js/Menu/Ox.Menu.js b/source/Ox.UI/js/Menu/Ox.Menu.js
index 1614e013..c1f4bf2f 100644
--- a/source/Ox.UI/js/Menu/Ox.Menu.js
+++ b/source/Ox.UI/js/Menu/Ox.Menu.js
@@ -178,8 +178,8 @@ Ox.Menu = function(options, self) {
self.optionGroups = {};
items.forEach(function(item, i) {
if (item.group) {
- items[i] = $.map(item.items, function(v, i) {
- return $.extend(v, {
+ items[i] = item.items.map(function(v, i) {
+ return Ox.extend(v, {
group: item.group
});
});
@@ -196,7 +196,7 @@ Ox.Menu = function(options, self) {
items.forEach(function(item) {
var position;
if ('id' in item) {
- that.items.push(Ox.MenuItem($.extend(item, {
+ that.items.push(Ox.MenuItem(Ox.extend(item, {
menu: that,
position: position = that.items.length
})).data('position', position).appendTo(that.$content)); // fixme: jquery bug when passing {position: position}? does not return the object?;
@@ -281,10 +281,7 @@ Ox.Menu = function(options, self) {
function constructSpace() {
return $('').append(
- $('', {
- 'class': 'OxSpace',
- colspan: 5
- })
+ $(' | ', {'class': 'OxSpace', colspan: 5})
);
}
@@ -720,10 +717,10 @@ Ox.Menu = function(options, self) {
};
/*@
- toggelMenu toggleMenu
+ toggleMenu toggleMenu
@*/
that.toggleMenu = function() {
- that.is(':hidden') ? that.showMenu() : that.hideMenu();
+ return that.is(':hidden') ? that.showMenu() : that.hideMenu();
};
return that;
diff --git a/source/Ox.UI/js/Menu/Ox.MenuItem.js b/source/Ox.UI/js/Menu/Ox.MenuItem.js
index 763d107e..ced2d346 100644
--- a/source/Ox.UI/js/Menu/Ox.MenuItem.js
+++ b/source/Ox.UI/js/Menu/Ox.MenuItem.js
@@ -36,7 +36,7 @@ Ox.MenuItem = function(options, self) {
position: 0,
title: [],
})
- .options($.extend(options, {
+ .options(Ox.extend(options, {
keyboard: parseKeyboard(options.keyboard || self.defaults.keyboard),
title: Ox.toArray(options.title || self.defaults.title)
}))
@@ -63,10 +63,8 @@ Ox.MenuItem = function(options, self) {
that.$icon = $('', {
'class': 'OxCell OxIcon'
})
- .append(self.options.icon ?
- $('', {
- src: self.options.icon
- }) : null
+ .append(self.options.icon
+ ? $('', {src: self.options.icon}) : null
)
)
.append(
@@ -78,17 +76,19 @@ Ox.MenuItem = function(options, self) {
.append(
$(' | ', {
'class': 'OxCell OxModifiers',
- html: $.map(self.options.keyboard.modifiers, function(modifier) {
+ html: self.options.keyboard.modifiers.map(function(modifier) {
return Ox.UI.symbols[modifier];
}).join('')
})
)
.append(
$(' | ', {
- 'class': 'OxCell Ox' + (self.options.items.length ? 'Submenu' : 'Key'),
- html: self.options.items.length ? Ox.UI.symbols.triangle_right :
- Ox.UI.symbols[self.options.keyboard.key] ||
- self.options.keyboard.key.toUpperCase()
+ 'class': 'OxCell Ox'
+ + (self.options.items.length ? 'Submenu' : 'Key'),
+ html: self.options.items.length
+ ? Ox.UI.symbols.triangle_right
+ : Ox.UI.symbols[self.options.keyboard.key]
+ || self.options.keyboard.key.toUpperCase()
})
);
@@ -108,7 +108,7 @@ Ox.MenuItem = function(options, self) {
if (key == 'checked') {
that.$status.html(value ? Ox.UI.symbols.check : '')
} else if (key == 'disabled') {
- that.toggleClass('OxDisabled'); // fixme: this will only work if onChange is only invoked on actual change
+ that.toggleClass('OxDisabled');
} else if (key == 'title') {
self.options.title = Ox.toArray(value);
that.$title.html(self.options.title[0]);
@@ -120,12 +120,11 @@ Ox.MenuItem = function(options, self) {
};
/*@
- toggelChecked toggleChecked
+ toggleChecked toggleChecked
@*/
that.toggleChecked = function() {
- that.options({
- checked: !self.options.checked
- });
+ that.options({checked: !self.options.checked});
+ return that;
};
that.toggleDisabled = function() {
@@ -133,13 +132,11 @@ Ox.MenuItem = function(options, self) {
};
/*@
- toggelTitle toggleTitle
+ toggleTitle toggleTitle
@*/
that.toggleTitle = function() {
- //Ox.print('s.o.t', self.options.title)
- that.options({
- title: self.options.title.reverse()
- });
+ that.options({title: self.options.title.reverse()});
+ return that;
};
return that;
diff --git a/source/Ox.UI/themes/classic/css/classic.css b/source/Ox.UI/themes/classic/css/classic.css
index d0272da7..a4105b43 100644
--- a/source/Ox.UI/themes/classic/css/classic.css
+++ b/source/Ox.UI/themes/classic/css/classic.css
@@ -378,24 +378,18 @@ Lists
.OxThemeClassic .OxTextList .OxFocus .OxItem.OxSelected:nth-child(even) {
background: rgb(206, 206, 206);
}
-.OxThemeClassic .OxTextList .OxBar {
- background: -moz-linear-gradient(top, rgb(240, 240, 240), rgb(208, 208, 208));
- background: -o-linear-gradient(top, rgb(240, 240, 240), rgb(208, 208, 208));
- background: -webkit-linear-gradient(top, rgb(240, 240, 240), rgb(208, 208, 208));
-}
-.OxThemeClassic .OxTextList .OxBar .OxSelected {
- background: -moz-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
- background: -o-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
- background: -webkit-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
- //color: rgb(0, 0, 0);
-}
-.OxThemeClassic .OxTextList .OxBar .OxOrder {
+
+
+.OxThemeClassic .OxTextList .OxHead .OxSelected {
+ background: -moz-linear-gradient(top, rgb(208, 208, 208), rgb(176, 176, 176));
+ background: -o-linear-gradient(top, rgb(208, 208, 208), rgb(176, 176, 176));
+ background: -webkit-linear-gradient(top, rgb(208, 208, 208), rgb(176, 176, 176));
color: rgb(0, 0, 0);
}
-.OxThemeClassic .OxTextList .OxBar .OxResize .OxCenter {
+.OxThemeClassic .OxTextList .OxHead .OxResize .OxCenter {
background: rgb(192, 192, 192);
}
-.OxThemeClassic .OxTextList .OxBar .OxSelect {
+.OxThemeClassic .OxTextList .OxHead .OxSelect {
border-color: rgb(192, 192, 192);
}
.OxThemeClassic .OxTextList .OxBody .OxItem .OxCell {
diff --git a/source/Ox.UI/themes/modern/css/modern.css b/source/Ox.UI/themes/modern/css/modern.css
index d4312f60..74b2c00e 100644
--- a/source/Ox.UI/themes/modern/css/modern.css
+++ b/source/Ox.UI/themes/modern/css/modern.css
@@ -369,28 +369,23 @@ Lists
//background: rgb(66, 66, 82);
}
.OxThemeModern .OxTextList .OxItem.OxDroppable.OxDrop:nth-child(odd) .OxCell {
- background: rgb(78, 78, 94);
background: rgb(78, 78, 78);
}
.OxThemeModern .OxTextList .OxItem.OxDroppable.OxDrop:nth-child(even) .OxCell {
- background: rgb(82, 82, 98);
background: rgb(82, 82, 82);
}
-.OxThemeModern .OxTextList .OxBar .OxSelected {
+.OxThemeModern .OxTextList .OxHead .OxSelected {
background: -moz-linear-gradient(top, rgb(80, 80, 80), rgb(48, 48, 48));
background: -o-linear-gradient(top, rgb(80, 80, 80), rgb(48, 48, 48));
background: -webkit-linear-gradient(top, rgb(80, 80, 80), rgb(48, 48, 48));
color: rgb(255, 255, 255);
}
-.OxThemeModern .OxTextList .OxBar .OxOrder {
- color: rgb(255, 255, 255);
-}
-.OxThemeModern .OxTextList .OxBar .OxResize .OxCenter {
+.OxThemeModern .OxTextList .OxHead .OxResize .OxCenter {
background: rgb(24, 24, 24);
}
-.OxThemeModern .OxTextList .OxBar .OxSelect {
+.OxThemeModern .OxTextList .OxHead .OxSelect {
border-color: rgb(24, 24, 24);
}
.OxThemeModern .OxTextList .OxBody .OxItem .OxCell {
| |