mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
1 line
No EOL
2.9 KiB
JavaScript
1 line
No EOL
2.9 KiB
JavaScript
jQuery(function(a){function b(a,b){for(var c=0,d=0;a&&a!=b;)c+=a.offsetTop,d+=a.offsetLeft,a=a.offsetParent;return{top:c,left:d}}function c(a,b){return Math.abs(a.top-b)<=3?(e.css({top:a.top-3,height:"5px"}),"before"):Math.abs(a.bottom-b)<=3?(e.css({top:a.bottom-3,height:"5px"}),"after"):(e.css({top:a.top+3,height:"27px"}),"prepend")}var d=!1,e=a('<li class="placeholder">');a("form.siteMap").delegate("li:not(.placeholder)",{"mousedown.st":function(f){var g,h,i,j,k,l,m,n,o,p;if(!a(f.target).is("a,input,label,textarea")&&1==f.which){for(d=!0,g=a(this),k=g.height(),j=g.width(),h=g.parentsUntil(".siteMap").filter("ul"),i=h.eq(-1),i.css("position","relative"),m={x:f.pageX,y:f.pageY},l=b(this,i.get(0)),$clone=g.clone(!0).attr("target",!0),o=h.length-1;o;o--)$clone=$clone.wrap("<li><ul /></li>").parent().parent();return n=[],i.find("li").each(function(){if(g[0]===this||g.has(this).length)return!0;var a=b(this,i.get(0));n.push({top:a.top,bottom:a.top+32,item:this})}),$clone.find(".side,input").remove().end().addClass("draggable").css({position:"absolute",opacity:.6,width:j,height:k,left:l.left,top:l.top,zIndex:100}).appendTo(i.eq(0)),e.css({position:"absolute",opacity:.6,width:j,height:"5px",left:l.left,top:l.top,zIndex:99}).appendTo(i.eq(0)),g.css("opacity",.6),a(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,d,e,f,g,h;for(p=null,b={x:m.x-a.pageX,y:m.y-a.pageY},d=l.top-b.y,e=0,f=n.length;f>e;e++)if(h=d,g=n[e],0==e&&h<g.top&&(h=g.top),e==f-1&&h>g.bottom&&(h=g.bottom),g.top<=h&&g.bottom>=h){p={element:g.item,state:c(g,h)};break}$clone.css({top:d})}).bind("mouseup.st",function(){var b,c;d=!1,a(document).unbind("mousemove.st mouseup.st"),g.css("opacity",""),$clone.remove(),e.remove(),c=a("<li />").height(g.height()),p&&(b=a(p.element),g.before(c),"prepend"==p.state?(b.find(">ul").length||b.find(">.side").after("<ul>"),b.find(">ul").prepend(g.hide())):b[p.state](g.hide()),g.slideDown(100,function(){g.removeClass("active")}),c.slideUp(100,function(){var a=c.parent();c.remove(),a.children("li").length||a.remove()}),g.trigger("dropped.st"))}),!1}},"mouseover.st":function(){return d||a(this).addClass("active"),!1},"mouseout.st":function(){return d||a(this).removeClass("active"),!1}}).find("li").prepend('<button type="button" class="moveTo">Move to</button>').append('<span class="vr"></span><span class="hr"></span>').find("input:text").focus(function(){var b=a(this),c=b.prev("label"),d=b.parent();b.width(d.width()-(parseInt(d.css("text-indent"))||0)-b.next(".side").width()-60).css("opacity",""),c.hide()}).blur(function(){var b=a(this),c=b.prev("label"),d=b.val();b.width(0).css("opacity",0),c.removeClass("no-text").empty().text(d).show(),d||c.addClass("no-text").text("---")}).each(function(b){var c=a(this),d="sitemap-id-"+b;c.attr("id",d).css({width:0,opacity:0,overflow:"hidden"}).before("<label />").prev("label").attr("for",d).text(c.val())}).end().end()}); |