这次给大家带来jquery鼠标拖动table进行排序(附代码),jquery鼠标拖动table进行排序的注意事项有哪些,下面就是实战案例,一起来看一下。
1、前端页面
<%@ page language="c#" autoeventwireup="true" codefile="拖动排序li或table.aspx.cs" inherits="拖动排序li或table" %>
<!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">
<head id="head1">
<title>广告管理 </title>
<link href="styles/css.css" rel="stylesheet" type="text/css" />
<script src="scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="scripts/ui.core.js" type="text/javascript"></script>
<script src="scripts/ui.sortable.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
//添加广告
function addlinks() {
editwidget("phonearticlelistpageinsorup.aspx");
}
</script>
<script type="text/javascript">
$(function () {
$('.sortable').sortable({ cursor: 'move' });
});
</script>
<script type="text/javascript">
//编辑
function editlink(prefix, aftfix, obj) {
editwidget("phonearticlelistpageinsorup.aspx?id=" + obj);
}
</script>
<script type="text/javascript">
function getsortresult(prefix, aftfix) {
var flag = document.getelementbyid("" + prefix + "_sortable_" + aftfix + "");
if (flag) {
var result = $("#" + prefix + "_sortable_" + aftfix + "").sortable('toarray');
$(":button").attr("disabled", "disabled"); $(":submit").attr("disabled", "disabled");
$("#delay_" + prefix + "_" + aftfix + "").show();
$("#normal_" + prefix + "_" + aftfix + "").hide();
$.ajax({
url: "phonearticlelistpage_2.aspx?word=" + result,
cache: false,
success: function (html) {
$("#delay_" + prefix + "_" + aftfix + "").hide();
$("#normal_" + prefix + "_" + aftfix + "").show();
$(":button").removeattr("disabled"); $(":submit").removeattr("disabled");
}
});
alert(flag);
alert("手机文章列表排列顺序保存成功!");
}
else {
alert("没有需要排序的手机文章列表!");
return false;
}
}
</script>
<script type="text/javascript">
//删除广告
function deletelink() {
if (confirm("您确定删除您刚才选中的项吗?")) {
var s = document.getelementsbyname("checkbox");
var s2 = "";
for (var i = 0; i < s.length; i++) {
if (s[i].checked) {
s2 += s[i].value + ',';
}
}
location.href = "phonearticlelistpage_2.aspx?del_id=" + s2; //这里传过去的是已逗号分隔开的id,需要在后面的页面内取出
}
}
</script>
<style type="text/css">
.sortable
{
margin: 0;
padding: 0;
}
.sortable li
{
margin: 3px 8px 3px 0;
float: left;
}
.sortable li
{
width: 250px;
height: 170px;
}
</style>
</head>
<body>
<form method="post" action="phonearticlelistpage_2.aspx" id="form1">
<table class="table1 fn-table fn-table-mouse" align="center">
<tr>
<td width="50%">
<input name="adsave" type="button" id="adsave" class="btn" onclick="getsortresult('sitelinks','text')"
value="保存顺序" />
</td>
<td width="50%" align="right">
提示:按住鼠标拖动链接,之后单击保存按钮就可以完成对链接的排列
</td>
</tr>
<tr>
<td width="100%" colspan="2" align="center" style="background-color: #f6f6f6;">
<p id="tabs">
<p id="tabs-sitelinks-text">
<p id="normal_sitelinks_text">
<ul class="sortable" id="sitelinks_sortable_text">
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_96">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="96" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','96')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
法国时代复分大占地方
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312023422.jpg '
alt='法国时代复分大占地方' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://www.uzai.com/trip/27879.html?46400284' target="_blank">http://www.uzai.com/trip/27879.html?46400284</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_78">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="78" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','78')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
医保结余7000亿花不出去 官员建议提高报销比例007
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312023115.jpg '
alt='医保结余7000亿花不出去 官员建议提高报销比例007' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://finance.sina.com.cn/china/20131202/011217492954.shtml' target="_blank">
http://finance.sina.com.cn/china/20131202/011217492954.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_94">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="94" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','94')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
新浪科技“因你而变”:卡片式社交首页新版上线
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312021700.jpg '
alt='新浪科技“因你而变”:卡片式社交首页新版上线' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://tech.sina.com.cn/i/2013-12-02/00158965413.shtml' target="_blank">http://tech.sina.com.cn/i/2013-12-02/00158965413.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_91">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="91" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','91')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
教授拒入普通病房:我的命十个人都换不来001
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312020214.jpg '
alt='教授拒入普通病房:我的命十个人都换不来001' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://news.sohu.com/20131202/n391116380.shtml' target="_blank">http://news.sohu.com/20131202/n391116380.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_79">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="79" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','79')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
广东打击*抓百人 首例案件开审9人批捕002
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312023939.jpg '
alt='广东打击*抓百人 首例案件开审9人批捕002' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://tech.sina.com.cn/t/2013-12-02/01148965434.shtml' target="_blank">http://tech.sina.com.cn/t/2013-12-02/01148965434.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_81">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="81" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','81')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
1男1女从南昌大学图书馆坠亡 女死者为该校学生003
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312024135.jpg '
alt='1男1女从南昌大学图书馆坠亡 女死者为该校学生003' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://news.sina.com.cn/s/2013-12-02/115128865820.shtml' target="_blank">http://news.sina.com.cn/s/2013-12-02/115128865820.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_77">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="77" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','77')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
河南车主遭罚服毒调查:每月办3000元月票可免罚004
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312022910.jpg '
alt='河南车主遭罚服毒调查:每月办3000元月票可免罚004' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://news.sina.com.cn/c/2013-12-02/023928862436.shtml' target="_blank">http://news.sina.com.cn/c/2013-12-02/023928862436.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_82">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="82" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','82')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
大学生见义勇为被连捅三刀 因家贫无钱医治(图)005
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312024219.jpg '
alt='大学生见义勇为被连捅三刀 因家贫无钱医治(图)005' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://news.sina.com.cn/s/2013-12-02/052028863120.shtml' target="_blank">http://news.sina.com.cn/s/2013-12-02/052028863120.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_80">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="80" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','80')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
676帽!韦德刷新盖帽纪录 前辈1100场他只用679场006
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312024034.jpg '
alt='676帽!韦德刷新盖帽纪录 前辈1100场他只用679场006' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://sports.sina.com.cn/nba/2013-12-02/10006913299.shtml' target="_blank">
http://sports.sina.com.cn/nba/2013-12-02/10006913299.shtml</a>
</td>
</tr>
</table>
</li>
<li style="padding: 0; border: 1px solid #bad5f2; background: #f7fbfe; text-align: left"
id="sitelinks_text_83">
<table cellspacing="0" cellpadding="0" border="0px" style="background: #f7fbfe; width: 100%;
height: 170px; table-layout: fixed; word-wrap: break-word;">
<tr style="height: 20px;">
<td width="30%" align="left" valign="top">
<input type="checkbox" name="checkbox" value="83" />
</td>
<td width="70%" height="10px" align="left">
<a href="javascript:void(0)" onclick="editlink('sitelinks','text','83')"><font color="#cc3333">[编辑]</font>
</a>
</td>
</tr>
<tr>
<td>
<b>文章标题:</b>
</td>
<td>
8岁大妈秀腹肌健壮,长相神秘还被曝已有两小孩008
</td>
</tr>
<tr>
<td>
<b>列表图片:</b>
</td>
<td>
<img width="100" height="50px" src='http://10.1.3.203:6001/manager/menupages/phonemanage/articleimg/201312024516.jpg '
alt='8岁大妈秀腹肌健壮,长相神秘还被曝已有两小孩008' />
</td>
</tr>
<tr>
<td>
<b>文章url:</b>
</td>
<td>
<a href='http://net.chinabyte.com/442/12792942.shtml' target="_blank">http://net.chinabyte.com/442/12792942.shtml</a>
</td>
</tr>
</table>
</li>
</ul>
</p>
</p>
</p>
</td>
</tr>
</table>
</form>
</body>
</html>
2、css样式
[css] view plaincopy在code上查看代码片派生到我的代码片
body,p,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
ol,ul{list-style:none;}
a{color:#333;text-decoration:none;}
a:hover{color:#f30;text-decoration:underline}
body{font-family:"宋体",arail,verdana;font-size:12px;line-height:1.5em;color:#222;background:#fff ;}
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
.clearfix{display:block;}
* html .clearfix{height:1%;}
.clear{clear:both;}
/*文本对齐*/
.tr{text-align:right}
.tl{text-align:left;}
.tc{text-align:center;}
/*浮动*/
.fn-fl{float:left;}
.fn-fr{float:right;}
.m5{margin:5px;} .m10{margin:10px;}
.mt5 { margin-top:5px;}.mr5 { margin-right:5px;}.mb5 { margin-bottom:5px;}.ml5 { margin-left:5px;}
.mt10 { margin-top:10px;}.mr10 { margin-right:10px;}.mb10 { margin-bottom:10px;}.ml10 { margin-left:10px;}
.p5{padding:5px;} .p10{padding:10px;}
.pt5 { padding-top:5px;}.pr5 { padding-right:5px;}.pb5 { padding-bottom:5px;}.pl5 { padding-left:5px;}
.pt10 { padding-top:10px;}.pr10 { padding-right:10px;}.pb10 { padding-bottom:10px;}.pl10 { padding-left:10px;}
.mt30{margin-top:30px;}.mb30{margin-bottom:30px;}
.pt30{padding-top:30px;}.pb30{padding-bottom:30px;}
/*无效状态*/
input[disabled], select[disabled], textarea[disabled], input[readonly], select[readonly], textarea[readonly] {background-color: #eee;cursor: not-allowed;box-shadow:none;opacity:0.5}
/*下拉列表*/
select{border:1px solid #ccc;border-radius:3px;padding:1px 2px;}
/*输入框*/
input:-moz-placeholder,textarea:-moz-placeholder {color: #999999;}
input:-ms-input-placeholder,textarea:-ms-input-placeholder {color: #999999;}
input::-webkit-input-placeholder,textarea::-webkit-input-placeholder {color: #999999;}
.txt,textarea,input[type="text"], input[type="password"] {border: 1px solid #ccc;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;border-radius:3px;padding:2px 3px;}
.txt:focus,textarea:focus,input[type="text"]:focus, input[type="password"]:focus {border: 1px solid #2c5193;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(44, 81, 147, 0.6);}
.txta{font-size:12px;line-height:18px;}
.txt20{width:20px;}
.txt30{width:30px;}
.txt50{width:50px;}
.txt75{width:75px;}
.txt85{width:85px;}
.txt100{width:100px;}
.txt125{width:125px;}
.txt150{width:150px;}
.txt175{width:175px;}
.txt200{width:200px;}
.txt250{width:250px;}
.txt280{width:280px;}
.txt300{width:300px;}
.txt350{width:350px;}
.txt400{width:400px;}
/*标准表格*/
.fn-table{width:100%;}
.fn-table>tbody>tr>td{padding:3px;background:#fff;border:1px solid #cedced;}
.fn-table>tbody>tr>th{background:#e3f5ff;padding:2px;border:1px solid #cedced;font-weight:bold;}
.fn-table-space>tbody>tr:nth-child(2n+1)>td{background:#efefef;}
/*细线表格*/
.fn-table-line>tbody>tr>td{}
/*鼠标hover表格*/
.fn-table-mouse>tbody>tr:nth-child(2n+1)>td{background:#efefef;}
.fn-table tr.on>tbody>tr>td,.fn-table-mouse>tbody>tr:hover>td{background:#fcf8e3;}
/*功能表格*/
.fn-table-function>tbody>tr>td:nth-child(2n+1){background:#e3f5ff;text-align:right;font-weight:bold;}
.fn-table-function>tbody>tr>td:first-child{background:#e3f5ff;text-align:right;font-weight:bold;}
/*干净表格*/
.fn-table-clear{}
.fn-table-clear>tbody>tr>td{padding:3px;background:#fff;border:none;}
.fn-table-clear>tbody>tr>th{background:#e3f5ff;padding:3px;border:none;}
/*iframe 头部样式,仅后台部分案例*/
.fn-iframe-hd{padding:2px 5px;background:#2c5193;margin-bottom:30px;line-height:22px;height:22px;color:#fff;position:fixed;left:0;top:0;width:100%;}
.fn-iframe-hd .close{background:url(/manager/themes/images/icons/closed.png) no-repeat center center;float:right;width:14px;height:13px;cursor:pointer;padding:4px 5px;margin-right:10px;}
.fn-iframe-hd .close:hover{opacity:0.8;}
.fn-iframe-hd .tt{float:left;font-weight:bold;}
/*标准tab选项卡*/
.fn-tab .hd li{float:left;margin-right:2px;padding:2px 5px;border:1px solid #2c5193;border-radius:5px 5px 0 0;cursor:pointer;background:#2c5193;color:#fff;}
.fn-tab .hd li.on{background:#4b8af9;color:#fff;border:1px solid #4b8af9;border-bottom:0;}
.fn-tab .bd{border:1px solid #ddd;padding:3px;margin-top:-1px;}
.fn-tab .bd p.item{display:none;}
.fn-tab .bd p.on{display:block;}
/*搜索框*/
.fn-searchbar{border:1px solid #cedced;padding:2px;border-radius:3px;}
.fn-searchbar input,.fn-searchbar select{vertical-align:middle;}
/*分页*/
.fn-pager{background:#e3f5ff;border:1px solid #cedced;margin:0 0 5px;border-top:0;}
.fn-pager p{line-height:26px;white-space:nowrap;word-break:break-all;}
.fn-pager input{margin-left:5px;}
.fn-pager a{border:1px solid #e3f5ff;padding:3px 5px;}
.fn-pager span.on{background:#2c5193;border:1px solid #2c5193;color:#fff;padding:3px 5px;font-weight:bold;}
.fn-pager a:hover{background:#2c5193;border:1px solid #2c5193;color:#fff;}
.fn-pager input,.fn-pager select,.fn-pager a,.fn-pager span{vertical-align:middle;}
.fn-pagerext{float:right;margin-top:-22px;}
.fn-pagerext input{vertical-align:middle;}
/*按钮*/
.btn,.fn-pager input[type='submit']{border-radius:3px;padding:1px 2px;border:1px solid #b3b3b3;cursor:pointer;background-image: linear-gradient(to bottom, #fff, #e6e6e6); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05);color:#666;line-height:20px;vertical-align:middle;text-decoration:none;padding:1px 3px\0;}
a.btn{padding:3px 6px;}
.btn:hover{background:#eee;text-decoration:none;}
.btn-on,.fn-pager input[type='submit']{background-image:linear-gradient(to bottom,#4b8af9,#2c5193);color:#fff;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.1);background-color:#2c5193;border:1px solid #2c5193\0;}
.btn-on:hover,.fn-pager input[type='submit']:hover{background:#4b8af9;color:#fff;}
.btn-gray{background:linear-gradient(to bottom,#ccc,#efefef);color:#fff;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.1);cursor:not-allowed;}
.btn-gray:hover{background:#eee;text-decoration:none;}
.btn:active{box-shadow:inset 0 1px 2px rgba(0,0,0,.25),inset 0 1px 3px rgba(0,0,0,0.15);}
#tooltip{position: absolute;border: 1px solid #333;background: #f7f5d1;padding: 2px 5px;color: #333;display: none;width: 500px;}
#tooltip{position:absolute;color:#333;display:block;background-color:#fff;border:1px solid #555;box-shadow:0 0 10px rgba(0,0,0,.3);border-radius:5px;padding:3px;min-width:160px;min-height:80px;}
#tooltip img{border-radius:5px;}
/*文字大小*/
.font12{font-size:12px;}
.font13{font-size:13px;}
.font14{font-size:14px;}
.font15{font-size:15px;}
.font16{font-size:16px;}
.font17{font-size:17px;}
.font18{font-size:18px;}
/*文字颜色*/
.font-red{color:red;}
.font-green{color:green;}
.font-white{color:white;}
.font-gray{color:gray;}
/*鼠标标记*/
.hand{cursor:pointer;}
3、主要js
jquery.js
ui.core.js
[javascript] view plaincopy在code上查看代码片派生到我的代码片
/*
* jquery ui 1.7.1
*
* copyright (c) 2009 authors.txt (http://jqueryui.com/about)
* dual licensed under the mit (mit-license.txt)
* and gpl (gpl-license.txt) licenses.
*
* http://docs.jquery.com/ui
*/
;jquery.ui || (function($) {
var _remove = $.fn.remove,
isff2 = $.browser.mozilla && (parsefloat($.browser.version) < 1.9);
//helper functions and ui object
$.ui = {
version: "1.7.1",
// $.ui.plugin is deprecated. use the proxy pattern instead.
plugin: {
add: function(module, option, set) {
var proto = $.ui[module].prototype;
for(var i in set) {
proto.plugins[i] = proto.plugins[i] || [];
proto.plugins[i].push([option, set[i]]);
}
},
call: function(instance, name, args) {
var set = instance.plugins[name];
if(!set || !instance.element[0].parentnode) { return; }
for (var i = 0; i < set.length; i++) {
if (instance.options[set[i][0]]) {
set[i][1].apply(instance.element, args);
}
}
}
},
contains: function(a, b) {
return document.comparedocumentposition
? a.comparedocumentposition(b) & 16
: a !== b && a.contains(b);
},
hasscroll: function(el, a) {
//if overflow is hidden, the element might have extra content, but the user wants to hide it
if ($(el).css('overflow') == 'hidden') { return false; }
var scroll = (a && a == 'left') ? 'scrollleft' : 'scrolltop',
has = false;
if (el[scroll] > 0) { return true; }
// todo: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to
// set the scroll
el[scroll] = 1;
has = (el[scroll] > 0);
el[scroll] = 0;
return has;
},
isoveraxis: function(x, reference, size) {
//determines when x coordinate is over "b" element axis
return (x > reference) && (x < (reference + size));
},
isover: function(y, x, top, left, height, width) {
//determines when x, y coordinates is over "b" element
return $.ui.isoveraxis(y, top, height) && $.ui.isoveraxis(x, left, width);
},
keycode: {
backspace: 8,
caps_lock: 20,
comma: 188,
control: 17,
delete: 46,
down: 40,
end: 35,
enter: 13,
escape: 27,
home: 36,
insert: 45,
left: 37,
numpad_add: 107,
numpad_decimal: 110,
numpad_pide: 111,
numpad_enter: 108,
numpad_multiply: 106,
numpad_subtract: 109,
page_down: 34,
page_up: 33,
period: 190,
right: 39,
shift: 16,
space: 32,
tab: 9,
up: 38
}
};
// wai-aria normalization
if (isff2) {
var attr = $.attr,
removeattr = $.fn.removeattr,
arians = "http://www.w3.org/2005/07/aaa",
ariastate = /^aria-/,
ariarole = /^wairole:/;
$.attr = function(elem, name, value) {
var set = value !== undefined;
return (name == 'role'
? (set
? attr.call(this, elem, name, "wairole:" + value)
: (attr.apply(this, arguments) || "").replace(ariarole, ""))
: (ariastate.test(name)
? (set
? elem.setattributens(arians,
name.replace(ariastate, "aaa:"), value)
: attr.call(this, elem, name.replace(ariastate, "aaa:")))
: attr.apply(this, arguments)));
};
$.fn.removeattr = function(name) {
return (ariastate.test(name)
? this.each(function() {
this.removeattributens(arians, name.replace(ariastate, ""));
}) : removeattr.call(this, name));
};
}
//jquery plugins
$.fn.extend({
remove: function() {
// safari has a native remove event which actually removes dom elements,
// so we have to use triggerhandler instead of trigger (#3037).
$("*", this).add(this).each(function() {
$(this).triggerhandler("remove");
});
return _remove.apply(this, arguments );
},
enableselection: function() {
return this
.attr('unselectable', 'off')
.css('mozuserselect', '')
.unbind('selectstart.ui');
},
disableselection: function() {
return this
.attr('unselectable', 'on')
.css('mozuserselect', 'none')
.bind('selectstart.ui', function() { return false; });
},
scrollparent: function() {
var scrollparent;
if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
scrollparent = this.parents().filter(function() {
return (/(relative|absolute|fixed)/).test($.curcss(this,'position',1)) && (/(auto|scroll)/).test($.curcss(this,'overflow',1)+$.curcss(this,'overflow-y',1)+$.curcss(this,'overflow-x',1));
}).eq(0);
} else {
scrollparent = this.parents().filter(function() {
return (/(auto|scroll)/).test($.curcss(this,'overflow',1)+$.curcss(this,'overflow-y',1)+$.curcss(this,'overflow-x',1));
}).eq(0);
}
return (/fixed/).test(this.css('position')) || !scrollparent.length ? $(document) : scrollparent;
}
});
//additional selectors
$.extend($.expr[':'], {
data: function(elem, i, match) {
return !!$.data(elem, match[3]);
},
focusable: function(element) {
var nodename = element.nodename.tolowercase(),
tabindex = $.attr(element, 'tabindex');
return (/input|select|textarea|button|object/.test(nodename)
? !element.disabled
: 'a' == nodename || 'area' == nodename
? element.href || !isnan(tabindex)
: !isnan(tabindex))
// the element and all of its ancestors must be visible
// the browser may report that the area is hidden
&& !$(element)['area' == nodename ? 'parents' : 'closest'](':hidden').length;
},
tabbable: function(element) {
var tabindex = $.attr(element, 'tabindex');
return (isnan(tabindex) || tabindex >= 0) && $(element).is(':focusable');
}
});
// $.widget is a factory to create jquery plugins
// taking some boilerplate code out of the plugin code
function getter(namespace, plugin, method, args) {
function getmethods(type) {
var methods = $[namespace][plugin][type] || [];
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
}
var methods = getmethods('getter');
if (args.length == 1 && typeof args[0] == 'string') {
methods = methods.concat(getmethods('gettersetter'));
}
return ($.inarray(method, methods) != -1);
}
$.widget = function(name, prototype) {
var namespace = name.split(".")[0];
name = name.split(".")[1];
// create plugin method
$.fn[name] = function(options) {
var ismethodcall = (typeof options == 'string'),
args = array.prototype.slice.call(arguments, 1);
// prevent calls to internal methods
if (ismethodcall && options.substring(0, 1) == '_') {
return this;
}
// handle getter methods
if (ismethodcall && getter(namespace, name, options, args)) {
var instance = $.data(this[0], name);
return (instance ? instance[options].apply(instance, args)
: undefined);
}
// handle initialization and non-getter methods
return this.each(function() {
var instance = $.data(this, name);
// constructor
(!instance && !ismethodcall &&
$.data(this, name, new $[namespace][name](this, options))._init());
// method call
(instance && ismethodcall && $.isfunction(instance[options]) &&
instance[options].apply(instance, args));
});
};
// create widget constructor
$[namespace] = $[namespace] || {};
$[namespace][name] = function(element, options) {
var self = this;
this.namespace = namespace;
this.widgetname = name;
this.widgeteventprefix = $[namespace][name].eventprefix || name;
this.widgetbaseclass = namespace + '-' + name;
this.options = $.extend({},
$.widget.defaults,
$[namespace][name].defaults,
$.metadata && $.metadata.get(element)[name],
options);
this.element = $(element)
.bind('setdata.' + name, function(event, key, value) {
if (event.target == element) {
return self._setdata(key, value);
}
})
.bind('getdata.' + name, function(event, key) {
if (event.target == element) {
return self._getdata(key);
}
})
.bind('remove', function() {
return self.destroy();
});
};
// add widget prototype
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
// todo: merge getter and gettersetter properties from widget prototype
// and plugin prototype
$[namespace][name].gettersetter = 'option';
};
$.widget.prototype = {
_init: function() {},
destroy: function() {
this.element.removedata(this.widgetname)
.removeclass(this.widgetbaseclass + '-disabled' + ' ' + this.namespace + '-state-disabled')
.removeattr('aria-disabled');
},
option: function(key, value) {
var options = key,
self = this;
if (typeof key == "string") {
if (value === undefined) {
return this._getdata(key);
}
options = {};
options[key] = value;
}
$.each(options, function(key, value) {
self._setdata(key, value);
});
},
_getdata: function(key) {
return this.options[key];
},
_setdata: function(key, value) {
this.options[key] = value;
if (key == 'disabled') {
this.element
[value ? 'addclass' : 'removeclass'](
this.widgetbaseclass + '-disabled' + ' ' +
this.namespace + '-state-disabled')
.attr("aria-disabled", value);
}
},
enable: function() {
this._setdata('disabled', false);
},
disable: function() {
this._setdata('disabled', true);
},
_trigger: function(type, event, data) {
var callback = this.options[type],
eventname = (type == this.widgeteventprefix
? type : this.widgeteventprefix + type);
event = $.event(event);
event.type = eventname;
// copy original event properties over to the new event
// this would happen if we could call $.event.fix instead of $.event
// but we don't have a way to force an event to be fixed multiple times
if (event.originalevent) {
for (var i = $.event.props.length, prop; i;) {
prop = $.event.props[--i];
event[prop] = event.originalevent[prop];
}
}
this.element.trigger(event, data);
return !($.isfunction(callback) && callback.call(this.element[0], event, data) === false
|| event.isdefaultprevented());
}
};
$.widget.defaults = {
disabled: false
};
/** mouse interaction plugin **/
$.ui.mouse = {
_mouseinit: function() {
var self = this;
this.element
.bind('mousedown.'+this.widgetname, function(event) {
return self._mousedown(event);
})
.bind('click.'+this.widgetname, function(event) {
if(self._preventclickevent) {
self._preventclickevent = false;
event.stopimmediatepropagation();
return false;
}
});
// prevent text selection in ie
if ($.browser.msie) {
this._mouseunselectable = this.element.attr('unselectable');
this.element.attr('unselectable', 'on');
}
this.started = false;
},
// todo: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
_mousedestroy: function() {
this.element.unbind('.'+this.widgetname);
// restore text selection in ie
($.browser.msie
&& this.element.attr('unselectable', this._mouseunselectable));
},
_mousedown: function(event) {
// don't let more than one widget handle mousestart
// todo: figure out why we have to use originalevent
event.originalevent = event.originalevent || {};
if (event.originalevent.mousehandled) { return; }
// we may have missed mouseup (out of window)
(this._mousestarted && this._mouseup(event));
this._mousedownevent = event;
var self = this,
btnisleft = (event.which == 1),
eliscancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
if (!btnisleft || eliscancel || !this._mousecapture(event)) {
return true;
}
this.mousedelaymet = !this.options.delay;
if (!this.mousedelaymet) {
this._mousedelaytimer = settimeout(function() {
self.mousedelaymet = true;
}, this.options.delay);
}
if (this._mousedistancemet(event) && this._mousedelaymet(event)) {
this._mousestarted = (this._mousestart(event) !== false);
if (!this._mousestarted) {
event.preventdefault();
return true;
}
}
// these delegates are required to keep context
this._mousemovedelegate = function(event) {
return self._mousemove(event);
};
this._mouseupdelegate = function(event) {
return self._mouseup(event);
};
$(document)
.bind('mousemove.'+this.widgetname, this._mousemovedelegate)
.bind('mouseup.'+this.widgetname, this._mouseupdelegate);
// preventdefault() is used to prevent the selection of text here -
// however, in safari, this causes select boxes not to be selectable
// anymore, so this fix is needed
($.browser.safari || event.preventdefault());
event.originalevent.mousehandled = true;
return true;
},
_mousemove: function(event) {
// ie mouseup check - mouseup happened when mouse was out of window
if ($.browser.msie && !event.button) {
return this._mouseup(event);
}
if (this._mousestarted) {
this._mousedrag(event);
return event.preventdefault();
}
if (this._mousedistancemet(event) && this._mousedelaymet(event)) {
this._mousestarted =
(this._mousestart(this._mousedownevent, event) !== false);
(this._mousestarted ? this._mousedrag(event) : this._mouseup(event));
}
return !this._mousestarted;
},
_mouseup: function(event) {
$(document)
.unbind('mousemove.'+this.widgetname, this._mousemovedelegate)
.unbind('mouseup.'+this.widgetname, this._mouseupdelegate);
if (this._mousestarted) {
this._mousestarted = false;
this._preventclickevent = (event.target == this._mousedownevent.target);
this._mousestop(event);
}
return false;
},
_mousedistancemet: function(event) {
return (math.max(
math.abs(this._mousedownevent.pagex - event.pagex),
math.abs(this._mousedownevent.pagey - event.pagey)
) >= this.options.distance
);
},
_mousedelaymet: function(event) {
return this.mousedelaymet;
},
// these are placeholder methods, to be overriden by extending plugin
_mousestart: function(event) {},
_mousedrag: function(event) {},
_mousestop: function(event) {},
_mousecapture: function(event) { return true; }
};
$.ui.mouse.defaults = {
cancel: null,
distance: 1,
delay: 0
};
})(jquery);
ui.sortable.js
[javascript] view plaincopy在code上查看代码片派生到我的代码片
/*
* jquery ui sortable 1.7.1
*
* copyright (c) 2009 authors.txt (http://jqueryui.com/about)
* dual licensed under the mit (mit-license.txt)
* and gpl (gpl-license.txt) licenses.
*
* http://docs.jquery.com/ui/sortables
*
* depends:
* ui.core.js
*/
(function($) {
$.widget("ui.sortable", $.extend({}, $.ui.mouse, {
_init: function() {
var o = this.options;
this.containercache = {};
this.element.addclass("ui-sortable");
//get the items
this.refresh();
//let's determine if the items are floating
this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
//let's determine the parent's offset
this.offset = this.element.offset();
//initialize mouse events for interaction
this._mouseinit();
},
destroy: function() {
this.element
.removeclass("ui-sortable ui-sortable-disabled")
.removedata("sortable")
.unbind(".sortable");
this._mousedestroy();
for ( var i = this.items.length - 1; i >= 0; i-- )
this.items[i].item.removedata("sortable-item");
},
_mousecapture: function(event, overridehandle) {
if (this.reverting) {
return false;
}
if(this.options.disabled || this.options.type == 'static') return false;
//we have to refresh the items data once first
this._refreshitems(event);
//find out if the clicked node (or one of its parents) is a actual item in this.items
var currentitem = null, self = this, nodes = $(event.target).parents().each(function() {
if($.data(this, 'sortable-item') == self) {
currentitem = $(this);
return false;
}
});
if($.data(event.target, 'sortable-item') == self) currentitem = $(event.target);
if(!currentitem) return false;
if(this.options.handle && !overridehandle) {
var validhandle = false;
$(this.options.handle, currentitem).find("*").andself().each(function() { if(this == event.target) validhandle = true; });
if(!validhandle) return false;
}
this.currentitem = currentitem;
this._removecurrentsfromitems();
return true;
},
_mousestart: function(event, overridehandle, noactivation) {
var o = this.options, self = this;
this.currentcontainer = this;
//we only need to call refreshpositions, because the refreshitems call has been moved to mousecapture
this.refreshpositions();
//create and append the visible helper
this.helper = this._createhelper(event);
//cache the helper size
this._cachehelperproportions();
/*
* - position generation -
* this block generates everything position related - it's the core of draggables.
*/
//cache the margins of the original element
this._cachemargins();
//get the next scrolling parent
this.scrollparent = this.helper.scrollparent();
//the element's absolute position on the page minus margins
this.offset = this.currentitem.offset();
this.offset = {
top: this.offset.top - this.margins.top,
left: this.offset.left - this.margins.left
};
// only after we got the offset, we can change the helper's position to absolute
// todo: still need to figure out a way to make relative sorting possible
this.helper.css("position", "absolute");
this.cssposition = this.helper.css("position");
$.extend(this.offset, {
click: { //where the click happened, relative to the element
left: event.pagex - this.offset.left,
top: event.pagey - this.offset.top
},
parent: this._getparentoffset(),
relative: this._getrelativeoffset() //this is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
//generate the original position
this.originalposition = this._generateposition(event);
this.originalpagex = event.pagex;
this.originalpagey = event.pagey;
//adjust the mouse offset relative to the helper if 'cursorat' is supplied
if(o.cursorat)
this._adjustoffsetfromhelper(o.cursorat);
//cache the former dom position
this.domposition = { prev: this.currentitem.prev()[0], parent: this.currentitem.parent()[0] };
//if the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
if(this.helper[0] != this.currentitem[0]) {
this.currentitem.hide();
}
//create the placeholder
this._createplaceholder();
//set a containment if given in the options
if(o.containment)
this._setcontainment();
if(o.cursor) { // cursor option
if ($('body').css("cursor")) this._storedcursor = $('body').css("cursor");
$('body').css("cursor", o.cursor);
}
if(o.opacity) { // opacity option
if (this.helper.css("opacity")) this._storedopacity = this.helper.css("opacity");
this.helper.css("opacity", o.opacity);
}
if(o.zindex) { // zindex option
if (this.helper.css("zindex")) this._storedzindex = this.helper.css("zindex");
this.helper.css("zindex", o.zindex);
}
//prepare scrolling
if(this.scrollparent[0] != document && this.scrollparent[0].tagname != 'html')
this.overflowoffset = this.scrollparent.offset();
//call callbacks
this._trigger("start", event, this._uihash());
//recache the helper size
if(!this._preservehelperproportions)
this._cachehelperproportions();
//post 'activate' events to possible containers
if(!noactivation) {
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uihash(this)); }
}
//prepare possible droppables
if($.ui.ddmanager)
$.ui.ddmanager.current = this;
if ($.ui.ddmanager && !o.dropbehaviour)
$.ui.ddmanager.prepareoffsets(this, event);
this.dragging = true;
this.helper.addclass("ui-sortable-helper");
this._mousedrag(event); //execute the drag once - this causes the helper not to be visible before getting its correct position
return true;
},
_mousedrag: function(event) {
//compute the helpers position
this.position = this._generateposition(event);
this.positionabs = this._convertpositionto("absolute");
if (!this.lastpositionabs) {
this.lastpositionabs = this.positionabs;
}
//do scrolling
if(this.options.scroll) {
var o = this.options, scrolled = false;
if(this.scrollparent[0] != document && this.scrollparent[0].tagname != 'html') {
if((this.overflowoffset.top + this.scrollparent[0].offsetheight) - event.pagey < o.scrollsensitivity)
this.scrollparent[0].scrolltop = scrolled = this.scrollparent[0].scrolltop + o.scrollspeed;
else if(event.pagey - this.overflowoffset.top < o.scrollsensitivity)
this.scrollparent[0].scrolltop = scrolled = this.scrollparent[0].scrolltop - o.scrollspeed;
if((this.overflowoffset.left + this.scrollparent[0].offsetwidth) - event.pagex < o.scrollsensitivity)
this.scrollparent[0].scrollleft = scrolled = this.scrollparent[0].scrollleft + o.scrollspeed;
else if(event.pagex - this.overflowoffset.left < o.scrollsensitivity)
this.scrollparent[0].scrollleft = scrolled = this.scrollparent[0].scrollleft - o.scrollspeed;
} else {
if(event.pagey - $(document).scrolltop() < o.scrollsensitivity)
scrolled = $(document).scrolltop($(document).scrolltop() - o.scrollspeed);
else if($(window).height() - (event.pagey - $(document).scrolltop()) < o.scrollsensitivity)
scrolled = $(document).scrolltop($(document).scrolltop() + o.scrollspeed);
if(event.pagex - $(document).scrollleft() < o.scrollsensitivity)
scrolled = $(document).scrollleft($(document).scrollleft() - o.scrollspeed);
else if($(window).width() - (event.pagex - $(document).scrollleft()) < o.scrollsensitivity)
scrolled = $(document).scrollleft($(document).scrollleft() + o.scrollspeed);
}
if(scrolled !== false && $.ui.ddmanager && !o.dropbehaviour)
$.ui.ddmanager.prepareoffsets(this, event);
}
//regenerate the absolute position used for position checks
this.positionabs = this._convertpositionto("absolute");
//set the helper position
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
//rearrange
for (var i = this.items.length - 1; i >= 0; i--) {
//cache variables and intersection, continue if no intersection
var item = this.items[i], itemelement = item.item[0], intersection = this._intersectswithpointer(item);
if (!intersection) continue;
if(itemelement != this.currentitem[0] //cannot intersect with itself
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemelement //no useless actions that have been done before
&& !$.ui.contains(this.placeholder[0], itemelement) //no action if the item moved is the parent of the item checked
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemelement) : true)
) {
this.direction = intersection == 1 ? "down" : "up";
if (this.options.tolerance == "pointer" || this._intersectswithsides(item)) {
this._rearrange(event, item);
} else {
break;
}
this._trigger("change", event, this._uihash());
break;
}
}
//post events to containers
this._contactcontainers(event);
//interconnect with droppables
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
//call callbacks
this._trigger('sort', event, this._uihash());
this.lastpositionabs = this.positionabs;
return false;
},
_mousestop: function(event, nopropagation) {
if(!event) return;
//if we are using droppables, inform the manager about the drop
if ($.ui.ddmanager && !this.options.dropbehaviour)
$.ui.ddmanager.drop(this, event);
if(this.options.revert) {
var self = this;
var cur = self.placeholder.offset();
self.reverting = true;
$(this.helper).animate({
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetparent[0] == document.body ? 0 : this.offsetparent[0].scrollleft),
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetparent[0] == document.body ? 0 : this.offsetparent[0].scrolltop)
}, parseint(this.options.revert, 10) || 500, function() {
self._clear(event);
});
} else {
this._clear(event, nopropagation);
}
return false;
},
cancel: function() {
var self = this;
if(this.dragging) {
this._mouseup();
if(this.options.helper == "original")
this.currentitem.css(this._storedcss).removeclass("ui-sortable-helper");
else
this.currentitem.show();
//post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
this.containers[i]._trigger("deactivate", null, self._uihash(this));
if(this.containers[i].containercache.over) {
this.containers[i]._trigger("out", null, self._uihash(this));
this.containers[i].containercache.over = 0;
}
}
}
//$(this.placeholder[0]).remove(); would have been the jquery way - unfortunately, it unbinds all events from the original node!
if(this.placeholder[0].parentnode) this.placeholder[0].parentnode.removechild(this.placeholder[0]);
if(this.options.helper != "original" && this.helper && this.helper[0].parentnode) this.helper.remove();
$.extend(this, {
helper: null,
dragging: false,
reverting: false,
_nofinalsort: null
});
if(this.domposition.prev) {
$(this.domposition.prev).after(this.currentitem);
} else {
$(this.domposition.parent).prepend(this.currentitem);
}
return true;
},
serialize: function(o) {
var items = this._getitemsasjquery(o && o.connected);
var str = []; o = o || {};
$(items).each(function() {
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
});
return str.join('&');
},
toarray: function(o) {
var items = this._getitemsasjquery(o && o.connected);
var ret = []; o = o || {};
items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
return ret;
},
/* be careful with the following core functions */
_intersectswith: function(item) {
var x1 = this.positionabs.left,
x2 = x1 + this.helperproportions.width,
y1 = this.positionabs.top,
y2 = y1 + this.helperproportions.height;
var l = item.left,
r = l + item.width,
t = item.top,
b = t + item.height;
var dyclick = this.offset.click.top,
dxclick = this.offset.click.left;
var isoverelement = (y1 + dyclick) > t && (y1 + dyclick) < b && (x1 + dxclick) > l && (x1 + dxclick) < r;
if( this.options.tolerance == "pointer"
|| this.options.forcepointerforcontainers
|| (this.options.tolerance != "pointer" && this.helperproportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
) {
return isoverelement;
} else {
return (l < x1 + (this.helperproportions.width / 2) // right half
&& x2 - (this.helperproportions.width / 2) < r // left half
&& t < y1 + (this.helperproportions.height / 2) // bottom half
&& y2 - (this.helperproportions.height / 2) < b ); // top half
}
},
_intersectswithpointer: function(item) {
var isoverelementheight = $.ui.isoveraxis(this.positionabs.top + this.offset.click.top, item.top, item.height),
isoverelementwidth = $.ui.isoveraxis(this.positionabs.left + this.offset.click.left, item.left, item.width),
isoverelement = isoverelementheight && isoverelementwidth,
verticaldirection = this._getdragverticaldirection(),
horizontaldirection = this._getdraghorizontaldirection();
if (!isoverelement)
return false;
return this.floating ?
( ((horizontaldirection && horizontaldirection == "right") || verticaldirection == "down") ? 2 : 1 )
: ( verticaldirection && (verticaldirection == "down" ? 2 : 1) );
},
_intersectswithsides: function(item) {
var isoverbottomhalf = $.ui.isoveraxis(this.positionabs.top + this.offset.click.top, item.top + (item.height/2), item.height),
isoverrighthalf = $.ui.isoveraxis(this.positionabs.left + this.offset.click.left, item.left + (item.width/2), item.width),
verticaldirection = this._getdragverticaldirection(),
horizontaldirection = this._getdraghorizontaldirection();
if (this.floating && horizontaldirection) {
return ((horizontaldirection == "right" && isoverrighthalf) || (horizontaldirection == "left" && !isoverrighthalf));
} else {
return verticaldirection && ((verticaldirection == "down" && isoverbottomhalf) || (verticaldirection == "up" && !isoverbottomhalf));
}
},
_getdragverticaldirection: function() {
var delta = this.positionabs.top - this.lastpositionabs.top;
return delta != 0 && (delta > 0 ? "down" : "up");
},
_getdraghorizontaldirection: function() {
var delta = this.positionabs.left - this.lastpositionabs.left;
return delta != 0 && (delta > 0 ? "right" : "left");
},
refresh: function(event) {
this._refreshitems(event);
this.refreshpositions();
},
_connectwith: function() {
var options = this.options;
return options.connectwith.constructor == string
? [options.connectwith]
: options.connectwith;
},
_getitemsasjquery: function(connected) {
var self = this;
var items = [];
var queries = [];
var connectwith = this._connectwith();
if(connectwith && connected) {
for (var i = connectwith.length - 1; i >= 0; i--){
var cur = $(connectwith[i]);
for (var j = cur.length - 1; j >= 0; j--){
var inst = $.data(cur[j], 'sortable');
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isfunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]);
}
};
};
}
queries.push([$.isfunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentitem }) : $(this.options.items, this.element).not(".ui-sortable-helper"), this]);
for (var i = queries.length - 1; i >= 0; i--){
queries[i][0].each(function() {
items.push(this);
});
};
return $(items);
},
_removecurrentsfromitems: function() {
var list = this.currentitem.find(":data(sortable-item)");
for (var i=0; i < this.items.length; i++) {
for (var j=0; j < list.length; j++) {
if(list[j] == this.items[i].item[0])
this.items.splice(i,1);
};
};
},
_refreshitems: function(event) {
this.items = [];
this.containers = [this];
var items = this.items;
var self = this;
var queries = [[$.isfunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentitem }) : $(this.options.items, this.element), this]];
var connectwith = this._connectwith();
if(connectwith) {
for (var i = connectwith.length - 1; i >= 0; i--){
var cur = $(connectwith[i]);
for (var j = cur.length - 1; j >= 0; j--){
var inst = $.data(cur[j], 'sortable');
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isfunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentitem }) : $(inst.options.items, inst.element), inst]);
this.containers.push(inst);
}
};
};
}
for (var i = queries.length - 1; i >= 0; i--) {
var targetdata = queries[i][1];
var _queries = queries[i][0];
for (var j=0, querieslength = _queries.length; j < querieslength; j++) {
var item = $(_queries[j]);
item.data('sortable-item', targetdata); // data for target checking (mouse manager)
items.push({
item: item,
instance: targetdata,
width: 0, height: 0,
left: 0, top: 0
});
};
};
},
refreshpositions: function(fast) {
//this has to be redone because due to the item being moved out/into the offsetparent, the offsetparent's position will change
if(this.offsetparent && this.helper) {
this.offset.parent = this._getparentoffset();
}
for (var i = this.items.length - 1; i >= 0; i--){
var item = this.items[i];
//we ignore calculating positions of all connected containers when we're not over them
if(item.instance != this.currentcontainer && this.currentcontainer && item.item[0] != this.currentitem[0])
continue;
var t = this.options.toleranceelement ? $(this.options.toleranceelement, item.item) : item.item;
if (!fast) {
item.width = t.outerwidth();
item.height = t.outerheight();
}
var p = t.offset();
item.left = p.left;
item.top = p.top;
};
if(this.options.custom && this.options.custom.refreshcontainers) {
this.options.custom.refreshcontainers.call(this);
} else {
for (var i = this.containers.length - 1; i >= 0; i--){
var p = this.containers[i].element.offset();
this.containers[i].containercache.left = p.left;
this.containers[i].containercache.top = p.top;
this.containers[i].containercache.width = this.containers[i].element.outerwidth();
this.containers[i].containercache.height = this.containers[i].element.outerheight();
};
}
},
_createplaceholder: function(that) {
var self = that || this, o = self.options;
if(!o.placeholder || o.placeholder.constructor == string) {
var classname = o.placeholder;
o.placeholder = {
element: function() {
var el = $(document.createelement(self.currentitem[0].nodename))
.addclass(classname || self.currentitem[0].classname+" ui-sortable-placeholder")
.removeclass("ui-sortable-helper")[0];
if(!classname)
el.style.visibility = "hidden";
return el;
},
update: function(container, p) {
// 1. if a classname is set as 'placeholder option, we don't force sizes - the class is responsible for that
// 2. the option 'forceplaceholdersize can be enabled to force it even if a class name is specified
if(classname && !o.forceplaceholdersize) return;
//if the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
if(!p.height()) { p.height(self.currentitem.innerheight() - parseint(self.currentitem.css('paddingtop')||0, 10) - parseint(self.currentitem.css('paddingbottom')||0, 10)); };
if(!p.width()) { p.width(self.currentitem.innerwidth() - parseint(self.currentitem.css('paddingleft')||0, 10) - parseint(self.currentitem.css('paddingright')||0, 10)); };
}
};
}
//create the placeholder
self.placeholder = $(o.placeholder.element.call(self.element, self.currentitem));
//append it after the actual current item
self.currentitem.after(self.placeholder);
//update the size of the placeholder (todo: logic to fuzzy, see line 316/317)
o.placeholder.update(self, self.placeholder);
},
_contactcontainers: function(event) {
for (var i = this.containers.length - 1; i >= 0; i--){
if(this._intersectswith(this.containers[i].containercache)) {
if(!this.containers[i].containercache.over) {
if(this.currentcontainer != this.containers[i]) {
//when entering a new container, we will find the item with the least distance and append our item near it
var dist = 10000; var itemwithleastdistance = null; var base = this.positionabs[this.containers[i].floating ? 'left' : 'top'];
for (var j = this.items.length - 1; j >= 0; j--) {
if(!$.ui.contains(this.containers[i].element[0], this.items[j].item[0])) continue;
var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];
if(math.abs(cur - base) < dist) {
dist = math.abs(cur - base); itemwithleastdistance = this.items[j];
}
}
if(!itemwithleastdistance && !this.options.droponempty) //check if droponempty is enabled
continue;
this.currentcontainer = this.containers[i];
itemwithleastdistance ? this._rearrange(event, itemwithleastdistance, null, true) : this._rearrange(event, null, this.containers[i].element, true);
this._trigger("change", event, this._uihash());
this.containers[i]._trigger("change", event, this._uihash(this));
//update the placeholder
this.options.placeholder.update(this.currentcontainer, this.placeholder);
}
this.containers[i]._trigger("over", event, this._uihash(this));
this.containers[i].containercache.over = 1;
}
} else {
if(this.containers[i].containercache.over) {
this.containers[i]._trigger("out", event, this._uihash(this));
this.containers[i].containercache.over = 0;
}
}
};
},
_createhelper: function(event) {
var o = this.options;
var helper = $.isfunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentitem])) : (o.helper == 'clone' ? this.currentitem.clone() : this.currentitem);
if(!helper.parents('body').length) //add the helper to the dom if that didn't happen already
$(o.appendto != 'parent' ? o.appendto : this.currentitem[0].parentnode)[0].appendchild(helper[0]);
if(helper[0] == this.currentitem[0])
this._storedcss = { width: this.currentitem[0].style.width, height: this.currentitem[0].style.height, position: this.currentitem.css("position"), top: this.currentitem.css("top"), left: this.currentitem.css("left") };
if(helper[0].style.width == '' || o.forcehelpersize) helper.width(this.currentitem.width());
if(helper[0].style.height == '' || o.forcehelpersize) helper.height(this.currentitem.height());
return helper;
},
_adjustoffsetfromhelper: function(obj) {
if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
if(obj.right != undefined) this.offset.click.left = this.helperproportions.width - obj.right + this.margins.left;
if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
if(obj.bottom != undefined) this.offset.click.top = this.helperproportions.height - obj.bottom + this.margins.top;
},
_getparentoffset: function() {
//get the offsetparent and cache its position
this.offsetparent = this.helper.offsetparent();
var po = this.offsetparent.offset();
// this is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. the position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. the actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
if(this.cssposition == 'absolute' && this.scrollparent[0] != document && $.ui.contains(this.scrollparent[0], this.offsetparent[0])) {
po.left += this.scrollparent.scrollleft();
po.top += this.scrollparent.scrolltop();
}
if((this.offsetparent[0] == document.body) //this needs to be actually done for all browsers, since pagex/pagey includes this information
|| (this.offsetparent[0].tagname && this.offsetparent[0].tagname.tolowercase() == 'html' && $.browser.msie)) //ugly ie fix
po = { top: 0, left: 0 };
return {
top: po.top + (parseint(this.offsetparent.css("bordertopwidth"),10) || 0),
left: po.left + (parseint(this.offsetparent.css("borderleftwidth"),10) || 0)
};
},
_getrelativeoffset: function() {
if(this.cssposition == "relative") {
var p = this.currentitem.position();
return {
top: p.top - (parseint(this.helper.css("top"),10) || 0) + this.scrollparent.scrolltop(),
left: p.left - (parseint(this.helper.css("left"),10) || 0) + this.scrollparent.scrollleft()
};
} else {
return { top: 0, left: 0 };
}
},
_cachemargins: function() {
this.margins = {
left: (parseint(this.currentitem.css("marginleft"),10) || 0),
top: (parseint(this.currentitem.css("margintop"),10) || 0)
};
},
_cachehelperproportions: function() {
this.helperproportions = {
width: this.helper.outerwidth(),
height: this.helper.outerheight()
};
},
_setcontainment: function() {
var o = this.options;
if(o.containment == 'parent') o.containment = this.helper[0].parentnode;
if(o.containment == 'document' || o.containment == 'window') this.containment = [
0 - this.offset.relative.left - this.offset.parent.left,
0 - this.offset.relative.top - this.offset.parent.top,
$(o.containment == 'document' ? document : window).width() - this.helperproportions.width - this.margins.left,
($(o.containment == 'document' ? document : window).height() || document.body.parentnode.scrollheight) - this.helperproportions.height - this.margins.top
];
if(!(/^(document|window|parent)$/).test(o.containment)) {
var ce = $(o.containment)[0];
var co = $(o.containment).offset();
var over = ($(ce).css("overflow") != 'hidden');
this.containment = [
co.left + (parseint($(ce).css("borderleftwidth"),10) || 0) + (parseint($(ce).css("paddingleft"),10) || 0) - this.margins.left,
co.top + (parseint($(ce).css("bordertopwidth"),10) || 0) + (parseint($(ce).css("paddingtop"),10) || 0) - this.margins.top,
co.left+(over ? math.max(ce.scrollwidth,ce.offsetwidth) : ce.offsetwidth) - (parseint($(ce).css("borderleftwidth"),10) || 0) - (parseint($(ce).css("paddingright"),10) || 0) - this.helperproportions.width - this.margins.left,
co.top+(over ? math.max(ce.scrollheight,ce.offsetheight) : ce.offsetheight) - (parseint($(ce).css("bordertopwidth"),10) || 0) - (parseint($(ce).css("paddingbottom"),10) || 0) - this.helperproportions.height - this.margins.top
];
}
},
_convertpositionto: function(d, pos) {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
var o = this.options, scroll = this.cssposition == 'absolute' && !(this.scrollparent[0] != document && $.ui.contains(this.scrollparent[0], this.offsetparent[0])) ? this.offsetparent : this.scrollparent, scrollisrootnode = (/(html|body)/i).test(scroll[0].tagname);
return {
top: (
pos.top // the absolute mouse position
+ this.offset.relative.top * mod // only for relative positioned nodes: relative offset from element to offset parent
+ this.offset.parent.top * mod // the offsetparent's offset without borders (offset + border)
- ($.browser.safari && this.cssposition == 'fixed' ? 0 : ( this.cssposition == 'fixed' ? -this.scrollparent.scrolltop() : ( scrollisrootnode ? 0 : scroll.scrolltop() ) ) * mod)
),
left: (
pos.left // the absolute mouse position
+ this.offset.relative.left * mod // only for relative positioned nodes: relative offset from element to offset parent
+ this.offset.parent.left * mod // the offsetparent's offset without borders (offset + border)
- ($.browser.safari && this.cssposition == 'fixed' ? 0 : ( this.cssposition == 'fixed' ? -this.scrollparent.scrollleft() : scrollisrootnode ? 0 : scroll.scrollleft() ) * mod)
)
};
},
_generateposition: function(event) {
var o = this.options, scroll = this.cssposition == 'absolute' && !(this.scrollparent[0] != document && $.ui.contains(this.scrollparent[0], this.offsetparent[0])) ? this.offsetparent : this.scrollparent, scrollisrootnode = (/(html|body)/i).test(scroll[0].tagname);
// this is another very weird special case that only happens for relative elements:
// 1. if the css position is relative
// 2. and the scroll parent is the document or similar to the offset parent
// we have to refresh the relative offset during the scroll so there are no jumps
if(this.cssposition == 'relative' && !(this.scrollparent[0] != document && this.scrollparent[0] != this.offsetparent[0])) {
this.offset.relative = this._getrelativeoffset();
}
var pagex = event.pagex;
var pagey = event.pagey;
/*
* - position constraining -
* constrain the position to a mix of grid, containment.
*/
if(this.originalposition) { //if we are not dragging yet, we won't check for options
if(this.containment) {
if(event.pagex - this.offset.click.left < this.containment[0]) pagex = this.containment[0] + this.offset.click.left;
if(event.pagey - this.offset.click.top < this.containment[1]) pagey = this.containment[1] + this.offset.click.top;
if(event.pagex - this.offset.click.left > this.containment[2]) pagex = this.containment[2] + this.offset.click.left;
if(event.pagey - this.offset.click.top > this.containment[3]) pagey = this.containment[3] + this.offset.click.top;
}
if(o.grid) {
var top = this.originalpagey + math.round((pagey - this.originalpagey) / o.grid[1]) * o.grid[1];
pagey = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
var left = this.originalpagex + math.round((pagex - this.originalpagex) / o.grid[0]) * o.grid[0];
pagex = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
}
}
return {
top: (
pagey // the absolute mouse position
- this.offset.click.top // click offset (relative to the element)
- this.offset.relative.top // only for relative positioned nodes: relative offset from element to offset parent
- this.offset.parent.top // the offsetparent's offset without borders (offset + border)
+ ($.browser.safari && this.cssposition == 'fixed' ? 0 : ( this.cssposition == 'fixed' ? -this.scrollparent.scrolltop() : ( scrollisrootnode ? 0 : scroll.scrolltop() ) ))
),
left: (
pagex // the absolute mouse position
- this.offset.click.left // click offset (relative to the element)
- this.offset.relative.left // only for relative positioned nodes: relative offset from element to offset parent
- this.offset.parent.left // the offsetparent's offset without borders (offset + border)
+ ($.browser.safari && this.cssposition == 'fixed' ? 0 : ( this.cssposition == 'fixed' ? -this.scrollparent.scrollleft() : scrollisrootnode ? 0 : scroll.scrollleft() ))
)
};
},
_rearrange: function(event, i, a, hardrefresh) {
a ? a[0].appendchild(this.placeholder[0]) : i.item[0].parentnode.insertbefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextsibling));
//various things done here to improve the performance:
// 1. we create a settimeout, that calls refreshpositions
// 2. on the instance, we have a counter variable, that get's higher after every append
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
// 4. this lets only the last addition to the timeout stack through
this.counter = this.counter ? ++this.counter : 1;
var self = this, counter = this.counter;
window.settimeout(function() {
if(counter == self.counter) self.refreshpositions(!hardrefresh); //precompute after each dom insertion, not on mousemove
},0);
},
_clear: function(event, nopropagation) {
this.reverting = false;
// we delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
var delayedtriggers = [], self = this;
// we first have to update the dom position of the actual currentitem
// note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
if(!this._nofinalsort && this.currentitem[0].parentnode) this.placeholder.before(this.currentitem);
this._nofinalsort = null;
if(this.helper[0] == this.currentitem[0]) {
for(var i in this._storedcss) {
if(this._storedcss[i] == 'auto' || this._storedcss[i] == 'static') this._storedcss[i] = '';
}
this.currentitem.css(this._storedcss).removeclass("ui-sortable-helper");
} else {
this.currentitem.show();
}
if(this.fromoutside && !nopropagation) delayedtriggers.push(function(event) { this._trigger("receive", event, this._uihash(this.fromoutside)); });
if((this.fromoutside || this.domposition.prev != this.currentitem.prev().not(".ui-sortable-helper")[0] || this.domposition.parent != this.currentitem.parent()[0]) && !nopropagation) delayedtriggers.push(function(event) { this._trigger("update", event, this._uihash()); }); //trigger update callback if the dom position has changed
if(!$.ui.contains(this.element[0], this.currentitem[0])) { //node was moved out of the current element
if(!nopropagation) delayedtriggers.push(function(event) { this._trigger("remove", event, this._uihash()); });
for (var i = this.containers.length - 1; i >= 0; i--){
if($.ui.contains(this.containers[i].element[0], this.currentitem[0]) && !nopropagation) {
delayedtriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uihash(this)); }; }).call(this, this.containers[i]));
delayedtriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uihash(this)); }; }).call(this, this.containers[i]));
}
};
};
//post events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
if(!nopropagation) delayedtriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uihash(this)); }; }).call(this, this.containers[i]));
if(this.containers[i].containercache.over) {
delayedtriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uihash(this)); }; }).call(this, this.containers[i]));
this.containers[i].containercache.over = 0;
}
}
//do what was originally in plugins
if(this._storedcursor) $('body').css("cursor", this._storedcursor); //reset cursor
if(this._storedopacity) this.helper.css("opacity", this._storedopacity); //reset cursor
if(this._storedzindex) this.helper.css("zindex", this._storedzindex == 'auto' ? '' : this._storedzindex); //reset z-index
this.dragging = false;
if(this.cancelhelperremoval) {
if(!nopropagation) {
this._trigger("beforestop", event, this._uihash());
for (var i=0; i < delayedtriggers.length; i++) { delayedtriggers[i].call(this, event); }; //trigger all delayed events
this._trigger("stop", event, this._uihash());
}
return false;
}
if(!nopropagation) this._trigger("beforestop", event, this._uihash());
//$(this.placeholder[0]).remove(); would have been the jquery way - unfortunately, it unbinds all events from the original node!
this.placeholder[0].parentnode.removechild(this.placeholder[0]);
if(this.helper[0] != this.currentitem[0]) this.helper.remove(); this.helper = null;
if(!nopropagation) {
for (var i=0; i < delayedtriggers.length; i++) { delayedtriggers[i].call(this, event); }; //trigger all delayed events
this._trigger("stop", event, this._uihash());
}
this.fromoutside = false;
return true;
},
_trigger: function() {
if ($.widget.prototype._trigger.apply(this, arguments) === false) {
this.cancel();
}
},
_uihash: function(inst) {
var self = inst || this;
return {
helper: self.helper,
placeholder: self.placeholder || $([]),
position: self.position,
absoluteposition: self.positionabs, //deprecated
offset: self.positionabs,
item: self.currentitem,
sender: inst ? inst.element : null
};
}
}));
$.extend($.ui.sortable, {
getter: "serialize toarray",
version: "1.7.1",
eventprefix: "sort",
defaults: {
appendto: "parent",
axis: false,
cancel: ":input,option",
connectwith: false,
containment: false,
cursor: 'auto',
cursorat: false,
delay: 0,
distance: 1,
droponempty: true,
forceplaceholdersize: false,
forcehelpersize: false,
grid: false,
handle: false,
helper: "original",
items: '> *',
opacity: false,
placeholder: false,
revert: false,
scroll: true,
scrollsensitivity: 20,
scrollspeed: 20,
scope: "default",
tolerance: "intersect",
zindex: 1000
}
});
})(jquery);
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery对表格标题排序
jquery实现根据中文表格排序
以上就是jquery鼠标拖动table进行排序(附代码)的详细内容。
