allow for updating 'draggable' and 'sortable' options of a table list
This commit is contained in:
parent
305dd4cec1
commit
6c79e5711e
2 changed files with 30 additions and 19 deletions
|
@ -86,6 +86,7 @@ Ox.List = function(options, self) {
|
|||
})
|
||||
.options(options || {})
|
||||
.update({
|
||||
draggable: updateDraggable,
|
||||
items: function() {
|
||||
if (!self.isAsync) {
|
||||
updateItems();
|
||||
|
@ -114,9 +115,8 @@ Ox.List = function(options, self) {
|
|||
selected: function() {
|
||||
setSelected(self.options.selected);
|
||||
},
|
||||
sort: function() {
|
||||
updateSort();
|
||||
}
|
||||
sort: updateSort,
|
||||
sortable: updateSortable
|
||||
})
|
||||
.scroll(scroll);
|
||||
|
||||
|
@ -154,22 +154,8 @@ Ox.List = function(options, self) {
|
|||
}
|
||||
|
||||
});
|
||||
if (self.options.draggable) {
|
||||
that.$content.bindEvent({
|
||||
dragstart: dragstart,
|
||||
drag: drag,
|
||||
dragpause: dragpause,
|
||||
dragenter: dragenter,
|
||||
dragleave: dragleave,
|
||||
dragend: dragend
|
||||
});
|
||||
} else if (self.options.sortable) {
|
||||
that.$content.bindEvent({
|
||||
dragstart: movestart,
|
||||
drag: move,
|
||||
dragend: moveend
|
||||
});
|
||||
}
|
||||
self.options.draggable && updateDraggable();
|
||||
self.options.sortable && updateSortable();
|
||||
|
||||
// fixme: without this, horizontal lists don't get their full width
|
||||
self.options.orientation == 'horizontal' && that.$content.css({height: '1px'});
|
||||
|
@ -1360,6 +1346,17 @@ Ox.List = function(options, self) {
|
|||
unloadPage(page + 1)
|
||||
}
|
||||
|
||||
function updateDraggable() {
|
||||
that.$content[self.options.draggable ? 'bindEvent' : 'unbindEvent']({
|
||||
dragstart: dragstart,
|
||||
drag: drag,
|
||||
dragpause: dragpause,
|
||||
dragenter: dragenter,
|
||||
dragleave: dragleave,
|
||||
dragend: dragend
|
||||
});
|
||||
}
|
||||
|
||||
function updateItems() {
|
||||
clear();
|
||||
that.$content.empty();
|
||||
|
@ -1511,6 +1508,14 @@ Ox.List = function(options, self) {
|
|||
//}
|
||||
}
|
||||
|
||||
function updateSortable() {
|
||||
that.$content[self.options.sortable ? 'bindEvent' : 'unbindEvent']({
|
||||
dragstart: movestart,
|
||||
drag: move,
|
||||
dragend: moveend
|
||||
});
|
||||
}
|
||||
|
||||
/*@
|
||||
addItems <f> add item to list
|
||||
(pos, items) -> <u> add items to list at position
|
||||
|
|
|
@ -90,6 +90,9 @@ Ox.TableList = function(options, self) {
|
|||
? disableHorizontalScrolling()
|
||||
: enableHorizontalScrolling();
|
||||
},
|
||||
draggable: function() {
|
||||
that.$body.options({sortable: self.options.draggable});
|
||||
},
|
||||
items: function() {
|
||||
that.$body.options({items: self.options.items});
|
||||
},
|
||||
|
@ -107,6 +110,9 @@ Ox.TableList = function(options, self) {
|
|||
sort: function() {
|
||||
updateColumn();
|
||||
that.$body.options({sort: self.options.sort});
|
||||
},
|
||||
sortable: function() {
|
||||
that.$body.options({sortable: self.options.sortable});
|
||||
}
|
||||
})
|
||||
.addClass('OxTableList');
|
||||
|
|
Loading…
Reference in a new issue