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 || {})
|
.options(options || {})
|
||||||
.update({
|
.update({
|
||||||
|
draggable: updateDraggable,
|
||||||
items: function() {
|
items: function() {
|
||||||
if (!self.isAsync) {
|
if (!self.isAsync) {
|
||||||
updateItems();
|
updateItems();
|
||||||
|
@ -114,9 +115,8 @@ Ox.List = function(options, self) {
|
||||||
selected: function() {
|
selected: function() {
|
||||||
setSelected(self.options.selected);
|
setSelected(self.options.selected);
|
||||||
},
|
},
|
||||||
sort: function() {
|
sort: updateSort,
|
||||||
updateSort();
|
sortable: updateSortable
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.scroll(scroll);
|
.scroll(scroll);
|
||||||
|
|
||||||
|
@ -154,22 +154,8 @@ Ox.List = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
if (self.options.draggable) {
|
self.options.draggable && updateDraggable();
|
||||||
that.$content.bindEvent({
|
self.options.sortable && updateSortable();
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// fixme: without this, horizontal lists don't get their full width
|
// fixme: without this, horizontal lists don't get their full width
|
||||||
self.options.orientation == 'horizontal' && that.$content.css({height: '1px'});
|
self.options.orientation == 'horizontal' && that.$content.css({height: '1px'});
|
||||||
|
@ -1360,6 +1346,17 @@ Ox.List = function(options, self) {
|
||||||
unloadPage(page + 1)
|
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() {
|
function updateItems() {
|
||||||
clear();
|
clear();
|
||||||
that.$content.empty();
|
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
|
addItems <f> add item to list
|
||||||
(pos, items) -> <u> add items to list at position
|
(pos, items) -> <u> add items to list at position
|
||||||
|
|
|
@ -90,6 +90,9 @@ Ox.TableList = function(options, self) {
|
||||||
? disableHorizontalScrolling()
|
? disableHorizontalScrolling()
|
||||||
: enableHorizontalScrolling();
|
: enableHorizontalScrolling();
|
||||||
},
|
},
|
||||||
|
draggable: function() {
|
||||||
|
that.$body.options({sortable: self.options.draggable});
|
||||||
|
},
|
||||||
items: function() {
|
items: function() {
|
||||||
that.$body.options({items: self.options.items});
|
that.$body.options({items: self.options.items});
|
||||||
},
|
},
|
||||||
|
@ -107,6 +110,9 @@ Ox.TableList = function(options, self) {
|
||||||
sort: function() {
|
sort: function() {
|
||||||
updateColumn();
|
updateColumn();
|
||||||
that.$body.options({sort: self.options.sort});
|
that.$body.options({sort: self.options.sort});
|
||||||
|
},
|
||||||
|
sortable: function() {
|
||||||
|
that.$body.options({sortable: self.options.sortable});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addClass('OxTableList');
|
.addClass('OxTableList');
|
||||||
|
|
Loading…
Reference in a new issue