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.1.1 to 1.2.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.2.0</h3>
<p>Added opener.as option to opener. Now is possible to use opener.as html or class option.</p>
<h3>v1.1.1</h3>

@@ -5,0 +8,0 @@ <p>Fixed bug on target parameter of isAllowed callback.</p>

121

jquery-sortable-lists.js

@@ -7,3 +7,4 @@ /**

(function ( $ ) {
( function ( $ )
{

@@ -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,6 +103,5 @@ .attr( 'id', 'sortableListsHintWrapper' )

// Is +/- ikon to open/close nested lists
// Is +/- ikon to open/close nested lists
opener = $( '<span />' )
.addClass( 'sortableListsOpener ' + setting.opener.openerClass )
.css( 'background-image', 'url(' + setting.opener.close + ')' )
.css( setting.opener.openerCss )

@@ -116,39 +116,42 @@ .on( 'mousedown', function( e )

return false; // Prevent default
}),
});
if ( setting.opener.as == 'class' ) { opener.addClass( setting.opener.close ); }
else if ( setting.opener.as == 'html' ) { opener.html( setting.opener.close ); }
else { opener.css( 'background-image', 'url(' + setting.opener.close + ')' ); console.error( 'jQuerySortableLists opener as background image is deprecated. In version 2.0.0 it will be removed. Use html instead please.' ); }
// Container with all actual elements and parameters
state = {
isDragged: false,
isRelEFP: null, // How browser counts elementFromPoint() position (relative to window/document)
oEl: null, // overElement is element which returns elementFromPoint() method
rootEl: null,
cEl: null, // currentElement is currently dragged element
upScroll: false,
downScroll: false,
pX: 0,
pY: 0,
cX: 0,
cY: 0,
isAllowed: true, // The function is defined in setting
e: { pageX: 0, pageY:0, clientX:0, clientY:0 }, // TODO: unused??
doc: $( document ),
win: $( window )
};
var state = {
isDragged: false,
isRelEFP: null, // How browser counts elementFromPoint() position (relative to window/document)
oEl: null, // overElement is element which returns elementFromPoint() method
rootEl: null,
cEl: null, // currentElement is currently dragged element
upScroll: false,
downScroll: false,
pX: 0,
pY: 0,
cX: 0,
cY: 0,
isAllowed: true, // The function is defined in setting
e: { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }, // TODO: unused??
doc: $( document ),
win: $( window )
};
if ( setting.opener.active )
{
if ( ! setting.opener.open ) throw 'Url for opener.open image is not defined';
if ( ! setting.opener.close ) throw 'Url for opener.close image is not defined';
if ( ! setting.opener.open ) throw 'Opener.open value is not defined. It should be valid url, html or css class.';
if ( ! setting.opener.close ) throw 'Opener.close value is not defined. It should be valid url, html or css class.';
$( this ).find( 'li' ).each( function() {
$( this ).find( 'li' ).each( function()
{
var li = $( this );
if ( li.children( 'ul,ol' ).length )
if ( li.children( setting.listSelector ).length )
{
opener.clone( true ).prependTo( li.children( 'div' ).first() );
if ( ! li.hasClass( 'sortableListsOpen' ) )
{
li.addClass( 'sortableListsClosed' );
close( li );
}
if ( ! li.hasClass( 'sortableListsOpen' ) ) { close( li ); }
else { open( li ); }
}

@@ -218,8 +221,7 @@ });

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 );

@@ -688,4 +690,18 @@ placeholderNode.css({

li.removeClass( 'sortableListsClosed' ).addClass( 'sortableListsOpen' );
li.children( 'ul, ol' ).css( 'display', 'block' );
li.children( 'div' ).children( '.sortableListsOpener' ).first().css( 'background-image', 'url(' + setting.opener.close + ')' );
li.children( setting.listSelector ).css( 'display', 'block' );
var opener = li.children( 'div' ).children( '.sortableListsOpener' ).first();
if ( setting.opener.as == 'html' )
{
opener.html( setting.opener.close );
}
else if ( setting.opener.as == 'class' )
{
opener.addClass( setting.opener.close ).removeClass( setting.opener.open );
}
else
{
opener.css( 'background-image', 'url(' + setting.opener.close + ')' );
}
}

@@ -700,4 +716,19 @@

li.removeClass( 'sortableListsOpen' ).addClass( 'sortableListsClosed' );
li.children( 'ul, ol' ).css( 'display', 'none' );
li.children( 'div' ).children( '.sortableListsOpener' ).first().css( 'background-image', 'url(' + setting.opener.open + ')' );
li.children( setting.listSelector ).css( 'display', 'none' );
var opener = li.children( 'div' ).children( '.sortableListsOpener' ).first();
if ( setting.opener.as == 'html' )
{
opener.html( setting.opener.open );
}
else if ( setting.opener.as == 'class' )
{
opener.addClass( setting.opener.open ).removeClass( setting.opener.close );
}
else
{
opener.css( 'background-image', 'url(' + setting.opener.open + ')' );
}
}

@@ -704,0 +735,0 @@

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