<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="stylesheet" href="//rawgit.com/iVantage/angular-ivh-treeview/master/dist/ivh-treeview.css">
<link rel="stylesheet" href="//rawgit.com/iVantage/angular-ivh-treeview/master/dist/ivh-treeview-theme-basic.css">
</head>
<body ng-app="bin">
<div ng-controller="DemoCtrl as demo">
<h3>Custom Node Templates</h3>
<p>A custom template with some spicy ASCII checkboxes. Defined inline via the <code>ivh-treeview-node-tpl</code> attribute.</p>
<div ivh-treeview="demo.stuff"
ivh-treeview-node-tpl="demo.tpl">
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.8/angular.js"></script>
<script src="//rawgit.com/iVantage/angular-ivh-treeview/master/dist/ivh-treeview.js"></script>
</body>
</html>
.custom-control {
position: relative;
display: block;
min-height: 1.5rem;
padding-left: 1.5rem;
}
.custom-control-input {
position: absolute;
z-index: -1;
opacity: 0;
}
.custom-control-label::before {
position: absolute;
top: .25rem;
left: -1.5rem;
display: block;
width: 1rem;
height: 1rem;
pointer-events: none;
content: "";
user-select: none;
user-select: none;
user-select: none;
user-select: none;
background-color: yellow;
}
.custom-control-label::after {
position: absolute;
top: .25rem;
left: -1.5rem;
display: block;
width: 1rem;
height: 1rem;
content: "";
}
.custom-checkbox-primaryblue .custom-control-label {
outline: none;
white-space: nowrap;
position: relative;
margin-bottom: 0;
background-color: yellow;
}
.custom-control-input:checked + .custom-control-label::before {
background-color:blue;
}
var stuff = [{
label: '1',
children: [
{label: '2'},
{label: '3'},
{label: '4'},
{label: '5'},
{label: '6'}
]
},{
label: '7',
children: [
{label: '8'},
{label: '9'},
{label: '10'},
{label: '11'},
{label: '12'}
]
}];
var app = angular.module('bin', ['ivh.treeview']);
app.config(function(ivhTreeviewOptionsProvider) {
ivhTreeviewOptionsProvider.set({
defaultSelectedState: false,
validate: true,
expandToDepth: -1
});
});
app.directive('asciiBox', function(ivhTreeviewMgr) {
return {
restrict: 'AE',
template: [
'<div class="custom-control custom-checkbox-primaryblue">',
'<input type="checkbox" class="custom-control-input" id="12">',
'<label class="custom-control-label" for="12">',
'{{:: trvw.label(node)}}',
'</label>',
'</div>',
].join(''),
link: function(scope, element, attrs) {
element.on('click', function() {
ivhTreeviewMgr.select(stuff, scope.node, !scope.node.selected);
scope.$apply();
});
}
};
});
app.controller('DemoCtrl', function() {
this.stuff = stuff;
this.tpl = [
'<div>',
'<ascii-box></ascii-box>',
'<span class="ivh-treeview-node-label" ivh-treeview-toggle>',
'</span>',
'<div ivh-treeview-children></div>',
'</div>'
].join('\n');
});
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |