Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

add new option for support auto-collapse on itemNode. #179

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ These advanced config options are also available:
* `emptyClass` The class used for empty list placeholder elements (default `'dd-empty'`)
* `expandBtnHTML` The HTML text used to generate a list item expand button (default `'<button data-action="expand">Expand></button>'`)
* `collapseBtnHTML` The HTML text used to generate a list item collapse button (default `'<button data-action="collapse">Collapse</button>'`)
* `autoCollapseClass` The class applied to list item element which will auto collapse others item when click "expandBtn" (default `'dd-auto-collapsed'`)

**Inspect the [Nestable Demo](http://dbushell.github.com/Nestable/) for guidance.**

## Change Log
### 10th October 2015
* support auto-collapse on itemNode. auto collapse others itemNode.

### 15th October 2012

Expand Down
15 changes: 14 additions & 1 deletion jquery.nestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>',
group : 0,
maxDepth : 5,
threshold : 20
threshold : 20,
autoCollapseClass : 'dd-auto-collapse'
};

function Plugin(element, options)
Expand Down Expand Up @@ -202,6 +203,18 @@
li.children('[data-action="expand"]').hide();
li.children('[data-action="collapse"]').show();
li.children(this.options.listNodeName).show();

var autoCollapse = li.hasClass(this.options.autoCollapseClass);
if(autoCollapse) {
var neiphbors = li.siblings().not(li).not('.dd-collapsed');
var listNodeName = this.options.listNodeName;
neiphbors.addClass(this.options.collapsedClass);
neiphbors.each(function(){
$(this).children('[data-action="collapse"]').hide();
$(this).children('[data-action="expand"]').show();
$(this).children(listNodeName).hide();
});
}
},

collapseItem: function(li)
Expand Down
15 changes: 15 additions & 0 deletions jquery.nestable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.