1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- function KANBAN_DEF() {
- }
- KANBAN_DEF.prototype = (function () {
- function allowDrop(ev) {
- ev.preventDefault();
- }
- function drag(ev) {
- ev.dataTransfer.setData("data-id", ev.target.id);
- }
- function drop(ev) {
- var landId = ev.target.id;
- var land = document.getElementById(landId);
- var landAttribute = land.getAttribute("data-kanban", 0);
- var isChild = (landAttribute !== "task") ? true : false;
- var elementId = ev.dataTransfer.getData("data-id");
- var element = document.getElementById(elementId);
- if (isChild && element != undefined && element != "") {
- ev.target.appendChild(element);
- ev.preventDefault();
- }
- }
- return {
- onload: function () {
- var cols = document.querySelectorAll('#kanban .tasks');
- [].forEach.call(cols, function(col) {
- col.addEventListener('dragover', kanban.ondragover, false);
- col.addEventListener('drop', kanban.ondrop, false);
- });
- var tasks = document.querySelectorAll('#kanban .task');
- [].forEach.call(tasks, function(task) {
- //TODO: could remove the element ids from the markup and add them in here instead
- task.addEventListener('dragstart', kanban.ondragstart, false);
- });
- },
- ondrop: function (event) {
- drop(event);
- },
- ondragover: function (event) {
- allowDrop(event);
- },
- ondragstart: function (event) {
- drag(event);
- }
- };
- })();
- var kanban = new KANBAN_DEF();
- window.onload = function(){
- kanban.onload();
- }
|