public/plugins/jquery/jquery-dad/jquery.dad.min.js

(完整代码) 4KB

/*
 jquery.dad.js v1 (http://konsolestudio.com/dad)
 Author William Lima
*/
(function(c){var t="ontouchstart"in window||navigator.msMaxTouchPoints;c.fn.dad=function(n){var f=this,e=c.extend({},{target:">div",draggable:!1,placeholder:"",callback:!1,containerClass:"dad-container",childrenClass:"dads-children",cloneClass:"dads-children-clone",active:!0},n);e.draggable?c(e.draggable,this).attr("title","\u6309\u4f4f\u9f20\u6807\u5de6\u952e\u62d6\u52a8\u66f4\u6362\u4f4d\u7f6e"):c(this).attr("title","\u6309\u4f4f\u9f20\u6807\u5de6\u952e\u62d6\u52a8\u66f4\u6362\u4f4d\u7f6e");c(this).each(function(){function n(a){var d=
1;a.find(h).each(function(){c(this).attr("data-dad-position",d);d++})}function q(){if(0!=a.target&&0!=a.clone){0!=r&&r(a.target);var d=a.target,g=a.clone,e=a.placeholder;c.contains(b[0],a.target[0])?a.clone.animate({top:a.target.offset().top-b.offset().top-0,left:a.target.offset().left-b.offset().left-0},300,function(){d.css({visibility:"visible"}).removeClass("active");g.remove()}):a.clone.fadeOut(300,function(){g.remove()});e.remove();a.clone=!1;a.placeholder=!1;a.target=!1;n(b)}c("html, body").removeClass("dad-noSelect")}
var l=e.active,b=c(this),k=e.childrenClass,u=e.cloneClass,h="."+k,m=b.find(e.target),v=e.placeholder,r=e.callback,a={x:0,y:0,target:!1,clone:!1,placeholder:!1,cloneoffset:{x:0,y:0},updatePosition:function(a){this.x=a.pageX;this.y=a.pageY},move:function(a){this.updatePosition(a);!1!==this.clone&&!1!==f.target&&this.clone.css({left:this.x-this.cloneoffset.x,top:this.y-this.cloneoffset.y})}};c(window).on("mousemove touchmove",function(d){var b=d;!1!==a.clone&&!1!==a.target&&d.preventDefault();t&&"touchmove"==
d.type&&(b=d.originalEvent.touches[0],d=document.elementFromPoint(b.clientX,b.clientY),c(d).trigger("touchenter"));a.move(b)});b.addClass(e.containerClass);b.hasClass("dad-active")||!0!==l||b.addClass("dad-active");f.addDropzone=function(d,b){c(d).on("mouseenter touchenter",function(){!1!==a.target&&(a.placeholder.css({display:"none"}),a.target.css({display:"none"}),c(this).addClass("active"))}).on("mouseup touchend",function(){0!=a.target&&(a.placeholder.css({display:"block"}),a.target.css({display:"block"}),
b(a.target),q());c(this).removeClass("active")}).on("mouseleave touchleave",function(){!1!==a.target&&(a.placeholder.css({display:"block"}),a.target.css({display:"block"}));c(this).removeClass("active")})};f.getPosition=function(){var a=[];c(this).find(h).each(function(){a[c(this).attr("data-dad-id")]=parseInt(c(this).attr("data-dad-position"))});return a};f.activate=function(){l=!0;b.hasClass("dad-active")||b.addClass("dad-active");return f};f.deactivate=function(){l=!1;b.removeClass("dad-active");
return f};b.on("DOMNodeInserted",function(a){a=c(a.target);a.hasClass(k)||a.hasClass("dads-children-placeholder")||a.addClass(k);e.draggable&&c(e.draggable,a).addClass("dad-draggable-area")});c(document).on("mouseup touchend",function(){q()});var p=1;m.addClass(k).each(function(){void 0==c(this).data("dad-id")&&c(this).attr("data-dad-id",p);c(this).attr("data-dad-position",p);p++});m=!1!==e.draggable?e.draggable:h;b.find(m).addClass("dad-draggable-area");b.on("mousedown touchstart",m,function(d){"touchstart"==
d.type&&a.updatePosition(d.originalEvent.touches[0]);if(0==a.target&&1==l&&(1==d.which||"touchstart"==d.type)){d=c(this);a.target=!1!==e.draggable?b.find(h).has(this):d;a.clone=a.target.clone();a.target.css({visibility:"hidden"}).addClass("active");a.clone.addClass(u);b.append(a.clone);d=c("<div></div>");a.placeholder=d;a.placeholder.addClass("dads-children-placeholder");a.placeholder.css({top:a.target.offset().top-b.offset().top,left:a.target.offset().left-b.offset().left,width:a.target.outerWidth()-
10,height:a.target.outerHeight()-10,lineHeight:a.target.height()-18+"px",textAlign:"center"}).text(v);b.append(a.placeholder);var g=Math.floor(parseFloat(b.css("border-left-width")));d=Math.floor(parseFloat(b.css("border-top-width")));g=a.x-a.target.offset().left+b.offset().left+g;d=a.y-a.target.offset().top+b.offset().top+d;a.cloneoffset.x=g;a.cloneoffset.y=d;a.clone.removeClass(k).css({position:"absolute",top:a.y-a.cloneoffset.y,left:a.x-a.cloneoffset.x,width:a.target.outerWidth()});c("html,body").addClass("dad-noSelect")}});
b.on("mouseenter touchenter",h,function(){var d=c(this);if(!1!==a.target&&!1!==a.clone){var e=c('<span style="display:none"></span>'),f=c('<span style="display:none"></span>');d.prevAll().hasClass("active")?d.after(f):d.before(f);a.target.before(e);f.before(a.target);a.placeholder.css({top:a.target.offset().top-b.offset().top,left:a.target.offset().left-b.offset().left,width:a.target.outerWidth()-10,height:a.target.outerHeight()-10});e.remove();f.remove()}})});return this}})(jQuery);

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。