Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: eternicode/bootstrap-datepicker
base: master
...
head fork: calendar42/bootstrap-datepicker
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 5 commits
  • 46 files changed
  • 0 commit comments
  • 3 contributors
Showing with 91 additions and 36 deletions.
  1. 0  .gitignore
  2. 0  .hgignore
  3. 0  LICENSE
  4. 0  README.md
  5. 0  build/build.less
  6. 0  build/build_standalone.less
  7. 0  css/datepicker.css
  8. +83 −35 js/bootstrap-datepicker.js
  9. 0  js/locales/bootstrap-datepicker.br.js
  10. 0  js/locales/bootstrap-datepicker.cs.js
  11. 0  js/locales/bootstrap-datepicker.da.js
  12. 0  js/locales/bootstrap-datepicker.de.js
  13. 0  js/locales/bootstrap-datepicker.es.js
  14. 0  js/locales/bootstrap-datepicker.fi.js
  15. 0  js/locales/bootstrap-datepicker.fr.js
  16. 0  js/locales/bootstrap-datepicker.is.js
  17. 0  js/locales/bootstrap-datepicker.it.js
  18. 0  js/locales/bootstrap-datepicker.lv.js
  19. 0  js/locales/bootstrap-datepicker.ms.js
  20. 0  js/locales/bootstrap-datepicker.nb.js
  21. 0  js/locales/bootstrap-datepicker.nl.js
  22. 0  js/locales/bootstrap-datepicker.pl.js
  23. 0  js/locales/bootstrap-datepicker.ru.js
  24. 0  js/locales/bootstrap-datepicker.sv.js
  25. 0  js/locales/bootstrap-datepicker.th.js
  26. 0  js/locales/bootstrap-datepicker.tr.js
  27. 0  js/locales/bootstrap-datepicker.zh-CN.js
  28. +8 −1 less/datepicker.less
  29. 0  tests/README.md
  30. 0  tests/_coverage.html
  31. 0  tests/assets/coverage.js
  32. 0  tests/assets/jquery-1.7.1.min.js
  33. 0  tests/assets/mock.js
  34. 0  tests/assets/qunit-logging.js
  35. 0  tests/assets/qunit.css
  36. 0  tests/assets/qunit.js
  37. 0  tests/assets/utils.js
  38. 0  tests/run-qunit.js
  39. 0  tests/suites/component.js
  40. 0  tests/suites/formats.js
  41. 0  tests/suites/keyboard_navigation/2011.js
  42. 0  tests/suites/keyboard_navigation/2012.js
  43. 0  tests/suites/mouse_navigation/2011.js
  44. 0  tests/suites/mouse_navigation/2012.js
  45. 0  tests/suites/options.js
  46. 0  tests/tests.html
