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

Commit

Permalink
feat(datepicker): remove replace: true usage
Browse files Browse the repository at this point in the history
- Remove `replace: true` usage

BREAKING CHANGE: As a result of removal of `replace: true`, there is the potential that this may break some CSS layout due to the slightly different HTML. Refer to the documentation examples to see the new structure.

Closes #5988
  • Loading branch information
wesleycho committed Jun 13, 2016
1 parent 1a870a3 commit e92fb7f
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 64 deletions.
21 changes: 15 additions & 6 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
yearRows: 4
})

.controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',
function($scope, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {
.controller('UibDatepickerController', ['$scope', '$element', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',
function($scope, $element, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {
var self = this,
ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;
ngModelOptions = {},
watchListeners = [],
optionsUsed = !!$attrs.datepickerOptions;

$element.addClass('uib-datepicker');
$attrs.$set('role', 'application');

if (!$scope.datepickerOptions) {
$scope.datepickerOptions = {};
}
Expand Down Expand Up @@ -330,6 +333,12 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
}
};

$element.on('keydown', function(evt) {
$scope.$apply(function() {
$scope.keydown(evt);
});
});

$scope.$on('$destroy', function() {
//Clear all watch listeners on destroy
while (watchListeners.length) {
Expand Down Expand Up @@ -572,14 +581,14 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

.directive('uibDatepicker', function() {
return {
replace: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'uib/template/datepicker/datepicker.html';
},
scope: {
datepickerOptions: '=?'
},
require: ['uibDatepicker', '^ngModel'],
restrict: 'A',
controller: 'UibDatepickerController',
controllerAs: 'datepicker',
link: function(scope, element, attrs, ctrls) {
Expand All @@ -592,11 +601,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

.directive('uibDaypicker', function() {
return {
replace: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'uib/template/datepicker/day.html';
},
require: ['^uibDatepicker', 'uibDaypicker'],
restrict: 'A',
controller: 'UibDaypickerController',
link: function(scope, element, attrs, ctrls) {
var datepickerCtrl = ctrls[0],
Expand All @@ -609,11 +618,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

.directive('uibMonthpicker', function() {
return {
replace: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'uib/template/datepicker/month.html';
},
require: ['^uibDatepicker', 'uibMonthpicker'],
restrict: 'A',
controller: 'UibMonthpickerController',
link: function(scope, element, attrs, ctrls) {
var datepickerCtrl = ctrls[0],
Expand All @@ -626,11 +635,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

.directive('uibYearpicker', function() {
return {
replace: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'uib/template/datepicker/year.html';
},
require: ['^uibDatepicker', 'uibYearpicker'],
restrict: 'A',
controller: 'UibYearpickerController',
link: function(scope, element, attrs, ctrls) {
var ctrl = ctrls[0];
Expand Down
2 changes: 1 addition & 1 deletion src/datepicker/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<h4>Inline</h4>
<div style="display:inline-block; min-height:290px;">
<uib-datepicker ng-model="dt" class="well well-sm" datepicker-options="options"></uib-datepicker>
<div uib-datepicker ng-model="dt" class="well well-sm" datepicker-options="options"></div>
</div>

<hr />
Expand Down
Loading

1 comment on commit e92fb7f

@justforuse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to your work, I'm curious about why you add ' restrict:"A" ' to datepicker , It is no matter to me, I can just change my usage, but just wonder is this necessary?

Please sign in to comment.