Initial work on handlers for re-ordering repeater items

This commit is contained in:
Ben Thomson 2019-04-08 15:57:04 +08:00
parent 332ed62931
commit 98832fbc57
1 changed files with 18 additions and 1 deletions

View File

@ -22,6 +22,9 @@
this.$el = $(element)
this.$sortable = $(options.sortableContainer, this.$el)
// Sortable tracking
this.sortingStartIndex = null
$.oc.foundation.controlUtils.markDisposable(element)
Base.call(this)
this.init()
@ -77,7 +80,9 @@
Repeater.prototype.bindSorting = function() {
var sortableOptions = {
handle: this.options.sortableHandle,
nested: false
nested: false,
onDragStart: this.proxy(this.onSortStart),
onDrop: this.proxy(this.onSortStop)
}
this.$sortable.sortable(sortableOptions)
@ -224,6 +229,18 @@
return defaultText
}
Repeater.prototype.onSortStart = function($item, container, callback, event) {
this.sortingStartIndex = $item.index()
callback($item, container, callback, event);
}
Repeater.prototype.onSortStop = function($item, container, callback, event) {
var endIndex = $item.index()
callback($item, container, callback, event);
}
// FIELD REPEATER PLUGIN DEFINITION
// ============================