View
0  .gitignore 100644 → 100755
File mode changed
View
0  .hgignore 100644 → 100755
File mode changed
View
0  LICENSE 100644 → 100755
File mode changed
View
0  README.md 100644 → 100755
File mode changed
View
0  build/build.less 100644 → 100755
File mode changed
View
0  build/build_standalone.less 100644 → 100755
File mode changed
View
0  css/datepicker.css 100644 → 100755
File mode changed
View
118 js/bootstrap-datepicker.js 100644 → 100755
@@ -28,7 +28,8 @@
this.language = this.language in dates ? this.language : "en";
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
this.picker = $(DPGlobal.template)
- .appendTo('body')
+ .attr('data-element-id', this.element.attr('id'))
+ .appendTo('body')
.on({
click: $.proxy(this.click, this),
mousedown: $.proxy(this.mousedown, this)
@@ -87,7 +88,8 @@
this.viewMode = this.startViewMode = 0;
break;
}
-
+ this.moveInputCursor = options.moveInputCursor || false;
+ this.pullRight = this.element.hasClass('pull-right');
this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
this.weekEnd = ((this.weekStart + 6) % 7);
this.startDate = -Infinity;
@@ -106,6 +108,7 @@
show: function(e) {
this.picker.show();
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
+ this.width = this.component ? this.component.outerWidth() : this.element.outerWidth();
this.place();
$(window).on('resize', $.proxy(this.place, this));
if (e ) {
@@ -194,10 +197,18 @@
place: function(){
var offset = this.component ? this.component.offset() : this.element.offset();
- this.picker.css({
- top: offset.top + this.height,
- left: offset.left
- });
+ if (this.pullRight) {
+ this.picker.css({
+ top: offset.top + this.height,
+ left:'auto',
+ right: window.innerWidth - offset.left - this.width
+ }).addClass('pull-right');
+ } else {
+ this.picker.css({
+ top: offset.top + this.height,
+ left: offset.left
+ });
+ }
},
update: function(){
@@ -256,25 +267,40 @@
nextMonth = nextMonth.valueOf();
html = [];
var clsName;
+ var today = new Date();
+ today.setHours(0);
+ today.setMinutes(0);
+ today.setSeconds(0);
+ today.setMilliseconds(0);
+
+ var rowContent = '';
+ var rowClass = '';
while(prevMonth.valueOf() < nextMonth) {
- if (prevMonth.getDay() == this.weekStart) {
- html.push('<tr>');
- }
clsName = '';
if (prevMonth.getFullYear() < year || (prevMonth.getFullYear() == year && prevMonth.getMonth() < month)) {
clsName += ' old';
} else if (prevMonth.getFullYear() > year || (prevMonth.getFullYear() == year && prevMonth.getMonth() > month)) {
clsName += ' new';
}
+ if (prevMonth.valueOf() === today.valueOf()) {
+ clsName += ' today';
+ }
if (prevMonth.valueOf() == currentDate) {
clsName += ' active';
+ rowClass += ' active';
}
if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate) {
clsName += ' disabled';
}
- html.push('<td class="day'+clsName+'">'+prevMonth.getDate() + '</td>');
+
+ rowContent += '<td class="day'+clsName+'">'+prevMonth.getDate() + '</td>';
if (prevMonth.getDay() == this.weekEnd) {
+ html.push('<tr class="week'+rowClass+'">');
+ html.push(rowContent);
html.push('</tr>');
+
+ rowContent = '';
+ rowClass = '';
}
prevMonth.setDate(prevMonth.getDate()+1);
}
@@ -498,34 +524,50 @@
break;
case 37: // left
case 39: // right
- dir = e.keyCode == 37 ? -1 : 1;
- if (e.ctrlKey){
- this.date = this.moveYear(this.date, dir);
- this.viewDate = this.moveYear(this.viewDate, dir);
- } else if (e.shiftKey){
- this.date = this.moveMonth(this.date, dir);
- this.viewDate = this.moveMonth(this.viewDate, dir);
- } else {
- this.date.setDate(this.date.getDate() + dir);
- this.viewDate.setDate(this.viewDate.getDate() + dir);
+ if(this.moveInputCursor === false){
+ dir = e.keyCode == 37 ? -1 : 1;
+ if (e.ctrlKey){
+ this.date = this.moveYear(this.date, dir);
+ this.viewDate = this.moveYear(this.viewDate, dir);
+ } else if (e.shiftKey){
+ this.date = this.moveMonth(this.date, dir);
+ this.viewDate = this.moveMonth(this.viewDate, dir);
+ } else {
+ this.date.setDate(this.date.getDate() + dir);
+ this.viewDate.setDate(this.viewDate.getDate() + dir);
+ }
+ this.setValue();
+ this.update();
+ e.preventDefault();
+ dateChanged = true;
}
- this.setValue();
- this.update();
- e.preventDefault();
- dateChanged = true;
break;
case 38: // up
case 40: // down
- dir = e.keyCode == 38 ? -1 : 1;
- if (e.ctrlKey){
- this.date = this.moveYear(this.date, dir);
- this.viewDate = this.moveYear(this.viewDate, dir);
- } else if (e.shiftKey){
- this.date = this.moveMonth(this.date, dir);
- this.viewDate = this.moveMonth(this.viewDate, dir);
- } else {
- this.date.setDate(this.date.getDate() + dir * 7);
- this.viewDate.setDate(this.viewDate.getDate() + dir * 7);
+ if(this.moveInputCursor === false){
+ dir = e.keyCode == 38 ? -1 : 1;
+ if (e.ctrlKey){
+ this.date = this.moveYear(this.date, dir);
+ this.viewDate = this.moveYear(this.viewDate, dir);
+ } else if (e.shiftKey){
+ this.date = this.moveMonth(this.date, dir);
+ this.viewDate = this.moveMonth(this.viewDate, dir);
+ } else {
+ this.date.setDate(this.date.getDate() + dir * 7);
+ this.viewDate.setDate(this.viewDate.getDate() + dir * 7);
+ }
+ }else{
+ dir = e.keyCode == 40 ? 1 : -1;
+ if (e.ctrlKey){
+ this.date = this.moveYear(this.date, dir);
+ this.viewDate = this.moveYear(this.viewDate, dir);
+ } else if (e.shiftKey){
+ this.date = this.moveMonth(this.date, dir);
+ this.viewDate = this.moveMonth(this.viewDate, dir);
+ } else {
+ this.date.setDate(this.date.getDate() + dir);
+ this.viewDate.setDate(this.viewDate.getDate() + dir);
+ }
}
this.setValue();
this.update();
@@ -571,9 +613,15 @@
data = $this.data('datepicker'),
options = typeof option == 'object' && option;
if (!data) {
+ $('.datepicker[data-element-id="' + $this.attr('id') + '"]').remove(); // TODO: Have a better way of reusing the datepicker
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
}
- if (typeof option == 'string') data[option].apply(data, args);
+ if (typeof option == 'string' && option === 'destroy') {
+ data.picker.remove();
+ $this.removeData('datepicker');
+ } else if (typeof option == 'string') {
+ data[option].apply(data, args);
+ }
});
};
View
0  js/locales/bootstrap-datepicker.br.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.cs.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.da.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.de.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.es.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.fi.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.fr.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.is.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.it.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.lv.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.ms.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.nb.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.nl.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.pl.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.ru.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.sv.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.th.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.tr.js 100644 → 100755
File mode changed
View
0  js/locales/bootstrap-datepicker.zh-CN.js 100644 → 100755
File mode changed
View
9 less/datepicker.less 100644 → 100755
@@ -7,7 +7,6 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
-
.datepicker {
top: 0;
left: 0;
@@ -25,6 +24,10 @@
top: -7px;
left: 6px;
}
+ &.pull-right:before {
+ left: auto;
+ right: 7px;
+ }
&:after {
content: '';
display: inline-block;
@@ -35,6 +38,10 @@
top: -6px;
left: 7px;
}
+ &.pull-right:after {
+ left: auto;
+ right: 7px;
+ }
>div {
display: none;
}
View
0  tests/README.md 100644 → 100755
File mode changed
View
0  tests/_coverage.html 100644 → 100755
File mode changed
View
0  tests/assets/coverage.js 100644 → 100755
File mode changed
View
0  tests/assets/jquery-1.7.1.min.js 100644 → 100755
File mode changed
View
0  tests/assets/mock.js 100644 → 100755
File mode changed
View
0  tests/assets/qunit-logging.js 100644 → 100755
File mode changed
View
0  tests/assets/qunit.css 100644 → 100755
File mode changed
View
0  tests/assets/qunit.js 100644 → 100755
File mode changed
View
0  tests/assets/utils.js 100644 → 100755
File mode changed
View
0  tests/run-qunit.js 100644 → 100755
File mode changed
View
0  tests/suites/component.js 100644 → 100755
File mode changed
View
0  tests/suites/formats.js 100644 → 100755
File mode changed
View
0  tests/suites/keyboard_navigation/2011.js 100644 → 100755
File mode changed
View
0  tests/suites/keyboard_navigation/2012.js 100644 → 100755
File mode changed
View
0  tests/suites/mouse_navigation/2011.js 100644 → 100755
File mode changed
View
0  tests/suites/mouse_navigation/2012.js 100644 → 100755
File mode changed
View
0  tests/suites/options.js 100644 → 100755
File mode changed
View
0  tests/tests.html 100644 → 100755
File mode changed

No commit comments for this range

Something went wrong with that request. Please try again.