New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jquery-sortable-lists

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-sortable-lists - npm Package Compare versions

Comparing version 1.0.15 to 1.1.0

3

CHANGELOG.md
<h1><a href="http://camohub.github.io/jquery-sortable-lists/index.html">jquery-sortable-lists</a></h1>
<h2 style="font-size:17px">Changelog</h2>
<h3>v1.1.0</h3>
<p>Callback onChange has been implemented.</p>
<h3>v1.0.14</h3>

@@ -5,0 +8,0 @@ <p>License have been changed to MIT.</p>

30

jquery-sortable-lists.js

@@ -18,3 +18,3 @@ /**

var jQBody = $( 'body' )
.css( 'position', 'relative' ),
.css( 'position', 'relative' ),

@@ -65,2 +65,3 @@ defaults = {

onDragStart: function( e, cEl ) { return true; }, // Params: e jQ. event obj., current el.
onChange: function( cEl ) { return true; }, // Params: current el.
complete: function( cEl ) { return true; } // Params: current el.

@@ -71,3 +72,3 @@ },

// base element from which is counted position of draged element
// base element from which is counted position of draged element
base = $( '<' + setting.listSelector + ' />' )

@@ -79,4 +80,4 @@ .prependTo( jQBody )

// placeholder != state.placeholderNode
// placeholder is document fragment and state.placeholderNode is document node
// placeholder != state.placeholderNode
// placeholder is document fragment and state.placeholderNode is document node
placeholder = $( '<li />' )

@@ -87,3 +88,3 @@ .attr( 'id', 'sortableListsPlaceholder' )

// hint is document fragment
// hint is document fragment
hint = $( '<li />' )

@@ -94,3 +95,3 @@ .attr( 'id', 'sortableListsHint' )

// Is document fragment used as wrapper if hint is inserted to the empty li
// Is document fragment used as wrapper if hint is inserted to the empty li
hintWrapper = $( '<' + setting.listSelector + ' />' )

@@ -102,3 +103,3 @@ .attr( 'id', 'sortableListsHintWrapper' )

// Is +/- ikon to open/close nested lists
// Is +/- ikon to open/close nested lists
opener = $( '<span />' )

@@ -118,3 +119,3 @@ .addClass( 'sortableListsOpener ' + setting.opener.openerClass )

// Container with all actual elements and parameters
// Container with all actual elements and parameters
state = {

@@ -218,8 +219,8 @@ isDragged: false,

el.css({
'width': el.width(),
'position': 'absolute',
'top': elXY.top - elMT,
'left': elXY.left - elML
})
.prependTo( base );
'width': el.width(),
'position': 'absolute',
'top': elXY.top - elMT,
'left': elXY.left - elML
})
.prependTo( base );

@@ -357,2 +358,3 @@ placeholderNode.css({

tidyEmptyLists();
setting.onChange( cEl.el );
setting.complete( cEl.el ); // Have to be here cause is necessary to remove placeholder before complete call.

@@ -359,0 +361,0 @@ state.isDragged = false;

/*
MIT
*/
(function(e){e.fn.sortableLists=function(g){function n(a){if(b.isDragged){var l=b.cEl,d=b.doc,v=b.win;a.pageX||A(a);d.scrollTop()>b.rootEl.offset.top-10&&50>a.clientY?b.upScroll?(a.pageY-=f.scroll,e("html, body").each(function(a){e(this).scrollTop(e(this).scrollTop()-f.scroll)}),p(a)):c(a):d.scrollTop()+v.height()<b.rootEl.offset.top+b.rootEl.el.outerHeight(!1)+10&&50>v.height()-a.clientY?b.downScroll?(a.pageY+=f.scroll,e("html, body").each(function(a){e(this).scrollTop(e(this).scrollTop()+f.scroll)}),
p(a)):k(a):t(b);b.oElOld=b.oEl;l.el[0].style.visibility="hidden";b.oEl=oEl=B(a.pageX,a.pageY);l.el[0].style.visibility="visible";C(a,b);D(a,b)}}function m(a){var l=b.cEl,d=e("#sortableListsHint",b.rootEl.el),c=h[0].style,r=null,g=!1,k=e("#sortableListsHintWrapper");"block"==c.display&&d.length&&b.isAllowed?(r=d,g=!0):(r=b.placeholderNode,g=!1);offset=r.offset();l.el.animate({left:offset.left-b.cEl.mL,top:offset.top-b.cEl.mT},250,function(){E(l);r.after(l.el[0]);r[0].style.display="none";c.display=
"none";d.remove();k.removeAttr("id").removeClass(f.hintWrapperClass);k.length&&k.prev("div").append(w.clone(!0));g?b.placeholderNode.slideUp(150,function(){b.placeholderNode.remove();x();f.complete(l.el);b.isDragged=!1}):(b.placeholderNode.remove(),x(),f.complete(l.el),b.isDragged=!1)});t(b);b.doc.unbind("mousemove",n).unbind("mouseup",m)}function c(a){b.upScroll||(b.upScroll=setInterval(function(){b.doc.trigger("mousemove")},50))}function k(a){b.downScroll||(b.downScroll=setInterval(function(){b.doc.trigger("mousemove")},
50))}function p(a){b.pY=a.pageY;b.pX=a.pageX;b.cY=a.clientY;b.cX=a.clientX}function A(a){a.pageY=b.pY;a.pageX=b.pX;a.clientY=b.cY;a.clientX=b.cX}function t(a){clearInterval(a.upScroll);clearInterval(a.downScroll);a.upScroll=a.downScroll=!1}function D(a,b){var d=b.cEl;d.el.css({top:a.pageY-d.xyOffsetDiff.Y-d.mT,left:a.pageX-d.xyOffsetDiff.X-d.mL})}function B(a,l){if(!document.elementFromPoint)return null;var d=b.isRelEFP;if(null===d){var f,c;0<(f=b.doc.scrollTop())&&(d=null==(c=document.elementFromPoint(0,
f+e(window).height()-1))||"HTML"==c.tagName.toUpperCase());0<(f=b.doc.scrollLeft())&&(d=null==(c=document.elementFromPoint(f+e(window).width()-1,0))||"HTML"==c.tagName.toUpperCase())}d&&(a-=b.doc.scrollLeft(),l-=b.doc.scrollTop());d=e(document.elementFromPoint(a,l));if(b.rootEl.el.find(d).length){if(d.is("#sortableListsPlaceholder")||d.is("#sortableListsHint"))return null;if(!d.is("li"))return d=d.closest("li"),d[0]?d:null;if(d.is("li"))return d}else return null}function C(a,l){var d=l.oEl;if(d&&
l.oElOld){var c=d.outerHeight(!1),g=a.pageY-d.offset().top;if(5>g)a:{e("#sortableListsHintWrapper",b.rootEl.el).length&&h.unwrap();if(a.pageX-d.offset().left<f.insertZone){if(d.prev("#sortableListsPlaceholder").length){h.css("display","none");break a}d.before(h)}else{c=d.children();g=d.children("ul").first();if(g.children().first().is("#sortableListsPlaceholder")){h.css("display","none");break a}g.length?g.prepend(h):(c.first().after(h),h.wrap(y));b.oEl&&u(d)}h.css("display","block");b.isAllowed=
f.isAllowed(b.cEl.el,e("#sortableListsHint"),d)}else if(c-5<g)a:{e("#sortableListsHintWrapper",b.rootEl.el).length&&h.unwrap();if(a.pageX-d.offset().left<f.insertZone){if(d.next("#sortableListsPlaceholder").length){h.css("display","none");break a}d.after(h)}else{c=d.children();g=d.children(f.listSelector).last();if(g.children().last().is("#sortableListsPlaceholder")){h.css("display","none");break a}g.length?c.last().append(h):(d.append(h),h.wrap(y));b.oEl&&u(d)}h.css("display","block");b.isAllowed=
f.isAllowed(b.cEl.el,e("#sortableListsHint"),d)}}}function u(a){a.removeClass("sortableListsClosed").addClass("sortableListsOpen");a.children("ul, ol").css("display","block");a.children("div").children(".sortableListsOpener").first().css("background-image","url("+f.opener.close+")")}function z(a){a.removeClass("sortableListsOpen").addClass("sortableListsClosed");a.children("ul, ol").css("display","none");a.children("div").children(".sortableListsOpener").first().css("background-image","url("+f.opener.open+
")")}function E(a){var b=a.el[0].style;a.el.removeClass(f.currElClass+" sortableListsCurrent");b.top="0";b.left="0";b.position="relative";b.width="auto"}function x(){e(f.listSelector,b.rootEl.el).each(function(a){e(this).children().length||(e(this).prev("div").children(".sortableListsOpener").first().remove(),e(this).remove())})}var q=e("body").css("position","relative"),F={currElClass:"",placeholderClass:"",placeholderCss:{position:"relative",padding:0},hintClass:"",hintCss:{display:"none",position:"relative",
(function(f){f.fn.sortableLists=function(g){function n(a){if(b.isDragged){var k=b.cEl,d=b.doc,v=b.win;a.pageX||A(a);d.scrollTop()>b.rootEl.offset.top-10&&50>a.clientY?b.upScroll?(a.pageY-=e.scroll,f("html, body").each(function(a){f(this).scrollTop(f(this).scrollTop()-e.scroll)}),p(a)):c(a):d.scrollTop()+v.height()<b.rootEl.offset.top+b.rootEl.el.outerHeight(!1)+10&&50>v.height()-a.clientY?b.downScroll?(a.pageY+=e.scroll,f("html, body").each(function(a){f(this).scrollTop(f(this).scrollTop()+e.scroll)}),
p(a)):l(a):t(b);b.oElOld=b.oEl;k.el[0].style.visibility="hidden";b.oEl=oEl=B(a.pageX,a.pageY);k.el[0].style.visibility="visible";C(a,b);D(a,b)}}function m(a){var k=b.cEl,d=f("#sortableListsHint",b.rootEl.el),c=h[0].style,r=null,g=!1,l=f("#sortableListsHintWrapper");"block"==c.display&&d.length&&b.isAllowed?(r=d,g=!0):(r=b.placeholderNode,g=!1);offset=r.offset();k.el.animate({left:offset.left-b.cEl.mL,top:offset.top-b.cEl.mT},250,function(){E(k);r.after(k.el[0]);r[0].style.display="none";c.display=
"none";d.remove();l.removeAttr("id").removeClass(e.hintWrapperClass);l.length&&l.prev("div").append(w.clone(!0));g?b.placeholderNode.slideUp(150,function(){b.placeholderNode.remove();x();e.onChange(k.el);e.complete(k.el);b.isDragged=!1}):(b.placeholderNode.remove(),x(),e.complete(k.el),b.isDragged=!1)});t(b);b.doc.unbind("mousemove",n).unbind("mouseup",m)}function c(a){b.upScroll||(b.upScroll=setInterval(function(){b.doc.trigger("mousemove")},50))}function l(a){b.downScroll||(b.downScroll=setInterval(function(){b.doc.trigger("mousemove")},
50))}function p(a){b.pY=a.pageY;b.pX=a.pageX;b.cY=a.clientY;b.cX=a.clientX}function A(a){a.pageY=b.pY;a.pageX=b.pX;a.clientY=b.cY;a.clientX=b.cX}function t(a){clearInterval(a.upScroll);clearInterval(a.downScroll);a.upScroll=a.downScroll=!1}function D(a,b){var d=b.cEl;d.el.css({top:a.pageY-d.xyOffsetDiff.Y-d.mT,left:a.pageX-d.xyOffsetDiff.X-d.mL})}function B(a,k){if(!document.elementFromPoint)return null;var d=b.isRelEFP;if(null===d){var e,c;0<(e=b.doc.scrollTop())&&(d=null==(c=document.elementFromPoint(0,
e+f(window).height()-1))||"HTML"==c.tagName.toUpperCase());0<(e=b.doc.scrollLeft())&&(d=null==(c=document.elementFromPoint(e+f(window).width()-1,0))||"HTML"==c.tagName.toUpperCase())}d&&(a-=b.doc.scrollLeft(),k-=b.doc.scrollTop());d=f(document.elementFromPoint(a,k));if(b.rootEl.el.find(d).length){if(d.is("#sortableListsPlaceholder")||d.is("#sortableListsHint"))return null;if(!d.is("li"))return d=d.closest("li"),d[0]?d:null;if(d.is("li"))return d}else return null}function C(a,k){var d=k.oEl;if(d&&
k.oElOld){var c=d.outerHeight(!1),g=a.pageY-d.offset().top;if(5>g)a:{f("#sortableListsHintWrapper",b.rootEl.el).length&&h.unwrap();if(a.pageX-d.offset().left<e.insertZone){if(d.prev("#sortableListsPlaceholder").length){h.css("display","none");break a}d.before(h)}else{c=d.children();g=d.children("ul").first();if(g.children().first().is("#sortableListsPlaceholder")){h.css("display","none");break a}g.length?g.prepend(h):(c.first().after(h),h.wrap(y));b.oEl&&u(d)}h.css("display","block");b.isAllowed=
e.isAllowed(b.cEl.el,f("#sortableListsHint"),d)}else if(c-5<g)a:{f("#sortableListsHintWrapper",b.rootEl.el).length&&h.unwrap();if(a.pageX-d.offset().left<e.insertZone){if(d.next("#sortableListsPlaceholder").length){h.css("display","none");break a}d.after(h)}else{c=d.children();g=d.children(e.listSelector).last();if(g.children().last().is("#sortableListsPlaceholder")){h.css("display","none");break a}g.length?c.last().append(h):(d.append(h),h.wrap(y));b.oEl&&u(d)}h.css("display","block");b.isAllowed=
e.isAllowed(b.cEl.el,f("#sortableListsHint"),d)}}}function u(a){a.removeClass("sortableListsClosed").addClass("sortableListsOpen");a.children("ul, ol").css("display","block");a.children("div").children(".sortableListsOpener").first().css("background-image","url("+e.opener.close+")")}function z(a){a.removeClass("sortableListsOpen").addClass("sortableListsClosed");a.children("ul, ol").css("display","none");a.children("div").children(".sortableListsOpener").first().css("background-image","url("+e.opener.open+
")")}function E(a){var b=a.el[0].style;a.el.removeClass(e.currElClass+" sortableListsCurrent");b.top="0";b.left="0";b.position="relative";b.width="auto"}function x(){f(e.listSelector,b.rootEl.el).each(function(a){f(this).children().length||(f(this).prev("div").children(".sortableListsOpener").first().remove(),f(this).remove())})}var q=f("body").css("position","relative"),F={currElClass:"",placeholderClass:"",placeholderCss:{position:"relative",padding:0},hintClass:"",hintCss:{display:"none",position:"relative",
padding:0},hintWrapperClass:"",hintWrapperCss:{},baseClass:"",baseCss:{position:"absolute",top:0-parseInt(q.css("margin-top")),left:0-parseInt(q.css("margin-left")),margin:0,padding:0,"z-index":2500},opener:{active:!1,open:"",close:"",openerCss:{"float":"left",display:"inline-block","background-position":"center center","background-repeat":"no-repeat"},openerClass:""},listSelector:"ul",listsClass:"",listsCss:{},insertZone:50,scroll:20,ignoreClass:"",isAllowed:function(a,b){return!0},onDragStart:function(a,
b){return!0},complete:function(a){return!0}},f=e.extend(!0,{},F,g),G=e("<"+f.listSelector+" />").prependTo(q).attr("id","sortableListsBase").css(f.baseCss).addClass(f.listsClass+" "+f.baseClass),H=e("<li />").attr("id","sortableListsPlaceholder").css(f.placeholderCss).addClass(f.placeholderClass),h=e("<li />").attr("id","sortableListsHint").css(f.hintCss).addClass(f.hintClass),y=e("<"+f.listSelector+" />").attr("id","sortableListsHintWrapper").addClass(f.listsClass+" "+f.hintWrapperClass).css(f.listsCss).css(f.hintWrapperCss),
w=e("<span />").addClass("sortableListsOpener "+f.opener.openerClass).css("background-image","url("+f.opener.close+")").css(f.opener.openerCss).on("mousedown",function(a){a=e(this).closest("li");a.hasClass("sortableListsClosed")?u(a):z(a);return!1}),b={isDragged:!1,isRelEFP:null,oEl:null,rootEl:null,cEl:null,upScroll:!1,downScroll:!1,pX:0,pY:0,cX:0,cY:0,isAllowed:!0,e:{pageX:0,pageY:0,clientX:0,clientY:0},doc:e(document),win:e(window)};if(f.opener.active){if(!f.opener.open)throw"Url for opener.open image is not defined";
if(!f.opener.close)throw"Url for opener.close image is not defined";e(this).find("li").each(function(){var a=e(this);a.children("ul,ol").length&&(w.clone(!0).prependTo(a.children("div").first()),a.hasClass("sortableListsOpen")||(a.addClass("sortableListsClosed"),z(a)))})}return this.on("mousedown",function(a){var c=e(a.target);if(!(!1!==b.isDragged||f.ignoreClass&&c.hasClass(f.ignoreClass))){a.preventDefault();var c=c.is("li")?c:c.closest("li"),d=e(this);if(c[0]){f.onDragStart(a,c);b.isDragged=!0;
var g=parseInt(c.css("margin-top")),k=parseInt(c.css("margin-bottom")),p=parseInt(c.css("margin-left")),u=parseInt(c.css("margin-right")),q=c.offset(),t=c.innerHeight();b.rootEl={el:d,offset:d.offset(),rootElClass:d.attr("class")};b.cEl={el:c,mT:g,mL:p,mB:k,mR:u,offset:q};b.cEl.xyOffsetDiff={X:a.pageX-b.cEl.offset.left,Y:a.pageY-b.cEl.offset.top};b.cEl.el.addClass("sortableListsCurrent "+f.currElClass);c.before(H);a=b.placeholderNode=e("#sortableListsPlaceholder");c.css({width:c.width(),position:"absolute",
top:q.top-g,left:q.left-p}).prependTo(G);a.css({display:"block",height:t});h.css("height",t);b.doc.on("mousemove",n).on("mouseup",m)}}})};e.fn.sortableListsToArray=function(g,n){g=g||[];var m=0;this.children("li").each(function(){var c=e(this),k={},p=c.attr("id");if(!p)throw console.log(c),"Previous item in console.log has no id. It is necessary to create the array.";k.id=p;k.parentId=n;k.value=c.data("value");k.order=m;g.push(k);c.children("ul,ol").sortableListsToArray(g,p);m++});return g};e.fn.sortableListsToHierarchy=
function(){var g=[],n=0;e(this).children("li").each(function(){var m=e(this),c={},k=m.attr("id");if(!k)throw console.log(m),"Previous item in console.log has no id. It is necessary to create the array.";c.id=k;c.value=m.data("value");c.order=n;g.push(c);c.children=m.children("ul,ol").sortableListsToHierarchy();n++});return g};e.fn.sortableListsToString=function(g,n){g=g||[];n=n||"no-parent";e(this).children("li").each(function(){var m=e(this),c=m.attr("id"),c=c?c.match(/(.+)[-=_](.+)/):null;if(!c)throw console.log(m),
"Previous item in console.log has no id or id is not in required format xx_yy, xx-yy or xx=yy. It is necessary to create valid string.";g.push(c[1]+"["+c[2]+"]="+n);e(this).children("ul,ol").sortableListsToString(g,c[2])});return g.join("&")}})(jQuery);
b){return!0},onChange:function(a){return!0},complete:function(a){return!0}},e=f.extend(!0,{},F,g),G=f("<"+e.listSelector+" />").prependTo(q).attr("id","sortableListsBase").css(e.baseCss).addClass(e.listsClass+" "+e.baseClass),H=f("<li />").attr("id","sortableListsPlaceholder").css(e.placeholderCss).addClass(e.placeholderClass),h=f("<li />").attr("id","sortableListsHint").css(e.hintCss).addClass(e.hintClass),y=f("<"+e.listSelector+" />").attr("id","sortableListsHintWrapper").addClass(e.listsClass+
" "+e.hintWrapperClass).css(e.listsCss).css(e.hintWrapperCss),w=f("<span />").addClass("sortableListsOpener "+e.opener.openerClass).css("background-image","url("+e.opener.close+")").css(e.opener.openerCss).on("mousedown",function(a){a=f(this).closest("li");a.hasClass("sortableListsClosed")?u(a):z(a);return!1}),b={isDragged:!1,isRelEFP:null,oEl:null,rootEl:null,cEl:null,upScroll:!1,downScroll:!1,pX:0,pY:0,cX:0,cY:0,isAllowed:!0,e:{pageX:0,pageY:0,clientX:0,clientY:0},doc:f(document),win:f(window)};
if(e.opener.active){if(!e.opener.open)throw"Url for opener.open image is not defined";if(!e.opener.close)throw"Url for opener.close image is not defined";f(this).find("li").each(function(){var a=f(this);a.children("ul,ol").length&&(w.clone(!0).prependTo(a.children("div").first()),a.hasClass("sortableListsOpen")||(a.addClass("sortableListsClosed"),z(a)))})}return this.on("mousedown",function(a){var c=f(a.target);if(!(!1!==b.isDragged||e.ignoreClass&&c.hasClass(e.ignoreClass))){a.preventDefault();var c=
c.is("li")?c:c.closest("li"),d=f(this);if(c[0]){e.onDragStart(a,c);b.isDragged=!0;var g=parseInt(c.css("margin-top")),l=parseInt(c.css("margin-bottom")),p=parseInt(c.css("margin-left")),u=parseInt(c.css("margin-right")),q=c.offset(),t=c.innerHeight();b.rootEl={el:d,offset:d.offset(),rootElClass:d.attr("class")};b.cEl={el:c,mT:g,mL:p,mB:l,mR:u,offset:q};b.cEl.xyOffsetDiff={X:a.pageX-b.cEl.offset.left,Y:a.pageY-b.cEl.offset.top};b.cEl.el.addClass("sortableListsCurrent "+e.currElClass);c.before(H);a=
b.placeholderNode=f("#sortableListsPlaceholder");c.css({width:c.width(),position:"absolute",top:q.top-g,left:q.left-p}).prependTo(G);a.css({display:"block",height:t});h.css("height",t);b.doc.on("mousemove",n).on("mouseup",m)}}})};f.fn.sortableListsToArray=function(g,n){g=g||[];var m=0;this.children("li").each(function(){var c=f(this),l={},p=c.attr("id");if(!p)throw console.log(c),"Previous item in console.log has no id. It is necessary to create the array.";l.id=p;l.parentId=n;l.value=c.data("value");
l.order=m;g.push(l);c.children("ul,ol").sortableListsToArray(g,p);m++});return g};f.fn.sortableListsToHierarchy=function(){var g=[],n=0;f(this).children("li").each(function(){var m=f(this),c={},l=m.attr("id");if(!l)throw console.log(m),"Previous item in console.log has no id. It is necessary to create the array.";c.id=l;c.value=m.data("value");c.order=n;g.push(c);c.children=m.children("ul,ol").sortableListsToHierarchy();n++});return g};f.fn.sortableListsToString=function(g,n){g=g||[];n=n||"no-parent";
f(this).children("li").each(function(){var m=f(this),c=m.attr("id"),c=c?c.match(/(.+)[-=_](.+)/):null;if(!c)throw console.log(m),"Previous item in console.log has no id or id is not in required format xx_yy, xx-yy or xx=yy. It is necessary to create valid string.";g.push(c[1]+"["+c[2]+"]="+n);f(this).children("ul,ol").sortableListsToString(g,c[2])});return g.join("&")}})(jQuery);
{
"name": "jquery-sortable-lists",
"version": "1.0.15",
"version": "1.1.0",
"description": "jQuery plugin to sorting lists also the tree structures",

@@ -5,0 +5,0 @@ "main": "jquery-sortable-lists.min.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc