Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e364af8
Showing
12 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
*.sublime* |
Binary file added
BIN
+4.06 KB
.sass-cache/28a2a6e4a7b3342b4b7b7201a0424c4c66048e50/bootstrap-treenav.scssc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* jshint node: true */ | ||
|
||
module.exports = function(grunt) { | ||
'use strict'; | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
|
||
// Metadata. | ||
pkg: grunt.file.readJSON('package.json'), | ||
banner: '/**\n' + | ||
'* <%= pkg.name %>.js v<%= pkg.version %> by @morrissinger\n' + | ||
'* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + | ||
'* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' + | ||
'*/\n', | ||
jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap Tree Nav requires jQuery\"); }\n\n', | ||
|
||
// Task configuration. | ||
clean: { | ||
dist: ['dist'] | ||
}, | ||
|
||
jshint: { | ||
options: { | ||
jshintrc: 'js/.jshintrc' | ||
}, | ||
gruntfile: { | ||
src: 'Gruntfile.js' | ||
}, | ||
src: { | ||
src: [ | ||
'js/lang/*/*.js', | ||
'js/*.js' | ||
] | ||
} | ||
}, | ||
|
||
concat: { | ||
options: { | ||
banner: '<%= banner %><%= jqueryCheck %>', | ||
stripBanners: false | ||
}, | ||
bootstraptreenav: { | ||
src: [ | ||
'js/*.js' | ||
], | ||
dest: 'dist/js/<%= pkg.name %>.js' | ||
} | ||
}, | ||
|
||
uglify: { | ||
options: { | ||
banner: '<%= banner %>' | ||
}, | ||
bootstraptreenav: { | ||
src: ['<%= concat.bootstraptreenav.dest %>'], | ||
dest: 'dist/js/<%= pkg.name %>.min.js' | ||
} | ||
}, | ||
|
||
copy: { | ||
img: { | ||
expand: true, | ||
src: ['img/*'], | ||
dest: 'dist/' | ||
} | ||
}, | ||
sass: { | ||
src: { | ||
options: { | ||
style: 'expanded', | ||
banner: '<%= banner %>' | ||
}, | ||
files: { | ||
'dist/css/bootstrap-treenav.css' : 'sass/bootstrap-treenav.scss' | ||
} | ||
}, | ||
dist: { | ||
options: { | ||
style: 'compressed', | ||
banner: '<%= banner %>' | ||
}, | ||
files: { | ||
'dist/css/bootstrap-treenav.min.css' : 'sass/bootstrap-treenav.scss' | ||
} | ||
} | ||
}, | ||
watch: { | ||
src: { | ||
files: '<%= jshint.src.src %>', | ||
tasks: ['jshint:src'] | ||
}, | ||
css: { | ||
files: '**/*.scss', | ||
tasks: ['sass'] | ||
} | ||
} | ||
}); | ||
|
||
|
||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-contrib-sass'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
var testSubtasks = ['dist-css', 'jshint']; | ||
// Only push to coveralls under Travis | ||
if (process.env.TRAVIS) { | ||
if ((process.env.TRAVIS_REPO_SLUG === 'morrissinger/BootstrapTreeNav' && process.env.TRAVIS_PULL_REQUEST === 'false')) { | ||
testSubtasks.push('coveralls'); | ||
} | ||
} | ||
grunt.registerTask('test', testSubtasks); | ||
|
||
// JS distribution task. | ||
grunt.registerTask('dist-js', ['concat', 'uglify']); | ||
|
||
// CSS distribution task. | ||
grunt.registerTask('dist-css', ['sass']); | ||
|
||
// Img distribution task. | ||
grunt.registerTask('dist-img', ['copy']); | ||
|
||
// Full distribution task. | ||
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-img', 'dist-js']); | ||
|
||
// Default task. | ||
grunt.registerTask('default', ['test', 'dist']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* bootstrap-treenav.js v1.0.0 by @morrissinger | ||
* Copyright 2013 Morris Singer | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
ul.nav-tree { | ||
list-style: none; | ||
margin-left: 20px; | ||
} | ||
ul.nav-tree ul.nav-tree { | ||
margin-left: 45px; | ||
} | ||
ul.nav-tree li { | ||
position: relative; | ||
margin-left: -15px; | ||
} | ||
ul.nav-tree li a { | ||
text-indent: 15px; | ||
} | ||
ul.nav-tree li span.opener { | ||
position: absolute; | ||
top: 5px; | ||
left: 10px; | ||
color: #444; | ||
z-index: +1; | ||
} | ||
ul.nav-tree li span.opener.closed span.tree-icon-opened { | ||
display: none; | ||
} | ||
ul.nav-tree li span.opener.closed span.tree-icon-closed { | ||
display: block; | ||
} | ||
ul.nav-tree li span.opener.opened span.tree-icon-open { | ||
display: block; | ||
} | ||
ul.nav-tree li span.opener.opened span.tree-icon-closed { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* bootstrap-treenav.js v1.0.0 by @morrissinger | ||
* Copyright 2013 Morris Singer | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
ul.nav-tree{list-style:none;margin-left:20px}ul.nav-tree ul.nav-tree{margin-left:45px}ul.nav-tree li{position:relative;margin-left:-15px}ul.nav-tree li a{text-indent:15px}ul.nav-tree li span.opener{position:absolute;top:5px;left:10px;color:#444;z-index:+1}ul.nav-tree li span.opener.closed span.tree-icon-opened{display:none}ul.nav-tree li span.opener.closed span.tree-icon-closed{display:block}ul.nav-tree li span.opener.opened span.tree-icon-open{display:block}ul.nav-tree li span.opener.opened span.tree-icon-closed{display:none} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/** | ||
* bootstrap-treenav.js v1.0.0 by @morrissinger | ||
* Copyright 2013 Morris Singer | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
if (!jQuery) { throw new Error("Bootstrap Tree Nav requires jQuery"); } | ||
|
||
/* ========================================================== | ||
* bootstrap-treenav.js | ||
* https://github.com/morrissinger/BootstrapTreeNav | ||
* ========================================================== | ||
* Copyright 2013 Morris Singer | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ========================================================== */ | ||
|
||
+function ($) { | ||
|
||
'use strict'; | ||
|
||
$.fn.navTree = function(options) { | ||
|
||
var defaults = { | ||
navTreeExpanded: 'icon-collapse-alt', | ||
navTreeCollapsed: 'icon-expand-alt' | ||
}; | ||
|
||
options = $.extend(defaults, options); | ||
|
||
if ($(this).prop('tagName') === 'LI') { | ||
collapsible(this, options); | ||
} else if ($(this).prop('tagName') === 'UL') { | ||
collapsible(this, options); | ||
} | ||
|
||
}; | ||
|
||
var collapsible = function(element, options) { | ||
var $childrenLi = $(element).find('li'); | ||
$childrenLi.each(function(index, li) { | ||
collapsibleAll($(li), options); | ||
|
||
// Expand the tree so that the active item is shown. | ||
if ($(li).hasClass('active')) { | ||
$(li).parents('ul').each(function(i, ul) { | ||
$(ul).show(); | ||
$(ul).siblings('span.opener') | ||
.removeClass('closed') | ||
.addClass('opened'); | ||
|
||
// If there's a real target to this menu item link, then allow it to be | ||
// clicked to go to that page, now that the menu has been expanded. | ||
if ($(ul).siblings('a').attr('href') !== '#' && $(ul).siblings('a').attr('href') !== '') { | ||
$(ul).siblings('a').off('click.bs.tree'); | ||
} | ||
|
||
}); | ||
} | ||
}); | ||
}; | ||
|
||
var collapsibleAll = function(element, options) { | ||
var $childUl = $(element).children('ul'); | ||
if ( $childUl.length > 0 ) { | ||
$childUl.hide(); | ||
$(element).prepend('<span class="opener closed"><span class="tree-icon-closed"><i class="' + options.navTreeCollapsed + '"></i></span><span class="tree-icon-opened"><i class="' + options.navTreeExpanded + '"></i></span></span>'); | ||
$(element).children('a').first().on('click.bs.tree', function(e) { | ||
e.preventDefault(); | ||
var $opener = $(this).siblings('span.opener'); | ||
if ($opener.hasClass('closed')) { | ||
expand(element); | ||
|
||
// If there's a real target to this menu item link, then allow it to be | ||
// clicked to go to that page, now that the menu has been expanded. | ||
if (($(this).attr('href') !== '#') && ($(this).attr('href') !== '')) { | ||
$(this).off('click.bs.tree'); | ||
} | ||
|
||
} else { | ||
collapse(element); | ||
} | ||
}); | ||
$(element).children('span.opener').first().on('click.bs.tree', function(e){ | ||
var $opener = $(this); | ||
if ($opener.hasClass('closed')) { | ||
expand(element); | ||
} else { | ||
collapse(element); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
var expand = function(element) { | ||
var $opener = $(element).children('span.opener'); | ||
$opener.removeClass('closed').addClass('opened'); | ||
$(element).children('ul').first().slideDown(); | ||
}; | ||
|
||
var collapse = function(element) { | ||
var $opener = $(element).children('span.opener'); | ||
$opener.removeClass('opened').addClass('closed'); | ||
$(element).children('ul').first().slideUp(); | ||
}; | ||
|
||
$('ul[data-toggle=nav-tree]').each(function(){ | ||
var $tree; | ||
$tree = $(this); | ||
$tree.navTree($tree.data()); | ||
}); | ||
|
||
}(window.jQuery); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.