behigh / bootstrap_dropdowns_enhancement Goto Github PK
View Code? Open in Web Editor NEWBootstrap Dropdown Menus Enhancement
Bootstrap Dropdown Menus Enhancement
Latest version on the bower is 2.3.2 which does not include sub-menu improvements.
thanks a lot!
Normal bootstrap dropdown has keyboard support to navigate through all the entries. But with this enhancement I am only able to open the menu but cant navigate through the list entries.
День добрый.
А можно ли с помощью существующего функционала сделать древовидный список?
Т.е. кликаем и у нас выпадает примерно такое:
заголовок
заголовок
заголовок
+чекбокс
+чекбокс
+чекбокс
+...
заголовок
+чекбокс
+...
Получается будет несколько ul'ев и где то в конце нужные чекбоксы.
Could it be possible to upgrade the solution to the newest version of the framework?
When I use the dropdown-enhancement in form any dropdown( bootstrap dropdown in TopMenu and dropdown in form) is opened and closed immediatly. How can i prevent conflict ?
Howdy,
On you demo/documentation page you state:
"To start using the improvements you need to include a modified dropdown-enhancement.js and dropdown-enhancement.css file."
What needs to be modified? I tried to figure it out myself, but you minified the js and css files...
This is an awesome enhancement, but the examples are not initiative. Please clarify.
Good morning,
I've tried to combine this extension with dropdown on hover. Unfortunately you can see from first line that it's written for
(function(e){function n(b){e(b).on("click"+p,this.toggle)}
Do you think it could be possible to add a function that would same things when dropdown is activated on hover?
Hi, I implemented these:
https://github.com/silviomoreto/bootstrap-select
but with this dropdowns it doesn't work :(.
Any ideas why?
Thanks,
M
thanks for your work
Hi, it seem some odd behavior when migrate to BS 4 alpha6, the main cause could be that in alpha6 boostrap substitute .open classes with .show, so, as I see on the code of the bootstrap_dropdowns_enhacement, it still use .open class. Or there is already a version which solve this issue and I dont know.
Thanks in advance.
By the way, great work!!!
I am trying to get a dropdown with radio buttons to work as a nested group, but it doesn't seem to work. Visually, the dropdown works, but the state doesn't change (i.e. selection doesn't happen) and the label neither.
I tried to track it down but all I figured out is that the proto.change
function doesn't even seem to be called.
Here is my code, simplified:
<div class="form-group">
<label>Group label</label><br>
<div class="btn-group" role="group" aria-label="..." data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" class="btn btn-default" name="endpoint" value="AAAvalue">
AAA
</label>
<label class="btn btn-primary">
<input type="radio" class="btn btn-default" name="endpoint" value="BBBvalue">
BBB
</label>
<!-- here is the dropdown -->
<div class="btn-group">
<button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" id="list-dropdown-button">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
Select from this dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><input type='radio' id='list-ccc' name='list' value='CCCvalue'><label for='list-ccc'>CCC</label></li>
<li><input type='radio' id='list-bbb' name='list' value='BBBvalue'><label for='list-bbb'>BBB</label></li>
</ul>
</div>
</div>
</div>
Is there something I am doing wrong?
Dropdown events don't bind. For example:
$('#myDropdown').on('show.bs.dropdown', function () {
// do something…
});
if use it on submenu with radio or checkbox
the label change has a bug that the all parent labels change the label.
I have a dropdown radio set with the custom placeholder labels. I need to clear the set and label back to default. I can clear the radio group value but that leaves the place holder in the button. What would be the best way to reset the button back to default text?
Thanks in advance for any help.
Not sure what the trick is -- how do you get it to load the select list with existing checked input?
Perhaps this isn't a feature from your code. In the demo, when you choose an item from the dropdown, the button text changes to indicate the selection(s).
This doesn't happen on my site. Any ideas what might be wrong?
I think that it will be more clear if in the 'Custom label text' example, the code matches exactly what the example shows. So instead of
<div class="btn-group">
<button data-toggle="dropdown" class="btn dropdown-toggle">Checked option <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"><span class="data-label">Label</span> Other text</label></li>
<!-- Other items -->
</ul>
</div>
maybe
<div class="btn-group">
<button data-label-placement="" class="btn btn-default"><i class="glyphicon glyphicon-pencil data-label"></i></button>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span> </button>
<ul class="dropdown-menu">
<li>
<input type="radio" checked="" value="1" name="ex7" id="ex7_1">
<label for="ex7_1"><i class="glyphicon glyphicon-pencil data-label"></i> Edit</label>
</li>
<li>
<input type="radio" value="2" name="ex7" id="ex7_2">
<label for="ex7_2"><i class="glyphicon glyphicon-trash data-label"></i> Remove</label>
</li>
<li>
<input type="radio" value="3" name="ex7" id="ex7_3">
<label for="ex7_3"><i class="glyphicon glyphicon-print data-label"></i> Print</label>
</li>
</ul>
</div>
This way lazy people, like myself, can just copy/paste the example.
If it's okay with you I will be glad to fork and change it.
When I dropped the new files into my bootstrap setup and ran bootstrap's make file I got the following error:
js/bootstrap-dropdown.js: line 82, col 42, Use '===' to compare with 'undefined'
Changing the == on line 82 to === removes the error.
Otherwise these controls worked pretty well. You should see if they'll add them to the main bootstrap build.
Your filenames include the word "dropdowns" with an S while the instructions say "dropdown". For anyone, like me, who copied the name from your tutorial buttons for adding the file locations to their page, it won't work.
All dropdown events are not fired
show.bs.dropdown, shown.bs.dropdown, hide.bs.dropdown, hidden.bs.dropdown not work with this plugin.
$('#myDropdown').on('show.bs.dropdown', function () { // **NOT WORK** })
What about to make Bower publish ?
All examples on https://behigh.github.io/bootstrap_dropdowns_enhancement/ just stoped working. How come?
Hey
Any way to add an "All" checkbox which will select all, in addition to permitting separate check box selection.
Also, how to show actual boxes which tick upon selection. Or atleast adds tick to selection.
Also, show subtext with the label but which does not show up when button text updates.
UPDATE - I have solved the check all issue.
Thanks.
In code we have something like this .dropdown-menu.noclose > li, for prevent .dropdown-menu to close, would be great if we can have the same behavior for any type of .dropdown-menu not only for lists.
My solution.
Added () to math ops
dropdowns-enhancement-mixins.less
.dropdown-menu-caret(@size; @offset; @border: @dropdown-border; @fallback-border: @dropdown-fallback-border; @bg: @dropdown-bg) {
margin-top: (@size + 1);
.defaults() {
width: 0;
height: 0;
content: '';
display: inline-block;
position: absolute;
border-color: transparent;
border-style: solid;
-webkit-transform:rotate(360deg); // for a better anti-aliasing in webkit browser
}
&:before {
.defaults();
border-width: 0 @size @size;
border-bottom-color: @fallback-border;
border-bottom-color: @border;
top: -@size;
left: @offset;
}
&:after {
.defaults();
border-width: 0 (@size - 1) (@size - 1);
border-bottom-color: @bg;
top: -(@size - 1);
left: @offset + 1;
}
}
dropdowns-enhancement.less
@import "mixins/dropdowns-enhancement-mixins.less";
.dropdown-menu {
// Style for <label>
> li > label:extend(.dropdown-menu > li > a all) {
margin-bottom: 0;
cursor: pointer;
}
> li > input {
&[type="radio"],
&[type="checkbox"] {
display: none;
position: absolute;
top: -9999em;
left: -9999em;
}
}
> li > label:focus,
> li > input:focus ~ label {
.tab-focus();
}
> li > input:checked ~ label:extend(.dropdown-menu > .active > a all),
> .active > label:extend(.dropdown-menu > .active > a all) {
}
> li > input[disabled] ~ label:extend(.dropdown-menu > .disabled > a all),
> .disabled > label:extend(.dropdown-menu > .disabled > a all) {
}
// Aligns the dropdown menu to right
&.pull-right {
right: 0;
left: auto;
}
// Show the dropdown menu above
&.pull-top {
bottom: 100%;
top: auto;
margin: 0 0 2px;
.box-shadow(0 -6px 12px rgba(0,0,0,.175)); // copied from bootstrap/dropdown.less
}
&.pull-center {
right: 50%;
// dropdown.js is used to center menu
left: auto;
}
&.pull-middle {
right: 100%;
// dropdown.js is used to center menu
margin: 0 2px 0 0;
box-shadow: -5px 0 10px rgba(0, 0, 0, 0.2);
left: auto;
&.pull-right {
right: auto;
left: 100%;
margin: 0 0 0 2px;
box-shadow: 5px 0 10px rgba(0, 0, 0, 0.2);
}
&.pull-center {
right: 50%;
margin: 0;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
}
&.bullet {
@size: 7px;
@offset: 9px;
.dropdown-menu-caret(@size; @offset);
&.pull-right {
&:before {
left: auto;
right: @offset;
}
&:after {
left: auto;
right: (@offset + 1);
}
}
&.pull-top {
margin-top: 0;
margin-bottom: (@size + 1);
&:before {
top: auto;
bottom: -@size;
border-bottom-width: 0;
border-top-width: @size;
border-top-color: @dropdown-fallback-border;
border-top-color: @dropdown-border;
}
&:after {
top: auto;
bottom: (-@size - 1);
border-bottom: none;
border-top-width: (@size - 1);
border-top-color: @dropdown-bg;
}
}
&.pull-center {
&:before {
left: auto;
right: 50%;
margin-right: (@size * -1);
}
&:after {
left: auto;
right: 50%;
margin-right: ((@size - 1) * -1);
}
}
&.pull-middle {
margin-right: (@size + 1);
&:before {
top: 50%;
left: 100%;
right: auto;
margin-top: (@size * -1);
border-right-width: 0;
border-bottom-color: transparent;
border-top-width: @size;
border-left-color: @dropdown-fallback-border;
border-left-color: @dropdown-border;
}
&:after {
top: 50%;
left: 100%;
right: auto;
margin-top: ((@size - 1) * -1);
border-right-width: 0;
border-bottom-color: transparent;
border-top-width: (@size - 1);
border-left-color: @dropdown-bg;
}
&.pull-right {
margin-right: 0;
margin-left: (@size + 1);
&:before {
left: -@size;
border-left-width: 0;
border-right-width: @size;
border-right-color: @dropdown-fallback-border;
border-right-color: @dropdown-border;
}
&:after {
left: (-@size - 1);
border-left-width: 0;
border-right-width: (@size - 1);
border-right-color: @dropdown-bg;
}
}
&.pull-center {
margin-left: 0;
margin-right: 0;
&:before {
border: none;
display: none
}
&:after {
border: none;
display: none
}
}
}
}
}
//
// Dropdown menus enhancement
// --------------------------------------------------
// Submenus
.dropdown-submenu {
position: relative;
> .dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-top-left-radius: 0;
}
> a:before {
display: block;
float: right;
width: 0;
height: 0;
content: "";
margin-top: (@line-height-computed / 2 - @caret-width-base);
margin-right: (-@caret-width-base * 2);
border-width: @caret-width-base 0 @caret-width-base @caret-width-base;
border-style: solid;
border-left-style: dashed;
border-top-color: transparent;
border-bottom-color: transparent;
}
}
.make-nested-list(@n, @i: 0) when (@i < @n) {
> .dropdown-menu {
> li {
> a {
padding-left: (35px + (10 * @i));
}
.make-nested-list(@n, (@i + 1));
}
}
}
.navbar-nav {
@media (max-width: @grid-float-breakpoint-max) {
.dropdown-submenu {
> a:before {
margin-top: ((@line-height-computed / 2) - (@caret-width-base / 2));
border-color: inherit;
border-style: solid;
border-width: @caret-width-base @caret-width-base 0;
border-left-color: transparent;
border-right-color: transparent;
}
> a {
padding-left: 40px;
}
}
> .open > .dropdown-menu > .dropdown-submenu {
.make-nested-list(5);
}
}
}
// Default navbar
.navbar-default {
// Dropdown menu items
.navbar-nav {
// Remove background color from open dropdown
.open > .dropdown-menu > .dropdown-submenu.open > a {
&,
&:hover,
&:focus {
background-color: @navbar-default-link-active-bg;
color: @navbar-default-link-active-color;
}
@media (max-width: @grid-float-breakpoint-max) {
&:before {
border-top-color: @navbar-default-link-active-color;
}
}
}
}
}
// Inverse navbar
.navbar-inverse {
// Dropdown menu items
.navbar-nav {
// Remove background color from open dropdown
.open > .dropdown-menu > .dropdown-submenu.open > a {
&,
&:hover,
&:focus {
background-color: @navbar-inverse-link-active-bg;
color: @navbar-inverse-link-active-color;
}
@media (max-width: @grid-float-breakpoint-max) {
&:before {
border-top-color: @navbar-inverse-link-active-color;
}
}
}
}
}
Is it possible to add "Container" option, something like http://getbootstrap.com/javascript/#popovers has. For example: container: 'body'. Or it's too difficult?
Hi There,
(Not sure that is the way to raise up UX needs. I am a UX person, not a developer but working direct with developers)
While working on optimising UX for my site I have come across a following issue:
BACKGROUND
We are using dropdown as forms with a button "save"
There are 4 dropdowns in one page.
Dropdowns (forms) are from small to big (1/3 of height to 1/1 of screen height)
PROBLEM 1 - SOLVED
by using standard dropdowns, the bottom of form was disappearing below that screen edge (making it uncomfy for user ie having to scroll down)
this was solved in 80% by bootstrap_dropdowns_enhancement: CENTERED
.pull-middle.pull-right
.pull-middle.pull-center
.pull-middle
PROBLEM 2 - UNSOLVED
However I have one form (which has i heighth of the screen - and for user comfort I would like it to show - from bottom to top. (please see illustration in the link below)
(ie
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.