-
-
Notifications
You must be signed in to change notification settings - Fork 601
ExtGlyph
About Fancytree glyph extension.
- Status: beta
- Examples: bootstrap and font awesome
Use glyph fonts as instead of icon sprites.
-
map, type: {object}, default: Font Awesome 3.2 symbols
Map of icon class names for different symbol types.
(n.a.)
(n.a.)
In addition to jQuery, jQuery UI, and Fancytree, include jquery.fancytree.glyph.js
.
Then add the glyph css, like bootstrap.min.css
, font-awesome.min.css
, or similar.
It is also important to use a Fancytree theme that is optimized for glyph icons
instead of gif sprites, for example skin-awesome
or skin-bootstrap
:
<link href="../src/skin-bootstrap/ui.fancytree.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<script src="//code.jquery.com/jquery-1.12.1.min.js" type="text/javascript"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
<script src="js/jquery.fancytree.js" type="text/javascript"></script>
<script src="js/jquery.fancytree.glyph.js" type="text/javascript"></script>
$("#tree").fancytree({
extensions: ["glyph"],
glyph: {
map: {
checkbox: "glyphicon glyphicon-unchecked",
checkboxSelected: "glyphicon glyphicon-check",
checkboxUnknown: "glyphicon glyphicon-share",
dragHelper: "glyphicon glyphicon-play",
dropMarker: "glyphicon glyphicon-arrow-right",
error: "glyphicon glyphicon-warning-sign",
expanderClosed: "glyphicon glyphicon-plus-sign",
expanderLazy: "glyphicon glyphicon-plus-sign",
expanderOpen: "glyphicon glyphicon-minus-sign",
loading: "glyphicon glyphicon-refresh glyphicon-spin",
nodata: "glyphicon glyphicon-info-sign",
// Default node icons.
// (Use tree.options.icon callback to define custom icons based on node data)
doc: "glyphicon glyphicon-file",
docOpen: "glyphicon glyphicon-file",
folder: "glyphicon glyphicon-folder-close",
folderOpen: "glyphicon glyphicon-folder-open"
}
},
...
});
The bootstrap theme also plays well with the ext-wide
extension.
Include the glyph css, use the skin-bootstrap
theme, and define the icon mapping:
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js" type="text/javascript"></script>
<link href="../src/skin-bootstrap/ui.fancytree.css" rel="stylesheet" type="text/css">
map: {
checkbox: "glyphicon glyphicon-unchecked",
checkboxSelected: "glyphicon glyphicon-check",
checkboxUnknown: "glyphicon glyphicon-share",
dragHelper: "glyphicon glyphicon-play",
dropMarker: "glyphicon glyphicon-arrow-right",
error: "glyphicon glyphicon-warning-sign",
expanderClosed: "glyphicon glyphicon-plus-sign",
expanderLazy: "glyphicon glyphicon-plus-sign",
expanderOpen: "glyphicon glyphicon-minus-sign",
// Default node icons.
// (Use tree.options.icon callback to define custom icons based on node data)
doc: "glyphicon glyphicon-file",
docOpen: "glyphicon glyphicon-file",
folder: "glyphicon glyphicon-folder-close",
folderOpen: "glyphicon glyphicon-folder-open",
loading: "glyphicon glyphicon-refresh glyphicon-spin"
}
Include the glyph css, use the skin-bootstrap
theme, and define the icon mapping:
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" >
<link href="../src/skin-awesome/ui.fancytree.css" rel="stylesheet" type="text/css">
map: {
checkbox: "fa fa-square-o",
checkboxSelected: "fa fa-check-square-o",
checkboxUnknown: "fa fa-square",
dragHelper: "fa arrow-right",
dropMarker: "fa long-arrow-right",
error: "fa fa-warning",
expanderClosed: "fa fa-caret-right",
expanderLazy: "fa fa-angle-right",
expanderOpen: "fa fa-caret-down",
nodata: "fa fa-meh-o",
loading: "fa fa-spinner fa-pulse",
// Default node icons.
// (Use tree.options.icon callback to define custom icons based on node data)
doc: "fa fa-file-o",
docOpen: "fa fa-file-o",
folder: "fa fa-folder-o",
folderOpen: "fa fa-folder-open-o"
}
Include the glyph css, use the skin-bootstrap
theme, and define the icon mapping:
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<link href="../src/skin-awesome/ui.fancytree.css" rel="stylesheet" type="text/css">
map: {
checkbox: "icon-check-empty",
checkboxSelected: "icon-check",
checkboxUnknown: "icon-check icon-muted",
dragHelper: "icon-caret-right",
dropMarker: "icon-caret-right",
error: "icon-exclamation-sign",
expanderClosed: "icon-caret-right",
expanderLazy: "icon-angle-right",
expanderOpen: "icon-caret-down",
loading: "icon-refresh icon-spin",
nodata: "icon-meh",
noExpander: "",
// Default node icons.
// (Use tree.options.icon callback to define custom icons based on node data)
doc: "icon-file-alt",
docOpen: "icon-file-alt",
folder: "icon-folder-close-alt",
folderOpen: "icon-folder-open-alt"
}
Use the icon
callback to define per-node custom icons:
$("#tree").fancytree({
...
icon: function(event, data){
if( data.node.isFolder() ) {
return "glyphicon glyphicon-book";
}
},
Another approach is to override the icon class directly with the node data:
[
{"title": "Node 1", "key": "1", "icon": "glyphicon glyphicon-book" },
...
Documentation Home - Project Page - Copyright (c) 2008-2022, Martin Wendt (https://wwWendt.de)