rhymix/modules/admin/tpl/js/sitemap.min.js
2012-09-24 09:26:31 +00:00

6 lines
2.8 KiB
JavaScript

jQuery(function(c){function p(a,c){for(var b=0,g=0;a&&a!=c;)b+=a.offsetTop,g+=a.offsetLeft,a=a.offsetParent;return{top:b,left:g}}var l=!1,k=c('<li class="placeholder">');c("form.siteMap").delegate("li:not(.placeholder)",{"mousedown.st":function(a){var d,b,g,h,n,q,i,m,j;if(!(c(a.target).is("a,input,label,textarea")||1!=a.which)){l=!0;b=c(this);q=b.height();n=b.width();g=b.parentsUntil(".siteMap").filter("ul");h=g.eq(-1);h.css("position","relative");d=a.pageY;i=p(this,h.get(0));$clone=b.clone(!0).attr("target",
!0);for(a=g.length-1;a;a--)$clone=$clone.wrap("<li><ul /></li>").parent().parent();m=[];h.find("li").each(function(){if(b[0]===this||b.has(this).length)return!0;var a=p(this,h.get(0));m.push({top:a.top,bottom:a.top+32,item:this})});$clone.find(".side,input").remove().end().addClass("draggable").css({position:"absolute",opacity:0.6,width:n,height:q,left:i.left,top:i.top,zIndex:100}).appendTo(h.eq(0));k.css({position:"absolute",opacity:0.6,width:n,height:"5px",left:i.left,top:i.top,zIndex:99}).appendTo(h.eq(0));
b.css("opacity",0.6);c(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,c,e,f;j=null;a=i.top-(d-a.pageY);b=0;for(c=m.length;b<c;b++)if(f=a,e=m[b],0==b&&f<e.top&&(f=e.top),b==c-1&&f>e.bottom&&(f=e.bottom),e.top<=f&&e.bottom>=f){b=e.item;3>=Math.abs(e.top-f)?(k.css({top:e.top-3,height:"5px"}),f="before"):3>=Math.abs(e.bottom-f)?(k.css({top:e.bottom-3,height:"5px"}),f="after"):(k.css({top:e.top+3,height:"27px"}),f="prepend");j={element:b,state:f};break}$clone.css({top:a})}).bind("mouseup.st",
function(){var a,d;l=!1;c(document).unbind("mousemove.st mouseup.st");b.css("opacity","");$clone.remove();k.remove();d=c("<li />").height(b.height());if(j){a=c(j.element);b.before(d);if("prepend"==j.state)a.find(">ul").length||a.find(">.side").after("<ul>"),a.find(">ul").prepend(b.hide());else a[j.state](b.hide());b.slideDown(100,function(){b.removeClass("active")});d.slideUp(100,function(){var a=d.parent();d.remove();a.children("li").length||a.remove()});b.trigger("dropped.st")}});return!1}},"mouseover.st":function(){l||
c(this).addClass("active");return!1},"mouseout.st":function(){l||c(this).removeClass("active");return!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 a=c(this),d=a.prev("label"),b=a.parent();a.width(b.width()-(parseInt(b.css("text-indent"))||0)-a.next(".side").width()-60).css("opacity","");d.hide()}).blur(function(){var a=c(this),d=a.prev("label"),b=a.val();a.width(0).css("opacity",
0);d.removeClass("no-text").empty().text(b).show();b||d.addClass("no-text").text("---")}).each(function(a){var d=c(this),a="sitemap-id-"+a;d.attr("id",a).css({width:0,opacity:0,overflow:"hidden"}).before("<label />").prev("label").attr("for",a).text(d.val())}).end().end()});