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

feat(dropdown): Add dropup behavior #3703

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c16ca49
feat(dropdown): Add dropup behavior
gorork May 23, 2015
51cffac
feat(dropdown): Tests for dropup behavior
gorork May 30, 2015
41ebf5f
feat(dropdown): fix singlequote
gorork May 30, 2015
e399e46
feat(dropdown): For cases when Dropdown isnt immediate parent + Test
gorork Jul 12, 2015
d6cda93
fix(tooltip): fix binding to multiple triggers
wesleycho Sep 9, 2015
eb2366f
fix(alert): properly pass $event as local
wesleycho Sep 9, 2015
0328a76
feat(accordion): use uib- prefix
Foxandxss Sep 9, 2015
bd38e8f
feat(modal): Added ability to add CSS class to top window
Jul 29, 2014
365cdd6
chore(carousel): clean up code style
wesleycho Sep 10, 2015
f269983
chore(carousel): clean up code style
wesleycho Sep 10, 2015
c08509a
feat(tooltip): hide tooltip when `esc` is hit
wesleycho Sep 5, 2015
4d01387
chore(accordion): update docs to match the general style
Foxandxss Sep 10, 2015
53f5f47
docs(collapse): update them yet again to latest design
Foxandxss Sep 10, 2015
65814f1
fix(datepicker): change to `$popup`
wesleycho Sep 11, 2015
9d6ab96
docs(changelog): update with breaking change for tooltip
wesleycho Sep 11, 2015
2528371
chore(changelog): fix formatting
wesleycho Sep 11, 2015
4707602
chore(accordion): test that any other keyCode wont work
Foxandxss Sep 10, 2015
fcb08e9
chore(accordion): clean tests a bit
Foxandxss Sep 10, 2015
b1fdca5
chore(accordion): add missing test for $destroy
Foxandxss Sep 10, 2015
641cdb3
chore(accordion): clean some stale code and comments
Foxandxss Sep 10, 2015
d1babb6
docs(changelog): update with breaking change
wesleycho Sep 11, 2015
a04b4ff
refactor(alert): move dismiss-on-timeout to an attribute
Foxandxss Sep 11, 2015
5e3a87a
feat(alert): use uib- prefix
Foxandxss Sep 11, 2015
36ecf60
fix(datepicker): remove focus management on date selection by keyboard
stereocilia Sep 12, 2015
fabf016
chore(dropdown): clean up code style
wesleycho Sep 14, 2015
cbf2c0d
chore(dropdown): clean up code style
wesleycho Sep 14, 2015
b10a48b
chore(tooltip): clean up code style
wesleycho Sep 14, 2015
fb90152
chore(tooltip): clean up code style
wesleycho Sep 14, 2015
7ba2527
chore(timepicker): clean up code style
wesleycho Sep 14, 2015
fa1cdfc
feat(typeahead): add customClass support for dropdown
gorork Sep 13, 2015
b74c263
Revert "feat(typeahead): add customClass support for dropdown"
wesleycho Sep 16, 2015
868c0e2
fix(datepicker): add check for `contains`
yjukaku Sep 16, 2015
d9a521a
feat(dateparser): reset parsers when $locale.id changes
tgunkel81 Sep 16, 2015
bba0e68
chore(tooltip): clean up code style
wesleycho Sep 17, 2015
2c0ad03
chore(docs): bump up angular version
wesleycho Sep 18, 2015
4031e29
docs(typeahead): add custom template demo
ehteshamkafeel Sep 14, 2015
5a1c2c9
feat(buttons): use uib- prefix
Foxandxss Sep 21, 2015
a59caf1
chore(demo): update collapse to use prefix
Foxandxss Sep 21, 2015
81a38d7
refactor(tooltip): rollup commit for several issues
RobJacobs Sep 23, 2015
ec6c0bc
style(buttons): change bind to on
Foxandxss Sep 24, 2015
19118f1
refactor(buttons): match general style
Foxandxss Sep 24, 2015
da71159
fix(carousel): improve accessibility
Sep 25, 2015
23a312d
chore(carousel): change to empty hrefs
wesleycho Sep 25, 2015
d25a8c2
feat(tabs): use uib- prefix
icfantv Sep 23, 2015
e432059
chore(demo): use prefix on tabs
Foxandxss Sep 26, 2015
8919b0a
chore(typeahead): clean up code style
wesleycho Sep 30, 2015
fdf53e6
feat(typeahead): add `appendElementToId`
trueinviso Aug 16, 2015
377b4b7
feat(rating): user uib- prefix
wesleycho Oct 1, 2015
298ec8c
feat(accordion): use uib- prefix
wesleycho Oct 1, 2015
0fa851f
feat(dateparser): use uib- prefix
wesleycho Oct 1, 2015
2e5bfac
feat(carousel): use uib- prefix
Oct 1, 2015
66819c2
chore(carousel): remove whitespace
wesleycho Oct 2, 2015
504e653
feat(timepicker): use uib- prefix
wesleycho Oct 2, 2015
6158091
feat(position): add uib- prefix
wesleycho Oct 2, 2015
5bc0851
feat(dropdown): uib- prefix
BobbieBarker Oct 2, 2015
6f9f1fc
revert(dropdown): undo adding of `open` class on body
wesleycho Oct 3, 2015
2e26815
fix(carousel): fix reading of `noTransition`
steven-pribilinskiy Sep 1, 2015
85d7748
chore(progressbar): clean up code style
wesleycho Oct 3, 2015
7b7039b
chore(typeahead): remove unnecessary $digest
wesleycho Oct 3, 2015
d1555dc
chore(timepicker): update docs
wesleycho Oct 3, 2015
8d19c60
chore(rating): update docs
wesleycho Oct 3, 2015
3a3b383
chore(progressbar): update docs
wesleycho Oct 3, 2015
8fa1587
chore(buttons): update docs
wesleycho Oct 3, 2015
e7c5879
fix(dropdown): restore deprecated directives
wesleycho Oct 3, 2015
db36c62
chore(carousel): clean up code style
wesleycho Oct 3, 2015
5382226
fix(accordion): re-expose AccordionController
wesleycho Oct 3, 2015
f561aa9
fix(alert): re-expose AlertController
wesleycho Oct 3, 2015
0b1e911
feat(dropdown): Add dropup behavior
gorork May 23, 2015
89ae929
feat(dropdown): Tests for dropup behavior
gorork May 30, 2015
45ad83a
feat(dropdown): fix singlequote
gorork May 30, 2015
22621e2
feat(dropdown): For cases when Dropdown isnt immediate parent + Test
gorork Jul 12, 2015
fb0a261
feat(dropdown): Rebase to master
gorork Oct 4, 2015
cb7f25e
feat(dropdown): code readability
gorork Oct 4, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@

