forked from 0x2620/oxjs
select multple annotations, option to pass confirm delete dialog
This commit is contained in:
parent
96d4dfe71d
commit
03eb3d4a56
4 changed files with 42 additions and 19 deletions
|
|
@ -25,6 +25,7 @@ Ox.ArrayEditable = function(options, self) {
|
||||||
var that = Ox.Element({}, self)
|
var that = Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
clickLink: null,
|
clickLink: null,
|
||||||
|
confirmDeleteDialog: null,
|
||||||
editable: true,
|
editable: true,
|
||||||
format: null,
|
format: null,
|
||||||
getSortValue: null,
|
getSortValue: null,
|
||||||
|
|
@ -120,11 +121,17 @@ Ox.ArrayEditable = function(options, self) {
|
||||||
// it is possible to delete an (empty-value) item
|
// it is possible to delete an (empty-value) item
|
||||||
// by selecting another one
|
// by selecting another one
|
||||||
id = id || self.options.selected;
|
id = id || self.options.selected;
|
||||||
var position = Ox.getIndexById(self.options.items, id)
|
|
||||||
|
(self.options.confirmDeleteDialog ? self.options.confirmDeleteDialog: Ox.noop)({
|
||||||
|
items: Ox.isArray(id) ? id : [id],
|
||||||
|
}, function(result) {
|
||||||
if (self.options.editable) {
|
if (self.options.editable) {
|
||||||
|
(Ox.isArray(id) ? id : [id]).forEach(id => {
|
||||||
|
var position = Ox.getIndexById(self.options.items, id)
|
||||||
self.options.items.splice(position, 1);
|
self.options.items.splice(position, 1);
|
||||||
renderItems();
|
|
||||||
that.triggerEvent('delete', {id: id});
|
that.triggerEvent('delete', {id: id});
|
||||||
|
})
|
||||||
|
renderItems();
|
||||||
self.editing = false;
|
self.editing = false;
|
||||||
if (self.options.selected == id) {
|
if (self.options.selected == id) {
|
||||||
self.selected = -1;
|
self.selected = -1;
|
||||||
|
|
@ -133,6 +140,8 @@ Ox.ArrayEditable = function(options, self) {
|
||||||
self.selected = Ox.getIndexById(self.options.item, self.options.selected)
|
self.selected = Ox.getIndexById(self.options.item, self.options.selected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doubleclick(e) {
|
function doubleclick(e) {
|
||||||
|
|
@ -290,12 +299,20 @@ Ox.ArrayEditable = function(options, self) {
|
||||||
if (!Ox.isArray(self.selected)) {
|
if (!Ox.isArray(self.selected)) {
|
||||||
self.selected = [self.selected]
|
self.selected = [self.selected]
|
||||||
}
|
}
|
||||||
if (self.options.selected.includes(id)) {
|
if (!self.options.selected.includes(id)) {
|
||||||
self.options.selected.pop(id)
|
var minPos, maxPos;
|
||||||
self.selected.pop(position)
|
if (Ox.min(self.selected) > position) {
|
||||||
|
minPos = position
|
||||||
|
maxPos = Ox.min(self.selected)
|
||||||
} else {
|
} else {
|
||||||
self.options.selected.push(id)
|
minPos = Ox.max(self.selected) + 1
|
||||||
self.selected.push(position)
|
maxPos = position + 1
|
||||||
|
}
|
||||||
|
Ox.range(minPos, maxPos).forEach(pos => {
|
||||||
|
self.selected.push(pos)
|
||||||
|
self.options.selected.push(getId(pos))
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
that.find('.OxSelected').removeClass('OxSelected').removeClass('OxMultiple');
|
that.find('.OxSelected').removeClass('OxSelected').removeClass('OxMultiple');
|
||||||
that.find('.OxGroup').removeClass('OxGroup')
|
that.find('.OxGroup').removeClass('OxGroup')
|
||||||
|
|
@ -371,7 +388,7 @@ Ox.ArrayEditable = function(options, self) {
|
||||||
position = $element.data('position');
|
position = $element.data('position');
|
||||||
// if clicked on an element
|
// if clicked on an element
|
||||||
if (position != self.selected) {
|
if (position != self.selected) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey && self.selected != -1) {
|
||||||
// add/remove item from multiple selection
|
// add/remove item from multiple selection
|
||||||
document.getSelection().removeAllRanges();
|
document.getSelection().removeAllRanges();
|
||||||
toggleItem(position);
|
toggleItem(position);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
var that = Ox.Element({}, self)
|
var that = Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
clickLink: null,
|
clickLink: null,
|
||||||
|
confirmDeleteDialog: null,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
highlight: '',
|
highlight: '',
|
||||||
|
|
@ -281,6 +282,7 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
}
|
}
|
||||||
self.$annotations = Ox.ArrayEditable(Ox.extend({
|
self.$annotations = Ox.ArrayEditable(Ox.extend({
|
||||||
clickLink: self.options.clickLink,
|
clickLink: self.options.clickLink,
|
||||||
|
confirmDeleteDialog: self.options.confirmDeleteDialog,
|
||||||
editable: self.options.editable,
|
editable: self.options.editable,
|
||||||
getSortValue: self.options.type == 'text'
|
getSortValue: self.options.type == 'text'
|
||||||
? function(value) {
|
? function(value) {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ Ox.AnnotationPanel = function(options, self) {
|
||||||
.defaults({
|
.defaults({
|
||||||
calendarSize: 256,
|
calendarSize: 256,
|
||||||
clickLink: null,
|
clickLink: null,
|
||||||
|
confirmDeleteDialog: null,
|
||||||
editable: false,
|
editable: false,
|
||||||
enableExport: false,
|
enableExport: false,
|
||||||
enableImport: false,
|
enableImport: false,
|
||||||
|
|
@ -371,6 +372,7 @@ Ox.AnnotationPanel = function(options, self) {
|
||||||
self.$folder[index] = Ox.AnnotationFolder(
|
self.$folder[index] = Ox.AnnotationFolder(
|
||||||
Ox.extend({
|
Ox.extend({
|
||||||
clickLink: self.options.clickLink,
|
clickLink: self.options.clickLink,
|
||||||
|
confirmDeleteDialog: self.options.confirmDeleteDialog,
|
||||||
collapsed: !self.options.showLayers[layer.id],
|
collapsed: !self.options.showLayers[layer.id],
|
||||||
editable: self.options.editable,
|
editable: self.options.editable,
|
||||||
highlight: getHighlight(layer.id),
|
highlight: getHighlight(layer.id),
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
censoredIcon: '',
|
censoredIcon: '',
|
||||||
censoredTooltip: '',
|
censoredTooltip: '',
|
||||||
clickLink: null,
|
clickLink: null,
|
||||||
|
confirmDeleteDialog: null,
|
||||||
cuts: [],
|
cuts: [],
|
||||||
duration: 0,
|
duration: 0,
|
||||||
enableDownload: false,
|
enableDownload: false,
|
||||||
|
|
@ -844,6 +845,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
autocomplete: self.options.autocomplete,
|
autocomplete: self.options.autocomplete,
|
||||||
calendarSize: self.options.annotationsCalendarSize,
|
calendarSize: self.options.annotationsCalendarSize,
|
||||||
clickLink: self.options.clickLink,
|
clickLink: self.options.clickLink,
|
||||||
|
confirmDeleteDialog: self.options.confirmDeleteDialog,
|
||||||
editable: true,
|
editable: true,
|
||||||
enableExport: self.options.enableExport,
|
enableExport: self.options.enableExport,
|
||||||
enableImport: self.options.enableImport,
|
enableImport: self.options.enableImport,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue