Skip to content

Commit 5bc0851

Browse files
BobbieBarkerwesleycho
authored andcommitted
feat(dropdown): uib- prefix
Closes angular-ui#4510
1 parent 6158091 commit 5bc0851

File tree

3 files changed

+164
-61
lines changed

3 files changed

+164
-61
lines changed

Diff for: src/dropdown/docs/demo.html

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11

22
<div ng-controller="DropdownCtrl">
33
<!-- Simple dropdown -->
4-
<span dropdown on-toggle="toggled(open)">
5-
<a href id="simple-dropdown" dropdown-toggle>
4+
<span uib-dropdown on-toggle="toggled(open)">
5+
<a href id="simple-dropdown" uib-dropdown-toggle>
66
Click me for a dropdown, yo!
77
</a>
8-
<ul class="dropdown-menu" aria-labelledby="simple-dropdown">
8+
<ul class="uib-dropdown-menu" aria-labelledby="simple-dropdown">
99
<li ng-repeat="choice in items">
1010
<a href>{{choice}}</a>
1111
</li>
1212
</ul>
1313
</span>
1414

1515
<!-- Single button -->
16-
<div class="btn-group" dropdown is-open="status.isopen">
17-
<button id="single-button" type="button" class="btn btn-primary" dropdown-toggle ng-disabled="disabled">
16+
<div class="btn-group" uib-dropdown is-open="status.isopen">
17+
<button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
1818
Button dropdown <span class="caret"></span>
1919
</button>
20-
<ul class="dropdown-menu" role="menu" aria-labelledby="single-button">
20+
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="single-button">
2121
<li role="menuitem"><a href="#">Action</a></li>
2222
<li role="menuitem"><a href="#">Another action</a></li>
2323
<li role="menuitem"><a href="#">Something else here</a></li>
@@ -27,13 +27,13 @@
2727
</div>
2828

2929
<!-- Split button -->
30-
<div class="btn-group" dropdown>
30+
<div class="btn-group" uib-dropdown>
3131
<button id="split-button" type="button" class="btn btn-danger">Action</button>
32-
<button type="button" class="btn btn-danger" dropdown-toggle>
32+
<button type="button" class="btn btn-danger" uib-dropdown-toggle>
3333
<span class="caret"></span>
3434
<span class="sr-only">Split button!</span>
3535
</button>
36-
<ul class="dropdown-menu" role="menu" aria-labelledby="split-button">
36+
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="split-button">
3737
<li role="menuitem"><a href="#">Action</a></li>
3838
<li role="menuitem"><a href="#">Another action</a></li>
3939
<li role="menuitem"><a href="#">Something else here</a></li>
@@ -43,11 +43,11 @@
4343
</div>
4444

4545
<!-- Single button using append-to-body -->
46-
<div class="btn-group" dropdown dropdown-append-to-body>
47-
<button id="btn-append-to-body" type="button" class="btn btn-primary" dropdown-toggle>
46+
<div class="btn-group" uib-dropdown dropdown-append-to-body>
47+
<button id="btn-append-to-body" type="button" class="btn btn-primary" uib-dropdown-toggle>
4848
Dropdown on Body <span class="caret"></span>
4949
</button>
50-
<ul class="dropdown-menu" role="menu" aria-labelledby="btn-append-to-body">
50+
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="btn-append-to-body">
5151
<li role="menuitem"><a href="#">Action</a></li>
5252
<li role="menuitem"><a href="#">Another action</a></li>
5353
<li role="menuitem"><a href="#">Something else here</a></li>
@@ -57,11 +57,11 @@
5757
</div>
5858

5959
<!-- Single button using template-url -->
60-
<div class="btn-group" dropdown>
61-
<button id="button-template-url" type="button" class="btn btn-primary" dropdown-toggle ng-disabled="disabled">
60+
<div class="btn-group" uib-dropdown>
61+
<button id="button-template-url" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
6262
Dropdown using template <span class="caret"></span>
6363
</button>
64-
<ul class="dropdown-menu" template-url="dropdown.html" aria-labelledby="button-template-url">
64+
<ul class="uib-dropdown-menu" template-url="dropdown.html" aria-labelledby="button-template-url">
6565
</ul>
6666
</div>
6767

@@ -73,11 +73,11 @@
7373

7474
<hr>
7575
<!-- Single button with keyboard nav -->
76-
<div class="btn-group" dropdown keyboard-nav>
77-
<button id="simple-btn-keyboard-nav" type="button" class="btn btn-primary" dropdown-toggle>
76+
<div class="btn-group" uib-dropdown keyboard-nav>
77+
<button id="simple-btn-keyboard-nav" type="button" class="btn btn-primary" uib-dropdown-toggle>
7878
Dropdown with keyboard navigation <span class="caret"></span>
7979
</button>
80-
<ul class="dropdown-menu" role="menu" aria-labelledby="simple-btn-keyboard-nav">
80+
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="simple-btn-keyboard-nav">
8181
<li role="menuitem"><a href="#">Action</a></li>
8282
<li role="menuitem"><a href="#">Another action</a></li>
8383
<li role="menuitem"><a href="#">Something else here</a></li>
@@ -87,7 +87,7 @@
8787
</div>
8888

8989
<script type="text/ng-template" id="dropdown.html">
90-
<ul class="dropdown-menu" role="menu" aria-labelledby="button-template-url">
90+
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="button-template-url">
9191
<li role="menuitem"><a href="#">Action in Template</a></li>
9292
<li role="menuitem"><a href="#">Another action in Template</a></li>
9393
<li role="menuitem"><a href="#">Something else here</a></li>

Diff for: src/dropdown/dropdown.js

+63-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
44
openClass: 'open'
55
})
66

7-
.service('dropdownService', ['$document', '$rootScope', function($document, $rootScope) {
7+
.service('uibDropdownService', ['$document', '$rootScope', function($document, $rootScope) {
88
var openScope = null;
99

1010
this.open = function(dropdownScope) {
@@ -65,7 +65,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
6565
};
6666
}])
6767

68-
.controller('DropdownController', ['$scope', '$attrs', '$parse', 'dropdownConfig', 'dropdownService', '$animate', '$position', '$document', '$compile', '$templateRequest', function($scope, $attrs, $parse, dropdownConfig, dropdownService, $animate, $position, $document, $compile, $templateRequest) {
68+
.controller('UibDropdownController', ['$scope', '$attrs', '$parse', 'dropdownConfig', 'uibDropdownService', '$animate', '$position', '$document', '$compile', '$templateRequest', function($scope, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest) {
6969
var self = this,
7070
scope = $scope.$new(), // create a child scope so we are not polluting original one
7171
templateScope,
@@ -91,7 +91,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
9191
}
9292

9393
appendToBody = angular.isDefined($attrs.dropdownAppendToBody);
94-
keynavEnabled = angular.isDefined($attrs.keyboardNav);
94+
keynavEnabled = angular.isDefined($attrs.uibKeyboardNav);
9595

9696
if (appendToBody && self.dropdownMenu) {
9797
body.append(self.dropdownMenu);
@@ -207,7 +207,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
207207
}
208208

209209
scope.focusToggleElement();
210-
dropdownService.open(scope);
210+
uibDropdownService.open(scope);
211211
} else {
212212
if (self.dropdownMenuTemplateUrl) {
213213
if (templateScope) {
@@ -218,7 +218,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
218218
self.dropdownMenu = newEl;
219219
}
220220

221-
dropdownService.close(scope);
221+
uibDropdownService.close(scope);
222222
self.selectedOption = null;
223223
}
224224

@@ -239,20 +239,20 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
239239
scope.$on('$destroy', offDestroy);
240240
}])
241241

242-
.directive('dropdown', function() {
242+
.directive('uibDropdown', function() {
243243
return {
244-
controller: 'DropdownController',
244+
controller: 'UibDropdownController',
245245
link: function(scope, element, attrs, dropdownCtrl) {
246246
dropdownCtrl.init(element);
247247
element.addClass('dropdown');
248248
}
249249
};
250250
})
251251

252-
.directive('dropdownMenu', function() {
252+
.directive('uibDropdownMenu', function() {
253253
return {
254254
restrict: 'AC',
255-
require: '?^dropdown',
255+
require: '?^uibDropdown',
256256
link: function(scope, element, attrs, dropdownCtrl) {
257257
if (!dropdownCtrl) {
258258
return;
@@ -268,10 +268,10 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
268268
};
269269
})
270270

271-
.directive('keyboardNav', function() {
271+
.directive('uibKeyboardNav', function() {
272272
return {
273273
restrict: 'A',
274-
require: '?^dropdown',
274+
require: '?^uibDropdown',
275275
link: function(scope, element, attrs, dropdownCtrl) {
276276
element.bind('keydown', function(e) {
277277
if ([38, 40].indexOf(e.which) !== -1) {
@@ -307,9 +307,9 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
307307
};
308308
})
309309

310-
.directive('dropdownToggle', function() {
310+
.directive('uibDropdownToggle', function() {
311311
return {
312-
require: '?^dropdown',
312+
require: '?^uibDropdown',
313313
link: function(scope, element, attrs, dropdownCtrl) {
314314
if (!dropdownCtrl) {
315315
return;
@@ -343,3 +343,53 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
343343
}
344344
};
345345
});
346+
347+
/* Depreciated dropdown below */
348+
349+
angular.module('ui.bootstrap.dropdown')
350+
.value('$dropdownSuppressWarning', false)
351+
.directive('dropdown', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
352+
return {
353+
link: function(scope, element, attrs, dropdownCtrl) {
354+
if (!$dropdownSuppressWarning) {
355+
$log.warn('dropdown is now deprecated. Use uib-dropdown instead.');
356+
}
357+
}
358+
};
359+
}])
360+
361+
.directive('dropdownMenu', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
362+
return {
363+
restrict: 'AC',
364+
require: '?^dropdown',
365+
link: function(scope, element, attrs, dropdownCtrl) {
366+
if (!$dropdownSuppressWarning) {
367+
$log.warn('dropdown-menu is now deprecated. Use uib-dropdown-menu instead.');
368+
}
369+
}
370+
};
371+
}])
372+
373+
.directive('keyboardNav', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
374+
return {
375+
restrict: 'A',
376+
require: '?^dropdown',
377+
link: function(scope, element, attrs, dropdownCtrl) {
378+
if (!$dropdownSuppressWarning) {
379+
$log.warn('keyboard-nav is now deprecated. Use uib-keyboard-nav instead.');
380+
}
381+
}
382+
};
383+
}])
384+
385+
.directive('dropdownToggle', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
386+
return {
387+
require: '?^dropdown',
388+
link: function(scope, element, attrs, dropdownCtrl) {
389+
if (!$dropdownSuppressWarning) {
390+
$log.warn('dropdown-toggle is now deprecated. Use uib-dropdown-toggle instead.');
391+
}
392+
}
393+
};
394+
}]);
395+

0 commit comments

Comments
 (0)