Skip to content

Commit c07e515

Browse files
committed
new markdown README
2 parents 22cdadd + 9837d17 commit c07e515

File tree

3 files changed

+205
-71
lines changed

3 files changed

+205
-71
lines changed

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# nestedSortable jQuery plugin
2+
3+
*nestedSortable* is a jQuery plugin that extends jQuery Sortable UI functionalities to nested lists.
4+
5+
## Features
6+
7+
- Designed to work seamlessly with the [nested](http://articles.sitepoint.com/article/hierarchical-data-database "A Sitepoint tutorial on PHP, MYSQL and nested sets") [set](http://en.wikipedia.org/wiki/Nested_set_model "Wikipedia article on nested sets") model (have a look at the `toArray` method)
8+
- Items can be sorted in their own list, moved across the tree, or nested under other items.
9+
- Sublists are created and deleted on the fly
10+
- All jQuery Sortable options, events and methods are available
11+
- It is possible to define elements that will not accept a new nested item/list
12+
- It is possible to define a maximum depth for nested items
13+
14+
## Usage
15+
16+
```
17+
<ol class="sortable">
18+
<li><div>Some content</div></li>
19+
<li>
20+
<div>Some content</div>
21+
<ol>
22+
<li><div>Some sub-item content</div></li>
23+
<li><div>Some sub-item content</div></li>
24+
</ol>
25+
</li>
26+
<li><div>Some content</div></li>
27+
</ol>
28+
```
29+
30+
Please note: every `<li>` must have either one or two direct children, the first one being a container element (such as `<div>` in the above example), and the (optional) second one being the nested list. The container element has to be set as the 'toleranceElement' in the options, and this, or one of its children, as the 'handle'.
31+
32+
## Custom Options
33+
34+
<dl>
35+
<dt>tabSize</dt>
36+
<dd>How far right or left (in pixels) the item has to travel in order to be nested or to be sent outside its current list. Default: <b>20</b></dd>
37+
<dt>disableNesting </dt>
38+
<dd>The class name of the items that will not accept nested lists. Default: <b>ui-nestedSortable-no-nesting</b></dd>
39+
<dt>errorClass </dt>
40+
<dd>The class given to the placeholder in case of error. Default: <b>ui-nestedSortable-error</b></dd>
41+
<dt>listType </dt>
42+
<dd>The list type used (ordered or unordered). Default: <b>ol</b></dd>
43+
<dt>maxLevels </dt>
44+
<dd>The maximum depth of nested items the list can accept. If set to '0' the levels are unlimited. Default: <b>0</b></dd>
45+
</dl>
46+
47+
## Custom Methods
48+
49+
<dl>
50+
<dt>serialize</dt>
51+
<dd>Serializes the nested list into a string like <b>setName[item1Id]=parentId&setName[item2Id]=parentId</b>, reading from each item's id formatted as 'setName_itemId' (where itemId is a number).
52+
It accepts the same options as the original Sortable method (<b>key</b>, <b>attribute</b> and <b>expression</b>).</dd>
53+
<dt>toArray</dt>
54+
<dd>Builds an array where each element is in the form:
55+
<pre>setName[n] =>
56+
{
57+
'item_id': itemId,
58+
'parent_id': parentId,
59+
'depth': depth,
60+
'left': left,
61+
'right': right,
62+
}
63+
</pre>
64+
It accepts the same options as the original Sortable method (<b>attribute</b> and <b>expression</b>) plus the custom <b>startDepthCount</b>, that sets the starting depth number (default is <b>0</b>).</dd>
65+
<dt>toHierarchy</dt>
66+
<dd>Builds a hierarchical object in the form:
67+
<pre>'0' ...
68+
'id' => itemId
69+
'1' ...
70+
'id' => itemId
71+
'children' ...
72+
'0' ...
73+
'id' => itemId
74+
'1' ...
75+
'id' => itemId
76+
'2' ...
77+
'id' => itemId
78+
</pre>
79+
Similarly to <code>toArray</code>, it accepts <b>attribute</b> and <b>expression</b> options.</dd>
80+
</dl>
81+
82+
## Known Bugs
83+
84+
*nestedSortable* doesn't work properly with connected draggables, because of the way Draggable simulates Sortable `mouseStart` and `mouseStop` events. This bug might or might not be fixed some time in the future (it's not specific to this plugin).
85+
86+
## Requirements
87+
88+
jQuery 1.4+
89+
jQuery UI Sortable 1.8+
90+
91+
## Browser Compatibility
92+
93+
Tested with: IE 6/7/8, Firefox 3.6/4, Chrome, Safari 3
94+
95+
## License
96+
97+
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
98+
99+
This work is *pizzaware*. If it saved your life, or you just feel good at heart, please consider offering me a pizza. This can be done in two ways: (1) use the Paypal button at the bottom of the project's [home page](http://mjsarfatti.com/sandbox/nestedSortable); (2) send me cash via traditional mail to my home address in Italy. Is the second method legal? It is in Italy if you use Posta assicurata. You should check with your local laws if you live elsewhere.
100+

README.textile

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)