Skip to content

Commit

Permalink
allow scrolling long sub menus via touch for fixed positioned menu bars
Browse files Browse the repository at this point in the history
remove IE6/7/8 Js and CSS tweaks/hacks
switch to box-sizing:border-box;
add Bower support http://bower.io/
fix: Bootstrap addon drop-downs z-index issue
fix: unneeded horizontal scrollbar triggered on RTL pages
  • Loading branch information
vadikom committed Aug 25, 2014
1 parent bc2fdb5 commit 3bb334c
Show file tree
Hide file tree
Showing 28 changed files with 3,188 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
dist/
zip/
node_modules/
.DS_Store
npm-debug.log
63 changes: 35 additions & 28 deletions Gruntfile.js
Expand Up @@ -36,7 +36,7 @@ module.exports = function(grunt) {
* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, Vadikom Web Ltd. <%= pkg.author.url %>; Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */',

banner_bootstrap_addon: '/*!\n\
* <%= pkg.title || pkg.name %> jQuery Plugin Bootstrap Addon - v<%= pkg.version_keyboard_addon %> - <%= grunt.template.today("mmmm d, yyyy") %>\n\
* <%= pkg.title || pkg.name %> jQuery Plugin Bootstrap Addon - v<%= pkg.version_bootstrap_addon %> - <%= grunt.template.today("mmmm d, yyyy") %>\n\
* <%= pkg.homepage %>\n\
*\n\
* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, Vadikom Web Ltd.\n\
Expand All @@ -45,92 +45,99 @@ module.exports = function(grunt) {
* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n\
*/\n\n',

banner_bootstrap_addon_min: '/*! <%= pkg.title || pkg.name %> jQuery Plugin Bootstrap Addon - v<%= pkg.version_keyboard_addon %> - <%= grunt.template.today("mmmm d, yyyy") %>\n\
banner_bootstrap_addon_min: '/*! <%= pkg.title || pkg.name %> jQuery Plugin Bootstrap Addon - v<%= pkg.version_bootstrap_addon %> - <%= grunt.template.today("mmmm d, yyyy") %>\n\
* <%= pkg.homepage %>\n\
* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, Vadikom Web Ltd. <%= pkg.author.url %>; Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */',

distdir: '<%= pkg.name %>-<%= pkg.version %>',

// Task configuration.
clean: ["dist/*"],
// copy stuff to dist
copy: {
main: {
files: [
{ src: ['LICENSE-MIT', 'README.md'], dest: 'dist/<%= distdir %>/' },
{ src: ['src/addons/bootstrap/jquery.smartmenus.bootstrap.css'], dest: 'dist/<%= distdir %>/addons/bootstrap/jquery.smartmenus.bootstrap.css' },
{ expand: true, cwd: 'src/', src: ['css/**', 'demo/**', 'libs/**'], dest: 'dist/<%= distdir %>/' }
]
}
},
clean: ['zip/*', 'dist/*'],
concat: {
dist: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
src: ['src/jquery.<%= pkg.name %>.js'],
dest: 'dist/<%= distdir %>/jquery.<%= pkg.name %>.js'
dest: 'zip/<%= distdir %>/jquery.<%= pkg.name %>.js'
},
dist_keyboard_addon: {
options: {
banner: '<%= banner_keyboard_addon %>',
stripBanners: true
},
src: ['src/addons/keyboard/jquery.<%= pkg.name %>.keyboard.js'],
dest: 'dist/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.js'
dest: 'zip/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.js'
},
dist_bootstrap_addon: {
options: {
banner: '<%= banner_bootstrap_addon %>',
stripBanners: true
},
src: ['src/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.js'],
dest: 'dist/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.js'
dest: 'zip/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.js'
}
},
uglify: {
dist: {
options: {
banner: '<%= banner_min %>'
},
src: 'dist/<%= distdir %>/jquery.<%= pkg.name %>.js',
dest: 'dist/<%= distdir %>/jquery.<%= pkg.name %>.min.js'
src: 'zip/<%= distdir %>/jquery.<%= pkg.name %>.js',
dest: 'zip/<%= distdir %>/jquery.<%= pkg.name %>.min.js'
},
dist_keyboard_addon: {
options: {
banner: '<%= banner_keyboard_addon_min %>'
},
src: 'dist/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.js',
dest: 'dist/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.min.js'
src: 'zip/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.js',
dest: 'zip/<%= distdir %>/addons/keyboard/jquery.<%= pkg.name %>.keyboard.min.js'
},
dist_bootstrap_addon: {
options: {
banner: '<%= banner_bootstrap_addon_min %>'
},
src: 'dist/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.js',
dest: 'dist/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.min.js'
src: 'zip/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.js',
dest: 'zip/<%= distdir %>/addons/bootstrap/jquery.<%= pkg.name %>.bootstrap.min.js'
}
},
copy: {
main: {
files: [
// copy stuff to zip/
{ src: ['LICENSE-MIT', 'README.md'], dest: 'zip/<%= distdir %>/' },
{ src: ['src/addons/bootstrap/jquery.smartmenus.bootstrap.css'], dest: 'zip/<%= distdir %>/addons/bootstrap/jquery.smartmenus.bootstrap.css' },
{ expand: true, cwd: 'src/', src: ['css/**', 'demo/**', 'libs/**'], dest: 'zip/<%= distdir %>/' },
// copy stuff to dist/
{ src: ['zip/<%= distdir %>/jquery.smartmenus.js'], dest: 'dist/jquery.smartmenus.js' },
{ src: ['zip/<%= distdir %>/jquery.smartmenus.min.js'], dest: 'dist/jquery.smartmenus.min.js' },
{ src: ['src/addons/bootstrap/jquery.smartmenus.bootstrap.css'], dest: 'dist/addons/bootstrap/jquery.smartmenus.bootstrap.css' },
{ expand: true, cwd: 'src/', src: ['css/**'], dest: 'dist/' },
{ expand: true, cwd: 'zip/<%= distdir %>/', src: ['addons/**'], dest: 'dist/' }
]
}
},
zip: {
dist: {
router: function (filepath) {
// remove "dist/" from filepath
return filepath.replace(/^dist\//, '');
// remove "zip/" from filepath
return filepath.replace(/^zip\//, '');
},
src: ['dist/<%= distdir %>/**'],
dest: 'dist/<%= distdir %>.zip'
src: ['zip/<%= distdir %>/**'],
dest: 'zip/<%= distdir %>.zip'
}
}
});

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-zip');

