1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; utf-8" />
<title>Sortables demo - Interface plugin for jQuery</title>
<script type="text/javascript" src="jQuery/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jQuery/interface 1.2/interface.js"></script>
<script type="text/javascript">
function CountClassInId(cl, objId, objClass)
{
var obj = document.getElementById(objId);
var tabDivs = obj.getElementsByTagName(objTag);
var counter = 0;
i = 0;
while (tabDivs['i'])
{
if (tabDivs[i].className == cl)
{
counter+;
}
i++;
}
return counter
}
</script>
</head>
<body>
<div id="sort1" class="groupWrapper">
<div id="newsFeeder" class="groupItem">
<div class="itemHeader">Feeds</div>
<div class="itemContent">
<p>blablabla</p>
</div>
</div>
<div id="news" class="groupItem">
<div class="itemHeader">News</div>
<div class="itemContent">
<p>blablabla</p>
</div>
</div>
</div>
<div id="sort2" class="groupWrapper" name="sort2">
<div id="shop" class="groupItem">
<div class="itemHeader">Shopping</div>
<div class="itemContent">
<p>blablabla</p>
</div>
</div>
</div>
<div id="sort3" class="groupWrapper">
<div id="links" class="groupItem">
<div class="itemHeader">Links</div>
<div class="itemContent">
<p>blablabla</p>
</div>
</div>
<div id="images" class="groupItem">
<div class="itemHeader">Images</div>
<div class="itemContent">
<p>blablabla</p>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(
function () {
$('div.groupWrapper').Sortable(
{
accept: 'groupItem',
helperclass: 'sortHelper',
activeclass : 'sortableactive',
hoverclass : 'sortablehover',
handle: 'div.itemHeader',
tolerance: 'pointer',
onChange : function(ser)
{
},
onStart : function()
{
$.iAutoscroller.start(this, document.getElementsByTagName('body'));
},
onStop : function()
{
$.iAutoscroller.stop();
}
}
);
}
);
</script>
<input type="button" onclick="alert('sort 1 => '+CountClassInId('groupItem','sort1','div'))" value="sort1" />
<input type="button" onclick="alert('sort 2 => '+CountClassInId('groupItem','sort2','div'))" value="sort2" />
<input type="button" onclick="alert('sort 3 => '+CountClassInId('groupItem','sort3','div'))" value="sort3" />
</body>
</html> |
Partager