Skip to content

Commit

Permalink
fixed #196
Browse files Browse the repository at this point in the history
  • Loading branch information
Atanas Atanasov committed Nov 19, 2017
1 parent da0977d commit 85b56be
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 32 deletions.
32 changes: 22 additions & 10 deletions dist/combined/js/gijgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10606,7 +10606,7 @@ gj.tree.plugins.checkboxes = {
/** This setting enable cascade check and uncheck of children
* @type boolean
* @default true
* @example False <!-- materialicons, checkbox, tree.base -->
* @example False.Remote.DataSource <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
* var tree = $('#tree').tree({
Expand All @@ -10618,6 +10618,15 @@ gj.tree.plugins.checkboxes = {
* tree.expandAll();
* });
* </script>
* @example False.Local.DataSource <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
* var tree = $('#tree').tree({
* checkboxes: true,
* dataSource: [ { text: 'foo', checked: true, children: [ { text: 'bar', checked: true }, { text: 'bar2', checked: false } ] }, { text: 'foo2', checked: true, children: [ { text: 'bar2', checked: false } ] } ],
* cascadeCheck: false
* });
* </script>
* @example True <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
Expand All @@ -10637,15 +10646,18 @@ gj.tree.plugins.checkboxes = {

private: {
dataBound: function ($tree) {
var $nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
var $nodes;
if ($tree.data('cascadeCheck')) {
$nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
}
},

nodeDataBound: function ($tree, $node, id, record) {
Expand Down
2 changes: 1 addition & 1 deletion dist/combined/js/gijgo.min.js

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dist/modular/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,15 +816,18 @@ gj.tree.widget.constructor = gj.tree.widget;

private: {
dataBound: function ($tree) {
var $nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
var $nodes;
if ($tree.data('cascadeCheck')) {
$nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
}
},

nodeDataBound: function ($tree, $node, id, record) {
Expand Down
2 changes: 1 addition & 1 deletion dist/modular/js/tree.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="../../dist/modular/js/core.js" type="text/javascript"></script>
<link href="../../dist/modular/css/core.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
<link href="../../dist/modular/css/checkbox.css" rel="stylesheet" type="text/css">
<link href="../../dist/modular/css/tree.css" rel="stylesheet" type="text/css">
<script src="../../dist/modular/js/checkbox.js"></script>
<script src="../../dist/modular/js/tree.js"></script>
</head>
<body style="padding: 6px;">
<div id="tree"></div>
<script>
var tree = $('#tree').tree({
checkboxes: true,
dataSource: [ { text: 'foo', checked: true, children: [ { text: 'bar', checked: true }, { text: 'bar2', checked: false } ] }, { text: 'foo2', checked: true, children: [ { text: 'bar2', checked: false } ] } ],
cascadeCheck: false
});
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion examples/tree/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
<li><a href="Tree.Checkboxes.checkboxes.Bootstrap.html">Tree.Checkboxes.checkboxes.Bootstrap</a></li>
<li><a href="Tree.Checkboxes.checkboxes.Material.Design.html">Tree.Checkboxes.checkboxes.Material.Design</a></li>
<li><a href="Tree.Checkboxes.checkedField.Custom.Name.html">Tree.Checkboxes.checkedField.Custom.Name</a></li>
<li><a href="Tree.Checkboxes.cascadeCheck.False.html">Tree.Checkboxes.cascadeCheck.False</a></li>
<li><a href="Tree.Checkboxes.cascadeCheck.False.Remote.DataSource.html">Tree.Checkboxes.cascadeCheck.False.Remote.DataSource</a></li>
<li><a href="Tree.Checkboxes.cascadeCheck.False.Local.DataSource.html">Tree.Checkboxes.cascadeCheck.False.Local.DataSource</a></li>
<li><a href="Tree.Checkboxes.cascadeCheck.True.html">Tree.Checkboxes.cascadeCheck.True</a></li>
<li><a href="Tree.Checkboxes.getCheckedNodes.Base.Theme.html">Tree.Checkboxes.getCheckedNodes.Base.Theme</a></li>
<li><a href="Tree.Checkboxes.checkAll.Sample.html">Tree.Checkboxes.checkAll.Sample</a></li>
Expand Down
32 changes: 22 additions & 10 deletions src/tree/js/tree.checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ gj.tree.plugins.checkboxes = {
/** This setting enable cascade check and uncheck of children
* @type boolean
* @default true
* @example False <!-- materialicons, checkbox, tree.base -->
* @example False.Remote.DataSource <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
* var tree = $('#tree').tree({
Expand All @@ -65,6 +65,15 @@ gj.tree.plugins.checkboxes = {
* tree.expandAll();
* });
* </script>
* @example False.Local.DataSource <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
* var tree = $('#tree').tree({
* checkboxes: true,
* dataSource: [ { text: 'foo', checked: true, children: [ { text: 'bar', checked: true }, { text: 'bar2', checked: false } ] }, { text: 'foo2', checked: true, children: [ { text: 'bar2', checked: false } ] } ],
* cascadeCheck: false
* });
* </script>
* @example True <!-- materialicons, checkbox, tree.base -->
* <div id="tree"></div>
* <script>
Expand All @@ -84,15 +93,18 @@ gj.tree.plugins.checkboxes = {

private: {
dataBound: function ($tree) {
var $nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
var $nodes;
if ($tree.data('cascadeCheck')) {
$nodes = $tree.find('li[data-role="node"]');
$.each($nodes, function () {
var $node = $(this),
state = $node.find('[data-role="checkbox"] input[type="checkbox"]').checkbox('state');
if (state === 'checked') {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
});
}
},

nodeDataBound: function ($tree, $node, id, record) {
Expand Down

0 comments on commit 85b56be

Please sign in to comment.