Skip to content

Commit d9bca20

Browse files
committed
Merge pull request #11 from dalelotts/develop
feat(model-type): Able to store date in the model as a Date, moment,milliseconds, or custom format
2 parents 8eda862 + 7ea6347 commit d9bca20

22 files changed

+1429
-355
lines changed

.bowerrc

-3
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
build
23
coverage
34
lib-cov
45
bower_components

.jscsrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"disallowDanglingUnderscores": { "allExcept": ["_$compile_", "_$rootScope_"] },
3+
"disallowMultipleVarDecl": "strict",
4+
"preset": "crockford",
5+
"requireMultipleVarDecl": null,
6+
"requireVarDeclFirst": null,
7+
"validateIndentation": 2
8+
}

.jshintrc

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
// JSHint Default Configuration File (as on JSHint website)
3+
// See http://jshint.com/docs/ for more details
4+
5+
"maxerr" : 50, // {int} Maximum error before stopping
6+
7+
// Enforcing
8+
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9+
"camelcase" : true, // true: Identifiers must be in camelCase
10+
"curly" : true, // true: Require {} for every new block or scope
11+
"eqeqeq" : true, // true: Require triple equals (===) for comparison
12+
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
13+
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
14+
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
15+
"indent" : 2, // {int} Number of spaces to use for indentation
16+
"latedef" : "nofunc", // true: Require variables/functions to be defined before being used
17+
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
18+
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
19+
"noempty" : true, // true: Prohibit use of empty blocks
20+
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
21+
"nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment)
22+
"plusplus" : true, // true: Prohibit use of `++` & `--`
23+
"quotmark" : "single", // Quotation mark consistency:
24+
// false : do nothing (default)
25+
// true : ensure whatever is used is consistent
26+
// "single" : require single quotes
27+
// "double" : require double quotes
28+
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
29+
"unused" : true, // true: Require all defined variables be used
30+
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
31+
"maxparams" : false, // {int} Max number of formal params allowed per function
32+
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
33+
"maxstatements" : false, // {int} Max number statements per function
34+
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
35+
"maxlen" : false, // {int} Max number of characters per line
36+
37+
// Relaxing
38+
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
39+
"boss" : false, // true: Tolerate assignments where comparisons would be expected
40+
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
41+
"eqnull" : false, // true: Tolerate use of `== null`
42+
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
43+
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
44+
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
45+
// (ex: `for each`, multiple try/catch, function expression…)
46+
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
47+
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
48+
"funcscope" : false, // true: Tolerate defining variables inside control statements
49+
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
50+
"iterator" : false, // true: Tolerate using the `__iterator__` property
51+
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
52+
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
53+
"laxcomma" : false, // true: Tolerate comma-first style coding
54+
"loopfunc" : false, // true: Tolerate functions being defined in loops
55+
"multistr" : false, // true: Tolerate multi-line strings
56+
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
57+
"notypeof" : false, // true: Tolerate invalid typeof operator values
58+
"proto" : false, // true: Tolerate using the `__proto__` property
59+
"scripturl" : false, // true: Tolerate script-targeted URLs
60+
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
61+
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
62+
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
63+
"validthis" : false, // true: Tolerate using this in a non-constructor function
64+
65+
// Environments
66+
"browser" : true, // Web Browser (window, document, etc)
67+
"browserify" : false, // Browserify (node.js code in the browser)
68+
"couch" : false, // CouchDB
69+
"devel" : true, // Development/debugging (alert, confirm, etc)
70+
"dojo" : false, // Dojo Toolkit
71+
"jasmine" : true, // Jasmine
72+
"jquery" : false, // jQuery
73+
"mocha" : true, // Mocha
74+
"mootools" : false, // MooTools
75+
"node" : false, // Node.js
76+
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
77+
"prototypejs" : false, // Prototype and Scriptaculous
78+
"qunit" : false, // QUnit
79+
"rhino" : false, // Rhino
80+
"shelljs" : false, // ShellJS
81+
"worker" : false, // Web Workers
82+
"wsh" : false, // Windows Scripting Host
83+
"yui" : false, // Yahoo User Interface
84+
85+
// Custom Globals
86+
"globals" : {
87+
"angular" : true,
88+
"moment" : true
89+
}
90+
}

.npmignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.gitignore
2+
.idea
3+
.jshintignore
4+
.jshintrc
5+
.travis.yml
6+
angular-date-time-input.iml
7+
bower_components
8+
complexity
9+
coverage
10+
demo
11+
Gruntfile.js
12+
gulpfile.js
13+
karma.conf.js
14+
paths.js
15+
test

