Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,30 @@ angular-kalendae
================

Angular directive to create a dropdown or inline datepicker using the Javascript agnostic library Kalendae.


angular demo mode='multiple':
1. include module:
```html
var App = angular.module('app', ['Kalendae']);
```

2. using directive in html:
```html
<div id="kalendaeDiv" style="width:175px; height:175px;" kalendae ng-model="constData.kalendaeDivVal"
callback="confirm()"
mode='multiple'> </div>
```

3. in your controller define confrim function and variable:
```html
$scope.constData = {
kalendaeDivVal: "2017-07-12, 2017-07-14" // init values
};

$scope.confirm = function (){ //callback after selected date
console.log( $scope.constData );
}
```


22 changes: 19 additions & 3 deletions angular.kalendae.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.directive('kalendae', ['$parse', 'kal', 'KalendaeAPI', function($parse, k
// Requires animate.css in order to animate.
angular.element(datePicker.container).addClass('animated fadeInDown');

datePicker.subscribe('date-clicked', function(date) {
/*datePicker.subscribe('date-clicked', function(date) {
var selectedDate = KalendaeAPI.setDate(date);
model.assign(scope, selectedDate);
scope.$apply(function() {
Expand All @@ -41,7 +41,7 @@ module.directive('kalendae', ['$parse', 'kal', 'KalendaeAPI', function($parse, k

// When using the dropdown datepicker, hide after selecting a date.
attrs.kalendae === 'dropdown' && element[0].blur();
});
});*/

// On init set date to the current model value.
var defaultDate = scope.$eval(attrs.ngModel);
Expand All @@ -53,6 +53,19 @@ module.directive('kalendae', ['$parse', 'kal', 'KalendaeAPI', function($parse, k

// When using the dropdown datepicker, hide after selecting a date.
attrs.kalendae === 'dropdown' && element[0].blur();

datePicker.subscribe('change', function(date) {

var selectedDate = KalendaeAPI.getSelected();
model.assign(scope, selectedDate);
scope.$apply(function() {
scope.$eval(attrs.callback);
});

// When using the dropdown datepicker, hide after selecting a date.
attrs.kalendae === 'dropdown' && element[0].blur();

});
}
};
}]);
Expand Down Expand Up @@ -107,6 +120,9 @@ module.factory('KalendaeAPI', ['Moment', function(Moment) {
}

return valueByDate;
},
getSelected: function () { // when using mode:multiple, you can getSelected values
return this.datePicker.getSelected();
}
};
}]);
}]);