黑夜的狼

沮丧吗,那就是一种无病呻吟!留恋它就是一种高度近视!目光应该放得更远一点! 别不想飞,只是要一步跨过太平洋!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
(function ($)
{
var methods = {
init:
function (options)
{
options.obj
= this;
options.obj.children().bind(
"mousedown", options, methods.ondrag).unbind("click").css({ cursor: "move" });
},
destroy:
function (options)
{
this.children().unbind("mousedown").css({ cursor: "hand" }); ;
if (options && options.fn)
{
this.children().bind("click", options.fn);
}
},
ondrag:
function (event)
{
this.setCapture();
var $this = $(this);
$
this.css({ "z-index": setdate.topindex, "filter": "alpha(opacity=50);-moz-opacity: 0.5;opacity: 0.5;" });
setdate.topindex
++;
setdate.mouseOffest
= { top: event.offsetY, left: event.offsetX };
$
this.bind("mousemove.drag", event.data, methods.onmove);
$
this.bind("mouseup.drag", event.data, methods.ondrop);
},
onmove:
function (event)
{
var $this = $(this);
$
this.offset({ top: event.clientY - setdate.mouseOffest.top, left: event.clientX - setdate.mouseOffest.left });
},
ondrop:
function (event)
{
var $this = $(this);
$
this.unbind(".drag").css({ "filter": "alpha(opacity=100);-moz-opacity: 1;opacity: 1;" });
this.releaseCapture();
},
checkpos:
function (event)
{

}
};
var setdate = { topindex: 1 };
$.fn.DragDropAuto
= function (method)
{
if (this.length == 0) return;
if (methods[method])
{
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof method === 'object' || !method)
{
return methods.init.apply(this, arguments);
}
else { $.error('Method ' + method + ' does not exist on jQuery.DragDropAuto'); }
};
})(jQuery);
posted on 2011-04-16 06:29  anncesky  阅读(357)  评论(0)    收藏  举报