Skip to content

Commit

Permalink
Added disable property
Browse files Browse the repository at this point in the history
Closes #14.
  • Loading branch information
indrimuska committed Feb 25, 2016
1 parent 78b5d72 commit 48be2c2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ max-view | `"hour"` | Maximum navigable view.
start-view | `"year"` | Initial view when the picker is open.
min-date | | Two-way bindable property representing the minimum selectable date in the same format of the value.
max-date | | Two-way bindable property representing the maximum selectable date in the same format of the value.
disable | | Disables the picker if truly.

## Events

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-moment-picker",
"version": "0.3.0",
"version": "0.4.0",
"authors": [
"Indri Muska <[email protected]>"
],
Expand Down
5 changes: 3 additions & 2 deletions dist/angular-moment-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
startView: '@?',
minDate: '=?',
maxDate: '=?',
disabled: '=?disable',
change: '&?'
};
$timeout = timeout;
Expand All @@ -53,7 +54,7 @@
MomentPickerDirective.prototype.$inject = ['$timeout', '$sce', '$compile', '$document', 'momentPicker'];
MomentPickerDirective.prototype.link = function ($scope, $element, $attrs) {
$scope.template = (
'<div class="moment-picker-container {{view.selected}}-view" ng-show="view.isOpen">' +
'<div class="moment-picker-container {{view.selected}}-view" ng-show="view.isOpen && !disabled" ng-class="{\'moment-picker-disabled\': disabled}">' +
'<table class="header-view">' +
'<thead>' +
'<tr>' +
Expand Down Expand Up @@ -118,7 +119,7 @@

// utilities
$scope.momentToDate = function (value) { return angular.isDefined(value) && value.isValid() ? value.clone().toDate() : undefined; }
$scope.valueUpdate = function () { $scope.value = $scope.momentToDate($scope.valueMoment); }
$scope.valueUpdate = function () { if (!$scope.disabled) $scope.value = $scope.momentToDate($scope.valueMoment); }
$scope.limits = {
isAfterOrEqualMin: function (value, precision) {
return !angular.isDefined($scope.minDateMoment) || value.isAfter($scope.minDateMoment, precision) || value.isSame($scope.minDateMoment, precision);
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-moment-picker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-moment-picker",
"version": "0.3.0",
"version": "0.4.0",
"description": "Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js",
"main": "Gruntfile.js",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/angular-moment-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
startView: '@?',
minDate: '=?',
maxDate: '=?',
disabled: '=?disable',
change: '&?'
};
$timeout = timeout;
Expand All @@ -53,7 +54,7 @@
MomentPickerDirective.prototype.$inject = ['$timeout', '$sce', '$compile', '$document', 'momentPicker'];
MomentPickerDirective.prototype.link = function ($scope, $element, $attrs) {
$scope.template = (
'<div class="moment-picker-container {{view.selected}}-view" ng-show="view.isOpen">' +
'<div class="moment-picker-container {{view.selected}}-view" ng-show="view.isOpen && !disabled" ng-class="{\'moment-picker-disabled\': disabled}">' +
'<table class="header-view">' +
'<thead>' +
'<tr>' +
Expand Down Expand Up @@ -118,7 +119,7 @@

// utilities
$scope.momentToDate = function (value) { return angular.isDefined(value) && value.isValid() ? value.clone().toDate() : undefined; }
$scope.valueUpdate = function () { $scope.value = $scope.momentToDate($scope.valueMoment); }
$scope.valueUpdate = function () { if (!$scope.disabled) $scope.value = $scope.momentToDate($scope.valueMoment); }
$scope.limits = {
isAfterOrEqualMin: function (value, precision) {
return !angular.isDefined($scope.minDateMoment) || value.isAfter($scope.minDateMoment, precision) || value.isSame($scope.minDateMoment, precision);
Expand Down

0 comments on commit 48be2c2

Please sign in to comment.