提交 62ea7b73 编写于 作者: C Catouse

* add expandSelect method to tree component.

上级 af499375
......@@ -79,8 +79,9 @@
// default options
Tree.DEFAULTS = {
animate: null,
initialState: 'normal', // 'normal' | 'preserve' | 'expand' | 'collapse',
initialState: 'normal', // 'normal' | 'preserve' | 'expand' | 'collapse', 'active',
toggleTemplate: '<i class="list-toggle icon"></i>',
// sortable: false, //
};
......@@ -257,6 +258,8 @@
this.expand();
} else if(initialState === 'collapse') {
this.collapse();
} else if (initialState === 'active') {
this.expandSelect('.active');
}
// Bind event
......@@ -294,6 +297,10 @@
}
};
Tree.prototype.expandSelect = function(selector) {
this.show(selector, true);
};
Tree.prototype.expand = function($li, disabledAnimate, notStore) {
if($li) {
$li.addClass('open');
......@@ -313,6 +320,9 @@
Tree.prototype.show = function($lis, disabledAnimate, notStore) {
var that = this;
if (!($lis instanceof $)) {
$lis = that.$.find('li').filter($lis);
}
$lis.each(function() {
var $li = $(this);
that.expand($li, disabledAnimate, notStore);
......@@ -408,4 +418,3 @@
$('[data-ride="tree"]').tree();
});
}(jQuery));
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册