|
|
@ -84,6 +84,21 @@
|
|
|
|
this.init = function () {
|
|
|
|
this.init = function () {
|
|
|
|
// set initial boards
|
|
|
|
// set initial boards
|
|
|
|
__setBoard();
|
|
|
|
__setBoard();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $el = $(self.element)
|
|
|
|
|
|
|
|
var $inner = $el.find('.kanban-container');
|
|
|
|
|
|
|
|
var leftRegion = $el.position().left + 10;
|
|
|
|
|
|
|
|
var rightRegion = $(window).width() - 10;
|
|
|
|
|
|
|
|
var onMouseMove = function (e) {
|
|
|
|
|
|
|
|
if (e.which !== 1) { return; } // left click
|
|
|
|
|
|
|
|
var distance = 20;
|
|
|
|
|
|
|
|
if (e.pageX < leftRegion) {
|
|
|
|
|
|
|
|
distance *= -1;
|
|
|
|
|
|
|
|
$el.scrollLeft(distance + $el.scrollLeft()) ;
|
|
|
|
|
|
|
|
} else if (e.pageX >= rightRegion) {
|
|
|
|
|
|
|
|
$el.scrollLeft(distance + $el.scrollLeft()) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
//set drag with dragula
|
|
|
|
//set drag with dragula
|
|
|
|
if (window.innerWidth > self.options.responsive) {
|
|
|
|
if (window.innerWidth > self.options.responsive) {
|
|
|
|
|
|
|
|
|
|
|
@ -109,20 +124,22 @@
|
|
|
|
if (typeof (el.dragfn) === 'function') {
|
|
|
|
if (typeof (el.dragfn) === 'function') {
|
|
|
|
el.dragfn(el, source);
|
|
|
|
el.dragfn(el, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('mousemove', onMouseMove);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('dragend', function (el) {
|
|
|
|
.on('dragend', function (el) {
|
|
|
|
el.classList.remove('is-moving');
|
|
|
|
el.classList.remove('is-moving');
|
|
|
|
self.options.dragendBoard(el);
|
|
|
|
self.options.dragendBoard(el);
|
|
|
|
|
|
|
|
$(document).off('mousemove', onMouseMove);
|
|
|
|
if (typeof (el.dragendfn) === 'function')
|
|
|
|
if (typeof (el.dragendfn) === 'function')
|
|
|
|
el.dragendfn(el);
|
|
|
|
el.dragendfn(el);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('over', function (el, target, source) {
|
|
|
|
.on('over', function (el, target, source) {
|
|
|
|
if (!target.classList.contains('kanban-trash')) { return false; }
|
|
|
|
if (!target.classList.contains('kanban-trash')) { return false; }
|
|
|
|
target.classList.add('kanban-trash-active');
|
|
|
|
$('.kanban-trash').addClass('kanban-trash-active');
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('out', function (el, target) {
|
|
|
|
.on('out', function (el, target) {
|
|
|
|
if (!target.classList.contains('kanban-trash')) { return false; }
|
|
|
|
if (!target.classList.contains('kanban-trash')) { return false; }
|
|
|
|
target.classList.remove('kanban-trash-active');
|
|
|
|
$('.kanban-trash').removeClass('kanban-trash-active');
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('drop', function (el, target, source, sibling) {
|
|
|
|
.on('drop', function (el, target, source, sibling) {
|
|
|
|
el.classList.remove('is-moving');
|
|
|
|
el.classList.remove('is-moving');
|
|
|
@ -187,6 +204,7 @@
|
|
|
|
self.dragItemPos = self.findElementPosition(el);
|
|
|
|
self.dragItemPos = self.findElementPosition(el);
|
|
|
|
|
|
|
|
|
|
|
|
el.classList.add('is-moving');
|
|
|
|
el.classList.add('is-moving');
|
|
|
|
|
|
|
|
$(document).on('mousemove', onMouseMove);
|
|
|
|
|
|
|
|
|
|
|
|
self.options.dragEl(el, source);
|
|
|
|
self.options.dragEl(el, source);
|
|
|
|
if (el !== null && typeof (el.dragfn) === 'function') {
|
|
|
|
if (el !== null && typeof (el.dragfn) === 'function') {
|
|
|
@ -197,6 +215,7 @@
|
|
|
|
console.log("In dragend");
|
|
|
|
console.log("In dragend");
|
|
|
|
el.classList.remove('is-moving');
|
|
|
|
el.classList.remove('is-moving');
|
|
|
|
self.options.dragendEl(el);
|
|
|
|
self.options.dragendEl(el);
|
|
|
|
|
|
|
|
$(document).off('mousemove', onMouseMove);
|
|
|
|
if (el !== null && typeof (el.dragendfn) === 'function') {
|
|
|
|
if (el !== null && typeof (el.dragendfn) === 'function') {
|
|
|
|
el.dragendfn(el);
|
|
|
|
el.dragendfn(el);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -631,9 +650,11 @@
|
|
|
|
var trash = self.trashContainer = document.createElement('div');
|
|
|
|
var trash = self.trashContainer = document.createElement('div');
|
|
|
|
trash.setAttribute('id', 'kanban-trash');
|
|
|
|
trash.setAttribute('id', 'kanban-trash');
|
|
|
|
trash.setAttribute('class', 'kanban-trash');
|
|
|
|
trash.setAttribute('class', 'kanban-trash');
|
|
|
|
|
|
|
|
var trashBg = document.createElement('div');
|
|
|
|
var trashIcon = document.createElement('i');
|
|
|
|
var trashIcon = document.createElement('i');
|
|
|
|
trashIcon.setAttribute('class', 'fa fa-trash');
|
|
|
|
trashIcon.setAttribute('class', 'fa fa-trash');
|
|
|
|
trash.appendChild(trashIcon);
|
|
|
|
trash.appendChild(trashIcon);
|
|
|
|
|
|
|
|
trash.appendChild(trashBg);
|
|
|
|
self.boardContainer.push(trash);
|
|
|
|
self.boardContainer.push(trash);
|
|
|
|
|
|
|
|
|
|
|
|
self.container = boardContainer;
|
|
|
|
self.container = boardContainer;
|
|
|
|