.travis.yml

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
sudo: false
12
language: node_js
3+
cache:
4+
directories:
5+
- node_modules
6+
notifications:
7+
email: none
28
node_js:
3-
- "0.10"
4-
5-
branches:
6-
except:
7-
- gh-pages
8-
9+
- '5'
910
before_install:
10-
- "export DISPLAY=:99.0"
11-
- "sh -e /etc/init.d/xvfb start"
12-
11+
- export DISPLAY=:99.0
12+
- sh -e /etc/init.d/xvfb start
1313
before_script:
14-
- npm install -g bower grunt-cli
15-
- bower install
16-
17-
script: "grunt --verbose"
14+
- npm prune
15+
script:
16+
- npm run test
17+
after_success:
18+
- npm run semantic-release
19+
branches:
20+
except:
21+
- "/^v\\d+\\.\\d+\\.\\d+$/"

Gruntfile.js

+11-41
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,22 @@
1-
/*globals module, require, process */
2-
1+
/*globals module, require */
2+
/*jslint vars:true */
33
module.exports = function (grunt) {
44
'use strict';
5+
56
// load all grunt tasks
67
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
78

8-
// Default task.
9-
grunt.registerTask('default', ['jshint', 'karma', 'coverage']);
10-
11-
var testConfig = function (configFile, customOptions) {
12-
var options = { configFile: configFile, keepalive: true };
13-
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
14-
return grunt.util._.extend(options, customOptions, travisOptions);
15-
};
16-
179
// Project configuration.
1810
grunt.initConfig({
19-
coverage: {
20-
options: {
21-
thresholds: {
22-
'statements': 100,
23-
'branches': 90,
24-
'lines': 100,
25-
'functions': 100
26-
},
27-
dir: 'coverage',
28-
root: ''
29-
}
30-
},
31-
karma: {
32-
unit: {
33-
options: testConfig('karma.conf.js')
34-
}
35-
},
36-
jshint: {
37-
files: ['src/*.js', 'test/**/*.js'],
11+
bump: {
3812
options: {
39-
curly: true,
40-
eqeqeq: true,
41-
immed: true,
42-
latedef: true,
43-
newcap: true,
44-
noarg: true,
45-
sub: true,
46-
boss: true,
47-
eqnull: true,
48-
globals: {}
13+
files: ['package.json', 'bower.json', 'README.md', 'src/js/*.js'],
14+
updateConfigs: [],
15+
commit: false,
16+
createTag: false,
17+
push: false,
18+
globalReplace: false
4919
}
5020
}
5121
});
52-
};
22+
};

README.md

+110-21
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,36 @@ Native AngularJS directive that allows user input of a date/time value. Valid da
88
#Dependencies
99

1010
Requires:
11-
* AngularJS 1.1.3 or higher (Not tested with 1.0.x)
11+
* AngularJS 1.4.x or higher
1212
* MomentJS 2.1.x or higher
1313

1414
#Testing
1515
We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:
1616

1717
```
18-
npm install -g grunt-cli
19-
npm install bower grunt
18+
npm install -g gulp
19+
npm install
20+
npm test
2021
```
2122

2223
The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in test\test.config.js
2324

2425
#Usage
25-
We use bower for dependency management. Add
26+
We use npm for dependency management. Add the following to your package
2627

27-
```json
28-
dependencies: {
29-
"angular-date-time-input": "latest"
30-
}
28+
```shell
29+
npm install angular-date-time-input --save
3130
```
32-
33-
To your bower.json file. Then run
34-
35-
```html
36-
bower install
37-
```
38-
39-
This will copy the angular-date-time-input files into your components folder, along with its dependencies.
31+
This will copy the angular-date-time-input files into your node_modules folder, along with its dependencies.
4032

4133
Load the script files in your application:
4234
```html
43-
<script type="text/javascript" src="components/moment/moment.js"></script>
44-
<script type="text/javascript" src="components/angular/angular.js"></script>
45-
<script type="text/javascript" src="components/angular-date-time-input/src/js/dateTimeInput.js"></script>
35+
<script type="text/javascript" src="node_modules/moment/moment.js"></script>
36+
<script type="text/javascript" src="node_modules/angular/angular.js"></script>
37+
<script type="text/javascript" src="node_modules/angular-date-time-input/src/js/dateTimeInput.js"></script>
4638
```
4739

48-
Add the date module as a dependency to your application module:
40+
Add this module as a dependency to your application module:
4941

5042
```html
5143
var myAppModule = angular.module('MyApp', ['ui.dateTimeInput'])
@@ -59,4 +51,101 @@ Apply the directive to your form elements:
5951

