gerybox 牛人很强的js

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Sortable list</title>
    <script type="text/javascript" src="../AJS.js"></script>
    <link href="../static/style.css" rel="stylesheet" type="text/css" media="all" />

    <style type="text/css">
        ul {
            margin: 0;
            padding: 0;
            list-style: none;
            width: 200px;
        }

        td {
            padding: 3px;
        }

        .item {
            background-color: #fff2c3;
            border: 1px solid #999;
            width: 150px;
            padding: 5px;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>

<h2>Sortable list</h2>
<ul id="list">
    <li class="item">1</li>
    <li class="item">2</li>
    <li class="item">3</li>
    <li class="item">4</li>
    <li class="item">5</li>
</ul>

<script>
var table_items = AJS.$bytc('li', null, AJS.$('list'));

var on_hover = function(drop_zone, click_elm, drag_elm) {
    var drag_elm = AJS.drag_elm;
    if(drop_zone != click_elm) {
        var d_z_top = drop_zone.offsetTop;
        var d_z_middle = drop_zone.offsetTop + (drop_zone.offsetHeight/2);
        var d_e_bottom = drag_elm.offsetTop + drag_elm.offsetHeight;
        var d_e_top = drag_elm.offsetTop;

        if(d_e_bottom > d_z_middle && d_e_top < d_z_top)
            AJS.insertAfter(click_elm, drop_zone);
        if(d_e_top < d_z_middle && d_e_top > d_z_top)
            AJS.insertBefore(click_elm, drop_zone);
    }
}

var on_drag = function(click_elm) {
    AJS.setOpacity(AJS.drag_elm, 0.75);
}

AJS.map(table_items, function(item) {
    AJS.dragAble(item, null, {
                             move_x: false,
                             on_drag: on_drag,
                             hide_on_move: true});
    AJS.dropZone(item, {on_hover: on_hover});
});
</script>

</body>
</html>
强,可以随便改变<li>中内容的位置,有点www.uumap.com的味道uumap是用的好象是dwr,这个比那个简单多了,不错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值