-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
218 lines (170 loc) · 6.48 KB
/
index.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title>List Reorder</title>
<link rel="stylesheet" type="text/css" href="list-reorder.css"/>
</head>
<body>
<div id="wrap">
<h1>List Reorder</h1>
<p><strong>A jQuery plugin by <a href="http://www.utdallas.edu/~jrb048000/">Jordan Bach</a>.</strong></p>
<p><a href="http://www.utdallas.edu/~jrb048000/ListReorder/ListReorder.zip">Download List Reorder</a></p>
<p>List Reorder is a jQuery plugin that allows you to reorder any simple ordered or unordered
list. List Reorder is easy to use and does not require any additional markup. Its look and feel
is completely customizable using a set of CSS classes. It is distributed under the terms of the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</p>
<p>Obviously, List Reorder requires the <a href="http://jquery.com/">jQuery Javascript library</a> because it is a jQuery plugin. Additionally, it requires the <a href="http://www.jdempster.com/category/jquery/disabletextselect/">Disable Text Select plugin</a>. For your convenience, both are packaged with this plugin along with the HTML and CSS sources for this example page. To use List Reorder on your own pages, you must first include the jQuery library, the Disable Text Select plugin, the List Reorder plugin, and your custom code in that order.</p>
<!-- Example One -->
<div id="example1">
<h2>A simple example</h2>
<p>Here we make two unstyled lists reorderable. You select the list as you would select any other DOM node using jQuery's CSS selector capabilities. Also, you must specify styles for the drag handle or it will not be visible. If it is not visible, you can't reorder your list! Optionally you could set the useDefaultDragHandle option to true. Click-drag the gray box to the right of the list items to reorder the list.</p>
<div style="position:relative">
<!-- This extra div is not necessary. It's just here to test for the presence (or absence) of a positioning bug. -->
<ul id="list1">
<li>It's 2009.</li>
<li>We're gonna party...</li>
<li>...like it's 2009.</li>
<li>Yeah!</li>
</ul>
</div>
<ol id="list2">
<li>Armadillo</li>
<li>Bobcat</li>
<li>Cougar</li>
<li>Dog</li>
<li>Eagle</li>
</ol>
<h3>The Javascript Code</h3>
<pre>
$(document).ready(function() {
var unordered = $('ul#list1').ListReorder();
var ordered = $('ol').ListReorder();
});
</pre>
<strong>Use CSS to make the drag handle visible.</strong>
<pre>
.dragHandle {
display: block;
float: right;
width: 10px;
height: 10px;
border: 2px solid #06f;
background:#fff;
cursor: move;
}
</pre>
<p>* It is important to specify a background color/image for the drag handle, otherwise Internet Explorer will not detect mouseover or mouseclick events on the element.</p>
</div>
<!-- Example Two -->
<div id="example2">
<h2>Multiple Lists with Event Handling and Custom Styles</h2>
<p>In this example we override the default options so we can use our custom CSS classes. You can style the lists almost any way you want, but the list items must be arranged vertically (for now). Also notice that we're using the default dragHandle for this example.</p>
<p>Next we bind an event handler function to the "listorderchanged" event. Whenever the order of either list changes, the output in the box below the lists is updated, showing the new order. The list order is given as an array where the value for each index corresponds to the original position of that item in the list. Clicking on either of the reset buttons will restore the items in that list to their original order.</p>
<ul id="List A" class="lists">
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
<li>Item Four</li>
</ul>
<ul id="List B" class="lists">
<li>Actual</li>
<li>Bonanza</li>
<li>Come</li>
<li>Dawn</li>
</ul>
<pre id="example2out">Event Handler Output</pre>
<input type="button" value="Reset List A" />
<input type="button" value="Reset List B" />
<h3>Javascript Code</h3>
<pre>
$(document).ready(function() {
var options = {
itemHoverClass : 'myItemHover',
dragTargetClass : 'myDragTarget',
dropTargetClass : 'myDropTarget',
useDefaultDragHandle : true
};
var lists = $('.lists').ListReorder(options);
lists.bind('listorderchanged', function(evt, jqList, listOrder) {
var str = jqList.attr('id') + " order changed: \n"
+ "\tcurrent -- original\n";
for (var i = 0; i < listOrder.length; i++)
str += "\t" + i + " -- " + listOrder[i] + "\n";
$('#example2out').html(str);
});
$('#example2 input').click(function(){
if ($(this).attr('value') == 'Reset List A')
lists.get(0).restoreOrder();
else
lists.get(1).restoreOrder();
return false;
});
});
</pre>
<h3>Custom CSS Styles</h3>
<pre>
ul.lists {
list-style: none;
padding: 0;
border-left: 3px solid #06f;
border-top: 1px solid #999;
}
.lists li {
margin: 0;
padding: 10px 3px;
border: 1px solid #999;
border-top: 0;
border-left-color: #06f;
background: #f6f6f6;
}
.myItemHover {
background: #cef;
}
.myDragTarget {
background: #cef;
opacity: 0.7;
border: 2px dashed #f90;
padding: 10px 3px; /* matches '.list li' padding */
}
.lists .myDropTarget {
background: #ccc;
}
</pre>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.disable.text.select.pack.js"></script>
<script type="text/javascript" src="jquery.listreorder.js"></script>
<script type="text/javascript">
// Example One
$(document).ready(function() {
var unordered = $('ul#list1').ListReorder();
var ordered = $('ol').ListReorder();
});
// Example Two
$(document).ready(function() {
var options = {
itemHoverClass : 'myItemHover',
dragTargetClass : 'myDragTarget',
dropTargetClass : 'myDropTarget',
useDefaultDragHandle : true
};
var lists = $('.lists').ListReorder(options);
lists.bind('listorderchanged', function(evt, jqList, listOrder) {
var str = jqList.attr('id') + " order changed: <br />"
+ "\tcurrent -- original<br />";
for (var i = 0; i < listOrder.length; i++)
str += "\t" + i + " -- " + listOrder[i] + "<br />";
$('#example2out').html(str);
});
$('#example2 input').click(function(){
if ($(this).attr('value') == 'Reset List A')
lists.get(0).restoreOrder();
else
lists.get(1).restoreOrder();
return false;
});
});
</script>
</body>
</html>