bootstrap-treeview.html

386 lines | 12.367 kB Blame History Raw Download
<!DOCTYPE html>
<!--[if IE 9]><html lang="en-us" class="ie9"><![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en-us">
<!--<![endif]-->
  <head>
    <title>Bootstrap Tree View - Red Hat&reg; Common User Experience</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/img/favicon.ico">
    <!-- iPad retina icon -->
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="/img/apple-touch-icon-precomposed-152.png">
    <!-- iPad retina icon (iOS < 7) -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/img/apple-touch-icon-precomposed-144.png">
    <!-- iPad non-retina icon -->
    <link rel="apple-touch-icon-precomposed" sizes="76x76" href="/img/apple-touch-icon-precomposed-76.png">
    <!-- iPad non-retina icon (iOS < 7) -->
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/apple-touch-icon-precomposed-72.png">
    <!-- iPhone 6 Plus icon -->
    <link rel="apple-touch-icon-precomposed" sizes="120x120" href="/img/apple-touch-icon-precomposed-180.png">
    <!-- iPhone retina icon (iOS < 7) -->
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/apple-touch-icon-precomposed-114.png">
    <!-- iPhone non-retina icon (iOS < 7) -->
    <link rel="apple-touch-icon-precomposed" sizes="57x57" href="/img/apple-touch-icon-precomposed-57.png">
    <link rel="stylesheet" href="../dist/css/rcue.min.css" >
    <link rel="stylesheet" href="../dist/css/rcue-additions.min.css" >
      <link href="tests.css" rel="stylesheet" media="screen, print">
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="//rawgit.com/patternfly/patternfly-bootstrap-treeview/v2.1.3/dist/bootstrap-treeview.min.js"></script>
    <script src="../components/patternfly/dist/js/patternfly.min.js"></script>
  </head>

  <body>
    <div class="container">
      <div class="page-header">
        <h1>Bootstrap Tree View</h1>
      </div>
      <div class="alert alert-warning">
        <span class="pficon pficon-warning-triangle-o"></span>
        These examples are included for development testing purposes.  For official documentation, see <a href="https://www.patternfly.org" class="alert-link">https://www.patternfly.org</a>, <a href="http://getbootstrap.com" class="alert-link">http://getbootstrap.com</a>, and <a href="https://github.com/patternfly/patternfly-bootstrap-treeview">https://github.com/patternfly/patternfly-bootstrap-treeview</a>.
      </div>
      <hr>
      <div class="row">
        <div class="col-sm-4">
          <h2>Default</h2>
          <div id="treeview1"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Collapsed</h2>
          <div id="treeview2"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Expanded</h2>
          <div id="treeview3"></div>
        </div><!--/col-->
      </div><!--/row-->
      <div class="row">
        <div class="col-sm-4">
          <h2>Link enabled</h2>
          <div id="treeview4"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Events</h2>
          <div id="treeview5"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Output</h2>
          <div id="event_output"></div>
        </div><!--/col-->
      </div><!--/row-->
      <div class="row">
        <div class="col-sm-4">
          <h2>JSON Data</h2>
          <div id="treeview6"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Checkboxes</h2>
          <div id="treeview7"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Hierarchal Checks</h2>
          <div id="treeview8"></div>
        </div><!--/col-->
      </div><!--/row-->
      <div class="row">
        <div class="col-sm-4">
          <h2>Highlight Select</h2>
          <div id="treeview9"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Lazy Load</h2>
          <div id="treeview10"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Hover and Select</h2>
          <div id="treeview13" class="treeview-pf-hover treeview-pf-select"></div>
        </div><!--/col-->
      </div>
      <div class="row">
        <div class="col-sm-4">
          <h2>Prevent Unselection</h2>
          <div id="treeview11" class="treeview-pf-select"></div>
        </div><!--/col-->
        <div class="col-sm-4">
          <h2>Disabled Nodes</h2>
          <div id="treeview12"></div>
        </div><!--/col-->
      </div><!--/row-->
      <script>
        $(function() {
          //icon options
          var collapseIcon = "fa fa-angle-down",
            expandIcon = "fa fa-angle-right",
            nodeIcon = "fa fa-folder",
            checkedIcon = "fa fa-check-square-o",
            uncheckedIcon = "fa fa-square-o",
            partiallyCheckedIcon = "fa fa-check-square",
            loadingIcon = "glyphicon glyphicon-hourglass";

          var defaultData = [
            {
              text: 'Parent 1',
              href: '#parent1',
              tags: ['4'],
              nodes: [
                {
                  text: 'Child 1',
                  href: '#child1',
                  tags: ['2'],
                  nodes: [
                    {
                      text: 'Grandchild 1',
                      href: '#grandchild1',
                      icon: 'fa fa-file-o',
                      tags: ['0']
                    },
                    {
                      text: 'Grandchild 2',
                      href: '#grandchild2',
                      icon: 'fa fa-file-o',
                      tags: ['0']
                    }
                  ]
                },
                {
                  text: 'Child 2',
                  href: '#child2',
                  icon: 'fa fa-file-o',
                  tags: ['0']
                }
              ]
            },
            {
              text: 'Parent 2',
              href: '#parent2',
              tags: ['0']
            },
            {
              text: 'Parent 3',
              href: '#parent3',
               tags: ['0']
            },
            {
              text: 'Parent 4',
              href: '#parent4',
              tags: ['0']
            },
            {
              text: 'Parent 5',
              href: '#parent5'  ,
              tags: ['0']
            }
          ];
          var json = '[' +
            '{' +
              '"text": "Parent 1",' +
              '"lazyLoad": true,' +
              '"nodes": [' +
                '{' +
                  '"text": "Child 1",' +
                  '"lazyLoad": true,' +
                  '"nodes": [' +
                    '{' +
                      '"icon": "fa fa-file-o",' +
                      '"text": "Grandchild 1"' +
                    '},' +
                    '{' +
                      '"icon": "fa fa-file-o",' +
                      '"text": "Grandchild 2"' +
                    '}' +
                  ']' +
                '},' +
                '{' +
                  '"icon": "fa fa-file-o",' +
                  '"text": "Child 2"' +
                '}' +
              ']' +
            '},' +
            '{' +
              '"text": "Parent 2"' +
            '},' +
            '{' +
              '"text": "Parent 3"' +
            '},' +
            '{' +
              '"text": "Parent 4"' +
            '},' +
            '{' +
              '"text": "Parent 5"' +
            '}' +
          ']';

          //Default
          $('#treeview1').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            expandIcon: expandIcon,
            nodeIcon: nodeIcon,
            showBorder: false
          });

          //Collapsed
          $('#treeview2').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            expandIcon: expandIcon,
            levels: 1,
            nodeIcon: nodeIcon,
            showBorder: false
          });

          //Expanded
          $('#treeview3').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false
          });

          //Link Enabled
          $('#treeview4').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            enableLinks: true,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false
          });

          //Events
          $('#treeview5').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false,
            onNodeSelected: function(event, node) {
              $('#event_output').prepend('<p>You clicked ' + node.text + '</p>');
            }
          });

          //JSON Data
          $('#treeview6').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false
          });

          //Checkboxes
          $('#treeview7').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            checkedIcon: checkedIcon,
            uncheckedIcon: uncheckedIcon,
            partiallyCheckedIcon: partiallyCheckedIcon,
            showBorder: false,
            showCheckbox: true,
            checkboxFirst: true,
            wrapNodeText: true
          });

          //Hierarchal Checks
          $('#treeview8').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            checkedIcon: checkedIcon,
            uncheckedIcon: uncheckedIcon,
            partiallyCheckedIcon: partiallyCheckedIcon,
            showBorder: false,
            showCheckbox: true,
            hierarchicalCheck: true,
            checkboxFirst: true,
            wrapNodeText: true
          });

          //Highlight Select
          $('#treeview9').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            checkedIcon: checkedIcon,
            uncheckedIcon: uncheckedIcon,
            partiallyCheckedIcon: partiallyCheckedIcon,
            showBorder: false,
            showCheckbox: true,
            hierarchicalCheck: true,
            checkboxFirst: true,
            wrapNodeText: true,
            highlightChanges: true,
            changedNodeColor: $.pfPaletteColors.black900
          });

          //Lazy Load
          $('#treeview10').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 1,
            nodeIcon: nodeIcon,
            showBorder: false,
            wrapNodeText: true,
            loadingIcon: loadingIcon,
            lazyLoad: function(node, callback){
              setTimeout(function() {
                callback([]);
              }, 2000);
            }
          });

          //Prevent Unselection
          $('#treeview11').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false,
            preventUnselect: true
          });

          //Disabled Nodes
          var tree12 = $('#treeview12').treeview({
            collapseIcon: collapseIcon,
            data: json,
            expandIcon: expandIcon,
            levels: 99,
            nodeIcon: nodeIcon,
            showBorder: false,
            onInitialized: function() {
              tree12.treeview('disableAll');
            }
          });

          //Hover and Select
          $('#treeview13').treeview({
            collapseIcon: collapseIcon,
            data: defaultData,
            expandIcon: expandIcon,
            nodeIcon: nodeIcon,
            showBorder: false
          });

        });
      </script>

    </div><!-- /container -->
  </body>
</html>