6052
## Options
6153

62-
The value of the date-time-input attribute must be a valid format string. See MomentJS documentation for valid formats.
54+
The value of the date-time-input attribute is the format the date values will be displayed.
55+
56+
Nota bene: The value saved in the model is, by default, a JavaScript ```Date``` object, not a string.
57+
This can result in differences between what is seen in the model and what is displayed.
58+
59+
### date-time-input
60+
61+
This option controls the way the date is displayed in the view, not the model.
62+
63+
```html
64+
<input data-date-time-input="YYYY-MMM-DD" />
65+
```
66+
See MomentJS documentation for valid formats.
67+
68+
### date-formats
69+
70+
This option defines additional input formats that will be accepted.
71+
72+
```html
73+
<input ... data-date-formats="['YYYY-MMM-DD']" />
74+
```
75+
76+
Nota bene: Parsing multiple formats is considerably slower than parsing a single format.
77+
If you can avoid it, it is much faster to parse a single format.
78+
79+
See [MomentJS documentation] (http://momentjs.com/docs/#/parsing/string-formats) for more information.
80+
81+
### date-parse-strict
82+
83+
This option enables/disables strict parsing of the input formats.
84+
85+
```html
86+
<input ... data-date-parse-strict="false" />
87+
```
88+
89+
### model-type
90+
91+
```html
92+
<input ... data-model-type="Date | moment | milliseconds | [custom format]" />
93+
```
94+
95+
Default: ```'Date'```
96+
97+
Specifies the data type to use when storing the selected date in the model.
98+
99+
Accepts any string value, but the following values have special meaning (these values are case sensitive) :
100+
* ```'Date'``` stores a Date instance in the model. Will accept Date, moment, milliseconds, and ISO 8601 strings as initial input from the model
101+
* ```'moment'``` stores a moment instance in the model. Accepts the same initial values as ```Date```
102+
* ```'milliseconds'``` store the epoch milliseconds (since 1-1-1970) in the model. Accepts the same initial values as ```Date```
103+
104+
Any other value is considered a custom format string.
105+
106+
##Contributing
107+
108+
See [Contributing] (contributing.md) document
109+
110+
## License
111+
112+
angular-date-time-input is released under the MIT license and is copyright 2016 Knight Rider Consulting, Inc.. Boiled down to smaller chunks, it can be described with the following conditions.
113+
114+
## It requires you to:
115+
116+
* Keep the license and copyright notice included in angular-date-time-input's CSS and JavaScript files when you use them in your works
117+
118+
## It permits you to:
119+
120+
* Freely download and use angular-date-time-input, in whole or in part, for personal, private, company internal, or commercial purposes
121+
* Use angular-date-time-input in packages or distributions that you create
122+
* Modify the source code
123+
* Grant a sublicense to modify and distribute angular-date-time-input to third parties not included in the license
124+
125+
## It forbids you to:
126+
127+
* Hold the authors and license owners liable for damages as angular-date-time-input is provided without warranty
128+
* Hold the creators or copyright holders of angular-date-time-input liable
129+
* Redistribute any piece of angular-date-time-input without proper attribution
130+
* Use any marks owned by Knight Rider Consulting, Inc. in any way that might state or imply that Knight Rider Consulting, Inc. endorses your distribution
131+
* Use any marks owned by Knight Rider Consulting, Inc. in any way that might state or imply that you created the Knight Rider Consulting, Inc. software in question
132+
133+
## It does not require you to:
134+
135+
* Include the source of angular-date-time-input itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it
136+
* Submit changes that you make to angular-date-time-input back to the angular-date-time-input project (though such feedback is encouraged)
137+
138+
The full angular-date-time-input license is located [in the project repository](https://github.com/dalelotts/angular-date-time-input/blob/master/LICENSE) for more information.
139+
140+
141+
## Donating
142+
Support this project and other work by Dale Lotts via [gittip][gittip-dalelotts].
143+
144+
[![Support via Gittip][gittip-badge]][gittip-dalelotts]
145+
146+
[gittip-badge]: https://rawgithub.com/twolfson/gittip-badge/master/dist/gittip.png
147+
[gittip-dalelotts]: https://www.gittip.com/dalelotts/
148+
149+
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
150+
[license-url]: LICENSE
151+

0 commit comments

Comments
 (0)