Skip to content

Commit

Permalink
Version 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Lins committed Jun 15, 2015
1 parent 6cf3699 commit cd0ffd9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "MIT",
"ignore": [],
"description": "A complete datepicker written from scratch built on top of AngularJS",
"version": "0.2.2",
"version": "0.2.3",
"main": [
"./paDatepicker.min.js",
"./paDatepicker.tpls.js"
Expand Down
38 changes: 19 additions & 19 deletions paDatepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@
init: function() {
this.selections = {};

this.initConfig();
this.initToday();
this.initCurrentPeriod();
this.initModel();
Expand All @@ -321,17 +320,6 @@
}.bind(this));
},

initConfig: function() {
this.config = angular.copy(paDatepickerConfig);

angular.forEach(this.config, function(value, option) {
if (typeof this[option] !== 'undefined') {
var newValue = this[option] !== 'false' ? this[option] : false;
this.config[option] = newValue;
}
}.bind(this));
},

initToday: function() {
this.today = new Date();
this.today.setHours(0, 0, 0, 0);
Expand All @@ -340,7 +328,7 @@
initPanels: function() {
this.datePanels = [];

var numberOfPanels = parseInt(this.config.panels, 10);
var numberOfPanels = parseInt(this.getConfig('panels'), 10);
var base = this.getPanelStart();

for (var i = 0; i < numberOfPanels; i++) {
Expand Down Expand Up @@ -370,6 +358,11 @@
}
},

getConfig: function(config) {
var value = this[config] || paDatepickerConfig[config];
return value !== 'false' ? value : false;
},

getPanelStart: function() {
if (this.isRange()) {
return this.getRangePanelStart();
Expand Down Expand Up @@ -426,7 +419,10 @@
},

startSelection: function(date) {
this.selections[this.currentPeriod] = { selected: date, start: date, end: date };
this.selections[this.currentPeriod] = {
selected: date, start: date, end: date
};

$rootScope.$broadcast('paDatepicker.selection.started');
},

Expand Down Expand Up @@ -464,13 +460,16 @@
},

isRange: function() {
return this.config.mode === 'range';
return this.getConfig('mode') === 'range';
},

isDateEnabled: function(date) {
if (this.config.minDate && this.compare(date, this.config.minDate) < 0) {
var minDate = this.getConfig('minDate');
var maxDate = this.getConfig('maxDate');

if (minDate && this.compare(date, minDate) < 0) {
return false;
} else if (this.config.maxDate && this.compare(date, this.config.maxDate) > 0) {
} else if (maxDate && this.compare(date, maxDate) > 0) {
return false;
} else {
return true;
Expand All @@ -483,7 +482,8 @@
this.isDateWithinComparisonPeriod(date);
}

return this.ngModel instanceof Date && date.getTime() === this.ngModel.getTime();
return this.ngModel instanceof Date &&
date.getTime() === this.ngModel.getTime();
},

isDateWithinBasePeriod: function(date) {
Expand Down Expand Up @@ -523,7 +523,7 @@
},

getStartingDay: function() {
return (parseInt(this.config.startingDay, 10) % 7) || 0;
return (parseInt(this.getConfig('startingDay'), 10) % 7) || 0;
},

closePopup: function() {
Expand Down
Loading

0 comments on commit cd0ffd9

Please sign in to comment.