diff --git a/.gitignore b/.gitignore index d106a75394..cf5742df1b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ lib-cov *.swp *.swo .DS_Store +.idea pids logs diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index a98b48dc7e..9d842a9797 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -471,7 +471,9 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi clearText: '@', closeText: '@', dateDisabled: '&', - customClass: '&' + customClass: '&', + position: '@' + }, link: function(scope, element, attrs, ngModel) { var dateFormat, @@ -682,7 +684,28 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi if (value) { scope.$broadcast('datepicker.focus'); scope.position = appendToBody ? $position.offset(element) : $position.position(element); - scope.position.top = scope.position.top + element.prop('offsetHeight'); + + var clearPosition = function() { + scope.position.top = scope.position.bottom = scope.position.left = scope.position.right = 'initial'; + }; + + if (!scope.position || scope.position === 'bottom-left') { + clearPosition(); + scope.position.left = 0; + scope.position.top = $position.position(element).height + 'px'; + } else if (scope.position === 'bottom-right') { + clearPosition(); + scope.position.right = 0; + scope.position.top = $position.position(element).height + 'px'; + } else if (scope.position === 'top-right') { + clearPosition(); + scope.position.right = 0; + scope.position.bottom = $position.position(element).height + 'px'; + } else if (scope.position === 'top-left') { + clearPosition(); + scope.position.left = 0; + scope.position.bottom = $position.position(element).height + 'px'; + } $document.bind('click', documentClickBind); } else { diff --git a/src/datepicker/docs/demo.html b/src/datepicker/docs/demo.html index 7ea3b98fd2..477e429476 100644 --- a/src/datepicker/docs/demo.html +++ b/src/datepicker/docs/demo.html @@ -22,7 +22,7 @@

Popup

- + diff --git a/src/datepicker/docs/readme.md b/src/datepicker/docs/readme.md index baa493d234..5365b69cb6 100644 --- a/src/datepicker/docs/readme.md +++ b/src/datepicker/docs/readme.md @@ -119,6 +119,10 @@ Specific settings for the `datepicker-popup`, that can globally configured throu _(Default: false)_: Append the datepicker popup element to `body`, rather than inserting after `datepicker-popup`. For global configuration, use `datepickerPopupConfig.appendToBody`. + * `position` + _(Default: 'bottom-left')_ : + Where datepicker should be displayed. Options _(bottom-left|bottom-right|top-left|top-right)_ + ### Keyboard Support ### Depending on datepicker's current mode, the date may reffer either to day, month or year. Accordingly, the term view reffers either to a month, year or year range. diff --git a/template/datepicker/popup.html b/template/datepicker/popup.html index 483bbe1e7f..73fd6ace23 100644 --- a/template/datepicker/popup.html +++ b/template/datepicker/popup.html @@ -1,10 +1,16 @@ -

\ No newline at end of file