([bf63cef](https://github.com/angular-ui/bootstrap/commit/bf63cef))

* **tooltip**
* Switch to use `addEventListener` and `removeEventListener` to prevent jqLite/jQuery bug where the events are swallowed on disabled elements
* this affects custom events, which must now be dispatched with `element[0].dispatchEvent(new Event('customEvent'))`, as opposed to `element.trigger('customEvent')`

Fixes #4060
Closes #4322

([7556bed](https://github.com/angular-ui/bootstrap/commit/7556beda486f26b40fb860448316e8a32457e9e9))

* **typeahead**
* for security reasons, only whitelisted HTML should be added.
* the typeahead match template now uses `ng-bind-html` instead of `bind-html-unsafe`.
Expand Down Expand Up @@ -584,6 +593,7 @@ Revert breaking change in **dropdown** ([1a998c4](http://github.com/angular-ui/b
`min` attribute has been renamed to `min-date`
`max` attribute has been renamed to `max-date`
`Open on focus` has been removed. Read more on this ([comment](https://github.com/angular-ui/bootstrap/pull/1922#issuecomment-40491716)).
`dateFormat` renamed to `datepickerPopup` in datepickerPopupConfig

- **dropdown:**

Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(grunt) {
grunt.util.linefeed = '\n';

grunt.initConfig({
ngversion: '1.4.5',
ngversion: '1.4.6',
bsversion: '3.1.1',
modules: [],//to be filled in by build task
pkg: grunt.file.readJSON('package.json'),
Expand Down
14 changes: 7 additions & 7 deletions misc/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<li><a href="#getting_started">Getting started</a></li>
</ul>
</nav>
<nav class="visible-xs" collapse="!isCollapsed">
<nav class="visible-xs" uib-collapse="!isCollapsed">
<ul class="nav navbar-nav">
<li><a href="#getting_started" ng-click="isCollapsed = !isCollapsed">Getting started</a></li>
<li><a href="#directives_small" ng-click="isCollapsed = !isCollapsed">Directives</a></li>
Expand Down Expand Up @@ -202,18 +202,18 @@ <h1><%= module.displayName %><small>
<div class="pull-right">
<button type="button" class="btn btn-info plunk-btn" ng-click="edit('<%= ngversion%>', '<%= bsversion %>', '<%= pkg.version%>', '<%= module.name %>')"><i class="glyphicon glyphicon-edit"></i> Edit in plunker</button>
</div>
<tabset>
<tab heading="Markup">
<uib-tabset>
<uib-tab heading="Markup">
<div plunker-content="markup">
<pre ng-non-bindable><code data-language="html"><%- module.docs.html %></code></pre>
</div>
</tab>
<tab heading="JavaScript">
</uib-tab>
<uib-tab heading="JavaScript">
<div plunker-content="javascript">
<pre ng-non-bindable><code data-language="javascript"><%- module.docs.js %></code></pre>
</div>
</tab>
</tabset>
</uib-tab>
</uib-tabset>
</div>
</div>
</section>
Expand Down
159 changes: 133 additions & 26 deletions src/accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])

.constant('accordionConfig', {
.constant('uibAccordionConfig', {
closeOthers: true
})

.controller('AccordionController', ['$scope', '$attrs', 'accordionConfig', function($scope, $attrs, accordionConfig) {
.controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) {
// This array keeps track of the accordion groups
this.groups = [];

Expand Down Expand Up @@ -43,24 +43,21 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])

// The accordion directive simply sets up the directive controller
// and adds an accordion CSS class to itself element.
.directive('accordion', function() {
.directive('uibAccordion', function() {
return {
restrict: 'EA',
controller: 'AccordionController',
controller: 'UibAccordionController',
controllerAs: 'accordion',
transclude: true,
replace: false,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/accordion/accordion.html';
}
};
})

// The accordion-group directive indicates a block of html that will expand and collapse in an accordion
.directive('accordionGroup', function() {
.directive('uibAccordionGroup', function() {
return {
require: '^accordion', // We need this directive to be inside an accordion
restrict: 'EA',
require: '^uibAccordion', // We need this directive to be inside an accordion
transclude: true, // It transcludes the contents of the directive into the template
replace: true, // The element containing the directive will be replaced with the template
templateUrl: function(element, attrs) {
Expand Down Expand Up @@ -100,17 +97,13 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
})

// Use accordion-heading below an accordion-group to provide a heading containing HTML
// <accordion-group>
// <accordion-heading>Heading containing HTML - <img src="..."></accordion-heading>
// </accordion-group>
.directive('accordionHeading', function() {
.directive('uibAccordionHeading', function() {
return {
restrict: 'EA',
transclude: true, // Grab the contents to be used as the heading
template: '', // In effect remove this element!
replace: true,
require: '^accordionGroup',
link: function(scope, element, attr, accordionGroupCtrl, transclude) {
require: '^uibAccordionGroup',
link: function(scope, element, attrs, accordionGroupCtrl, transclude) {
// Pass the heading to the accordion-group controller
// so that it can be transcluded into the right place in the template
// [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
Expand All @@ -121,22 +114,136 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])

// Use in the accordion-group template to indicate where you want the heading to be transcluded
// You must provide the property on the accordion-group controller that will hold the transcluded element
// <div class="accordion-group">
// <div class="accordion-heading" ><a ... accordion-transclude="heading">...</a></div>
// ...
// </div>
.directive('accordionTransclude', function() {
.directive('uibAccordionTransclude', function() {
return {
require: '^accordionGroup',
link: function(scope, element, attr, controller) {
scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
require: ['?^uibAccordionGroup', '?^accordionGroup'],
link: function(scope, element, attrs, controller) {
controller = controller[0] ? controller[0] : controller[1]; // Delete after we remove deprecation
scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {
if (heading) {
element.find('span').html('');
element.find('span').append(heading);
}
});
}
};
})
});

/* Deprecated accordion below */

angular.module('ui.bootstrap.accordion')

.value('$accordionSuppressWarning', false)

.controller('AccordionController', ['$scope', '$attrs', '$controller', '$log', '$accordionSuppressWarning', function($scope, $attrs, $controller, $log, $accordionSuppressWarning) {
if (!$accordionSuppressWarning) {
$log.warn('AccordionController is now deprecated. Use UibAccordionController instead.');
}

angular.extend(this, $controller('UibAccordionController', {
$scope: $scope,
$attrs: $attrs
}));
}])

.directive('accordion', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
return {
restrict: 'EA',
controller: 'AccordionController',
controllerAs: 'accordion',
transclude: true,
replace: false,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/accordion/accordion.html';
},
link: function() {
if (!$accordionSuppressWarning) {
$log.warn('accordion is now deprecated. Use uib-accordion instead.');
}
}
};
}])

.directive('accordionGroup', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
return {
require: '^accordion', // We need this directive to be inside an accordion
restrict: 'EA',
transclude: true, // It transcludes the contents of the directive into the template
replace: true, // The element containing the directive will be replaced with the template
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/accordion/accordion-group.html';
},
scope: {
heading: '@', // Interpolate the heading attribute onto this scope
isOpen: '=?',
isDisabled: '=?'
},
controller: function() {
this.setHeading = function(element) {
this.heading = element;
};
},
link: function(scope, element, attrs, accordionCtrl) {
if (!$accordionSuppressWarning) {
$log.warn('accordion-group is now deprecated. Use uib-accordion-group instead.');
}

accordionCtrl.addGroup(scope);

scope.openClass = attrs.openClass || 'panel-open';
scope.panelClass = attrs.panelClass;
scope.$watch('isOpen', function(value) {
element.toggleClass(scope.openClass, !!value);
if (value) {
accordionCtrl.closeOthers(scope);
}
});

scope.toggleOpen = function($event) {
if (!scope.isDisabled) {
if (!$event || $event.which === 32) {
scope.isOpen = !scope.isOpen;
}
}
};
}
};
}])

.directive('accordionHeading', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
return {
restrict: 'EA',
transclude: true, // Grab the contents to be used as the heading
template: '', // In effect remove this element!
replace: true,
require: '^accordionGroup',
link: function(scope, element, attr, accordionGroupCtrl, transclude) {
if (!$accordionSuppressWarning) {
$log.warn('accordion-heading is now deprecated. Use uib-accordion-heading instead.');
}
// Pass the heading to the accordion-group controller
// so that it can be transcluded into the right place in the template
// [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
accordionGroupCtrl.setHeading(transclude(scope, angular.noop));
}
};
}])

.directive('accordionTransclude', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
return {
require: '^accordionGroup',
link: function(scope, element, attr, controller) {
if (!$accordionSuppressWarning) {
$log.warn('accordion-transclude is now deprecated. Use uib-accordion-transclude instead.');
}

scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
if (heading) {
element.find('span').html('');
element.find('span').append(heading);
}
});
}
};
}]);

;
38 changes: 19 additions & 19 deletions src/accordion/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<div class="panel {{panelClass || 'panel-default'}}">
<div class="panel-heading">
<h4 class="panel-title" style="color:#fa39c3">
<a href tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" accordion-transclude="heading"><span
<a href tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading"><span
ng-class="{'text-muted': isDisabled}">{{heading}}</span></a>
</h4>
</div>
<div class="panel-collapse collapse" collapse="!isOpen">
<div class="panel-collapse collapse" uib-collapse="!isOpen">
<div class="panel-body" style="text-align: right" ng-transclude></div>
</div>
</div>
Expand All @@ -24,30 +24,30 @@ <h4 class="panel-title" style="color:#fa39c3">
Open only one at a time
</label>
</div>
<accordion close-others="oneAtATime">
<accordion-group heading="Static Header, initially expanded" is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
<uib-accordion close-others="oneAtATime">
<uib-accordion-group heading="Static Header, initially expanded" is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
This content is straight in the template.
</accordion-group>
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
</uib-accordion-group>
<uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</accordion-group>
<accordion-group heading="Dynamic Body Content">
<p>The body of the accordion group grows to fit the contents</p>
</uib-accordion-group>
<uib-accordion-group heading="Dynamic Body Content">
<p>The body of the uib-accordion group grows to fit the contents</p>
<button type="button" class="btn btn-default btn-sm" ng-click="addItem()">Add Item</button>
<div ng-repeat="item in items">{{item}}</div>
</accordion-group>
<accordion-group heading="Custom template" template-url="group-template.html">
</uib-accordion-group>
<uib-accordion-group heading="Custom template" template-url="group-template.html">
Hello
</accordion-group>
<accordion-group heading="Delete account" panel-class="panel-danger">
</uib-accordion-group>
<uib-accordion-group heading="Delete account" panel-class="panel-danger">
<p>Please, to delete your account, click the button below</p>
<button class="btn btn-danger">Delete</button>
</accordion-group>
<accordion-group is-open="status.open">
<accordion-heading>
</uib-accordion-group>
<uib-accordion-group is-open="status.open">
<uib-accordion-heading>
I can have markup, too! <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"></i>
</accordion-heading>
</uib-accordion-heading>
This is just some content to illustrate fancy headings.
</accordion-group>
</accordion>
</uib-accordion-group>
</uib-accordion>
</div>
54 changes: 34 additions & 20 deletions src/accordion/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,40 @@ The **accordion directive** builds on top of the collapse directive to provide a

The body of each accordion group is transcluded into the body of the collapsible element.

### Accordion Settings

* `close-others` (Defaults: false) :
Control whether expanding an item will cause the other items to close
* `template-url` (Defaults: `template/accordion/accordion.html`) :
Add the ability to override the template used on the component.

### Accordion Group Settings

* `is-disabled` <i class="glyphicon glyphicon-eye-open"></i> (Defaults: false) :
Whether the accordion group is disabled or not.
* `is-open` <i class="glyphicon glyphicon-eye-open"></i> (Defaults: false) :
Whether accordion group is open or closed.
* `heading` (Defaults: none) :
The clickable text on the group's header. You need one to be able to click on the header for toggling.
* `panel-class` (Defaults: `panel-default`) :
Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string.
* `template-url` (Defaults: `template/accordion/accordion-group.html`) :
Add the ability to override the template used on the component.
### uib-accordion Settings

* `close-others`
_(Default: `false`)_ -
Control whether expanding an item will cause the other items to close.

* `template-url`
_(Default: `template/accordion/accordion.html`)_ -
Add the ability to override the template used on the component.

### uib-accordion Group Settings

* `is-disabled`
<i class="glyphicon glyphicon-eye-open"></i>
_(Default: `false`)_ -
Whether the accordion group is disabled or not.

* `is-open`
<i class="glyphicon glyphicon-eye-open"></i>
_(Default: `false`)_ -
Whether accordion group is open or closed.

* `heading`
_(Default: `none`)_ -
The clickable text on the group's header. You need one to be able to click on the header for toggling.

* `panel-class`
_(Default: `panel-default`)_ -
Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string.

* `template-url`
_(Default: `template/accordion/accordion-group.html`)_ -
Add the ability to override the template used on the component.

### Accordion heading

Instead of the `heading` attribute on the `accordion-group`, you can use an `accordion-heading` element inside a group that will be used as the group's header.
Instead of the `heading` attribute on the `uib-accordion-group`, you can use an `uib-accordion-heading` element inside a group that will be used as the group's header.
Loading