// Default task.
grunt.registerTask('default', ['clean', 'copy', 'concat', 'uglify', 'zip']);
grunt.registerTask('default', ['clean', 'concat', 'uglify', 'copy', 'zip']);

};
26 changes: 14 additions & 12 deletions README.md
@@ -1,26 +1,28 @@
# SmartMenus

jQuery website menu plugin. Responsive and accessible list-based website menus that work on all devices.
Advanced jQuery website menu plugin. Responsive and accessible list-based website menus that work on all devices.
Check out [the demo page](http://vadikom.github.io/smartmenus/src/demo/).

## Homepage
## Quick start

http://www.smartmenus.org/
- [Download the latest release](http://www.smartmenus.org/download/).
- Install with [Bower](http://bower.io): `bower install smartmenus`.
- Clone the repo: `git clone https://github.com/vadikom/smartmenus.git`.

## Download
Check out the [project documentation](http://www.smartmenus.org/docs/) for quick setup instructions, API reference, tutorials and more.

Download the ZIP package which includes a basic demo:
## Homepage

http://www.smartmenus.org/download/
<http://www.smartmenus.org/>

## Getting started and API documentation
## Community and support

http://www.smartmenus.org/docs/
- Visit the [Community forums](http://www.smartmenus.org/support/forums/) for free support.
- Read and subscribe to [the project blog](http://www.smartmenus.org/blog/).
- Follow [@vadikom on Twitter](http://twitter.com/vadikom).

## Bugs and issues

https://github.com/vadikom/smartmenus/issues

## Support forums
For bugs and issues only please. For support requests please use the [Community forums](http://www.smartmenus.org/support/forums/).

http://www.smartmenus.org/support/forums/
<https://github.com/vadikom/smartmenus/issues>
31 changes: 31 additions & 0 deletions bower.json
@@ -0,0 +1,31 @@
{
"name": "smartmenus",
"version": "0.9.7",
"description": "Advanced jQuery website menu plugin. Responsive and accessible list-based website menus that work on all devices.",
"homepage": "http://www.smartmenus.org/",
"main": [
"dist/jquery.smartmenus.js"
],
"authors": [
"Vasil Dinkov <vasko.dinkov@gmail.com> (http://vadikom.com)"
],
"keywords": [
"menu",
"navigation",
"accessible",
"responsive",
"ui"
],
"repository": {
"type": "git",
"url": "git://github.com/vadikom/smartmenus.git"
},
"license": "MIT",
"ignore": [
".gitignore",
"Gruntfile.js"
],
"dependencies": {
"jquery": ">=1.4.4"
}
}
101 changes: 101 additions & 0 deletions dist/addons/bootstrap/jquery.smartmenus.bootstrap.css
@@ -0,0 +1,101 @@
/*
You probably do not need to edit this at all.
Add some SmartMenus required styles not covered in Bootstrap 3's default CSS.
These are theme independent and should work with any Bootstrap 3 theme mod.
*/
/* sub menus arrows */
.navbar-nav .sub-arrow, .navbar-nav .collapsible .sub-arrow {
position:static;
margin-top:0;
margin-right:0;
margin-left:6px;
display:inline-block;
width:0;
height:0;
overflow:hidden;
vertical-align:middle;
border-top:4px solid;
border-right:4px dashed transparent;
border-bottom:4px dashed transparent;
border-left:4px dashed transparent;
}
.navbar-fixed-bottom .sub-arrow {
margin-top:-5px;
border-top:4px dashed transparent;
border-bottom:4px solid;
}
.navbar-nav ul .sub-arrow {
position:absolute;
right:0;
margin-top:6px;
margin-right:15px;
border-top:4px dashed transparent;
border-bottom:4px dashed transparent;
border-left:4px solid;
}
.navbar-nav ul a.has-submenu {
padding-right:30px;
}
/* scrolling arrows for tall menus */
.navbar-nav span.scroll-up, .navbar-nav span.scroll-down {
position:absolute;
display:none;
visibility:hidden;
height:20px;
overflow:hidden;
text-align:center;
}
.navbar-nav span.scroll-up-arrow, .navbar-nav span.scroll-down-arrow {
position:absolute;
top:-2px;
left:50%;
margin-left:-8px;
width:0;
height:0;
overflow:hidden;
border-top:7px dashed transparent;
border-right:7px dashed transparent;
border-bottom:7px solid;
border-left:7px dashed transparent;
}
.navbar-nav span.scroll-down-arrow {
top:6px;
border-top:7px solid;
border-right:7px dashed transparent;
border-bottom:7px dashed transparent;
border-left:7px dashed transparent;
}
/* add more indentation for 2+ level sub in collapsible mode - Bootstrap normally supports just 1 level sub menus */
.navbar-nav .collapsible ul .dropdown-menu > li > a,
.navbar-nav .collapsible ul .dropdown-menu .dropdown-header {
padding-left:35px;
}
.navbar-nav .collapsible ul ul .dropdown-menu > li > a,
.navbar-nav .collapsible ul ul .dropdown-menu .dropdown-header {
padding-left:45px;
}
.navbar-nav .collapsible ul ul ul .dropdown-menu > li > a,
.navbar-nav .collapsible ul ul ul .dropdown-menu .dropdown-header {
padding-left:55px;
}
.navbar-nav .collapsible ul ul ul ul .dropdown-menu > li > a,
.navbar-nav .collapsible ul ul ul ul .dropdown-menu .dropdown-header {
padding-left:65px;
}
/* fix SmartMenus sub menus auto width (subMenusMinWidth and subMenusMaxWidth options) */
.navbar-nav .dropdown-menu > li > a {
white-space:normal;
}
.navbar-nav ul.sm-nowrap > li > a {
white-space:nowrap;
}
/* fix .navbar-right subs alignment */
.navbar-right ul.dropdown-menu {
left:0;
right:auto;
}
/* The following will make the sub menus collapsible for small screen devices (it's not recommended editing these) */
.navbar-nav .collapsible ul {display:none;position:static !important;top:auto !important;left:auto !important;margin-left:0 !important;margin-top:0 !important;width:auto !important;min-width:0 !important;max-width:none !important;}
.navbar-nav .collapsible ul.sm-nowrap > li > a {white-space:normal;}
.navbar-nav .collapsible iframe{display:none;}
72 changes: 72 additions & 0 deletions dist/addons/bootstrap/jquery.smartmenus.bootstrap.js
@@ -0,0 +1,72 @@
/*!
* SmartMenus jQuery Plugin Bootstrap Addon - v0.1.1 - August 25, 2014
* http://www.smartmenus.org/
*
* Copyright 2014 Vasil Dinkov, Vadikom Web Ltd.
* http://vadikom.com
*
* Licensed MIT
*/

(function($) {

// init ondomready
$(function() {

// init all menus
$('ul.navbar-nav').each(function() {
var $this = $(this);
$this.addClass('sm').smartmenus({

// these are some good default options that should work for all
// you can, of course, tweak these as you like
subMenusSubOffsetX: 2,
subMenusSubOffsetY: -6,
subIndicatorsPos: 'append',
subIndicatorsText: '...',
collapsibleShowFunction: null,
collapsibleHideFunction: null,
rightToLeftSubMenus: $this.hasClass('navbar-right'),
bottomToTopSubMenus: $this.closest('.navbar').hasClass('navbar-fixed-bottom')
})
// set Bootstrap's "active" class to SmartMenus "current" items (should someone decide to enable markCurrentItem: true)
.find('a.current').parent().addClass('active');
})
.bind({
// set/unset proper Bootstrap classes for some menu elements
'show.smapi': function(e, menu) {
var $menu = $(menu),
$scrollArrows = $menu.dataSM('scroll-arrows'),
obj = $(this).data('smartmenus');
if ($scrollArrows) {
// they inherit border-color from body, so we can use its background-color too
$scrollArrows.css('background-color', $(document.body).css('background-color'));
}
$menu.parent().addClass('open' + (obj.isCollapsible() ? ' collapsible' : ''));
},
'hide.smapi': function(e, menu) {
$(menu).parent().removeClass('open collapsible');
},
// click the parent item to toggle the sub menus (and reset deeper levels and other branches on click)
'click.smapi': function(e, item) {
var obj = $(this).data('smartmenus');
if (obj.isCollapsible()) {
var $item = $(item),
$sub = $item.parent().dataSM('sub');
if ($sub && $sub.dataSM('shown-before') && $sub.is(':visible')) {
obj.itemActivate($item);
obj.menuHide($sub);
return false;
}
}
}
});

});

// fix collapsible menu detection for Bootstrap 3
$.SmartMenus.prototype.isCollapsible = function() {
return this.$firstLink.parent().css('float') != 'left';
};

})(jQuery);
3 changes: 3 additions & 0 deletions dist/addons/bootstrap/jquery.smartmenus.bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3bb334c

Please sign in to comment.