| 1 | | /* |
|---|
| 2 | | * jQuery UI Sortable |
|---|
| 3 | | * |
|---|
| 4 | | * Copyright (c) 2008 Paul Bakaus |
|---|
| 5 | | * Dual licensed under the MIT (MIT-LICENSE.txt) |
|---|
| 6 | | * and GPL (GPL-LICENSE.txt) licenses. |
|---|
| 7 | | * |
|---|
| 8 | | * http://docs.jquery.com/UI/Sortables |
|---|
| 9 | | * |
|---|
| 10 | | * Depends: |
|---|
| 11 | | * ui.core.js |
|---|
| 12 | | * |
|---|
| 13 | | * Revision: $Id: ui.sortable.js 5433 2008-05-04 20:07:17Z joern.zaefferer $ |
|---|
| 14 | | */ |
|---|
| 15 | | ;(function($) { |
|---|
| | 1 | eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(b(B){b A(E,D){9 C=B.2Q.3T&&B.2Q.3S<3R;5(E.2P&&!C){c E.2P(D)}5(E.2O){c!!(E.2O(D)&16)}1O(D=D.1g){5(D==E){c W}}c w}B.3Q("k.o",B.2f(B.k.3P,{3O:b(){9 C=4.6;4.O={};4.g.24("k-o");4.25();4.13=4.f.z?(/7|23/).17(4.f[0].v.e("3N")):w;5(!(/(2N|1s|3M)/).17(4.g.e("Y"))){4.g.e("Y","2N")}4.a=4.g.a();4.3L()},3K:{},k:b(C){c{l:(C||4)["l"],q:(C||4)["q"]||B([]),Y:(C||4)["Y"],3J:(C||4)["1b"],6:4.6,g:4.g,v:(C||4)["j"],3I:C?C.g:X}},t:b(F,E,C,D){B.k.1o.14(4,F,[E,4.k(C)]);5(!D){4.g.3H(F=="1z"?F:"1z"+F,[E,4.k(C)],4.6[F])}},2e:b(E){9 C=(B.1L(4.6.f)?4.6.f.14(4.g):B(4.6.f,4.g)).1F(".k-o-l");9 D=[];E=E||{};C.1v(b(){9 F=(B(4).2L(E.3G||"2K")||"").3F(E.3E||(/(.+)[-=3D](.+)/));5(F){D.1w((E.2M||F[1])+"[]="+(E.2M?F[1]:F[2]))}});c D.3C("&")},2d:b(C){9 D=(B.1L(4.6.f)?4.6.f.14(4.g):B(4.6.f,4.g)).1F(".k-o-l");9 E=[];D.1v(b(){E.1w(B(4).2L(C||"2K"))});c E},2F:b(J){9 E=4.1b.7,D=E+4.r.m,I=4.1b.8,H=I+4.r.n;9 F=J.7,C=F+J.m,K=J.8,G=K+J.n;5(4.6.1r=="2J"||(4.6.1r=="1S"&&4.r[4.13?"m":"n"]>J[4.13?"m":"n"])){c(I+4.a.p.8>K&&I+4.a.p.8<G&&E+4.a.p.7>F&&E+4.a.p.7<C)}Z{c(F<E+(4.r.m/2)&&D-(4.r.m/2)<C&&K<I+(4.r.n/2)&&H-(4.r.n/2)<G)}},2s:b(J){9 E=4.1b.7,D=E+4.r.m,I=4.1b.8,H=I+4.r.n;9 F=J.7,C=F+J.m,K=J.8,G=K+J.n;5(4.6.1r=="2J"||(4.6.1r=="1S"&&4.r[4.13?"m":"n"]>J[4.13?"m":"n"])){5(!(I+4.a.p.8>K&&I+4.a.p.8<G&&E+4.a.p.7>F&&E+4.a.p.7<C)){c w}5(4.13){5(E+4.a.p.7>F&&E+4.a.p.7<F+J.m/2){c 2}5(E+4.a.p.7>F+J.m/2&&E+4.a.p.7<C){c 1}}Z{5(I+4.a.p.8>K&&I+4.a.p.8<K+J.n/2){c 2}5(I+4.a.p.8>K+J.n/2&&I+4.a.p.8<G){c 1}}}Z{5(!(F<E+(4.r.m/2)&&D-(4.r.m/2)<C&&K<I+(4.r.n/2)&&H-(4.r.n/2)<G)){c w}5(4.13){5(D>F&&E<F){c 2}5(E<C&&D>C){c 1}}Z{5(H>K&&I<K){c 1}5(I<G&&H>G){c 2}}}c w},25:b(){4.2I();4.1T()},2I:b(){4.f=[];4.d=[4];9 C=4.f;9 E=[B.1L(4.6.f)?4.6.f.14(4.g):B(4.6.f,4.g)];5(4.6.28){P(9 F=4.6.28.z-1;F>=0;F--){9 H=B(4.6.28[F]);P(9 D=H.z-1;D>=0;D--){9 G=B.1f(H[D],"o");5(G&&!G.6.27){E.1w(B.1L(G.6.f)?G.6.f.14(G.g):B(G.6.f,G.g));4.d.1w(G)}}}}P(9 F=E.z-1;F>=0;F--){E[F].1v(b(){B.1f(4,"o-v",W);C.1w({v:B(4),m:0,n:0,7:0,8:0})})}},1T:b(C){P(9 E=4.f.z-1;E>=0;E--){9 D=4.f[E].v;5(!C){4.f[E].m=(4.6.1l?B(4.6.1l,D):D).1u()}5(!C){4.f[E].n=(4.6.1l?B(4.6.1l,D):D).1t()}9 F=(4.6.1l?B(4.6.1l,D):D).a();4.f[E].7=F.7;4.f[E].8=F.8}P(9 E=4.d.z-1;E>=0;E--){9 F=4.d[E].g.a();4.d[E].O.7=F.7;4.d[E].O.8=F.8;4.d[E].O.m=4.d[E].g.1u();4.d[E].O.n=4.d[E].g.1t()}},3B:b(){4.g.3A("k-o k-o-27").2H("o").3z(".o");4.3y();P(9 C=4.f.z-1;C>=0;C--){4.f[C].v.2H("o-v")}},1Z:b(E){9 C=E||4,F=C.6;5(F.q.3x==3w){9 D=F.q;F.q={g:b(){c B("<2G></2G>").24(D)[0]},1i:b(G,H){H.e(G.a()).e({m:G.1u(),n:G.1t()})}}}C.q=B(F.q.g.14(C.g,C.j)).1q("S").e({Y:"1s"});F.q.1i.14(C.g,C.j,C.q)},2q:b(F){P(9 D=4.d.z-1;D>=0;D--){5(4.2F(4.d[D].O)){5(!4.d[D].O.1a){5(4.26!=4.d[D]){9 I=3v;9 H=X;9 E=4.1b[4.d[D].13?"7":"8"];P(9 C=4.f.z-1;C>=0;C--){5(!A(4.d[D].g[0],4.f[C].v[0])){1X}9 G=4.f[C][4.d[D].13?"7":"8"];5(1k.2E(G-E)<I){I=1k.2E(G-E);H=4.f[C]}}5(!H&&!4.6.2c){1X}5(4.q){4.q.1E()}5(4.d[D].6.q){4.d[D].1Z(4)}Z{4.q=X}H?4.1D(F,H):4.1D(F,X,4.d[D].g);4.t("1W",F);4.d[D].t("1W",F,4);4.26=4.d[D]}4.d[D].t("1a",F,4);4.d[D].O.1a=1}}Z{5(4.d[D].O.1a){4.d[D].t("2k",F,4);4.d[D].O.1a=0}}}},3u:b(F,E){5(4.6.27||4.6.2r=="3t"){c w}9 D=X,C=B(F.1K).2C().1v(b(){5(B.1f(4,"o-v")){D=B(4);c w}});5(B.1f(F.1K,"o-v")){D=B(F.1K)}5(!D){c w}5(4.6.2D&&!E){9 G=w;B(4.6.2D,D).3s("*").3r().1v(b(){5(4==F.1K){G=W}});5(!G){c w}}4.j=D;c W},3q:b(H,F,C){9 J=4.6;4.26=4;4.25();4.l=3p J.l=="b"?B(J.l.3o(4.g[0],[H,4.j])):4.j.2w();5(!4.l.2C("S").z){4.l.1q((J.1q!="s"?J.1q:4.j[0].1g))}4.l.e({Y:"1s",1H:"3n"}).24("k-o-l");4.T={7:(L(4.j.e("3m"),10)||0),8:(L(4.j.e("3l"),10)||0)};4.a=4.j.a();4.a={8:4.a.8-4.T.8,7:4.a.7-4.T.7};4.a.p={7:H.1c-4.a.7,8:H.1e-4.a.8};4.u=4.l.u();9 D=4.u.a();4.a.s={8:D.8+(L(4.u.e("21"),10)||0),7:D.7+(L(4.u.e("22"),10)||0)};4.1j=4.1Y(H);4.r={m:4.l.1u(),n:4.l.1t()};5(J.12){5(J.12.7!=1J){4.a.p.7=J.12.7}5(J.12.23!=1J){4.a.p.7=4.r.m-J.12.23}5(J.12.8!=1J){4.a.p.8=J.12.8}5(J.12.2B!=1J){4.a.p.8=4.r.n-J.12.2B}}4.1U=4.j.1G()[0];5(J.i){5(J.i=="s"){J.i=4.l[0].1g}5(J.i=="h"||J.i=="1d"){4.i=[0-4.a.s.7,0-4.a.s.8,B(J.i=="h"?h:1d).m()-4.a.s.7-4.r.m-4.T.7-(L(4.g.e("2A"),10)||0),(B(J.i=="h"?h:1d).n()||h.S.1g.2y)-4.a.s.8-4.r.n-4.T.8-(L(4.g.e("2x"),10)||0)]}5(!(/^(h|1d|s)$/).17(J.i)){9 G=B(J.i)[0];9 I=B(J.i).a();4.i=[I.7+(L(B(G).e("22"),10)||0)-4.a.s.7,I.8+(L(B(G).e("21"),10)||0)-4.a.s.8,I.7+1k.2z(G.3k,G.29)-(L(B(G).e("22"),10)||0)-4.a.s.7-4.r.m-4.T.7-(L(4.j.e("2A"),10)||0),I.8+1k.2z(G.2y,G.2a)-(L(B(G).e("21"),10)||0)-4.a.s.8-4.r.n-4.T.8-(L(4.j.e("2x"),10)||0)]}}5(J.q){4.1Z()}4.t("1n",H);4.r={m:4.l.1u(),n:4.l.1t()};5(4.6.q!="2w"){4.j.e("2i","3j")}5(!C){P(9 E=4.d.z-1;E>=0;E--){4.d[E].t("3i",H,4)}}5(B.k.15){B.k.15.3h=4}5(B.k.15&&!J.2n){B.k.15.3g(4,H)}4.2j=W;4.2u(H);c W},2t:b(D,E){5(!E){E=4.Y}9 C=D=="1s"?1:-1;c{8:(E.8+4.a.s.8*C-(4.u[0]==h.S?0:4.u[0].N)*C+4.T.8*C),7:(E.7+4.a.s.7*C-(4.u[0]==h.S?0:4.u[0].M)*C+4.T.7*C)}},1Y:b(F){9 G=4.6;9 C={8:(F.1e-4.a.p.8-4.a.s.8+(4.u[0]==h.S?0:4.u[0].N)),7:(F.1c-4.a.p.7-4.a.s.7+(4.u[0]==h.S?0:4.u[0].M))};5(!4.1j){c C}5(4.i){5(C.7<4.i[0]){C.7=4.i[0]}5(C.8<4.i[1]){C.8=4.i[1]}5(C.7>4.i[2]){C.7=4.i[2]}5(C.8>4.i[3]){C.8=4.i[3]}}5(G.11){9 E=4.1j.8+1k.2v((C.8-4.1j.8)/G.11[1])*G.11[1];C.8=4.i?(!(E<4.i[1]||E>4.i[3])?E:(!(E<4.i[1])?E-G.11[1]:E+G.11[1])):E;9 D=4.1j.7+1k.2v((C.7-4.1j.7)/G.11[0])*G.11[0];C.7=4.i?(!(D<4.i[0]||D>4.i[2])?D:(!(D<4.i[0])?D-G.11[0]:D+G.11[0])):D}c C},2u:b(D){4.Y=4.1Y(D);4.1b=4.2t("1s");P(9 C=4.f.z-1;C>=0;C--){9 E=4.2s(4.f[C]);5(!E){1X}5(4.f[C].v[0]!=4.j[0]&&4.j[E==1?"3f":"1G"]()[0]!=4.f[C].v[0]&&!A(4.j[0],4.f[C].v[0])&&(4.6.2r=="3e-3d"?!A(4.g[0],4.f[C].v[0]):W)){4.2h=E==1?"2g":"3c";4.1D(D,4.f[C]);4.t("1W",D);3b}}4.2q(D);4.t("1z",D);5(!4.6.1I||4.6.1I=="x"){4.l[0].2p.7=4.Y.7+"2o"}5(!4.6.1I||4.6.1I=="y"){4.l[0].2p.8=4.Y.8+"2o"}5(B.k.15){B.k.15.3a(4,D)}c w},39:b(E,D){5(B.k.15&&!4.6.2n){B.k.15.38(4,E)}5(4.6.1V){9 C=4;9 F=C.j.a();5(C.q){C.q.2m({18:"37"},(L(4.6.1V,10)||2l)-36)}B(4.l).2m({7:F.7-4.a.s.7-C.T.7+(4.u[0]==h.S?0:4.u[0].M),8:F.8-4.a.s.8-C.T.8+(4.u[0]==h.S?0:4.u[0].N)},L(4.6.1V,10)||2l,b(){C.t("1p",E,X,D);C.1H(E)})}Z{4.t("1p",E,X,D);4.1H(E,D)}c w},1H:b(E,D){5(4.1U!=4.j.1G().1F(".k-o-l")[0]){4.t("1i",E,X,D)}5(!A(4.g[0],4.j[0])){5(4.1U==4.j.1G().1F(".k-o-l")[0]){4.t("1i",E,X,D)}4.t("1E",E,X,D);P(9 C=4.d.z-1;C>=0;C--){5(A(4.d[C].g[0],4.j[0])){4.d[C].t("1i",E,4,D);4.d[C].t("35",E,4,D)}}}P(9 C=4.d.z-1;C>=0;C--){4.d[C].t("34",E,4,D);5(4.d[C].O.1a){4.d[C].t("2k",E,4);4.d[C].O.1a=0}}4.2j=w;5(4.33){c w}B(4.j).e("2i","");5(4.q){4.q.1E()}4.l.1E();c W},1D:b(E,D,C){C?C.32(4.j):D.v[4.2h=="2g"?"31":"30"](4.j);4.1T(W);5(4.6.q){4.6.q.1i.14(4.g,4.j,4.q)}}}));B.2f(B.k.o,{2Z:"2e 2d",2Y:{1r:"1S",2X:0,2W:0,2V:":2U,2T",f:"> *",19:2S,2c:W,1q:"s"}});B.k.1o.1C("o","1h",{1n:b(E,D){9 C=B("S");5(C.e("1h")){D.6.1R=C.e("1h")}C.e("1h",D.6.1h)},1p:b(D,C){5(C.6.1R){B("S").e("1h",C.6.1R)}}});B.k.1o.1C("o","19",{1n:b(E,D){9 C=D.l;5(C.e("19")){D.6.1Q=C.e("19")}C.e("19",D.6.19)},1p:b(D,C){5(C.6.1Q){B(C.l).e("19",C.6.1Q)}}});B.k.1o.1C("o","18",{1n:b(E,D){9 C=D.l;5(C.e("18")){D.6.1P=C.e("18")}C.e("18",D.6.18)},1p:b(D,C){5(C.6.1P){B(C.l).e("18",C.6.1P)}}});B.k.1o.1C("o","1m",{1n:b(E,D){9 F=D.6;9 C=B(4).1f("o");F.V=F.V||20;F.U=F.U||20;C.R=b(G){2b{5(/1B|1m/.17(G.e("1A"))||(/1B|1m/).17(G.e("1A-y"))){c G}G=G.s()}1O(G[0].1g);c B(h)}(C.j);C.Q=b(G){2b{5(/1B|1m/.17(G.e("1A"))||(/1B|1m/).17(G.e("1A-x"))){c G}G=G.s()}1O(G[0].1g);c B(h)}(C.j);5(C.R[0]!=h&&C.R[0].1y!="1x"){C.1N=C.R.a()}5(C.Q[0]!=h&&C.Q[0].1y!="1x"){C.1M=C.Q.a()}},1z:b(E,D){9 F=D.6;9 C=B(4).1f("o");5(C.R[0]!=h&&C.R[0].1y!="1x"){5((C.1N.8+C.R[0].2a)-E.1e<F.V){C.R[0].N=C.R[0].N+F.U}5(E.1e-C.1N.8<F.V){C.R[0].N=C.R[0].N-F.U}}Z{5(E.1e-B(h).N()<F.V){B(h).N(B(h).N()-F.U)}5(B(1d).n()-(E.1e-B(h).N())<F.V){B(h).N(B(h).N()+F.U)}}5(C.Q[0]!=h&&C.Q[0].1y!="1x"){5((C.1M.7+C.Q[0].29)-E.1c<F.V){C.Q[0].M=C.Q[0].M+F.U}5(E.1c-C.1M.7<F.V){C.Q[0].M=C.Q[0].M-F.U}}Z{5(E.1c-B(h).M()<F.V){B(h).M(B(h).M()-F.U)}5(B(1d).m()-(E.1c-B(h).M())<F.V){B(h).M(B(h).M()+F.U)}}}})})(2R)',62,242,'||||this|if|options|left|top|var|offset|function|return|containers|css|items|element|document|containment|currentItem|ui|helper|width|height|sortable|click|placeholder|helperProportions|parent|propagate|offsetParent|item|false|||length||||||||||||parseInt|scrollLeft|scrollTop|containerCache|for|overflowX|overflowY|body|margins|scrollSpeed|scrollSensitivity|true|null|position|else||grid|cursorAt|floating|call|ddmanager||test|opacity|zIndex|over|positionAbs|pageX|window|pageY|data|parentNode|cursor|update|originalPosition|Math|toleranceElement|scroll|start|plugin|stop|appendTo|tolerance|absolute|outerHeight|outerWidth|each|push|HTML|tagName|sort|overflow|auto|add|rearrange|remove|not|prev|clear|axis|undefined|target|isFunction|overflowXOffset|overflowYOffset|while|_opacity|_zIndex|_cursor|guess|refreshPositions|domPosition|revert|change|continue|generatePosition|createPlaceholder||borderTopWidth|borderLeftWidth|right|addClass|refresh|currentContainer|disabled|connectWith|offsetWidth|offsetHeight|do|dropOnEmpty|toArray|serialize|extend|down|direction|visibility|dragging|out|500|animate|dropBehaviour|px|style|contactContainers|type|intersectsWithEdge|convertPositionTo|mouseDrag|round|clone|marginBottom|scrollHeight|max|marginRight|bottom|parents|handle|abs|intersectsWith|div|removeData|refreshItems|pointer|id|attr|key|relative|compareDocumentPosition|contains|browser|jQuery|1000|button|input|cancel|delay|distance|defaults|getter|after|before|append|cancelHelperRemoval|deactivate|receive|50|hide|drop|mouseStop|drag|break|up|dynamic|semi|next|prepareOffsets|current|activate|hidden|scrollWidth|marginTop|marginLeft|both|apply|typeof|mouseStart|andSelf|find|static|mouseCapture|10000|String|constructor|mouseDestroy|unbind|removeClass|destroy|join|_|expression|match|attribute|triggerHandler|sender|absolutePosition|plugins|mouseInit|fixed|float|init|mouse|widget|522|version|safari'.split('|'),0,{})) |
|---|
| 17 | | function contains(a, b) { |
|---|
| 18 | | var safari2 = $.browser.safari && $.browser.version < 522; |
|---|
| 19 | | if (a.contains && !safari2) { |
|---|
| 20 | | return a.contains(b); |
|---|
| 21 | | } |
|---|
| 22 | | if (a.compareDocumentPosition) |
|---|
| 23 | | return !!(a.compareDocumentPosition(b) & 16); |
|---|
| 24 | | while (b = b.parentNode) |
|---|
| 25 | | if (b == a) return true; |
|---|
| 26 | | return false; |
|---|
| 27 | | }; |
|---|
| 28 | | |
|---|
| 29 | | $.widget("ui.sortable", $.extend($.ui.mouse, { |
|---|
| 30 | | init: function() { |
|---|
| 31 | | |
|---|
| 32 | | var o = this.options; |
|---|
| 33 | | this.containerCache = {}; |
|---|
| 34 | | this.element.addClass("ui-sortable"); |
|---|
| 35 | | |
|---|
| 36 | | //Get the items |
|---|
| 37 | | this.refresh(); |
|---|
| 38 | | |
|---|
| 39 | | //Let's determine if the items are floating |
|---|
| 40 | | this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; |
|---|
| 41 | | |
|---|
| 42 | | //Let's determine the parent's offset |
|---|
| 43 | | if(!(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative'); |
|---|
| 44 | | this.offset = this.element.offset(); |
|---|
| 45 | | |
|---|
| 46 | | //Initialize mouse events for interaction |
|---|
| 47 | | this.mouseInit(); |
|---|
| 48 | | |
|---|
| 49 | | }, |
|---|
| 50 | | plugins: {}, |
|---|
| 51 | | ui: function(inst) { |
|---|
| 52 | | return { |
|---|
| 53 | | helper: (inst || this)["helper"], |
|---|
| 54 | | placeholder: (inst || this)["placeholder"] || $([]), |
|---|
| 55 | | position: (inst || this)["position"], |
|---|
| 56 | | absolutePosition: (inst || this)["positionAbs"], |
|---|
| 57 | | options: this.options, |
|---|
| 58 | | element: this.element, |
|---|
| 59 | | item: (inst || this)["currentItem"], |
|---|
| 60 | | sender: inst ? inst.element : null |
|---|
| 61 | | }; |
|---|
| 62 | | }, |
|---|
| 63 | | propagate: function(n,e,inst, noPropagation) { |
|---|
| 64 | | $.ui.plugin.call(this, n, [e, this.ui(inst)]); |
|---|
| 65 | | if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]); |
|---|
| 66 | | }, |
|---|
| 67 | | serialize: function(o) { |
|---|
| 68 | | |
|---|
| 69 | | |
|---|
| 70 | | |
|---|
| 71 | | var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself |
|---|
| 72 | | var str = []; o = o || {}; |
|---|
| 73 | | |
|---|
| 74 | | items.each(function() { |
|---|
| 75 | | var res = ($(this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); |
|---|
| 76 | | if(res) str.push((o.key || res[1])+'[]='+(o.key ? res[1] : res[2])); |
|---|
| 77 | | }); |
|---|
| 78 | | |
|---|
| 79 | | return str.join('&'); |
|---|
| 80 | | |
|---|
| 81 | | }, |
|---|
| 82 | | toArray: function(attr) { |
|---|
| 83 | | var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself |
|---|
| 84 | | var ret = []; |
|---|
| 85 | | |
|---|
| 86 | | items.each(function() { ret.push($(this).attr(attr || 'id')); }); |
|---|
| 87 | | return ret; |
|---|
| 88 | | }, |
|---|
| 89 | | enable: function() { |
|---|
| 90 | | this.element.removeClass("ui-sortable-disabled"); |
|---|
| 91 | | this.options.disabled = false; |
|---|
| 92 | | }, |
|---|
| 93 | | disable: function() { |
|---|
| 94 | | this.element.addClass("ui-sortable-disabled"); |
|---|
| 95 | | this.options.disabled = true; |
|---|
| 96 | | }, |
|---|
| 97 | | /* Be careful with the following core functions */ |
|---|
| 98 | | intersectsWith: function(item) { |
|---|
| 99 | | |
|---|
| 100 | | var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, |
|---|
| 101 | | y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height; |
|---|
| 102 | | var l = item.left, r = l + item.width, |
|---|
| 103 | | t = item.top, b = t + item.height; |
|---|
| 104 | | |
|---|
| 105 | | if(this.options.tolerance == "pointer") { |
|---|
| 106 | | return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r); |
|---|
| 107 | | } else { |
|---|
| 108 | | |
|---|
| 109 | | return (l < x1 + (this.helperProportions.width / 2) // Right Half |
|---|
| 110 | | && x2 - (this.helperProportions.width / 2) < r // Left Half |
|---|
| 111 | | && t < y1 + (this.helperProportions.height / 2) // Bottom Half |
|---|
| 112 | | && y2 - (this.helperProportions.height / 2) < b ); // Top Half |
|---|
| 113 | | |
|---|
| 114 | | } |
|---|
| 115 | | |
|---|
| 116 | | }, |
|---|
| 117 | | intersectsWithEdge: function(item) { |
|---|
| 118 | | var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, |
|---|
| 119 | | y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height; |
|---|
| 120 | | var l = item.left, r = l + item.width, |
|---|
| 121 | | t = item.top, b = t + item.height; |
|---|
| 122 | | |
|---|
| 123 | | if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.currentItem[0]['offset'+(this.floating ? 'Width' : 'Height')] > item.item[0]['offset'+(this.floating ? 'Width' : 'Height')])) { |
|---|
| 124 | | |
|---|
| 125 | | if(!(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r)) return false; |
|---|
| 126 | | |
|---|
| 127 | | if(this.floating) { |
|---|
| 128 | | if(x1 + this.offset.click.left > l && x1 + this.offset.click.left < l + item.width/2) return 2; |
|---|
| 129 | | if(x1 + this.offset.click.left > l+item.width/2 && x1 + this.offset.click.left < r) return 1; |
|---|
| 130 | | } else { |
|---|
| 131 | | if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < t + item.height/2) return 2; |
|---|
| 132 | | if(y1 + this.offset.click.top > t+item.height/2 && y1 + this.offset.click.top < b) return 1; |
|---|
| 133 | | } |
|---|
| 134 | | |
|---|
| 135 | | } else { |
|---|
| 136 | | |
|---|
| 137 | | if (!(l < x1 + (this.helperProportions.width / 2) // Right Half |
|---|
| 138 | | && x2 - (this.helperProportions.width / 2) < r // Left Half |
|---|
| 139 | | && t < y1 + (this.helperProportions.height / 2) // Bottom Half |
|---|
| 140 | | && y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half |
|---|
| 141 | | |
|---|
| 142 | | if(this.floating) { |
|---|
| 143 | | if(x2 > l && x1 < l) return 2; //Crosses left edge |
|---|
| 144 | | if(x1 < r && x2 > r) return 1; //Crosses right edge |
|---|
| 145 | | } else { |
|---|
| 146 | | if(y2 > t && y1 < t) return 1; //Crosses top edge |
|---|
| 147 | | if(y1 < b && y2 > b) return 2; //Crosses bottom edge |
|---|
| 148 | | } |
|---|
| 149 | | |
|---|
| 150 | | } |
|---|
| 151 | | |
|---|
| 152 | | return false; |
|---|
| 153 | | |
|---|
| 154 | | }, |
|---|
| 155 | | refresh: function() { |
|---|
| 156 | | this.refreshItems(); |
|---|
| 157 | | this.refreshPositions(); |
|---|
| 158 | | }, |
|---|
| 159 | | refreshItems: function() { |
|---|
| 160 | | |
|---|
| 161 | | this.items = []; |
|---|
| 162 | | this.containers = [this]; |
|---|
| 163 | | var items = this.items; |
|---|
| 164 | | var queries = [$.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)]; |
|---|
| 165 | | |
|---|
| 166 | | if(this.options.connectWith) { |
|---|
| 167 | | for (var i = this.options.connectWith.length - 1; i >= 0; i--){ |
|---|
| 168 | | var cur = $(this.options.connectWith[i]); |
|---|
| 169 | | for (var j = cur.length - 1; j >= 0; j--){ |
|---|
| 170 | | var inst = $.data(cur[j], 'sortable'); |
|---|
| 171 | | if(inst && !inst.options.disabled) { |
|---|
| 172 | | queries.push($.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element)); |
|---|
| 173 | | this.containers.push(inst); |
|---|
| 174 | | } |
|---|
| 175 | | }; |
|---|
| 176 | | }; |
|---|
| 177 | | } |
|---|
| 178 | | |
|---|
| 179 | | for (var i = queries.length - 1; i >= 0; i--){ |
|---|
| 180 | | queries[i].each(function() { |
|---|
| 181 | | $.data(this, 'sortable-item', true); // Data for target checking (mouse manager) |
|---|
| 182 | | items.push({ |
|---|
| 183 | | item: $(this), |
|---|
| 184 | | width: 0, height: 0, |
|---|
| 185 | | left: 0, top: 0 |
|---|
| 186 | | }); |
|---|
| 187 | | }); |
|---|
| 188 | | }; |
|---|
| 189 | | |
|---|
| 190 | | }, |
|---|
| 191 | | refreshPositions: function(fast) { |
|---|
| 192 | | for (var i = this.items.length - 1; i >= 0; i--){ |
|---|
| 193 | | var t = this.items[i].item; |
|---|
| 194 | | if(!fast) this.items[i].width = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerWidth(); |
|---|
| 195 | | if(!fast) this.items[i].height = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerHeight(); |
|---|
| 196 | | var p = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).offset(); |
|---|
| 197 | | this.items[i].left = p.left; |
|---|
| 198 | | this.items[i].top = p.top; |
|---|
| 199 | | }; |
|---|
| 200 | | for (var i = this.containers.length - 1; i >= 0; i--){ |
|---|
| 201 | | var p =this.containers[i].element.offset(); |
|---|
| 202 | | this.containers[i].containerCache.left = p.left; |
|---|
| 203 | | this.containers[i].containerCache.top = p.top; |
|---|
| 204 | | this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
|---|
| 205 | | this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
|---|
| 206 | | }; |
|---|
| 207 | | }, |
|---|
| 208 | | destroy: function() { |
|---|
| 209 | | this.element |
|---|
| 210 | | .removeClass("ui-sortable ui-sortable-disabled") |
|---|
| 211 | | .removeData("sortable") |
|---|
| 212 | | .unbind(".sortable"); |
|---|
| 213 | | this.mouseDestroy(); |
|---|
| 214 | | |
|---|
| 215 | | for ( var i = this.items.length - 1; i >= 0; i-- ) |
|---|
| 216 | | this.items[i].item.removeData("sortable-item"); |
|---|
| 217 | | }, |
|---|
| 218 | | createPlaceholder: function(that) { |
|---|
| 219 | | |
|---|
| 220 | | var self = that || this, o = self.options; |
|---|
| 221 | | |
|---|
| 222 | | if(o.placeholder.constructor == String) { |
|---|
| 223 | | var className = o.placeholder; |
|---|
| 224 | | o.placeholder = { |
|---|
| 225 | | element: function() { |
|---|
| 226 | | return $('<div></div>').addClass(className)[0]; |
|---|
| 227 | | }, |
|---|
| 228 | | update: function(i, p) { |
|---|
| 229 | | p.css(i.offset()).css({ width: i.outerWidth(), height: i.outerHeight() }); |
|---|
| 230 | | } |
|---|
| 231 | | }; |
|---|
| 232 | | } |
|---|
| 233 | | |
|---|
| 234 | | self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)).appendTo('body').css({ position: 'absolute' }); |
|---|
| 235 | | o.placeholder.update.call(self.element, self.currentItem, self.placeholder); |
|---|
| 236 | | }, |
|---|
| 237 | | contactContainers: function(e) { |
|---|
| 238 | | for (var i = this.containers.length - 1; i >= 0; i--){ |
|---|
| 239 | | |
|---|
| 240 | | if(this.intersectsWith(this.containers[i].containerCache)) { |
|---|
| 241 | | if(!this.containers[i].containerCache.over) { |
|---|
| 242 | | |
|---|
| 243 | | |
|---|
| 244 | | if(this.currentContainer != this.containers[i]) { |
|---|
| 245 | | |
|---|
| 246 | | //When entering a new container, we will find the item with the least distance and append our item near it |
|---|
| 247 | | var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top']; |
|---|
| 248 | | for (var j = this.items.length - 1; j >= 0; j--) { |
|---|
| 249 | | if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue; |
|---|
| 250 | | var cur = this.items[j][this.containers[i].floating ? 'left' : 'top']; |
|---|
| 251 | | if(Math.abs(cur - base) < dist) { |
|---|
| 252 | | dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; |
|---|
| 253 | | } |
|---|
| 254 | | } |
|---|
| 255 | | |
|---|
| 256 | | if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled |
|---|
| 257 | | continue; |
|---|
| 258 | | |
|---|
| 259 | | //We also need to exchange the placeholder |
|---|
| 260 | | if(this.placeholder) this.placeholder.remove(); |
|---|
| 261 | | if(this.containers[i].options.placeholder) { |
|---|
| 262 | | this.containers[i].createPlaceholder(this); |
|---|
| 263 | | } else { |
|---|
| 264 | | this.placeholder = null;; |
|---|
| 265 | | } |
|---|
| 266 | | |
|---|
| 267 | | |
|---|
| 268 | | itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element); |
|---|
| 269 | | this.propagate("change", e); //Call plugins and callbacks |
|---|
| 270 | | this.containers[i].propagate("change", e, this); //Call plugins and callbacks |
|---|
| 271 | | this.currentContainer = this.containers[i]; |
|---|
| 272 | | |
|---|
| 273 | | } |
|---|
| 274 | | |
|---|
| 275 | | this.containers[i].propagate("over", e, this); |
|---|
| 276 | | this.containers[i].containerCache.over = 1; |
|---|
| 277 | | } |
|---|
| 278 | | } else { |
|---|
| 279 | | if(this.containers[i].containerCache.over) { |
|---|
| 280 | | this.containers[i].propagate("out", e, this); |
|---|
| 281 | | this.containers[i].containerCache.over = 0; |
|---|
| 282 | | } |
|---|
| 283 | | } |
|---|
| 284 | | |
|---|
| 285 | | }; |
|---|
| 286 | | }, |
|---|
| 287 | | mouseStart: function(e, overrideHandle, noActivation) { |
|---|
| 288 | | |
|---|
| 289 | | var o = this.options; |
|---|
| 290 | | this.currentContainer = this; |
|---|
| 291 | | |
|---|
| 292 | | if(this.options.disabled || this.options.type == 'static') return false; |
|---|
| 293 | | |
|---|
| 294 | | //Find out if the clicked node (or one of its parents) is a actual item in this.items |
|---|
| 295 | | var currentItem = null, nodes = $(e.target).parents().each(function() { |
|---|
| 296 | | if($.data(this, 'sortable-item')) { |
|---|
| 297 | | currentItem = $(this); |
|---|
| 298 | | return false; |
|---|
| 299 | | } |
|---|
| 300 | | }); |
|---|
| 301 | | if($.data(e.target, 'sortable-item')) currentItem = $(e.target); |
|---|
| 302 | | |
|---|
| 303 | | if(!currentItem) return false; |
|---|
| 304 | | if(this.options.handle && !overrideHandle) { |
|---|
| 305 | | var validHandle = false; |
|---|
| 306 | | $(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; }); |
|---|
| 307 | | if(!validHandle) return false; |
|---|
| 308 | | } |
|---|
| 309 | | |
|---|
| 310 | | this.currentItem = currentItem; |
|---|
| 311 | | |
|---|
| 312 | | this.refresh(); |
|---|
| 313 | | |
|---|
| 314 | | //Create and append the visible helper |
|---|
| 315 | | this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : this.currentItem.clone(); |
|---|
| 316 | | if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)); //Add the helper to the DOM if that didn't happen already |
|---|
| 317 | | this.helper.css({ position: 'absolute', clear: 'both' }).addClass('ui-sortable-helper'); //Position it absolutely and add a helper class |
|---|
| 318 | | |
|---|
| 319 | | /* |
|---|
| 320 | | * - Position generation - |
|---|
| 321 | | * This block generates everything position related - it's the core of draggables. |
|---|
| 322 | | */ |
|---|
| 323 | | |
|---|
| 324 | | this.margins = { //Cache the margins |
|---|
| 325 | | left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
|---|
| 326 | | top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
|---|
| 327 | | }; |
|---|
| 328 | | |
|---|
| 329 | | this.offset = this.currentItem.offset(); //The element's absolute position on the page |
|---|
| 330 | | this.offset = { //Substract the margins from the element's absolute offset |
|---|
| 331 | | top: this.offset.top - this.margins.top, |
|---|
| 332 | | left: this.offset.left - this.margins.left |
|---|
| 333 | | }; |
|---|
| 334 | | |
|---|
| 335 | | this.offset.click = { //Where the click happened, relative to the element |
|---|
| 336 | | left: e.pageX - this.offset.left, |
|---|
| 337 | | top: e.pageY - this.offset.top |
|---|
| 338 | | }; |
|---|
| 339 | | |
|---|
| 340 | | this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position |
|---|
| 341 | | |
|---|
| 342 | | this.offset.parent = { //Store its position plus border |
|---|
| 343 | | top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|---|
| 344 | | left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|---|
| 345 | | }; |
|---|
| 346 | | |
|---|
| 347 | | this.originalPosition = this.generatePosition(e); //Generate the original position |
|---|
| 348 | | this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size |
|---|
| 349 | | |
|---|
| 350 | | if(o.cursorAt) { |
|---|
| 351 | | if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left; |
|---|
| 352 | | if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right; |
|---|
| 353 | | if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top; |
|---|
| 354 | | if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom; |
|---|
| 355 | | } |
|---|
| 356 | | |
|---|
| 357 | | this.domPosition = this.currentItem.prev()[0]; //Cache the former DOM position |
|---|
| 358 | | |
|---|
| 359 | | /* |
|---|
| 360 | | * - Position constraining - |
|---|
| 361 | | * Here we prepare position constraining like grid and containment. |
|---|
| 362 | | */ |
|---|
| 363 | | |
|---|
| 364 | | if(o.containment) { |
|---|
| 365 | | if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|---|
| 366 | | if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)]; |
|---|
| 367 | | if(!(/^(document|window|parent)$/).test(o.containment)) { |
|---|
| 368 | | var ce = $(o.containment)[0]; |
|---|
| 369 | | var co = $(o.containment).offset(); |
|---|
| 370 | | |
|---|
| 371 | | this.containment = [ |
|---|
| 372 | | co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left, |
|---|
| 373 | | co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top, |
|---|
| 374 | | co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), |
|---|
| 375 | | co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) |
|---|
| 376 | | ]; |
|---|
| 377 | | } |
|---|
| 378 | | } |
|---|
| 379 | | |
|---|
| 380 | | //If o.placeholder is used, create a new element at the given position with the class |
|---|
| 381 | | if(o.placeholder) this.createPlaceholder(); |
|---|
| 382 | | |
|---|
| 383 | | //Call plugins and callbacks |
|---|
| 384 | | this.propagate("start", e); |
|---|
| 385 | | this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size |
|---|
| 386 | | |
|---|
| 387 | | if(this.options.placeholder != 'clone') this.currentItem.css('visibility', 'hidden'); //Set the original element visibility to hidden to still fill out the white space |
|---|
| 388 | | |
|---|
| 389 | | if(!noActivation) { |
|---|
| 390 | | for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } //Post 'activate' events to possible containers |
|---|
| 391 | | } |
|---|
| 392 | | |
|---|
| 393 | | //Prepare possible droppables |
|---|
| 394 | | if($.ui.ddmanager) $.ui.ddmanager.current = this; |
|---|
| 395 | | if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); |
|---|
| 396 | | |
|---|
| 397 | | this.dragging = true; |
|---|
| 398 | | |
|---|
| 399 | | this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|---|
| 400 | | return true; |
|---|
| 401 | | |
|---|
| 402 | | |
|---|
| 403 | | }, |
|---|
| 404 | | convertPositionTo: function(d, pos) { |
|---|
| 405 | | if(!pos) pos = this.position; |
|---|
| 406 | | var mod = d == "absolute" ? 1 : -1; |
|---|
| 407 | | return { |
|---|
| 408 | | top: ( |
|---|
| 409 | | pos.top // the calculated relative position |
|---|
| 410 | | + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
|---|
| 411 | | - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position |
|---|
| 412 | | + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods) |
|---|
| 413 | | ), |
|---|
| 414 | | left: ( |
|---|
| 415 | | pos.left // the calculated relative position |
|---|
| 416 | | + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
|---|
| 417 | | - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position |
|---|
| 418 | | + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods) |
|---|
| 419 | | ) |
|---|
| 420 | | }; |
|---|
| 421 | | }, |
|---|
| 422 | | generatePosition: function(e) { |
|---|
| 423 | | |
|---|
| 424 | | var o = this.options; |
|---|
| 425 | | var position = { |
|---|
| 426 | | top: ( |
|---|
| 427 | | e.pageY // The absolute mouse position |
|---|
| 428 | | - this.offset.click.top // Click offset (relative to the element) |
|---|
| 429 | | - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
|---|
| 430 | | + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed |
|---|
| 431 | | ), |
|---|
| 432 | | left: ( |
|---|
| 433 | | e.pageX // The absolute mouse position |
|---|
| 434 | | - this.offset.click.left // Click offset (relative to the element) |
|---|
| 435 | | - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
|---|
| 436 | | + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed |
|---|
| 437 | | ) |
|---|
| 438 | | }; |
|---|
| 439 | | |
|---|
| 440 | | if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options |
|---|
| 441 | | |
|---|
| 442 | | /* |
|---|
| 443 | | * - Position constraining - |
|---|
| 444 | | * Constrain the position to a mix of grid, containment. |
|---|
| 445 | | */ |
|---|
| 446 | | if(this.containment) { |
|---|
| 447 | | if(position.left < this.containment[0]) position.left = this.containment[0]; |
|---|
| 448 | | if(position.top < this.containment[1]) position.top = this.containment[1]; |
|---|
| 449 | | if(position.left > this.containment[2]) position.left = this.containment[2]; |
|---|
| 450 | | if(position.top > this.containment[3]) position.top = this.containment[3]; |
|---|
| 451 | | } |
|---|
| 452 | | |
|---|
| 453 | | if(o.grid) { |
|---|
| 454 | | var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1]; |
|---|
| 455 | | position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|---|
| 456 | | |
|---|
| 457 | | var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0]; |
|---|
| 458 | | position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|---|
| 459 | | } |
|---|
| 460 | | |
|---|
| 461 | | return position; |
|---|
| 462 | | }, |
|---|
| 463 | | mouseDrag: function(e) { |
|---|
| 464 | | |
|---|
| 465 | | |
|---|
| 466 | | //Compute the helpers position |
|---|
| 467 | | this.position = this.generatePosition(e); |
|---|
| 468 | | this.positionAbs = this.convertPositionTo("absolute"); |
|---|
| 469 | | |
|---|
| 470 | | //Rearrange |
|---|
| 471 | | for (var i = this.items.length - 1; i >= 0; i--) { |
|---|
| 472 | | var intersection = this.intersectsWithEdge(this.items[i]); |
|---|
| 473 | | if(!intersection) continue; |
|---|
| 474 | | |
|---|
| 475 | | if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself |
|---|
| 476 | | && this.currentItem[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before |
|---|
| 477 | | && !contains(this.currentItem[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked |
|---|
| 478 | | && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true) |
|---|
| 479 | | ) { |
|---|
| 480 | | |
|---|
| 481 | | this.direction = intersection == 1 ? "down" : "up"; |
|---|
| 482 | | this.rearrange(e, this.items[i]); |
|---|
| 483 | | this.propagate("change", e); //Call plugins and callbacks |
|---|
| 484 | | break; |
|---|
| 485 | | } |
|---|
| 486 | | } |
|---|
| 487 | | |
|---|
| 488 | | //Post events to containers |
|---|
| 489 | | this.contactContainers(e); |
|---|
| 490 | | |
|---|
| 491 | | //Call plugins and callbacks |
|---|
| 492 | | this.propagate("sort", e); |
|---|
| 493 | | |
|---|
| 494 | | if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px'; |
|---|
| 495 | | |
|---|