Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
feat(dropdown): add dropdown classes dynamically
Browse files Browse the repository at this point in the history
- Add `dropdown` and `dropdown-toggle` classes dynamically for template simplification

Closes #3984
Closes #3986
  • Loading branch information
uberspeck authored and wesleycho committed Jul 21, 2015
1 parent 2332f14 commit 4af83ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/dropdown/docs/demo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

<div ng-controller="DropdownCtrl">
<!-- Simple dropdown -->
<span class="dropdown" dropdown on-toggle="toggled(open)">
<a href id="simple-dropdown" class="dropdown-toggle" dropdown-toggle>
<span dropdown on-toggle="toggled(open)">
<a href id="simple-dropdown" dropdown-toggle>
Click me for a dropdown, yo!
</a>
<ul class="dropdown-menu" aria-labelledby="simple-dropdown">
Expand All @@ -14,7 +14,7 @@

<!-- Single button -->
<div class="btn-group" dropdown is-open="status.isopen">
<button id="single-button" type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle ng-disabled="disabled">
<button id="single-button" type="button" class="btn btn-primary" dropdown-toggle ng-disabled="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="single-button">
Expand All @@ -29,7 +29,7 @@
<!-- Split button -->
<div class="btn-group" dropdown>
<button id="split-button" type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger dropdown-toggle" dropdown-toggle>
<button type="button" class="btn btn-danger" dropdown-toggle>
<span class="caret"></span>
<span class="sr-only">Split button!</span>
</button>
Expand All @@ -44,7 +44,7 @@

<!-- Single button using append-to-body -->
<div class="btn-group" dropdown dropdown-append-to-body>
<button id="btn-append-to-body" type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle>
<button id="btn-append-to-body" type="button" class="btn btn-primary" dropdown-toggle>
Dropdown on Body <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="btn-append-to-body">
Expand All @@ -58,7 +58,7 @@

<!-- Single button using template-url -->
<div class="btn-group" dropdown>
<button id="button-template-url" type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle ng-disabled="disabled">
<button id="button-template-url" type="button" class="btn btn-primary" dropdown-toggle ng-disabled="disabled">
Dropdown using template <span class="caret"></span>
</button>
<ul class="dropdown-menu" template-url="dropdown.html" aria-labelledby="button-template-url">
Expand All @@ -74,7 +74,7 @@
<hr>
<!-- Single button with keyboard nav -->
<div class="btn-group" dropdown keyboard-nav>
<button id="simple-btn-keyboard-nav" type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle>
<button id="simple-btn-keyboard-nav" type="button" class="btn btn-primary" dropdown-toggle>
Dropdown with keyboard navigation <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="simple-btn-keyboard-nav">
Expand Down
3 changes: 3 additions & 0 deletions src/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
controller: 'DropdownController',
link: function(scope, element, attrs, dropdownCtrl) {
dropdownCtrl.init( element );
element.addClass('dropdown');
}
};
})
Expand Down Expand Up @@ -303,6 +304,8 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
return;
}

element.addClass('dropdown-toggle');

dropdownCtrl.toggleElement = element;

var toggleDropdown = function(event) {
Expand Down

0 comments on commit 4af83ad

Please sign in to comment.