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

Commit

Permalink
fix(datepicker): remove edge case position updates
Browse files Browse the repository at this point in the history
Closes #1296
  • Loading branch information
bekos committed Dec 18, 2013
1 parent 48955d6 commit 1fbcb5d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
10 changes: 2 additions & 8 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,22 +381,16 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon

element.bind('input change keyup', function() {
scope.$apply(function() {
updateCalendar();
scope.date = ngModel.$modelValue;
});
});

// Outter change
ngModel.$render = function() {
var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : '';
element.val(date);

updateCalendar();
};

function updateCalendar() {
scope.date = ngModel.$modelValue;
updatePosition();
}
};

function addWatchableAttribute(attribute, scopeProperty, datepickerAttribute) {
if (attribute) {
Expand Down
8 changes: 5 additions & 3 deletions src/datepicker/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
<pre>Selected date is: <em>{{dt | date:'fullDate' }}</em></pre>

<h4>Inline</h4>
<div class="well well-small" ng-model="dt" style="display:inline-block;">
<datepicker min="minDate" show-weeks="showWeeks"></datepicker>
<div style="display:inline-block; min-height:290px;">
<div class="well well-small" ng-model="dt">
<datepicker min="minDate" show-weeks="showWeeks"></datepicker>
</div>
</div>

<h4>Popup</h4>
<div class="form-horizontal">
<p>
<input type="text" datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
<button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
<button class="btn" ng-click="open($event)"><i class="icon-calendar"></i></button>
</p>
<p><i>Format options:</i> <select ng-model="format" ng-options="f for f in formats"><option></option></select></p>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/datepicker/docs/demo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var DatepickerDemoCtrl = function ($scope, $timeout) {
var DatepickerDemoCtrl = function ($scope) {
$scope.today = function() {
$scope.dt = new Date();
};
Expand All @@ -23,10 +23,11 @@ var DatepickerDemoCtrl = function ($scope, $timeout) {
};
$scope.toggleMin();

$scope.open = function() {
$timeout(function() {
$scope.opened = true;
});
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();

$scope.opened = true;
};

$scope.dateOptions = {
Expand Down

0 comments on commit 1fbcb5d

Please sign in to comment.