nested-sort
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -252,2 +252,3 @@ 'use strict'; | ||
this.maybeInitDataDom(); | ||
this.addListAttributes(); | ||
this.initDragAndDrop(); | ||
@@ -273,8 +274,17 @@ } | ||
const list = this.getDataEngine().render(); | ||
list.classList.add(...this.listClassNames); | ||
document.getElementById(this.selector).appendChild(list); | ||
} | ||
getSortableList() { | ||
if (this.sortableList instanceof HTMLUListElement) return this.sortableList | ||
const list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
return this.sortableList | ||
} | ||
addListAttributes() { | ||
this.getSortableList().classList.add(...this.listClassNames); | ||
} | ||
initDragAndDrop() { | ||
document.addEventListener('dragover', this.dragListener.bind(this), false); | ||
@@ -284,6 +294,3 @@ | ||
const list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
this.sortableList.querySelectorAll('li').forEach(el => { | ||
this.getSortableList().querySelectorAll('li').forEach(el => { | ||
el.setAttribute('draggable', 'true'); | ||
@@ -356,3 +363,3 @@ | ||
if (typeof this.actions.onDrop === 'function') { | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.sortableList)); | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.getSortableList())); | ||
} | ||
@@ -508,3 +515,3 @@ } | ||
cleanupPlaceholderLists() { | ||
this.sortableList.querySelectorAll('ul').forEach(ul => { | ||
this.getSortableList().querySelectorAll('ul').forEach(ul => { | ||
if (!ul.querySelectorAll('li').length) { | ||
@@ -511,0 +518,0 @@ ul.remove(); |
@@ -250,2 +250,3 @@ class DataEngine { | ||
this.maybeInitDataDom(); | ||
this.addListAttributes(); | ||
this.initDragAndDrop(); | ||
@@ -271,8 +272,17 @@ } | ||
const list = this.getDataEngine().render(); | ||
list.classList.add(...this.listClassNames); | ||
document.getElementById(this.selector).appendChild(list); | ||
} | ||
getSortableList() { | ||
if (this.sortableList instanceof HTMLUListElement) return this.sortableList | ||
const list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
return this.sortableList | ||
} | ||
addListAttributes() { | ||
this.getSortableList().classList.add(...this.listClassNames); | ||
} | ||
initDragAndDrop() { | ||
document.addEventListener('dragover', this.dragListener.bind(this), false); | ||
@@ -282,6 +292,3 @@ | ||
const list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
this.sortableList.querySelectorAll('li').forEach(el => { | ||
this.getSortableList().querySelectorAll('li').forEach(el => { | ||
el.setAttribute('draggable', 'true'); | ||
@@ -354,3 +361,3 @@ | ||
if (typeof this.actions.onDrop === 'function') { | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.sortableList)); | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.getSortableList())); | ||
} | ||
@@ -506,3 +513,3 @@ } | ||
cleanupPlaceholderLists() { | ||
this.sortableList.querySelectorAll('ul').forEach(ul => { | ||
this.getSortableList().querySelectorAll('ul').forEach(ul => { | ||
if (!ul.querySelectorAll('li').length) { | ||
@@ -509,0 +516,0 @@ ul.remove(); |
@@ -364,2 +364,3 @@ (function (global, factory) { | ||
this.maybeInitDataDom(); | ||
this.addListAttributes(); | ||
this.initDragAndDrop(); | ||
@@ -390,12 +391,22 @@ } | ||
value: function maybeInitDataDom() { | ||
var _list$classList; | ||
if (!(Array.isArray(this.data) && this.data.length)) return; | ||
var list = this.getDataEngine().render(); | ||
(_list$classList = list.classList).add.apply(_list$classList, _toConsumableArray(this.listClassNames)); | ||
document.getElementById(this.selector).appendChild(list); | ||
} | ||
}, { | ||
key: "getSortableList", | ||
value: function getSortableList() { | ||
if (this.sortableList instanceof HTMLUListElement) return this.sortableList; | ||
var list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
return this.sortableList; | ||
} | ||
}, { | ||
key: "addListAttributes", | ||
value: function addListAttributes() { | ||
var _this$getSortableList; | ||
(_this$getSortableList = this.getSortableList().classList).add.apply(_this$getSortableList, _toConsumableArray(this.listClassNames)); | ||
} | ||
}, { | ||
key: "initDragAndDrop", | ||
@@ -407,5 +418,3 @@ value: function initDragAndDrop() { | ||
this.initPlaceholderList(); | ||
var list = document.getElementById(this.selector); | ||
this.sortableList = list.nodeName === 'UL' ? list : list.querySelector('ul'); | ||
this.sortableList.querySelectorAll('li').forEach(function (el) { | ||
this.getSortableList().querySelectorAll('li').forEach(function (el) { | ||
el.setAttribute('draggable', 'true'); | ||
@@ -485,3 +494,3 @@ el.addEventListener('dragstart', _this.onDragStart.bind(_this), false); | ||
if (typeof this.actions.onDrop === 'function') { | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.sortableList)); | ||
this.actions.onDrop(this.getDataEngine().convertDomToData(this.getSortableList())); | ||
} | ||
@@ -658,3 +667,3 @@ } | ||
this.sortableList.querySelectorAll('ul').forEach(function (ul) { | ||
this.getSortableList().querySelectorAll('ul').forEach(function (ul) { | ||
if (!ul.querySelectorAll('li').length) { | ||
@@ -661,0 +670,0 @@ ul.remove(); |
{ | ||
"name": "nested-sort", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": "Hesam Bahrami (Genzo)", | ||
@@ -5,0 +5,0 @@ "description": "A JavaScript library to create a nested list of elements", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53548
1502