zpzMdCalendar is a calendar module designed for use with Angular Material which allows for date selection and event previewing.
Documentation is not complete yet but it's enough to get you up with your first
instance of it. See the /demo
folder to check out how to create events and display
them.
Use either Bower or NPM to install zpzMdCalendar as follows:
bower install zpz-md-calendar
npm install zpz-md-calendar
<script src="/path/to/bower_components/zpz-md-calendar/dist/zpz-md-calendar.min.js"></script>
<link rel="stylesheet" href="/path/to/bower_components/zpz-md-calendar/dist/zpz-md-calendar.min.css" />
Add the zpzMdCalendar
module to your own app like this:
angular.module('YourApp', [
/*other modules...*/
'zpzMdCalendar'
/*other modules...*/
]);
In your HTML, use the <zpz-md-calendar>
directive to add
a calendar view there.
<zpz-md-calendar></zpz-md-calendar>
See /demo/eg1.viewonly.html.
Use the ng-model
attribute to assign a local variable
to collect information from the <zpz-md-calendar>
directive
<zpz-md-calendar
ng-model='model'
></zpz-md-calendar>
Add a $scope.model
to your controller.
angular.module('YourApp').controller('yourController', [
/// other dependencies ...
'zpzMdCalendarSvc',
/// other dependencies ...
function(
/// other dependencies ...
zpzMdCalendarSvc
/// other dependencies ...
) {
$scope.model = null;
}
]);
You will be able to use $scope.model
after <zpz-md-calendar>
has
been initialised.
Add a ng-model
attribute to the <zpz-md-calendar>
directive.
<zpz-md-calendar
ng-model='model'
></zpz-md-calendar>
Add a $scope.model
to your controller.
angular.module('YourApp').controller('yourController', [
/// other dependencies ...
'zpzMdCalendarSvc',
/// other dependencies ...
function(
/// other dependencies ...
zpzMdCalendarSvc
/// other dependencies ...
) {
$scope.model = [
zpzMdCalendarSvc.createEvent(
'Event Title',
'Event Description',
// start timing
new Date(),
// end timing (optional)
new Date((new Date()).getTime() + (1000*60*60*24)),
// options (optional)
null,
// other data (optional)
{
address: '...'
contactPerson: 'John Doe',
contactNumber: '123456789'
}
)
];
}
]);
The ng-config
attribute takes in a configuration which will be merged with the
default configuration. To use the default configuration, leaving ng-config
empty
will result in the user of the default configuration.
<zpz-md-calendar
ng-model='model'
></zpz-md-calendar>
angular.module('YourApp').controller('yourController', [
/// other dependencies ...
'zpzMdCalendarSvc',
/// other dependencies ...
function(
/// other dependencies ...
zpzMdCalendarSvc
/// other dependencies ...
) {
/// other code ...
}
]);
<zpz-md-calendar
ng-config="config"
ng-model='model'
></zpz-md-calendar>
angular.module('YourApp').controller('yourController', [
/// other dependencies ...
'zpzMdCalendarSvc',
/// other dependencies ...
function(
/// other dependencies ...
zpzMdCalendarSvc
/// other dependencies ...
) {
/// use defaults
$scope.config = zpzMdCalendarSvc.constant.config.default;
/// other code ...
}
]);
[since v1.0.2]
The ng-config
variable if specified with an object merges the object properties
with the default configuration. Specify only the options you use.
<zpz-md-calendar
ng-config='config'
ng-model='model'
></zpz-md-calendar>
angular.module('YourApp').controller('yourController', [
/// other dependencies ...
'zpzMdCalendarSvc',
/// other dependencies ...
function(
/// other dependencies ...
zpzMdCalendarSvc
/// other dependencies ...
) {
/// use a custom Configuration
/// this sets the year navigation buttons to not show
$scope.config = {
view: {
display: {
navigation: {
year: false
}
}
}
};
/// other code ...
}
]);
See the /demo folder for an example of how to initialize zpzMdCalendar. The files are as follows:
demo
-> development
- config.js
- index.html
-> production
- config.js
- index.html
- data.js
- index.html
- index.js
Enhancement to allow for partial ngConfig specification such that the provided code in the partial configuration will be merged with the default configuration on view load.
Bug fix to allow for optional ngModel and ngConfig
Initial release
This section is for developers who wish to contribute to this project. Fork this repository, add your changes including test cases, make sure all existing/new test cases are passing, do a Gulp build and then submit a pull request.
Install the development dependencies via the following two commands:
npm install --dev
bower install --dev
This module contains all components concerning the logic behind zpzMdCalendar.
This module contains directives and the HTML templates.
Contains all constants used in zpzMdCalendar.
Facade class which contains methods so plugin users cam avoid accessing component internals directly.
Utility functions used in zpzMdCalendar.
This component stores a single event and it's associated title, description, start time, end time, options and any other data you might want to store.
This component stores an array of events and handles retrieval and storage of information.
This component represents the ngModel of a <zpz-md-calendar>
directive and allows the data to interact with the view.
This component represents the calendar view and is used by zpzMdCalendarModelObject to display items on the calendar.
This component is the controller for the <zpz-md-calendar>
directive.
Main component.
Component for the options button.
Component that displays the date in each calendar cell.
Component that displays the event indicators in each calendar cell.
Component that displays the navigation controllers.
Component that displays the days of the week.
Karma is used for testing. All functions asides from getters and
setters should have their own unit tests. After installation
of npm
and bower
development dependencies, run the following
command to start Karma:
karma start karma.conf.js
We use Gulp to build the component. Building consists of
placing all HTML files into the run()
segment of the module
zpzMdCalendar Templates via $templateCache, and concatenating
and minifying all CSS and JS files.
Run the following command to do a build:
gulp build
You may have to run this twice to compile the HTML properly. Look for changes in the reported size of the files.
To bump a version number so that it reflects in Bower, you need to run:
git tag -a vX.Y.Z -m "Functionality added"
X is the major version, Y is the minor version and Z is the patch version. Bump Z for bug fixes and minor enhancements. Bump Y for new user-directed functionality. Bump X for major UI and developer changes.
Send me a pull request and I will do the publishing on Bower and NPM.
Cheers!